diff --git a/.changeset/calm-ants-dream.md b/.changeset/calm-ants-dream.md new file mode 100644 index 000000000000..15908ea02cba --- /dev/null +++ b/.changeset/calm-ants-dream.md @@ -0,0 +1,5 @@ +--- +'@eth-optimism/l2geth': patch +--- + +Add new config `ROLLUP_GAS_PRICE_ORACLE_OWNER_ADDRESS` to set the owner of the gas price oracle at runtime diff --git a/.changeset/odd-shrimps-laugh.md b/.changeset/odd-shrimps-laugh.md new file mode 100644 index 000000000000..cf599708e9af --- /dev/null +++ b/.changeset/odd-shrimps-laugh.md @@ -0,0 +1,5 @@ +--- +'@eth-optimism/l2geth': patch +--- + +Removes config options that are no longer required. `ROLLUP_DATAPRICE`, `ROLLUP_EXECUTION_PRICE`, `ROLLUP_GAS_PRICE_ORACLE_ADDRESS` and `ROLLUP_ENABLE_L2_GAS_POLLING`. The oracle was moved to a predeploy 0x42.. address and polling is always enabled as it no longer needs to be backwards compatible diff --git a/l2geth/cmd/geth/main.go b/l2geth/cmd/geth/main.go index 957a7f1655c3..5a183bd1d0bb 100644 --- a/l2geth/cmd/geth/main.go +++ b/l2geth/cmd/geth/main.go @@ -164,12 +164,9 @@ var ( utils.RollupStateDumpPathFlag, utils.RollupDiffDbFlag, utils.RollupMaxCalldataSizeFlag, - utils.RollupDataPriceFlag, - utils.RollupExecutionPriceFlag, utils.RollupBackendFlag, - utils.RollupEnableL2GasPollingFlag, - utils.RollupGasPriceOracleAddressFlag, utils.RollupEnforceFeesFlag, + utils.GasPriceOracleOwnerAddress, } rpcFlags = []cli.Flag{ diff --git a/l2geth/cmd/geth/usage.go b/l2geth/cmd/geth/usage.go index ea5462fa4591..8b9cf2231668 100644 --- a/l2geth/cmd/geth/usage.go +++ b/l2geth/cmd/geth/usage.go @@ -79,12 +79,9 @@ var AppHelpFlagGroups = []flagGroup{ utils.RollupStateDumpPathFlag, utils.RollupDiffDbFlag, utils.RollupMaxCalldataSizeFlag, - utils.RollupDataPriceFlag, - utils.RollupExecutionPriceFlag, utils.RollupBackendFlag, - utils.RollupEnableL2GasPollingFlag, - utils.RollupGasPriceOracleAddressFlag, utils.RollupEnforceFeesFlag, + utils.GasPriceOracleOwnerAddress, }, }, { diff --git a/l2geth/cmd/utils/flags.go b/l2geth/cmd/utils/flags.go index 684a151c576f..9c29027f2498 100644 --- a/l2geth/cmd/utils/flags.go +++ b/l2geth/cmd/utils/flags.go @@ -863,7 +863,6 @@ var ( Value: "l1", EnvVar: "ROLLUP_BACKEND", } - // Flag to enable verifier mode RollupEnableVerifierFlag = cli.BoolFlag{ Name: "rollup.verifier", Usage: "Enable the verifier", @@ -893,34 +892,16 @@ var ( Value: eth.DefaultConfig.Rollup.MaxCallDataSize, EnvVar: "ROLLUP_MAX_CALLDATA_SIZE", } - RollupDataPriceFlag = BigFlag{ - Name: "rollup.dataprice", - Usage: "The L1 calldata price to use for the sequencer fees", - Value: eth.DefaultConfig.Rollup.DataPrice, - EnvVar: "ROLLUP_DATAPRICE", - } - RollupExecutionPriceFlag = BigFlag{ - Name: "rollup.executionprice", - Usage: "The execution gas price to use for the sequencer fees", - Value: eth.DefaultConfig.Rollup.ExecutionPrice, - EnvVar: "ROLLUP_EXECUTIONPRICE", - } - RollupGasPriceOracleAddressFlag = cli.StringFlag{ - Name: "rollup.gaspriceoracleaddress", - Usage: "Address of the rollup gas price oracle", - Value: "0x0000000000000000000000000000000000000000", - EnvVar: "ROLLUP_GAS_PRICE_ORACLE_ADDRESS", - } - RollupEnableL2GasPollingFlag = cli.BoolFlag{ - Name: "rollup.enablel2gaspolling", - Usage: "Poll for the L2 gas price from the L2 state", - EnvVar: "ROLLUP_ENABLE_L2_GAS_POLLING", - } RollupEnforceFeesFlag = cli.BoolFlag{ Name: "rollup.enforcefeesflag", Usage: "Disable transactions with 0 gas price", EnvVar: "ROLLUP_ENFORCE_FEES", } + GasPriceOracleOwnerAddress = cli.StringFlag{ + Name: "rollup.gaspriceoracleowneraddress", + Usage: "Owner of the OVM_GasPriceOracle", + EnvVar: "ROLLUP_GAS_PRICE_ORACLE_OWNER_ADDRESS", + } ) // MakeDataDir retrieves the currently requested data directory, terminating @@ -1198,11 +1179,9 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) { if ctx.GlobalIsSet(RollupTimstampRefreshFlag.Name) { cfg.TimestampRefreshThreshold = ctx.GlobalDuration(RollupTimstampRefreshFlag.Name) } - if ctx.GlobalIsSet(RollupDataPriceFlag.Name) { - cfg.DataPrice = GlobalBig(ctx, RollupDataPriceFlag.Name) - } - if ctx.GlobalIsSet(RollupExecutionPriceFlag.Name) { - cfg.ExecutionPrice = GlobalBig(ctx, RollupExecutionPriceFlag.Name) + if ctx.GlobalIsSet(GasPriceOracleOwnerAddress.Name) { + addr := ctx.GlobalString(GasPriceOracleOwnerAddress.Name) + cfg.GasPriceOracleOwnerAddress = common.HexToAddress(addr) } if ctx.GlobalIsSet(RollupBackendFlag.Name) { val := ctx.GlobalString(RollupBackendFlag.Name) @@ -1213,13 +1192,6 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) { } cfg.Backend = backend } - if ctx.GlobalIsSet(RollupGasPriceOracleAddressFlag.Name) { - addr := ctx.GlobalString(RollupGasPriceOracleAddressFlag.Name) - cfg.GasPriceOracleAddress = common.HexToAddress(addr) - } - if ctx.GlobalIsSet(RollupEnableL2GasPollingFlag.Name) { - cfg.EnableL2GasPolling = true - } if ctx.GlobalIsSet(RollupEnforceFeesFlag.Name) { cfg.EnforceFees = true } @@ -1790,8 +1762,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { l1FeeWalletAddress := cfg.Rollup.L1FeeWalletAddress addrManagerOwnerAddress := cfg.Rollup.AddressManagerOwnerAddress l1ETHGatewayAddress := cfg.Rollup.L1ETHGatewayAddress + gpoOwnerAddress := cfg.Rollup.GasPriceOracleOwnerAddress stateDumpPath := cfg.Rollup.StateDumpPath - cfg.Genesis = core.DeveloperGenesisBlock(uint64(ctx.GlobalInt(DeveloperPeriodFlag.Name)), developer.Address, xdomainAddress, l1ETHGatewayAddress, addrManagerOwnerAddress, l1FeeWalletAddress, stateDumpPath, chainID, gasLimit) + cfg.Genesis = core.DeveloperGenesisBlock(uint64(ctx.GlobalInt(DeveloperPeriodFlag.Name)), developer.Address, xdomainAddress, l1ETHGatewayAddress, addrManagerOwnerAddress, gpoOwnerAddress, l1FeeWalletAddress, stateDumpPath, chainID, gasLimit) if !ctx.GlobalIsSet(MinerGasPriceFlag.Name) && !ctx.GlobalIsSet(MinerLegacyGasPriceFlag.Name) { cfg.Miner.GasPrice = big.NewInt(1) } diff --git a/l2geth/console/console_test.go b/l2geth/console/console_test.go index 22da70013845..4a835d2b9519 100644 --- a/l2geth/console/console_test.go +++ b/l2geth/console/console_test.go @@ -98,7 +98,7 @@ func newTester(t *testing.T, confOverride func(*eth.Config)) *tester { t.Fatalf("failed to create node: %v", err) } ethConf := ð.Config{ - Genesis: core.DeveloperGenesisBlock(15, common.Address{}, common.Address{}, common.Address{}, common.Address{}, common.Address{}, "", nil, 12000000), + Genesis: core.DeveloperGenesisBlock(15, common.Address{}, common.Address{}, common.Address{}, common.Address{}, common.Address{}, common.Address{}, "", nil, 12000000), Miner: miner.Config{ Etherbase: common.HexToAddress(testAddress), }, diff --git a/l2geth/core/genesis.go b/l2geth/core/genesis.go index 465fcbb52b4f..6fd5a812cbe5 100644 --- a/l2geth/core/genesis.go +++ b/l2geth/core/genesis.go @@ -73,6 +73,7 @@ type Genesis struct { L1CrossDomainMessengerAddress common.Address `json:"-"` AddressManagerOwnerAddress common.Address `json:"-"` L1ETHGatewayAddress common.Address `json:"-"` + GasPriceOracleOwnerAddress common.Address `json:"-"` ChainID *big.Int `json:"-"` } @@ -267,7 +268,7 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig { } // ApplyOvmStateToState applies the initial OVM state to a state object. -func ApplyOvmStateToState(statedb *state.StateDB, stateDump *dump.OvmDump, l1XDomainMessengerAddress common.Address, l1ETHGatewayAddress common.Address, addrManagerOwnerAddress common.Address, l1FeeWalletAddress common.Address, chainID *big.Int, gasLimit uint64) { +func ApplyOvmStateToState(statedb *state.StateDB, stateDump *dump.OvmDump, l1XDomainMessengerAddress, l1ETHGatewayAddress, addrManagerOwnerAddress, gpoOwnerAddress, l1FeeWalletAddress common.Address, chainID *big.Int, gasLimit uint64) { if len(stateDump.Accounts) == 0 { return } @@ -305,7 +306,7 @@ func ApplyOvmStateToState(statedb *state.StateDB, stateDump *dump.OvmDump, l1XDo log.Info("Setting OVM_L1ETHGateway in OVM_ETH", "address", l1ETHGatewayAddress.Hex()) if strings.Contains(OVM_ETH.Code, "a84ce98") { // Set the gateway of OVM_ETH at new dump - log.Info("Detected current OVM_ETH dump, setting slot 0x1 ") + log.Info("Detected current OVM_ETH dump, setting slot 0x1") l1GatewaySlot := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001") l1GatewayValue := common.BytesToHash(l1ETHGatewayAddress.Bytes()) statedb.SetState(OVM_ETH.Address, l1GatewaySlot, l1GatewayValue) @@ -337,6 +338,13 @@ func ApplyOvmStateToState(statedb *state.StateDB, stateDump *dump.OvmDump, l1XDo l1FeeWalletSlot := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000") l1FeeWalletValue := common.BytesToHash(l1FeeWalletAddress.Bytes()) statedb.SetState(OVM_SequencerFeeVault.Address, l1FeeWalletSlot, l1FeeWalletValue) + GasPriceOracle, ok := stateDump.Accounts["OVM_GasPriceOracle"] + if ok { + ownerSlot := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000") + ownerValue := common.BytesToHash(gpoOwnerAddress.Bytes()) + statedb.SetState(GasPriceOracle.Address, ownerSlot, ownerValue) + log.Info("Setting GasPriceOracle Owner", "owner", gpoOwnerAddress.Hex()) + } } } @@ -350,7 +358,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block { if vm.UsingOVM { // OVM_ENABLED - ApplyOvmStateToState(statedb, g.Config.StateDump, g.L1CrossDomainMessengerAddress, g.L1ETHGatewayAddress, g.AddressManagerOwnerAddress, g.L1FeeWalletAddress, g.ChainID, g.GasLimit) + ApplyOvmStateToState(statedb, g.Config.StateDump, g.L1CrossDomainMessengerAddress, g.L1ETHGatewayAddress, g.AddressManagerOwnerAddress, g.GasPriceOracleOwnerAddress, g.L1FeeWalletAddress, g.ChainID, g.GasLimit) } for addr, account := range g.Alloc { @@ -477,7 +485,7 @@ func DefaultGoerliGenesisBlock() *Genesis { } // DeveloperGenesisBlock returns the 'geth --dev' genesis block. -func DeveloperGenesisBlock(period uint64, faucet, l1XDomainMessengerAddress common.Address, l1ETHGatewayAddress common.Address, addrManagerOwnerAddress common.Address, l1FeeWalletAddress common.Address, stateDumpPath string, chainID *big.Int, gasLimit uint64) *Genesis { +func DeveloperGenesisBlock(period uint64, faucet, l1XDomainMessengerAddress common.Address, l1ETHGatewayAddress common.Address, addrManagerOwnerAddress, gpoOwnerAddress, l1FeeWalletAddress common.Address, stateDumpPath string, chainID *big.Int, gasLimit uint64) *Genesis { // Override the default period to the user requested one config := *params.AllCliqueProtocolChanges config.Clique.Period = period @@ -536,6 +544,7 @@ func DeveloperGenesisBlock(period uint64, faucet, l1XDomainMessengerAddress comm L1FeeWalletAddress: l1FeeWalletAddress, AddressManagerOwnerAddress: addrManagerOwnerAddress, L1ETHGatewayAddress: l1ETHGatewayAddress, + GasPriceOracleOwnerAddress: gpoOwnerAddress, ChainID: config.ChainID, } } diff --git a/l2geth/eth/backend.go b/l2geth/eth/backend.go index 740b73ac1ff7..1892d2f3ef75 100644 --- a/l2geth/eth/backend.go +++ b/l2geth/eth/backend.go @@ -226,7 +226,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { eth.miner = miner.New(eth, &config.Miner, chainConfig, eth.EventMux(), eth.engine, eth.isLocalBlock) eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData)) - log.Info("Backend Config", "max-calldata-size", config.Rollup.MaxCallDataSize, "gas-limit", config.Rollup.GasLimit, "is-verifier", config.Rollup.IsVerifier, "using-ovm", vm.UsingOVM, "data-price", config.Rollup.DataPrice, "execution-price", config.Rollup.ExecutionPrice) + log.Info("Backend Config", "max-calldata-size", config.Rollup.MaxCallDataSize, "gas-limit", config.Rollup.GasLimit, "is-verifier", config.Rollup.IsVerifier, "using-ovm", vm.UsingOVM) eth.APIBackend = &EthAPIBackend{ctx.ExtRPCEnabled(), eth, nil, nil, config.Rollup.IsVerifier, config.Rollup.GasLimit, vm.UsingOVM, config.Rollup.MaxCallDataSize} gpoParams := config.GPO if gpoParams.Default == nil { @@ -234,7 +234,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { } eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams) // create the Rollup GPO and allow the API backend and the sync service to access it - rollupGpo := gasprice.NewRollupOracle(config.Rollup.DataPrice, config.Rollup.ExecutionPrice) + rollupGpo := gasprice.NewRollupOracle() eth.APIBackend.rollupGpo = rollupGpo eth.syncService.RollupGpo = rollupGpo return eth, nil diff --git a/l2geth/eth/config.go b/l2geth/eth/config.go index 33186b0935cc..63b0e1ad091d 100644 --- a/l2geth/eth/config.go +++ b/l2geth/eth/config.go @@ -81,8 +81,6 @@ var DefaultConfig = Config{ // is additional overhead that is unaccounted. Round down to 127000 for // safety. MaxCallDataSize: 127000, - DataPrice: big.NewInt(100 * params.GWei), - ExecutionPrice: big.NewInt(0), }, DiffDbCache: 256, } diff --git a/l2geth/eth/gasprice/rollup_gasprice.go b/l2geth/eth/gasprice/rollup_gasprice.go index 7b0a062e6c41..ac4166dea95e 100644 --- a/l2geth/eth/gasprice/rollup_gasprice.go +++ b/l2geth/eth/gasprice/rollup_gasprice.go @@ -17,10 +17,12 @@ type RollupOracle struct { } // NewRollupOracle returns an initialized RollupOracle -func NewRollupOracle(l1GasPrice *big.Int, l2GasPrice *big.Int) *RollupOracle { +func NewRollupOracle() *RollupOracle { return &RollupOracle{ - l1GasPrice: l1GasPrice, - l2GasPrice: l2GasPrice, + l1GasPrice: new(big.Int), + l2GasPrice: new(big.Int), + l1GasPriceLock: sync.RWMutex{}, + l2GasPriceLock: sync.RWMutex{}, } } diff --git a/l2geth/rollup/config.go b/l2geth/rollup/config.go index b5778fab0a88..a2b87011a26b 100644 --- a/l2geth/rollup/config.go +++ b/l2geth/rollup/config.go @@ -26,7 +26,7 @@ type Config struct { L1FeeWalletAddress common.Address AddressManagerOwnerAddress common.Address L1ETHGatewayAddress common.Address - GasPriceOracleAddress common.Address + GasPriceOracleOwnerAddress common.Address // Turns on checking of state for L2 gas price EnableL2GasPolling bool // Deployment Height of the canonical transaction chain @@ -37,10 +37,6 @@ type Config struct { PollInterval time.Duration // Interval for updating the timestamp TimestampRefreshThreshold time.Duration - // The gas price to use when estimating L1 calldata publishing costs - DataPrice *big.Int - // The gas price to use for L2 congestion costs - ExecutionPrice *big.Int // Represents the source of the transactions that is being synced Backend Backend // Only accept transactions with fees diff --git a/l2geth/rollup/sync_service.go b/l2geth/rollup/sync_service.go index ad674a799e8d..72f7209ad43e 100644 --- a/l2geth/rollup/sync_service.go +++ b/l2geth/rollup/sync_service.go @@ -31,6 +31,7 @@ var errShortRemoteTip = errors.New("Unexpected remote less than tip") // L2GasPrice slot refers to the storage slot that the execution price is stored // in the L2 predeploy contract, the GasPriceOracle var l2GasPriceSlot = common.BigToHash(big.NewInt(1)) +var l2GasPriceOracleAddress = common.HexToAddress("0x420000000000000000000000000000000000000F") // SyncService implements the main functionality around pulling in transactions // and executing them. It can be configured to run in both sequencer mode and in @@ -58,8 +59,6 @@ type SyncService struct { timestampRefreshThreshold time.Duration chainHeadCh chan core.ChainHeadEvent backend Backend - gpoAddress common.Address - enableL2GasPolling bool enforceFees bool } @@ -114,8 +113,6 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co pollInterval: pollInterval, timestampRefreshThreshold: timestampRefreshThreshold, backend: cfg.Backend, - gpoAddress: cfg.GasPriceOracleAddress, - enableL2GasPolling: cfg.EnableL2GasPolling, enforceFees: cfg.EnforceFees, } @@ -430,11 +427,6 @@ func (s *SyncService) updateL1GasPrice() error { // price oracle at the state that corresponds to the state root. If no state // root is passed in, then the tip is used. func (s *SyncService) updateL2GasPrice(hash *common.Hash) error { - // TODO(mark): this is temporary and will be able to be rmoved when the - // OVM_GasPriceOracle is moved into the predeploy contracts - if !s.enableL2GasPolling { - return nil - } var state *state.StateDB var err error if hash != nil { @@ -445,7 +437,7 @@ func (s *SyncService) updateL2GasPrice(hash *common.Hash) error { if err != nil { return err } - result := state.GetState(s.gpoAddress, l2GasPriceSlot) + result := state.GetState(l2GasPriceOracleAddress, l2GasPriceSlot) s.RollupGpo.SetL2GasPrice(result.Big()) return nil } diff --git a/l2geth/rollup/sync_service_test.go b/l2geth/rollup/sync_service_test.go index 8ba60a3facb5..62e543d690f4 100644 --- a/l2geth/rollup/sync_service_test.go +++ b/l2geth/rollup/sync_service_test.go @@ -516,8 +516,6 @@ func TestSyncServiceL2GasPrice(t *testing.T) { if err != nil { t.Fatal(err) } - service.enableL2GasPolling = true - service.gpoAddress = common.HexToAddress("0xF20b338752976878754518183873602902360704") price, err := service.RollupGpo.SuggestL2GasPrice(context.Background()) if err != nil { @@ -533,7 +531,7 @@ func TestSyncServiceL2GasPrice(t *testing.T) { t.Fatal("Cannot get state db") } l2GasPrice := big.NewInt(100000000000) - state.SetState(service.gpoAddress, l2GasPriceSlot, common.BigToHash(l2GasPrice)) + state.SetState(l2GasPriceOracleAddress, l2GasPriceSlot, common.BigToHash(l2GasPrice)) root, _ := state.Commit(false) service.updateL2GasPrice(&root) @@ -695,7 +693,7 @@ func newTestSyncService(isVerifier bool) (*SyncService, chan core.NewTxsEvent, e return nil, nil, nil, fmt.Errorf("Cannot initialize syncservice: %w", err) } - service.RollupGpo = gasprice.NewRollupOracle(big.NewInt(0), big.NewInt(0)) + service.RollupGpo = gasprice.NewRollupOracle() txCh := make(chan core.NewTxsEvent, 1) sub := service.SubscribeNewTxsEvent(txCh) @@ -717,7 +715,7 @@ type mockClient struct { func setupMockClient(service *SyncService, responses map[string]interface{}) { client := newMockClient(responses) service.client = client - service.RollupGpo = gasprice.NewRollupOracle(big.NewInt(0), big.NewInt(0)) + service.RollupGpo = gasprice.NewRollupOracle() } func newMockClient(responses map[string]interface{}) *mockClient {