diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 51f59800a..0971b0c03 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -699,35 +699,30 @@ func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.S // Make sure the context is cancelled when the call has completed // this makes sure resources are cleaned up. defer cancel() + return applyMessage(ctx, b, args, state, header, timeout, globalGasCap, &blockCtx, &vm.Config{NoBaseFee: true}, precompiles, true, runMode) +} + +func applyMessage(ctx context.Context, b Backend, args TransactionArgs, state *state.StateDB, header *types.Header, timeout time.Duration, globalGasCap uint64, blockContext *vm.BlockContext, vmConfig *vm.Config, precompiles vm.PrecompiledContracts, skipChecks bool, runMode core.MessageRunMode) (*core.ExecutionResult, error) { + // Get a new instance of the EVM. gp := new(core.GasPool) - if globalGasCap == 0 { + + if b.ChainConfig().IsArbitrum() { + gp.AddGas(1 << 50) // Arbitrum: static high gas pool limit to pay for l1gas + } else if globalGasCap == 0 { gp.AddGas(gomath.MaxUint64) } else { gp.AddGas(globalGasCap) } - return applyMessage(ctx, b, args, state, header, timeout, gp, &blockCtx, &vm.Config{NoBaseFee: true}, precompiles, true, runMode) -} -func applyMessage(ctx context.Context, b Backend, args TransactionArgs, state *state.StateDB, header *types.Header, timeout time.Duration, gp *core.GasPool, blockContext *vm.BlockContext, vmConfig *vm.Config, precompiles vm.PrecompiledContracts, skipChecks bool, runMode core.MessageRunMode) (*core.ExecutionResult, error) { - // Get a new instance of the EVM. if err := args.CallDefaults(gp.Gas(), blockContext.BaseFee, b.ChainConfig().ChainID); err != nil { return nil, err } - msg := args.ToMessage(blockContext.BaseFee, gp.Gas(), header, state, runMode, skipChecks, skipChecks) + msg := args.ToMessage(blockContext.BaseFee, globalGasCap, header, state, runMode, skipChecks, skipChecks) - // Arbitrum: raise the gas cap to ignore L1 costs so that it's compute-only - if gp.Gas() > 0 { - postingGas, err := core.RPCPostingGasHook(msg, header, state) - if err != nil { - return nil, err - } - if gp.Gas() < gomath.MaxUint64-postingGas { - gp.AddGas(postingGas) - } - } - if msg.GasLimit > gp.Gas() { + if b.ChainConfig().IsArbitrum() && msg.GasLimit > gp.Gas() { // Arbitrum: gas limit is counted inside the message and not in the gas-pool gp.SetGas(msg.GasLimit) } + // Arbitrum: support NodeInterface.sol by swapping out the message if needed var res *core.ExecutionResult var err error diff --git a/internal/ethapi/transaction_args.go b/internal/ethapi/transaction_args.go index 53d02463f..9a2db1d9e 100644 --- a/internal/ethapi/transaction_args.go +++ b/internal/ethapi/transaction_args.go @@ -149,6 +149,10 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend, skipGas gas = hexutil.Uint64(math.MaxUint64 / 2) } args.Gas = &gas + if args.SkipL1Charging == nil { + skipCharging := true + args.SkipL1Charging = &skipCharging + } } else { // Estimate the gas usage otherwise. // These fields are immutable during the estimation, safe to // pass the pointer directly. @@ -194,6 +198,9 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head if args.BlobFeeCap != nil && args.BlobFeeCap.ToInt().Sign() == 0 { return errors.New("maxFeePerBlobGas, if specified, must be non-zero") } + if b.ChainConfig().IsCancun(head.Number, head.Time, types.DeserializeHeaderExtraInformation(head).ArbOSFormatVersion) { + args.setCancunFeeDefaults(b.ChainConfig(), head) + } // If both gasPrice and at least one of the EIP-1559 fee parameters are specified, error. if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) { return errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified") @@ -211,10 +218,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 { return fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas) } - // No need to set anything other than CancunFeeDefaults, user already set MaxFeePerGas and MaxPriorityFeePerGas - if err := args.setCancunFeeDefaults(ctx, b.ChainConfig(), head, b); err != nil { - return err - } + return nil // No need to set anything, user already set MaxFeePerGas and MaxPriorityFeePerGas } // Sanity check the non-EIP-1559 fee parameters. @@ -228,14 +232,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head } // Now attempt to fill in default value depending on whether London is active or not. - if b.ChainConfig().IsCancun(head.Number, head.Time, types.DeserializeHeaderExtraInformation(head).ArbOSFormatVersion) { - if err := args.setCancunFeeDefaults(ctx, b.ChainConfig(), head, b); err != nil { - return err - } - } else if isLondon { - if args.BlobFeeCap != nil { - return errors.New("maxFeePerBlobGas is not valid before Cancun is active") - } + if isLondon { // London is active, set maxPriorityFeePerGas and maxFeePerGas. if err := args.setLondonFeeDefaults(ctx, head, b); err != nil { return err @@ -255,7 +252,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head } // setCancunFeeDefaults fills in reasonable default fee values for unspecified fields. -func (args *TransactionArgs) setCancunFeeDefaults(ctx context.Context, config *params.ChainConfig, head *types.Header, b Backend) error { +func (args *TransactionArgs) setCancunFeeDefaults(config *params.ChainConfig, head *types.Header) { // Set maxFeePerBlobGas if it is missing. if args.BlobHashes != nil && args.BlobFeeCap == nil { blobBaseFee := eip4844.CalcBlobFee(config, head) @@ -265,7 +262,6 @@ func (args *TransactionArgs) setCancunFeeDefaults(ctx context.Context, config *p val := new(big.Int).Mul(blobBaseFee, big.NewInt(2)) args.BlobFeeCap = (*hexutil.Big)(val) } - return args.setLondonFeeDefaults(ctx, head, b) } // setLondonFeeDefaults fills in reasonable default fee values for unspecified fields.