fix: bind keyed-collection keys into the SSZ state root#295
Open
matthias-wright wants to merge 2 commits into
Open
fix: bind keyed-collection keys into the SSZ state root#295matthias-wright wants to merge 2 commits into
matthias-wright wants to merge 2 commits into
Conversation
d08e65a to
73a84cd
Compare
|
LGTM! This commits the Small non-blocking follow-up: it would be useful to expose the new key leaves through |
73a84cd to
c8e8cab
Compare
Collaborator
Author
|
Update(c8e8cab):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #293 (which builds on #292 and #291).
Addresses #257.
The SSZ tree committed validator_accounts and added_validators as value-only positional lists, so the BTreeMap keys were not bound by the state root. Two states differing only in a map key produced the same root, and validator-account proofs bound a value without binding the pubkey it belongs to.
Changes:
node_pubkeyas a 9th field; per-validator subtree grows 8 → 16 leaves (depth 3 → 4). Threaded the map key through set_validator_fields and update_/insert_validator_at_slot; rebuild_validators iterates by (key, account); set_account passes the pubkey.epochas a 3rd per-item field; subtree grows 2 → 4 leaves (depth 1 → 2). rebuild_added_validators carries the epoch through the flatten.top_gindex << (sd - log_block + 1)(log_block = fields_per_item.ilog2()), so it adapts to the new depths.A field/whole-item proof's branch now includes the key, so the proof self-binds identity. ValidatorAccount::hash_tree_root no longer equals the per-validator subtree root (the root now includes the node pubkey).