Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate: bump up the spvchain database version in filter indexer migration #1097

Merged
merged 1 commit into from
Nov 1, 2022

Conversation

theanmolsharma
Copy link
Collaborator

Closes #1095

@codecov-commenter
Copy link

Codecov Report

Merging #1097 (a50785c) into master (36bf60e) will decrease coverage by 0.00%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #1097      +/-   ##
==========================================
- Coverage   69.35%   69.35%   -0.01%     
==========================================
  Files         158      158              
  Lines       26586    26586              
==========================================
- Hits        18439    18438       -1     
- Misses       8147     8148       +1     
Impacted Files Coverage Δ
lib/net/hostlist.js 50.00% <0.00%> (-0.16%) ⬇️
lib/golomb/reader.js 88.67% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

await updateChainVersion(chainDB, 7);
// update spvChainDB if it exists
const spvchain = path.resolve(process.argv[2], '../spvchain');
if (await fs.exists(spvchain)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to add the same check for full node chain directory as well. If you have only ever used bcoin in spv mode, there will not be a ~/.bcoin/chain directory and the script will fail.

At the same time, the migrate/latest script also needs to be more clever, because if index doesn't exist we STILL need to run that script in order to bump the chain and/or spvchain databases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@pinheadmz
Copy link
Member

At the same time, the migrate/latest script also needs to be more clever, because if index doesn't exist we STILL need to run that script in order to bump the chain and/or spvchain databases.

still needs this fix I think:

--> migrate/latest ~/.bcoin-spv-only
Opened /Users/matthewzipkin/.bcoin-spv-only/spvchain.
Already upgraded.
Migration complete.
Opened /Users/matthewzipkin/.bcoin-spv-only/wallet.
Checking version.
Updating wallets...
Updated 1 wallets.
Checking version.
Updating version to 8.
Migration complete.
--> bcoin --spv --prefix ~/.bcoin-spv-only
[info] (chain) Chain is loading.
[info] (chain) Checkpoints are enabled.
[info] (chaindb) Opening ChainDB...
Error: Database version mismatch for database: "chain". Please run a data migration before opening.
    at DB.verify (/Users/matthewzipkin/Desktop/work/bcoin/node_modules/bdb/lib/db.js:568:13)
    at async ChainDB.open (/Users/matthewzipkin/Desktop/work/bcoin/lib/blockchain/chaindb.js:65:5)
    at async Chain.open (/Users/matthewzipkin/Desktop/work/bcoin/lib/blockchain/chain.js:89:5)
    at async SPVNode.open (/Users/matthewzipkin/Desktop/work/bcoin/lib/node/spvnode.js:148:5)
    at async /Users/matthewzipkin/Desktop/work/bcoin/bin/spvnode:42:3

…ation

Signed-off-by: theanmolsharma <anmolsharma0234@gmail.com>
@pinheadmz
Copy link
Member

Ok I think this is done, thanks!

Tested this morning with a ton of configurations against a regtest blockchain with thousands of blocks and tens of thousands of transactions.

  1. full node
  2. full node with all indexers
  3. spv node
  4. spv sharing root data directory with (1)
  5. spv sharing root data directory with (2)

Each instance was synced on bcoin v2.0.0 and then duplicated (ten total tests). Tested by migrating with migrate/latest and again with migrate/indexerdb0to1. Every instance migrated successfully and restarted correctly and continued syncing.

@pinheadmz pinheadmz merged commit a44a7de into bcoin-org:master Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

migrate/latest and migrate/indexerdb0to1 need spvchain awareness
3 participants