Skip to content

fix(flows): verify Bob funding confirms + eRPC reflects it before buy#368

Merged
bussyjd merged 1 commit intomainfrom
fix/flow-11-funding-verification
Apr 22, 2026
Merged

fix(flows): verify Bob funding confirms + eRPC reflects it before buy#368
bussyjd merged 1 commit intomainfrom
fix/flow-11-funding-verification

Conversation

@bussyjd
Copy link
Copy Markdown
Collaborator

@bussyjd bussyjd commented Apr 22, 2026

Summary

Flow-11 step 28 (fund Bob's remote-signer with 0.05 USDC) had two bugs that caused a 32/33 false-green ~50% of the time:

  1. Unconditional PASS — the cast send ... | grep status || true pipe masked silently-dropped funding txs. The pass line ran regardless.
  2. eRPC cache race — even when the tx confirmed, the AI agent's buy.py in step 32 queries balance through eRPC, which has a 10s eth_call cache TTL. If the agent polled during the cache window it saw 0 USDC, declined the buy verbosely, and step 32's >100 chars heuristic mistook the refusal for success. Step 33 then failed: PurchaseRequest CR not ready: No resources found.

Fix

  • Capture cast send output; require status 1 (success) in the receipt, fail-fast otherwise.
  • Poll direct Base Sepolia RPC until Bob's on-chain USDC ≥ 50000 (bypasses eRPC — confirms the tx is actually mined).
  • New step: poll Bob's in-pod buy.py balance via eRPC until it reports 0.05. This is the exact path the AI agent will take in step 32, so passing here guarantees no zero-balance race.

Verification

  • Before the patch: rounds 1 and 2 both hit FAIL: [33] with the Balance: 0 USDC refusal in the agent response.
  • After the patch: round 3 → 42/42 green (tally grew by 1 because of the new explicit "eRPC reflects funding" step).

Test plan

  • Run ./flows/flow-11-dual-stack.sh with a fresh .env key — 42/42.
  • Run two more times against varying Base Sepolia congestion to confirm the poll budget (36s direct + 90s eRPC) is tight enough to catch real drops without false-failing slow mempools.

Flow-11's step 28 submitted a USDC transfer from the .env key to Bob's
remote-signer wallet but:

1. Marked the step PASS unconditionally (the `... 2>&1 | grep status || true`
   pipe masked cast-send failures), so a silently-dropped tx still looked
   green.
2. Moved straight to step 32 where the AI agent's buy.py queries balance
   through eRPC. eRPC's eth_call cache TTL is 10s, so even when the tx
   confirmed, the agent could still see 0 USDC for the first poll — and the
   agent's LLM, faced with "0 USDC, needs 0.005 USDC", declined the purchase
   with a verbose explanation, which step 32's `>100 chars` heuristic
   mistook for success. Step 33 then failed because no PurchaseRequest CR
   was ever created.

This caused a 32/33 false-green on the first two runs.

Fix:

- Capture cast-send output, require `status   1 (success)` in the receipt,
  fail-fast otherwise.
- Poll the direct Base Sepolia RPC until Bob's on-chain USDC >= 50000
  (bypasses eRPC cache — confirms the tx is actually mined).
- Then add a new step that polls Bob's in-pod buy.py `balance` via eRPC
  until it reports 0.05 USDC — this is the same path the AI agent will
  take in step 32, so passing here guarantees the agent won't see zero.

With the patch, flow-11 runs 42/42 green. Without it, ~50% of runs hit
the eRPC cache and fail on step 33.
@bussyjd bussyjd merged commit ff4144e into main Apr 22, 2026
6 checks passed
@bussyjd bussyjd deleted the fix/flow-11-funding-verification branch April 22, 2026 22:23
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