From f3f8f59ab996e3dcda2c1b8dd7fff9198beaf9e9 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Fri, 14 Jun 2024 16:10:16 +0800 Subject: [PATCH] eth/tracers,internal/ethapi: use correct baseFee when BlockOverrides is provided in call/traceCall (#29051) --- eth/api_tracer.go | 2 ++ internal/ethapi/api.go | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 36f91897b481..b8ad9195a46c 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -688,6 +688,8 @@ func (api *PrivateDebugAPI) TraceCall(ctx context.Context, args ethapi.Transacti } } // Execute the trace + // TODO: replace block.BaseFee() with vmctx.BaseFee + // reference: https://github.com/ethereum/go-ethereum/pull/29051 msg, err := args.ToMessage(api.eth.ApiBackend, block.Number(), api.eth.ApiBackend.RPCGasCap(), block.BaseFee()) if err != nil { return nil, err diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 35f0cd2e91f5..bf8043249324 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1330,12 +1330,6 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash return nil, 0, false, err, nil } - msg, err := args.ToMessage(b, header.Number, globalGasCap, header.BaseFee) - if err != nil { - return nil, 0, false, err, nil - } - msg.SetBalanceTokenFeeForCall() - // Setup context so it may be cancelled the call has completed // or, in case of unmetered gas, setup a context with a timeout. var cancel context.CancelFunc @@ -1364,6 +1358,14 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash return nil, 0, false, err, nil } + // TODO: replace header.BaseFee with blockCtx.BaseFee + // reference: https://github.com/ethereum/go-ethereum/pull/29051 + msg, err := args.ToMessage(b, header.Number, globalGasCap, header.BaseFee) + if err != nil { + return nil, 0, false, err, nil + } + msg.SetBalanceTokenFeeForCall() + // Get a new instance of the EVM. evm, vmError, err := b.GetEVM(ctx, msg, statedb, XDCxState, header, &vm.Config{NoBaseFee: true}) if err != nil {