Add FastCommitManager for optimistic signed commit flow #56
+1,174
−20
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
Introduces an optimistic commit flow that allows the revealing player to submit the committing player's signed commitment along with their own reveal in a single transaction, reducing the number of on-chain transactions needed from 3 to 2.
Changes
DefaultCommitManager
ENGINEandplayerDatavisibility fromprivatetointernalto allow subclass access_getPlayerIndex()helper function to determine player index from address_storeCommitment()helper function to store commitment data (used by FastCommitManager for signed commits)New FastCommitManager Contract
DefaultCommitManagerwith EIP-712 signature verificationrevealMoveWithOtherPlayerSignedCommit()to accept signed commitments from the committing playerplayerSwitchForTurnFlag == 2)New SignedCommitLib Library
SignedCommitstructSignedCommit(bytes32 moveHash,bytes32 battleKey,uint64 turnId)hashSignedCommit()function for struct hashingImplementation Details
revealMoveWithOtherPlayerSignedCommit()with the signaturehttps://claude.ai/code/session_012MZ9EeP4GD7GXEmu1S5xL1