hirosystems / docs

Hiro developer documentation website
https://docs.hiro.so/
32 stars 51 forks source link

[documentation] Restoring api node #637

Closed radicleart closed 4 months ago

radicleart commented 4 months ago

Hey!

Running into difficulties following this guide on restoring from archived data

Ubuntu: 23.10 Stacks-node: stacks-core-2.4.0.1.0 (my node reports stacks-node 0.0.1 (:, debug build, linux [x86_64]) ?) Stacks-blockchain-api: 7.9.0 Postgres: 15

I running stacks-node and postgres as services on the host and the api in docker (have tried several combinations).

Restore using pg_restore

Couple of issues;

  1. pg_restore fails as it requires the database to exist. I can rerun after creating stacks_blockchain_api db but noticed a line in the restore log that errors when it also tries to create the database
  2. after creating the db pg_restore runs to completion and on spinning up the node I see correct tip height here: http://leibniz.brightblock.org:3999/v2/info BUT do not see the contract info e.g. http://leibniz.brightblock.org:3999/extended/v1/contract/ST1R1061ZT6KPJXQ7PAXPFB6ZAZ6ZWW28G8HXK9G5.asset-3

Restore using tsv import

I tried importing the tsv file using;

node ./lib/index.js import-events --file /mnt/stacks-testnet/archives/testnet-stacks-blockchain-api-7.8.2-20240322.tsv --wipe-db --force

but get;

Error: UNDEFINED_VALUE: Undefined values are not allowed

any help would be great - I've tried syncing from genesis using docker containers but never managed to catch up wth the (mainnet) tip height.

radicleart commented 4 months ago

UPDATE

Just noticed the api 7.9 releases tagged with nakamoto - after dropping back to 7.8.2.

$ node ./lib/index.js import-events --file /mnt/bitcoin-testnet/stacks-testnet/testnet-stacks-blockchain-api-7.8.2.tsv --wipe-db --force

(node:128790) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
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 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 ReadyForQuery (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/connection.js:541:27)
    at handle (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/connection.js:476:6)
    at Socket.data (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/node_modules/postgres/cjs/src/connection.js:315:9)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Socket.Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
    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 databaseHasData (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/src/postgres/migrations.ts:109:50)
    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 databaseHasData (/mnt/bitcoin-testnet/stacks-testnet/stacks-blockchain-api-7.8.2/node_modules/@hirosystems/api-toolkit/src/postgres/migrations.ts:109:50) {
  code: 'UNDEFINED_VALUE
radicleart commented 4 months ago

Found some new instructions - closing this for now.