diff --git a/arbnode/api.go b/arbnode/api.go index abb30e09b0..55b6b1bf20 100644 --- a/arbnode/api.go +++ b/arbnode/api.go @@ -14,7 +14,6 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/arbos/arbosState" - "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/validator" "github.com/pkg/errors" @@ -57,107 +56,6 @@ type ArbDebugAPI struct { blockchain *core.BlockChain } -type PricingModelHistoryPreExp struct { - First uint64 `json:"first"` - Timestamp []uint64 `json:"timestamp"` - BaseFee []*big.Int `json:"baseFee"` - RateEstimate []uint64 `json:"rateEstimate"` - GasPool []int64 `json:"gasPool"` - GasUsed []uint64 `json:"gasUsed"` - L1BaseFeeEstimate []*big.Int `json:"l1BaseFeeEstimate"` - L1BaseFeeUpdateTime []uint64 `json:"l1BaseFeeUpdateTime"` - GasPoolMax int64 `json:"gasPoolMax"` - GasPoolTarget uint64 `json:"gasPoolTarget"` - GasPoolWeight uint64 `json:"gasPoolWeight"` - SpeedLimit uint64 `json:"speedLimit"` - MaxPerBlockGasLimit uint64 `json:"maxPerBlockGasLimit"` - L1BaseFeeEstimateInertia uint64 `json:"l1BaseFeeEstimateInertia"` -} - -func (api *ArbDebugAPI) PricingModelPreExp(ctx context.Context, start, end rpc.BlockNumber) (PricingModelHistoryPreExp, error) { - start, _ = api.blockchain.ClipToPostNitroGenesis(start) - end, _ = api.blockchain.ClipToPostNitroGenesis(end) - - blocks := end.Int64() - start.Int64() - if blocks <= 0 { - return PricingModelHistoryPreExp{}, fmt.Errorf("invalid block range: %v to %v", start.Int64(), end.Int64()) - } - - history := PricingModelHistoryPreExp{ - First: uint64(start), - Timestamp: make([]uint64, blocks), - BaseFee: make([]*big.Int, blocks), - RateEstimate: make([]uint64, blocks), - GasPool: make([]int64, blocks), - GasUsed: make([]uint64, blocks), - L1BaseFeeEstimate: make([]*big.Int, blocks), - L1BaseFeeUpdateTime: make([]uint64, blocks+1), - } - - genesisBlock := api.blockchain.Config().ArbitrumChainParams.GenesisBlockNum - if start > rpc.BlockNumber(genesisBlock) { - state, _, err := stateAndHeader(api.blockchain, uint64(start)-1) - if err != nil { - return history, err - } - l1BaseFeeUpdateTime, err := state.L1PricingState().LastL1BaseFeeUpdateTime() - if err != nil { - return history, err - } - history.L1BaseFeeUpdateTime[0] = l1BaseFeeUpdateTime - } - - for i := uint64(0); i < uint64(blocks); i++ { - state, header, err := stateAndHeader(api.blockchain, i+uint64(start)) - if err != nil { - return history, err - } - l1Pricing := state.L1PricingState() - l2Pricing := state.L2PricingState() - - if state.FormatVersion() >= l2pricing.FirstExponentialPricingVersion { - // blocks from here on use the new model so we'll zero-fill the remaining values - break - } - - rateEstimate, _ := l2Pricing.RateEstimate() - gasPool, _ := l2Pricing.GasPool_preExp() - l1BaseFeeEstimate, _ := l1Pricing.L1BaseFeeEstimateWei() - l1BaseFeeUpdateTime, err := l1Pricing.LastL1BaseFeeUpdateTime() - if err != nil { - return history, err - } - - history.Timestamp[i] = header.Time - history.BaseFee[i] = header.BaseFee - history.RateEstimate[i] = rateEstimate - history.GasPool[i] = gasPool - history.GasUsed[i] = header.GasUsed - history.L1BaseFeeEstimate[i] = l1BaseFeeEstimate - history.L1BaseFeeUpdateTime[i+1] = l1BaseFeeUpdateTime - - if i == uint64(blocks)-1 { - speedLimit, _ := l2Pricing.SpeedLimitPerSecond() - gasPoolMax, _ := l2Pricing.GasPoolMax() - gasPoolTarget, _ := l2Pricing.GasPoolTarget() - gasPoolWeight, _ := l2Pricing.GasPoolWeight() - maxPerBlockGasLimit, _ := l2Pricing.MaxPerBlockGasLimit() - l1BaseFeeEstimateInertia, err := l1Pricing.L1BaseFeeEstimateInertia() - if err != nil { - return history, err - } - history.SpeedLimit = speedLimit - history.GasPoolMax = gasPoolMax - history.GasPoolTarget = uint64(gasPoolTarget) - history.GasPoolWeight = uint64(gasPoolWeight) - history.MaxPerBlockGasLimit = maxPerBlockGasLimit - history.L1BaseFeeEstimateInertia = l1BaseFeeEstimateInertia - } - } - - return history, nil -} - type PricingModelHistory struct { First uint64 `json:"first"` Timestamp []uint64 `json:"timestamp"` @@ -217,11 +115,6 @@ func (api *ArbDebugAPI) PricingModel(ctx context.Context, start, end rpc.BlockNu history.Timestamp[i] = header.Time history.BaseFee[i] = header.BaseFee - if state.FormatVersion() < l2pricing.FirstExponentialPricingVersion { - // this block doesn't use the exponential pricing model, so we'll zero-fill it - continue - } - gasBacklog, _ := l2Pricing.GasBacklog() l1BaseFeeEstimate, _ := l1Pricing.L1BaseFeeEstimateWei() l1BaseFeeUpdateTime, err := l1Pricing.LastL1BaseFeeUpdateTime() @@ -236,7 +129,7 @@ func (api *ArbDebugAPI) PricingModel(ctx context.Context, start, end rpc.BlockNu if i == uint64(blocks)-1 { speedLimit, _ := l2Pricing.SpeedLimitPerSecond() - maxPerBlockGasLimit, _ := l2Pricing.MaxPerBlockGasLimit() + maxPerBlockGasLimit, _ := l2Pricing.PerBlockGasLimit() l1BaseFeeEstimateInertia, err := l1Pricing.L1BaseFeeEstimateInertia() minBaseFee, _ := l2Pricing.MinBaseFeeWei() pricingInertia, _ := l2Pricing.PricingInertia() diff --git a/arbos/arbosState/arbosstate.go b/arbos/arbosState/arbosstate.go index d9028d99bd..d96970afbd 100644 --- a/arbos/arbosState/arbosstate.go +++ b/arbos/arbosState/arbosstate.go @@ -11,7 +11,6 @@ import ( "github.com/offchainlabs/nitro/arbos/blockhash" "github.com/offchainlabs/nitro/arbos/l2pricing" - "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/arbos/addressSet" "github.com/offchainlabs/nitro/arbos/burn" @@ -184,7 +183,7 @@ func InitializeArbosState(stateDB vm.StateDB, burner burn.Burner, chainConfig *p } arbosVersion = chainConfig.ArbitrumChainParams.InitialArbOSVersion - if arbosVersion < 1 || arbosVersion > 4 { + if arbosVersion != 1 { return nil, fmt.Errorf("cannot initialize to unsupported ArbOS version %v", arbosVersion) } @@ -201,7 +200,7 @@ func InitializeArbosState(stateDB vm.StateDB, burner burn.Burner, chainConfig *p _ = sto.SetByUint64(uint64(chainIdOffset), common.BigToHash(chainConfig.ChainID)) _ = sto.SetUint64ByUint64(uint64(genesisBlockNumOffset), chainConfig.ArbitrumChainParams.GenesisBlockNum) _ = l1pricing.InitializeL1PricingState(sto.OpenSubStorage(l1PricingSubspace)) - _ = l2pricing.InitializeL2PricingState(sto.OpenSubStorage(l2PricingSubspace), arbosVersion) + _ = l2pricing.InitializeL2PricingState(sto.OpenSubStorage(l2PricingSubspace)) _ = retryables.InitializeRetryableState(sto.OpenSubStorage(retryablesSubspace)) addressTable.Initialize(sto.OpenSubStorage(addressTableSubspace)) merkleAccumulator.InitializeMerkleAccumulator(sto.OpenSubStorage(sendMerkleSubspace)) @@ -219,31 +218,15 @@ func InitializeArbosState(stateDB vm.StateDB, burner burn.Burner, chainConfig *p return OpenArbosState(stateDB, burner) } -var TestnetUpgrade2Owner = common.HexToAddress("0x40Fd01b32e97803f12693517776826a71e2B8D5f") - func (state *ArbosState) UpgradeArbosVersionIfNecessary(currentTimestamp uint64, chainConfig *params.ChainConfig) { upgradeTo, err := state.upgradeVersion.Get() state.Restrict(err) flagday, _ := state.upgradeTimestamp.Get() if upgradeTo > state.arbosVersion && currentTimestamp >= flagday { for upgradeTo > state.arbosVersion && currentTimestamp >= flagday { - if state.arbosVersion == 1 { - // Upgrade version 1->2 adds a chain owner for the testnet - if arbmath.BigEquals(chainConfig.ChainID, params.ArbitrumTestnetChainConfig().ChainID) { - state.Restrict(state.chainOwners.Add(TestnetUpgrade2Owner)) - } - } else if state.arbosVersion == 2 { - // Upgrade version 2->3 has no state changes - } else if state.arbosVersion == 3 { - // Upgrade version 3->4 adds two fields to the L2 pricing model - // (We don't bother to remove no-longer-used fields, for safety - // and because they'll be removed when we telescope versions for re-launch.) - state.Restrict(state.l2PricingState.UpgradeToVersion4()) - } else { - // code to upgrade to future versions will be put here - panic("Unable to perform requested ArbOS upgrade") - } - state.arbosVersion++ + // code to upgrade to future versions will be put here + panic("Unable to perform requested ArbOS upgrade") + // state.arbosVersion++ } state.Restrict(state.backingStorage.SetUint64ByUint64(uint64(versionOffset), state.arbosVersion)) } diff --git a/arbos/block_processor.go b/arbos/block_processor.go index cf4c594bdb..3949a60963 100644 --- a/arbos/block_processor.go +++ b/arbos/block_processor.go @@ -146,7 +146,7 @@ func ProduceBlockAdvanced( header := createNewHeader(lastBlockHeader, l1Info, state, chainConfig) signer := types.MakeSigner(chainConfig, header.Number) - gasLeft, _ := state.L2PricingState().PerBlockGasLimit(state.FormatVersion()) + gasLeft, _ := state.L2PricingState().PerBlockGasLimit() l1BlockNum := l1Info.l1BlockNumber // Prepend a tx before all others to touch up the state (update the L1 block num, pricing pools, etc) diff --git a/arbos/internal_tx.go b/arbos/internal_tx.go index 452196ad84..4e840cffc7 100644 --- a/arbos/internal_tx.go +++ b/arbos/internal_tx.go @@ -34,7 +34,7 @@ func InternalTxStartBlock( if l1BaseFee == nil { l1BaseFee = big.NewInt(0) } - data, err := util.PackInternalTxDataStartBlock(l1BaseFee, lastHeader.BaseFee, l1BlockNum, timePassed) + data, err := util.PackInternalTxDataStartBlock(l1BaseFee, l1BlockNum, timePassed) if err != nil { panic(fmt.Sprintf("Failed to pack internal tx %v", err)) } @@ -52,22 +52,14 @@ func ApplyInternalTxUpdate(tx *types.ArbitrumInternalTx, state *arbosState.Arbos panic(err) } l1BaseFee, _ := inputs[0].(*big.Int) // current block's - l2BaseFee, _ := inputs[1].(*big.Int) // the last L2 block's base fee (which is the result of the calculation 2 blocks ago) - l1BlockNumber, _ := inputs[2].(uint64) // current block's - timePassed, _ := inputs[3].(uint64) // since last block + l1BlockNumber, _ := inputs[1].(uint64) // current block's + timePassed, _ := inputs[2].(uint64) // since last block nextL1BlockNumber, err := state.Blockhashes().NextBlockNumber() state.Restrict(err) - if state.FormatVersion() >= 3 { - // The `l2BaseFee` in the tx data is indeed the last block's base fee, - // however, for the purposes of this function, we need the previous computed base fee. - // Since the computed base fee takes one block to apply, the last block's base fee - // is actually two calculations ago. Instead, as of ArbOS format version 3, - // we use the current state's base fee, which is the result of the last calculation. - l2BaseFee, err = state.L2PricingState().BaseFeeWei() - state.Restrict(err) - } + l2BaseFee, err := state.L2PricingState().BaseFeeWei() + state.Restrict(err) if l1BlockNumber >= nextL1BlockNumber { var prevHash common.Hash @@ -83,7 +75,7 @@ func ApplyInternalTxUpdate(tx *types.ArbitrumInternalTx, state *arbosState.Arbos _ = state.RetryableState().TryToReapOneRetryable(currentTime, evm, util.TracingDuringEVM) _ = state.RetryableState().TryToReapOneRetryable(currentTime, evm, util.TracingDuringEVM) - state.L2PricingState().UpdatePricingModel(l2BaseFee, timePassed, state.FormatVersion(), false) + state.L2PricingState().UpdatePricingModel(l2BaseFee, timePassed, false) state.L1PricingState().UpdatePricingModel(l1BaseFee, currentTime) state.UpgradeArbosVersionIfNecessary(currentTime, evm.ChainConfig()) diff --git a/arbos/l2pricing/l2pricing.go b/arbos/l2pricing/l2pricing.go index 24caf4923e..1c7edd954d 100644 --- a/arbos/l2pricing/l2pricing.go +++ b/arbos/l2pricing/l2pricing.go @@ -4,25 +4,15 @@ package l2pricing import ( - "errors" - "math" "math/big" "github.com/offchainlabs/nitro/arbos/storage" - "github.com/offchainlabs/nitro/util/arbmath" ) type L2PricingState struct { storage *storage.Storage - gasPool_preExp storage.StorageBackedInt64 - gasPoolLastBlock storage.StorageBackedInt64 - gasPoolSeconds storage.StorageBackedUint64 - gasPoolTarget storage.StorageBackedBips - gasPoolWeight storage.StorageBackedBips - rateEstimate storage.StorageBackedUint64 - rateEstimateInertia storage.StorageBackedUint64 speedLimitPerSecond storage.StorageBackedUint64 - maxPerBlockGasLimit storage.StorageBackedUint64 + perBlockGasLimit storage.StorageBackedUint64 baseFeeWei storage.StorageBackedBigInt minBaseFeeWei storage.StorageBackedBigInt gasBacklog storage.StorageBackedUint64 @@ -31,15 +21,8 @@ type L2PricingState struct { } const ( - gasPoolOffset_preExp uint64 = iota - gasPoolLastBlockOffset - gasPoolSecondsOffset - gasPoolTargetOffset - gasPoolWeightOffset - rateEstimateOffset - rateEstimateInertiaOffset - speedLimitPerSecondOffset - maxPerBlockGasLimitOffset + speedLimitPerSecondOffset uint64 = iota + perBlockGasLimitOffset baseFeeWeiOffset minBaseFeeWeiOffset gasBacklogOffset @@ -49,37 +32,21 @@ const ( const GethBlockGasLimit = 1 << 50 -func InitializeL2PricingState(sto *storage.Storage, arbosVersion uint64) error { - _ = sto.SetUint64ByUint64(gasPoolOffset_preExp, InitialGasPoolSeconds*InitialSpeedLimitPerSecond) - _ = sto.SetUint64ByUint64(gasPoolLastBlockOffset, InitialGasPoolSeconds*InitialSpeedLimitPerSecond) - _ = sto.SetUint64ByUint64(gasPoolSecondsOffset, InitialGasPoolSeconds) - _ = sto.SetUint64ByUint64(gasPoolTargetOffset, uint64(InitialGasPoolTargetBips)) - _ = sto.SetUint64ByUint64(gasPoolWeightOffset, uint64(InitialGasPoolWeightBips)) - _ = sto.SetUint64ByUint64(rateEstimateOffset, InitialSpeedLimitPerSecond) - _ = sto.SetUint64ByUint64(rateEstimateInertiaOffset, InitialRateEstimateInertia) +func InitializeL2PricingState(sto *storage.Storage) error { _ = sto.SetUint64ByUint64(speedLimitPerSecondOffset, InitialSpeedLimitPerSecond) - _ = sto.SetUint64ByUint64(maxPerBlockGasLimitOffset, InitialPerBlockGasLimit) + _ = sto.SetUint64ByUint64(perBlockGasLimitOffset, InitialPerBlockGasLimit) _ = sto.SetUint64ByUint64(baseFeeWeiOffset, InitialBaseFeeWei) - if arbosVersion >= FirstExponentialPricingVersion { - _ = sto.SetUint64ByUint64(gasBacklogOffset, 0) - _ = sto.SetUint64ByUint64(pricingInertiaOffset, InitialPricingInertia) - _ = sto.SetUint64ByUint64(backlogToleranceOffset, InitialBacklogTolerance) - } + _ = sto.SetUint64ByUint64(gasBacklogOffset, 0) + _ = sto.SetUint64ByUint64(pricingInertiaOffset, InitialPricingInertia) + _ = sto.SetUint64ByUint64(backlogToleranceOffset, InitialBacklogTolerance) return sto.SetUint64ByUint64(minBaseFeeWeiOffset, InitialMinimumBaseFeeWei) } func OpenL2PricingState(sto *storage.Storage) *L2PricingState { return &L2PricingState{ sto, - sto.OpenStorageBackedInt64(gasPoolOffset_preExp), - sto.OpenStorageBackedInt64(gasPoolLastBlockOffset), - sto.OpenStorageBackedUint64(gasPoolSecondsOffset), - sto.OpenStorageBackedBips(gasPoolTargetOffset), - sto.OpenStorageBackedBips(gasPoolWeightOffset), - sto.OpenStorageBackedUint64(rateEstimateOffset), - sto.OpenStorageBackedUint64(rateEstimateInertiaOffset), sto.OpenStorageBackedUint64(speedLimitPerSecondOffset), - sto.OpenStorageBackedUint64(maxPerBlockGasLimitOffset), + sto.OpenStorageBackedUint64(perBlockGasLimitOffset), sto.OpenStorageBackedBigInt(baseFeeWeiOffset), sto.OpenStorageBackedBigInt(minBaseFeeWeiOffset), sto.OpenStorageBackedUint64(gasBacklogOffset), @@ -88,101 +55,6 @@ func OpenL2PricingState(sto *storage.Storage) *L2PricingState { } } -func (ps *L2PricingState) UpgradeToVersion4() error { - gasPoolSeconds, err := ps.GasPoolSeconds() - if err != nil { - return err - } - speedLimit, err := ps.SpeedLimitPerSecond() - if err != nil { - return err - } - gasPool, err := ps.GasPool_preExp() - if err != nil { - return err - } - if err := ps.SetGasBacklog(uint64(int64(gasPoolSeconds*speedLimit) - gasPool)); err != nil { - return err - } - if err := ps.SetPricingInertia(InitialPricingInertia); err != nil { - return err - } - return ps.SetBacklogTolerance(InitialBacklogTolerance) -} - -func (ps *L2PricingState) GasPool_preExp() (int64, error) { - return ps.gasPool_preExp.Get() -} - -func (ps *L2PricingState) SetGasPool_preExp(val int64) error { - return ps.gasPool_preExp.Set(val) -} - -func (ps *L2PricingState) GasPoolLastBlock() (int64, error) { - return ps.gasPoolLastBlock.Get() -} - -func (ps *L2PricingState) SetGasPoolLastBlock(val int64) { - ps.Restrict(ps.gasPoolLastBlock.Set(val)) -} - -func (ps *L2PricingState) GasPoolSeconds() (uint64, error) { - return ps.gasPoolSeconds.Get() -} - -func (ps *L2PricingState) SetGasPoolSeconds(seconds uint64) error { - limit, err := ps.SpeedLimitPerSecond() - if err != nil { - return err - } - if seconds == 0 || seconds > 3*60*60 || arbmath.SaturatingUMul(seconds, limit) > math.MaxInt64 { - return errors.New("GasPoolSeconds is out of bounds") - } - if err := ps.clipGasPool_preExp(seconds, limit); err != nil { - return err - } - return ps.gasPoolSeconds.Set(seconds) -} - -func (ps *L2PricingState) GasPoolTarget() (arbmath.Bips, error) { - target, err := ps.gasPoolTarget.Get() - return arbmath.Bips(target), err -} - -func (ps *L2PricingState) SetGasPoolTarget(target arbmath.Bips) error { - if target > arbmath.OneInBips { - return errors.New("GasPoolTarget is out of bounds") - } - return ps.gasPoolTarget.Set(target) -} - -func (ps *L2PricingState) GasPoolWeight() (arbmath.Bips, error) { - return ps.gasPoolWeight.Get() -} - -func (ps *L2PricingState) SetGasPoolWeight(weight arbmath.Bips) error { - if weight > arbmath.OneInBips { - return errors.New("GasPoolWeight is out of bounds") - } - return ps.gasPoolWeight.Set(weight) -} - -func (ps *L2PricingState) RateEstimate() (uint64, error) { - return ps.rateEstimate.Get() -} - -func (ps *L2PricingState) SetRateEstimate(rate uint64) { - ps.Restrict(ps.rateEstimate.Set(rate)) -} - -func (ps *L2PricingState) RateEstimateInertia() (uint64, error) { - return ps.rateEstimateInertia.Get() -} - -func (ps *L2PricingState) SetRateEstimateInertia(inertia uint64) error { - return ps.rateEstimateInertia.Set(inertia) -} - func (ps *L2PricingState) BaseFeeWei() (*big.Int, error) { return ps.baseFeeWei.Get() } @@ -207,34 +79,15 @@ func (ps *L2PricingState) SpeedLimitPerSecond() (uint64, error) { } func (ps *L2PricingState) SetSpeedLimitPerSecond(limit uint64) error { - seconds, err := ps.GasPoolSeconds() - if err != nil { - return err - } - if limit == 0 || arbmath.SaturatingUMul(seconds, limit) > math.MaxInt64 { - return errors.New("SetSpeedLimitPerSecond is out of bounds") - } - if err := ps.clipGasPool_preExp(seconds, limit); err != nil { - return err - } return ps.speedLimitPerSecond.Set(limit) } -func (ps *L2PricingState) GasPoolMax() (int64, error) { - speedLimit, _ := ps.SpeedLimitPerSecond() - seconds, err := ps.GasPoolSeconds() - if err != nil { - return 0, err - } - return arbmath.SaturatingCast(seconds * speedLimit), nil -} - -func (ps *L2PricingState) MaxPerBlockGasLimit() (uint64, error) { - return ps.maxPerBlockGasLimit.Get() +func (ps *L2PricingState) PerBlockGasLimit() (uint64, error) { + return ps.perBlockGasLimit.Get() } func (ps *L2PricingState) SetMaxPerBlockGasLimit(limit uint64) error { - return ps.maxPerBlockGasLimit.Set(limit) + return ps.perBlockGasLimit.Set(limit) } func (ps *L2PricingState) GasBacklog() (uint64, error) { @@ -261,19 +114,6 @@ func (ps *L2PricingState) SetBacklogTolerance(val uint64) error { return ps.backlogTolerance.Set(val) } -// Ensure the gas pool is within the implied maximum capacity -func (ps *L2PricingState) clipGasPool_preExp(seconds, speedLimit uint64) error { - pool, err := ps.GasPool_preExp() - if err != nil { - return err - } - newMax := arbmath.SaturatingCast(arbmath.SaturatingUMul(seconds, speedLimit)) - if pool > newMax { - err = ps.SetGasPool_preExp(newMax) - } - return err -} - func (ps *L2PricingState) Restrict(err error) { ps.storage.Burner().Restrict(err) } diff --git a/arbos/l2pricing/l2pricing_test.go b/arbos/l2pricing/l2pricing_test.go index 71ccecd454..57759d7f82 100644 --- a/arbos/l2pricing/l2pricing_test.go +++ b/arbos/l2pricing/l2pricing_test.go @@ -14,88 +14,52 @@ import ( "github.com/offchainlabs/nitro/util/testhelpers" ) -func PricingForTest(t *testing.T, arbosVersion uint64) *L2PricingState { +func PricingForTest(t *testing.T) *L2PricingState { storage := storage.NewMemoryBacked(burn.NewSystemBurner(nil, false)) - err := InitializeL2PricingState(storage, arbosVersion) + err := InitializeL2PricingState(storage) Require(t, err) return OpenL2PricingState(storage) } -func fakeBlockUpdate(t *testing.T, pricing *L2PricingState, gasUsed int64, timePassed uint64, arbosVersion uint64) { +func fakeBlockUpdate(t *testing.T, pricing *L2PricingState, gasUsed int64, timePassed uint64) { basefee := getPrice(t, pricing) - pricing.storage.Burner().Restrict(pricing.AddToGasPool(-gasUsed, arbosVersion)) - pricing.UpdatePricingModel(arbmath.UintToBig(basefee), timePassed, arbosVersion, true) -} - -func TestPricingModelPreExp(t *testing.T) { - versionedTestPricingModel(t, FirstExponentialPricingVersion-1) + pricing.storage.Burner().Restrict(pricing.AddToGasPool(-gasUsed)) + pricing.UpdatePricingModel(arbmath.UintToBig(basefee), timePassed, true) } func TestPricingModelExp(t *testing.T) { - versionedTestPricingModel(t, FirstExponentialPricingVersion) -} - -func versionedTestPricingModel(t *testing.T, arbosVersion uint64) { - pricing := PricingForTest(t, arbosVersion) - maxPool := maxGasPool(t, pricing) - gasPool := getGasPool(t, pricing) + pricing := PricingForTest(t) minPrice := getMinPrice(t, pricing) price := getPrice(t, pricing) limit := getSpeedLimit(t, pricing) - if gasPool != maxPool { - Fail(t, "pool not filled", gasPool, maxPool) - } if price != minPrice { Fail(t, "price not minimal", price, minPrice) } - // declare that we've been running at the speed limit - pricing.SetRateEstimate(limit) - // show that running at the speed limit with a full pool is a steady-state colors.PrintBlue("full pool & speed limit") for seconds := 0; seconds < 4; seconds++ { - fakeBlockUpdate(t, pricing, int64(seconds)*int64(limit), uint64(seconds), arbosVersion) + fakeBlockUpdate(t, pricing, int64(seconds)*int64(limit), uint64(seconds)) if getPrice(t, pricing) != minPrice { Fail(t, "price changed when it shouldn't have") } - if arbosVersion < 4 && getGasPool(t, pricing) != maxPool { - Fail(t, "pool changed when it shouldn't have") - } } - // set the gas pool to the target - target, _ := pricing.GasPoolTarget() - poolTarget := int64(target) * maxPool / 10000 - Require(t, pricing.SetGasPool_preExp(poolTarget)) - pricing.SetGasPoolLastBlock(poolTarget) - pricing.SetRateEstimate(limit) - // show that running at the speed limit with a target pool is close to a steady-state // note that for large enough spans of time the price will rise a miniscule amount due to the pool's avg colors.PrintBlue("pool target & speed limit") for seconds := 0; seconds < 4; seconds++ { - fakeBlockUpdate(t, pricing, int64(seconds)*int64(limit), uint64(seconds), arbosVersion) + fakeBlockUpdate(t, pricing, int64(seconds)*int64(limit), uint64(seconds)) if getPrice(t, pricing) != minPrice { Fail(t, "price changed when it shouldn't have") } - if arbosVersion < FirstExponentialPricingVersion && getGasPool(t, pricing) != poolTarget { - Fail(t, "pool changed when it shouldn't have") - } } - // fill the gas pool - Require(t, pricing.SetGasPool_preExp(maxPool)) - pricing.SetGasPoolLastBlock(maxPool) - // show that running over the speed limit escalates the price before the pool drains colors.PrintBlue("exceeding the speed limit") for { - fakeBlockUpdate(t, pricing, 8*int64(limit), 1, arbosVersion) - if arbosVersion < FirstExponentialPricingVersion && getGasPool(t, pricing) < poolTarget { - Fail(t, "the price failed to rise before the pool drained") - } + fakeBlockUpdate(t, pricing, 8*int64(limit), 1) newPrice := getPrice(t, pricing) if newPrice < price { Fail(t, "the price shouldn't have fallen") @@ -107,44 +71,22 @@ func versionedTestPricingModel(t *testing.T, arbosVersion uint64) { } // empty the pool - pricing.SetRateEstimate(limit) price = getPrice(t, pricing) - rate := rateEstimate(t, pricing) - if arbosVersion < FirstExponentialPricingVersion { - Require(t, pricing.SetGasPool_preExp(0)) - pricing.SetGasPoolLastBlock(0) - } else { - Require(t, pricing.SetGasBacklog(100000000)) - } + Require(t, pricing.SetGasBacklog(100000000)) // show that nothing happens when no time has passed and no gas has been burnt colors.PrintBlue("nothing should happen") - fakeBlockUpdate(t, pricing, 0, 0, arbosVersion) - if arbosVersion < FirstExponentialPricingVersion && (getPrice(t, pricing) != price || getGasPool(t, pricing) != 0 || rateEstimate(t, pricing) != rate) { - Fail(t, "state shouldn't have changed") - } + fakeBlockUpdate(t, pricing, 0, 0) // show that the pool will escalate the price colors.PrintBlue("gas pool is empty") - fakeBlockUpdate(t, pricing, 0, 1, arbosVersion) + fakeBlockUpdate(t, pricing, 0, 1) if getPrice(t, pricing) <= price { fmt.Println(price, getPrice(t, pricing)) Fail(t, "price should have risen") } } -func maxGasPool(t *testing.T, pricing *L2PricingState) int64 { - value, err := pricing.GasPoolMax() - Require(t, err) - return value -} - -func getGasPool(t *testing.T, pricing *L2PricingState) int64 { - value, err := pricing.GasPool_preExp() - Require(t, err) - return value -} - func getPrice(t *testing.T, pricing *L2PricingState) uint64 { value, err := pricing.BaseFeeWei() Require(t, err) @@ -163,12 +105,6 @@ func getSpeedLimit(t *testing.T, pricing *L2PricingState) uint64 { return value } -func rateEstimate(t *testing.T, pricing *L2PricingState) uint64 { - value, err := pricing.RateEstimate() - Require(t, err) - return value -} - func Require(t *testing.T, err error, printables ...interface{}) { t.Helper() testhelpers.RequireImpl(t, err, printables...) diff --git a/arbos/l2pricing/model.go b/arbos/l2pricing/model.go index bd97ea2795..4f93cbffdd 100644 --- a/arbos/l2pricing/model.go +++ b/arbos/l2pricing/model.go @@ -6,10 +6,8 @@ package l2pricing import ( "math/big" - "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/util/arbmath" - "github.com/offchainlabs/nitro/util/colors" ) const InitialSpeedLimitPerSecond = 1000000 @@ -24,13 +22,7 @@ const InitialBacklogTolerance = 10 var InitialGasPoolTargetBips = arbmath.PercentToBips(80) var InitialGasPoolWeightBips = arbmath.PercentToBips(60) -const FirstExponentialPricingVersion = 4 - -func (ps *L2PricingState) AddToGasPool(gas int64, arbosVersion uint64) error { - if arbosVersion < FirstExponentialPricingVersion { - return ps.AddToGasPool_preExp(gas) - } - +func (ps *L2PricingState) AddToGasPool(gas int64) error { backlog, err := ps.GasBacklog() if err != nil { return err @@ -40,25 +32,10 @@ func (ps *L2PricingState) AddToGasPool(gas int64, arbosVersion uint64) error { return ps.SetGasBacklog(backlog) } -func (ps *L2PricingState) AddToGasPool_preExp(gas int64) error { - gasPool, err := ps.GasPool_preExp() - if err != nil { - return err - } - return ps.SetGasPool_preExp(arbmath.SaturatingAdd(gasPool, gas)) -} - // Update the pricing model with info from the last block -func (ps *L2PricingState) UpdatePricingModel(l2BaseFee *big.Int, timePassed uint64, arbosVersion uint64, debug bool) { - if arbosVersion < FirstExponentialPricingVersion { - // note: if we restart the chain at version >= FirstExponentialPricingVersion, - // we can simplify the L2-pricing-related params and precompiles - ps.UpdatePricingModel_preExp(l2BaseFee, timePassed, arbosVersion, debug) - return - } - +func (ps *L2PricingState) UpdatePricingModel(l2BaseFee *big.Int, timePassed uint64, debug bool) { speedLimit, _ := ps.SpeedLimitPerSecond() - _ = ps.AddToGasPool(int64(timePassed*speedLimit), arbosVersion) + _ = ps.AddToGasPool(int64(timePassed * speedLimit)) inertia, _ := ps.PricingInertia() tolerance, _ := ps.BacklogTolerance() backlog, _ := ps.GasBacklog() @@ -71,110 +48,3 @@ func (ps *L2PricingState) UpdatePricingModel(l2BaseFee *big.Int, timePassed uint } _ = ps.SetBaseFeeWei(baseFee) } - -func (ps *L2PricingState) UpdatePricingModel_preExp(l2BaseFee *big.Int, timePassed uint64, arbosVersion uint64, debug bool) { - - // update the rate estimate, which is the weighted average of the past and present - // rate' = weighted average of the historical rate and the current - // rate' = (memory * rate + passed * recent) / (memory + passed) - // rate' = (memory * rate + used) / (memory + passed) - // - gasPool, _ := ps.GasPool_preExp() - gasPoolLastBlock, _ := ps.GasPoolLastBlock() - poolMax, _ := ps.GasPoolMax() - gasPool = arbmath.MinInt(gasPool, poolMax) - gasPoolLastBlock = arbmath.MinInt(gasPoolLastBlock, poolMax) - gasUsed := uint64(gasPoolLastBlock - gasPool) - rateSeconds, _ := ps.RateEstimateInertia() - priorRate, _ := ps.RateEstimate() - rate := arbmath.SaturatingUAdd(arbmath.SaturatingUMul(rateSeconds, priorRate), gasUsed) / (rateSeconds + timePassed) - ps.SetRateEstimate(rate) - - // compute the rate ratio - // ratio = recent gas consumption rate / speed limit - // - speedLimit, _ := ps.SpeedLimitPerSecond() - rateRatio := arbmath.UfracToBigFloat(rate, speedLimit) - - // compute the pool fullness ratio & the updated gas pool - // ratio = max(0, 2 - (average fullness) / (target fullness)) - // pool' = min(maximum, pool + speed * passed) - // - timeToFull := (poolMax - gasPool) / int64(speedLimit) - var averagePool uint64 - var newGasPool int64 - if timePassed > uint64(timeToFull) { - spaceBefore := uint64(poolMax - gasPool) - averagePool = uint64(poolMax) - spaceBefore*spaceBefore/arbmath.SaturatingUMul(2*speedLimit, timePassed) - newGasPool = poolMax - } else { - averagePool = uint64(gasPool) + timePassed*speedLimit/2 - newGasPool = gasPool + int64(speedLimit*timePassed) - } - poolTarget, _ := ps.GasPoolTarget() - poolTargetGas := uint64(arbmath.IntMulByBips(poolMax, poolTarget)) - poolRatio := arbmath.UfracToBigFloat(0, 1) - if averagePool < 2*poolTargetGas { - poolRatio = arbmath.UfracToBigFloat(2*poolTargetGas-averagePool, poolTargetGas) - } - - // take the weighted average of the ratios, in basis points - // average = weight * pool + (1 - weight) * rate - // - poolWeight, _ := ps.GasPoolWeight() - oneInBips := arbmath.OneInBips - averageOfRatiosRaw, _ := arbmath.BigAddFloat( - arbmath.BigFloatMulByUint(poolRatio, uint64(poolWeight)), - arbmath.BigFloatMulByUint(rateRatio, uint64(oneInBips-poolWeight)), - ).Uint64() - averageOfRatios := arbmath.Bips(averageOfRatiosRaw) - averageOfRatiosUnbounded := averageOfRatios - if arbosVersion < 3 && averageOfRatios > arbmath.PercentToBips(200) { - averageOfRatios = arbmath.PercentToBips(200) - } - - // update the gas price, adjusting each second by the max allowed by EIP 1559 - // price' = price * exp(seconds at intensity) / 2 mins - // - exp := (averageOfRatios - arbmath.OneInBips) * arbmath.Bips(timePassed) / 120 // limit to EIP 1559's max rate - price := arbmath.BigMulByBips(l2BaseFee, arbmath.ApproxExpBasisPoints(exp)) - maxPrice := arbmath.BigMulByInt(l2BaseFee, params.ElasticityMultiplier) - minPrice, _ := ps.MinBaseFeeWei() - - p := func(args ...interface{}) { - if debug { - colors.PrintGrey(args...) - } - } - p("\nused\t", gasUsed, " in ", timePassed, "s = ", rate, "/s vs limit ", speedLimit, "/s for ", rateRatio) - p("pool\t", gasPool, "/", poolMax, " ➤ ", averagePool, " ➤ ", newGasPool, " ", poolRatio) - p("ratio\t", poolRatio, rateRatio, " ➤ ", averageOfRatiosUnbounded, "‱ ") - p("exp()\t", exp, " ➤ ", arbmath.ApproxExpBasisPoints(exp), "‱ ") - p("price\t", l2BaseFee, " ➤ ", price, " bound to [", minPrice, ", ", maxPrice, "]\n") - - if arbmath.BigLessThan(price, minPrice) { - price = minPrice - } - if arbmath.BigGreaterThan(price, maxPrice) { - log.Warn("ArbOS tried to 2x the price", "price", price, "bound", maxPrice) - price = maxPrice - } - _ = ps.SetBaseFeeWei(price) - _ = ps.SetGasPool_preExp(newGasPool) - ps.SetGasPoolLastBlock(newGasPool) -} - -func (ps *L2PricingState) PerBlockGasLimit(arbosVersion uint64) (uint64, error) { - if arbosVersion >= FirstExponentialPricingVersion { - return ps.MaxPerBlockGasLimit() - } - pool, _ := ps.GasPool_preExp() - maxLimit, err := ps.MaxPerBlockGasLimit() - if pool < 0 || err != nil { - return 0, err - } else if uint64(pool) > maxLimit { - return maxLimit, nil - } else { - return uint64(pool), nil - } -} diff --git a/arbos/tx_processor.go b/arbos/tx_processor.go index 178da66a0a..792bb2a817 100644 --- a/arbos/tx_processor.go +++ b/arbos/tx_processor.go @@ -290,7 +290,7 @@ func (p *TxProcessor) GasChargingHook(gasRemaining *uint64) error { if p.msg.RunMode() != types.MessageEthcallMode { // If this is a real tx, limit the amount of computed based on the gas pool. // We do this by charging extra gas, and then refunding it later. - gasAvailable, _ := p.state.L2PricingState().PerBlockGasLimit(p.state.FormatVersion()) + gasAvailable, _ := p.state.L2PricingState().PerBlockGasLimit() if *gasRemaining > gasAvailable { p.computeHoldGas = *gasRemaining - gasAvailable *gasRemaining = gasAvailable @@ -356,7 +356,7 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) { } } // we've already credited the network fee account, but we didn't charge the gas pool yet - p.state.Restrict(p.state.L2PricingState().AddToGasPool(-arbmath.SaturatingCast(gasUsed), p.state.FormatVersion())) + p.state.Restrict(p.state.L2PricingState().AddToGasPool(-arbmath.SaturatingCast(gasUsed))) return } @@ -390,7 +390,7 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) { log.Error("total gas used < poster gas component", "gasUsed", gasUsed, "posterGas", p.posterGas) computeGas = gasUsed } - p.state.Restrict(p.state.L2PricingState().AddToGasPool(-arbmath.SaturatingCast(computeGas), p.state.FormatVersion())) + p.state.Restrict(p.state.L2PricingState().AddToGasPool(-arbmath.SaturatingCast(computeGas))) } } @@ -443,19 +443,6 @@ func (p *TxProcessor) L1BlockHash(blockCtx vm.BlockContext, l1BlockNumber uint64 if err != nil { return common.Hash{}, err } - if state.FormatVersion() < 2 { - // Support the old broken behavior - var lower, upper uint64 - upper = p.evm.Context.BlockNumber.Uint64() - if upper < 257 { - lower = 0 - } else { - lower = upper - 256 - } - if l1BlockNumber < lower || l1BlockNumber >= upper { - return common.Hash{}, nil - } - } return state.Blockhashes().BlockHash(l1BlockNumber) } diff --git a/blockscout b/blockscout index f0a1e5fb5d..d320b2874e 160000 --- a/blockscout +++ b/blockscout @@ -1 +1 @@ -Subproject commit f0a1e5fb5d9c72859a0974ecf36c9a1c40f725ca +Subproject commit d320b2874ee301385a98a2e577d6fba75bcf3b2c diff --git a/contracts/src/precompiles/ArbGasInfo.sol b/contracts/src/precompiles/ArbGasInfo.sol index d4c1dfa65e..cd6f223118 100644 --- a/contracts/src/precompiles/ArbGasInfo.sol +++ b/contracts/src/precompiles/ArbGasInfo.sol @@ -75,7 +75,7 @@ interface ArbGasInfo { uint256 ); - /// @notice Get the gas accounting parameters + /// @notice Get the gas accounting parameters. `gasPoolMax` is always zero, as the exponential pricing model has no such notion. /// @return (speedLimitPerSecond, gasPoolMax, maxTxGasLimit) function getGasAccountingParams() external @@ -89,21 +89,6 @@ interface ArbGasInfo { /// @notice Get the minimum gas price needed for a tx to succeed function getMinimumGasPrice() external view returns (uint256); - /// @notice Get the number of seconds worth of the speed limit the gas pool contains - function getGasPoolSeconds() external view returns (uint64); - - /// @notice Get the target fullness in bips the pricing model will try to keep the pool at - function getGasPoolTarget() external view returns (uint64); - - /// @notice Get the extent in bips to which the pricing model favors filling the pool over increasing speeds - function getGasPoolWeight() external view returns (uint64); - - /// @notice Get ArbOS's estimate of the amount of gas being burnt per second - function getRateEstimate() external view returns (uint64); - - /// @notice Get how slowly ArbOS updates its estimate the amount of gas being burnt per second - function getRateEstimateInertia() external view returns (uint64); - /// @notice Get ArbOS's estimate of the L1 basefee in wei function getL1BaseFeeEstimate() external view returns (uint256); @@ -116,9 +101,6 @@ interface ArbGasInfo { /// @notice Get L1 gas fees paid by the current transaction function getCurrentTxL1GasFees() external view returns (uint256); - /// @notice Get the amount of gas remaining in the gas pool - function getGasPool() external view returns (int64); - /// @notice Get the backlogged amount of gas burnt in excess of the speed limit function getGasBacklog() external view returns (uint64); diff --git a/contracts/src/precompiles/ArbOwner.sol b/contracts/src/precompiles/ArbOwner.sol index a5f26b2754..f469b6ff53 100644 --- a/contracts/src/precompiles/ArbOwner.sol +++ b/contracts/src/precompiles/ArbOwner.sol @@ -39,18 +39,6 @@ interface ArbOwner { /// @notice Set the computational speed limit for the chain function setSpeedLimit(uint64 limit) external; - /// @notice Set the number of seconds worth of the speed limit the gas pool contains - function setGasPoolSeconds(uint64 factor) external; - - /// @notice Set the target fullness in bips the pricing model will try to keep the pool at - function setGasPoolTarget(uint64 target) external; - - /// @notice Set the extent in bips to which the pricing model favors filling the pool over increasing speeds - function setGasPoolWeight(uint64 weight) external; - - /// @notice Set how slowly ArbOS updates its estimate the amount of gas being burnt per second - function setRateEstimateInertia(uint64 inertia) external; - /// @notice Set the maximum size a tx (and block) can be function setMaxTxGasLimit(uint64 limit) external; diff --git a/contracts/src/precompiles/ArbosActs.sol b/contracts/src/precompiles/ArbosActs.sol index c4258fab88..61b349c09c 100644 --- a/contracts/src/precompiles/ArbosActs.sol +++ b/contracts/src/precompiles/ArbosActs.sol @@ -26,13 +26,11 @@ interface ArbosActs { /** * @notice ArbOS "calls" this when starting a block * @param l1BaseFee the L1 BaseFee - * @param l2BaseFeeLastBlock the L2 BaseFee in the last block's header * @param l1BlockNumber the L1 block number * @param timePassed number of seconds since the last block */ function startBlock( uint256 l1BaseFee, - uint256 l2BaseFeeLastBlock, uint64 l1BlockNumber, uint64 timePassed ) external; diff --git a/go-ethereum b/go-ethereum index f7082a87bb..7e332b7049 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit f7082a87bbe5e0b1ad122db47c096b87047e415b +Subproject commit 7e332b704961e33a5dd7edcc419e49d8de244bb5 diff --git a/nodeInterface/virtual-contracts.go b/nodeInterface/virtual-contracts.go index 1c6fbf292e..4c97fdd9ea 100644 --- a/nodeInterface/virtual-contracts.go +++ b/nodeInterface/virtual-contracts.go @@ -135,7 +135,7 @@ func init() { *gascap = arbmath.SaturatingUAdd(*gascap, posterCostInL2Gas) } - core.GetArbOSComputeRate = func(statedb *state.StateDB) (float64, error) { + core.GetArbOSSpeedLimitPerSecond = func(statedb *state.StateDB) (uint64, error) { arbosVersion := arbosState.ArbOSVersion(statedb) if arbosVersion == 0 { return 0.0, errors.New("ArbOS not installed") @@ -151,12 +151,7 @@ func init() { log.Error("failed to get the speed limit", "err", err) return 0.0, err } - rateEstimate, err := pricing.RateEstimate() - if err != nil { - log.Error("failed to get the rate estimate", "err", err) - return 0.0, err - } - return float64(rateEstimate) / float64(speedLimit), nil + return speedLimit, nil } arbSys, err := precompilesgen.ArbSysMetaData.GetAbi() diff --git a/precompiles/ArbGasInfo.go b/precompiles/ArbGasInfo.go index efa1e626ae..21578c2670 100644 --- a/precompiles/ArbGasInfo.go +++ b/precompiles/ArbGasInfo.go @@ -104,9 +104,8 @@ func (con ArbGasInfo) GetPricesInArbGas(c ctx, evm mech) (huge, huge, huge, erro func (con ArbGasInfo) GetGasAccountingParams(c ctx, evm mech) (huge, huge, huge, error) { l2pricing := c.State.L2PricingState() speedLimit, _ := l2pricing.SpeedLimitPerSecond() - gasPoolMax, _ := l2pricing.GasPoolMax() - maxTxGasLimit, err := l2pricing.MaxPerBlockGasLimit() - return arbmath.UintToBig(speedLimit), big.NewInt(gasPoolMax), arbmath.UintToBig(maxTxGasLimit), err + maxTxGasLimit, err := l2pricing.PerBlockGasLimit() + return arbmath.UintToBig(speedLimit), arbmath.UintToBig(maxTxGasLimit), arbmath.UintToBig(maxTxGasLimit), err } // Get the minimum gas price needed for a transaction to succeed @@ -114,33 +113,6 @@ func (con ArbGasInfo) GetMinimumGasPrice(c ctx, evm mech) (huge, error) { return c.State.L2PricingState().MinBaseFeeWei() } -// Get the number of seconds worth of the speed limit the gas pool contains -func (con ArbGasInfo) GetGasPoolSeconds(c ctx, evm mech) (uint64, error) { - return c.State.L2PricingState().GasPoolSeconds() -} - -// Get the target fullness in bips the pricing model will try to keep the pool at -func (con ArbGasInfo) GetGasPoolTarget(c ctx, evm mech) (uint64, error) { - target, err := c.State.L2PricingState().GasPoolTarget() - return uint64(target), err -} - -// Get the extent in bips to which the pricing model favors filling the pool over increasing speeds -func (con ArbGasInfo) GetGasPoolWeight(c ctx, evm mech) (uint64, error) { - weight, err := c.State.L2PricingState().GasPoolWeight() - return uint64(weight), err -} - -// Get ArbOS's estimate of the amount of gas being burnt per second -func (con ArbGasInfo) GetRateEstimate(c ctx, evm mech) (uint64, error) { - return c.State.L2PricingState().RateEstimate() -} - -// Get how slowly ArbOS updates its estimate the amount of gas being burnt per second -func (con ArbGasInfo) GetRateEstimateInertia(c ctx, evm mech) (uint64, error) { - return c.State.L2PricingState().RateEstimateInertia() -} - // Get the current estimate of the L1 basefee func (con ArbGasInfo) GetL1BaseFeeEstimate(c ctx, evm mech) (huge, error) { return c.State.L1PricingState().L1BaseFeeEstimateWei() @@ -161,11 +133,6 @@ func (con ArbGasInfo) GetCurrentTxL1GasFees(c ctx, evm mech) (huge, error) { return c.txProcessor.PosterFee, nil } -// Get the amount of gas remaining in the gas pool -func (con ArbGasInfo) GetGasPool(c ctx, evm mech) (int64, error) { - return c.State.L2PricingState().GasPool_preExp() -} - // Get the backlogged amount of gas burnt in excess of the speed limit func (con ArbGasInfo) GetGasBacklog(c ctx, evm mech) (uint64, error) { return c.State.L2PricingState().GasBacklog() diff --git a/precompiles/ArbOwner.go b/precompiles/ArbOwner.go index 4c3d7f349a..74fe94b69c 100644 --- a/precompiles/ArbOwner.go +++ b/precompiles/ArbOwner.go @@ -7,7 +7,6 @@ import ( "errors" "github.com/ethereum/go-ethereum/common" - "github.com/offchainlabs/nitro/util/arbmath" ) // This precompile provides owners with tools for managing the rollup. @@ -69,26 +68,6 @@ func (con ArbOwner) SetSpeedLimit(c ctx, evm mech, limit uint64) error { return c.State.L2PricingState().SetSpeedLimitPerSecond(limit) } -// Sets the number of seconds worth of the speed limit the gas pool contains -func (con ArbOwner) SetGasPoolSeconds(c ctx, evm mech, seconds uint64) error { - return c.State.L2PricingState().SetGasPoolSeconds(seconds) -} - -// Set the target fullness in bips the pricing model will try to keep the pool at -func (con ArbOwner) SetGasPoolTarget(c ctx, evm mech, target uint64) error { - return c.State.L2PricingState().SetGasPoolTarget(arbmath.SaturatingCastToBips(target)) -} - -// Set the extent in bips to which the pricing model favors filling the pool over increasing speeds -func (con ArbOwner) SetGasPoolWeight(c ctx, evm mech, weight uint64) error { - return c.State.L2PricingState().SetGasPoolWeight(arbmath.SaturatingCastToBips(weight)) -} - -// Set how slowly ArbOS updates its estimate the amount of gas being burnt per second -func (con ArbOwner) SetRateEstimateInertia(c ctx, evm mech, inertia uint64) error { - return c.State.L2PricingState().SetRateEstimateInertia(inertia) -} - // Sets the maximum size a tx (and block) can be func (con ArbOwner) SetMaxTxGasLimit(c ctx, evm mech, limit uint64) error { return c.State.L2PricingState().SetMaxPerBlockGasLimit(limit) diff --git a/precompiles/ArbRetryableTx.go b/precompiles/ArbRetryableTx.go index 13f3596951..f180082d98 100644 --- a/precompiles/ArbRetryableTx.go +++ b/precompiles/ArbRetryableTx.go @@ -118,7 +118,7 @@ func (con ArbRetryableTx) Redeem(c ctx, evm mech, ticketId bytes32) (bytes32, er // Add the gasToDonate back to the gas pool: the retryable attempt will then consume it. // This ensures that the gas pool has enough gas to run the retryable attempt. - return retryTxHash, c.State.L2PricingState().AddToGasPool(arbmath.SaturatingCast(gasToDonate), c.State.FormatVersion()) + return retryTxHash, c.State.L2PricingState().AddToGasPool(arbmath.SaturatingCast(gasToDonate)) } // Gets the default lifetime period a retryable has at creation diff --git a/precompiles/ArbSys.go b/precompiles/ArbSys.go index 162a676bdf..bbfdfd42ce 100644 --- a/precompiles/ArbSys.go +++ b/precompiles/ArbSys.go @@ -7,8 +7,6 @@ import ( "errors" "math/big" - "github.com/offchainlabs/nitro/arbos/l2pricing" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/vm" @@ -32,48 +30,6 @@ type ArbSys struct { var InvalidBlockNum = errors.New("Invalid block number") -func (con *ArbSys) emitL2ToL1Tx( - c ctx, - evm mech, - destination addr, - hash huge, - position huge, - ethBlockNum huge, - callvalue huge, - data []byte, -) error { - if c.State.FormatVersion() >= l2pricing.FirstExponentialPricingVersion { - return con.L2ToL1Tx( - c, - evm, - c.caller, - destination, - hash, - position, - evm.Context.BlockNumber, - ethBlockNum, - evm.Context.Time, - callvalue, - data, - ) - } else { - return con.L2ToL1Transaction( - c, - evm, - c.caller, - destination, - hash, - position, - big.NewInt(0), - evm.Context.BlockNumber, - ethBlockNum, - evm.Context.Time, - callvalue, - data, - ) - } -} - // Gets the current L2 block number func (con *ArbSys) ArbBlockNumber(c ctx, evm mech) (huge, error) { return evm.Context.BlockNumber, nil @@ -198,13 +154,16 @@ func (con *ArbSys) SendTxToL1(c ctx, evm mech, value huge, destination addr, cal leafNum := big.NewInt(int64(size - 1)) - err = con.emitL2ToL1Tx( + err = con.L2ToL1Tx( c, evm, + c.caller, destination, sendHash.Big(), leafNum, + evm.Context.BlockNumber, bigL1BlockNum, + evm.Context.Time, value, calldataForL1, ) diff --git a/precompiles/ArbosActs.go b/precompiles/ArbosActs.go index 9bc84d94d6..edb33496a2 100644 --- a/precompiles/ArbosActs.go +++ b/precompiles/ArbosActs.go @@ -11,6 +11,6 @@ type ArbosActs struct { CallerNotArbOSError func() error } -func (con ArbosActs) StartBlock(c ctx, evm mech, l1BaseFee, l2BaseFeeLastBlock huge, l1BlockNumber, timeLastBlock uint64) error { +func (con ArbosActs) StartBlock(c ctx, evm mech, l1BaseFee huge, l1BlockNumber, timeLastBlock uint64) error { return con.CallerNotArbOSError() } diff --git a/precompiles/wrapper.go b/precompiles/wrapper.go index 69dc29f4d0..00e233ba18 100644 --- a/precompiles/wrapper.go +++ b/precompiles/wrapper.go @@ -92,7 +92,7 @@ func (wrapper *OwnerPrecompile) Call( return nil, burner.gasLeft, err } - if !isOwner && (state.FormatVersion() >= 2 || caller != arbosState.TestnetUpgrade2Owner) { + if !isOwner { return nil, burner.gasLeft, errors.New("unauthorized caller to access-controlled method") } diff --git a/system_tests/replay_fuzz/replay_fuzz.go b/system_tests/replay_fuzz/replay_fuzz.go index f296e082de..1dc21bae1c 100644 --- a/system_tests/replay_fuzz/replay_fuzz.go +++ b/system_tests/replay_fuzz/replay_fuzz.go @@ -105,7 +105,7 @@ func (c noopChainContext) GetHeader(common.Hash, uint64) *types.Header { func Fuzz(input []byte) int { chainDb := rawdb.NewMemoryDatabase() - stateRoot, err := arbosState.InitializeArbosInDatabase(chainDb, statetransfer.NewMemoryInitDataReader(&statetransfer.ArbosInitializationInfo{}), params.ArbitrumTestnetChainConfig()) + stateRoot, err := arbosState.InitializeArbosInDatabase(chainDb, statetransfer.NewMemoryInitDataReader(&statetransfer.ArbosInitializationInfo{}), params.ArbitrumDevnetChainConfig()) if err != nil { panic(err) }