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

Feat/add all indexes #3029

Merged
merged 15 commits into from
Feb 1, 2022
Merged

Feat/add all indexes #3029

merged 15 commits into from
Feb 1, 2022

Conversation

jcnelson
Copy link
Member

This PR makes it so all database indexes in all databases are instantiated unconditionally, in an idempotent fashion, after all migrations have been applied. This way, if we want to add future indexes in subsequent PRs and have them take effect on existing chain state, we can do so just by adding the index-creation command to the list of indexes to create.

While testing this, I uncovered and fixed two small bugs that arise only when a node is stopped and restarted during boot-up:

  • When booting up, the neighbor-walk logic should always try to walk to a bootstrap peer during IBD. This way, the inventory state-machine will be able to resume crawling bootstrap peers right away, which causes block downloads to resume right away. Before, it would take potentially a long time for the node to resume downloading blocks, because it would only stumble upon a bootstrap peer by chance.

  • When booting up from existing chainstate, the burnchain controller would download 2100 Bitcoin blocks (1 reward cycle) unconditionally from when it left off, before starting the runloop and chains coordinator. This PR makes it so that the node will instead just resume the main run loop and chains coordinator, so that both Bitcoin and Stacks blocks can proceed in parallel.

@@ -653,6 +654,11 @@ impl MemPoolDB {
// apply all migrations
MemPoolDB::apply_schema_migrations(&mut tx)?;

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't you want to add the index creation code snippet to the open function as well? Same comment for other dbs (like open_db for StacksChainState)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes; thanks for catching that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

src/net/neighbors.rs Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 31, 2022

Codecov Report

Merging #3029 (890f121) into develop (ff18dfc) will increase coverage by 0.23%.
The diff coverage is 83.63%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3029      +/-   ##
===========================================
+ Coverage    82.42%   82.66%   +0.23%     
===========================================
  Files          242      242              
  Lines       195691   195780      +89     
===========================================
+ Hits        161301   161833     +532     
+ Misses       34390    33947     -443     
Impacted Files Coverage Δ
src/burnchains/burnchain.rs 89.75% <40.00%> (-0.76%) ⬇️
testnet/stacks-node/src/run_loop/neon.rs 80.63% <72.22%> (-0.59%) ⬇️
src/chainstate/stacks/db/mod.rs 86.78% <87.50%> (+<0.01%) ⬆️
src/chainstate/burn/db/sortdb.rs 95.05% <90.90%> (-0.07%) ⬇️
src/net/db.rs 91.07% <92.85%> (+0.11%) ⬆️
src/burnchains/db.rs 94.79% <94.11%> (-0.05%) ⬇️
src/core/mempool.rs 84.13% <100.00%> (+0.08%) ⬆️
src/net/atlas/db.rs 91.78% <100.00%> (+0.27%) ⬆️
src/net/neighbors.rs 38.33% <100.00%> (+0.01%) ⬆️
src/net/p2p.rs 58.87% <100.00%> (+0.84%) ⬆️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff18dfc...890f121. Read the comment docs.

Copy link
Member

@kantai kantai left a comment

Choose a reason for hiding this comment

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

LGTM -- just had one comment

@jcnelson jcnelson merged commit 8c7dc19 into develop Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants