Skip to content

Commit a588006

Browse files
committed
generate parentRoot for witness check
Signed-off-by: Ignacio Hagopian <[email protected]>
1 parent 0406d61 commit a588006

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd/evm/internal/t8ntool/execution.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
175175
receipts = make(types.Receipts, 0)
176176
txIndex = 0
177177
)
178+
parentRoot := statedb.GetTrie().Hash()
179+
178180
gaspool.AddGas(pre.Env.GasLimit)
179181
vmContext := vm.BlockContext{
180182
CanTransfer: core.CanTransfer,
@@ -392,7 +394,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
392394
BaseFee: (*math.HexOrDecimal256)(vmContext.BaseFee),
393395
VerkleProof: vktProof,
394396
StateDiff: vktStateDiff,
395-
ParentRoot: pre.Env.BlockHashes[math.HexOrDecimal64(pre.Env.Number-1)],
397+
ParentRoot: parentRoot,
396398
}
397399
if pre.Env.Withdrawals != nil {
398400
h := types.DeriveSha(types.Withdrawals(pre.Env.Withdrawals), trie.NewStackTrie(nil))
@@ -453,7 +455,9 @@ func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prest
453455
codeHash := crypto.Keccak256Hash(acc.Code)
454456
rawdb.WriteCode(codeWriter, codeHash, acc.Code)
455457
}
456-
statedb.Commit(0, false)
458+
if _, err := statedb.Commit(0, false); err != nil {
459+
panic(err)
460+
}
457461

458462
return statedb
459463
}

0 commit comments

Comments
 (0)