Step 8: ICP and ICRC accounts #9
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.57) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #9"
general
weight: 0.35
b3hr4d
<!-- claude-projects-attribution: {"github_login":"b3hr4d"} -->
_Requested by Behrad · project thread_
Before: the wallet had no accounts.
accounts,add_accountandbalancedid not exist, and aTransferproposal was refused.After: an owner adds ICP and ICRC accounts, every member lists them and reads their balances from the ledgers, and
Transferactions send tokens, at most once each. A transfer that keeps its chain's spending over the last 24 hours within the daily limit is released at once.Accounts. An account is an ICRC-1 account of the wallet's own principal. Index
nof a chain is subaccountnas 32 big-endian bytes, so index 0 is the plain principal and the address of index 1 ends in.1, as you chose on 2026-10-21 (recorded asdocs/decisions/0002-subaccounts.md). Adding one needs no approval, since it moves nothing, and a wallet has at most 64. The wallet reaches the ICP ledger through its ICRC-1 interface, and anIcrcchain may not name it, so ICP tokens have one daily limit. Bitcoin and EVM accounts are refused for now.At most once. Each
executeof a transfer makes one bounded-waiticrc1_transfer, and a secondexecutewhile it is in flight is refused. The call carries acreated_at_time. When the wallet cannot tell whether a call ran (it timed out, its answer does not decode, or the wallet's code after it trapped, which a drop guard records), the nextexecutereuses that time, so the ledger answers with the earlier block;Duplicatecounts as sent. Ledgers find a repeated transfer for 24 hours, so such an action stays open that long and cannot be rejected. Only a reject by the IC before the ledger ran the call (SysFatal,SysTransient,DestinationInvalid) counts as not run; a reject from the ledger itself, a stopped ledger's included, may follow a committed transfer, so it counts as unknown (Codex's finding). A refusal (too little in the account, a wrong fee) ends the actionFailed, unless an earlier call may have run: a ledger checks the fee before it looks for a repeat, so then the action stays ready (Codex's finding).Daily limit. A chain's spending is what it sent in the last 24 hours plus what its open transfers under the limit may still send, so several small proposals cannot pass the limit together.
executechecks the limit again, so a lowered limit stops a transfer proposed under the old one. Under a Transfer rule of one approval and no timelock, as in the default policy, the limit changes nothing.How:
accounts.rs(accounts and their addresses),transfers.rs(checks, the ledger argument, reading the answer) and the attempt state inactions.rsare pure;ledger.rsmakes the calls;lib.rsaddsaccounts,add_account,balanceand the transfer branch ofexecute. Sent transfers go to memory 6, which the daily limit reads; accounts to memory 3, both asdocs/design.mdplanned. Memory 11 is a transfer clock: every fresh ledger call gets acreated_at_timeno other call has, so two identical transfers executed in one round are both sent (Codex's finding).Worth your review
AuditEventgainsAccountAdded : AccountId, one entry peradd_account.Pending.expires_at_nscan now be later than its window, for a transfer whose call may have run.icrc-ledger-types0.2.0, DFINITY's, for the ICRC-1 account text form and the ledger's transfer types.StoredPendinggains two optional fields; actions stored by step 7 decode with both absent, and the upgrade test now carries an open action across the upgrade.toyet; only ICRC-1 account text is.historyis not exported yet: memory 6 holds only what the wallet sent, and incoming transfers need the ledgers' index canisters.Tests. The PocketIC tests install the ICRC-1 ledger Wasm from the dfinity/ic release
ledger-suite-icrc-2025-09-01(CI pins the checksum itsSHA256SUMSlists) at the ICP ledger's mainnet id on the NNS subnet, and as a token on the wallet's subnet. They check addresses against the mapping written out in the test; balances; a transfer with a memo and fee to the wallet's own subaccount and on from it; a stopped ledger, then started, sending once; twoexecutecalls at once; two identical actions executed together; insufficient funds and a wrong fee; the checks atpropose; the daily limit with open transfers and its 24-hour window; and the check again atexecute. A property test drives the attempt state against a model ledger that sends, loses the answer, traps the callback, stalls or refuses, and checks that the tokens are sent at most once, that a transfer endsExecutedonly if they were, and that one sent unheard stays open while the ledger can find it.Faults. Injected one at a time, each made at least one test fail: little-endian subaccounts; every transfer sent from the default subaccount; no in-flight lock; open transfers not counted against the daily limit; no limit check at
execute; sent transfers not recorded; a call that did not run failing the transfer;balanceasking for the caller's account;add_accountnot audited;Icrcallowed to name the ICP ledger;Duplicatenot counted as sent; a refused transfer left ready; the memo dropped; every fresh call created atnow; a ledger'sCanisterErrorcounted as not run; a refusal after an unknown call ending the action. The last three are Codex's findings, and the property test's model ledger now refuses before deduplication too. The property test also catches an expiry that ignores an unknown outcome, in 5 of 5 runs.Checks run locally:
cargo fmt --all --check, clippy native and wasm32 with-D warnings, unit and interface tests, the release Wasm build, and the PocketIC tests against server 16.1.0, including the upgrade from step 7.🤖 Generated with Claude Code
https://claude.ai/code/session_013Vgh2De8Zarye1iDyGSRbe