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 block_body_indices for BlockchainProvider2 #10106

Merged
merged 5 commits into from
Aug 7, 2024

Conversation

Rjected
Copy link
Member

@Rjected Rjected commented Aug 5, 2024

I would like some review on the correctness of this method, specifically whether or not next_tx is accurate. Previously this would just go to the database, when it should be possible to fetch block body indices for the in memory canonical state.

@Rjected Rjected added C-bug An unexpected or incorrect behavior A-db Related to the database A-blockchain-tree Related to sidechains, reorgs and pending blocks labels Aug 5, 2024
self.database.block_body_indices(number)
if let Some(indices) = self.database.block_body_indices(number)? {
Ok(Some(indices))
} else if self.canonical_in_memory_state.hash_by_number(number).is_some() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should also use the BlockState and traverse its parent blocks for this and the anchor block number to read the indices from disk

@Rjected Rjected force-pushed the dan/add-block-body-indices-provider-two branch from ae7bb25 to d04050b Compare August 7, 2024 15:30
let mut parent_chain = state.parent_state_chain();
parent_chain.reverse();
let anchor_num = state.anchor().number;
let mut stored_indices = self
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I'm reading this correctly, then we need to do a + 1 here on the first_tx_num

// Get id for the next tx_num of zero if there are no transactions.
let mut next_tx_num = tx_block_cursor.last()?.map(|(id, _)| id + 1).unwrap_or_default();

@Rjected Rjected added this pull request to the merge queue Aug 7, 2024
@mattsse mattsse removed this pull request from the merge queue due to a manual request Aug 7, 2024
@Rjected Rjected added this pull request to the merge queue Aug 7, 2024
Merged via the queue into main with commit a706206 Aug 7, 2024
33 checks passed
@Rjected Rjected deleted the dan/add-block-body-indices-provider-two branch August 7, 2024 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-blockchain-tree Related to sidechains, reorgs and pending blocks A-db Related to the database C-bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants