Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into improve-blocksreexe…
Browse files Browse the repository at this point in the history
…cutor-impl
  • Loading branch information
tsahee committed Nov 7, 2024
2 parents ad60c0d + f57a0eb commit a74d22a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
10 changes: 4 additions & 6 deletions execution/nodeInterface/NodeInterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,10 @@ func (n NodeInterface) GasEstimateL1Component(
args.Gas = (*hexutil.Uint64)(&randomGas)

// We set the run mode to eth_call mode here because we want an exact estimate, not a padded estimate
gasLimitNotSetByUser := args.Gas == nil
if err := args.CallDefaults(randomGas, evm.Context.BaseFee, evm.ChainConfig().ChainID, gasLimitNotSetByUser); err != nil {
if err := args.CallDefaults(randomGas, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil {
return 0, nil, nil, err
}
msg := args.ToMessage(evm.Context.BaseFee, randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode, evm.ChainConfig().ChainID, gasLimitNotSetByUser)
msg := args.ToMessage(evm.Context.BaseFee, randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode)

pricing := c.State.L1PricingState()
l1BaseFeeEstimate, err := pricing.PricePerUnit()
Expand Down Expand Up @@ -579,11 +578,10 @@ func (n NodeInterface) GasEstimateComponents(
// Setting the gas currently doesn't affect the PosterDataCost,
// but we do it anyways for accuracy with potential future changes.
args.Gas = &totalRaw
gasLimitNotSetByUser := args.Gas == nil
if err := args.CallDefaults(gasCap, evm.Context.BaseFee, evm.ChainConfig().ChainID, gasLimitNotSetByUser); err != nil {
if err := args.CallDefaults(gasCap, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil {
return 0, 0, nil, nil, err
}
msg := args.ToMessage(evm.Context.BaseFee, gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode, evm.ChainConfig().ChainID, gasLimitNotSetByUser)
msg := args.ToMessage(evm.Context.BaseFee, gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode)
brotliCompressionLevel, err := c.State.BrotliCompressionLevel()
if err != nil {
return 0, 0, nil, nil, fmt.Errorf("failed to get brotli compression level: %w", err)
Expand Down
20 changes: 6 additions & 14 deletions execution/nodeInterface/virtual-contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/offchainlabs/nitro/precompiles"
"github.com/offchainlabs/nitro/solgen/go/node_interfacegen"
"github.com/offchainlabs/nitro/solgen/go/precompilesgen"
"github.com/offchainlabs/nitro/util/arbmath"
)

type addr = common.Address
Expand Down Expand Up @@ -115,35 +114,28 @@ func init() {
return msg, nil, nil
}

core.InterceptRPCGasCap = func(gascap *uint64, msg *core.Message, header *types.Header, statedb *state.StateDB) {
if *gascap == 0 {
// It's already unlimited
return
}
core.RPCPostingGasHook = func(msg *core.Message, header *types.Header, statedb *state.StateDB) (uint64, error) {
arbosVersion := arbosState.ArbOSVersion(statedb)
if arbosVersion == 0 {
// ArbOS hasn't been installed, so use the vanilla gas cap
return
return 0, nil
}
state, err := arbosState.OpenSystemArbosState(statedb, nil, true)
if err != nil {
log.Error("failed to open ArbOS state", "err", err)
return
return 0, err
}
if header.BaseFee.Sign() == 0 {
// if gas is free or there's no reimbursable poster, the user won't pay for L1 data costs
return
return 0, nil
}

brotliCompressionLevel, err := state.BrotliCompressionLevel()
if err != nil {
log.Error("failed to get brotli compression level", "err", err)
return
return 0, err
}
posterCost, _ := state.L1PricingState().PosterDataCost(msg, l1pricing.BatchPosterAddress, brotliCompressionLevel)
// Use estimate mode because this is used to raise the gas cap, so we don't want to underestimate.
posterCostInL2Gas := arbos.GetPosterGas(state, header.BaseFee, core.MessageGasEstimationMode, posterCost)
*gascap = arbmath.SaturatingUAdd(*gascap, posterCostInL2Gas)
return arbos.GetPosterGas(state, header.BaseFee, core.MessageGasEstimationMode, posterCost), nil
}

core.GetArbOSSpeedLimitPerSecond = func(statedb *state.StateDB) (uint64, error) {
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum

0 comments on commit a74d22a

Please sign in to comment.