Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contracts: update
OVM_GasPriceOracle
Add a setter for L1 base fee. The trusted oracle can update it over time. Eventually this will become trustless, but this is a quick and easy approach for now. Also add a setter/getter for the per batch overhead and the scalar. Also emit events for when the values are updated. This will make it much easier to track historical gas prices over time. Add tests for new functionality. L2 geth will consume the new value in the `OVM_GasPriceOracle` Add getters that make it easy for users to know the L1 costs. - `getL1Fee` returns the L1 fee given the current L1 base fee known by the L2 node - `getL1GasUsed` counts the bytes and creates a sum for the gas cost of submitting the data to L1
- Loading branch information
1 parent
cd9e62c
commit dfdbe3c
Showing
6 changed files
with
487 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@eth-optimism/contracts': patch | ||
--- | ||
|
||
Add getter and setter to `OVM_GasPriceOracle` for the l1 base fee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/contracts/contracts/L2/predeploys/iOVM_GasPriceOracle.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >0.5.0 <0.8.0; | ||
|
||
/** | ||
* @title iOVM_GasPriceOracle | ||
*/ | ||
interface iOVM_GasPriceOracle { | ||
|
||
/********** | ||
* Events * | ||
**********/ | ||
|
||
event GasPriceUpdated(uint256); | ||
event L1BaseFeeUpdated(uint256); | ||
event OverheadUpdated(uint256); | ||
event ScalarUpdated(uint256); | ||
event DecimalsUpdated(uint256); | ||
|
||
/******************** | ||
* Public Functions * | ||
********************/ | ||
|
||
function setGasPrice(uint256 _gasPrice) external; | ||
function setL1BaseFee(uint256 _baseFee) external; | ||
function setOverhead(uint256 _overhead) external; | ||
function setScalar(uint256 _scalar) external; | ||
function setDecimals(uint256 _decimals) external; | ||
function getL1Fee(bytes memory _data) external returns (uint256); | ||
function getL1GasUsed(bytes memory _data) external returns (uint256); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.