-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
Signed-off-by: Guillaume Ballet <[email protected]>
core/block_validator.go
Outdated
// 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 |
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.
} // Verify that the advertised root is correct before | |
} | |
// Verify that the advertised root is correct before |
// 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) | ||
} |
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.
The parent has most definitely already been loaded before, see if it's possible to pass it as a parameter.
core/block_validator.go
Outdated
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) | ||
} | ||
} | ||
} |
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'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]>
Nothing to salvage, closing. |
This is one of the conclusions from the geth retreat: the contents of proof and witness should be validated, in order to avoid bloating.