Conversation
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.
Follow-up to rust-sdk#2459, where @igamigo noted these checks belong here as well.
Problem
SwapNote::newrejects a self-swap, andPswapNoteBuilder::buildrejects a same-faucet pair, but neither looks at the amounts:Both sides carry value. The note holds the offered asset, and filling it emits a payback carrying the requested one, so a zero requested asset leaves the payback empty and a zero offered asset leaves a note whose consumer pays and receives nothing.
Change
Reject a zero-amount asset on either side in both constructors, with
NoteError::otheralongside the existing checks.For SWAP the assets are
Asset, so the test goes through a smallis_zero_fungiblehelper — a non-fungible asset always carries value. For PSWAP both sides areFungibleAssetand compare directly.PswapNoteStorage::min_fill_stepis left alone: it defaults toAssetAmount::ZEROon purpose, to disable the fill floor.Test plan
swap_note_builder_rejects_a_zero_assetandpswap_note_builder_rejects_a_zero_assetcover both sides of each constructor. Both fail onnext— the firstexpect_errgets anOknote back.All 275
miden-standardslib tests pass, and the workspace builds.