Skip to content

Commit

Permalink
Merge pull request #2436 from OffchainLabs/stylus_pricing
Browse files Browse the repository at this point in the history
update minInitGas for stylus v2
  • Loading branch information
tsahee authored Jun 26, 2024
2 parents e2c0347 + bc1b891 commit dd8cf65
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion arbos/arbosState/arbosstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func (state *ArbosState) UpgradeArbosVersion(
case 31:
params, err := state.Programs().Params()
ensure(err)
params.Version = 2
ensure(params.UpgradeToVersion(2))
ensure(params.Save())

default:
Expand Down
15 changes: 15 additions & 0 deletions arbos/programs/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package programs

import (
"errors"
"fmt"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
Expand All @@ -29,6 +30,8 @@ const initialExpiryDays = 365 // deactivate after 1 year.
const initialKeepaliveDays = 31 // wait a month before allowing reactivation.
const initialRecentCacheSize = 32 // cache the 32 most recent programs.

const v2MinInitGas = 69 // charge 69 * 128 = 8832 gas (minCachedGas will also be charged in v2).

const MinCachedGasUnits = 32 /// 32 gas for each unit
const MinInitGasUnits = 128 // 128 gas for each unit
const CostScalarPercent = 2 // 2% for each unit
Expand Down Expand Up @@ -137,6 +140,18 @@ func (p *StylusParams) Save() error {
return nil
}

func (p *StylusParams) UpgradeToVersion(version uint16) error {
if version != 2 {
return fmt.Errorf("dest version not supported for upgrade")
}
if p.Version != 1 {
return fmt.Errorf("existing version not supported for upgrade")
}
p.Version = 2
p.MinInitGas = v2MinInitGas
return nil
}

func initStylusParams(sto *storage.Storage) {
params := &StylusParams{
backingStorage: sto,
Expand Down

0 comments on commit dd8cf65

Please sign in to comment.