hirosystems/ordinals-api

Ordhook jumps over the middle blocks events, cannot recover from the missing period.

Closed this issue · 2 comments

I use hirosystems/ordinals-api to register predicates and get events from the start_block , it runs steadily the first time, but I find the event jumps over the middle block when ordhook receives a new block from ZMQ.
So the pg data from hirosystems/ordinals-api misses some blocks.

When I start from the missing block, it shows a unique key conflict in hirosystems/ordinals-api.

{
    "level":"error",
    "time":"2023-11-08T08:57:00.689Z",
    "pid":986544,
    "hostname":"n-btcmain-full-0lo11ltx2",
    "name":"chainhook-client",
    "err":{
        "type":"PostgresError",
        "message":"duplicate key value violates unique constraint \"brc20_events_genesis_location_id_key\"",
        "stack":"PostgresError: duplicate key value violates unique constraint \"brc20_events_genesis_location_id_key\"\n    at ErrorResponse (/data2/ordinals-api/node_modules/postgres/cjs/src/connection.js:769:26)\n    at handle (/data2/ordinals-api/node_modules/postgres/cjs/src/connection.js:472:6)\n    at Socket.data (/data2/ordinals-api/node_modules/postgres/cjs/src/connection.js:313:9)\n    at Socket.emit (node:events:514:28)\n    at addChunk (node:internal/streams/readable:376:12)\n    at readableAddChunk (node:internal/streams/readable:349:9)\n    at Readable.push (node:internal/streams/readable:286:10)\n    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)\n    at TCP.callbackTrampoline (node:internal/async_hooks:130:17)\n    at cachedError (/data2/ordinals-api/node_modules/postgres/cjs/src/query.js:171:23)\n    at new Query (/data2/ordinals-api/node_modules/postgres/cjs/src/query.js:36:24)\n    at sql (/data2/ordinals-api/node_modules/postgres/cjs/src/index.js:111:11)\n    at /data2/ordinals-api/dist/src/meta-protocols/brc-20/pg/brc20-pg-store.js:87:39",
        "name":"PostgresError",
        "severity_local":"ERROR",
        "severity":"ERROR",
        "code":"23505",
        "detail":"Key (genesis_location_id)=(168479060) already exists.",
        "schema_name":"ordinals_api",
        "table_name":"brc20_events",
        "constraint_name":"brc20_events_genesis_location_id_key",
        "file":"nbtinsert.c",
        "line":"664",
        "routine":"_bt_check_unique"
    },
    "msg":"ChainhookEventObserver error processing payload"
}

@taoyouxian thanks for the report, we'll release a fix for it soon.

Addressed in v1.2.0