fix(tholos): verify balance deltas for incoming token transfers (#164) - #181
Closed
xtep103 wants to merge 1 commit into
Closed
fix(tholos): verify balance deltas for incoming token transfers (#164)#181xtep103 wants to merge 1 commit into
xtep103 wants to merge 1 commit into
Conversation
Contributor
Author
|
Closing duplicate PR in favor of #180, which has been updated with the clean, verified commit history and full test suite. |
Collaborator
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.
Overview
Verifies balance deltas for incoming token transfers during assertion creation (
assert_outcome) and disputes (dispute) incontracts/tholos, recording actual received tokens and protectingresolveandfinalizepayouts against deadlocks caused by fee-on-transfer tokens.Related Issue
Closes #164
Changes
contracts/tholos
contracts/tholos/src/lib.rsassert_outcomeanddispute.assertion.bondin persistent storage. Rejects zero/negative received amounts withError::InvalidBondAmount.finalize(assertion.bond.min(contract_balance)) andresolve((assertion.bond.saturating_mul(2)).min(contract_balance)) to prevent transfer failure panics when contract balances are constrained by transfer deductions.contracts/tholos/src/test.rsFeeTokentest fixture simulating configurable fee-on-transfer mechanics.test_fee_on_transfer_token_dispute_resolves_without_deadlockconfirming assertions with fee tokens can be disputed and resolved without balance underflow.test_fee_on_transfer_token_finalize_resolves_without_deadlockconfirming undisputed assertions with fee tokens finalize successfully.test_zero_received_transfer_rejectedensuring 100% fee transfers that deliver 0 tokens are rejected.Verification Results
assert_outcome&disputeError::InvalidBondAmountresolve/finalizeclamped to available balance to prevent deadlock