Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
de7ba3ca
Commit
de7ba3ca
authored
Feb 21, 2023
by
clabby
Committed by
Mark Tyneway
Feb 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update `L2OutputOracle` invariant test
parent
9a5563f5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
10 deletions
+37
-10
L2OutputOracle.t.sol
...ts-bedrock/contracts/test/invariants/L2OutputOracle.t.sol
+36
-9
L2OutputOracle.md
packages/contracts-bedrock/invariant-docs/L2OutputOracle.md
+1
-1
No files found.
packages/contracts-bedrock/contracts/test/invariants/L2OutputOracle.t.sol
View file @
de7ba3ca
pragma solidity 0.8.15;
import { L2OutputOracle_Initializer } from "../CommonTest.t.sol";
import { L2OutputOracle } from "../../L1/L2OutputOracle.sol";
import { Vm } from "forge-std/Vm.sol";
contract L2OutputOracle_Proposer {
L2OutputOracle internal oracle;
Vm internal vm;
constructor(L2OutputOracle _oracle, Vm _vm) {
oracle = _oracle;
vm = _vm;
}
/**
* @dev Allows the actor to propose an L2 output to the `L2OutputOracle`
*/
function proposeL2Output(
bytes32 _outputRoot,
uint256 _l2BlockNumber,
bytes32 _l1BlockHash,
uint256 _l1BlockNumber
) external {
// Act as the proposer and propose a new output.
vm.prank(oracle.PROPOSER());
oracle.proposeL2Output(_outputRoot, _l2BlockNumber, _l1BlockHash, _l1BlockNumber);
}
}
contract L2OutputOracle_MonotonicBlockNumIncrease_Invariant is L2OutputOracle_Initializer {
L2OutputOracle_Proposer internal actor;
function setUp() public override {
super.setUp();
// Set the target contract to the oracle proxy
targetContract(address(oracle));
// Set the target sender to the proposer
targetSender(address(proposer));
// Create a proposer actor.
actor = new L2OutputOracle_Proposer(oracle, vm);
// Set the target contract to the proposer actor.
targetContract(address(actor));
// Set the target selector for `proposeL2Output`
// `proposeL2Output` is the only function we care about, as it is the only function
// that can modify the `l2Outputs` array in the oracle.
bytes4[] memory selectors = new bytes4[](1);
selectors[0] = oracle.proposeL2Output.selector;
FuzzSelector memory selector = FuzzSelector({
addr: address(oracle),
selectors: selectors
});
selectors[0] = actor.proposeL2Output.selector;
FuzzSelector memory selector = FuzzSelector({ addr: address(actor), selectors: selectors });
targetSelector(selector);
}
...
...
packages/contracts-bedrock/invariant-docs/L2OutputOracle.md
View file @
de7ba3ca
# `L2OutputOracle` Invariants
## The block number of the output root proposals should monotonically increase.
**Test:**
[
`L2OutputOracle.t.sol#L
32`
](
../contracts/test/invariants/L2OutputOracle.t.sol#L32
)
**Test:**
[
`L2OutputOracle.t.sol#L
59`
](
../contracts/test/invariants/L2OutputOracle.t.sol#L59
)
When a new output is submitted, it should never be allowed to correspond to a block number that is less than the current output.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment