diff --git a/core/state_transition.go b/core/state_transition.go index a10a58102b..041f66e08d 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -347,6 +347,9 @@ func (st *StateTransition) canPayFee(accountOwner common.Address, feeCurrency *c } func (st *StateTransition) debitFee(from common.Address, feeCurrency *common.Address) (err error) { + if st.evm.Config.SkipDebitCredit { + return nil + } effectiveFee := new(big.Int).Mul(new(big.Int).SetUint64(st.msg.Gas()), st.gasPrice) // If GatewayFeeRecipient is unspecified, the gateway fee value is ignore and the sender is not charged. if st.msg.GatewayFeeRecipient() != nil { @@ -527,6 +530,10 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { // creditTxFees calculates the amounts and recipients of transaction fees and credits the accounts. func (st *StateTransition) creditTxFees() error { + if st.evm.Config.SkipDebitCredit { + return nil + } + // Run only primary evm.Call() with tracer if st.evm.GetDebug() { st.evm.SetDebug(false) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 894c9b71b0..a2dfa6ffc9 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -36,6 +36,9 @@ type Config struct { JumpTable [256]*operation // EVM instruction table, automatically populated if unset ExtraEips []int // Additional EIPS that are to be enabled + + // Celo + SkipDebitCredit bool } // ScopeContext contains the things that are per-call, such as stack and memory, diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index c5b5a24d4a..95fcdfd834 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -909,7 +909,7 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash if err != nil { return nil, err } - evm, vmError, err := b.GetEVM(ctx, msg, state, header, &vm.Config{NoBaseFee: true}) + evm, vmError, err := b.GetEVM(ctx, msg, state, header, &vm.Config{NoBaseFee: true, SkipDebitCredit: true}) if err != nil { return nil, err } @@ -1014,6 +1014,9 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr // also fail with gas limit B, which may not be the case if the gas price is non-zero, // depending on the account's balance. args.GasPrice = nil + // If a fee tip or fee cap are passed, those will override the gas price, so zero them out as well. + args.MaxFeePerGas = nil + args.MaxPriorityFeePerGas = nil // Create a helper to check if a gas allowance results in an executable transaction executable := func(gas uint64) (bool, *core.ExecutionResult, error) { args.Gas = (*hexutil.Uint64)(&gas)