-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: reset trie updates on make_canonical #8370
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm pending @rakita
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one nit, but lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, optional suggestion re standalone function, but didn't check if viable
.filter_map(|child| self.block_indices().get_blocks_chain_id(&child)) | ||
.collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah we need this collect because this resides in state and the compiler doesn't allow us to borrow here.
maybe we could move this to a function in state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattsse exactly, with a for_each after the filter_map the second closure (in for_each) required exclusive access to self.state.chains but was already borrowed in the first closure (filter_map) due to the use of *self.
Not sure if moving the code to a function in state could help, the first part (determining the dependent blocks that extend the old tip and their chain ids) is done using the indices, not the state, and the second one (querying the chains associated with each chain id) is done using the state, maybe I'm missing something?
I've pushed changes to prevent creating the temporary vector using nested if lets, ptal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
Reset trie updates for the rest of the children forking from the canonical tip after a fork choice update.