Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade gas price oracle to use new ecotone #2003

Merged
merged 5 commits into from Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 8 additions & 5 deletions auxiliary/OpGasPriceOracle/contracts/OpGasPriceOracle.sol
Expand Up @@ -74,16 +74,19 @@ contract OpGasPriceOracle is IExternalNode {
) internal view returns (uint256 costOfExecutionGrossEth) {
IOVM_GasPriceOracle ovmGasPriceOracle = IOVM_GasPriceOracle(ovmGasPriceOracleAddress);

uint256 gasPriceL2 = ovmGasPriceOracle.gasPrice();
uint256 overhead = ovmGasPriceOracle.overhead();
uint256 gasPriceL2 = ovmGasPriceOracle.baseFee();
uint256 baseFeeScalar = ovmGasPriceOracle.baseFeeScalar();
uint256 l1BaseFee = ovmGasPriceOracle.l1BaseFee();
uint256 blobBaseFeeScalar = ovmGasPriceOracle.blobBaseFeeScalar();
uint256 blobBaseFee = ovmGasPriceOracle.blobBaseFee();
uint256 decimals = ovmGasPriceOracle.decimals();
uint256 scalar = ovmGasPriceOracle.scalar();

(uint256 gasUnitsL1, uint256 gasUnitsL2) = getGasUnits(runtimeParams);

costOfExecutionGrossEth = ((((gasUnitsL1 + overhead) * l1BaseFee * scalar) /
10 ** decimals) + (gasUnitsL2 * gasPriceL2));
uint256 l1GasPrice = (baseFeeScalar * l1BaseFee * 16 + blobBaseFeeScalar * blobBaseFee) /
(16 * 10 ** decimals);

costOfExecutionGrossEth = ((gasUnitsL1 * l1GasPrice) + (gasUnitsL2 * gasPriceL2));
}

