Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ctb): Add new move type to FDG for OR counters #10438

Merged
merged 5 commits into from
May 9, 2024

Conversation

clabby
Copy link
Member

@clabby clabby commented May 7, 2024

Overview

Adds a potential new move type to the FaultDisputeGame that allows for a participant to reveal the preimage of the claimed output root to display to the dispute game that the claimed L2 block number does not match up with the block number that the block header within the output root commits to.

Semantics

The root output can be challenged with the new special move type iff:

  1. The passed OutputRootProof hashes to equal the claimed output root.
  2. The passed Header RLP hashes to equal the block hash within the OutputRootProof above.
  3. The claimed block number in the dispute game does not equal the block number that the output root commits to.

If there is a successful challenge with the new move type, that claim itself is inserted as a special case counter. In resolveClaim, the contract will always consider the creator of the L2 block challenge the winner of the bond. Notably, this only applies for the root claim subgame.

Copy link
Member Author

clabby commented May 7, 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

Copy link

codecov bot commented May 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.22%. Comparing base (671d08b) to head (c8b061c).
Report is 3 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #10438       +/-   ##
============================================
- Coverage    42.31%   29.22%   -13.09%     
============================================
  Files           73       31       -42     
  Lines         4838     2898     -1940     
  Branches       766      614      -152     
============================================
- Hits          2047      847     -1200     
+ Misses        2682     1976      -706     
+ Partials       109       75       -34     
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

@clabby clabby marked this pull request as ready for review May 7, 2024 19:49
@clabby clabby requested a review from a team as a code owner May 7, 2024 19:49
@clabby clabby requested a review from tynes May 7, 2024 19:49
@clabby clabby self-assigned this May 7, 2024
Copy link
Contributor

coderabbitai bot commented May 7, 2024

Walkthrough

Walkthrough

This update involves minor adjustments to gas costs, semantic version updates in the OptimismPortal contracts, and enhancements to error handling in RLP-related libraries. New custom error definitions are introduced, and error handling in RLPReader is improved by replacing require statements with revert statements. Additionally, there are updates to test files and the deployment summary to reflect changes in addresses and error handling.

Changes

Files Change Summary
.../contracts-bedrock/.gas-snapshot, .../OptimismPortal.sol, .../OptimismPortal2.sol Updated gas costs and semantic versions in contracts.
.../rlp/RLPErrors.sol, .../rlp/RLPReader.sol, .../rlp/RLPReader.t.sol, .../trie/MerkleTrie.t.sol Introduced custom error definitions and improved error handling in RLP-related files.
.../test/dispute/FaultDisputeGame.t.sol, .../proofs/utils/DeploymentSummary.sol Updated test files with new imports and address changes.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between a8e6e2c and c8b061c.
Files ignored due to path filters (1)
  • packages/contracts-bedrock/semver-lock.json is excluded by !**/*.json
Files selected for processing (1)
  • packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol

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: 0

Out of diff range and nitpick comments (5)
packages/contracts-bedrock/src/dispute/lib/Errors.sol (5)

48-48: Ensure the error message for InvalidClaim is descriptive enough to aid debugging.


108-108: Ensure the error message for InvalidOutputRootProof is descriptive enough to aid debugging.


111-111: Ensure the error message for InvalidHeaderRLP is descriptive enough to aid debugging.


115-115: Ensure the error message for BlockNumberMatches is descriptive enough to aid debugging.


118-118: Ensure the error message for L2BlockNumberChallenged is descriptive enough to aid debugging.

Copy link
Contributor

@Inphi Inphi left a comment

Choose a reason for hiding this comment

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

This is good. Sorry to ask you to do this, but can we avoid touching claimData or introducing new claims?

The changes to resolution should be minimal; just need to add a check asserting that the root's subgame cannot be resolved if the L2 block number is challenged.

@clabby clabby removed the M-do-not-merge Meta: Do not merge label May 8, 2024
@clabby clabby requested a review from Inphi May 8, 2024 20:08
clabby added 4 commits May 8, 2024 16:54
Adds a potential new move type to the `FaultDisputeGame` that allows for
a participant to reveal the preimage of the claimed output root to
display to the dispute game that the claimed L2 block number does not
match up with the block number that the block header within the output
root commits to.

The root output can be challenged with the new special move type iff:
1. The passed `OutputRootProof` hashes to equal the claimed output root.
1. The passed Header RLP hashes to equal the block hash within the
`OutputRootProof` above.
1. The claimed block number in the dispute game does not equal the block
number that the output root commits to.

If there is a successful challenge with the new move type, that claim
itself is inserted as a special case counter. In `resolveClaim`, the
contract will always consider the creator of the L2 block challenge the
winner of the bond. Notably, this only applies for the root claim
subgame.
* feat(ctb): Transition `RLPReader` to 4byte errors

* semver
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: 0

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

8-8: Consider removing unused imports to clean up the code.


14-16: Ensure that all imported libraries are used within the file to avoid unnecessary dependencies.

Copy link
Contributor

@smartcontracts smartcontracts left a comment

Choose a reason for hiding this comment

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

Looking good, leaving one comment. Personally I would've preferred not to make the RLP changes but they've been made already so whatever. We need to justify any diff that's being made on top of audited code when we go to gov vote, prefer to avoid this sort of stuff if we can.

@clabby clabby enabled auto-merge May 8, 2024 22:22
Copy link
Contributor

@refcell refcell left a comment

Choose a reason for hiding this comment

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

Looks great to me! Nice unit tests as well

@clabby clabby added this pull request to the merge queue May 8, 2024
@clabby clabby removed this pull request from the merge queue due to a manual request May 8, 2024
Copy link
Contributor

@Inphi Inphi left a comment

Choose a reason for hiding this comment

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

Excellent!

@clabby clabby enabled auto-merge May 8, 2024 23:01
@clabby clabby added this pull request to the merge queue May 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 9, 2024
@ajsutton ajsutton added this pull request to the merge queue May 9, 2024
Merged via the queue into develop with commit 93e9d15 May 9, 2024
72 checks passed
@ajsutton ajsutton deleted the cl/ctb/magic-challenge branch May 9, 2024 01:34
clabby added a commit that referenced this pull request May 14, 2024
* feat(ctb): Add new move type to FDG for OR counters

Adds a potential new move type to the `FaultDisputeGame` that allows for
a participant to reveal the preimage of the claimed output root to
display to the dispute game that the claimed L2 block number does not
match up with the block number that the block header within the output
root commits to.

The root output can be challenged with the new special move type iff:
1. The passed `OutputRootProof` hashes to equal the claimed output root.
1. The passed Header RLP hashes to equal the block hash within the
`OutputRootProof` above.
1. The claimed block number in the dispute game does not equal the block
number that the output root commits to.

If there is a successful challenge with the new move type, that claim
itself is inserted as a special case counter. In `resolveClaim`, the
contract will always consider the creator of the L2 block challenge the
winner of the bond. Notably, this only applies for the root claim
subgame.

* feat(ctb): Transition `RLPReader` to 4byte errors (#10439)

* feat(ctb): Transition `RLPReader` to 4byte errors

* semver

* update summary

* portal semver

* extra checks
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.

5 participants