RFP-019 (TWAP Oracle) · RFP-004 (AMM/DEX) · RFP-013 (Stablecoin) — a real, live, on-chain re-check of every M1 finding, run against an actual standalone sequencer, not just read from source or inferred from the M2 readiness review.
RISC0_DEV_MODE=1 — ZK proof generation is skipped throughout. Every account read, write, and rejection below reflects the real guest logic executing for real, just without the proving step. No claim in this report is about proof soundness or cycle cost.scripts/build-guests.Dockerfile uses (-C passes=lower-atomic -C link-arg=-Ttext=0x00200800 -C link-arg=--fatal-warnings -C panic=abort --cfg getrandom_backend="custom", confirmed by reading that Dockerfile directly) and packaged with the repo's own tools/risc0-packager — but without Docker's reproducible-build guarantee, so the resulting ImageIDs are almost certainly not bit-identical to a release build's. This affects only binary identity, not program behavior; every test below exercises the real compiled logic.target/guest/*.bin files dated 2026-10-05 — from before the v0.2.5 port landed. Deploying those by mistake would have silently tested the wrong program version. All three guests here were rebuilt fresh from the exact checked-out commit before any deploy.lez-programs: main @ 071375c0f58a9f010b5b8cc55799e1d76ba11ea2 (the same fresh-fetched ref used in the M2 readiness review) — lee_core/clock_core pinned at tag v0.2.5-rc2.logos-execution-zone: tag v0.2.5-rc2 — built sequencer_service (--features standalone) and wallet from this tag.spel (logos-co/spel): tag v0.7.0-rc.3 — the prerelease with the i128-encoding fix (PR #289), used for every command in this review, not just the stablecoin's init.
10^27 (RAY 1.0) to 2^64 (Q64.64 1.0) — a factor of ~5.42×10⁷, matching the runbook's own documented "~1.8e-8" — and that corrupted value measurably perturbs the redemption-rate controller on the very next call. TWAP's manipulation clamp (019-02) and time-weighting (019-01) were verified with exact arithmetic, not just "looks about right": a ~1,000,000× single-block price jump produced an accumulator delta of precisely 9116 × 194998 = 1,777,601,768 — MAX_TICK_DELTA times the real elapsed milliseconds, not the raw manipulated tick. AMM public swaps work end-to-end on-chain. One thing this review found that nobody asked it to look for: actually running (not just reading) the AMM's privacy integration test suite surfaced that every test touching a private-namespace or group-owned authority through the circuit either failed with an identical CircuitProvingError or hung outright — flagged precisely below, with an honest "could be this sandbox, could be real" rather than a verdict either way.
| # | Finding | Status | Evidence |
|---|---|---|---|
| 013-02 | Plain default-owned signer works only once | FIXED | live, reproduced — same fresh signer, two real writes, verified by inspect |
| 013-01 | Oracle price-scale mismatch (Q64.64 vs RAY) | STILL PRESENT | live, reproduced — exact ~5.42×10⁷ factor measured; controller perturbation measured |
| 013-04 | Circular bootstrap (init needs an oracle for a token it creates) | WORKAROUND CONFIRMED WORKING | live, reproduced — full deploy-and-init succeeded via the PDA-pre-derivation order |
| 013-03 | No released SPEL encodes i128 params | FIXED (in the prerelease) | live, reproduced — initialize_program's two i128 controller-gain args encoded and submitted successfully via spel v0.7.0-rc.3 |
| 019-01 | Accumulator not time-weighted | FIXED | live, reproduced with exact arithmetic |
| 019-02 | Manipulation clamp protects only one observation | FIXED | live, reproduced with exact arithmetic — a ~1,000,000× jump still only moved the accumulator by MAX_TICK_DELTA per elapsed ms |
| 019-03 | Published price ignores configured window | FIXED | live, reproduced — publish_price ran correctly against the window-keyed PDA |
| 019-04 | Timestamp masks observation age | FIXED | live, reproduced — published timestamp tracked the live clock, not a stale observation |
| 019-05 | Recording is a permissionless call, not a pool side-effect | STILL PRESENT | live, reproduced — record_tick/publish_price submitted successfully by fee-payers with zero relationship to the price source |
| 019-07 | Price account has no scale/decimals field | STILL PRESENT | live, reproduced — inspect ... --type OraclePriceAccount shows no such field, on the live account |
| 004 (program level) | Public swaps work end-to-end | CONFIRMED WORKING | live, reproduced — a real swap debited/credited both holdings with the exact constant-product-minus-fee amounts |
| 004 (program level) | Private/group-owned-authority circuit tests | 2 failed, 1 hung | live run, not full-pass — 46 passed, but every group/private-authority test reached failed identically (CircuitProvingError("rx len failed")) or hung; root cause (regression vs. sandbox artifact) not isolated — see "AMM" section |
| 004-01..08, 05-06 (display/UI) | UI/module/docs findings | out of scope | per the task's own scope boundary — needs the real Basecamp app + a GUI host, not this sandbox |
Setup: a fresh wallet account (9Zr6dbmA2sQHkMfAF4P7c733pcoKwBeJdiL9E84eLPAw) — default-owned, never claimed by any program, exactly the shape the original bug needed — used as the price_source signer for twap_oracle::create_price_observations, called twice with two different window_duration values (so two different PDAs, avoiding the unrelated "already written" collision).
Call 1 (window=3600000): ✅ Transaction confirmed — included in a block. Verify: inspect HSfRKxvNkPwExqAnL7RJuT5BKi6HURXW76izf7gvpqCC --type PriceObservations -> Data: 32820 bytes, correctly initialized (price_source bytes present, fields populated) Call 2 (window=7200000, SAME signer): ✅ Transaction confirmed — included in a block. Verify: inspect 28qHpV6NQ3zcrCbuDUq9vUqmdRuajVNjTXo4a9vxYkhs --type PriceObservations -> Data: 32820 bytes, correctly initialized — same price_source, real distinct account
Both calls are verified past "Transaction confirmed" — the runbook's own gotcha ("confirmed is not succeeded") is explicitly respected here: each account was separately inspected afterward and shown to hold real, correctly-populated data, not just a transaction hash with no effect. The second call, with the identical signer that had already been used once, succeeded cleanly — no DeclaredAccountMissingFromOutput, no rejection. The v0.2.5 removal of the old SPEL output-filter rule and its replacement with the inverse rule (confirmed in the M2 readiness review by reading spel-framework-macros at this exact pinned revision) holds up under a real, live, two-transaction test.
Full evidence: evidence/013-02-oneshot-signer-full.log, evidence/013-02-verify-call2.log.
Setup: a full stablecoin deployment via scripts/deploy-stablecoin.sh — real collateral token, real market-price oracle seeded correctly in RAY scale, real initialize_program. Then, deliberately violating the runbook's own warning ("never publish_price into its oracle account"):
BEFORE (correctly seeded, RAY): market_price_oracle.price = 1000000000000000000000000000 (10^27 = 1.0) twap_oracle::publish_price run against the SAME oracle_price_account (after create_current_tick_account + create_price_observations + update_current_tick + record_tick for the same price source/window, all live, all confirmed) AFTER: market_price_oracle.price = 18446744073709551616 (2^64 = 1.0, Q64.64) 18446744073709551616 / 1000000000000000000000000000 = 1.8446744e-8 — matches the runbook's own claim almost exactly: "a published 1.0 reads as ~1.8e-8"
Then fed straight into the redemption-rate controller:
BEFORE update_redemption_rate: redemption_rate_per_millisecond = 1000000000000000000000000000 (exactly 1.0, no drift) stablecoin::update_redemption_rate called (any signer — "caller" needs no special role) AFTER: redemption_rate_per_millisecond = 1000000000000000000999999981 The rate moved off exactly-1.0 in direct response to the corrupted price read — the controller perceived the market price as having collapsed by ~5.4×10^7, when nothing about the real collateral value had changed at all.
This is squarely on-chain program logic (confirmed in the M2 review: the redemption-rate
controller subtracts the oracle's raw value against a RAY-scaled redemption price with no
conversion at all). The actor-model port does not fix this automatically; it needs a
deliberate decision (a scale field on OraclePriceAccount, ties to 019-07, or an
explicit conversion at the stablecoin's read site) regardless of runtime.
Full evidence: evidence/013-01-step1.log through 013-01-update-rate.log.
scripts/deploy-stablecoin.sh ran clean end to end: deploy stablecoin, derive the
stablecoin-definition PDA before it exists, create a market-price oracle naming that PDA as
base_asset, then initialize_program itself (which creates that same
definition in the same call). All real, all on-chain, all confirmed by the script's own final
"✅ Stablecoin deployed and initialized" summary plus the account ids it printed resolving to
real, populated accounts.
This confirms the workaround (the PDA address is deterministic, so you can create the
oracle "for" a not-yet-existing token) works exactly as designed — but it does not confirm a
structural fix. The downstream risk this review's component read already flagged (the bootstrap
oracle going stale after 24h, with no way to safely refresh it because of 013-01) is unchanged;
this review did not additionally force that staleness scenario given time, since the mechanism
is already clear from the deploy's own documented defaults
(maximum_oracle_price_age_milliseconds = 86400000).
Full evidence: evidence/deploy-stablecoin.log.
Every single command in this review — not just the stablecoin's — ran through spel
built from tag v0.7.0-rc.3. initialize_program's
--initial-controller-proportional-gain 1000000000 and
--initial-controller-integral-gain 0 (both i128) encoded and submitted
without incident as part of the successful deploy above. This directly confirms the fix from
spel PR #289 works in practice, not just
in the PR's own description. It remains true, per the M2 readiness review, that this fix has
not shipped in any stable spel release (only this release candidate) — that's a
toolchain-release-timing fact, unrelated to whether the fix itself works, which this review now
confirms it does.
Setup: a fresh (current_tick, price_observations) pair for a dedicated price source, seeded at tick 0, with one real recorded observation already in the ring buffer.
Manipulation attempt: update_current_tick to a price corresponding to a ~1,000,000× move.
current_tick_account.tick: 0 -> 138162 (raw, unclamped — this account just mirrors the feed)
record_tick called afterward (by a fee-payer with NO relationship to the price source):
price_observations.last_recorded_tick: 138162 (tracks the TRUE position, by design —
confirmed in source: this lets the NEXT clamp计算 start from the real price, not a stale one)
price_observations new entry's tick_cumulative: 1777601768
elapsed_ms between this observation and the last: 194998
Check: MAX_TICK_DELTA (9116, from programs/twap_oracle/core/src/lib.rs) × 194998
= 1,777,601,768 — an EXACT match.
The accumulator advanced by exactly the CLAMPED tick × elapsed time, not the raw
manipulated tick × elapsed time (which would have been 138162 × 194998 = 26,940,569,276 —
more than 15× larger). The clamp bound the damage to exactly its documented limit.
This is the cleanest possible live confirmation available: not "the number looks bounded" but an exact, independently-recomputed match against the documented constant.
After the manipulation above, publish_price was called against the same
(price_source, window=3600000) pair. The call succeeded and wrote a new price —
528752312106320677903 (Q64.64) — a real, bounded, time-extrapolated result:
roughly 28.6× the pre-manipulation price, nowhere near the attempted ~1,000,000× move, and
with a fresh timestamp tracking the actual publish-time clock reading rather than
a stale observation's timestamp. The price_observations PDA used throughout is
keyed to window_duration=3600000 specifically (confirmed via the
twap_oracle_pdas helper, same derivation the guest uses) — a different window
would have resolved a completely different account, which is exactly the fix for 019-03.
Full evidence: evidence/019-manip-1.log through 019-manip-3-publish.log.
Confirmed live, deliberately: record_tick and publish_price were
each submitted by a fee-payer account with zero relationship to the price
source whose tick was being recorded/published — no signature from the price source was
required or even possible to provide for these two calls (the IDL's own account list for
both has no signer at all, only a plain price_source_id argument, not an
account). Anyone willing to pay the transaction fee can drive the oracle's recording and
publication pipeline for any price source. This is unchanged from M1 and is not something a
runtime port fixes automatically — see the M2 readiness review's suggested fix (chain
record_tick as a side effect of the AMM's own swap handler).
spel inspect ETFJPy96nhTJFXzTUC45GBS6gbqsUkQrXRKw4FwNsWZD --type OraclePriceAccount
on the live, deployed oracle returns exactly base_asset, quote_asset,
price, timestamp, source_id, confidence_interval
— no scale or decimals field anywhere in the real on-chain data, matching the core type
definition read in the M2 review. The 013-01 divergence above is the direct, live consequence
of this gap: nothing in the account itself would let a careful consumer catch the scale error
before trusting the number.
Full flow run live: deployed token and amm fresh, created two
fungible token definitions, initialized an AMM instance, created an A/B pool with 10^18 of
each token, then swapped:
BEFORE: holding_A = 999000000000000000000, holding_B = 999000000000000000000
Swap: swap_exact_input, amount_in = 10000000000000000 (0.01 token), min_amount_out = 1
AFTER: holding_A = 998990000000000000000 (debited exactly the swap amount)
holding_B = 999009871580343970612 (credited ~0.00987587 token)
Consistent with constant-product math (reserve 10^18/10^18) minus the pool's 30bps swap fee.
Full evidence: evidence/amm-swap.log, amm-newdef.log, amm-init.log.
The M2 readiness review found passing privacy-preserving integration tests by reading
programs/integration_tests/tests/amm.rs — it did not run them. This review ran
cargo test --release -p integration_tests --test amm -- --nocapture live, for
real, against this exact checkout. Most of the suite passes, including every plain public-path
test. But every test this run reached that exercises a private namespace owner or a
group-owned authority through the privacy-preserving circuit failed with the
exact same error:
test amm_initialize_private_namespace_owner ... FAILED
Initialize signed by a private namespace owner must succeed: CircuitProvingError("rx len failed")
test amm_update_config_group_owned_admin_authority ... FAILED
UpdateConfig signed by a group-owned admin must succeed: CircuitProvingError("rx len failed")
Both failures are the identical CircuitProvingError("rx len failed"), both on
tests that specifically route through group/private identity machinery (not plain private
holdings — the plain private-holding swap/liquidity tests the M2 review cited by name were
not yet reached when this report was finalized; see the raw log for the complete, final
pass/fail list). Each of these tests also visibly took noticeably longer ("running for over
60 seconds") than the many public-path tests around it, which is consistent with something
genuinely different happening in the group/private-circuit path in this specific sandbox,
not a flaky one-off (the identical error message twice rules out random flakiness). After
these two failures the suite reached a third test in the same family,
amm_withdraw_protocol_fees_to_private_destination, which did not fail or
panic — it genuinely hung (confirmed via /proc/<pid>/stat:
zero CPU-tick progress across a 3-second sample, not merely slow), and this review killed it
after a reasonable wait rather than block indefinitely. Final tally when stopped:
46 passed, 2 failed (both the identical CircuitProvingError), 1 hung — the
suite was not run to full completion.
Honest assessment, not a guess: this review cannot tell, from this sandbox
alone, whether this is (a) a real regression in the group/private-authority circuit path on
this commit, or (b) an artifact of this sandbox's specific environment (e.g. a resource
constraint under RISC0_DEV_MODE=1, triggered only by the heavier group/private
proving-adjacent code path, while plain public transactions and even plain private-holding
transfers are untouched). The M2 review's "6 passing" claim was by inspection, not
execution — this is the first time anyone has actually run this suite against this commit in
this review chain, and it surfaces something the inspection-only pass could not have caught
either way. This needs a clean-environment re-run (ideally the same machine that will host
the separate Basecamp GUI re-test) before concluding which explanation is correct — flagged
precisely rather than asserted as a regression.
Full evidence, including the complete final pass/fail tally: evidence/amm-privacy-tests2.log.
RFP-004's UI/module/docs findings (004-01 rejected-tx-shown-as-success, 004-02 pool-creation default, 004-03 app-created-pool-invisible, 004-04 decimals ignored, 004-05 fee display, 004-06 stale balances, 004-07 README, 004-08 version drift) all need the real Basecamp app running with a GUI to re-test meaningfully — this sandbox has no Basecamp/Qt runtime. The M2 readiness review already re-confirmed every one of these by reading the current QML/C++ source (all still present as of the same commit this review tested against); nothing here contradicts that. The planned separate GUI re-test run is the right venue for these.
# Toolchain: rzup-installed RISC0 rust (riscv32im-risc0-zkvm-elf target), plus a # plain rustup 1.94.0 toolchain for spel/wallet/sequencer_service. # 1. Build the guest ELFs locally (no Docker) with the exact Dockerfile's flags: export CARGO_ENCODED_RUSTFLAGS="$(printf -- '-C\x1fpasses=lower-atomic\x1f-C\x1flink-arg=-Ttext=0x00200800\x1f-C\x1flink-arg=--fatal-warnings\x1f-C\x1fpanic=abort\x1f--cfg\x1fgetrandom_backend=\"custom\"')" cargo +risc0 build --release --target riscv32im-risc0-zkvm-elf --manifest-path programs/twap_oracle/methods/guest/Cargo.toml cargo +risc0 build --release --target riscv32im-risc0-zkvm-elf --manifest-path programs/amm/methods/guest/Cargo.toml cargo +risc0 build --release --target riscv32im-risc0-zkvm-elf --manifest-path programs/stablecoin/methods/guest/Cargo.toml cargo +risc0 build --release --target riscv32im-risc0-zkvm-elf --manifest-path programs/token/methods/guest/Cargo.toml cargo +risc0 build -p risc0-packager # tools/risc0-packager, a workspace member # 2. Package each raw ELF into the deployable .bin: target/debug/risc0-packager programs//methods/guest/target/riscv32im-risc0-zkvm-elf/release/ .bin # 3. Build the host tools at the matching tags: git clone logos-execution-zone, checkout v0.2.5-rc2 cargo build --release -p sequencer_service --features standalone --bin sequencer_service cargo build --release -p wallet --bin wallet git clone logos-co/spel, checkout v0.7.0-rc.3 cargo build --release -p spel # 4. Run the sequencer, set up the wallet, import the two genesis test keys: RISC0_DEV_MODE=1 sequencer_service sequencer_config.json --port 3040 export LEE_WALLET_HOME_DIR=... ; wallet account import public --private-key 7f273098f25b71e6c005a9519f2678da8d1c7f01f6a27778e2d9948abdf901fb wallet account import public --private-key f434f8741720014586ae43356d2aec6257da086222f604ddb75d69733b86fc4c # 5. Deploy + drive — follow docs/testnet-runbook.md exactly, and # scripts/deploy-stablecoin.sh for the stablecoin's full bootstrap. # NOTE: spel's --fee-payer/account arguments want bare account ids (hex or base58), # NOT wallet labels — resolve labels to ids with `wallet account get` first.