Skip to content

Commit f134965

Browse files
authored
feat: merge-train/spartan (#24745)
See [merge-train-readme.md](https://github.com/AztecProtocol/aztec-packages/blob/next/.github/workflows/merge-train-readme.md). This is a merge-train.
2 parents 9f404f4 + 0e2d593 commit f134965

3 files changed

Lines changed: 302 additions & 0 deletions

File tree

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
name: aztec-node-rpc
3+
description: Fetch data from an Aztec node over JSON-RPC — block numbers, blocks, checkpoints, txs, node info, fees, config, and admin/debug operations. Use whenever you need to query a live Aztec node (public testnet/mainnet gateways, drpc, or a node inside the k8s clusters) or a locally running node. Covers endpoints, auth, namespaces/methods, and a health-check helper.
4+
argument-hint: [endpoint or network, e.g. "testnet block number" or "mainnet node info"]
5+
---
6+
7+
# Query an Aztec node over JSON-RPC
8+
9+
An Aztec node exposes a JSON-RPC HTTP API. Use this skill to fetch chain/tx/node data from a
10+
live network or a local node, and to run admin/debug operations.
11+
12+
## First: health-check the endpoint
13+
14+
Before anything else, confirm the endpoint answers. The canonical liveness call is
15+
`aztec_getBlockNumber` (POST to `/`):
16+
17+
```bash
18+
curl -s -X POST <URL> -H 'content-type: application/json' \
19+
-d '{"jsonrpc":"2.0","method":"aztec_getBlockNumber","params":[],"id":1}'
20+
# -> {"jsonrpc":"2.0","id":1,"result":2445}
21+
```
22+
23+
Or use the helper (auto-falls back to the legacy `node_` namespace, e.g. for drpc):
24+
25+
```bash
26+
.claude/skills/aztec-node-rpc/check-rpc.sh https://v5.testnet.rpc.aztec-labs.com
27+
# -> OK https://v5.testnet.rpc.aztec-labs.com (aztec_getBlockNumber) block=2445
28+
```
29+
30+
## Wire format
31+
32+
- **Transport**: HTTP POST to path `/`, JSON-RPC 2.0.
33+
- **Method name**: `<namespace>_<method>`, e.g. `aztec_getBlock`, `aztecAdmin_getConfig`.
34+
- **Ports** (for a node you run or port-forward): main API on **8080**, admin API on **8880**.
35+
- Batch requests are supported (array of request objects).
36+
37+
```bash
38+
curl -s -X POST http://localhost:8080/ -H 'content-type: application/json' \
39+
-d '{"jsonrpc":"2.0","method":"aztec_getBlock","params":[42],"id":1}'
40+
```
41+
42+
## Namespaces
43+
44+
Registered by `registerAztecNodeRpcHandlers` (yarn-project/aztec-node/src/aztec-node/register_node_rpc_handlers.ts).
45+
46+
| Namespace | Server (port) | Auth | Purpose |
47+
|---|---|---|---|
48+
| `aztec` (alias `node`) | main (8080) | none | main read/query + `sendTx` |
49+
| `p2p` | main (8080) | none | peer/mempool introspection |
50+
| `aztecDebug` (alias `nodeDebug`) | main (8080) | none | debug ops; only if node started with debug enabled |
51+
| `aztecAdmin` (alias `nodeAdmin`) | admin (8880) | API key | node config / lifecycle control |
52+
| `prover` | admin (8880) | API key | prover-node ops (only on a prover node) |
53+
54+
> **Legacy aliases**: `node_*`, `nodeDebug_*`, `nodeAdmin_*` are pre-v5 aliases kept for
55+
> back-compat. Most public nodes accept the new `aztec_*` names; **drpc only accepts the
56+
> legacy `node_*` names** (see Endpoints). When `aztec_*` returns `-32601 method is not
57+
> available`, retry with `node_*`.
58+
59+
See `references/methods.md` for the full per-namespace method list. Commonly used `aztec_*`
60+
methods: `getBlockNumber`, `getCheckpointNumber`, `getBlock`, `getBlocks`, `getBlockData`,
61+
`getChainTips`, `getNodeInfo`, `getNodeVersion`, `getChainId`, `getL1ContractAddresses`,
62+
`getProtocolContractAddresses`, `getL1Constants`, `getSyncedL2SlotNumber`,
63+
`getWorldStateSyncStatus`, `sendTx`, `getTxReceipt`, `getTxEffect`, `getTxByHash`,
64+
`getPendingTxs`, `getPublicStorageAt`, `getContract`, `getCurrentMinFees`,
65+
`getValidatorsStats`, `simulatePublicCalls`.
66+
67+
## Endpoints
68+
69+
### Public gateways (Kong `key-auth`)
70+
71+
Hosted at `*.rpc.aztec-labs.com`. Auth is either the header `x-aztec-api-key: <key>` **or**
72+
the key as the first URL path segment (`https://host/<key>` — Kong copies it into the header,
73+
then strips it before proxying).
74+
75+
| Network / rollup | Hosts | Auth |
76+
|---|---|---|
77+
| testnet v5 (canonical) | `v5.testnet.rpc.aztec-labs.com`, `canonical.testnet.rpc.aztec-labs.com` | keyless OK (rate-limited) |
78+
| testnet v4 | `v4.testnet.rpc.aztec-labs.com`, `testnet.rpc.aztec-labs.com` | keyless OK |
79+
| mainnet v5 (canonical) | `v5.mainnet.rpc.aztec-labs.com`, `canonical.mainnet.rpc.aztec-labs.com` | **key required** |
80+
| mainnet v4 | `v4.mainnet.rpc.aztec-labs.com` | **key required** |
81+
82+
Testnet gateways allow keyless use; mainnet requires a consumer key.
83+
84+
```bash
85+
# testnet — no key
86+
curl -s -X POST https://v5.testnet.rpc.aztec-labs.com/ -H 'content-type: application/json' \
87+
-d '{"jsonrpc":"2.0","method":"aztec_getBlockNumber","params":[],"id":1}'
88+
89+
# mainnet — key from the secrets file (see below)
90+
. ~/.claude/secrets/aztec-rpc.env
91+
curl -s -X POST https://v5.mainnet.rpc.aztec-labs.com/ -H 'content-type: application/json' \
92+
-H "x-aztec-api-key: ${AZTEC_MAINNET_GATEWAY_KEY}" \
93+
-d '{"jsonrpc":"2.0","method":"aztec_getBlockNumber","params":[],"id":1}'
94+
```
95+
96+
### drpc (third-party load balancer)
97+
98+
`https://lb.drpc.live/aztec-mainnet/<key>` and `https://lb.drpc.live/aztec-testnet/<key>`
99+
(key is a URL path segment). **drpc only whitelists the legacy `node_*` namespace** — use
100+
`node_getBlockNumber`, `node_getNodeInfo`, etc. `aztec_*` methods return `-32601`.
101+
102+
```bash
103+
. ~/.claude/secrets/aztec-rpc.env
104+
curl -s -X POST "$AZTEC_DRPC_TESTNET_URL" -H 'content-type: application/json' \
105+
-d '{"jsonrpc":"2.0","method":"node_getBlockNumber","params":[],"id":1}'
106+
```
107+
108+
### Nodes inside the k8s clusters (kubectl port-forward)
109+
110+
Two GKE clusters (GCP project `testnet-440309`). Contexts: `aztec-gke-public`, `aztec-gke-private`.
111+
112+
| Cluster (context) | Namespaces of interest |
113+
|---|---|
114+
| `aztec-gke-public` | `testnet`, `testnet-rpc`, `mainnet` (public/standby), `mainnet-rpc` |
115+
| `aztec-gke-private` | `next-net`, `mainnet` (ignition — active) |
116+
117+
Every node exposes the main API on **8080** and admin on **8880**. Service names follow
118+
`<namespace>-<role>[-aztec-node]`:
119+
120+
| Service (svc/…) | Role |
121+
|---|---|
122+
| `<ns>-rpc-aztec-node` | public-facing RPC node (LoadBalancer) |
123+
| `<ns>-validator`, `<ns>-validator-ha-1` | validator/sequencer node |
124+
| `<ns>-prover-node` | prover node |
125+
| `<ns>-p2p-bootstrap-node` | p2p bootstrap node |
126+
| `<ns>-fisherman-aztec-node` | fisherman node (mainnet) |
127+
| `testnet-rpc-v5-aztec-node`, `mainnet-rpc-canonical-aztec-node` | dedicated RPC upstreams (behind Kong) in the `*-rpc` namespaces |
128+
129+
List what's actually deployed:
130+
`kubectl --context <ctx> -n <ns> get svc | grep -E 'aztec-node|validator|prover|bootstrap'`
131+
132+
Port-forward and query:
133+
134+
```bash
135+
kubectl --context aztec-gke-public -n testnet port-forward svc/testnet-rpc-aztec-node 18080:8080 &
136+
PF=$!
137+
curl -s --retry 15 --retry-connrefused --retry-delay 1 -X POST http://localhost:18080/ \
138+
-H 'content-type: application/json' \
139+
-d '{"jsonrpc":"2.0","method":"aztec_getBlockNumber","params":[],"id":1}'
140+
kill $PF
141+
```
142+
143+
For the **admin API** (port 8880) forward `svc/<name>-admin` on `18880:8880` and send the
144+
namespace's admin key as `x-api-key`. The key lives in a k8s secret:
145+
146+
```bash
147+
kubectl --context <ctx> -n <ns> get secret aztec-admin-api-key -o jsonpath='{.data.key}' | base64 -d
148+
```
149+
150+
## Admin & debug APIs
151+
152+
- **Admin** (`aztecAdmin_*`, port 8880, needs API key): `getConfig`, `setConfig`, `pauseSync`,
153+
`resumeSync`, `pauseSequencer`, `resumeSequencer`, `rollbackTo`, `startSnapshotUpload`,
154+
`getSlashOffenses`, `reloadKeystore`. Auth header: `x-api-key: <key>` or `Authorization: Bearer <key>`.
155+
- **Debug** (`aztecDebug_*`, port 8080, only if the node runs with debug on): `mineBlock`,
156+
`prove`, `warpL2TimeAtLeastTo`, `warpL2TimeAtLeastBy`, `registerContractFunctionSignatures`.
157+
Typically only enabled on local/sandbox nodes.
158+
159+
For a node you start locally, `aztec start --node ...` prints the admin API key on first boot
160+
(persisted under the data dir); pass `--admin-port` / `--port` to change ports.
161+
162+
## Secrets
163+
164+
API keys are **not** stored in this skill. They live in `~/.claude/secrets/aztec-rpc.env`
165+
(chmod 600) and are `source`d as shown above:
166+
167+
- `AZTEC_MAINNET_GATEWAY_KEY` — mainnet public-gateway consumer key (internal/test consumer,
168+
GCP secret `mainnet-rpc-consumer-client1`, project `testnet-440309`).
169+
- `AZTEC_DRPC_MAINNET_URL` / `AZTEC_DRPC_TESTNET_URL` — full drpc URLs with the key embedded.
170+
171+
To (re)issue or inspect gateway consumer keys: `spartan/scripts/create_api_key.sh`, and
172+
`gcloud secrets list --filter=rpc-consumer` (annotation `client_name` labels each consumer).
173+
Refresh the stored mainnet key with:
174+
`gcloud secrets versions access latest --secret=mainnet-rpc-consumer-client1 --project=testnet-440309`
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
# Health-check an Aztec node JSON-RPC endpoint by calling <namespace>_getBlockNumber.
3+
#
4+
# Usage:
5+
# check-rpc.sh <url> [--key <api-key>] [--ns aztec|node] [--method <method>]
6+
#
7+
# <url> full endpoint, e.g. https://v5.testnet.rpc.aztec-labs.com or http://localhost:8080
8+
# --key API key sent as `x-aztec-api-key` header (mainnet gateway etc.);
9+
# falls back to $AZTEC_RPC_API_KEY
10+
# --ns method namespace: aztec (default) or node (legacy; required by drpc)
11+
# --method override the method entirely (default: <ns>_getBlockNumber)
12+
#
13+
# When the aztec_* method is unavailable (-32601), it retries once with the legacy node_*
14+
# namespace, so it works against public gateways, drpc, and port-forwarded cluster nodes.
15+
set -euo pipefail
16+
17+
URL=""
18+
KEY="${AZTEC_RPC_API_KEY:-}"
19+
NS="aztec"
20+
METHOD=""
21+
22+
while [[ $# -gt 0 ]]; do
23+
case "$1" in
24+
--key) KEY="$2"; shift 2 ;;
25+
--ns) NS="$2"; shift 2 ;;
26+
--method) METHOD="$2"; shift 2 ;;
27+
-h|--help) sed -n '2,15p' "$0"; exit 0 ;;
28+
-*) echo "unknown flag: $1" >&2; exit 2 ;;
29+
*) URL="$1"; shift ;;
30+
esac
31+
done
32+
33+
if [[ -z "$URL" ]]; then
34+
echo "usage: check-rpc.sh <url> [--key KEY] [--ns aztec|node] [--method M]" >&2
35+
exit 2
36+
fi
37+
38+
call() {
39+
local method="$1"
40+
local hdr=()
41+
[[ -n "$KEY" ]] && hdr=(-H "x-aztec-api-key: $KEY")
42+
curl -s -m 25 -X POST "$URL" -H 'content-type: application/json' "${hdr[@]}" \
43+
-d "{\"jsonrpc\":\"2.0\",\"method\":\"$method\",\"params\":[],\"id\":1}"
44+
}
45+
46+
method="${METHOD:-${NS}_getBlockNumber}"
47+
resp="$(call "$method")"
48+
49+
if [[ -z "$METHOD" && "$NS" == "aztec" && "$resp" == *'-32601'* ]]; then
50+
method="node_getBlockNumber"
51+
resp="$(call "$method")"
52+
fi
53+
54+
if [[ "$resp" == *'"result"'* ]]; then
55+
bn="$(printf '%s' "$resp" | sed -n 's/.*"result":\([0-9]*\).*/\1/p')"
56+
echo "OK $URL ($method) block=${bn:-?}"
57+
exit 0
58+
fi
59+
60+
echo "FAIL $URL ($method)"
61+
echo " ${resp:-<no response>}"
62+
exit 1
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Aztec node RPC methods
2+
3+
Method names on the wire are `<namespace>_<method>` (e.g. `aztec_getBlock`). Sourced from the
4+
Zod API schemas in `yarn-project/stdlib/src/interfaces/`. Read those files for exact
5+
parameter and return types.
6+
7+
## `aztec_*` — main API (port 8080, no auth)
8+
9+
`AztecNodeApiSchema` (`interfaces/client/aztec-node.ts`). Legacy alias: `node_*`.
10+
11+
**Chain / blocks / checkpoints**
12+
- `getBlockNumber`, `getCheckpointNumber`, `getChainTips`
13+
- `getBlock`, `getBlocks`, `getBlockData`
14+
- `getCheckpoint`, `getCheckpoints`, `getCheckpointsData`
15+
- `getSyncedL2SlotNumber`, `getSyncedL2EpochNumber`, `getSyncedL1Timestamp`
16+
- `getWorldStateSyncStatus`, `isReady`
17+
18+
**Node / protocol info**
19+
- `getNodeInfo`, `getNodeVersion`, `getVersion`, `getChainId`
20+
- `getL1Constants`, `getL1ContractAddresses`, `getProtocolContractAddresses`
21+
22+
**Transactions**
23+
- `sendTx`
24+
- `getTxReceipt`, `getTxEffect`, `getTxByHash`, `getTxsByHash`
25+
- `getPendingTxs`, `getPendingTxCount`
26+
- `isValidTx`, `simulatePublicCalls`
27+
28+
**State / contracts / logs**
29+
- `getPublicStorageAt`, `getContract`, `getContractClass`
30+
- `getPrivateLogsByTags`, `getPublicLogsByTags`
31+
- `getL2ToL1Messages`, `getL1ToL2MessageCheckpoint`
32+
- `findLeavesIndexes`
33+
- membership witnesses: `getNullifierMembershipWitness`, `getLowNullifierMembershipWitness`,
34+
`getPublicDataWitness`, `getBlockHashMembershipWitness`, `getNoteHashMembershipWitness`,
35+
`getL1ToL2MessageMembershipWitness`, `getL2ToL1MembershipWitness`
36+
37+
**Fees / validators**
38+
- `getCurrentMinFees`, `getPredictedMinFees`, `getMaxPriorityFees`
39+
- `getValidatorsStats`, `getValidatorStats`
40+
41+
## `p2p_*` — p2p API (port 8080, no auth)
42+
43+
`P2PApiSchema` (`interfaces/server/p2p.ts`).
44+
- `getPeers`, `getEncodedEnr`
45+
- `getPendingTxs`, `getPendingTxCount`
46+
- `getCheckpointAttestationsForSlot`
47+
48+
## `aztecAdmin_*` — admin API (port 8880, API key required)
49+
50+
`AztecNodeAdminApiSchema` (`interfaces/client/aztec-node-admin.ts`). Legacy alias: `nodeAdmin_*`.
51+
- `getConfig`, `setConfig`
52+
- `pauseSync`, `resumeSync`, `pauseSequencer`, `resumeSequencer`
53+
- `rollbackTo`, `startSnapshotUpload`
54+
- `getSlashOffenses`, `reloadKeystore`
55+
56+
## `aztecDebug_*` — debug API (port 8080, only when node started with debug)
57+
58+
`AztecNodeDebugApiSchema` (`interfaces/client/aztec-node-debug.ts`). Legacy alias: `nodeDebug_*`.
59+
- `mineBlock`, `prove`
60+
- `warpL2TimeAtLeastTo`, `warpL2TimeAtLeastBy`
61+
- `registerContractFunctionSignatures`
62+
63+
## `prover_*` — prover-node API (port 8880, API key required; prover nodes only)
64+
65+
`ProverNodeApiSchema` (`interfaces/server/prover-node.ts`).
66+
- `getJobs`, `startProof`

0 commit comments

Comments
 (0)