-
Notifications
You must be signed in to change notification settings - Fork 191
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: World State Re-orgs #9035
Conversation
…ges into ag/world-state
…ges into ag/world-state
This PR fixes a bug in the block synbc process of indexed trees
); | ||
}; | ||
|
||
const compareSnapshots = async (left: MerkleTreeReadOperations, right: MerkleTreeReadOperations) => { |
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.
Isn't this the same code as compareChains above? Either way, I'd move this to test utils, and loop over MerkleTreeId to make it more manageable.
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.
Done
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.
if (blockNumber == 0) { | ||
throw std::runtime_error("Invalid block number"); | ||
} |
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.
Don't we ever request the sibling path for the genesis block (0) on the archive tree? Seems not, since this is not blowing up, but I'd've expected to be possible to fetch it?
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.
I don't believe so.
if (blockNumber == 0) { | ||
throw std::runtime_error("Invalid block number"); | ||
} |
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.
Does this mean we cannot unwind to genesis, which means initial epoch cannot be unwound?
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.
Also, should we check we are not accidentally removing the finalised block, both here and when removing historical? (maybe it's checked somewhere else)
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.
Yes, the api here is 'off by one' compared to TS. So unwinding block 1 leaves you at block 0.
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.
Will protect against removing the current finalised block in either direction.
uint32_t p = static_cast<uint32_t>(std::log2(highest_index + 1)) + 1; | ||
index_t span = static_cast<uint32_t>(std::pow(2, p)); | ||
uint64_t numBatches = workers_->num_threads(); | ||
uint32_t indexPower2Ceil = static_cast<uint32_t>(std::ceil(std::log2(highest_index + 1))); |
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.
Maybe something like this is safer than relying on floating point?
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.
BB has some helpers in "numeric" that might be useful: https://github.com/AztecProtocol/aztec-packages/blob/master/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.hpp
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.
Done, that's much better.
This PR adds pruning and re-org support to the native world state.