Skip to content

feat(lore-0021): add the testnet token matrix and test-token events - #63

Open
karczuRF wants to merge 3 commits into
developfrom
lore-0021-testnet-token-matrix
Open

karczuRF wants to merge 3 commits into
developfrom
lore-0021-testnet-token-matrix

Conversation

@karczuRF

Copy link
Copy Markdown
Collaborator

Summary

Task 0021, M1 Story 1.7: evidence that a seller can charge in any SEP-41 token, not only USDC. One exact payment in testnet USDC, a self-issued SAC and a non-SAC SEP-41 token each verifies and settles through the facilitator on testnet, with the facilitator paying every fee, and a concurrent batch lands in one ledger through several channels.

  • Token matrix script (apps/facilitator/scripts/token-matrix.ts): a facilitator from main() with 4 new channels and a new seller. Each token goes through the same pay(asset) (/verify, /settle, the transaction read back from the chain, the seller's balance), with only asset changing; then 6 test-token payments go to /settle at once. The buyer is 0004's e2e client, which holds testnet USDC (only Circle's faucet hands it out).
  • Results (apps/facilitator/scripts/results/token-matrix-testnet.json): every hash, ledger, channel and fee, the buyer's XLM and sequence number before and after, and the checks. Addresses only.
  • Test token events (contracts/test-token): transfer, approve and mint now publish their SEP-41 events. Deployed with deploy/scripts/deploy-contract.sh test-token at CBFIYRHJG4C4E4AU3K5XCCMSZKZR3IMVFPCKNAJ3OBRQCHDLPCT3GV53 (WASM d3108f81…3d31); 0004's upto e2e deploys through the same script, so its next run picks up the new ID.
  • Follow-up 0066 (backlog): what /verify does when a payment must restore archived state.

Please note

  1. 0004's test token emitted no events, so it couldn't be paid in through exact. Upstream's verifier reads the simulated SEP-41 transfer event and answered invalid_exact_stellar_payload_no_transfer_events. 0004's upto path never reads events, so nobody saw it. A Rust test now checks the literal topics and data the verifier reads.
  2. Archived state can push a valid payment over MAX_FEE_STROOPS. Since Protocol 23 a transaction restores the archived entries it touches and pays their rent. 0004's UPTOE2E SAC instance and the buyer's old test-token balance were archived, which made the buyer's transaction cost 551,787 and 342,189 stroops of resource fee against the 250,000 cap, so /verify answered fee_exceeds_maximum. The script restores such entries from the facilitator account before paying, the same way for every token; what the facilitator itself should do is 0066.
  3. The test-token settlement costs about 152,600 stroops, mostly the rent of the seller's new balance entry, against about 12,000 for the two SACs, whose sellers hold trustlines. It stays under the cap.

Testing

  • pnpm format:check (flags only untracked local files), pnpm lint, pnpm typecheck, pnpm test, pnpm build pass; pnpm contracts:lint, pnpm contracts:test (test-token 1, upto-proxy 42) and pnpm contracts:test:wasm pass. The event test fails when transfer is switched to map data.
  • Testnet, cd apps/facilitator && CLIENT_SECRET=… npx tsx scripts/token-matrix.ts, the committed run (2026-10-23 14:16 UTC), every check true:
    • USDC, the self-issued SAC and the test token verified and settled in ledgers 5348278, 5348281 and 5348283, the facilitator the fee source of each;
    • 4 of 6 batch payments in ledger 5348285 through 4 different channels, the other 2 in 5348286;
    • the buyer's XLM (9,999.99998) and sequence number unchanged.
  • Two earlier runs passed too; one attempt failed on testnet's RPC ("setting ContractComputeV0 is not present in the snapshot", after testnet moved to protocol 29) and the rerun passed.

The test token moved storage without events, so upstream's exact
verifier, which reads the simulated SEP-41 transfer event, refused
every payment in it with no_transfer_events. transfer, approve and
mint now publish their SEP-41 events, and a test checks the literal
topics and data the verifier reads.
One exact payment each in testnet USDC, a self-issued SAC and the
non-SAC test token goes through /verify and /settle of a facilitator
built by main(), with only the asset changing, then a concurrent
batch across four channels. The script restores archived state from
the facilitator account first and commits its results with every
transaction hash.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant