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

Enforce block index invariants in chainstate #1708

Merged
merged 27 commits into from
Apr 15, 2024

Conversation

ImplOfAnImpl
Copy link
Contributor

  • is_persistent flag was added to BlockIndex, which means that this BlockIndex will never be deleted (until we implement purging, that is). In practice, a BlockIndex is persistent iff the corresponding Block is in the chainstate db.
  • In ChainstateInterface, get_block_index/get_gen_block_index were replaced with get_persistent_block_index/get_any_block_index and get_persistent_gen_block_index/get_any_gen_block_index; the get_persistent variants only return a BlockIndex is it's marked as "persistent".
  • Some block index related consistency checks were added to TestFramework.
  • Chainstate consistency checks were added, which are performed once at startup and then after a block is processed or invalidated; they are enabled by default for regtest only (but can be enabled via a command-line argument for mainnet and testnet too).

Copy link
Collaborator

@TheQuantumPhysicist TheQuantumPhysicist left a comment

Choose a reason for hiding this comment

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

First round done. I'll review again tomorrow.

Copy link
Member

@azarovh azarovh left a comment

Choose a reason for hiding this comment

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

Looks good. Though I'm not a fan of new functions in BlockchainStorageRead and it feels like they belong to chainstate/storage/src/internal/expensive.rs. But I don't see the way to actually do that so let it be.

@ImplOfAnImpl ImplOfAnImpl force-pushed the enforce_block_index_invariants branch from aa59061 to 1484d16 Compare April 4, 2024 18:13
@ImplOfAnImpl ImplOfAnImpl merged commit cf4d058 into master Apr 15, 2024
23 checks passed
@ImplOfAnImpl ImplOfAnImpl deleted the enforce_block_index_invariants branch April 15, 2024 14:40
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.

None yet

4 participants