Skip to content

feat: Squash libraries in dispute contracts#10351

Merged
Inphi merged 3 commits intodevelopfrom
cl/ctb/squash-libs
May 1, 2024
Merged

feat: Squash libraries in dispute contracts#10351
Inphi merged 3 commits intodevelopfrom
cl/ctb/squash-libs

Conversation

@clabby
Copy link
Contributor

@clabby clabby commented Apr 30, 2024

Overview

Reorganizes the libraries in the dispute contracts to remove circular
dependencies. The existing dependency structure resolves within the
monorepo's environment, but not when the monorepo's contracts are
imported as a forge project dependency. This unblocks our ability to use
these contracts for post-checks in superchain-ops.

@clabby clabby self-assigned this Apr 30, 2024
Copy link
Contributor Author

clabby commented Apr 30, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @clabby and the rest of your teammates on Graphite Graphite

@semgrep-app
Copy link
Contributor

semgrep-app bot commented Apr 30, 2024

Semgrep found 2 sol-style-return-arg-fmt findings:

Named return arguments to functions must be appended with an underscore (_)

Ignore this finding from sol-style-return-arg-fmt.

Semgrep found 6 sol-style-notice-over-dev-natspec findings:

Prefer @notice over @dev in natspec comments

Ignore this finding from sol-style-notice-over-dev-natspec.

Semgrep found 3 sol-style-input-arg-fmt findings:

Inputs to functions must be prepended with an underscore (_)

Ignore this finding from sol-style-input-arg-fmt.

@clabby clabby force-pushed the cl/ctb/portal-extension-event branch from 754bca1 to c02683f Compare April 30, 2024 17:54
@clabby clabby force-pushed the cl/ctb/squash-libs branch from a95b6ae to 62d430b Compare April 30, 2024 17:55
@codecov
Copy link

codecov bot commented Apr 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.47%. Comparing base (b952dc0) to head (f186cf9).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #10351      +/-   ##
===========================================
+ Coverage    42.33%   43.47%   +1.14%     
===========================================
  Files           73       41      -32     
  Lines         4845     3986     -859     
  Branches       766      614     -152     
===========================================
- Hits          2051     1733     -318     
+ Misses        2684     2143     -541     
  Partials       110      110              
Flag Coverage Δ
cannon-go-tests 81.43% <ø> (ø)
chain-mon-tests 27.14% <ø> (ø)
common-ts-tests ?
contracts-ts-tests 12.25% <ø> (ø)
core-utils-tests ?
sdk-tests 40.27% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 32 files with indirect coverage changes

Base automatically changed from cl/ctb/portal-extension-event to develop April 30, 2024 19:02
@clabby clabby force-pushed the cl/ctb/squash-libs branch from 62d430b to f184c56 Compare April 30, 2024 19:21
clabby added 3 commits April 30, 2024 18:03
Reorganizes the libraries in the dispute contracts to remove circular
dependencies. The existing dependency structure resolves within the
monorepo's environment, but not when the monorepo's contracts are
imported as a forge project dependency. This unblocks our ability to use
these contracts for post-checks in `superchain-ops`.
@clabby clabby force-pushed the cl/ctb/squash-libs branch from f184c56 to f186cf9 Compare April 30, 2024 22:15
@clabby clabby marked this pull request as ready for review April 30, 2024 22:16
@clabby clabby requested a review from a team as a code owner April 30, 2024 22:16
@clabby clabby requested a review from tynes April 30, 2024 22:16
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 30, 2024

Walkthrough

Walkthrough

The recent updates involve a significant reorganization of the file structure and renaming of import paths, focusing on dispute-related types and error handling in Solidity contracts. New types and utility libraries have been introduced, enhancing data handling and functionality. The changes also include updates to versioning and adjustments in variable naming and type declarations to ensure consistency and clarity across the contract suite.

Changes

