#933 SC-24: Validate player addresses are not identical in create_tournament_escrow - #938
Merged
chinweobtagaz merged 1 commit intoJul 30, 2026
Conversation
…entical in create_tournament_escrow Adds a require!(player1 != player2) check in create_tournament_escrow to prevent a player from creating a tournament escrow against themselves, preventing potential ELO and payout rounding exploits.
|
@ZeePearl56 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Closes #933
Adds a validation check in
create_tournament_escrowto prevent a player from creating a tournament escrow against themselves. Without this check, a user could create a game whereplayer1 == player2, potentially gaming ELO mechanics or exploiting edge cases in payout rounding.Changes
File:
contracts/game_contract/src/lib.rs—create_tournament_escrowfunctionAdded the following check immediately after verifying the game state is
Completedand before the authorization check:Rationale
ContractError::AlreadyJoined(value6) already existed and is semantically appropriate — it is the same error returned byjoin_gamewhenplayer1 == player2.require_auth(), following the fail-fast pattern used elsewhere in the contract. This avoids prompting for authorization on a request that will be rejected.if let Some(ref player2)pattern correctly handles games whereplayer2isNone(single-player games), where address equality is not a concern.Acceptance Criteria
join_gameTesting
All 65 existing tests pass with zero failures after the change: