|
3 | 3 | Worktree: `E:\FlowMemory\flowmemory-live-node-rpc` |
4 | 4 | Branch: `agent/live-product-node-rpc` |
5 | 5 |
|
6 | | -Mission: make FlowChain run like a real local/private L1 node product with an |
7 | | -RPC surface that wallets, relayers, and explorers can use. Build on the current |
8 | | -runtime and control-plane. Do not replace the runtime. |
| 6 | +Mission: build the FlowChain RPC into a real, wallet/explorer/bridge-usable |
| 7 | +L1 RPC surface. Do not stop at docs, fixtures, UI labels, or a local-only demo. |
| 8 | +Keep looping until every RPC requirement below is implemented, machine-tested, |
| 9 | +or blocked by a precise external deployment input with a fail-closed check. |
| 10 | + |
| 11 | +You are not alone in the codebase. Other agents may be changing runtime, |
| 12 | +wallet, bridge, dashboard, storage, and verification files. Do not revert their |
| 13 | +edits. Integrate with the existing runtime/control-plane contracts and avoid |
| 14 | +creating a parallel RPC stack. |
9 | 15 |
|
10 | 16 | Read first: |
11 | | -- `crates/flowmemory-devnet/` |
| 17 | +- `AGENTS.md` |
| 18 | +- `docs/agent-goals/production-l1-live-chain/README.md` |
| 19 | +- `docs/FLOWCHAIN_CONTROL_PLANE_API.md` |
| 20 | +- `docs/FLOWCHAIN_PRODUCTION_L1_GO_NO_GO.md` |
| 21 | +- `docs/FLOWCHAIN_LIVE_L1_BRIDGE_GO_NO_GO.md` |
12 | 22 | - `services/control-plane/src/` |
| 23 | +- `crates/flowmemory-devnet/` |
13 | 24 | - `infra/scripts/flowchain-node*.ps1` |
14 | | -- `docs/LOCAL_DEVNET.md` |
15 | | - |
16 | | -Own: |
17 | | -- node start/stop/status/log commands |
18 | | -- JSON-RPC or HTTP endpoints for submit, blocks, txs, receipts, balances, |
19 | | - accounts, assets, swaps, bridge credits, and finality |
20 | | -- local multi-process peer smoke and LAN documentation if exposed |
21 | | -- wallet-safe connection discovery |
22 | | - |
23 | | -Build requirements: |
24 | | -1. A wallet can discover the active node/API without hard-coded stale ports. |
25 | | -2. RPC writes must submit to the active runtime, not to static fixtures. |
26 | | -3. RPC reads must reflect the same state file the runtime is mutating. |
27 | | -4. Every write endpoint must return a stable receipt or fail closed. |
28 | | -5. Add health probes for block production, finality lag, mempool depth, peer |
29 | | - count, bridge relayer lag, and wallet API reachability. |
30 | | -6. Support configurable confirmation/finality settings without hard-coded |
31 | | - arbitrary pilot caps. |
32 | | -7. Ensure CORS is safe for local desktop/mobile use and does not expose secrets. |
33 | | - |
34 | | -Commands: |
35 | | -- `npm run flowchain:node` |
36 | | -- `npm run flowchain:node:status` |
37 | | -- `npm run control-plane:smoke` |
38 | | -- `npm run flowchain:restart:verify` |
| 25 | +- `infra/scripts/flowchain-production-l1-e2e.ps1` |
| 26 | +- `infra/scripts/flowchain-live-l1-bridge-e2e.ps1` |
| 27 | +- `apps/dashboard/src/views/WalletView.tsx` |
| 28 | +- `apps/dashboard/src/views/WorkbenchView.tsx` |
39 | 29 |
|
40 | | -Acceptance gates: |
41 | | -- Wallet send uses a live RPC/control-plane path. |
42 | | -- Explorer block and transaction reads match runtime state after a write. |
43 | | -- Node restart does not lose pending or included transactions. |
44 | | -- API errors name missing env/deployment artifacts exactly. |
45 | | -- No endpoint returns private keys, vault ciphertext, RPC credentials, or seed |
46 | | - material. |
| 30 | +Own these files/modules unless coordination requires otherwise: |
| 31 | +- `services/control-plane/src/` |
| 32 | +- `services/control-plane/test/` |
| 33 | +- `services/control-plane/README.md` |
| 34 | +- `docs/FLOWCHAIN_CONTROL_PLANE_API.md` |
| 35 | +- `docs/agent-runs/live-product-node-rpc/` |
| 36 | +- node/RPC scripts under `infra/scripts/flowchain-node*.ps1` |
| 37 | +- root `package.json` RPC scripts, only for RPC-focused commands |
| 38 | + |
| 39 | +Do not own: |
| 40 | +- wallet private-key custody internals except RPC discovery integration |
| 41 | +- Base lockbox Solidity deployment except fields needed by RPC readiness |
| 42 | +- bridge event parsing logic except relay/RPC contracts |
| 43 | +- dashboard redesign except proving dashboard can consume RPC |
| 44 | +- unrelated formatting churn or broad refactors |
| 45 | + |
| 46 | +Required product standard: |
| 47 | +A wallet on another machine must be able to discover a FlowChain RPC URL, query |
| 48 | +chain status, create/use a local account address, submit a signed FlowChain |
| 49 | +transaction, see the transaction enter mempool or a block, query updated account |
| 50 | +balances, and see bridge credits once the bridge relayer submits them. An |
| 51 | +explorer must be able to read the same blocks, transactions, receipts, accounts, |
| 52 | +balances, token/DEX state, bridge credits, finality, and health state from that |
| 53 | +same RPC. If any part is not live, return a structured fail-closed reason. |
| 54 | + |
| 55 | +RPC protocol requirements: |
| 56 | +1. Keep JSON-RPC 2.0 at `/rpc`. |
| 57 | +2. Add/maintain machine-readable discovery: |
| 58 | + - `rpc_discover` |
| 59 | + - browser-safe `GET /rpc/discover` |
| 60 | + - all supported method names, categories, read/write mode, and boundaries. |
| 61 | +3. Add/maintain machine-readable readiness: |
| 62 | + - `rpc_readiness` |
| 63 | + - browser-safe `GET /rpc/readiness` |
| 64 | + - exact missing env/deployment names only, never values. |
| 65 | +4. Maintain core methods: |
| 66 | + - `health`, `node_status`, `peer_list`, `chain_status` |
| 67 | + - `block_list`, `block_get` |
| 68 | + - `transaction_list`, `transaction_get`, `transaction_submit` |
| 69 | + - `mempool_list` |
| 70 | + - `account_list`, `account_get` |
| 71 | + - `balance_get` |
| 72 | + - `wallet_metadata_list`, `wallet_metadata_get` |
| 73 | + - `wallet_balance_list`, `wallet_transfer_history` |
| 74 | + - token/DEX methods: token, token balance, pool, LP position, swap |
| 75 | + - bridge methods: live readiness, status, observations, deposits, credits, |
| 76 | + withdrawals, lifecycle records |
| 77 | + - receipt/provenance/finality methods. |
| 78 | +5. Every write method must: |
| 79 | + - reject unsigned or malformed envelopes; |
| 80 | + - reject private keys, seed phrases, mnemonics, RPC credentials, API keys, |
| 81 | + webhook URLs, vault ciphertext, and browser-stored secrets; |
| 82 | + - return a stable accepted/rejected receipt; |
| 83 | + - write to active runtime intake, not static committed fixtures; |
| 84 | + - be replay-safe or explicitly fail closed. |
| 85 | +6. Every read method must: |
| 86 | + - prefer active `devnet/local/` runtime state; |
| 87 | + - fall back to deterministic fixtures only with `source` and `localOnly` |
| 88 | + boundaries; |
| 89 | + - never silently present fixture data as live state; |
| 90 | + - include enough IDs for wallet/explorer linking. |
| 91 | + |
| 92 | +Runtime coupling requirements: |
| 93 | +1. RPC reads must reflect the exact state file the node is mutating. |
| 94 | +2. RPC writes must be visible in `mempool_list` immediately. |
| 95 | +3. After block production, submitted txs must be visible in `block_get`, |
| 96 | + `transaction_get`, account/balance reads, and relevant receipt/finality |
| 97 | + reads. |
| 98 | +4. Restart must not lose mempool, included tx, bridge credit, replay key, |
| 99 | + account, balance, token, DEX, or finality state. |
| 100 | +5. Export/import/recovery must prove the same roots before and after restart. |
47 | 101 |
|
| 102 | +Network and deployment requirements: |
| 103 | +1. Support a configurable bind host and port without hard-coded stale ports. |
| 104 | +2. Provide a safe local default: `127.0.0.1`, no public exposure by accident. |
| 105 | +3. Public exposure must require explicit env/deployment fields: |
| 106 | + - `FLOWCHAIN_RPC_PUBLIC_URL` |
| 107 | + - `FLOWCHAIN_RPC_ALLOWED_ORIGINS` |
| 108 | + - `FLOWCHAIN_RPC_RATE_LIMIT_PER_MINUTE` |
| 109 | + - `FLOWCHAIN_RPC_TLS_TERMINATED` |
| 110 | + - `FLOWCHAIN_RPC_STATE_BACKUP_PATH` |
| 111 | +4. If any public RPC input is absent, `rpc_readiness` must report `BLOCKED`. |
| 112 | +5. Add production-shaped CORS guidance. Do not leave broad `*` as the public |
| 113 | + deployment path without a readiness blocker. |
| 114 | +6. Add health probes for: |
| 115 | + - process alive |
| 116 | + - latest block height/hash/root |
| 117 | + - block production age |
| 118 | + - finality lag |
| 119 | + - mempool depth |
| 120 | + - peer count |
| 121 | + - bridge relayer lag/readiness |
| 122 | + - state persistence/readability |
| 123 | + - wallet API reachability |
| 124 | + - no-secret response checks. |
| 125 | +7. Add rate-limit/auth extension points without breaking local development. |
| 126 | + |
| 127 | +Wallet/explorer/bridge integration: |
| 128 | +1. Wallet must be able to call `rpc_discover` and `rpc_readiness`. |
| 129 | +2. Wallet send must use a live RPC/control-plane write path, not a draft row. |
| 130 | +3. Receive address must match an account address the RPC can query. |
| 131 | +4. Explorer blocks/txs/accounts/balances must match runtime state after a write. |
| 132 | +5. Bridge relayer handoff must produce RPC-visible bridge credit rows. |
| 133 | +6. The RPC must distinguish: |
| 134 | + - local/test units, |
| 135 | + - live Base 8453 observed deposits, |
| 136 | + - applied FlowChain credits, |
| 137 | + - spendable balances, |
| 138 | + - withdrawal intents, |
| 139 | + - release evidence. |
| 140 | + |
| 141 | +Security and safety requirements: |
| 142 | +1. Do not print or return secrets. |
| 143 | +2. Do not commit `.env`, private keys, wallet vaults, RPC credentials, API keys, |
| 144 | + or webhook URLs. |
| 145 | +3. All missing live config must be reported by variable/artifact name only. |
| 146 | +4. Broad public readiness must remain false until live gates prove it. |
| 147 | +5. Do not call the RPC EVM-compatible unless EVM JSON-RPC compatibility is |
| 148 | + implemented and tested. If it is FlowChain-native JSON-RPC, say so. |
| 149 | +6. Keep real-funds paths fail-closed unless Base RPC, lockbox, block range, |
| 150 | + caps, confirmations, and owner acknowledgement are configured. |
| 151 | + |
| 152 | +Implementation loop: |
| 153 | +1. Create `docs/agent-runs/live-product-node-rpc/PLAN.md`, |
| 154 | + `CHECKLIST.md`, `EXPERIMENTS.md`, and `NOTES.md`. |
| 155 | +2. Inventory existing methods and mark each `live-runtime`, `fixture-fallback`, |
| 156 | + `write-intake`, `missing`, or `blocked`. |
| 157 | +3. Implement the highest-risk missing RPC feature first. |
| 158 | +4. Add or update unit tests for every changed method. |
| 159 | +5. Add HTTP/browser-safe tests for discovery/readiness. |
| 160 | +6. Run the focused command set below. |
| 161 | +7. Update the checklist with evidence, not claims. |
| 162 | +8. Repeat until the RPC is green or every remaining gap has a failing/skipped |
| 163 | + test and exact blocker. |
| 164 | + |
| 165 | +Commands to run before finishing: |
| 166 | +```powershell |
| 167 | +npm test --prefix services/control-plane |
| 168 | +npm run control-plane:smoke |
| 169 | +npm run flowchain:node:smoke |
| 170 | +npm run flowchain:wallet:transfer:e2e |
| 171 | +npm run flowchain:production-l1:e2e |
| 172 | +npm run flowchain:no-secret:scan |
| 173 | +``` |
| 174 | + |
| 175 | +Add a new root command if it does not already exist: |
| 176 | +```powershell |
| 177 | +npm run flowchain:rpc:e2e |
| 178 | +``` |
| 179 | + |
| 180 | +That command must: |
| 181 | +1. start or attach to a local FlowChain node; |
| 182 | +2. call `rpc_discover` and verify method coverage; |
| 183 | +3. call `rpc_readiness` and verify fail-closed public readiness if env is |
| 184 | + absent; |
| 185 | +4. submit a signed transaction; |
| 186 | +5. verify mempool visibility; |
| 187 | +6. produce or wait for a block; |
| 188 | +7. verify block, tx, account, balance, receipt, finality, and provenance reads; |
| 189 | +8. restart the node/control-plane; |
| 190 | +9. verify state continuity after restart; |
| 191 | +10. verify no-secret scan coverage for RPC outputs. |
| 192 | + |
| 193 | +Acceptance gates: |
| 194 | +- `rpc_discover` and `GET /rpc/discover` exist and are tested. |
| 195 | +- `rpc_readiness` and `GET /rpc/readiness` exist and are tested. |
| 196 | +- Wallet/explorer/bridge can discover the same RPC endpoint and method list. |
| 197 | +- Runtime writes are visible through mempool and block/tx reads. |
| 198 | +- Active runtime state takes precedence over fixtures and says when it is a |
| 199 | + fallback. |
| 200 | +- Public RPC readiness is `BLOCKED` unless all explicit public deployment inputs |
| 201 | + are configured. |
| 202 | +- No endpoint returns private keys, vault ciphertext, seed phrases, RPC |
| 203 | + credentials, API keys, or webhooks. |
| 204 | +- Reports under `docs/agent-runs/live-product-node-rpc/` include exact commands, |
| 205 | + outputs, gaps, and next owners. |
| 206 | +- Do not mark complete if the RPC is local-only but described as public/live. |
0 commit comments