Skip to content

verify 0.16.0: desk orders held to their signed 0x quotes - #89

Merged
kurokawasato merged 5 commits into
mainfrom
verify-desk-order
Nov 28, 2026
Merged

kurokawasato merged 5 commits into
mainfrom
verify-desk-order

Conversation

@kurokawasato

Copy link
Copy Markdown
Contributor

desk-order <tx> re-checks an order a BrainChain desk sent on Robinhood Chain against the 0x quote it was sent on: the quote record is the one the order carries, 0x signed it for this order, the order handed 0x the quote's calldata byte for byte, and the mandate spent and received what the quote said. --quote <file|url> takes the record directly, for regions the desk log refuses.

Quotes asked for with txOrigin, as every desk quote is, now verify: a QuoteIntent may name txOrigin, and 0x's signature is still checked over the query exactly as sent.

Live run on the 26 Nov SPY order (0x4829f77f…869f): 23 of 23 checks pass, verdict match. Tests: 262 pass.

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Jev did not accept the review of 4919321, so it is not posted and the payment is being refunded. The review of a2fa0f4 is below.

BrainChain review

Findings

  1. tools/verify-decision/src/cli.ts line 226–227: desk-order is not guaranteed to terminate before the --quote check or the generic parser. checkDeskOrder() is declared Promise<never> and every path ends in exit(status), so this works only if exit really never returns and fail/usage are typed never. I did not see their definitions. If exit is a thin wrapper that sets process.exitCode, flow falls through to usage("--quote goes with desk-order"), and a successful run then fails. Fix: await checkDeskOrder(); return;, or confirm that exit calls process.exit.

  2. cli.ts lines 720–727: r is read after a try/catch that may not leave scope. TypeScript accepts r as definitely assigned only if failWith returns never. If it does not, r is undefined at line 728 and the tool throws a TypeError. I did not see failWith; check that it is typed never.

  3. cli.ts line 723: fail(..., 2) is thrown inside the try. If fail throws rather than exiting, catch passes it to failWith. That can turn the exit-2 chain mismatch into exit 1, which contradicts the README's exit-2 row for "an RPC that serves another chain". Move the chain-id check outside the try.

  4. cli.ts lines 741–742: the summary hard-codes 6 decimals for USDG and calls BigInt(...) on report strings. This is fine if the order really trades USDG. It also assumes amountOut is a decimal string. The decimals shown for the other token come from the token's own answer, so a token that returns a bad decimals only changes the display. I did not see how desks.ts fills these fields.

  5. desks.ts lines 113–121: the first Order event from the mandate is used with no check on the number of matches. One transaction could emit several. This is unlikely given the mandate's design, but I did not see the contract. Cross-check the event against the decoded call's desk, token, buy, amountIn and quote, or require exactly one Order event.

  6. desks.ts lines 101–104: the Promise.all plus .catch only translates not-found errors. A pending transaction has a transaction object but no receipt, and the receipt error is mapped to "has no transaction". This message is misleading. Fix: say "not mined yet".

The diff is cut at line 124, so the quote checks, calldata comparison and registry reads were not reviewed.


Reviewed through BrainChain. Jev, a decision model from TypeSafe, hired the model and accepted this review, so the model earns 0.97 USDG. Paid 1 USDG on Robinhood Chain; see task 140. Reviewed at a2fa0f4.

@kurokawasato
kurokawasato merged commit bded053 into main Nov 28, 2026
5 checks passed
@kurokawasato
kurokawasato deleted the verify-desk-order branch November 28, 2026 12:51
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.

3 participants