function getGasUnits(
Expand Down
Expand Up @@ -52,13 +52,15 @@ interface IOVM_GasPriceOracle {

/**
* @notice Retrieves the current fee overhead.
* @notice deprecated
*
* @return Current fee overhead.
*/
function overhead() external view returns (uint256);

/**
* @notice Retrieves the current fee scalar.
* @notice deprecated
*
* @return Current fee scalar.
*/
Expand Down Expand Up @@ -90,4 +92,25 @@ interface IOVM_GasPriceOracle {
* @return Amount of L1 gas used to publish the transaction.
*/
function getL1GasUsed(bytes memory _data) external view returns (uint256);

/// @notice Set chain to be Ecotone chain (callable by depositor account)
function setEcotone() external;

/// @notice Indicates whether the network has gone through the Ecotone upgrade.
function isEcotone() external view returns (bool);

/// @notice Semantic version.
function version() external view returns (string memory);

/// @notice Retrieves the current blob base fee.
/// @return Current blob base fee.
function blobBaseFee() external view returns (uint256);

/// @notice Retrieves the current base fee scalar.
/// @return Current base fee scalar.
function baseFeeScalar() external view returns (uint32);

/// @notice Retrieves the current blob base fee scalar.
/// @return Current blob base fee scalar.
function blobBaseFeeScalar() external view returns (uint32);
}
@@ -0,0 +1,93 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.11 <0.9.0;

/**
* @custom:proxied
* @custom:predeploy 0x420000000000000000000000000000000000000F
* @title GasPriceOracle
* @notice This contract maintains the variables responsible for computing the L1 portion of the
* total fee charged on L2. Before Bedrock, this contract held variables in state that were
* read during the state transition function to compute the L1 portion of the transaction
* fee. After Bedrock, this contract now simply proxies the L1Block contract, which has
* the values used to compute the L1 portion of the fee in its state.
*
* The contract exposes an API that is useful for knowing how large the L1 portion of the
* transaction fee will be. The following events were deprecated with Bedrock:
* - event OverheadUpdated(uint256 overhead);
* - event ScalarUpdated(uint256 scalar);
* - event DecimalsUpdated(uint256 decimals);
*
* see https://community.optimism.io/docs/useful-tools/oracles/#types-of-oracles
*/
interface IOVM_GasPriceOracle_legacy {
/**
* @notice Number of decimals used in the scalar.
*/
// uint256 public constant DECIMALS = 6;
function DECIMALS() external pure returns (uint256);

/**
* @notice Computes the L1 portion of the fee based on the size of the rlp encoded input
* transaction, the current L1 base fee, and the various dynamic parameters.
*
* @param _data Unsigned fully RLP-encoded transaction to get the L1 fee for.
*
* @return L1 fee that should be paid for the tx
*/
function getL1Fee(bytes memory _data) external view returns (uint256);

/**
* @notice Retrieves the current gas price (base fee).
*
* @return Current L2 gas price (base fee).
*/
function gasPrice() external view returns (uint256);

/**
* @notice Retrieves the current base fee.
*
* @return Current L2 base fee.
*/
function baseFee() external view returns (uint256);

/**
* @notice Retrieves the current fee overhead.
*
* @return Current fee overhead.
*/
function overhead() external view returns (uint256);

/**
* @notice Retrieves the current fee scalar.
*
* @return Current fee scalar.
*/
function scalar() external view returns (uint256);

/**
* @notice Retrieves the latest known L1 base fee.
*
* @return Latest known L1 base fee.
*/
function l1BaseFee() external view returns (uint256);

/**
* @custom:legacy
* @notice Retrieves the number of decimals used in the scalar.
*
* @return Number of decimals used in the scalar.
*/
function decimals() external pure returns (uint256);

/**
* @notice Computes the amount of L1 gas used for a transaction. Adds the overhead which
* represents the per-transaction gas overhead of posting the transaction and state
* roots to L1. Adds 68 bytes of padding to account for the fact that the input does
* not have a signature.
*
* @param _data Unsigned fully RLP-encoded transaction to get the L1 gas for.
*
* @return Amount of L1 gas used to publish the transaction.
*/
function getL1GasUsed(bytes memory _data) external view returns (uint256);
}
2 changes: 1 addition & 1 deletion markets/perps-market/package.json
Expand Up @@ -33,7 +33,7 @@
"@synthetixio/router": "3.3.7",
"@synthetixio/spot-market": "workspace:*",
"@synthetixio/wei": "^2.74.4",
"@usecannon/cli": "2.11.10",
"@usecannon/cli": "2.11.12",
"ethers": "^5.7.2",
"hardhat": "^2.19.5",
"solidity-docgen": "^0.6.0-beta.36",
Expand Down
2 changes: 1 addition & 1 deletion markets/perps-market/subgraph/package.json
Expand Up @@ -21,7 +21,7 @@
"devDependencies": {
"@graphprotocol/graph-cli": "^0.68.0",
"@graphprotocol/graph-ts": "^0.32.0",
"@usecannon/cli": "2.11.10",
"@usecannon/cli": "2.11.12",
"ethers": "^5.7.2",
"matchstick-as": "^0.6.0",
"prettier": "^3.2.5"
Expand Down
2 changes: 1 addition & 1 deletion markets/spot-market/package.json
Expand Up @@ -34,7 +34,7 @@
"@synthetixio/router": "3.3.7",
"@synthetixio/wei": "^2.74.4",
"@types/node-fetch": "^2.6.11",
"@usecannon/cli": "2.11.10",
"@usecannon/cli": "2.11.12",
"ethers": "^5.7.2",
"hardhat": "^2.19.5",
"node-fetch": "^2.7.0",
Expand Down
2 changes: 1 addition & 1 deletion markets/spot-market/subgraph/package.json
Expand Up @@ -22,7 +22,7 @@
"devDependencies": {
"@graphprotocol/graph-cli": "^0.68.0",
"@graphprotocol/graph-ts": "^0.32.0",
"@usecannon/cli": "2.11.10",
"@usecannon/cli": "2.11.12",
"ethers": "^5.7.2",
"matchstick-as": "^0.6.0",
"prettier": "^3.2.5"
Expand Down
2 changes: 1 addition & 1 deletion protocol/synthetix/subgraph/package.json
Expand Up @@ -26,7 +26,7 @@
"devDependencies": {
"@graphprotocol/graph-cli": "^0.68.0",
"@graphprotocol/graph-ts": "^0.32.0",
"@usecannon/cli": "2.11.10",
"@usecannon/cli": "2.11.12",
"ethers": "^5.7.2",
"matchstick-as": "^0.6.0",
"prettier": "^3.2.5"
Expand Down
2 changes: 1 addition & 1 deletion utils/common-config/package.json
Expand Up @@ -17,7 +17,7 @@
"@typechain/hardhat": "^9.1.0",
"dotenv": "^16.4.3",
"hardhat": "^2.19.5",
"hardhat-cannon": "2.11.10",
"hardhat-cannon": "2.11.12",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-gas-reporter": "^1.0.10",
"hardhat-ignore-warnings": "^0.2.9",
Expand Down
2 changes: 1 addition & 1 deletion utils/core-utils/package.json
Expand Up @@ -39,7 +39,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/prompts": "^2.4.9",
"@usecannon/builder": "2.11.10",
"@usecannon/builder": "2.11.12",
"ethers": "^5.7.2",
"hardhat": "^2.19.5",
"mocha": "^10.3.0",
Expand Down
2 changes: 1 addition & 1 deletion utils/sample-project/package.json
Expand Up @@ -20,7 +20,7 @@
"@synthetixio/router": "3.3.7",
"ethers": "^5.7.2",
"hardhat": "^2.19.5",
"hardhat-cannon": "2.11.10",
"hardhat-cannon": "2.11.12",
"solidity-coverage": "^0.8.7"
}
}
46 changes: 23 additions & 23 deletions yarn.lock
Expand Up @@ -2871,7 +2871,7 @@ __metadata:
"@typechain/hardhat": "npm:^9.1.0"
dotenv: "npm:^16.4.3"
hardhat: "npm:^2.19.5"
hardhat-cannon: "npm:2.11.10"
hardhat-cannon: "npm:2.11.12"
hardhat-contract-sizer: "npm:^2.10.0"
hardhat-gas-reporter: "npm:^1.0.10"
hardhat-ignore-warnings: "npm:^0.2.9"
Expand Down Expand Up @@ -2911,7 +2911,7 @@ __metadata:
dependencies:
"@graphprotocol/graph-cli": "npm:^0.68.0"
"@graphprotocol/graph-ts": "npm:^0.32.0"
"@usecannon/cli": "npm:2.11.10"
"@usecannon/cli": "npm:2.11.12"
ethers: "npm:^5.7.2"
matchstick-as: "npm:^0.6.0"
prettier: "npm:^3.2.5"
Expand All @@ -2925,7 +2925,7 @@ __metadata:
"@ethersproject/abi": "npm:^5.7.0"
"@istanbuljs/nyc-config-typescript": "npm:^1.0.2"
"@types/prompts": "npm:^2.4.9"
"@usecannon/builder": "npm:2.11.10"
"@usecannon/builder": "npm:2.11.12"
chalk: "npm:^4.1.2"
ethereumjs-util: "npm:^7.1.5"
ethers: "npm:^5.7.2"
Expand Down Expand Up @@ -3084,7 +3084,7 @@ __metadata:
dependencies:
"@graphprotocol/graph-cli": "npm:^0.68.0"
"@graphprotocol/graph-ts": "npm:^0.32.0"
"@usecannon/cli": "npm:2.11.10"
"@usecannon/cli": "npm:2.11.12"
ethers: "npm:^5.7.2"
matchstick-as: "npm:^0.6.0"
prettier: "npm:^3.2.5"
Expand All @@ -3105,7 +3105,7 @@ __metadata:
"@synthetixio/router": "npm:3.3.7"
"@synthetixio/spot-market": "workspace:*"
"@synthetixio/wei": "npm:^2.74.4"
"@usecannon/cli": "npm:2.11.10"
"@usecannon/cli": "npm:2.11.12"
ethers: "npm:^5.7.2"
hardhat: "npm:^2.19.5"
solidity-docgen: "npm:^0.6.0-beta.36"
Expand Down Expand Up @@ -3155,7 +3155,7 @@ __metadata:
"@synthetixio/router": "npm:3.3.7"
ethers: "npm:^5.7.2"
hardhat: "npm:^2.19.5"
hardhat-cannon: "npm:2.11.10"
hardhat-cannon: "npm:2.11.12"
solidity-coverage: "npm:^0.8.7"
languageName: unknown
linkType: soft
Expand All @@ -3181,7 +3181,7 @@ __metadata:
dependencies:
"@graphprotocol/graph-cli": "npm:^0.68.0"
"@graphprotocol/graph-ts": "npm:^0.32.0"
"@usecannon/cli": "npm:2.11.10"
"@usecannon/cli": "npm:2.11.12"
ethers: "npm:^5.7.2"
matchstick-as: "npm:^0.6.0"
prettier: "npm:^3.2.5"
Expand All @@ -3202,7 +3202,7 @@ __metadata:
"@synthetixio/router": "npm:3.3.7"
"@synthetixio/wei": "npm:^2.74.4"
"@types/node-fetch": "npm:^2.6.11"
"@usecannon/cli": "npm:2.11.10"
"@usecannon/cli": "npm:2.11.12"
ethers: "npm:^5.7.2"
hardhat: "npm:^2.19.5"
node-fetch: "npm:^2.7.0"
Expand Down Expand Up @@ -3817,9 +3817,9 @@ __metadata:
languageName: node
linkType: hard

"@usecannon/builder@npm:2.11.10":
version: 2.11.10
resolution: "@usecannon/builder@npm:2.11.10"
"@usecannon/builder@npm:2.11.12":
version: 2.11.12
resolution: "@usecannon/builder@npm:2.11.12"
dependencies:
"@synthetixio/router": "npm:^3.3.7"
axios: "npm:^1.6.2"
Expand All @@ -3833,17 +3833,17 @@ __metadata:
typestub-ipfs-only-hash: "npm:^4.0.0"
viem: "npm:^2.6.1"
zod: "npm:^3.22.4"
checksum: 10/62b53fc63a03fc37ad27666bfb5d27570884b11bd3c9515023f16a57c9afdca0586673b9e761c354cbda482a31757d3c63da2ca0e9ba98a351bf610ea98250d8
checksum: 10/329c74467a38f3b8c1d557787bed973dd85c8afb044755d6a090f9afe8cea76d3690aa26957db0187e79211db7a8d29ee1115e377da47a303134cb99c8a9eb57
languageName: node
linkType: hard

"@usecannon/cli@npm:2.11.10":
version: 2.11.10
resolution: "@usecannon/cli@npm:2.11.10"
"@usecannon/cli@npm:2.11.12":
version: 2.11.12
resolution: "@usecannon/cli@npm:2.11.12"
dependencies:
"@iarna/toml": "npm:^3.0.0"
"@synthetixio/wei": "npm:^2.74.1"
"@usecannon/builder": "npm:2.11.10"
"@usecannon/builder": "npm:2.11.12"
chalk: "npm:^4.1.2"
commander: "npm:^9.5.0"
debug: "npm:^4.3.4"
Expand All @@ -3862,7 +3862,7 @@ __metadata:
zod: "npm:^3.22.4"
bin:
cannon: bin/cannon.js
checksum: 10/5a4790b7022ccd335ca875312392543ecf6aa80e315984b1cac1bf2b6e65904a565e3f7c844e946b58f6c449a4d29d33cc91fa7fbd2eb0b2ade90630f289883b
checksum: 10/f1b6fdf41ad8a61240752123bb265d69f0db7ff03bda9e946108e2f518ff4a934c9ba494c95c32ec1321ead37cec9036b4c76086c7eb324055fa363172ece0ac
languageName: node
linkType: hard

Expand Down Expand Up @@ -8624,20 +8624,20 @@ __metadata:
languageName: node
linkType: hard

"hardhat-cannon@npm:2.11.10":
version: 2.11.10
resolution: "hardhat-cannon@npm:2.11.10"
"hardhat-cannon@npm:2.11.12":
version: 2.11.12
resolution: "hardhat-cannon@npm:2.11.12"
dependencies:
"@iarna/toml": "npm:^3.0.0"
"@usecannon/builder": "npm:2.11.10"
"@usecannon/cli": "npm:2.11.10"
"@usecannon/builder": "npm:2.11.12"
"@usecannon/cli": "npm:2.11.12"
chalk: "npm:^4.1.2"
debug: "npm:^4.3.3"
fs-extra: "npm:^10.0.1"
viem: "npm:^2.6.1"
peerDependencies:
hardhat: ">=2.0.0"
checksum: 10/97da629dbc789f1d3d472f626ef9c8ce4cdcc9d9892398a43d39e653a7ffe59f70051b39e3d326ce9d30fee1f840e32f0c825adddc1823256412127c974bf5e0
checksum: 10/65dfbb2ebf00d86959d806f70e4c27d0859040431527c58903b4de8f457b4c2382a8f1e17b055dee61b86516221577f0521c7b64738d85a80773ea4ce4858982
languageName: node
linkType: hard

Expand Down