fix(toolkit): support user-owned Zswap inputs in custom contract builder - #2093
alba-press wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…pend CustomContractBuilder treated every EncodedZswapLocalState input as contract-owned (Input::new_contract_owned / SenderEvidence::Contract). When the funding wallet actually owns the coin, use exact nullifier match and InputInfo → WalletState::spend (SenderEvidence::User). Signed-off-by: alba-press <70040824+alba-press@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
e8bd9e6 to
78827da
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8bd9e607f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // EncodedZswapLocalState.inputs carries no ownership discriminator. | ||
| // Prefer the funding wallet's exact coin (nonce+color+value) and the | ||
| // canonical user spend path (WalletState::spend → SenderEvidence::User). |
There was a problem hiding this comment.
Add the required toolkit change file
This changes product-facing send-intent behavior in util/toolkit, but the commit adds no entry under changes/toolkit/added/ or changes/toolkit/changed/, so the fix will be omitted from the toolkit change record. Add a toolkit change file describing support for user-owned shielded inputs.
AGENTS.md reference: AGENTS.md:L195-L201
Useful? React with 👍 / 👎.
Fixes #2092
Summary
CustomContractBuilderpreviously interpreted unmatchedEncodedZswapLocalState.inputsas contract-owned and alwaysconstructed them through
Input::new_contract_owned.That is incorrect when the referenced shielded coin belongs to
the funding wallet.
The builder now resolves an exact funding-wallet coin and uses
the existing canonical wallet spend path:
InputInfo<WalletSeed> -> WalletState::spendwhich produces
SenderEvidence::User.True contract-owned inputs continue using the existing
Input::new_contract_ownedpath.Why
The old path produces commitment/nullifier evidence for
SenderEvidence::Contract, which cannot authenticate auser-owned shielded coin.
Safety
Selection is exact and does not choose another coin merely
because token type/value match.
Existing contract-owned semantics are preserved.
Tests
contract_custom::tests: 14/14 PASS across ledger 8 + 9cargo test -p midnight-node-toolkit --lib:149 passed, 0 failed
Scope is one toolkit builder file only.
No runtime, BEEFY, bridge, or consensus changes.
Made with Cursor