-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Use historical hashing for ExecutionStateView
#4977
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
base: main
Are you sure you want to change the base?
Conversation
MathieuDutSik
left a comment
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.
This is definitely better than having the hash set to zero.
That is why I approve it.
Otherwise, the problem of historical hash is that if we have
10000 batches being inserted, then we have to process every
one of them in order to get to a state that we are sure is the right
one by the batches. That is why it may be advantageous to have
a checkpointing where the block creator can choose at a given
step that the block being created is the classic hash of the state,
not of the batch. Maybe an issue can be created on this point.
## Motivation The derived implementation of `View::context` currently returns just the context of the first sub-view of the view. This means that if a view A has a sub-view B, and view B has a sub-view C, when A calls `context()` on B and assumes that its own base key is eg. a byte shorter than what it gets as a result, it will in fact get a context with C's base key, which may lead to wrong results if B also appends some bytes to the base key before passing the context on to C (which happens in hashable wrappers, for example!). ## Proposal Make the implementation of `context()` in all views correctly trim the base key contained in the context before returning the value. This unfortunately introduces the necessity of cloning the context and returning it by value instead of by reference. An alternative (but somewhat more complicated) solution would be to require _all_ views to store their inner contexts, and make the `View` derive macro require a `context` field in all structs for which `View` is derived. ## Test Plan CI will catch regressions. This was also manually confirmed to fix a bug that surfaced in #4977. ## Release Plan - Nothing to do / These changes follow the usual release cycle. - This bug may be causing some issues on the testnet, but the fix cannot be safely backported without a complex migration. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
ed8d0c1 to
27b629d
Compare
Motivation
Hashing of all the data in
ExecutionStateViews became a bottleneck in large chain states.Proposal
Replace the current hashing mechanism of
ExecutionStateViews with historical hashing.Test Plan
CI will catch regressions
Release Plan
Links