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
7de692a6
Commit
7de692a6
authored
Dec 05, 2023
by
inphi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup auth specs
parent
15866f34
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
20 deletions
+25
-20
Authorization.t.sol
packages/contracts-bedrock/test/Authorization.t.sol
+25
-20
No files found.
packages/contracts-bedrock/test/Authorization.t.sol
View file @
7de692a6
...
...
@@ -10,7 +10,11 @@ import { SystemConfig } from "src/L1/SystemConfig.sol";
/// @title Authorization_Test
/// @dev Specify access requirements of all entrypoints to L1 contracts.
/// New contract and methods should be added to the `setUp` function.
/// When adding new functions, make sure to update the `setUp` function to document if
/// the function should be authorized or not. The `Spec` struct reppresents this
/// documentation, where `auth` is `true` if the function requires authorization and
/// `false` otherwise. However, this contract does not test for authorization, only that
/// an auth spec is defined for every L1 function.
contract Authorization_Test is CommonTest {
struct AbiEntry {
string fnName;
...
...
@@ -72,9 +76,7 @@ contract Authorization_Test is CommonTest {
_addSpec("L1ERC721Bridge", _getSel("bridgeERC721(address,address,uint256,uint32,bytes)"), false);
_addSpec("L1ERC721Bridge", _getSel("bridgeERC721To(address,address,address,uint256,uint32,bytes)"), false);
_addSpec("L1ERC721Bridge", _getSel("deposits(address,address,uint256)"), false);
_addSpec(
"L1ERC721Bridge", _getSel("finalizeBridgeERC721(address,address,address,address,uint256,bytes)"), false
);
_addSpec("L1ERC721Bridge", _getSel("finalizeBridgeERC721(address,address,address,address,uint256,bytes)"), true);
_addSpec("L1ERC721Bridge", _getSel("messenger()"), false);
_addSpec("L1ERC721Bridge", _getSel("otherBridge()"), false);
_addSpec("L1ERC721Bridge", _getSel("version()"), false);
...
...
@@ -92,13 +94,13 @@ contract Authorization_Test is CommonTest {
_addSpec("L1StandardBridge", _getSel("depositETHTo(address,uint32,bytes)"), false);
_addSpec("L1StandardBridge", _getSel("deposits(address,address)"), false);
_addSpec(
"L1StandardBridge", _getSel("finalizeBridgeERC20(address,address,address,address,uint256,bytes)"),
fals
e
"L1StandardBridge", _getSel("finalizeBridgeERC20(address,address,address,address,uint256,bytes)"),
tru
e
);
_addSpec("L1StandardBridge", _getSel("finalizeBridgeETH(address,address,uint256,bytes)"),
fals
e);
_addSpec("L1StandardBridge", _getSel("finalizeBridgeETH(address,address,uint256,bytes)"),
tru
e);
_addSpec(
"L1StandardBridge", _getSel("finalizeERC20Withdrawal(address,address,address,address,uint256,bytes)"),
fals
e
"L1StandardBridge", _getSel("finalizeERC20Withdrawal(address,address,address,address,uint256,bytes)"),
tru
e
);
_addSpec("L1StandardBridge", _getSel("finalizeETHWithdrawal(address,address,uint256,bytes)"),
fals
e);
_addSpec("L1StandardBridge", _getSel("finalizeETHWithdrawal(address,address,uint256,bytes)"),
tru
e);
_addSpec("L1StandardBridge", _getSel("l2TokenBridge()"), false);
_addSpec("L1StandardBridge", _getSel("messenger()"), false);
_addSpec("L1StandardBridge", _getSel("otherBridge()"), false);
...
...
@@ -112,7 +114,7 @@ contract Authorization_Test is CommonTest {
_addSpec("L2OutputOracle", _getSel("SUBMISSION_INTERVAL()"), false);
_addSpec("L2OutputOracle", _getSel("challenger()"), false);
_addSpec("L2OutputOracle", _getSel("computeL2Timestamp(uint256)"), false);
_addSpec("L2OutputOracle", _getSel("deleteL2Outputs(uint256)"),
fals
e);
_addSpec("L2OutputOracle", _getSel("deleteL2Outputs(uint256)"),
tru
e);
_addSpec("L2OutputOracle", _getSel("finalizationPeriodSeconds()"), false);
_addSpec("L2OutputOracle", _getSel("getL2Output(uint256)"), false);
_addSpec("L2OutputOracle", _getSel("getL2OutputAfter(uint256)"), false);
...
...
@@ -123,7 +125,7 @@ contract Authorization_Test is CommonTest {
_addSpec("L2OutputOracle", _getSel("latestOutputIndex()"), false);
_addSpec("L2OutputOracle", _getSel("nextBlockNumber()"), false);
_addSpec("L2OutputOracle", _getSel("nextOutputIndex()"), false);
_addSpec("L2OutputOracle", _getSel("proposeL2Output(bytes32,uint256,bytes32,uint256)"),
fals
e);
_addSpec("L2OutputOracle", _getSel("proposeL2Output(bytes32,uint256,bytes32,uint256)"),
tru
e);
_addSpec("L2OutputOracle", _getSel("proposer()"), false);
_addSpec("L2OutputOracle", _getSel("startingBlockNumber()"), false);
_addSpec("L2OutputOracle", _getSel("startingTimestamp()"), false);
...
...
@@ -136,7 +138,7 @@ contract Authorization_Test is CommonTest {
_addSpec("OptimismPortal", _getSel("SYSTEM_CONFIG()"), false);
_addSpec("OptimismPortal", _getSel("depositTransaction(address,uint256,uint64,bool,bytes)"), false);
_addSpec("OptimismPortal", _getSel("donateETH()"), false);
_addSpec("OptimismPortal", OptimismPortal.finalizeWithdrawalTransaction.selector,
false);
_addSpec("OptimismPortal", OptimismPortal.finalizeWithdrawalTransaction.selector,
true); // pauseable
_addSpec("OptimismPortal", _getSel("finalizedWithdrawals(bytes32)"), false);
_addSpec("OptimismPortal", _getSel("guardian()"), false);
_addSpec("OptimismPortal", _getSel("initialize(address)"), false);
...
...
@@ -146,7 +148,7 @@ contract Authorization_Test is CommonTest {
_addSpec("OptimismPortal", _getSel("minimumGasLimit(uint64)"), false);
_addSpec("OptimismPortal", _getSel("params()"), false);
_addSpec("OptimismPortal", _getSel("paused()"), false);
_addSpec("OptimismPortal", OptimismPortal.proveWithdrawalTransaction.selector,
false);
_addSpec("OptimismPortal", OptimismPortal.proveWithdrawalTransaction.selector,
true); // pauseable
_addSpec("OptimismPortal", _getSel("provenWithdrawals(bytes32)"), false);
_addSpec("OptimismPortal", _getSel("spacer_53_0_1()"), false);
_addSpec("OptimismPortal", _getSel("superchainConfig()"), false);
...
...
@@ -175,9 +177,9 @@ contract Authorization_Test is CommonTest {
_addSpec("SuperchainConfig", _getSel("PAUSED_SLOT()"), false);
_addSpec("SuperchainConfig", _getSel("guardian()"), false);
_addSpec("SuperchainConfig", _getSel("initialize(address)"), false);
_addSpec("SuperchainConfig", _getSel("pause(string)"),
fals
e);
_addSpec("SuperchainConfig", _getSel("pause(string)"),
tru
e);
_addSpec("SuperchainConfig", _getSel("paused()"), false);
_addSpec("SuperchainConfig", _getSel("unpause()"),
fals
e);
_addSpec("SuperchainConfig", _getSel("unpause()"),
tru
e);
_addSpec("SuperchainConfig", _getSel("version()"), false);
// SystemConfig
...
...
@@ -192,25 +194,28 @@ contract Authorization_Test is CommonTest {
_addSpec("SystemConfig", _getSel("renounceOwnership()"), true);
_addSpec("SystemConfig", SystemConfig.resourceConfig.selector, false);
_addSpec("SystemConfig", _getSel("scalar()"), false);
_addSpec("SystemConfig", SystemConfig.setBatcherHash.selector,
fals
e);
_addSpec("SystemConfig", SystemConfig.setGasConfig.selector,
fals
e);
_addSpec("SystemConfig", SystemConfig.setGasLimit.selector,
fals
e);
_addSpec("SystemConfig", SystemConfig.setResourceConfig.selector,
fals
e);
_addSpec("SystemConfig", SystemConfig.setUnsafeBlockSigner.selector,
fals
e);
_addSpec("SystemConfig", _getSel("transferOwnership(address)"),
fals
e);
_addSpec("SystemConfig", SystemConfig.setBatcherHash.selector,
tru
e);
_addSpec("SystemConfig", SystemConfig.setGasConfig.selector,
tru
e);
_addSpec("SystemConfig", SystemConfig.setGasLimit.selector,
tru
e);
_addSpec("SystemConfig", SystemConfig.setResourceConfig.selector,
tru
e);
_addSpec("SystemConfig", SystemConfig.setUnsafeBlockSigner.selector,
tru
e);
_addSpec("SystemConfig", _getSel("transferOwnership(address)"),
tru
e);
_addSpec("SystemConfig", SystemConfig.unsafeBlockSigner.selector, false);
_addSpec("SystemConfig", _getSel("version()"), false);
}
/// @dev Computes the selector from a function signature.
function _getSel(string memory _name) internal returns (bytes4) {
return bytes4(keccak256(abi.encodePacked(_name)));
}
/// @dev Adds a spec for a function.
function _addSpec(string memory _name, bytes4 _sel, bool _auth) internal {
specs[_name][_sel] = Spec({ name: _name, sel: _sel, auth: _auth });
numEntries[_name]++;
}
/// @notice Ensures that there's an auth spec for every L1 contract function.
function testContractAuth() public {
Abi[] memory abis = _getL1ContractFunctionAbis();
...
...
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