Skip to content

dispute-game: Sanity check disputed claim index#10520

Merged
clabby merged 8 commits intodevelopfrom
inphi/fdg-safe
May 14, 2024
Merged

dispute-game: Sanity check disputed claim index#10520
clabby merged 8 commits intodevelopfrom
inphi/fdg-safe

Conversation

@Inphi
Copy link
Contributor

@Inphi Inphi commented May 13, 2024

The IFaultDisputeGame.move interface has been modified to accept a disputed Claim hash. This allows the FDG to sanity check the disputed claim hash against its corresponding index in the claimData array.

This improves the UX of the interface to guard against possible reorgs when a challenger attempts to move against a reorg'd claim at an incorrect claimData index.

@Inphi Inphi requested review from ajsutton and clabby May 13, 2024 17:08
Copy link
Contributor

@clabby clabby left a comment

Choose a reason for hiding this comment

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

Change LGTM. Good to go pending challenger changes.

Also looks like there's some stack too deep issues in the ctb tests to sort.

@codecov
Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.22%. Comparing base (95d39a7) to head (9940317).

Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #10520       +/-   ##
============================================
- Coverage    42.35%   29.22%   -13.13%     
============================================
  Files           73       31       -42     
  Lines         4838     2898     -1940     
  Branches       766      614      -152     
============================================
- Hits          2049      847     -1202     
+ Misses        2681     1976      -705     
+ Partials       108       75       -33     
Flag Coverage Δ
cannon-go-tests ?
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 42 files with indirect coverage changes

Copy link
Contributor

@clabby clabby left a comment

Choose a reason for hiding this comment

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

Needs CTB snapshots

@Inphi Inphi marked this pull request as ready for review May 14, 2024 00:10
@Inphi Inphi requested review from a team as code owners May 14, 2024 00:10
@Inphi Inphi requested review from mds1 and protolambda May 14, 2024 00:10
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 14, 2024

Walkthrough

Walkthrough

The updates focus on enhancing claim handling in dispute games within the op-challenger and packages/contracts-bedrock modules. Key changes include transitioning from ParentIdx to ParentClaim, introducing new versions of contract functions, and aligning interfaces and tests with these modifications. The contract version is incremented to "1.2.0" to ensure improved accuracy and consistency in managing claims during dispute scenarios.

Changes

File Path Change Summary
op-challenger/cmd/move.go Updated Move function to retrieve parentClaim before creating transactions.
op-challenger/game/fault/agent.go Updated logging to use action.ParentClaim.ContractIndex instead of action.ParentIdx.
op-challenger/game/fault/contracts/faultdisputegame.go Modified AttackTx and DefendTx functions to accept types.Claim and context parameters. Added txWithBond function.
op-challenger/game/fault/contracts/faultdisputegame0180.go, faultdisputegame080.go, faultdisputegame111.go Added AttackTx and DefendTx functions for different versions of FaultDisputeGameContract.
op-challenger/game/fault/contracts/faultdisputegame_test.go Updated tests to handle new parentClaim parameter and added version-specific test cases.
op-challenger/game/fault/responder/responder.go Updated GameContract interface and PerformAction method to use ParentClaim and removed GetRequiredBond function.
op-challenger/game/fault/responder/responder_test.go Refactored tests to use ParentClaim instead of ParentIdx.
op-challenger/game/fault/solver/game_solver.go, game_solver_test.go, rules.go Updated methods and validation logic to use ParentClaim instead of ParentIdx.
op-challenger/game/fault/test/game_builder.go Adjusted GameBuilderSeq methods to use ParentClaim.
op-challenger/game/fault/types/actions.go Replaced ParentIdx and ParentPosition with ParentClaim in Action struct.
op-e2e/e2eutils/disputegame/game_helper.go, honest_helper.go, output_game_helper.go Modified Attack and Defend functions to include parentClaim parameter.
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol Updated move, attack, and defend functions to include _disputed parameter and incremented version to "1.2.0".
packages/contracts-bedrock/src/dispute/PermissionedDisputeGame.sol Updated move function to include _disputed parameter and rearranged parameters.
packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol Updated interface functions to include _disputed parameter.
packages/contracts-bedrock/src/dispute/lib/Errors.sol Replaced InvalidClaim() with InvalidDisputedClaimIndex().
packages/contracts-bedrock/test/actors/FaultDisputeActors.sol, dispute/PermissionedDisputeGame.t.sol Updated tests to use disputed claims in function calls.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 515c0c5 and 9940317.
Files ignored due to path filters (5)
  • op-bindings/bindings/faultdisputegame.go is excluded by !op-bindings/bindings/**
  • op-challenger/game/fault/contracts/abis/FaultDisputeGame-1.1.1.json is excluded by !**/*.json
  • 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
