hirosystems / stacks-blockchain-api

API for the Stacks blockchain
https://stacks-blockchain-api.vercel.app
GNU General Public License v3.0
170 stars 108 forks source link

Error running event replay #1909

Open radicleart opened 3 months ago

radicleart commented 3 months ago

Describe the bug UNDEFINED_VALUE: Undefined values are not allowed is returned from running the event replay version 2 process.

To Reproduce Steps to reproduce the behavior:

Note: I performed steps 1-3 on my macbook pro (32G) and then rsynced to target ubuntu server.

  1. Downloaded archive
  2. Ran: python3 -m event_replay --tsv-file ../testnet-stacks-blockchain-api-7.8.2-20240322.gz
  3. In postgres:
    • drop database stacks_blockchain_api;
    • CREATE DATABASE stacks_blockchain_api WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'en_US.UTF-8' OWNER = 'postgres';
  4. rsync -aP events $USER@$SERVER/.../events
  5. cd stacks-blockchain-api-7.8.2
  6. Ran: STACKS_EVENTS_DIR="/mnt/bitcoin-testnet/stacks-testnet/events-9.8.2/events" NODE_OPTIONS="--max-old-space-size=4096" STACKS_CHAIN_ID=2147483648 node ./lib/index.js from-parquet-events --workers=2

Expected behavior Postgres database to be populated.

Console log

stacks-blockchain-api$ STACKS_EVENTS_DIR="/mnt/bitcoin-testnet/stacks-testnet/events-9.8.2/events" NODE_OPTIONS="--max-old-space-size=4096" STACKS_CHAIN_ID=2147483648 node ./lib/index.js from-parquet-events --workers=2
(node:155347) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
{"level":"info","time":"2024-03-25T12:31:31.451Z","pid":155347,"hostname":"leibniz.brightblock.org","name":"stacks-blockchain-api","component":"event-replay","msg":"Cleaning up the Database"}
Error: UNDEFINED_VALUE: Undefined values are not allowed
    at handleValue (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/types.js:83:20)
    at stringifyValue (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/types.js:113:5)
    at stringify (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/types.js:100:16)
    at build (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/connection.js:223:20)
    at Object.execute (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/connection.js:167:7)
    at Query.handler (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/index.js:294:15)
    at Query.handle (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/query.js:140:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at cachedError (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/query.js:170:23)
    at new Query (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/query.js:36:24)
    at sql (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/index.js:112:11)
    at relNamesQuery (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/src/postgres/migrations.ts:146:79) {
  code: 'UNDEFINED_VALUE'
}
from-parquet-events process failed

Environment (please complete the following information):

OS: Ubuntu 23.10 mantic Stacks-blockchain-api: 7.8.2 (testnet) Postgres: 15 (7.8.2) psql (PostgreSQL) 15.6 (Ubuntu 15.6-1.pgdg23.10+1) pg_restore (PostgreSQL) 15.6 (Ubuntu 15.6-1.pgdg23.10+1)

Additional information

Same error received trying to load the raw TSV file using version 1 of event replay.

zone117x commented 2 months ago

@csgui do we know what caused this bug? Will it be fixed by https://github.com/hirosystems/stacks-blockchain-api/pull/1925 ?

csgui commented 2 months ago

@zone117x No, this seems an issue with the local environment. Note that the same issue appears when trying to run even the first version of the event-replay.

@radicleart can you please clean-up the node_modules under your API folder stacks-blockchain-api-7.8.2 and try to run the event-replay again?