From 96a6e0a74739bc9c55b8403752900089a0b66d14 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 2964a2b5d6f6..4be1c89fb60a 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -691,6 +691,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 65c4f387d03d..8561a1283de0 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 {