Skip to content

Commit 99283b1

Browse files
committed
use the keys passed with the proof in AddPostValuesToProof
Signed-off-by: Guillaume Ballet <[email protected]>
1 parent c620056 commit 99283b1

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

cmd/evm/internal/t8ntool/execution.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,14 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
349349
var (
350350
verkleProof *verkle.Proof
351351
statelessProof *verkle.VerkleProof
352-
keys = statedb.Witness().Keys()
353352
proofTrie *trie.VerkleTrie
354353
)
355354
if chainConfig.IsVerkle(big.NewInt(int64(pre.Env.Number)), pre.Env.Timestamp) {
356355
if err := overlay.OverlayVerkleTransition(statedb, common.Hash{}, chainConfig.OverlayStride); err != nil {
357356
return nil, nil, fmt.Errorf("error performing the transition, err=%w", err)
358357
}
359358

359+
keys := statedb.Witness().Keys()
360360
if len(keys) > 0 && vtrpre != nil {
361361
switch tr := statedb.GetTrie().(type) {
362362
case *trie.VerkleTrie:
@@ -382,7 +382,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
382382
// Add the witness to the execution result
383383
var statelessDiff verkle.StateDiff
384384
if chainConfig.IsVerkle(big.NewInt(int64(pre.Env.Number)), pre.Env.Timestamp) && verkleProof != nil {
385-
err = trie.AddPostValuesToProof(keys, proofTrie, verkleProof)
385+
err = trie.AddPostValuesToProof(proofTrie, verkleProof)
386386
if err != nil {
387387
return nil, nil, fmt.Errorf("error adding post values to proof: %w", err)
388388
}

consensus/beacon/consensus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
421421
// Assemble and return the final block.
422422
block := types.NewBlockWithWithdrawals(header, txs, uncles, receipts, withdrawals, trie.NewStackTrie(nil))
423423
if chain.Config().IsVerkle(header.Number, header.Time) && chain.Config().ProofInBlocks {
424-
err := trie.AddPostValuesToProof(keys, state.GetTrie().(*trie.VerkleTrie), proof)
424+
err := trie.AddPostValuesToProof(state.GetTrie().(*trie.VerkleTrie), proof)
425425
if err != nil {
426426
return nil, fmt.Errorf("error adding post values to proof: %w", err)
427427
}

core/block_validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
153153
return fmt.Errorf("invalid merkle root (remote: %x local: %x) dberr: %w", header.Root, root, statedb.Error())
154154
}
155155
if blockEw := block.ExecutionWitness(); blockEw != nil {
156-
err := trie.AddPostValuesToProof(keys, statedb.GetTrie().(*trie.VerkleTrie), proof)
156+
err := trie.AddPostValuesToProof(statedb.GetTrie().(*trie.VerkleTrie), proof)
157157
if err != nil {
158158
return fmt.Errorf("error adding post values to proof: %w", err)
159159
}

trie/verkle.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,14 @@ func (trie *VerkleTrie) IsVerkle() bool {
290290
return true
291291
}
292292

293-
func AddPostValuesToProof(keys [][]byte, postroot *VerkleTrie, proof *verkle.Proof) error {
294-
proof.PostValues = make([][]byte, len(keys))
293+
func AddPostValuesToProof(postroot *VerkleTrie, proof *verkle.Proof) error {
294+
proof.PostValues = make([][]byte, len(proof.Keys))
295295
if postroot != nil {
296-
// keys were sorted already in the above GetcommitmentsForMultiproof.
297296
// Set the post values, if they are untouched, leave them `nil`
298-
for i := range keys {
299-
val, err := postroot.root.Get(keys[i], nil)
297+
for i := range proof.Keys {
298+
val, err := postroot.root.Get(proof.Keys[i], nil)
300299
if err != nil {
301-
return fmt.Errorf("error getting post-state value for key %x: %w", keys[i], err)
300+
return fmt.Errorf("error getting post-state value for key %x: %w", proof.Keys[i], err)
302301
}
303302
if !bytes.Equal(proof.PreValues[i], val) {
304303
proof.PostValues[i] = val

0 commit comments

Comments
 (0)