diff --git a/eth/gasestimator/gasestimator.go b/eth/gasestimator/gasestimator.go index d8aaf0ec9fa0..c5ab3184d16f 100644 --- a/eth/gasestimator/gasestimator.go +++ b/eth/gasestimator/gasestimator.go @@ -28,7 +28,6 @@ import ( "github.com/XinFinOrg/XDPoSChain/core/state" "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/core/vm" - "github.com/XinFinOrg/XDPoSChain/internal/ethapi/override" "github.com/XinFinOrg/XDPoSChain/log" "github.com/XinFinOrg/XDPoSChain/params" ) @@ -39,11 +38,10 @@ import ( // these together, it would be excessively hard to test. Splitting the parts out // allows testing without needing a proper live chain. type Options struct { - Config *params.ChainConfig // Chain configuration for hard fork selection - Chain core.ChainContext // Chain context to access past block hashes - Header *types.Header // Header defining the block context to execute in - State *state.StateDB // Pre-state on top of which to estimate the gas - BlockOverrides *override.BlockOverrides // Block overrides to apply during the estimation + Config *params.ChainConfig // Chain configuration for hard fork selection + Chain core.ChainContext // Chain context to access past block hashes + Header *types.Header // Header defining the block context to execute in + State *state.StateDB // Pre-state on top of which to estimate the gas } // Estimate returns the lowest possible gas limit that allows the transaction to @@ -63,13 +61,7 @@ func Estimate(ctx context.Context, call *core.Message, opts *Options, gasCap uin // Cap the maximum gas allowance according to EIP-7825 if the estimation targets Osaka if hi > params.MaxTxGas { - blockNumber := opts.Header.Number - if opts.BlockOverrides != nil { - if opts.BlockOverrides.Number != nil { - blockNumber = opts.BlockOverrides.Number.ToInt() - } - } - if opts.Config.IsOsaka(blockNumber) { + if opts.Config.IsOsaka(opts.Header.Number) { hi = params.MaxTxGas } } @@ -186,9 +178,6 @@ func run(ctx context.Context, call *core.Message, opts *Options) (*core.Executio evmContext = core.NewEVMBlockContext(opts.Header, opts.Chain, nil) dirtyState = opts.State.Copy() ) - if opts.BlockOverrides != nil { - opts.BlockOverrides.Apply(&evmContext) - } // Lower the basefee to 0 to avoid breaking EVM // invariants (basefee < feecap). if msgContext.GasPrice.Sign() == 0 { diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 02e75df92615..20a757570ca2 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1267,27 +1267,25 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr if err = overrides.Apply(state, nil); err != nil { return 0, err } - estimationHeader := header if blockOverrides != nil { - estimationHeader = blockOverrides.MakeHeader(header) + header = blockOverrides.MakeHeader(header) } // Construct the gas estimator option from the user input opts := &gasestimator.Options{ - Config: b.ChainConfig(), - Chain: NewChainContext(ctx, b), - Header: estimationHeader, - BlockOverrides: blockOverrides, - State: state, + Config: b.ChainConfig(), + Chain: NewChainContext(ctx, b), + Header: header, + State: state, } // Set any required transaction default, but make sure the gas cap itself is not messed with // if it was not specified in the original argument list. if args.Gas == nil { args.Gas = new(hexutil.Uint64) } - if err := args.CallDefaults(gasCap, estimationHeader.BaseFee, b.ChainConfig().ChainID); err != nil { + if err := args.CallDefaults(gasCap, header.BaseFee, b.ChainConfig().ChainID); err != nil { return 0, err } - call := args.ToMessage(b, estimationHeader.BaseFee, true) + call := args.ToMessage(b, header.BaseFee, true) // Run the gas estimation andwrap any revertals into a custom return estimate, revert, err := gasestimator.Estimate(ctx, call, opts, gasCap)