Files Changes
.../Deploy.s.sol, .../FaultDisputeGameViz.s.sol, .../fpac/FPACOPS.s.sol Updated import paths from "src/libraries/DisputeTypes.sol" to "src/dispute/lib/Types.sol".
.../FaultDisputeGameViz.s.sol Import path changed from "src/libraries/DisputeErrors.sol" to "src/dispute/lib/Errors.sol".
.../DisputeGameFactory.sol Import paths and version updated; minor adjustments in variable unpacking and type declarations.
.../FaultDisputeGame.sol Updated imports, version, and key types; modified function parameter types.
.../lib/LibUDT.sol, .../lib/Types.sol Introduced new types and libraries for handling dispute-related data structures.
.../test/dispute/lib/LibGameId.t.sol Adjusted imports and types used in test functions; simplified assertions.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between b952dc0 and f186cf9.
Files ignored due to path filters (5)
  • packages/contracts-bedrock/semver-lock.json is excluded by !**/*.json
  • packages/contracts-bedrock/snapshots/abi/FaultDisputeGame.json is excluded by !**/*.json
  • packages/contracts-bedrock/snapshots/abi/PermissionedDisputeGame.json is excluded by !**/*.json
  • packages/contracts-bedrock/snapshots/storageLayout/FaultDisputeGame.json is excluded by !**/*.json
  • packages/contracts-bedrock/snapshots/storageLayout/PermissionedDisputeGame.json is excluded by !**/*.json
Files selected for processing (33)
  • packages/contracts-bedrock/scripts/Deploy.s.sol (1 hunks)
  • packages/contracts-bedrock/scripts/FaultDisputeGameViz.s.sol (1 hunks)
  • packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol (1 hunks)
  • packages/contracts-bedrock/src/L1/OptimismPortal2.sol (1 hunks)
  • packages/contracts-bedrock/src/Safe/DeputyGuardianModule.sol (2 hunks)
  • packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol (2 hunks)
  • packages/contracts-bedrock/src/dispute/DisputeGameFactory.sol (7 hunks)
  • packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol (4 hunks)
  • packages/contracts-bedrock/src/dispute/PermissionedDisputeGame.sol (1 hunks)
  • packages/contracts-bedrock/src/dispute/interfaces/IAnchorStateRegistry.sol (1 hunks)
  • packages/contracts-bedrock/src/dispute/interfaces/IDisputeGame.sol (1 hunks)
  • packages/contracts-bedrock/src/dispute/interfaces/IDisputeGameFactory.sol (1 hunks)
  • packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol (1 hunks)
  • packages/contracts-bedrock/src/dispute/lib/Errors.sol (1 hunks)
  • packages/contracts-bedrock/src/dispute/lib/LibPosition.sol (2 hunks)
  • packages/contracts-bedrock/src/dispute/lib/LibUDT.sol (7 hunks)
  • packages/contracts-bedrock/src/dispute/lib/Types.sol (1 hunks)
  • packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol (1 hunks)
  • packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol (2 hunks)
  • packages/contracts-bedrock/test/actors/FaultDisputeActors.sol (1 hunks)
  • packages/contracts-bedrock/test/cannon/MIPS.t.sol (1 hunks)
  • packages/contracts-bedrock/test/dispute/AnchorStateRegistry.t.sol (1 hunks)
  • packages/contracts-bedrock/test/dispute/DelayedWETH.t.sol (1 hunks)
  • packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol (2 hunks)
  • packages/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol (1 hunks)
  • packages/contracts-bedrock/test/dispute/PermissionedDisputeGame.t.sol (1 hunks)
  • packages/contracts-bedrock/test/dispute/lib/LibClock.t.sol (1 hunks)
  • packages/contracts-bedrock/test/dispute/lib/LibGameId.t.sol (1 hunks)
  • packages/contracts-bedrock/test/dispute/lib/LibPosition.t.sol (1 hunks)
  • packages/contracts-bedrock/test/invariants/FaultDisputeGame.t.sol (1 hunks)
  • packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol (1 hunks)
  • packages/contracts-bedrock/test/mocks/AlphabetVM.sol (1 hunks)
  • packages/contracts-bedrock/test/vendor/Initializable.t.sol (1 hunks)
Files skipped from review due to trivial changes (9)
  • packages/contracts-bedrock/scripts/FaultDisputeGameViz.s.sol
  • packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol
  • packages/contracts-bedrock/src/dispute/interfaces/IDisputeGame.sol
  • packages/contracts-bedrock/src/dispute/interfaces/IDisputeGameFactory.sol
  • packages/contracts-bedrock/src/dispute/lib/Errors.sol
  • packages/contracts-bedrock/test/cannon/MIPS.t.sol
  • packages/contracts-bedrock/test/dispute/AnchorStateRegistry.t.sol
  • packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
  • packages/contracts-bedrock/test/dispute/lib/LibClock.t.sol
Additional Context Used
Learnings (1)
packages/contracts-bedrock/scripts/Deploy.s.sol (2)
User: tynes
PR: ethereum-optimism/optimism#8428
File: packages/contracts-bedrock/scripts/Deploy.s.sol:56-64
Timestamp: 2023-12-04T22:46:19.482Z
Learning: User tynes acknowledged the suggestion to remove redundant imports and plans to open another PR with the fix.
User: tynes
PR: ethereum-optimism/optimism#9100
File: packages/contracts-bedrock/scripts/Deployer.sol:28-28
Timestamp: 2024-01-20T00:50:26.866Z
Learning: The `sync()` method and its associated comment block have been removed from the `Deployer.sol` file as part of PR 9100, which aims to streamline the `contracts-bedrock` codebase by removing outdated and unused code components.
Additional comments not posted (35)
packages/contracts-bedrock/test/dispute/lib/LibGameId.t.sol (3)

7-7: Update import path to reflect new library structure.


14-14: Ensure the new type address for _gameProxy is correctly handled in all related functions.

Verification successful

The verification process has successfully identified the usage of _gameProxy in the file LibGameId.t.sol. The results show that _gameProxy is declared as an address, used as a parameter in the LibGameId.pack function, and compared in an assertion. This indicates that _gameProxy is being treated consistently as an address type across its usages in the file.

Based on this information, it can be concluded that the new type address for _gameProxy is correctly handled in all related functions within the file LibGameId.t.sol.

  • The declaration address _gameProxy confirms the type.
  • The function call LibGameId.pack(_gameType, _timestamp, _gameProxy) correctly passes _gameProxy as an argument.
  • The assertion assertEq(gameProxy_, _gameProxy) checks the equality of _gameProxy with another address, further confirming its correct usage as an address.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the new type `address` for `_gameProxy` is correctly handled in all related functions in `LibGameId.t.sol`.

# Find all occurrences of `_gameProxy` being used in the file and ensure it's treated as an address.
rg --type solidity '_gameProxy' 'packages/contracts-bedrock/test/dispute/lib/LibGameId.t.sol' | gawk '/_gameProxy/ {print $0}'

Length of output: 157



Script:

#!/bin/bash
# Description: Verify that the new type `address` for `_gameProxy` is correctly handled in all related functions in `LibGameId.t.sol`.

# Find all occurrences of `_gameProxy` being used in the file and ensure it's treated as an address.
rg '_gameProxy' 'packages/contracts-bedrock/test/dispute/lib/LibGameId.t.sol'

Length of output: 219


20-24: Validation of unpacked values looks correct and ensures integrity of the data.

packages/contracts-bedrock/src/dispute/interfaces/IAnchorStateRegistry.sol (1)

6-6: Update import path to reflect new library structure.

packages/contracts-bedrock/test/mocks/AlphabetVM.sol (1)

6-6: Update import path to reflect new library structure.

packages/contracts-bedrock/src/dispute/lib/Types.sol (1)

1-74: Ensure all new types and libraries are correctly defined and used consistently across the project.

Verification successful

The verification process has successfully identified that the new types and libraries defined in Types.sol are being used consistently across various parts of the project. The types such as GameType, Timestamp, Hash, VMStatus, GameStatus, OutputRoot, GameTypes, VMStatuses, and LocalPreimageKey are utilized in multiple files, including contract implementations, interfaces, and test suites. This widespread usage confirms that the new definitions are integrated and functional within the project's ecosystem.

Files confirming usage include:

  • PermissionedDisputeGame.sol
  • FaultDisputeGame.sol
  • IDisputeGameFactory.sol
  • IDisputeGame.sol
  • IAnchorStateRegistry.sol
  • AnchorStateRegistry.sol
  • DisputeGameFactory.sol
  • Safe/DeputyGuardianModule.sol
  • OptimismPortal2.sol
  • Various test files such as FaultDisputeGame.t.sol, PermissionedDisputeGame.t.sol, and others.

This comprehensive integration across contract logic and testing ensures that the new types are not only defined but are actively supporting the functionality of the system.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all new types and libraries in `Types.sol` are used consistently across the project.

# Find all files that import `Types.sol` and check for consistent usage of the new types.
rg --files-with-matches --type solidity 'import "src/dispute/lib/Types.sol"' | while read file; do
  # Check for consistent usage of new types.
  rg --type solidity 'GameType|Timestamp|Hash|VMStatus|GameStatus|OutputRoot|GameTypes|VMStatuses|LocalPreimageKey' "$file"
done

Length of output: 123



Script:

#!/bin/bash
# Description: Verify that all new types and libraries in `Types.sol` are used consistently across the project.

# Find all files that import `Types.sol` and check for consistent usage of the new types.
rg --files-with-matches 'import "src/dispute/lib/Types.sol"' | while read file; do
  # Check for consistent usage of new types.
  rg 'GameType|Timestamp|Hash|VMStatus|GameStatus|OutputRoot|GameTypes|VMStatuses|LocalPreimageKey' "$file"
done

Length of output: 41392

packages/contracts-bedrock/test/invariants/FaultDisputeGame.t.sol (1)

9-10: Update import paths to reflect new library structure and ensure new error handling is integrated.

packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol (2)

12-12: Update import path to reflect new library structure.


27-28: Semantic version update correctly reflects the changes made in this contract.

packages/contracts-bedrock/src/dispute/PermissionedDisputeGame.sol (1)

7-8: Update import paths to reflect new library structure and ensure new error handling is integrated.

packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol (1)

6-6: Update import path to reflect new library structure.

packages/contracts-bedrock/src/Safe/DeputyGuardianModule.sol (2)

13-13: Updated import path to src/dispute/lib/Types.sol aligns with the PR's objective to reorganize libraries to resolve circular dependencies.


46-47: Semantic version updated to 1.0.1. Ensure this version increment reflects all the functional changes and dependencies accurately.

Verification successful

The verification process has confirmed that no other contracts importing DeputyGuardianModule.sol have version annotations (@custom:semver) that could conflict or need to be updated in relation to the version update in DeputyGuardianModule.sol to 1.0.1. This suggests that the version increment is consistent within the scope of the contracts directly related to DeputyGuardianModule.sol.

  • Conclusion: The semantic version update in DeputyGuardianModule.sol to 1.0.1 is verified as consistent with the changes made across related contracts, as no conflicting version annotations were found in the importing contracts.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the version increment in `DeputyGuardianModule.sol` is consistent with the changes made across related contracts.

# Find all Solidity files that import `DeputyGuardianModule.sol` and check their version annotations.
rg --files-with-matches --type solidity $'import .*DeputyGuardianModule.sol' | while read file; do
  # Test: Search for version annotations in the importing files. Expect: Consistent versioning.
  rg --type solidity $'@custom:semver' "$file"
done

Length of output: 122



Script:

#!/bin/bash
# Description: Verify that the version increment in `DeputyGuardianModule.sol` is consistent with the changes made across related contracts.

# Find all Solidity files that import `DeputyGuardianModule.sol` and check their version annotations.
rg --files-with-matches 'import .*DeputyGuardianModule.sol' *.sol | while read file; do
  # Test: Search for version annotations in the importing files. Expect: Consistent versioning.
  rg '@custom:semver' "$file"
done

Length of output: 127



Script:

#!/bin/bash
# Description: Verify that the version increment in `DeputyGuardianModule.sol` is consistent with the changes made across related contracts.

# Find all Solidity files using fd and check for imports of `DeputyGuardianModule.sol`.
fd '.sol$' | while read file; do
  # Check if the file imports `DeputyGuardianModule.sol`.
  if rg --quiet 'import .*DeputyGuardianModule.sol' "$file"; then
    # If it does, search for version annotations in the file.
    rg '@custom:semver' "$file"
  fi
done

Length of output: 33767

packages/contracts-bedrock/test/dispute/PermissionedDisputeGame.t.sol (1)

14-15: Updated import paths to src/dispute/lib/Types.sol and src/dispute/lib/Errors.sol are consistent with the PR's objectives to reorganize and centralize type and error definitions.

packages/contracts-bedrock/src/dispute/DisputeGameFactory.sol (1)

11-12: Updated import paths to src/dispute/lib/Types.sol and src/dispute/lib/Errors.sol align with the PR's restructuring goals.

packages/contracts-bedrock/test/dispute/DelayedWETH.t.sol (1)

4-5: Updated import paths to src/dispute/lib/Types.sol and src/dispute/lib/Errors.sol are consistent with the PR's objectives to reorganize and centralize type and error definitions.

packages/contracts-bedrock/src/dispute/lib/LibUDT.sol (1)

4-13: The use of type-specific libraries (LibClaim, LibHash, etc.) enhances modularity and reusability of code. Ensure that these libraries are used consistently across the project.

Verification successful

The verification process has successfully confirmed that the type-specific libraries (LibClaim, LibHash, etc.) are used consistently across the project. Each Solidity file that was checked contains consistent usage of these libraries, which aligns with the practices observed in the LibUDT.sol file. This consistency supports modularity and reusability of code across the project.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify consistent use of type-specific libraries across the project.

# Find all Solidity files and check for inconsistent usage of the libraries.
rg --files-with-matches --type solidity $'using .*Lib.* for .*;' | while read file; do
  # Test: Search for inconsistent library usage. Expect: Consistent usage.
  rg --type solidity $'using .*Lib.* for .*;' "$file"
done

Length of output: 110



Script:

#!/bin/bash
# Description: Verify consistent use of type-specific libraries across the project.

# Define Solidity files by their extension and check for inconsistent usage of the libraries.
find . -name "*.sol" -print | while read file; do
  # Test: Search for inconsistent library usage. Expect: Consistent usage.
  rg 'using .*Lib.* for .*;' "$file"
done

Length of output: 29502

packages/contracts-bedrock/src/dispute/lib/LibPosition.sol (1)

4-4: The global usage of LibPosition for the Position type is appropriate and enhances code clarity and reusability.

packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol (1)

18-18: Ensure the newly imported Types.sol is utilized appropriately in the file.

Verification successful

The verification process has confirmed that the file OptimismPortal2.t.sol does indeed utilize the Types imported from Types.sol. This aligns with the review comment's concern about ensuring the newly imported module is used appropriately within the file.

  • File: packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol
  • Usage: The file contains references to Types, indicating that the import is not redundant.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the newly imported `Types.sol` is utilized in the `OptimismPortal2.t.sol` file.

# Search for usage of `Types` in the file.
rg --files-with-matches --type solidity $'Types' "packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol"

Length of output: 145



Script:

#!/bin/bash
# Description: Verify that the newly imported `Types.sol` is utilized in the `OptimismPortal2.t.sol` file.

# Search for usage of `Types` in the file without specifying the file type.
rg --files-with-matches 'Types' "packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol"

Length of output: 161

packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol (1)

12-12: Ensure the newly imported GameType from Types.sol is utilized appropriately in the file.

Verification successful

The verification process has confirmed that the GameType from Types.sol is indeed utilized in the DeputyGuardianModule.t.sol file. This aligns with the import statement added, suggesting that the import is functional and being used as expected within the file.

  • packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol: Confirmed usage of GameType.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the newly imported `GameType` from `Types.sol` is utilized in the `DeputyGuardianModule.t.sol` file.

# Search for usage of `GameType` in the file.
rg --files-with-matches --type solidity $'GameType' "packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol"

Length of output: 147



Script:

#!/bin/bash
# Description: Verify that the newly imported `GameType` from `Types.sol` is utilized in the `DeputyGuardianModule.t.sol` file.

# Search for usage of `GameType` in the file without specifying the file type.
rg --files-with-matches 'GameType' "packages/contracts-bedrock/test/Safe/DeputyGuardianModule.t.sol"

Length of output: 162

packages/contracts-bedrock/test/actors/FaultDisputeActors.sol (1)

9-9: Update import path to reflect new library structure.

This change aligns with the PR's objective to reorganize libraries to resolve circular dependencies.

packages/contracts-bedrock/test/dispute/lib/LibPosition.t.sol (1)

6-6: Update import path to reflect new library structure.

This change aligns with the PR's objective to reorganize libraries to resolve circular dependencies.

packages/contracts-bedrock/test/vendor/Initializable.t.sol (1)

14-14: Update import path to reflect new library structure.

This change aligns with the PR's objective to reorganize libraries to resolve circular dependencies.

packages/contracts-bedrock/src/L1/OptimismPortal2.sol (1)

19-19: Updated import path for Types.sol aligns with the PR's objectives to resolve circular dependencies.

Verification successful

The verification confirms that Types.sol is correctly imported and utilized in the OptimismPortal2.sol contract. The types defined in Types.sol are actively used in the contract's functions, aligning with the PR's objectives to resolve circular dependencies and reorganize libraries.

  • The import statement import "src/dispute/lib/Types.sol"; is correctly placed.
  • The types Types.WithdrawalTransaction and Types.OutputRootProof are used in the contract's logic.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `Types.sol` is used correctly in the OptimismPortal2 contract.

# Search for the usage of `Types.sol` in the OptimismPortal2 contract.
rg --type solidity --files-with-matches $'import "src/dispute/lib/Types.sol"' packages/contracts-bedrock/src/L1/OptimismPortal2.sol | xargs rg --type solidity 'Types\.' 

Length of output: 235



Script:

#!/bin/bash
# Description: Verify that `Types.sol` is used correctly in the OptimismPortal2 contract without specifying file type.

# Search for the usage of `Types.sol` in the OptimismPortal2 contract.
rg --files-with-matches 'import "src/dispute/lib/Types.sol"' packages/contracts-bedrock/src/L1/OptimismPortal2.sol | xargs rg 'Types\.'

Length of output: 483

packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol (5)

17-18: Update import paths to reflect new library locations.

This change aligns with the PR's objective to reorganize libraries to resolve circular dependencies.


64-65: Version update to "0.18.1" is appropriate.

This minor version increment (from "0.18.0" to "0.18.1") correctly reflects the backward-compatible changes made in this contract.


86-86: Change of mapping key type from ClaimHash to Hash in claims.

This change is consistent with the PR's goal to streamline type usage across the contract, enhancing maintainability and reducing complexity.


367-367: Introduction of new claim hash calculation and storage logic.

This addition ensures that claims are uniquely identified and prevents duplicate claims, which is crucial for the integrity of the dispute game mechanism.


Line range hint 1-367: Ensure comprehensive testing of new and modified logic.

Comprehensive testing is crucial, especially for contracts involved in dispute resolution, to prevent errors that could lead to financial losses or disputes not being resolved correctly.

Verification successful

The provided test files FaultDisputeGame.t.sol and FaultDisputeGame_Solvency_Invariant.t.sol contain extensive unit tests covering various aspects of the FaultDisputeGame contract. These tests include initialization checks, parameter validation, game logic, and edge cases. Additionally, the tests ensure that the contract handles ETH correctly, adheres to game rules, and maintains consistent state throughout the game lifecycle.

The tests are structured to validate:

  • Constructor parameters and their constraints.
  • Game initialization and state transitions.
  • Handling of ETH deposits and withdrawals.
  • Correct application of game rules, such as move validity and game resolution.
  • Invariants like solvency, ensuring no ETH is left locked in the contract unintentionally.

Given the comprehensive nature of these tests, it appears that the new and modified logic in the FaultDisputeGame contract is adequately covered. This should help ensure that the contract behaves as expected under various conditions, thereby reducing the risk of bugs or vulnerabilities in a live environment.

Conclusion:
The unit tests provided in the FaultDisputeGame.t.sol and FaultDisputeGame_Solvency_Invariant.t.sol files appear to cover the new and modified logic in the FaultDisputeGame contract comprehensively. This includes checks for correct initialization, game logic adherence, and proper handling of ETH transactions, which are critical for the contract's functionality and security.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all new and modified logic in `FaultDisputeGame.sol` is covered by unit tests.

# Find test files related to `FaultDisputeGame.sol`.
fd 'FaultDisputeGame.t.sol' --exec bash -c 'echo "Testing file: $1"; cat $1' --

Length of output: 95284

packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol (1)

25-25: Update import paths to reflect new library locations.

This change aligns with the PR's objective to reorganize libraries to resolve circular dependencies and improve modularity.

packages/contracts-bedrock/scripts/Deploy.s.sol (1)

50-50: Updated import path aligns with the PR's objectives to reorganize libraries.

packages/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol (4)

12-13: Updated import paths to reflect new library locations.


13-13: Check if LibClock should also be moved to the new library structure.

Verification successful

The verification process has confirmed that LibClock is consistently imported from "src/dispute/lib/LibUDT.sol" across multiple Solidity files within the packages/contracts-bedrock directory. This indicates that LibClock has indeed been moved to the new library structure as part of the reorganization, and the imports are correctly updated in the codebase.

  • PermissionedDisputeGame.t.sol
  • FaultDisputeGame.t.sol
  • LibClock.t.sol
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if `LibClock` is moved to the new library structure or if it should be.

# Search for `LibClock` import in all Solidity files to see if it's been moved.
rg --type sol 'import .*LibClock' | while read line; do
  echo "Found LibClock import in: $line"
done

Length of output: 75



Script:

#!/bin/bash
# Description: Verify if `LibClock` is moved to the new library structure or if it should be.

# Search for `LibClock` import in all Solidity files to see if it's been moved.
rg 'import .*LibClock' -g '*.sol' | while read line; do
  echo "Found LibClock import in: $line"
done

Length of output: 980


Line range hint 47-47: Check the correctness of the gameType initialization to ensure it matches expected game configurations.

Verification successful

The verification process has successfully identified multiple instances of gameType usage across various Solidity files in the repository. These instances include declarations, assertions, and function parameters, indicating a consistent and widespread use of the gameType variable throughout the codebase.

Given the extensive references and the context in which gameType is used, it appears that the initialization and handling of gameType align with the expected configurations and usage patterns within the project. Therefore, the original review comment concerning the correctness of the gameType initialization seems to be adequately addressed by the current implementation in the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `gameType` initialization matches the expected configurations.

# Search for `gameType` usage in all Solidity files to ensure consistency.
rg --type sol 'gameType' | while read line; do
  echo "Found gameType usage in: $line"
done

Length of output: 64



Script:

#!/bin/bash
# Description: Verify that the `gameType` initialization matches the expected configurations.

# Search for `gameType` usage in all files with the .sol extension to ensure consistency.
rg 'gameType' --glob '*.sol' | while read line; do
  echo "Found gameType usage in: $line"
done

Length of output: 63041


Line range hint 104-104: Ensure setUp function correctly prepares the test environment for all scenarios.

Verification successful

The verification process has successfully identified the usage of the setUp function across various test files in the packages/contracts-bedrock directory. This function is consistently used to prepare the test environment, as indicated by its presence in multiple test scenarios and files. Each instance of the setUp function is marked with appropriate visibility and override modifiers, suggesting that it is tailored to fit the specific needs of each test suite.

Given this comprehensive usage across the test suite, it can be concluded that the setUp function is indeed set up correctly to prepare the environment across all test scenarios in the FaultDisputeGame_Test contract and related test contracts.

Conclusion:

  • The setUp function is used extensively and appropriately across the test suites to prepare the test environment.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `setUp` function prepares the environment correctly across all test scenarios.

# Search for `setUp` usage in test files to ensure it's adequately preparing the environment.
rg --type sol --files-with-matches 'function setUp' | while read file; do
  echo "setUp function found in: $file"
done

Length of output: 93



Script:

#!/bin/bash
# Description: Verify that the `setUp` function prepares the environment correctly across all test scenarios.

# Corrected search for `setUp` usage in Solidity files to ensure it's adequately preparing the environment.
rg 'function setUp' -g '*.sol' | while read line; do
  echo "$line"
done

Length of output: 26403


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Out of diff range and nitpick comments (1)
packages/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol (1)

Line range hint 35-35: Ensure realistic time setting in tests reflects intended scenarios.

@clabby clabby requested review from Inphi and refcell May 1, 2024 15:24
clabby added a commit to ethereum-optimism/specs that referenced this pull request May 1, 2024
## Overview

Removes references to the `ClaimHash` type, in favor of "state witness
hash". This is a more accurate description, and the `ClaimHash` type was
removed in ethereum-optimism/optimism#10351
@clabby clabby added this pull request to the merge queue May 1, 2024
clabby added a commit to ethereum-optimism/specs that referenced this pull request May 1, 2024
Removes references to the `ClaimHash` type, in favor of "state witness
hash". This is a more accurate description, and the `ClaimHash` type was
removed in ethereum-optimism/optimism#10351
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 1, 2024
@clabby clabby added this pull request to the merge queue May 1, 2024
github-merge-queue bot pushed a commit that referenced this pull request May 1, 2024
* feat: Squash libraries in dispute contracts

Reorganizes the libraries in the dispute contracts to remove circular
dependencies. The existing dependency structure resolves within the
monorepo's environment, but not when the monorepo's contracts are
imported as a forge project dependency. This unblocks our ability to use
these contracts for post-checks in `superchain-ops`.

* Remove `IDisputeGame` dep in `LibUDT`

* semver lock
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 1, 2024
@Inphi Inphi added this pull request to the merge queue May 1, 2024
Merged via the queue into develop with commit 154f976 May 1, 2024
@Inphi Inphi deleted the cl/ctb/squash-libs branch May 1, 2024 20:22
ajsutton pushed a commit to ethereum-optimism/specs that referenced this pull request May 1, 2024
Removes references to the `ClaimHash` type, in favor of "state witness
hash". This is a more accurate description, and the `ClaimHash` type was
removed in ethereum-optimism/optimism#10351


Co-authored-by: Inphi <mlaw2501@gmail.com>
pcw109550 added a commit to ethereum-optimism/asterisc that referenced this pull request Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants