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

verify block witness and proof #496

Closed
wants to merge 2 commits into from

Conversation

gballet
Copy link
Owner

@gballet gballet commented Sep 13, 2024

This is one of the conclusions from the geth retreat: the contents of proof and witness should be validated, in order to avoid bloating.

Signed-off-by: Guillaume Ballet <[email protected]>
// Verify the proof
trie.DeserializeAndVerifyVerkleProof(block.ExecutionWitness().VerkleProof, parent.Root.Bytes(), block.Root().Bytes(), block.ExecutionWitness().StateDiff)

} // Verify that the advertised root is correct before
Copy link
Owner Author

Choose a reason for hiding this comment

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

Suggested change
} // Verify that the advertised root is correct before
}
// Verify that the advertised root is correct before

Comment on lines +158 to +162
// Open the pre-tree to prove the pre-state against
parent := v.bc.GetHeaderByNumber(header.Number.Uint64() - 1)
if parent == nil {
return fmt.Errorf("nil parent header for block %d", header.Number)
}
Copy link
Owner Author

Choose a reason for hiding this comment

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

The parent has most definitely already been loaded before, see if it's possible to pass it as a parameter.

Comment on lines 138 to 156
keys := statedb.Witness().Keys()
var key [32]byte
for _, stemdiff := range block.ExecutionWitness().StateDiff {
copy(key[:31], stemdiff.Stem[:])
for _, suffixdiff := range stemdiff.SuffixDiffs {
key[31] = suffixdiff.Suffix

var found bool
for _, k := range keys {
if bytes.Equal(k, key[:]) {
found = true
break
}
}
if !found {
return fmt.Errorf("superfluous key %x could not be found in witness", key)
}
}
}
Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm only checking that the leaves from the block witness are present in the destination witness, because we are targeting state bloat. It could be that the witness does not contain all necessary leaves for stateless execution. This should be checked as well, either by execution (slow) or by just checking that there is the exact same amount of leaves.

Signed-off-by: Guillaume Ballet <[email protected]>
@gballet
Copy link
Owner Author

gballet commented Oct 29, 2024

Nothing to salvage, closing.

@gballet gballet closed this Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant