diff --git a/core/evm.go b/core/evm.go index 148e1ac07f6..3421f8a9a45 100644 --- a/core/evm.go +++ b/core/evm.go @@ -51,7 +51,14 @@ func NewEVMBlockContext(header *types.Header, blockHashFunc func(n uint64) libco var prevRandDao *libcommon.Hash if header.Difficulty.Cmp(merge.ProofOfStakeDifficulty) == 0 { // EIP-4399. We use ProofOfStakeDifficulty (i.e. 0) as a telltale of Proof-of-Stake blocks. - prevRandDao = &header.MixDigest + prevRandDao = new(libcommon.Hash) + *prevRandDao = header.MixDigest + } + + var excessBlobGas *uint64 + if header.ExcessBlobGas != nil { + excessBlobGas = new(uint64) + *excessBlobGas = *header.ExcessBlobGas } var transferFunc evmtypes.TransferFunc @@ -71,7 +78,7 @@ func NewEVMBlockContext(header *types.Header, blockHashFunc func(n uint64) libco BaseFee: &baseFee, GasLimit: header.GasLimit, PrevRanDao: prevRandDao, - ExcessBlobGas: header.ExcessBlobGas, + ExcessBlobGas: excessBlobGas, } } diff --git a/turbo/jsonrpc/eth_callMany.go b/turbo/jsonrpc/eth_callMany.go index df7bfd9e377..540fc862069 100644 --- a/turbo/jsonrpc/eth_callMany.go +++ b/turbo/jsonrpc/eth_callMany.go @@ -4,14 +4,15 @@ import ( "context" "encoding/hex" "fmt" - "github.com/ledgerwatch/erigon-lib/common/hexutil" "math/big" "time" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/log/v3" + "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutil" + "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/state" @@ -77,7 +78,6 @@ func (api *APIImpl) CallMany(ctx context.Context, bundles []Bundle, simulateCont blockCtx evmtypes.BlockContext txCtx evmtypes.TxContext overrideBlockHash map[uint64]common.Hash - baseFee uint256.Int ) overrideBlockHash = make(map[uint64]common.Hash) @@ -138,9 +138,9 @@ func (api *APIImpl) CallMany(ctx context.Context, bundles []Bundle, simulateCont st := state.New(stateReader) - parent := block.Header() + header := block.Header() - if parent == nil { + if header == nil { return nil, fmt.Errorf("block %d(%x) not found", blockNum, hash) } @@ -155,21 +155,7 @@ func (api *APIImpl) CallMany(ctx context.Context, bundles []Bundle, simulateCont return hash } - if parent.BaseFee != nil { - baseFee.SetFromBig(parent.BaseFee) - } - - blockCtx = evmtypes.BlockContext{ - CanTransfer: core.CanTransfer, - Transfer: core.Transfer, - GetHash: getHash, - Coinbase: parent.Coinbase, - BlockNumber: parent.Number.Uint64(), - Time: parent.Time, - Difficulty: new(big.Int).Set(parent.Difficulty), - GasLimit: parent.GasLimit, - BaseFee: &baseFee, - } + blockCtx = core.NewEVMBlockContext(header, getHash, api.engine(), nil /* author */) // Get a new instance of the EVM evm = vm.NewEVM(blockCtx, txCtx, st, chainConfig, vm.Config{Debug: false}) diff --git a/turbo/jsonrpc/tracing.go b/turbo/jsonrpc/tracing.go index f799d35c964..3ab8ed8c547 100644 --- a/turbo/jsonrpc/tracing.go +++ b/turbo/jsonrpc/tracing.go @@ -3,7 +3,6 @@ package jsonrpc import ( "context" "fmt" - "math/big" "time" "github.com/holiman/uint256" @@ -12,6 +11,7 @@ import ( "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/common/hexutil" + "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/state" @@ -373,7 +373,6 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun blockCtx evmtypes.BlockContext txCtx evmtypes.TxContext overrideBlockHash map[uint64]common.Hash - baseFee uint256.Int ) if config == nil { @@ -453,9 +452,9 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun st := state.New(stateReader) - parent := block.Header() + header := block.Header() - if parent == nil { + if header == nil { stream.WriteNil() return fmt.Errorf("block %d(%x) not found", blockNum, hash) } @@ -471,22 +470,7 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun return hash } - if parent.BaseFee != nil { - baseFee.SetFromBig(parent.BaseFee) - } - - blockCtx = evmtypes.BlockContext{ - CanTransfer: core.CanTransfer, - Transfer: core.Transfer, - GetHash: getHash, - Coinbase: parent.Coinbase, - BlockNumber: parent.Number.Uint64(), - Time: parent.Time, - Difficulty: new(big.Int).Set(parent.Difficulty), - GasLimit: parent.GasLimit, - BaseFee: &baseFee, - } - + blockCtx = core.NewEVMBlockContext(header, getHash, api.engine(), nil /* author */) // Get a new instance of the EVM evm = vm.NewEVM(blockCtx, txCtx, st, chainConfig, vm.Config{Debug: false}) signer := types.MakeSigner(chainConfig, blockNum, block.Time()) @@ -540,7 +524,7 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun } txCtx = core.NewEVMTxContext(msg) ibs := evm.IntraBlockState().(*state.IntraBlockState) - ibs.SetTxContext(common.Hash{}, parent.Hash(), txnIndex) + ibs.SetTxContext(common.Hash{}, header.Hash(), txnIndex) err = transactions.TraceTx(ctx, msg, blockCtx, txCtx, evm.IntraBlockState(), config, chainConfig, stream, api.evmCallTimeout) if err != nil { stream.WriteArrayEnd()