Skip to content

Commit e0577b0

Browse files
committed
Add FlowChain RPC discovery readiness gate
1 parent a086cd5 commit e0577b0

11 files changed

Lines changed: 529 additions & 37 deletions

File tree

docs/FLOWCHAIN_CONTROL_PLANE_API.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Commands:
2020
npm run control-plane:test
2121
npm run control-plane:demo
2222
npm run control-plane:smoke
23+
npm run flowchain:rpc:e2e
2324
npm run control-plane:serve
2425
```
2526

@@ -125,11 +126,54 @@ GET /health
125126
Browser-safe summary endpoints are also available:
126127

127128
```text
129+
GET /rpc/discover
130+
GET /rpc/readiness
128131
GET /explorer/summary
129132
GET /product-flow/status
130133
GET /pilot/status
131134
```
132135

136+
### `rpc_discover`
137+
138+
Params: none.
139+
140+
Returns the FlowChain-native JSON-RPC method inventory for wallets, explorers,
141+
relayers, and deployment checks. This method is intentionally not EVM JSON-RPC
142+
or Solana JSON-RPC compatibility. It reports the supported FlowChain methods,
143+
their categories, read/write mode, local-only boundary, and current production
144+
readiness status.
145+
146+
HTTP mirror:
147+
148+
```text
149+
GET /rpc/discover
150+
```
151+
152+
### `rpc_readiness`
153+
154+
Params: none.
155+
156+
Returns a fail-closed machine-readable readiness object for the FlowChain RPC.
157+
It reports whether active runtime state is readable, whether wallet/explorer/
158+
bridge consumers can use the current RPC, and which public deployment inputs
159+
are missing. It returns environment variable names only, never values.
160+
161+
Public RPC deployment inputs currently checked by name:
162+
163+
```text
164+
FLOWCHAIN_RPC_PUBLIC_URL
165+
FLOWCHAIN_RPC_ALLOWED_ORIGINS
166+
FLOWCHAIN_RPC_RATE_LIMIT_PER_MINUTE
167+
FLOWCHAIN_RPC_TLS_TERMINATED
168+
FLOWCHAIN_RPC_STATE_BACKUP_PATH
169+
```
170+
171+
HTTP mirror:
172+
173+
```text
174+
GET /rpc/readiness
175+
```
176+
133177
### `chain_status`
134178

135179
Params: none.

docs/agent-goals/production-l1-live-chain/03-node-rpc-network.md

Lines changed: 195 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,204 @@
33
Worktree: `E:\FlowMemory\flowmemory-live-node-rpc`
44
Branch: `agent/live-product-node-rpc`
55

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.
915

1016
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`
1222
- `services/control-plane/src/`
23+
- `crates/flowmemory-devnet/`
1324
- `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`
3929

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.
47101

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.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"flowchain:bridge:evidence:export": "powershell -NoProfile -ExecutionPolicy Bypass -File infra/scripts/bridge-evidence-export.ps1",
9090
"flowchain:bridge:emergency-stop": "powershell -NoProfile -ExecutionPolicy Bypass -File infra/scripts/bridge-base8453-control.ps1 -Action EmergencyStop",
9191
"flowchain:control-plane:smoke": "npm run control-plane:smoke",
92+
"flowchain:rpc:e2e": "npm run rpc:e2e --prefix services/control-plane",
9293
"flowchain:dashboard:build": "powershell -NoProfile -ExecutionPolicy Bypass -File infra/scripts/flowchain-workbench.ps1 -BuildOnly",
9394
"flowchain:dashboard:verify": "powershell -NoProfile -ExecutionPolicy Bypass -File infra/scripts/flowchain-workbench.ps1 -BuildOnly",
9495
"flowchain:export": "powershell -NoProfile -ExecutionPolicy Bypass -File infra/scripts/flowchain-export.ps1",

services/control-plane/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ From the repository root:
1212
npm run control-plane:demo
1313
npm run control-plane:test
1414
npm run control-plane:smoke
15+
npm run flowchain:rpc:e2e
1516
npm run control-plane:serve
1617
npm run flowchain:real-value-pilot:control-dashboard
1718
```
@@ -24,6 +25,8 @@ The server defaults to `http://127.0.0.1:8787`.
2425
The dispatcher supports:
2526

2627
- `health`
28+
- `rpc_discover`
29+
- `rpc_readiness`
2730
- `node_status`
2831
- `peer_list`
2932
- `chain_status`
@@ -119,7 +122,9 @@ If the launch-core fixture is missing, the loader rebuilds the in-memory view fr
119122

120123
`transaction_submit` accepts signed local test transaction envelopes only and writes them to `devnet/local/intake/transactions.ndjson` by default. `bridge_observation_submit` writes bridge-agent observations to `devnet/local/intake/bridge-observations.ndjson`. These files are local runtime intake, not committed fixtures.
121124

122-
`npm run control-plane:smoke` runs an in-process JSON-RPC client over the complete local lifecycle surface: health, node status, peers, chain status, real-value pilot status/list/status methods, blocks, transactions, mempool, accounts, balances, tokens, token balances, pools, LP positions, swaps, product-flow status, faucet events, wallet public metadata, rootfields, agents, models, work receipts, artifact availability, verifier modules, verifier reports, memory cells, challenges, finality, bridge observations, bridge deposits, bridge credits, withdrawals, provenance, and raw JSON.
125+
`npm run control-plane:smoke` runs an in-process JSON-RPC client over the complete local lifecycle surface: RPC discovery/readiness, health, node status, peers, chain status, real-value pilot status/list/status methods, blocks, transactions, mempool, accounts, balances, tokens, token balances, pools, LP positions, swaps, product-flow status, faucet events, wallet public metadata, rootfields, agents, models, work receipts, artifact availability, verifier modules, verifier reports, memory cells, challenges, finality, bridge observations, bridge deposits, bridge credits, withdrawals, provenance, and raw JSON.
126+
127+
`npm run flowchain:rpc:e2e` verifies the FlowChain-native JSON-RPC discovery and readiness methods, required method coverage, no-secret report boundary, and writes `devnet/local/rpc-e2e/flowchain-rpc-e2e-report.json`. It intentionally reports public RPC readiness as blocked until the explicit public RPC deployment inputs are configured.
123128

124129
`npm run flowchain:real-value-pilot:control-dashboard` verifies that the API exposes the capped owner-testing pilot lifecycle, rejects secret-shaped material, and that the dashboard source renders the pilot evidence and next operator command without browser secret storage. The root `flowchain:real-value-pilot:e2e` command is the upstream final HQ pilot gate and depends on proof commands from multiple owner branches.
125130

services/control-plane/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"demo": "node src/demo.ts",
77
"real-value-pilot:e2e": "node src/real-value-pilot-e2e.ts",
8+
"rpc:e2e": "node src/rpc-e2e.ts",
89
"serve": "node src/server.ts",
910
"smoke": "node src/smoke.ts",
1011
"test": "node --test test/*.test.ts"

0 commit comments

Comments
 (0)