Commit 01646a0a authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

fix: predeploy gasprice oracle (#1039)

* l2geth: delete extra config options

* l2geth: stop using extra config options

* l2geth: more stop using extra config options

* chore: add changeset

* l2geth: add new config for gpo owner

* chore: add changeset

* l2geth: fix tests

* tests: fix build
parent e045f582
---
'@eth-optimism/l2geth': patch
---
Add new config `ROLLUP_GAS_PRICE_ORACLE_OWNER_ADDRESS` to set the owner of the gas price oracle at runtime
---
'@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
...@@ -164,12 +164,9 @@ var ( ...@@ -164,12 +164,9 @@ var (
utils.RollupStateDumpPathFlag, utils.RollupStateDumpPathFlag,
utils.RollupDiffDbFlag, utils.RollupDiffDbFlag,
utils.RollupMaxCalldataSizeFlag, utils.RollupMaxCalldataSizeFlag,
utils.RollupDataPriceFlag,
utils.RollupExecutionPriceFlag,
utils.RollupBackendFlag, utils.RollupBackendFlag,
utils.RollupEnableL2GasPollingFlag,
utils.RollupGasPriceOracleAddressFlag,
utils.RollupEnforceFeesFlag, utils.RollupEnforceFeesFlag,
utils.GasPriceOracleOwnerAddress,
} }
rpcFlags = []cli.Flag{ rpcFlags = []cli.Flag{
......
...@@ -79,12 +79,9 @@ var AppHelpFlagGroups = []flagGroup{ ...@@ -79,12 +79,9 @@ var AppHelpFlagGroups = []flagGroup{
utils.RollupStateDumpPathFlag, utils.RollupStateDumpPathFlag,
utils.RollupDiffDbFlag, utils.RollupDiffDbFlag,
utils.RollupMaxCalldataSizeFlag, utils.RollupMaxCalldataSizeFlag,
utils.RollupDataPriceFlag,
utils.RollupExecutionPriceFlag,
utils.RollupBackendFlag, utils.RollupBackendFlag,
utils.RollupEnableL2GasPollingFlag,
utils.RollupGasPriceOracleAddressFlag,
utils.RollupEnforceFeesFlag, utils.RollupEnforceFeesFlag,
utils.GasPriceOracleOwnerAddress,
}, },
}, },
{ {
......
...@@ -863,7 +863,6 @@ var ( ...@@ -863,7 +863,6 @@ var (
Value: "l1", Value: "l1",
EnvVar: "ROLLUP_BACKEND", EnvVar: "ROLLUP_BACKEND",
} }
// Flag to enable verifier mode
RollupEnableVerifierFlag = cli.BoolFlag{ RollupEnableVerifierFlag = cli.BoolFlag{
Name: "rollup.verifier", Name: "rollup.verifier",
Usage: "Enable the verifier", Usage: "Enable the verifier",
...@@ -893,34 +892,16 @@ var ( ...@@ -893,34 +892,16 @@ var (
Value: eth.DefaultConfig.Rollup.MaxCallDataSize, Value: eth.DefaultConfig.Rollup.MaxCallDataSize,
EnvVar: "ROLLUP_MAX_CALLDATA_SIZE", 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{ RollupEnforceFeesFlag = cli.BoolFlag{
Name: "rollup.enforcefeesflag", Name: "rollup.enforcefeesflag",
Usage: "Disable transactions with 0 gas price", Usage: "Disable transactions with 0 gas price",
EnvVar: "ROLLUP_ENFORCE_FEES", 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 // MakeDataDir retrieves the currently requested data directory, terminating
...@@ -1198,11 +1179,9 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) { ...@@ -1198,11 +1179,9 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) {
if ctx.GlobalIsSet(RollupTimstampRefreshFlag.Name) { if ctx.GlobalIsSet(RollupTimstampRefreshFlag.Name) {
cfg.TimestampRefreshThreshold = ctx.GlobalDuration(RollupTimstampRefreshFlag.Name) cfg.TimestampRefreshThreshold = ctx.GlobalDuration(RollupTimstampRefreshFlag.Name)
} }
if ctx.GlobalIsSet(RollupDataPriceFlag.Name) { if ctx.GlobalIsSet(GasPriceOracleOwnerAddress.Name) {
cfg.DataPrice = GlobalBig(ctx, RollupDataPriceFlag.Name) addr := ctx.GlobalString(GasPriceOracleOwnerAddress.Name)
} cfg.GasPriceOracleOwnerAddress = common.HexToAddress(addr)
if ctx.GlobalIsSet(RollupExecutionPriceFlag.Name) {
cfg.ExecutionPrice = GlobalBig(ctx, RollupExecutionPriceFlag.Name)
} }
if ctx.GlobalIsSet(RollupBackendFlag.Name) { if ctx.GlobalIsSet(RollupBackendFlag.Name) {
val := ctx.GlobalString(RollupBackendFlag.Name) val := ctx.GlobalString(RollupBackendFlag.Name)
...@@ -1213,13 +1192,6 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) { ...@@ -1213,13 +1192,6 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) {
} }
cfg.Backend = backend 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) { if ctx.GlobalIsSet(RollupEnforceFeesFlag.Name) {
cfg.EnforceFees = true cfg.EnforceFees = true
} }
...@@ -1790,8 +1762,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { ...@@ -1790,8 +1762,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
l1FeeWalletAddress := cfg.Rollup.L1FeeWalletAddress l1FeeWalletAddress := cfg.Rollup.L1FeeWalletAddress
addrManagerOwnerAddress := cfg.Rollup.AddressManagerOwnerAddress addrManagerOwnerAddress := cfg.Rollup.AddressManagerOwnerAddress
l1ETHGatewayAddress := cfg.Rollup.L1ETHGatewayAddress l1ETHGatewayAddress := cfg.Rollup.L1ETHGatewayAddress
gpoOwnerAddress := cfg.Rollup.GasPriceOracleOwnerAddress
stateDumpPath := cfg.Rollup.StateDumpPath 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) { if !ctx.GlobalIsSet(MinerGasPriceFlag.Name) && !ctx.GlobalIsSet(MinerLegacyGasPriceFlag.Name) {
cfg.Miner.GasPrice = big.NewInt(1) cfg.Miner.GasPrice = big.NewInt(1)
} }
......
...@@ -98,7 +98,7 @@ func newTester(t *testing.T, confOverride func(*eth.Config)) *tester { ...@@ -98,7 +98,7 @@ func newTester(t *testing.T, confOverride func(*eth.Config)) *tester {
t.Fatalf("failed to create node: %v", err) t.Fatalf("failed to create node: %v", err)
} }
ethConf := &eth.Config{ ethConf := &eth.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{ Miner: miner.Config{
Etherbase: common.HexToAddress(testAddress), Etherbase: common.HexToAddress(testAddress),
}, },
......
...@@ -73,6 +73,7 @@ type Genesis struct { ...@@ -73,6 +73,7 @@ type Genesis struct {
L1CrossDomainMessengerAddress common.Address `json:"-"` L1CrossDomainMessengerAddress common.Address `json:"-"`
AddressManagerOwnerAddress common.Address `json:"-"` AddressManagerOwnerAddress common.Address `json:"-"`
L1ETHGatewayAddress common.Address `json:"-"` L1ETHGatewayAddress common.Address `json:"-"`
GasPriceOracleOwnerAddress common.Address `json:"-"`
ChainID *big.Int `json:"-"` ChainID *big.Int `json:"-"`
} }
...@@ -267,7 +268,7 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig { ...@@ -267,7 +268,7 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
} }
// ApplyOvmStateToState applies the initial OVM state to a state object. // 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 { if len(stateDump.Accounts) == 0 {
return return
} }
...@@ -305,7 +306,7 @@ func ApplyOvmStateToState(statedb *state.StateDB, stateDump *dump.OvmDump, l1XDo ...@@ -305,7 +306,7 @@ func ApplyOvmStateToState(statedb *state.StateDB, stateDump *dump.OvmDump, l1XDo
log.Info("Setting OVM_L1ETHGateway in OVM_ETH", "address", l1ETHGatewayAddress.Hex()) log.Info("Setting OVM_L1ETHGateway in OVM_ETH", "address", l1ETHGatewayAddress.Hex())
if strings.Contains(OVM_ETH.Code, "a84ce98") { if strings.Contains(OVM_ETH.Code, "a84ce98") {
// Set the gateway of OVM_ETH at new dump // 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") l1GatewaySlot := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001")
l1GatewayValue := common.BytesToHash(l1ETHGatewayAddress.Bytes()) l1GatewayValue := common.BytesToHash(l1ETHGatewayAddress.Bytes())
statedb.SetState(OVM_ETH.Address, l1GatewaySlot, l1GatewayValue) statedb.SetState(OVM_ETH.Address, l1GatewaySlot, l1GatewayValue)
...@@ -337,6 +338,13 @@ func ApplyOvmStateToState(statedb *state.StateDB, stateDump *dump.OvmDump, l1XDo ...@@ -337,6 +338,13 @@ func ApplyOvmStateToState(statedb *state.StateDB, stateDump *dump.OvmDump, l1XDo
l1FeeWalletSlot := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000") l1FeeWalletSlot := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000")
l1FeeWalletValue := common.BytesToHash(l1FeeWalletAddress.Bytes()) l1FeeWalletValue := common.BytesToHash(l1FeeWalletAddress.Bytes())
statedb.SetState(OVM_SequencerFeeVault.Address, l1FeeWalletSlot, l1FeeWalletValue) 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 { ...@@ -350,7 +358,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
if vm.UsingOVM { if vm.UsingOVM {
// OVM_ENABLED // 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 { for addr, account := range g.Alloc {
...@@ -477,7 +485,7 @@ func DefaultGoerliGenesisBlock() *Genesis { ...@@ -477,7 +485,7 @@ func DefaultGoerliGenesisBlock() *Genesis {
} }
// DeveloperGenesisBlock returns the 'geth --dev' genesis block. // 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 // Override the default period to the user requested one
config := *params.AllCliqueProtocolChanges config := *params.AllCliqueProtocolChanges
config.Clique.Period = period config.Clique.Period = period
...@@ -536,6 +544,7 @@ func DeveloperGenesisBlock(period uint64, faucet, l1XDomainMessengerAddress comm ...@@ -536,6 +544,7 @@ func DeveloperGenesisBlock(period uint64, faucet, l1XDomainMessengerAddress comm
L1FeeWalletAddress: l1FeeWalletAddress, L1FeeWalletAddress: l1FeeWalletAddress,
AddressManagerOwnerAddress: addrManagerOwnerAddress, AddressManagerOwnerAddress: addrManagerOwnerAddress,
L1ETHGatewayAddress: l1ETHGatewayAddress, L1ETHGatewayAddress: l1ETHGatewayAddress,
GasPriceOracleOwnerAddress: gpoOwnerAddress,
ChainID: config.ChainID, ChainID: config.ChainID,
} }
} }
......
...@@ -226,7 +226,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { ...@@ -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 = miner.New(eth, &config.Miner, chainConfig, eth.EventMux(), eth.engine, eth.isLocalBlock)
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData)) 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} eth.APIBackend = &EthAPIBackend{ctx.ExtRPCEnabled(), eth, nil, nil, config.Rollup.IsVerifier, config.Rollup.GasLimit, vm.UsingOVM, config.Rollup.MaxCallDataSize}
gpoParams := config.GPO gpoParams := config.GPO
if gpoParams.Default == nil { if gpoParams.Default == nil {
...@@ -234,7 +234,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { ...@@ -234,7 +234,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
} }
eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams) eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams)
// create the Rollup GPO and allow the API backend and the sync service to access it // 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.APIBackend.rollupGpo = rollupGpo
eth.syncService.RollupGpo = rollupGpo eth.syncService.RollupGpo = rollupGpo
return eth, nil return eth, nil
......
...@@ -81,8 +81,6 @@ var DefaultConfig = Config{ ...@@ -81,8 +81,6 @@ var DefaultConfig = Config{
// is additional overhead that is unaccounted. Round down to 127000 for // is additional overhead that is unaccounted. Round down to 127000 for
// safety. // safety.
MaxCallDataSize: 127000, MaxCallDataSize: 127000,
DataPrice: big.NewInt(100 * params.GWei),
ExecutionPrice: big.NewInt(0),
}, },
DiffDbCache: 256, DiffDbCache: 256,
} }
......
...@@ -17,10 +17,12 @@ type RollupOracle struct { ...@@ -17,10 +17,12 @@ type RollupOracle struct {
} }
// NewRollupOracle returns an initialized RollupOracle // NewRollupOracle returns an initialized RollupOracle
func NewRollupOracle(l1GasPrice *big.Int, l2GasPrice *big.Int) *RollupOracle { func NewRollupOracle() *RollupOracle {
return &RollupOracle{ return &RollupOracle{
l1GasPrice: l1GasPrice, l1GasPrice: new(big.Int),
l2GasPrice: l2GasPrice, l2GasPrice: new(big.Int),
l1GasPriceLock: sync.RWMutex{},
l2GasPriceLock: sync.RWMutex{},
} }
} }
......
...@@ -26,7 +26,7 @@ type Config struct { ...@@ -26,7 +26,7 @@ type Config struct {
L1FeeWalletAddress common.Address L1FeeWalletAddress common.Address
AddressManagerOwnerAddress common.Address AddressManagerOwnerAddress common.Address
L1ETHGatewayAddress common.Address L1ETHGatewayAddress common.Address
GasPriceOracleAddress common.Address GasPriceOracleOwnerAddress common.Address
// Turns on checking of state for L2 gas price // Turns on checking of state for L2 gas price
EnableL2GasPolling bool EnableL2GasPolling bool
// Deployment Height of the canonical transaction chain // Deployment Height of the canonical transaction chain
...@@ -37,10 +37,6 @@ type Config struct { ...@@ -37,10 +37,6 @@ type Config struct {
PollInterval time.Duration PollInterval time.Duration
// Interval for updating the timestamp // Interval for updating the timestamp
TimestampRefreshThreshold time.Duration 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 // Represents the source of the transactions that is being synced
Backend Backend Backend Backend
// Only accept transactions with fees // Only accept transactions with fees
......
...@@ -31,6 +31,7 @@ var errShortRemoteTip = errors.New("Unexpected remote less than tip") ...@@ -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 // L2GasPrice slot refers to the storage slot that the execution price is stored
// in the L2 predeploy contract, the GasPriceOracle // in the L2 predeploy contract, the GasPriceOracle
var l2GasPriceSlot = common.BigToHash(big.NewInt(1)) var l2GasPriceSlot = common.BigToHash(big.NewInt(1))
var l2GasPriceOracleAddress = common.HexToAddress("0x420000000000000000000000000000000000000F")
// SyncService implements the main functionality around pulling in transactions // SyncService implements the main functionality around pulling in transactions
// and executing them. It can be configured to run in both sequencer mode and in // and executing them. It can be configured to run in both sequencer mode and in
...@@ -58,8 +59,6 @@ type SyncService struct { ...@@ -58,8 +59,6 @@ type SyncService struct {
timestampRefreshThreshold time.Duration timestampRefreshThreshold time.Duration
chainHeadCh chan core.ChainHeadEvent chainHeadCh chan core.ChainHeadEvent
backend Backend backend Backend
gpoAddress common.Address
enableL2GasPolling bool
enforceFees bool enforceFees bool
} }
...@@ -114,8 +113,6 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co ...@@ -114,8 +113,6 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
pollInterval: pollInterval, pollInterval: pollInterval,
timestampRefreshThreshold: timestampRefreshThreshold, timestampRefreshThreshold: timestampRefreshThreshold,
backend: cfg.Backend, backend: cfg.Backend,
gpoAddress: cfg.GasPriceOracleAddress,
enableL2GasPolling: cfg.EnableL2GasPolling,
enforceFees: cfg.EnforceFees, enforceFees: cfg.EnforceFees,
} }
...@@ -430,11 +427,6 @@ func (s *SyncService) updateL1GasPrice() error { ...@@ -430,11 +427,6 @@ func (s *SyncService) updateL1GasPrice() error {
// price oracle at the state that corresponds to the state root. If no state // price oracle at the state that corresponds to the state root. If no state
// root is passed in, then the tip is used. // root is passed in, then the tip is used.
func (s *SyncService) updateL2GasPrice(hash *common.Hash) error { 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 state *state.StateDB
var err error var err error
if hash != nil { if hash != nil {
...@@ -445,7 +437,7 @@ func (s *SyncService) updateL2GasPrice(hash *common.Hash) error { ...@@ -445,7 +437,7 @@ func (s *SyncService) updateL2GasPrice(hash *common.Hash) error {
if err != nil { if err != nil {
return err return err
} }
result := state.GetState(s.gpoAddress, l2GasPriceSlot) result := state.GetState(l2GasPriceOracleAddress, l2GasPriceSlot)
s.RollupGpo.SetL2GasPrice(result.Big()) s.RollupGpo.SetL2GasPrice(result.Big())
return nil return nil
} }
......
...@@ -516,8 +516,6 @@ func TestSyncServiceL2GasPrice(t *testing.T) { ...@@ -516,8 +516,6 @@ func TestSyncServiceL2GasPrice(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
service.enableL2GasPolling = true
service.gpoAddress = common.HexToAddress("0xF20b338752976878754518183873602902360704")
price, err := service.RollupGpo.SuggestL2GasPrice(context.Background()) price, err := service.RollupGpo.SuggestL2GasPrice(context.Background())
if err != nil { if err != nil {
...@@ -533,7 +531,7 @@ func TestSyncServiceL2GasPrice(t *testing.T) { ...@@ -533,7 +531,7 @@ func TestSyncServiceL2GasPrice(t *testing.T) {
t.Fatal("Cannot get state db") t.Fatal("Cannot get state db")
} }
l2GasPrice := big.NewInt(100000000000) l2GasPrice := big.NewInt(100000000000)
state.SetState(service.gpoAddress, l2GasPriceSlot, common.BigToHash(l2GasPrice)) state.SetState(l2GasPriceOracleAddress, l2GasPriceSlot, common.BigToHash(l2GasPrice))
root, _ := state.Commit(false) root, _ := state.Commit(false)
service.updateL2GasPrice(&root) service.updateL2GasPrice(&root)
...@@ -695,7 +693,7 @@ func newTestSyncService(isVerifier bool) (*SyncService, chan core.NewTxsEvent, e ...@@ -695,7 +693,7 @@ func newTestSyncService(isVerifier bool) (*SyncService, chan core.NewTxsEvent, e
return nil, nil, nil, fmt.Errorf("Cannot initialize syncservice: %w", err) 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) txCh := make(chan core.NewTxsEvent, 1)
sub := service.SubscribeNewTxsEvent(txCh) sub := service.SubscribeNewTxsEvent(txCh)
...@@ -717,7 +715,7 @@ type mockClient struct { ...@@ -717,7 +715,7 @@ type mockClient struct {
func setupMockClient(service *SyncService, responses map[string]interface{}) { func setupMockClient(service *SyncService, responses map[string]interface{}) {
client := newMockClient(responses) client := newMockClient(responses)
service.client = client service.client = client
service.RollupGpo = gasprice.NewRollupOracle(big.NewInt(0), big.NewInt(0)) service.RollupGpo = gasprice.NewRollupOracle()
} }
func newMockClient(responses map[string]interface{}) *mockClient { func newMockClient(responses map[string]interface{}) *mockClient {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment