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(op-dispute-mon): L2BlockNumberChallenged Support #10451

Merged
merged 4 commits into from May 11, 2024

Conversation

refcell
Copy link
Contributor

@refcell refcell commented May 8, 2024

Description

Updates the op-dispute-mon to support L2 Block Number challenging. On game extraction, the dispute monitor now queries the FaultDisputeGame contract if the L2 Block Number has been challenged and hydrates a new field in the EnrichedGameData that downstream monitor components can read. The Forecast component has been updated as well to record games as AgreeChallengerWins if the game's L2 Block Number has been challenged successfully, ignoring all other claim status.

Metadata

Fixes https://github.com/ethereum-optimism/client-pod/issues/853

Copy link
Contributor Author

refcell commented May 8, 2024

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

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

@refcell refcell changed the title feat(op-dispute-mon): L2BlockNumberChallenged dispute monitor support feat(op-dispute-mon): L2BlockNumberChallenged Support May 8, 2024
@refcell refcell requested review from ajsutton and Inphi May 8, 2024 15:44
@refcell refcell marked this pull request as ready for review May 8, 2024 15:44
@refcell refcell requested a review from a team as a code owner May 8, 2024 15:44
Copy link
Contributor

coderabbitai bot commented May 8, 2024

Walkthrough

Walkthrough

The recent updates across various components focus on integrating a new boolean field, blockNumChallenged, to track if a block number is challenged. This affects functions primarily related to game metadata retrieval and processing in the system, enhancing the monitoring and forecasting capabilities regarding disputed block numbers in games.

Changes

