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
500d4807
Unverified
Commit
500d4807
authored
Apr 22, 2024
by
Inphi
Committed by
GitHub
Apr 22, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ctb: Add disputegame contracts to Spec tests (#10234)
parent
4ff07403
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
204 additions
and
8 deletions
+204
-8
ForgeArtifacts.sol
packages/contracts-bedrock/scripts/ForgeArtifacts.sol
+10
-2
DeputyGuardianModule.t.sol
...es/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol
+3
-1
Specs.t.sol
packages/contracts-bedrock/test/Specs.t.sol
+191
-5
No files found.
packages/contracts-bedrock/scripts/ForgeArtifacts.sol
View file @
500d4807
...
...
@@ -146,11 +146,19 @@ library ForgeArtifacts {
/// @notice Returns the function ABIs of all L1 contracts.
function getContractFunctionAbis(
string memory path,
string
memory e
xcludes
string
[] memory pathE
xcludes
)
internal
returns (Abi[] memory abis_)
{
string memory pathExcludesPat;
for (uint256 i = 0; i < pathExcludes.length; i++) {
pathExcludesPat = string.concat(pathExcludesPat, " -path ", pathExcludes[i]);
if (i != pathExcludes.length - 1) {
pathExcludesPat = string.concat(pathExcludesPat, " -o ");
}
}
string[] memory command = new string[](3);
command[0] = Executables.bash;
command[1] = "-c";
...
...
@@ -158,8 +166,8 @@ library ForgeArtifacts {
Executables.find,
" ",
path,
bytes(pathExcludesPat).length > 0 ? string.concat(" ! \\( ", pathExcludesPat, " \\)") : "",
" -type f ",
bytes(excludes).length > 0 ? string.concat(" ! -name ", excludes, " ") : "",
"-exec basename {} \\;",
" | ",
Executables.sed,
...
...
packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol
View file @
500d4807
...
...
@@ -241,7 +241,9 @@ contract DeputyGuardianModule_NoPortalCollisions_Test is DeputyGuardianModule_Te
/// @dev tests that no function selectors in the L1 contracts collide with the OptimismPortal2 functions called by
/// the DeputyGuardianModule.
function test_noPortalCollisions_succeeds() external {
Abi[] memory abis = ForgeArtifacts.getContractFunctionAbis("src/{L1,dispute,universal}/", "OptimismPortal2.sol");
string[] memory excludes = new string[](1);
excludes[0] = "src/L1/OptimismPortal2.sol";
Abi[] memory abis = ForgeArtifacts.getContractFunctionAbis("src/{L1,dispute,universal}/", excludes);
for (uint256 i; i < abis.length; i++) {
for (uint256 j; j < abis[i].entries.length; j++) {
bytes4 sel = abis[i].entries[j].sel;
...
...
packages/contracts-bedrock/test/Specs.t.sol
View file @
500d4807
...
...
@@ -28,7 +28,9 @@ contract Specification_Test is CommonTest {
L1PROXYADMINOWNER,
GOVERNANCETOKENOWNER,
MINTMANAGEROWNER,
DATAAVAILABILITYCHALLENGEOWNER
DATAAVAILABILITYCHALLENGEOWNER,
DISPUTEGAMEFACTORYOWNER,
DELAYEDWETHOWNER
}
/// @notice Represents the specification of a function.
...
...
@@ -445,6 +447,176 @@ contract Specification_Test is CommonTest {
_addSpec({ _name: "MintManager", _sel: _getSel("renounceOwnership()"), _auth: Role.MINTMANAGEROWNER });
_addSpec({ _name: "MintManager", _sel: _getSel("transferOwnership(address)"), _auth: Role.MINTMANAGEROWNER });
_addSpec({ _name: "MintManager", _sel: _getSel("upgrade(address)"), _auth: Role.MINTMANAGEROWNER });
// AnchorStateRegistry
_addSpec({ _name: "AnchorStateRegistry", _sel: _getSel("anchors(uint32)") });
_addSpec({ _name: "AnchorStateRegistry", _sel: _getSel("disputeGameFactory()") });
_addSpec({ _name: "AnchorStateRegistry", _sel: _getSel("initialize((uint32,(bytes32,uint256))[])") });
_addSpec({ _name: "AnchorStateRegistry", _sel: _getSel("tryUpdateAnchorState()") });
_addSpec({ _name: "AnchorStateRegistry", _sel: _getSel("version()") });
// PermissionedDisputeGame
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("absolutePrestate()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("addLocalData(uint256,uint256,uint256)") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("anchorStateRegistry()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("attack(uint256,bytes32)"), _auth: Role.CHALLENGER });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("challenger()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("claimCredit(address)") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("claimData(uint256)") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("claimDataLen()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("claims(bytes32)") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("clockExtension()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("createdAt()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("credit(address)") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("defend(uint256,bytes32)"), _auth: Role.CHALLENGER });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("extraData()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("gameCreator()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("gameData()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("gameType()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("getChallengerDuration(uint256)") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("getRequiredBond(uint128)") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("initialize()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("l1Head()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("l2BlockNumber()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("l2ChainId()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("maxClockDuration()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("maxGameDepth()") });
_addSpec({
_name: "PermissionedDisputeGame",
_sel: _getSel("move(uint256,bytes32,bool)"),
_auth: Role.CHALLENGER
});
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("proposer()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("resolve()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("resolveClaim(uint256)") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("resolvedAt()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("resolvedSubgames(uint256)") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("rootClaim()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("splitDepth()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("startingBlockNumber()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("startingOutputRoot()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("startingRootHash()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("status()") });
_addSpec({
_name: "PermissionedDisputeGame",
_sel: _getSel("step(uint256,bool,bytes,bytes)"),
_auth: Role.CHALLENGER
});
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("subgames(uint256,uint256)") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("version()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("vm()") });
_addSpec({ _name: "PermissionedDisputeGame", _sel: _getSel("weth()") });
// FaultDisputeGame
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("absolutePrestate()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("addLocalData(uint256,uint256,uint256)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("anchorStateRegistry()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("attack(uint256,bytes32)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("challenger()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("claimCredit(address)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("claimData(uint256)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("claimDataLen()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("claims(bytes32)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("clockExtension()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("createdAt()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("credit(address)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("defend(uint256,bytes32)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("extraData()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("gameCreator()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("gameData()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("gameType()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("getChallengerDuration(uint256)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("getRequiredBond(uint128)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("initialize()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("l1Head()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("l2BlockNumber()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("l2ChainId()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("maxClockDuration()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("maxGameDepth()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("move(uint256,bytes32,bool)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("proposer()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("resolve()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("resolveClaim(uint256)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("resolvedAt()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("resolvedSubgames(uint256)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("rootClaim()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("splitDepth()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("startingBlockNumber()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("startingOutputRoot()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("startingRootHash()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("status()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("step(uint256,bool,bytes,bytes)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("subgames(uint256,uint256)") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("version()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("vm()") });
_addSpec({ _name: "FaultDisputeGame", _sel: _getSel("weth()") });
// DisputeGameFactory
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("create(uint32,bytes32,bytes)") });
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("findLatestGames(uint32,uint256,uint256)") });
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("gameAtIndex(uint256)") });
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("gameCount()") });
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("gameImpls(uint32)") });
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("games(uint32,bytes32,bytes)") });
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("getGameUUID(uint32,bytes32,bytes)") });
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("initBonds(uint32)") });
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("initialize(address)") });
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("owner()") });
_addSpec({
_name: "DisputeGameFactory",
_sel: _getSel("renounceOwnership()"),
_auth: Role.DISPUTEGAMEFACTORYOWNER
});
_addSpec({
_name: "DisputeGameFactory",
_sel: _getSel("setImplementation(uint32,address)"),
_auth: Role.GUARDIAN
});
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("setInitBond(uint32,uint256)"), _auth: Role.GUARDIAN });
_addSpec({
_name: "DisputeGameFactory",
_sel: _getSel("transferOwnership(address)"),
_auth: Role.DISPUTEGAMEFACTORYOWNER
});
_addSpec({ _name: "DisputeGameFactory", _sel: _getSel("version()") });
// DelayedWETH
_addSpec({ _name: "DelayedWETH", _sel: _getSel("allowance(address,address)") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("approve(address,uint256)") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("balanceOf(address)") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("config()") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("decimals()") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("delay()") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("deposit()") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("hold(address,uint256)"), _auth: Role.GUARDIAN });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("initialize(address,address)") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("name()") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("owner()") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("recover(uint256)"), _auth: Role.GUARDIAN });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("renounceOwnership()"), _auth: Role.DELAYEDWETHOWNER });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("symbol()") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("totalSupply()") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("transfer(address,uint256)") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("transferFrom(address,address,uint256)") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("transferOwnership(address)"), _auth: Role.DELAYEDWETHOWNER });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("unlock(address,uint256)") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("version()") });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("withdraw(address,uint256)"), _pausable: true });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("withdraw(uint256)"), _pausable: true });
_addSpec({ _name: "DelayedWETH", _sel: _getSel("withdrawals(address,address)") });
// WETH98
_addSpec({ _name: "WETH98", _sel: _getSel("allowance(address,address)") });
_addSpec({ _name: "WETH98", _sel: _getSel("approve(address,uint256)") });
_addSpec({ _name: "WETH98", _sel: _getSel("balanceOf(address)") });
_addSpec({ _name: "WETH98", _sel: _getSel("decimals()") });
_addSpec({ _name: "WETH98", _sel: _getSel("deposit()") });
_addSpec({ _name: "WETH98", _sel: _getSel("name()") });
_addSpec({ _name: "WETH98", _sel: _getSel("symbol()") });
_addSpec({ _name: "WETH98", _sel: _getSel("totalSupply()") });
_addSpec({ _name: "WETH98", _sel: _getSel("transfer(address,uint256)") });
_addSpec({ _name: "WETH98", _sel: _getSel("transferFrom(address,address,uint256)") });
_addSpec({ _name: "WETH98", _sel: _getSel("withdraw(uint256)") });
}
/// @dev Computes the selector from a function signature.
...
...
@@ -475,12 +647,17 @@ contract Specification_Test is CommonTest {
/// @notice Ensures that there's an auth spec for every L1 contract function.
function testContractAuth() public {
Abi[] memory abis = ForgeArtifacts.getContractFunctionAbis("src/{L1,governance,universal/ProxyAdmin.sol}", "");
string[] memory pathExcludes = new string[](1);
pathExcludes[0] = "src/dispute/interfaces/*";
Abi[] memory abis =
ForgeArtifacts.getContractFunctionAbis("src/{L1,dispute,governance,universal/ProxyAdmin.sol}", pathExcludes);
for (uint256 i = 0; i < abis.length; i++) {
string memory contractName = abis[i].contractName;
assertEq(
abis[i].entries.length, numEntries[contractName], "Specification_Test: invalid number of ABI entries"
abis[i].entries.length,
numEntries[contractName],
string.concat("Specification_Test: invalid number of ABI entries for ", contractName)
);
for (uint256 j = 0; j < abis[i].entries.length; j++) {
...
...
@@ -489,8 +666,17 @@ contract Specification_Test is CommonTest {
"Checking auth spec for %s: %s(%x)", contractName, abiEntry.fnName, uint256(uint32(abiEntry.sel))
);
Spec memory spec = specs[contractName][abiEntry.sel];
assertTrue(spec.sel != bytes4(0), "Specification_Test: missing spec definition");
assertEq(abiEntry.sel, spec.sel, "Specification_Test: invalid ABI");
assertTrue(
spec.sel != bytes4(0),
string.concat(
"Specification_Test: missing spec definition for ", contractName, "::", abiEntry.fnName
)
);
assertEq(
abiEntry.sel,
spec.sel,
string.concat("Specification_Test: invalid ABI ", contractName, "::", abiEntry.fnName)
);
}
}
}
...
...
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