Skip to content

Commit 3e51b30

Browse files
committed
fix: enable live Pudge registry commitments
1 parent 18b530b commit 3e51b30

9 files changed

Lines changed: 72 additions & 7 deletions

File tree

‎docs/wiki/Tutorial-12-Phase1-Registry-End-to-End.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ CellScript path first, then the generic artifact path.
1212

1313
Open `https://cellscript.dev/registry/submit`. The page does not expose a
1414
network selector. The production Registry is CKB mainnet-only. Pudge testing
15-
uses `https://testnet.cellscript.dev/registry`, with a different API origin,
15+
uses `https://testnet.registry.cellscript.dev/registry`, with a different API origin,
1616
database, object store, wallet connection state, and testnet-only evidence.
1717
Sandbox records disappear from discovery after 72 hours and their source bytes
1818
are purged after a 24-hour grace period; this does not erase Pudge chain history.

‎services/registry-api/README.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The Pudge test environment is a separate, ephemeral service:
1313

1414
- `https://api.testnet.registry.cellscript.dev` is the sandbox API;
1515
- `https://objects.testnet.registry.cellscript.dev` is its object origin;
16-
- `https://testnet.cellscript.dev/registry` is its `noindex` UI.
16+
- `https://testnet.registry.cellscript.dev/registry` is its `noindex` UI.
1717

1818
It uses a different Postgres volume, object volume, signing origin, wallet
1919
storage key, RPC identity, and Compose project. Do not put a network selector in
@@ -254,7 +254,11 @@ require `code_hash` to equal the data hash. Success appends hash-addressed
254254
evidence and sets only `deployment_status = chain_verified`.
255255

256256
`CKB_RPC_URL` configures the environment RPC. `CKB_MAINNET_RPC_URL` remains a
257-
production compatibility alias.
257+
production compatibility alias. The Docker deployment sets
258+
`CKB_RPC_MAX_RESPONSE_BYTES=8388608`: canonical secp256k1 DepGroup validation
259+
must read the genesis data Cell, whose JSON-RPC hex encoding exceeds the
260+
conservative 2 MiB library default. The API still enforces its 8 MiB hard
261+
ceiling and bounded RPC timeout.
258262

259263
## Registry Chain Commitments
260264