File Path Change Summary
op-challenger/cmd/list_games.go Added blockNumChallenged field in gameInfo struct and updated variable assignments in listGames function.
op-challenger/game/fault/contracts/*.go Updated GetGameMetadata function across multiple files to include a new boolean return value indicating if the block number is challenged.
op-dispute-mon/mon/extract/caller.go, op-dispute-mon/mon/extract/extractor.go Added handling and storage for the new blockNumChallenged field in game data processing and struct definitions.
op-dispute-mon/mon/forecast.go Added conditional block in forecastGame method to handle games with challenged block numbers and update metrics.
op-challenger/game/fault/contracts/faultdisputegame_test.go Modified test to include new blockNumChallenged variable and added corresponding assertion.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 6c0bf44 and a3840f3.
Files selected for processing (23)
  • op-challenger/cmd/list_games.go (1 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 (3 hunks)
  • op-challenger/game/fault/contracts/faultdisputegame_test.go (1 hunks)
  • op-dispute-mon/metrics/metrics.go (4 hunks)
  • op-dispute-mon/metrics/noop.go (2 hunks)
  • op-dispute-mon/mon/bonds/monitor.go (1 hunks)
  • op-dispute-mon/mon/bonds/monitor_test.go (16 hunks)
  • op-dispute-mon/mon/extract/bond_enricher.go (1 hunks)
  • op-dispute-mon/mon/extract/caller.go (1 hunks)
  • op-dispute-mon/mon/extract/extractor.go (2 hunks)
  • op-dispute-mon/mon/extract/extractor_test.go (2 hunks)
  • op-dispute-mon/mon/extract/recipient_enricher.go (1 hunks)
  • op-dispute-mon/mon/extract/recipient_enricher_test.go (2 hunks)
  • op-dispute-mon/mon/forecast.go (1 hunks)
  • op-dispute-mon/mon/forecast_test.go (1 hunks)
  • op-dispute-mon/mon/l2_challenges.go (1 hunks)
  • op-dispute-mon/mon/l2_challenges_test.go (1 hunks)
  • op-dispute-mon/mon/monitor.go (5 hunks)
  • op-dispute-mon/mon/monitor_test.go (10 hunks)
  • op-dispute-mon/mon/service.go (3 hunks)
  • op-dispute-mon/mon/types/types.go (1 hunks)
Files skipped from review as they are similar to previous changes (8)
  • op-challenger/cmd/list_games.go
  • op-challenger/game/fault/contracts/faultdisputegame0180.go
  • op-challenger/game/fault/contracts/faultdisputegame080.go
  • op-challenger/game/fault/contracts/faultdisputegame_test.go
  • op-dispute-mon/metrics/noop.go
  • op-dispute-mon/mon/extract/extractor.go
  • op-dispute-mon/mon/forecast.go
  • op-dispute-mon/mon/forecast_test.go
Additional comments not posted (22)
op-dispute-mon/mon/extract/recipient_enricher_test.go (1)

Line range hint 15-24: The test effectively verifies the addition of BlockNumberChallenger to the Recipients map. Good coverage for the new functionality.

op-dispute-mon/mon/extract/recipient_enricher.go (1)

28-30: Correctly adds BlockNumberChallenger to Recipients if it's a valid address. Ensures that only meaningful data is stored.

op-dispute-mon/mon/extract/bond_enricher.go (1)

30-36: Properly handles discrepancies in the number of credits received versus requested, enhancing data integrity.

op-dispute-mon/mon/l2_challenges.go (1)

24-42: Effectively monitors and logs details of L2 block number challenges, with appropriate logging levels based on the challenge agreement status.

op-dispute-mon/mon/types/types.go (1)

20-28: The additions to EnrichedGameData are well-structured and crucial for supporting L2 block number challenges.

op-dispute-mon/mon/extract/caller.go (1)

28-28: Simplifies the fetching of game metadata, enhancing the interface's usability.

op-dispute-mon/mon/l2_challenges_test.go (1)

14-49: Thoroughly tests the logging and metrics recording functionality of L2ChallengesMonitor for both agreed and disagreed block number challenges.

op-dispute-mon/mon/bonds/monitor.go (1)

62-65: Correctly handles the payment of bonds to the block number challenger if the root claim is challenged, ensuring accurate handling of disputed games.

op-dispute-mon/mon/monitor.go (3)

43-45: Addition of l2Challenges field to gameMonitor struct.

This change aligns with the PR's objective to enhance L2 block number challenge monitoring.


61-63: Addition of l2Challenges parameter in newGameMonitor function.

This ensures that the L2 challenges monitoring functionality is properly initialized.


109-109: Integration of L2 challenges monitoring in the monitorGames method.

This addition is crucial for the new functionality to monitor L2 block number challenges as described in the PR.

op-dispute-mon/mon/monitor_test.go (4)

28-28: Addition of a test case for handling failures in fetching the block number.

This test ensures robust error handling for the block number fetching process.


38-38: Addition of a test case for handling failures in fetching the block hash.

This test is important for verifying that errors during block hash retrieval are handled correctly.


Line range hint 48-57: Addition of a test case for monitoring scenarios where no games are present, including a check for L2 challenges calls.

This test is crucial for ensuring that the system behaves correctly even when no games are available to monitor.


Line range hint 61-70: Addition of a test case for monitoring multiple games, including a check for L2 challenges calls.

This test ensures that the monitoring system can handle multiple games simultaneously and correctly processes L2 challenges.

op-dispute-mon/mon/service.go (1)

Line range hint 216-229: Integration of the L2 challenges monitor in the initMonitor function.

This change properly sets up the L2 challenges monitoring as part of the service initialization, aligning with the PR's objectives.

op-dispute-mon/mon/extract/extractor_test.go (1)

156-156: Addition of the verifyLogs function to check the correctness of logged errors during extraction.

This function is crucial for ensuring that the logging of errors in the extraction process is verified, which helps maintain the robustness of error handling.

op-dispute-mon/mon/bonds/monitor_test.go (1)

Line range hint 60-296: Addition of comprehensive tests for checking recipient credits in various game scenarios, including those with L2 block number challenges.

These tests are essential for ensuring that the bond monitoring logic correctly handles different game conditions and L2 challenges, aligning with the PR's objectives to enhance monitoring capabilities.

op-dispute-mon/metrics/metrics.go (2)

135-136: LGTM! The addition of RecordL2Challenges aligns with the PR's objectives to enhance L2 challenge monitoring.


Line range hint 174-323: LGTM! The l2Challenges metric is well-defined and necessary for monitoring L2 block number challenges effectively.

op-challenger/game/fault/contracts/faultdisputegame.go (2)

166-174: LGTM! The GameMetadata struct is well-defined and improves the structure of game data handling.


176-212: LGTM! The updated GetGameMetadata function correctly uses the new GameMetadata struct and handles errors appropriately.


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.

@refcell refcell self-assigned this May 8, 2024
@refcell refcell added C-feature Category: features A-op-dispute-mon Area: op-dispute-mon related labels May 8, 2024
@refcell refcell force-pushed the refcell/l2-block-number-challenge-support branch from a4a64c1 to 835921f Compare May 8, 2024 16:03
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: 3

op-challenger/cmd/list_games.go Outdated Show resolved Hide resolved
op-challenger/game/fault/contracts/faultdisputegame080.go Outdated Show resolved Hide resolved
op-challenger/game/fault/contracts/faultdisputegame.go Outdated Show resolved Hide resolved
@refcell refcell force-pushed the refcell/l2-block-number-challenge-support branch from 8a3c79f to 67e0edf Compare May 8, 2024 22:28
@Inphi
Copy link
Contributor

Inphi commented May 9, 2024

dispute-mon shouldn't trust the contract for l2 block disputes to be robust against contract exploits.
Same deal as Output root agreement, if dispute-mon observes an invalid put effective l2 block dispute, then it should yell loudly.

@refcell
Copy link
Contributor Author

refcell commented May 9, 2024

dispute-mon shouldn't trust the contract for l2 block disputes to be robust against contract exploits. Same deal as Output root agreement, if dispute-mon observes an invalid put effective l2 block dispute, then it should yell loudly.

This is correct but is a different follow up metric to this pr - the dispute mon should extract the block number challenge from the game and then forecast the result properly. Then it should also have a metric to validate the l2 block number challenge and yell loudly. Though, the way our contracts are set up now - if an invalid l2 block number challenge succeeds, the game will resolve incorrectly regardless as I understand it.

feat(op-dispute-mon): query for the l2 block number through the game metadata call

fix(op-dispute-mon): query for the l2 block number through the game metadata call

fix(op-dispute-mon): query for the l2 block number through the game metadata call
@refcell refcell force-pushed the refcell/l2-block-number-challenge-support branch from 5404c20 to b837cc4 Compare May 9, 2024 16:57
@refcell refcell requested a review from ajsutton May 9, 2024 17:14
@Inphi
Copy link
Contributor

Inphi commented May 9, 2024

dispute-mon shouldn't trust the contract for l2 block disputes to be robust against contract exploits. Same deal as Output root agreement, if dispute-mon observes an invalid put effective l2 block dispute, then it should yell loudly.

This is correct but is a different follow up metric to this pr - the dispute mon should extract the block number challenge from the game and then forecast the result properly. Then it should also have a metric to validate the l2 block number challenge and yell loudly. Though, the way our contracts are set up now - if an invalid l2 block number challenge succeeds, the game will resolve incorrectly regardless as I understand it.

Gotcha. I just realized that dispute-mon already checks the claimed L2 block number against the claimed output. That is the check I wanted to ensure was happening.

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.

LGTM!

@refcell
Copy link
Contributor Author

refcell commented May 9, 2024

dispute-mon shouldn't trust the contract for l2 block disputes to be robust against contract exploits. Same deal as Output root agreement, if dispute-mon observes an invalid put effective l2 block dispute, then it should yell loudly.

This is correct but is a different follow up metric to this pr - the dispute mon should extract the block number challenge from the game and then forecast the result properly. Then it should also have a metric to validate the l2 block number challenge and yell loudly. Though, the way our contracts are set up now - if an invalid l2 block number challenge succeeds, the game will resolve incorrectly regardless as I understand it.

Gotcha. I just realized that dispute-mon already checks the claimed L2 block number against the claimed output. That is the check I wanted to ensure was happening.

You were correct - we were able to do this easily since @ajsutton's recent PRs added this agreement hydration to the enriched game object with nice concurrency 😄

op-challenger/game/fault/contracts/faultdisputegame.go Outdated Show resolved Hide resolved
op-dispute-mon/metrics/metrics.go Outdated Show resolved Hide resolved
op-dispute-mon/mon/forecast.go Outdated Show resolved Hide resolved
@ajsutton
Copy link
Contributor

Implemented my suggested changes in #10483

@refcell
Copy link
Contributor Author

refcell commented May 10, 2024

Implemented my suggested changes in #10483

Reviewed, I do like the change to pull the status out into a separate metric, though I don't think we should leave the incorrect forecast ambiguous and explicitly create an alert if op_dispute_mon_l2_challenge{agreement="true", namespace="op-dispute-mon"} > 0. That way the investigator is immediately aware of the issue. It'll be a minor change to this pr and one additional alert in k8s, but to me that clarity is worth the small additional code.

* op-dispute-mon: Consider l2 block number challenged when forecasting but don't make it a new game status.

Add a separate metric to report the number of successful L2 block number challenges.

* op-challenger: Remove unused blockNumChallenged field from list-games info struct

* op-dispute-mon: Consider l2 block challenger in expected credits. (#10484)

* feat(op-dispute-mon): Update L2 Challenges Metrics (#10492)

* fix: change the l2 challenges to tha gauge vec

* fix: consistent metric labels

---------

Co-authored-by: refcell <abigger87@gmail.com>
@refcell refcell enabled auto-merge May 11, 2024 08:24
@refcell refcell added this pull request to the merge queue May 11, 2024
Merged via the queue into develop with commit bde6a96 May 11, 2024
69 checks passed
@refcell refcell deleted the refcell/l2-block-number-challenge-support branch May 11, 2024 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-op-dispute-mon Area: op-dispute-mon related C-feature Category: features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants