fix(ata): validate token dispatch and existing occupants#84
fix(ata): validate token dispatch and existing occupants#84
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the ATA program’s trust boundary by ensuring chained token operations only dispatch to the canonical token program (wired by the ATA guest), and by tightening idempotent Create so an already-occupied ATA PDA is only accepted if it is a valid canonical token holding for the requested token definition.
Changes:
- Threaded a trusted
token_program_idthrough ATAcreate,transfer, andburn, and validated token definition / holding ownership + decoding before emitting chained token calls. - Strengthened idempotent
Createto reject malformed, foreign-owned, or wrong-definition occupants at the derived ATA PDA. - Added unit + integration tests covering foreign token owners, malformed existing ATA occupants, and burn definition mismatches.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| integration_tests/tests/ata.rs | Adds integration coverage for rejecting foreign-owned token definitions, malformed ATA occupants, foreign-owned sender ATA, and burn definition mismatches. |
| ata/src/validation.rs | Introduces helpers to enforce canonical token-program ownership and decode token definitions/holdings. |
| ata/src/transfer.rs | Uses trusted token_program_id and canonical holding validation instead of deriving dispatch from account owners. |
| ata/src/tests.rs | Extends unit tests to cover foreign-owned/malformed accounts and definition mismatches across create/transfer/burn. |
| ata/src/lib.rs | Registers the new validation module. |
| ata/src/create.rs | Validates canonical token definition and existing ATA occupant correctness for idempotent create. |
| ata/src/burn.rs | Validates canonical token definition + holding, and enforces holding/definition match before chaining burn. |
| ata/methods/guest/src/bin/ata.rs | Wires ATA dispatch to the canonical token program ID via token_methods::TOKEN_ID. |
| ata/methods/guest/Cargo.toml | Adds a dependency on token-methods to access the canonical token program ID. |
| ata/methods/guest/Cargo.lock | Records the new token-methods dependency resolution. |
| ata/core/src/lib.rs | Updates documentation to reflect canonical guest-wired token dispatch (no longer account-owner-derived). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| risc0-zkvm = { version = "=3.0.5", default-features = false } | ||
| ata_core = { path = "../../core" } | ||
| ata_program = { path = "../..", package = "ata_program" } | ||
| token-methods = { path = "../../../token/methods" } |
|
This should not be merged yet. I am researching on a proper solution (actually a proposal/feature request for LEZ), which would not require hardcoding programid, because this limitation causes a lot of problems down the road for the future of this ecossystem. |
Closes #83
Summary
This PR makes ATA token operations dispatch only to the canonical token program and tightens idempotent
Createhandling for already occupied ATA PDAs.ATA now receives the trusted token program ID from guest wiring instead of deriving downstream token dispatch from caller-supplied account metadata. Existing ATA occupants are accepted as idempotent only when they are canonical token holdings for the requested token definition.
Changes
token_methods::TOKEN_IDwithout adding a caller-supplied instruction argument or changing the ATA IDL.Createreject malformed, foreign-owned, or wrong-definition ATA PDA occupants.Burnreject foreign-owned token definitions and holder/definition mismatches before forwarding the burn.Validation
The following checks passed: