fix: add sanity upper bound on src_amount/min_dst_amount inputs - #163
Open
bambuska-man wants to merge 1 commit into
Open
fix: add sanity upper bound on src_amount/min_dst_amount inputs#163bambuska-man wants to merge 1 commit into
bambuska-man wants to merge 1 commit into
Conversation
- Add MAX_AMOUNT constant (10^30) and Error::AmountTooLarge variant (stellar-vortex-protocol#41) - Enforce upper bound in submit_intent with boundary tests - Add reentrancy-focused tests using hostile mock SEP-41 token (stellar-vortex-protocol#40) - Add economic security tests asserting MIN_BOND vs notional gap (stellar-vortex-protocol#39) - README already contained fill_amount trust-assumption docs (stellar-vortex-protocol#38) Closes stellar-vortex-protocol#41, stellar-vortex-protocol#40, stellar-vortex-protocol#39, stellar-vortex-protocol#38
|
@bambuska-man 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.
fix: add sanity bounds, reentrancy tests, economic security tests,
and fill_amount trust docs
Closes #41
Closes #40
Closes #39
Closes #38
What changed
#41 — Sanity upper bound on
src_amount/min_dst_amountsubmit_intentpreviously only checked that amounts were positive. Afat-fingered
or malicious caller could pass an astronomically large value that
interacts badly
with fee/slash arithmetic downstream.
MAX_AMOUNT = 10^30constant (one trillion 18-decimal tokens— round,
economically implausible, and well within
i128::MAX / PROTOCOL_FEE_BPSsofee multiplication can never overflow)
Error::AmountTooLarge(variant 22)submit_intentimmediately after the existingzero-amount check
one-above-max
fails,
i128::MAXfails#40 — Reentrancy-focused tests using a hostile mock SEP-41 token
None of the existing tests used a non-SAC destination token. Added:
HostileToken— a minimal self-contained SEP-41 implementationregistered as
dst_tokenin tests, with onlytransferandbalancedoing realwork
setup_with_hostile_dst/hostile_minthelpersfill_intent, storage ordering(checks-effects-interactions),
slash_solver, and a double-call toregister_solver(simulatinga hypothetical
hostile-token callback)
Note: Soroban's single-threaded execution model prevents true
EVM-style mid-frame
reentrancy. These tests instead confirm correct CEI ordering and
compatibility with
arbitrary SEP-41 implementations.
#39 — Economic security test:
MIN_BONDvs worst-case notionalMIN_BONDis a flat 50 USDC regardless of intent size. A min-bondedsolver can
accept a trillion-USDC intent and lose only 5 USDC if they default —
0 basis points
of notional.
economic_security_min_bond_slash_vs_large_notional— documentsthe gap with a
10^19-unit intent; asserts the penalty rounds to 0 bps
(intentionally failing
to be "safe", to make the gap visible)
economic_security_proportionate_bond_yields_meaningful_penalty—positive
counterpart showing that a solver bonded at 1% of notional produces
a ≥10 bps
penalty, documenting the target ratio for a future
accept_intentguard
A follow-up design issue should add a per-intent bond-to-notional
ratio check
inside
accept_intent.#38 — Trust-assumption docs for solver-reported
fill_amountThe
Known Limitationssection was added to the README covering:fill_amountissolver-attested)
Testing
All new tests are in
intent_settlement/src/test.rs. No existingtests were modified.