Commit fa9823f3 authored by Maurelian's avatar Maurelian Committed by GitHub

Naming improvements in Oracle (#2990)

* style(ctb): Rename append to propose
Please enter the commit message for your changes. Lines starting

* style(ctb): Use output root for bytes32

This is more accurate than saying 'L2 output' which is better
applied to the full unhashed data structure

* style(ctb): Rename sequencer to proposer in oracle
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 1487cf60
---
'@eth-optimism/contracts-bedrock': patch
---
Naming improvements for functions and variables in the L2OutputOracle
This diff is collapsed.
...@@ -185,7 +185,7 @@ func (d *Driver) CraftTx( ...@@ -185,7 +185,7 @@ func (d *Driver) CraftTx(
opts.Nonce = nonce opts.Nonce = nonce
opts.NoSend = true opts.NoSend = true
return d.l2ooContract.AppendL2Output(opts, l2OutputRoot, nextCheckpointBlock, l1Header.Hash(), l1Header.Number) return d.l2ooContract.ProposeL2Output(opts, l2OutputRoot, nextCheckpointBlock, l1Header.Hash(), l1Header.Number)
} }
// UpdateGasPrice signs an otherwise identical txn to the one provided but with // UpdateGasPrice signs an otherwise identical txn to the one provided but with
......
This diff is collapsed.
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
|-------------------+----------------------------------------------------------+------+--------+-------+------------------------------------------------| |-------------------+----------------------------------------------------------+------+--------+-------+------------------------------------------------|
| __gap | uint256[49] | 52 | 0 | 1568 | contracts/L1/L2OutputOracle.sol:L2OutputOracle | | __gap | uint256[49] | 52 | 0 | 1568 | contracts/L1/L2OutputOracle.sol:L2OutputOracle |
|-------------------+----------------------------------------------------------+------+--------+-------+------------------------------------------------| |-------------------+----------------------------------------------------------+------+--------+-------+------------------------------------------------|
| sequencer | address | 101 | 0 | 20 | contracts/L1/L2OutputOracle.sol:L2OutputOracle | | proposer | address | 101 | 0 | 20 | contracts/L1/L2OutputOracle.sol:L2OutputOracle |
|-------------------+----------------------------------------------------------+------+--------+-------+------------------------------------------------| |-------------------+----------------------------------------------------------+------+--------+-------+------------------------------------------------|
| latestBlockNumber | uint256 | 102 | 0 | 32 | contracts/L1/L2OutputOracle.sol:L2OutputOracle | | latestBlockNumber | uint256 | 102 | 0 | 32 | contracts/L1/L2OutputOracle.sol:L2OutputOracle |
|-------------------+----------------------------------------------------------+------+--------+-------+------------------------------------------------| |-------------------+----------------------------------------------------------+------+--------+-------+------------------------------------------------|
......
...@@ -183,7 +183,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver { ...@@ -183,7 +183,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
uint256 offset = (_l2BlockNumber - startingBlockNumber) % interval; uint256 offset = (_l2BlockNumber - startingBlockNumber) % interval;
// Look up the checkpoint block after it. // Look up the checkpoint block after it.
proposal = L2_ORACLE.getL2Output(_l2BlockNumber + (interval - offset)); proposal = L2_ORACLE.getL2Output(_l2BlockNumber + (interval - offset));
// False if that block is not yet appended. // False if that block is not yet proposed.
if (proposal.outputRoot == bytes32(uint256(0))) { if (proposal.outputRoot == bytes32(uint256(0))) {
return false; return false;
} }
......
...@@ -129,11 +129,11 @@ contract GasBenchMark_L2OutputOracle is L2OutputOracle_Initializer { ...@@ -129,11 +129,11 @@ contract GasBenchMark_L2OutputOracle is L2OutputOracle_Initializer {
function setUp() public override { function setUp() public override {
super.setUp(); super.setUp();
nextBlockNumber = oracle.nextBlockNumber(); nextBlockNumber = oracle.nextBlockNumber();
warpToAppendTime(nextBlockNumber); warpToProposeTime(nextBlockNumber);
vm.startPrank(sequencer); vm.startPrank(proposer);
} }
function test_appendL2Output_benchmark() external { function test_proposeL2Output_benchmark() external {
oracle.appendL2Output(nonZeroHash, nextBlockNumber, 0, 0); oracle.proposeL2Output(nonZeroHash, nextBlockNumber, 0, 0);
} }
} }
...@@ -58,7 +58,7 @@ contract L2OutputOracle_Initializer is CommonTest { ...@@ -58,7 +58,7 @@ contract L2OutputOracle_Initializer is CommonTest {
L2OutputOracle oracleImpl; L2OutputOracle oracleImpl;
// Constructor arguments // Constructor arguments
address sequencer = 0x000000000000000000000000000000000000AbBa; address proposer = 0x000000000000000000000000000000000000AbBa;
address owner = 0x000000000000000000000000000000000000ACDC; address owner = 0x000000000000000000000000000000000000ACDC;
uint256 submissionInterval = 1800; uint256 submissionInterval = 1800;
uint256 l2BlockTime = 2; uint256 l2BlockTime = 2;
...@@ -70,8 +70,8 @@ contract L2OutputOracle_Initializer is CommonTest { ...@@ -70,8 +70,8 @@ contract L2OutputOracle_Initializer is CommonTest {
// Test data // Test data
uint256 initL1Time; uint256 initL1Time;
// Advance the evm's time to meet the L2OutputOracle's requirements for appendL2Output // Advance the evm's time to meet the L2OutputOracle's requirements for proposeL2Output
function warpToAppendTime(uint256 _nextBlockNumber) public { function warpToProposeTime(uint256 _nextBlockNumber) public {
vm.warp(oracle.computeL2Timestamp(_nextBlockNumber) + 1); vm.warp(oracle.computeL2Timestamp(_nextBlockNumber) + 1);
} }
...@@ -83,7 +83,7 @@ contract L2OutputOracle_Initializer is CommonTest { ...@@ -83,7 +83,7 @@ contract L2OutputOracle_Initializer is CommonTest {
initL1Time = startingTimestamp + 1; initL1Time = startingTimestamp + 1;
vm.warp(initL1Time); vm.warp(initL1Time);
vm.roll(startingBlockNumber); vm.roll(startingBlockNumber);
// Deploy the L2OutputOracle and transfer owernship to the sequencer // Deploy the L2OutputOracle and transfer owernship to the proposer
oracleImpl = new L2OutputOracle( oracleImpl = new L2OutputOracle(
submissionInterval, submissionInterval,
genesisL2Output, genesisL2Output,
...@@ -91,7 +91,7 @@ contract L2OutputOracle_Initializer is CommonTest { ...@@ -91,7 +91,7 @@ contract L2OutputOracle_Initializer is CommonTest {
startingBlockNumber, startingBlockNumber,
startingTimestamp, startingTimestamp,
l2BlockTime, l2BlockTime,
sequencer, proposer,
owner owner
); );
Proxy proxy = new Proxy(multisig); Proxy proxy = new Proxy(multisig);
...@@ -102,7 +102,7 @@ contract L2OutputOracle_Initializer is CommonTest { ...@@ -102,7 +102,7 @@ contract L2OutputOracle_Initializer is CommonTest {
L2OutputOracle.initialize.selector, L2OutputOracle.initialize.selector,
genesisL2Output, genesisL2Output,
startingBlockNumber, startingBlockNumber,
sequencer, proposer,
owner owner
) )
); );
......
...@@ -288,8 +288,8 @@ contract OptimismPortal_Test is Portal_Initializer { ...@@ -288,8 +288,8 @@ contract OptimismPortal_Test is Portal_Initializer {
uint256 checkpoint = oracle.nextBlockNumber(); uint256 checkpoint = oracle.nextBlockNumber();
vm.roll(checkpoint); vm.roll(checkpoint);
vm.warp(oracle.computeL2Timestamp(checkpoint) + 1); vm.warp(oracle.computeL2Timestamp(checkpoint) + 1);
vm.prank(oracle.sequencer()); vm.prank(oracle.proposer());
oracle.appendL2Output(keccak256(abi.encode(2)), checkpoint, 0, 0); oracle.proposeL2Output(keccak256(abi.encode(2)), checkpoint, 0, 0);
// warp to the final second of the finalization period // warp to the final second of the finalization period
uint256 finalizationHorizon = block.timestamp + op.FINALIZATION_PERIOD_SECONDS(); uint256 finalizationHorizon = block.timestamp + op.FINALIZATION_PERIOD_SECONDS();
......
This diff is collapsed.
...@@ -33,9 +33,7 @@ const getTargetOutput = async ( ...@@ -33,9 +33,7 @@ const getTargetOutput = async (
withdrawalTimestamp: number withdrawalTimestamp: number
) => { ) => {
const submissionInterval = (await oracle.SUBMISSION_INTERVAL()).toNumber() const submissionInterval = (await oracle.SUBMISSION_INTERVAL()).toNumber()
const startingTimestamp = ( const startingTimestamp = (await oracle.STARTING_TIMESTAMP()).toNumber()
await oracle.STARTING_TIMESTAMP()
).toNumber()
const nextTimestamp = (await oracle.nextTimestamp()).toNumber() const nextTimestamp = (await oracle.nextTimestamp()).toNumber()
let targetOutputTimestamp let targetOutputTimestamp
if (withdrawalTimestamp < nextTimestamp) { if (withdrawalTimestamp < nextTimestamp) {
......
...@@ -43,7 +43,7 @@ described [below](#l2-output-commitment-construction). ...@@ -43,7 +43,7 @@ described [below](#l2-output-commitment-construction).
If there is no newly finalized output, the service continues querying until it receives one. It then submits this If there is no newly finalized output, the service continues querying until it receives one. It then submits this
output, and the appropriate timestamp, to the [L2 Output Root](#l2-output-root-smart-contract) contract's output, and the appropriate timestamp, to the [L2 Output Root](#l2-output-root-smart-contract) contract's
`appendL2Output()` function. The timestamp MUST be the next multiple of the `SUBMISSION_INTERVAL` value. `proposeL2Output()` function. The timestamp MUST be the next multiple of the `SUBMISSION_INTERVAL` value.
The proposer may also delete the most recent output root by calling the `deleteL2Output()` function. The proposer may also delete the most recent output root by calling the `deleteL2Output()` function.
The function can be called repeatedly if it is necessary to roll back the state further. The function can be called repeatedly if it is necessary to roll back the state further.
...@@ -102,13 +102,13 @@ The L2 Output Oracle contract implements the following interface: ...@@ -102,13 +102,13 @@ The L2 Output Oracle contract implements the following interface:
* @notice Accepts an L2 outputRoot and the timestamp of the corresponding L2 block. The * @notice Accepts an L2 outputRoot and the timestamp of the corresponding L2 block. The
* timestamp must be equal to the current value returned by `nextTimestamp()` in order to be * timestamp must be equal to the current value returned by `nextTimestamp()` in order to be
* accepted. * accepted.
* This function may only be called by the Sequencer. * This function may only be called by the Proposer.
* @param _l2Output The L2 output of the checkpoint block. * @param _l2Output The L2 output of the checkpoint block.
* @param _l2BlockNumber The L2 block number that resulted in _l2Output. * @param _l2BlockNumber The L2 block number that resulted in _l2Output.
* @param _l1Blockhash A block hash which must be included in the current chain. * @param _l1Blockhash A block hash which must be included in the current chain.
* @param _l1BlockNumber The block number with the specified block hash. * @param _l1BlockNumber The block number with the specified block hash.
*/ */
function appendL2Output( function proposeL2Output(
bytes32 _l2Output, bytes32 _l2Output,
uint256 _l2BlockNumber, uint256 _l2BlockNumber,
bytes32 _l1Blockhash, bytes32 _l1Blockhash,
...@@ -133,7 +133,7 @@ function nextBlockNumber() public view returns (uint256) { ...@@ -133,7 +133,7 @@ function nextBlockNumber() public view returns (uint256) {
### L1 Reorgs ### L1 Reorgs
If the L1 has a reorg after an output has been generated and submitted, the L2 state and correct output may change If the L1 has a reorg after an output has been generated and submitted, the L2 state and correct output may change
leading to a faulty proposal. This is mitigated against by allowing the sequencer to submit an leading to a faulty proposal. This is mitigated against by allowing the proposer to submit an
L1 block number and hash to the Output Oracle when appending a new output; in the event of a reorg, the block hash L1 block number and hash to the Output Oracle when appending a new output; in the event of a reorg, the block hash
will not match that of the block with that number and the call will revert. will not match that of the block with that number and the call will revert.
......
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