-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat: deployment config for fee oracle contract #936
Changes from 15 commits
e7f9675
0d6d2e2
40f5e28
ff28fc8
b88023b
2af3c2f
86053b2
175e1f5
a53ead4
c6d9228
ebf471f
16b080c
842161d
6d50d92
8d62807
7447768
52329ee
5ce4fa3
fe4c81c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@eth-optimism/contracts': patch | ||
--- | ||
|
||
Introduces the congestion price oracle contract |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >0.5.0 <0.8.0; | ||
|
||
/* External Imports */ | ||
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
/** | ||
* @title OVM_GasPriceOracle | ||
* @dev This contract exposes the current l2 gas price, a measure of how congested the network | ||
* currently is. This measure is used by the Sequencer to determine what fee to charge for | ||
* transactions. When the system is more congested, the l2 gas price will increase and fees | ||
* will also increase as a result. | ||
* | ||
* Compiler used: optimistic-solc | ||
* Runtime target: OVM | ||
*/ | ||
contract OVM_GasPriceOracle is Ownable { | ||
|
||
/************* | ||
* Variables * | ||
*************/ | ||
|
||
// Current l2 gas price | ||
uint256 public gasPrice; | ||
|
||
/************* | ||
* Constants * | ||
*************/ | ||
uint256 public constant GAS_PRICE_MULTIPLE = 100000000; | ||
|
||
/*************** | ||
* Constructor * | ||
***************/ | ||
|
||
/** | ||
* @param _owner Address that will initially own this contract. | ||
*/ | ||
constructor( | ||
address _owner, | ||
uint256 _initialGasPrice | ||
) | ||
Ownable() | ||
{ | ||
setGasPrice(_initialGasPrice); | ||
transferOwnership(_owner); | ||
} | ||
|
||
|
||
/******************** | ||
* Public Functions * | ||
********************/ | ||
|
||
/** | ||
* Allows the owner to modify the l2 gas price. | ||
* @param _gasPrice New l2 gas price. | ||
*/ | ||
function setGasPrice( | ||
uint256 _gasPrice | ||
) | ||
public | ||
onlyOwner | ||
{ | ||
require( | ||
_gasPrice % GAS_PRICE_MULTIPLE == 0, | ||
"OVM_GasPriceOracle: l2 gas price must satisfy x % (10**8) == 0" | ||
); | ||
|
||
gasPrice = _gasPrice; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* Imports: External */ | ||
import { DeployFunction } from 'hardhat-deploy/dist/types' | ||
|
||
/* Imports: Internal */ | ||
import { getContractDefinition } from '../src' | ||
|
||
const deployFn: DeployFunction = async (hre: any) => { | ||
const { deployments, getNamedAccounts } = hre | ||
const { deploy } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
|
||
const gasPriceOracle = getContractDefinition('OVM_GasPriceOracle', true) | ||
|
||
const gasOracleOwner = (hre as any).deployConfig.ovmSequencerAddress | ||
const initialGasPrice = (hre as any).deployConfig.initialGasPriceOracleGasPrice | ||
|
||
if (!gasOracleOwner || !initialGasPrice) { | ||
throw new Error('initialGasPrice & ovmSequencerAddress required to deploy gas price oracle') | ||
} | ||
|
||
await deploy('OVM_GasPriceOracle', { | ||
contract: gasPriceOracle, | ||
from: deployer, | ||
args: [gasOracleOwner, initialGasPrice], | ||
log: true, | ||
}); | ||
} | ||
|
||
deployFn.tags = ['OVM_GasPriceOracle'] | ||
|
||
export default deployFn |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
69 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
{ | ||
"address": "0x67B08211026Ef9434a535E2464edA5dc2713F3Ff", | ||
"abi": [ | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "_owner", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "_initialGasPrice", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "nonpayable", | ||
"type": "constructor" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "previousOwner", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "newOwner", | ||
"type": "address" | ||
} | ||
], | ||
"name": "OwnershipTransferred", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "GAS_PRICE_MULTIPLE", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "gasPrice", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "owner", | ||
"outputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "renounceOwnership", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "_gasPrice", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "setGasPrice", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "newOwner", | ||
"type": "address" | ||
} | ||
], | ||
"name": "transferOwnership", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
], | ||
"transactionHash": "0xad527e4e96a235ee4563ca479bd334fcfea5f2caa8e38580a4fe663562125c0e", | ||
"receipt": { | ||
"to": null, | ||
"from": "0xd033f09cB85621F98F7A84C64dB381ac16Eff818", | ||
"contractAddress": "0x67B08211026Ef9434a535E2464edA5dc2713F3Ff", | ||
"transactionIndex": 0, | ||
"gasUsed": "1370143", | ||
"logsBloom": "0x00000000000000000000000000000040000000000000000000840000000000000000000000000000000000100000000000000000000000040000000000000000000000000000000000000008000000000001000010000000000000000000000400000000020000000000000000008800000000000000000000010010000000400000000000000000000000000000000000000000002000000000000000000000000000000000000000010000000000000000000000000000000000000000000000008002000000000000000000000000000200000000000000040000000060000000000000000000000000000000000001000000000000000000000000000000", | ||
"blockHash": "0xa28462f2316146aca71a9afd18b07982ce7f91b13aa6619912c9d760907a4206", | ||
"transactionHash": "0xad527e4e96a235ee4563ca479bd334fcfea5f2caa8e38580a4fe663562125c0e", | ||
"logs": [ | ||
{ | ||
"transactionIndex": 0, | ||
"blockNumber": 226481, | ||
"transactionHash": "0xad527e4e96a235ee4563ca479bd334fcfea5f2caa8e38580a4fe663562125c0e", | ||
"address": "0x4200000000000000000000000000000000000006", | ||
"topics": [ | ||
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", | ||
"0x000000000000000000000000d033f09cb85621f98f7a84c64db381ac16eff818", | ||
"0x0000000000000000000000004200000000000000000000000000000000000005" | ||
], | ||
"data": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"logIndex": 0, | ||
"blockHash": "0xa28462f2316146aca71a9afd18b07982ce7f91b13aa6619912c9d760907a4206" | ||
}, | ||
{ | ||
"transactionIndex": 0, | ||
"blockNumber": 226481, | ||
"transactionHash": "0xad527e4e96a235ee4563ca479bd334fcfea5f2caa8e38580a4fe663562125c0e", | ||
"address": "0x67B08211026Ef9434a535E2464edA5dc2713F3Ff", | ||
"topics": [ | ||
"0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", | ||
"0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"0x000000000000000000000000d033f09cb85621f98f7a84c64db381ac16eff818" | ||
], | ||
"data": "0x", | ||
"logIndex": 1, | ||
"blockHash": "0xa28462f2316146aca71a9afd18b07982ce7f91b13aa6619912c9d760907a4206" | ||
}, | ||
{ | ||
"transactionIndex": 0, | ||
"blockNumber": 226481, | ||
"transactionHash": "0xad527e4e96a235ee4563ca479bd334fcfea5f2caa8e38580a4fe663562125c0e", | ||
"address": "0x67B08211026Ef9434a535E2464edA5dc2713F3Ff", | ||
"topics": [ | ||
"0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", | ||
"0x000000000000000000000000d033f09cb85621f98f7a84c64db381ac16eff818", | ||
"0x00000000000000000000000018394b52d3cb931dfa76f63251919d051953413d" | ||
], | ||
"data": "0x", | ||
"logIndex": 2, | ||
"blockHash": "0xa28462f2316146aca71a9afd18b07982ce7f91b13aa6619912c9d760907a4206" | ||
} | ||
], | ||
"blockNumber": 226481, | ||
"cumulativeGasUsed": "1370143", | ||
"status": 1, | ||
"byzantium": true | ||
}, | ||
"args": [ | ||
"0x18394B52d3Cb931dfA76F63251919D051953413d", | ||
10000000000000 | ||
], | ||
"bytecode": "0x60806040523480156200001c57600080620000196200033a565b50505b5060405162000ba638038062000ba6833981810160405260408110156200004d576000806200004a6200033a565b50505b81019080805192919060200180519250600091506200006d9050620000ec565b90508060006001816200007f620003a7565b816001600160a01b0302191690836001600160a01b0316021790620000a362000409565b5050506001600160a01b038116600060008051602062000b8683398151915260405160405180910390a350620000d981620000fe565b620000e482620001d4565b50506200049f565b60005a620000f962000458565b905090565b62000108620000ec565b6001600160a01b03166200011b62000317565b6001600160a01b031614620001705760405162461bcd60e51b8152602060048201819052602482015260008051602062000b668339815191526044820152606401604051809103906200016d6200033a565b50505b6305f5e100810615620001c05760405162461bcd60e51b815260040180806020018281038252603e81526020018062000b28603e913960400191505060405180910390620001bd6200033a565b50505b80806001620001ce62000409565b50505050565b620001de620000ec565b6001600160a01b0316620001f162000317565b6001600160a01b031614620002465760405162461bcd60e51b8152602060048201819052602482015260008051602062000b66833981519152604482015260640160405180910390620002436200033a565b50505b6001600160a01b038116620002985760405162461bcd60e51b815260040180806020018281038252602681526020018062000b026026913960400191505060405180910390620002956200033a565b50505b806001600160a01b0316600080620002af620003a7565b906101000a90046001600160a01b03166001600160a01b031660008051602062000b8683398151915260405160405180910390a3806000600181620002f3620003a7565b816001600160a01b0302191690836001600160a01b0316021790620001ce62000409565b6000808062000325620003a7565b906101000a90046001600160a01b0316905090565b632a2a7adb598160e01b8152600481016020815285602082015260005b868110156200037457808601518282016040015260200162000357565b506020828760640184336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b505050565b6303daa959598160e01b8152836004820152602081602483336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b8051935060005b60408110156200040457600082820152602001620003eb565b505050565b6322bd64c0598160e01b8152836004820152846024820152600081604483336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b600081526020620003eb565b6373509064598160e01b8152602081600483336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b80516000825293506020620003eb565b61065380620004af6000396000f3fe608060405234801561001957600080610016610494565b50505b506004361061006b5760003560e01c8063456a4d9514610079578063715018a6146100935780638da5cb5b1461009d578063bf1fe420146100c1578063f2fde38b146100e7578063fe173b9714610116575b600080610076610494565b50505b61008161011e565b60405190815260200160405180910390f35b61009b610126565b005b6100a5610228565b6040516001600160a01b03909116815260200160405180910390f35b61009b600480360360208110156100e0576000806100dd610494565b50505b5035610249565b61009b6004803603602081101561010657600080610103610494565b50505b50356001600160a01b0316610323565b610081610477565b6305f5e10081565b61012e610484565b6001600160a01b031661013f610228565b6001600160a01b0316146101a25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016040518091039061019f610494565b50505b600080806101ae6104ff565b906101000a90046001600160a01b03166001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000806001816102016104ff565b816001600160a01b0302191690836001600160a01b031602179061022361055a565b505050565b600080806102346104ff565b906101000a90046001600160a01b0316905090565b610251610484565b6001600160a01b0316610262610228565b6001600160a01b0316146102c55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401604051809103906102c2610494565b50505b6305f5e1008106156103115760405162461bcd60e51b815260040180806020018281038252603e815260200180610615603e91396040019150506040518091039061030e610494565b50505b8080600161031d61055a565b50505050565b61032b610484565b6001600160a01b031661033c610228565b6001600160a01b03161461039f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016040518091039061039c610494565b50505b6001600160a01b0381166103ed5760405162461bcd60e51b81526004018080602001828103825260268152602001806105ef60269139604001915050604051809103906103ea610494565b50505b806001600160a01b03166000806104026104ff565b906101000a90046001600160a01b03166001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a38060006001816104556104ff565b816001600160a01b0302191690836001600160a01b031602179061031d61055a565b60016104816104ff565b81565b60005a61048f6105a8565b905090565b632a2a7adb598160e01b8152600481016020815285602082015260005b868110156104cc5780860151828201604001526020016104b1565b506020828760640184336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b505050565b6303daa959598160e01b8152836004820152602081602483336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b8051935060005b604081101561022357600082820152602001610543565b6322bd64c0598160e01b8152836004820152846024820152600081604483336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b600081526020610543565b6373509064598160e01b8152602081600483336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b8051600082529350602061054356fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f564d5f47617350726963654f7261636c653a206c3220676173207072696365206d757374207361746973667920782025202831302a2a3829203d3d20304f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f564d5f47617350726963654f7261636c653a206c3220676173207072696365206d757374207361746973667920782025202831302a2a3829203d3d20304f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65728be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", | ||
"deployedBytecode": "0x608060405234801561001957600080610016610494565b50505b506004361061006b5760003560e01c8063456a4d9514610079578063715018a6146100935780638da5cb5b1461009d578063bf1fe420146100c1578063f2fde38b146100e7578063fe173b9714610116575b600080610076610494565b50505b61008161011e565b60405190815260200160405180910390f35b61009b610126565b005b6100a5610228565b6040516001600160a01b03909116815260200160405180910390f35b61009b600480360360208110156100e0576000806100dd610494565b50505b5035610249565b61009b6004803603602081101561010657600080610103610494565b50505b50356001600160a01b0316610323565b610081610477565b6305f5e10081565b61012e610484565b6001600160a01b031661013f610228565b6001600160a01b0316146101a25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016040518091039061019f610494565b50505b600080806101ae6104ff565b906101000a90046001600160a01b03166001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000806001816102016104ff565b816001600160a01b0302191690836001600160a01b031602179061022361055a565b505050565b600080806102346104ff565b906101000a90046001600160a01b0316905090565b610251610484565b6001600160a01b0316610262610228565b6001600160a01b0316146102c55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401604051809103906102c2610494565b50505b6305f5e1008106156103115760405162461bcd60e51b815260040180806020018281038252603e815260200180610615603e91396040019150506040518091039061030e610494565b50505b8080600161031d61055a565b50505050565b61032b610484565b6001600160a01b031661033c610228565b6001600160a01b03161461039f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016040518091039061039c610494565b50505b6001600160a01b0381166103ed5760405162461bcd60e51b81526004018080602001828103825260268152602001806105ef60269139604001915050604051809103906103ea610494565b50505b806001600160a01b03166000806104026104ff565b906101000a90046001600160a01b03166001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a38060006001816104556104ff565b816001600160a01b0302191690836001600160a01b031602179061031d61055a565b60016104816104ff565b81565b60005a61048f6105a8565b905090565b632a2a7adb598160e01b8152600481016020815285602082015260005b868110156104cc5780860151828201604001526020016104b1565b506020828760640184336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b505050565b6303daa959598160e01b8152836004820152602081602483336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b8051935060005b604081101561022357600082820152602001610543565b6322bd64c0598160e01b8152836004820152846024820152600081604483336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b600081526020610543565b6373509064598160e01b8152602081600483336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b8051600082529350602061054356fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f564d5f47617350726963654f7261636c653a206c3220676173207072696365206d757374207361746973667920782025202831302a2a3829203d3d2030" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,12 @@ task('deploy') | |
undefined, | ||
types.string | ||
) | ||
.addOptionalParam( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it optional? What is the default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is optional because this contract is deployed to L2 and not to L1. From the point of view of hardhard deploy, I think it needs to be optional for that reason. The default value should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that we have now have gotten rid of the |
||
'initialGasPriceOracleGasPrice', | ||
'The initial execution price for the gas price oracle.', | ||
undefined, | ||
types.int | ||
) | ||
.setAction(async (args, hre: any, runSuper) => { | ||
// Necessary because hardhat doesn't let us attach non-optional parameters to existing tasks. | ||
const validateAddressArg = (argName: string) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows for
0
to be set. Is this intentional?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0 was a valid gas price at the time - it still is a valid gas price, there is no longer a concept of invalid gas prices. there is likely an upper bound which is a nice addition for the future but for now this is good