From e4ddf5881bc6a28b2748ce8e4560069d3e39e8dd Mon Sep 17 00:00:00 2001 From: Matus Kysel Date: Wed, 13 Mar 2024 09:57:33 +0100 Subject: [PATCH] parlia: add state prepare for internal SC transaction (#2272) --- consensus/parlia/parlia.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/consensus/parlia/parlia.go b/consensus/parlia/parlia.go index edc797aa8e..f28bcdd4b7 100644 --- a/consensus/parlia/parlia.go +++ b/consensus/parlia/parlia.go @@ -1988,16 +1988,19 @@ func applyMessage( chainConfig *params.ChainConfig, chainContext core.ChainContext, ) (uint64, error) { - // TODO(Nathan): state.Prepare should be called here, now accessList related EIP not affect systemtxs - // EIP1153 may cause a critical issue in the future // Create a new context to be used in the EVM environment context := core.NewEVMBlockContext(header, chainContext, nil) // Create a new environment which holds all relevant information // about the transaction and calling mechanisms. vmenv := vm.NewEVM(context, vm.TxContext{Origin: msg.From(), GasPrice: big.NewInt(0)}, state, chainConfig, vm.Config{}) // Apply the transaction to the current state (included in the env) + if chainConfig.IsCancun(header.Number, header.Time) { + rules := vmenv.ChainConfig().Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time) + state.Prepare(rules, msg.From(), vmenv.Context.Coinbase, msg.To(), vm.ActivePrecompiles(rules), msg.AccessList) + } // Increment the nonce for the next transaction state.SetNonce(msg.From(), state.GetNonce(msg.From())+1) + ret, returnGas, err := vmenv.Call( vm.AccountRef(msg.From()), *msg.To(),