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
6dc18168
Unverified
Commit
6dc18168
authored
Oct 27, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into aj/tag-not-branch
parents
31d1b6f5
e36d7e3e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
15 deletions
+27
-15
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+1
-3
OptimismPortal.md
packages/contracts-bedrock/invariant-docs/OptimismPortal.md
+4
-4
CommonTest.t.sol
packages/contracts-bedrock/test/CommonTest.t.sol
+13
-0
L2OutputOracle.t.sol
packages/contracts-bedrock/test/L2OutputOracle.t.sol
+2
-2
OptimismPortal.t.sol
...es/contracts-bedrock/test/invariants/OptimismPortal.t.sol
+7
-6
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
6dc18168
...
...
@@ -49,7 +49,6 @@ CrossDomainOwnable_Test:test_onlyOwner_succeeds() (gas: 34883)
DelayedVetoable_Getters_Test:test_getters() (gas: 24466)
DelayedVetoable_Getters_TestFail:test_getters_notZeroAddress_reverts() (gas: 36220)
DelayedVetoable_HandleCall_TestFail:test_handleCall_unauthorizedInitiation_reverts() (gas: 21867)
DeleteOutput:test_script_succeeds() (gas: 3100)
DeployerWhitelist_Test:test_owner_succeeds() (gas: 7582)
DeployerWhitelist_Test:test_storageSlots_succeeds() (gas: 33395)
DisputeGameFactory_Owner_Test:test_owner_succeeds() (gas: 12581)
...
...
@@ -77,7 +76,6 @@ Drippie_Test:test_status_unauthorized_reverts() (gas: 167388)
Drippie_Test:test_trigger_oneFunction_succeeds() (gas: 338226)
Drippie_Test:test_trigger_twoFunctions_succeeds() (gas: 491907)
Drippie_Test:test_twice_inOneInterval_reverts() (gas: 303933)
EASUpgrader:test_script_succeeds() (gas: 3078)
FaucetTest:test_authAdmin_drip_succeeds() (gas: 366107)
FaucetTest:test_drip_afterTimeout_succeeds() (gas: 447891)
FaucetTest:test_drip_beforeTimeout_reverts() (gas: 378884)
...
...
@@ -249,7 +247,7 @@ L2OutputOracleUpgradeable_Test:test_initValuesOnImpl_succeeds() (gas: 23902)
L2OutputOracleUpgradeable_Test:test_initValuesOnProxy_succeeds() (gas: 46800)
L2OutputOracleUpgradeable_Test:test_initializeImpl_alreadyInitialized_reverts() (gas: 15216)
L2OutputOracleUpgradeable_Test:test_initializeProxy_alreadyInitialized_reverts() (gas: 20216)
L2OutputOracleUpgradeable_Test:test_upgrading_succeeds() (gas: 1
9145
5)
L2OutputOracleUpgradeable_Test:test_upgrading_succeeds() (gas: 1
8787
5)
L2OutputOracle_constructor_Test:test_constructor_l2BlockTimeZero_reverts() (gas: 39022)
L2OutputOracle_constructor_Test:test_constructor_submissionInterval_reverts() (gas: 39032)
L2OutputOracle_constructor_Test:test_constructor_succeeds() (gas: 51777)
...
...
packages/contracts-bedrock/invariant-docs/OptimismPortal.md
View file @
6dc18168
# `OptimismPortal` Invariants
## Deposits of any value should always succeed unless `_to` = `address(0)` or `_isCreation` = `true`.
**Test:**
[
`OptimismPortal.t.sol#L14
7`
](
../test/invariants/OptimismPortal.t.sol#L147
)
**Test:**
[
`OptimismPortal.t.sol#L14
8`
](
../test/invariants/OptimismPortal.t.sol#L148
)
All deposits, barring creation transactions and transactions sent to
`address(0)`
, should always succeed.
## `finalizeWithdrawalTransaction` should revert if the finalization period has not elapsed.
**Test:**
[
`OptimismPortal.t.sol#L17
0`
](
../test/invariants/OptimismPortal.t.sol#L170
)
**Test:**
[
`OptimismPortal.t.sol#L17
1`
](
../test/invariants/OptimismPortal.t.sol#L171
)
A withdrawal that has been proven should not be able to be finalized until after the finalization period has elapsed.
## `finalizeWithdrawalTransaction` should revert if the withdrawal has already been finalized.
**Test:**
[
`OptimismPortal.t.sol#L20
0`
](
../test/invariants/OptimismPortal.t.sol#L200
)
**Test:**
[
`OptimismPortal.t.sol#L20
1`
](
../test/invariants/OptimismPortal.t.sol#L201
)
Ensures that there is no chain of calls that can be made that allows a withdrawal to be finalized twice.
## A withdrawal should **always** be able to be finalized `FINALIZATION_PERIOD_SECONDS` after it was successfully proven.
**Test:**
[
`OptimismPortal.t.sol#L2
29`
](
../test/invariants/OptimismPortal.t.sol#L229
)
**Test:**
[
`OptimismPortal.t.sol#L2
30`
](
../test/invariants/OptimismPortal.t.sol#L230
)
This invariant asserts that there is no chain of calls that can be made that will prevent a withdrawal from being finalized exactly
`FINALIZATION_PERIOD_SECONDS`
after it was successfully proven.
\ No newline at end of file
packages/contracts-bedrock/test/CommonTest.t.sol
View file @
6dc18168
...
...
@@ -3,6 +3,7 @@ pragma solidity 0.8.15;
// Testing utilities
import { Test, StdUtils } from "forge-std/Test.sol";
import { Vm } from "forge-std/Vm.sol";
import { L2OutputOracle } from "src/L1/L2OutputOracle.sol";
import { L2ToL1MessagePasser } from "src/L2/L2ToL1MessagePasser.sol";
import { L1StandardBridge } from "src/L1/L1StandardBridge.sol";
...
...
@@ -731,6 +732,18 @@ contract FFIInterface is Test {
}
}
library EIP1967Helper {
Vm internal constant vm = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
function getAdmin(address _proxy) internal view returns (address) {
return address(uint160(uint256(vm.load(address(_proxy), Constants.PROXY_OWNER_ADDRESS))));
}
function getImplementation(address _proxy) internal view returns (address) {
return address(uint160(uint256(vm.load(address(_proxy), Constants.PROXY_IMPLEMENTATION_ADDRESS))));
}
}
// Used for testing a future upgrade beyond the current implementations.
// We include some variables so that we can sanity check accessing storage values after an upgrade.
contract NextImpl is Initializable {
...
...
packages/contracts-bedrock/test/L2OutputOracle.t.sol
View file @
6dc18168
...
...
@@ -3,7 +3,7 @@ pragma solidity 0.8.15;
// Testing utilities
import { stdError } from "forge-std/Test.sol";
import { L2OutputOracle_Initializer, NextImpl } from "test/CommonTest.t.sol";
import { L2OutputOracle_Initializer, NextImpl
, EIP1967Helper
} from "test/CommonTest.t.sol";
// Libraries
import { Types } from "src/libraries/Types.sol";
...
...
@@ -463,7 +463,7 @@ contract L2OutputOracleUpgradeable_Test is L2OutputOracle_Initializer {
assertEq(bytes32(0), slot21Before);
NextImpl nextImpl = new NextImpl();
vm.startPrank(
multisig
);
vm.startPrank(
EIP1967Helper.getAdmin(address(proxy))
);
proxy.upgradeToAndCall(
address(nextImpl), abi.encodeWithSelector(NextImpl.initialize.selector, Constants.INITIALIZER + 1)
);
...
...
packages/contracts-bedrock/test/invariants/OptimismPortal.t.sol
View file @
6dc18168
...
...
@@ -12,6 +12,7 @@ import { ResourceMetering } from "src/L1/ResourceMetering.sol";
import { Constants } from "src/libraries/Constants.sol";
import { Portal_Initializer } from "test/CommonTest.t.sol";
import { EIP1967Helper } from "test/CommonTest.t.sol";
import { Types } from "src/libraries/Types.sol";
contract OptimismPortal_Depositor is StdUtils, ResourceMetering {
...
...
@@ -158,8 +159,8 @@ contract OptimismPortal_CannotTimeTravel is OptimismPortal_Invariant_Harness {
// Set the target contract to the portal proxy
targetContract(address(op));
// Exclude the proxy
multisig
from the senders so that the proxy cannot be upgraded
excludeSender(
address(multisig
));
// Exclude the proxy
admin
from the senders so that the proxy cannot be upgraded
excludeSender(
EIP1967Helper.getAdmin(address(op)
));
}
/// @custom:invariant `finalizeWithdrawalTransaction` should revert if the finalization
...
...
@@ -188,8 +189,8 @@ contract OptimismPortal_CannotFinalizeTwice is OptimismPortal_Invariant_Harness
// Set the target contract to the portal proxy
targetContract(address(op));
// Exclude the proxy
multisig
from the senders so that the proxy cannot be upgraded
excludeSender(
address(multisig
));
// Exclude the proxy
admin
from the senders so that the proxy cannot be upgraded
excludeSender(
EIP1967Helper.getAdmin(address(op)
));
}
/// @custom:invariant `finalizeWithdrawalTransaction` should revert if the withdrawal
...
...
@@ -215,8 +216,8 @@ contract OptimismPortal_CanAlwaysFinalizeAfterWindow is OptimismPortal_Invariant
// Set the target contract to the portal proxy
targetContract(address(op));
// Exclude the proxy
multisig
from the senders so that the proxy cannot be upgraded
excludeSender(
address(multisig
));
// Exclude the proxy
admin
from the senders so that the proxy cannot be upgraded
excludeSender(
EIP1967Helper.getAdmin(address(op)
));
}
/// @custom:invariant A withdrawal should **always** be able to be finalized
...
...
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