‎services/registry-api/deploy/docker-compose.production.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ services:
5555
STATIC_REGISTRY_ORIGIN: ${STATIC_REGISTRY_ORIGIN:-https://registry.cellscript.dev}
5656
CKB_MAINNET_RPC_URL: ${CKB_MAINNET_RPC_URL:-https://mainnet.ckb.dev/rpc}
5757
CKB_RPC_URL: ${CKB_RPC_URL:-https://mainnet.ckb.dev/rpc}
58+
CKB_RPC_MAX_RESPONSE_BYTES: "8388608"
5859
REGISTRY_TYPE_SCRIPT_JSON: ${REGISTRY_TYPE_SCRIPT_JSON:-}
5960
REGISTRY_TYPE_SCRIPT_CELL_DEP_JSON: ${REGISTRY_TYPE_SCRIPT_CELL_DEP_JSON:-}
6061
REGISTRY_COMMITMENT_LOCK_SCRIPT_JSON: ${REGISTRY_COMMITMENT_LOCK_SCRIPT_JSON:-}

‎services/registry-api/deploy/docker-compose.testnet.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ services:
4444
REGISTRY_ORIGIN: ${REGISTRY_TESTNET_ORIGIN:-https://api.testnet.registry.cellscript.dev}
4545
STATIC_REGISTRY_ORIGIN: ${STATIC_REGISTRY_TESTNET_ORIGIN:-https://objects.testnet.registry.cellscript.dev}
4646
CKB_RPC_URL: ${CKB_TESTNET_RPC_URL:-https://testnet.ckb.dev/rpc}
47+
CKB_RPC_MAX_RESPONSE_BYTES: "8388608"
4748
CKB_MIN_CONFIRMATIONS: "4"
4849
REGISTRY_TYPE_SCRIPT_JSON: ${REGISTRY_TESTNET_TYPE_SCRIPT_JSON:-}
4950
REGISTRY_TYPE_SCRIPT_CELL_DEP_JSON: ${REGISTRY_TESTNET_TYPE_SCRIPT_CELL_DEP_JSON:-}

‎services/registry-api/src/index.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,20 @@ async function ckbRpcRequest(
14081408
if (!response.ok) {
14091409
throw new ApiError(503, "ckb_rpc_unavailable", `CKB RPC returned HTTP ${response.status}`);
14101410
}
1411-
const rpc = assertPlainObject(await readBoundedRpcJson(response, options.maximum_bytes), "invalid_ckb_rpc_response");
1411+
let rpcBody: unknown;
1412+
try {
1413+
rpcBody = await readBoundedRpcJson(response, options.maximum_bytes);
1414+
} catch (error) {
1415+
if (error instanceof ApiError && error.code === "ckb_rpc_response_too_large") {
1416+
throw new ApiError(
1417+
error.status,
1418+
error.code,
1419+
`CKB RPC ${method} response exceeds the configured size limit`,
1420+
);
1421+
}
1422+
throw error;
1423+
}
1424+
const rpc = assertPlainObject(rpcBody, "invalid_ckb_rpc_response");
14121425
if (rpc["error"]) {
14131426
throw new ApiError(503, "ckb_rpc_error", `CKB RPC rejected ${method}`);
14141427
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { Env } from "./index";
2+
3+
type NodeCkbRpcEnv = Pick<
4+
Env,
5+
| "CKB_MAINNET_RPC_URL"
6+
| "CKB_RPC_URL"
7+
| "CKB_RPC_TIMEOUT_MS"
8+
| "CKB_RPC_MAX_RESPONSE_BYTES"
9+
| "CKB_DEP_GROUP_MAX_MEMBERS"
10+
>;
11+
12+
export function nodeCkbRpcEnv(
13+
processEnv: Readonly<Record<string, string | undefined>>,
14+
): Partial<NodeCkbRpcEnv> {
15+
return {
16+
...(processEnv["CKB_MAINNET_RPC_URL"] ? { CKB_MAINNET_RPC_URL: processEnv["CKB_MAINNET_RPC_URL"] } : {}),
17+
...(processEnv["CKB_RPC_URL"] ? { CKB_RPC_URL: processEnv["CKB_RPC_URL"] } : {}),
18+
...(processEnv["CKB_RPC_TIMEOUT_MS"] ? { CKB_RPC_TIMEOUT_MS: processEnv["CKB_RPC_TIMEOUT_MS"] } : {}),
19+
...(processEnv["CKB_RPC_MAX_RESPONSE_BYTES"]
20+
? { CKB_RPC_MAX_RESPONSE_BYTES: processEnv["CKB_RPC_MAX_RESPONSE_BYTES"] }
21+
: {}),
22+
...(processEnv["CKB_DEP_GROUP_MAX_MEMBERS"]
23+
? { CKB_DEP_GROUP_MAX_MEMBERS: processEnv["CKB_DEP_GROUP_MAX_MEMBERS"] }
24+
: {}),
25+
};
26+
}

‎services/registry-api/src/node-server.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { randomUUID } from "node:crypto";
66

77
import { createApp, type Env } from "./index";
88
import { FilesystemObjectStore } from "./filesystem-object-store";
9+
import { nodeCkbRpcEnv } from "./node-runtime-env";
910
import { SqlRegistryStore } from "./sql-store";
1011

1112
const port = integerEnv("PORT", 8787, 1, 65_535);
@@ -40,8 +41,7 @@ const env: Env = {
4041
...(process.env["NAMESPACE_CLAIM_COOLDOWN_SECONDS"]
4142
? { NAMESPACE_CLAIM_COOLDOWN_SECONDS: process.env["NAMESPACE_CLAIM_COOLDOWN_SECONDS"] }
4243
: {}),
43-
...(process.env["CKB_MAINNET_RPC_URL"] ? { CKB_MAINNET_RPC_URL: process.env["CKB_MAINNET_RPC_URL"] } : {}),
44-
...(process.env["CKB_RPC_URL"] ? { CKB_RPC_URL: process.env["CKB_RPC_URL"] } : {}),
44+
...nodeCkbRpcEnv(process.env),
4545
...(process.env["REGISTRY_TYPE_SCRIPT_JSON"]
4646
? { REGISTRY_TYPE_SCRIPT_JSON: process.env["REGISTRY_TYPE_SCRIPT_JSON"] }
4747
: {}),

‎services/registry-api/test/registry-api.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
type SnapshotWriter,
4444
} from "../src/index";
4545
import type { PackageVersionRecord } from "../src/store";
46+
import { nodeCkbRpcEnv } from "../src/node-runtime-env";
4647

4748
const now = new Date("2026-06-23T12:00:00Z");
4849
const ckbPrivateKey = Uint8Array.from({ length: 32 }, (_, index) => index === 31 ? 7 : 0);
@@ -51,6 +52,25 @@ const reproducerPublicKeys = {
5152
"builder-b": "p256-spki:MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEcZljLFjOhAdes8hm88phoxoMmsya3kKGRbmwjtH1eW4tWV_sn81NRL5EwkrqhjPuYxXfEbYBfuSVPMVD3at7hQ",
5253
} as const;
5354

55+
describe("Node CKB RPC environment", () => {
56+
it("forwards every bounded RPC control used by the shared API", () => {
57+
expect(nodeCkbRpcEnv({
58+
CKB_MAINNET_RPC_URL: "https://mainnet.ckb.dev/rpc",
59+
CKB_RPC_URL: "https://testnet.ckb.dev/rpc",
60+
CKB_RPC_TIMEOUT_MS: "15000",
61+
CKB_RPC_MAX_RESPONSE_BYTES: "8388608",
62+
CKB_DEP_GROUP_MAX_MEMBERS: "256",
63+
UNRELATED_SECRET: "must-not-pass-through",
64+
})).toEqual({
65+
CKB_MAINNET_RPC_URL: "https://mainnet.ckb.dev/rpc",
66+
CKB_RPC_URL: "https://testnet.ckb.dev/rpc",
67+
CKB_RPC_TIMEOUT_MS: "15000",
68+
CKB_RPC_MAX_RESPONSE_BYTES: "8388608",
69+
CKB_DEP_GROUP_MAX_MEMBERS: "256",
70+
});
71+
});
72+
});
73+
5474
function bytesHex(value: Uint8Array): string {
5575
return `0x${[...value].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
5676
}

0 commit comments

Comments
 (0)