Skip to content

Commit

Permalink
gas-oracle: use configured gas-price
Browse files Browse the repository at this point in the history
Use the configured gas price when updating the L1 base fee.
In production, this should be set to 0 and the sequencer
will allow for transactions with 0 gas price when they are
from the owner of the gas price oracle. This prevents the
need to manage funds on L2 for the `gas-oracle`
  • Loading branch information
tynes authored and smartcontracts committed Oct 14, 2021
1 parent 7ef08ef commit e0e9770
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tall-chefs-pay.md
@@ -0,0 +1,5 @@
---
'@eth-optimism/gas-oracle': patch
---

Use the configured gas price when updating the L1 base fee in L2 state
13 changes: 13 additions & 0 deletions go/gas-oracle/oracle/base_fee.go
Expand Up @@ -53,6 +53,19 @@ func wrapUpdateBaseFee(l1Backend bind.ContractTransactor, l2Backend DeployContra
log.Debug("non significant base fee update", "tip", tip.BaseFee, "current", baseFee)
return nil
}

// Use the configured gas price if it is set,
// otherwise use gas estimation
if cfg.gasPrice != nil {
opts.GasPrice = cfg.gasPrice
} else {
gasPrice, err := l2Backend.SuggestGasPrice(opts.Context)
if err != nil {
return err
}
opts.GasPrice = gasPrice
}

tx, err := contract.SetL1BaseFee(opts, tip.BaseFee)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions go/gas-oracle/oracle/base_fee_test.go
Expand Up @@ -26,7 +26,7 @@ func TestBaseFeeUpdate(t *testing.T) {
privateKey: key,
l2ChainID: big.NewInt(1337),
gasPriceOracleAddress: addr,
gasPrice: big.NewInt(677228895),
gasPrice: big.NewInt(782049771),
}

update, err := wrapUpdateBaseFee(sim, sim, cfg)
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestBaseFeeUpdate(t *testing.T) {
}
// Call the update function to do the update
if err := update(); err != nil {
t.Fatal("cannot update base fee")
t.Fatalf("cannot update base fee: %s", err)
}
sim.Commit()
// Check the updated base fee
Expand Down

0 comments on commit e0e9770

Please sign in to comment.