Files selected for processing (23)
  • op-challenger/cmd/move.go (1 hunks)
  • op-challenger/game/fault/agent.go (2 hunks)
  • op-challenger/game/fault/contracts/faultdisputegame.go (3 hunks)
  • op-challenger/game/fault/contracts/faultdisputegame0180.go (2 hunks)
  • op-challenger/game/fault/contracts/faultdisputegame080.go (2 hunks)
  • op-challenger/game/fault/contracts/faultdisputegame111.go (1 hunks)
  • op-challenger/game/fault/contracts/faultdisputegame_test.go (5 hunks)
  • op-challenger/game/fault/responder/responder.go (4 hunks)
  • op-challenger/game/fault/responder/responder_test.go (9 hunks)
  • op-challenger/game/fault/solver/game_solver.go (2 hunks)
  • op-challenger/game/fault/solver/game_solver_test.go (4 hunks)
  • op-challenger/game/fault/solver/rules.go (13 hunks)
  • op-challenger/game/fault/test/game_builder.go (2 hunks)
  • op-challenger/game/fault/types/actions.go (1 hunks)
  • op-e2e/e2eutils/disputegame/output_game_helper.go (2 hunks)
  • packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol (3 hunks)
  • packages/contracts-bedrock/src/dispute/PermissionedDisputeGame.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/test/actors/FaultDisputeActors.sol (1 hunks)
  • packages/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol (41 hunks)
  • packages/contracts-bedrock/test/dispute/PermissionedDisputeGame.t.sol (3 hunks)
  • packages/contracts-bedrock/test/invariants/FaultDisputeGame.t.sol (1 hunks)
Files not summarized due to errors (1)
  • packages/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (22)
  • op-challenger/cmd/move.go
  • op-challenger/game/fault/agent.go
  • op-challenger/game/fault/contracts/faultdisputegame.go
  • op-challenger/game/fault/contracts/faultdisputegame0180.go
  • op-challenger/game/fault/contracts/faultdisputegame080.go
  • op-challenger/game/fault/contracts/faultdisputegame111.go
  • op-challenger/game/fault/contracts/faultdisputegame_test.go
  • op-challenger/game/fault/responder/responder.go
  • op-challenger/game/fault/responder/responder_test.go
  • op-challenger/game/fault/solver/game_solver.go
  • op-challenger/game/fault/solver/game_solver_test.go
  • op-challenger/game/fault/solver/rules.go
  • op-challenger/game/fault/test/game_builder.go
  • op-challenger/game/fault/types/actions.go
  • op-e2e/e2eutils/disputegame/output_game_helper.go
  • packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
  • packages/contracts-bedrock/src/dispute/PermissionedDisputeGame.sol
  • packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol
  • packages/contracts-bedrock/src/dispute/lib/Errors.sol
  • packages/contracts-bedrock/test/actors/FaultDisputeActors.sol
  • packages/contracts-bedrock/test/dispute/PermissionedDisputeGame.t.sol
  • packages/contracts-bedrock/test/invariants/FaultDisputeGame.t.sol
Additional comments not posted (10)
packages/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol (10)

361-364: Ensure the root claim data is correctly retrieved before making the move.


369-371: Ensure the root claim data is correctly retrieved before attempting to defend the root claim.


381-385: Ensure the non-existent parent claim is correctly handled to trigger the expected revert.


396-403: Ensure the maximum game depth is correctly handled to trigger the expected revert.


414-416: Ensure the clock time is correctly handled to trigger the expected revert.


Line range hint 428-454: Ensure the chess clock incrementation is correctly tested and validated.


Line range hint 473-495: Ensure the clock extension is correctly tested and validated.


507-512: Ensure the duplicate claim handling is correctly tested and validated.


522-533: Ensure the handling of identical claims in different subgames is correctly tested and validated.


547-548: Ensure the opening attack is correctly tested and validated.


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.

@Inphi Inphi requested review from ajsutton and clabby May 14, 2024 00:11
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: 2

@Inphi Inphi force-pushed the inphi/fdg-safe branch from 0e0fb00 to 9940317 Compare May 14, 2024 15:33
@Inphi Inphi disabled auto-merge May 14, 2024 15:48
@clabby clabby added this pull request to the merge queue May 14, 2024
Merged via the queue into develop with commit 78e1084 May 14, 2024
@clabby clabby deleted the inphi/fdg-safe branch May 14, 2024 16:40
clabby pushed a commit that referenced this pull request May 14, 2024
* dispute-game: Sanity check disputed claim index

* Fix tests

* update snapshots

* fix docs

* move param

* op-challenger: Supply parent value when performing moves

Also moves calculation of the required bond into the contract bindings so the returned TxCandidate is ready to send.

* op-challenger: Add backwards compatibility with v1.1.1

* op-e2e: Update e2e for new FaultDisputeGame ABI

---------

Co-authored-by: Adrian Sutton <adrian@oplabs.co>
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.

3 participants