optimism icon indicating copy to clipboard operation
optimism copied to clipboard

feat(ctb): FDG bond safety mode

Open clabby opened this issue 1 year ago • 4 comments

Overview

Adds a safety mode to the FaultDisputeGame that can be triggered by the SuperchainConfig's guardian role. This mode will return all bonds back to their submitters when claimCredit is called. This is intended to mitigate situations where the honest challenger is playing a very high-stakes dispute game, and there is risk of losing a massive amount of money due to a bug in the system.

Semantic Changes

  • A new function, enableSafetyMode, has been added. This function may only be called by the Guardian.
    • This function toggles the safetyMode flag.
  • When claimCredit is called:
    • If safetyMode is false, the _recipient's credit is distributed to them.
    • If safetyMode is true, the _recipient's bonds are returned to them.

Open Questions

  • The Guardian role is slow-moving, and requires multisig signers to gather. Do we want a new role for this action?
  • What should the BOND_PAYOUT_DELAY be?
  • The safety mode flag is currently per-game. This should likely live in another contract so that it may be set globally?

TODO

  • [ ] Have the op-challenger wait the BOND_PAYOUT_DELAY after a game has resolved to claim their bonds.

clabby avatar Feb 17 '24 16:02 clabby

Current dependencies on/for this PR:

  • #9591 Graphite 👈
  • develop

This stack of pull requests is managed by Graphite.

clabby avatar Feb 17 '24 16:02 clabby

Codecov Report

Attention: 13 lines in your changes are missing coverage. Please review.

Comparison is base (100ec14) 28.96% compared to head (9d57158) 16.47%. Report is 7 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #9591       +/-   ##
============================================
- Coverage    28.96%   16.47%   -12.50%     
============================================
  Files          161      119       -42     
  Lines         7046     5130     -1916     
  Branches      1287     1138      -149     
============================================
- Hits          2041      845     -1196     
+ Misses        4899     4210      -689     
+ Partials       106       75       -31     
Flag Coverage Δ
cannon-go-tests ?
chain-mon-tests 27.14% <ø> (ø)
common-ts-tests ?
contracts-bedrock-tests 0.64% <0.00%> (-0.01%) :arrow_down:
contracts-ts-tests 12.25% <ø> (ø)
core-utils-tests ?
sdk-next-tests 41.53% <ø> (ø)
sdk-tests 41.53% <ø> (ø)

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

Files Coverage Δ
...ts-bedrock/src/dispute/PermissionedDisputeGame.sol 0.00% <ø> (ø)
...ages/contracts-bedrock/src/L1/SuperchainConfig.sol 0.00% <0.00%> (ø)
...contracts-bedrock/src/dispute/FaultDisputeGame.sol 0.00% <0.00%> (ø)

... and 42 files with indirect coverage changes

codecov[bot] avatar Feb 17 '24 16:02 codecov[bot]

Walkthrough

Walkthrough

The recent updates focus on integrating the SuperchainConfig across multiple components to enhance system flexibility and security. These changes introduce a new BOND_PAYOUT_DELAY constant, a bonds mapping, and a safetyMode flag. The enhancements aim to refine dispute resolution mechanisms by incorporating bond payout delays and enabling a safety mode for heightened security measures. The version update to "0.6.0" signifies significant functional improvements.

Changes

Files Summary
Deploy.s.sol Added _superchainConfig initialization with SuperchainConfig.
.../dispute/FaultDisputeGame.sol, .../dispute/PermissionedDisputeGame.sol - Added SuperchainConfig import and declaration.
- Updated constructors to include _superchainConfig.
- Introduced BOND_PAYOUT_DELAY, bonds mapping, safetyMode flag, and updated version to "0.6.0".
- Enhanced dispute resolution with bond payout delay and safety mode features.
- Added tests for the new functionalities.
.../libraries/DisputeErrors.sol Added BondDelayNotExpired and UnauthorizedCaller error types.

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

coderabbitai[bot] avatar Feb 17 '24 17:02 coderabbitai[bot]

What's the status of this PR? Are we still using this approach for safety mode?

Nah, don't think so. Will move into draft for reference in case the other plan doesn't work out.

clabby avatar Feb 22 '24 17:02 clabby