Skip to content

Commit

Permalink
Merge pull request #1549 from OffchainLabs/update-l1-pricing-params
Browse files Browse the repository at this point in the history
Update L1 pricing params to more accurate values in ArbOS version 11
  • Loading branch information
PlasmaPower authored Aug 2, 2023
2 parents f5e7c28 + 2084869 commit dd013d5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
15 changes: 13 additions & 2 deletions arbos/arbosState/arbosstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,16 @@ func (state *ArbosState) UpgradeArbosVersion(
ErrFatalNodeOutOfDate,
)
}
// no state changes needed
// Update the PerBatchGasCost to a more accurate value compared to the old v6 default.
ensure(state.l1PricingState.SetPerBatchGasCost(l1pricing.InitialPerBatchGasCostV12))

// We had mistakenly initialized AmortizedCostCapBips to math.MaxUint64 in older versions,
// but the correct value to disable the amortization cap is 0.
oldAmortizationCap, err := state.l1PricingState.AmortizedCostCapBips()
ensure(err)
if oldAmortizationCap == math.MaxUint64 {
ensure(state.l1PricingState.SetAmortizedCostCapBips(0))
}
default:
return fmt.Errorf(
"the chain is upgrading to unsupported ArbOS version %v, %w",
Expand All @@ -315,7 +324,9 @@ func (state *ArbosState) UpgradeArbosVersion(
}

if firstTime && upgradeTo >= 6 {
state.Restrict(state.l1PricingState.SetPerBatchGasCost(l1pricing.InitialPerBatchGasCostV6))
if upgradeTo < 11 {
state.Restrict(state.l1PricingState.SetPerBatchGasCost(l1pricing.InitialPerBatchGasCostV6))
}
state.Restrict(state.l1PricingState.SetEquilibrationUnits(l1pricing.InitialEquilibrationUnitsV6))
state.Restrict(state.l2PricingState.SetSpeedLimitPerSecond(l2pricing.InitialSpeedLimitPerSecondV6))
state.Restrict(state.l2PricingState.SetMaxPerBlockGasLimit(l2pricing.InitialPerBlockGasLimitV6))
Expand Down
7 changes: 4 additions & 3 deletions arbos/l1pricing/l1pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ const (
)

const (
InitialInertia = 10
InitialPerUnitReward = 10
InitialPerBatchGasCostV6 = 100000
InitialInertia = 10
InitialPerUnitReward = 10
InitialPerBatchGasCostV6 = 100_000
InitialPerBatchGasCostV12 = 210_000 // overriden as part of the upgrade
)

// one minute at 100000 bytes / sec
Expand Down
15 changes: 6 additions & 9 deletions precompiles/ArbOwner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,17 @@ import (
"math/big"
"testing"

"github.com/offchainlabs/nitro/arbos/l1pricing"

"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"

"github.com/offchainlabs/nitro/arbos/arbosState"
"github.com/offchainlabs/nitro/arbos/burn"
"github.com/offchainlabs/nitro/util/testhelpers"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/offchainlabs/nitro/arbos/l1pricing"
"github.com/offchainlabs/nitro/arbos/util"
"github.com/offchainlabs/nitro/util/testhelpers"
)

func TestArbOwner(t *testing.T) {
Expand Down Expand Up @@ -99,7 +96,7 @@ func TestArbOwner(t *testing.T) {

costCap, err := gasInfo.GetAmortizedCostCapBips(callCtx, evm)
Require(t, err)
if costCap != math.MaxUint64 {
if costCap != 0 {
Fail(t, costCap)
}
newCostCap := uint64(77734)
Expand Down

0 comments on commit dd013d5

Please sign in to comment.