op-challenger: call closeGame() for games with no bonds to claim#18787
Merged
op-challenger: call closeGame() for games with no bonds to claim#18787
Conversation
This fixes an issue where permissioned games don't update the AnchorStateRegistry because the challenger has no bonds to claim. When chains switch from permissioned to permissionless, the anchor state could be too old and can't be proven in time. Changes: - Add CloseGameTx() method to FaultDisputeGameContract interface and all implementations - Older contract versions (080, 0180, 111, 131) return ErrCloseGameNotSupported - Modify Claimer.claimBond() to call closeGame() when: - Game is finalized (not in progress) - No credit to claim - bondDistributionMode is UNDECIDED - Add tests for the new closeGame() behavior Co-Authored-By: Kelvin Fichter <kelvinfichter@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #18787 +/- ##
===========================================
+ Coverage 73.93% 77.63% +3.69%
===========================================
Files 190 135 -55
Lines 11318 7288 -4030
===========================================
- Hits 8368 5658 -2710
+ Misses 2804 1630 -1174
+ Partials 146 0 -146
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
ajsutton
reviewed
Jan 15, 2026
- Skip closeGame() when in selective claim resolution mode - Add GetBondDistributionMode and CloseGameTx to OptimisticZKDisputeGameContract interface - Add tests for GetBondDistributionMode and CloseGameTx in optimisticdisputegame_test.go - Add tests for CloseGameTx in faultdisputegame_test.go including older versions returning ErrCloseGameNotSupported - Pass SelectiveClaimResolution config to Claimer via service.go Co-Authored-By: Kelvin Fichter <kelvinfichter@gmail.com>
ajsutton
reviewed
Jan 15, 2026
op-challenger/game/fault/contracts/optimisticzkdisputegame_test.go
Outdated
Show resolved
Hide resolved
Co-Authored-By: Kelvin Fichter <kelvinfichter@gmail.com>
Refactored ClaimBonds to: - Create contract once per game instead of once per claimant - Track if any claimant had credit > 0 for a game - Only call closeGame once per game if no claimant had credit This avoids wasting resources checking bond distribution mode for every address. Co-Authored-By: Kelvin Fichter <kelvinfichter@gmail.com>
ajsutton
reviewed
Jan 15, 2026
Co-Authored-By: Kelvin Fichter <kelvinfichter@gmail.com>
… addresses Co-Authored-By: Kelvin Fichter <kelvinfichter@gmail.com>
ajsutton
approved these changes
Jan 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue where permissioned games don't update the AnchorStateRegistry because the challenger has no bonds to claim. When chains switch from permissioned to permissionless, the anchor state could be too old and can't be proven in time in cannon.
Changes:
CloseGameTx()method toFaultDisputeGameContractinterface and all implementationsErrCloseGameNotSupportedGetBondDistributionMode()andCloseGameTx()toOptimisticZKDisputeGameContractinterfacecloseGame()once per game when no claimant has creditcloseGame()when running in selective claim resolution mode (--selective-claim-resolution)Updates since last revision
Addressed PR review comments:
selectivefield toClaimerto respect--selective-claim-resolutionCLI optionGetBondDistributionMode()andCloseGameTx()inoptimisticzkdisputegame_test.goCloseGameTx()infaultdisputegame_test.go, including verification that older versions returnErrCloseGameNotSupportedfaultTypes.NormalDistributionModeconstant instead of magic number in testClaimBondsto only attemptcloseGameonce per game (not once per address)claimBondshelper method that only iterates through addresses (claimer.go:75-84)closeGamecall remains inClaimBondsmethod (claimer.go:68-70), not in the helperReview & Testing Checklist for Human
claimBondreturn value semantics inclaimer.go:88-119: Returnstruewhen the game should NOT be closed (credit exists, credit locked, or game in progress). This is counterintuitive - verify all return paths are correct.claimBondshelper inclaimer.go:75-84: Verify it only iterates addresses and returns whether any credit was found.closeGamecall location inclaimer.go:68-70: ConfirmcloseGameis called fromClaimBonds, not from the helper method.bondDistributionMode()andcloseGame()methods on-chain.closeGame()is called and the AnchorStateRegistry is updated.Notes
ErrSimulationFailedandErrCloseGameNotSupported- this is intentional to gracefully handle games that aren't ready to close or use older contract versions.Link to Devin run: https://app.devin.ai/sessions/969d461e83b040838c350e63f2e6b0d4
Requested by: Kelvin Fichter (@smartcontracts)
Last update: 2026-01-15 01:12 ET