Skip to content

Commit 5ca22ae

Browse files
chore: add local-rpc mode as default for CLI users (#1824)
add local-rpc mode as default for cli users fix build.sh and install.sh add deprecated getCachedActiveStateTreeInfo for backward compatibility update changelog fix using our cli fork reliably released js pkgs chore: adapt cli chore: bump cli version and constant to 0.27.0 released 0.26.0 fix install.sh for ci fix local proving-keys
1 parent 69a499c commit 5ca22ae

File tree

20 files changed

+233
-110
lines changed

20 files changed

+233
-110
lines changed

cli/package.json

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lightprotocol/zk-compression-cli",
3-
"version": "0.25.0",
3+
"version": "0.27.0",
44
"description": "ZK Compression: Secure Scaling on Solana",
55
"maintainers": [
66
{
@@ -17,54 +17,31 @@
1717
"/accounts",
1818
"/bin",
1919
"!bin/cargo-generate",
20+
"!/bin/**/*.vkey",
21+
"!/bin/proving-keys/*.key",
22+
"/bin/proving-keys/combined_26_1_1.key",
23+
"/bin/proving-keys/combined_26_1_2.key",
24+
"/bin/proving-keys/combined_26_2_1.key",
25+
"/bin/proving-keys/combined_32_40_1_1.key",
26+
"/bin/proving-keys/combined_32_40_1_2.key",
27+
"/bin/proving-keys/combined_32_40_2_1.key",
28+
"/bin/proving-keys/inclusion_32_1.key",
29+
"/bin/proving-keys/inclusion_32_2.key",
30+
"/bin/proving-keys/inclusion_32_3.key",
31+
"/bin/proving-keys/inclusion_32_4.key",
32+
"/bin/proving-keys/mainnet_inclusion_26_1.key",
33+
"/bin/proving-keys/mainnet_inclusion_26_2.key",
34+
"/bin/proving-keys/mainnet_inclusion_26_3.key",
35+
"/bin/proving-keys/mainnet_inclusion_26_4.key",
36+
"/bin/proving-keys/non-inclusion_26_1.key",
37+
"/bin/proving-keys/non-inclusion_26_2.key",
38+
"/bin/proving-keys/non-inclusion_40_1.key",
39+
"/bin/proving-keys/non-inclusion_40_2.key",
2040
"/dist",
2141
"/test_bin",
2242
"./config.json",
2343
"/npm-shrinkwrap.json",
24-
"/oclif.manifest.json",
25-
"bin/proving-keys/combined_26_1_1.key",
26-
"bin/proving-keys/combined_26_1_1.vkey",
27-
"bin/proving-keys/combined_26_1_10.key",
28-
"bin/proving-keys/combined_26_1_10.vkey",
29-
"bin/proving-keys/combined_26_10_1.key",
30-
"bin/proving-keys/combined_26_10_1.vkey",
31-
"bin/proving-keys/combined_26_10_10.key",
32-
"bin/proving-keys/combined_26_10_10.vkey",
33-
"bin/proving-keys/inclusion_26_1.key",
34-
"bin/proving-keys/inclusion_26_1.vkey",
35-
"bin/proving-keys/inclusion_26_10.key",
36-
"bin/proving-keys/inclusion_26_10.vkey",
37-
"bin/proving-keys/non-inclusion_26_1.key",
38-
"bin/proving-keys/non-inclusion_26_1.vkey",
39-
"bin/proving-keys/non-inclusion_26_10.key",
40-
"bin/proving-keys/non-inclusion_26_10.vkey",
41-
"!bin/proving-keys/update_26_10.key",
42-
"!bin/proving-keys/update_26_10.vkey",
43-
"!bin/proving-keys/address-append_40_1.key",
44-
"!bin/proving-keys/address-append_40_1.vkey",
45-
"!bin/proving-keys/address-append_40_10.key",
46-
"!bin/proving-keys/address-append_40_10.vkey",
47-
"!bin/proving-keys/append-with-proofs_26_10.key",
48-
"!bin/proving-keys/append-with-proofs_26_10.vkey",
49-
"!bin/proving-keys/append-with-subtrees_26_10.key",
50-
"!bin/proving-keys/append-with-subtrees_26_10.vkey",
51-
"!bin/proving-keys/non-inclusion_40_1.vkey",
52-
"!bin/proving-keys/non-inclusion_40_2.vkey",
53-
"!bin/proving-keys/non-inclusion_40_3.vkey",
54-
"!bin/proving-keys/non-inclusion_40_4.vkey",
55-
"!bin/proving-keys/non-inclusion_40_8.vkey",
56-
"!bin/proving-keys/mainnet_inclusion_26_1.key",
57-
"!bin/proving-keys/mainnet_inclusion_26_1.vkey",
58-
"!bin/proving-keys/mainnet_inclusion_26_2.vkey",
59-
"!bin/proving-keys/mainnet_inclusion_26_3.vkey",
60-
"!bin/proving-keys/mainnet_inclusion_26_4.vkey",
61-
"!bin/proving-keys/mainnet_inclusion_26_8.vkey",
62-
"!bin/proving-keys/inclusion_32_1.key",
63-
"!bin/proving-keys/inclusion_32_1.vkey",
64-
"!bin/proving-keys/inclusion_32_2.vkey",
65-
"!bin/proving-keys/inclusion_32_3.vkey",
66-
"!bin/proving-keys/inclusion_32_4.vkey",
67-
"!bin/proving-keys/inclusion_32_8.vkey"
44+
"/oclif.manifest.json"
6845
],
6946
"dependencies": {
7047
"@coral-xyz/anchor": "0.29.0",
@@ -133,14 +110,16 @@
133110
},
134111
"scripts": {
135112
"add-bins": "./scripts/copyLocalProgramBinaries.sh && scripts/buildProver.sh",
113+
"add-bins-release": "./scripts/copyLocalProgramBinaries.sh && scripts/buildProver.sh --release-only",
136114
"postinstall": "[ -d ./bin ] && find ./bin -type f -exec chmod +x {} + || echo 'No bin directory found, skipping chmod'",
137115
"build": "shx rm -rf dist && pnpm tsc -p tsconfig.json && pnpm tsc -p tsconfig.test.json && pnpm add-bins",
116+
"build-release": "shx rm -rf dist && pnpm tsc -p tsconfig.json && pnpm tsc -p tsconfig.test.json && pnpm add-bins-release",
138117
"format": "pnpm prettier --write \"src/**/*.{ts,js}\" \"test/**/*.{ts,js}\" -w",
139118
"format:check": "pnpm prettier \"src/**/*{ts,js}\" \"test/**/*.{ts,js}\" --check",
140119
"lint": "eslint . --ext .ts",
141120
"lint:fix": "eslint . --fix",
142121
"postpack": "shx rm -f oclif.manifest.json",
143-
"prepack": "pnpm build && oclif manifest && oclif readme",
122+
"prepack": "pnpm build-release && oclif manifest && oclif readme",
144123
"test-utils": "mocha ./test/utils/index.test.ts -t 10000000 --exit",
145124
"test-config": "mocha ./test/commands/config/index.test.ts -t 10000000 --exit",
146125
"test-create-mint": "mocha ./test/commands/create-mint/index.test.ts -t 10000000 --exit",

cli/scripts/buildProver.sh

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,26 @@ build_prover() {
66
GOOS=$1 GOARCH=$2 go build -o "$3"
77
}
88

9+
# Parse command line arguments
10+
RELEASE_ONLY=false
11+
while [[ $# -gt 0 ]]; do
12+
case $1 in
13+
--release-only)
14+
RELEASE_ONLY=true
15+
shift
16+
;;
17+
*)
18+
echo "Unknown option: $1"
19+
echo "Usage: $0 [--release-only]"
20+
exit 1
21+
;;
22+
esac
23+
done
24+
925
root_dir="$(git rev-parse --show-toplevel)"
1026
gnark_dir="${root_dir}/prover/server"
1127
out_dir="${root_dir}/cli/bin"
28+
cli_dir="${root_dir}/cli"
1229

1330
if [ ! -e "$out_dir" ]; then
1431
mkdir -p "$out_dir"
@@ -21,7 +38,41 @@ if [ ! -d "${gnark_dir}/proving-keys" ] || [ -z "$(ls -A "${gnark_dir}/proving-k
2138
exit 1
2239
fi
2340

24-
cp -r "${gnark_dir}/proving-keys" "$out_dir"
41+
# Create proving-keys directory in output
42+
mkdir -p "$out_dir/proving-keys"
43+
44+
if [ "$RELEASE_ONLY" = true ]; then
45+
echo "Release mode: copying only keys listed in package.json"
46+
# Dynamically read .key files from package.json files field
47+
# Extract all lines containing "/bin/proving-keys/" and ".key"
48+
key_files=$(node -e "
49+
const pkg = require('${cli_dir}/package.json');
50+
const keyFiles = pkg.files
51+
.filter(f => f.includes('/bin/proving-keys/') && f.endsWith('.key'))
52+
.map(f => f.split('/').pop());
53+
console.log(keyFiles.join(' '));
54+
")
55+
56+
# Copy only the specified .key files
57+
for key_file in $key_files; do
58+
if [ -f "${gnark_dir}/proving-keys/${key_file}" ]; then
59+
cp "${gnark_dir}/proving-keys/${key_file}" "$out_dir/proving-keys/${key_file}"
60+
echo "Copied (release): ${key_file}"
61+
else
62+
echo "WARNING: ${key_file} not found in ${gnark_dir}/proving-keys"
63+
fi
64+
done
65+
else
66+
echo "Development mode: copying ALL .key files"
67+
# Copy ALL .key files from prover directory
68+
for key_file in "${gnark_dir}/proving-keys"/*.key; do
69+
if [ -f "$key_file" ]; then
70+
filename=$(basename "$key_file")
71+
cp "$key_file" "$out_dir/proving-keys/$filename"
72+
echo "Copied (all): $filename"
73+
fi
74+
done
75+
fi
2576

2677
cd "$gnark_dir"
2778

cli/src/commands/start-prover/index.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ class StartProver extends Command {
1717
}),
1818
"run-mode": Flags.string({
1919
description:
20-
"Specify the running mode (forester, forester-test, rpc, full, or full-test)",
21-
options: ["rpc", "forester", "forester-test", "full", "full-test"],
20+
"Specify the running mode (local-rpc, forester, forester-test, rpc, or full). Default: local-rpc",
21+
options: [
22+
"local-rpc",
23+
"rpc",
24+
"forester",
25+
"forester-test",
26+
"full",
27+
"full-test",
28+
],
2229
required: false,
2330
}),
2431
circuit: Flags.string({
@@ -63,13 +70,16 @@ class StartProver extends Command {
6370
const proverPort = flags["prover-port"] || 3001;
6471
const force = flags["force"] || false;
6572
const redisUrl = flags["redisUrl"] || process.env.REDIS_URL || undefined;
66-
await startProver(
67-
proverPort,
68-
flags["run-mode"],
69-
flags["circuit"],
70-
force,
71-
redisUrl,
72-
);
73+
74+
// TODO: remove this workaround.
75+
// Force local-rpc mode when rpc is specified
76+
let runMode = flags["run-mode"];
77+
if (runMode === "rpc") {
78+
runMode = "local-rpc";
79+
this.log("Note: Running in local-rpc mode instead of rpc mode");
80+
}
81+
82+
await startProver(proverPort, runMode, flags["circuit"], force, redisUrl);
7383

7484
const healthy = await healthCheck(proverPort, 10, 1000);
7585
loader.stop();

cli/src/commands/test-validator/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ class SetupCommand extends Command {
7777
}),
7878
"prover-run-mode": Flags.string({
7979
description:
80-
"Specify the running mode for the prover (forester, forester-test, rpc, or full)",
80+
"Specify the running mode for the prover (local-rpc, forester, forester-test, rpc, or full). Default: local-rpc",
8181
options: [
82+
"local-rpc",
8283
"rpc",
8384
"forester",
8485
"forester-test",

cli/src/utils/constants.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ export const SOLANA_VALIDATOR_PROCESS_NAME = "solana-test-validator";
1919
export const LIGHT_PROVER_PROCESS_NAME = "light-prover";
2020
export const INDEXER_PROCESS_NAME = "photon";
2121

22-
export const PHOTON_VERSION = "0.50.0";
22+
export const PHOTON_VERSION = "0.50.1";
23+
24+
// Set these to override Photon requirements with a specific git commit:
25+
export const USE_PHOTON_FROM_GIT = true; // If true, will show git install command instead of crates.io.
26+
export const PHOTON_GIT_REPO = "https://github.com/lightprotocol/photon.git";
27+
export const PHOTON_GIT_COMMIT = "49b7e7f0d668babbc4d65fe8a0a7236df76f75a8"; // If empty, will use main branch.
2328

2429
export const LIGHT_PROTOCOL_PROGRAMS_DIR_ENV = "LIGHT_PROTOCOL_PROGRAMS_DIR";
2530
export const BASE_PATH = "../../bin/";
@@ -29,7 +34,7 @@ export const SOLANA_SDK_VERSION = "2.2";
2934
export const ANCHOR_VERSION = "0.31.1";
3035
export const COMPRESSED_PROGRAM_TEMPLATE_TAG = "v0.3.1";
3136
export const TOKIO_VERSION = "1.36.0";
32-
export const LIGHT_CLI_VERSION = "0.26.0";
37+
export const LIGHT_CLI_VERSION = "0.27.0";
3338
export const SOLANA_CLI_VERSION = "2.2.15";
3439

3540
export const LIGHT_HASHER_VERSION = "3.1.0";

cli/src/utils/initTestEnv.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export async function initTestEnv({
109109
photonDatabaseUrl?: string;
110110
limitLedgerSize?: number;
111111
proverRunMode?:
112+
| "local-rpc"
112113
| "inclusion"
113114
| "non-inclusion"
114115
| "forester"

cli/src/utils/processPhotonIndexer.ts

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
11
import which from "which";
22
import { killProcess, spawnBinary, waitForServers } from "./process";
3-
import { INDEXER_PROCESS_NAME, PHOTON_VERSION } from "./constants";
3+
import {
4+
INDEXER_PROCESS_NAME,
5+
PHOTON_VERSION,
6+
USE_PHOTON_FROM_GIT,
7+
PHOTON_GIT_REPO,
8+
PHOTON_GIT_COMMIT,
9+
} from "./constants";
410
import { exec } from "node:child_process";
511
import * as util from "node:util";
12+
import { exit } from "node:process";
13+
14+
const execAsync = util.promisify(exec);
15+
16+
async function isExpectedPhotonVersion(
17+
requiredVersion: string,
18+
): Promise<boolean> {
19+
try {
20+
const { stdout } = await execAsync("photon --version");
21+
const version = stdout.trim();
22+
return version.includes(requiredVersion);
23+
} catch (error) {
24+
console.error("Error checking Photon version:", error);
25+
return false;
26+
}
27+
}
28+
29+
function getPhotonInstallMessage(): string {
30+
if (USE_PHOTON_FROM_GIT && PHOTON_GIT_COMMIT) {
31+
return `\nLatest Photon indexer not found. Please install it by running: "cargo install --git ${PHOTON_GIT_REPO} --rev ${PHOTON_GIT_COMMIT} --locked"`;
32+
} else if (USE_PHOTON_FROM_GIT) {
33+
return `\nLatest Photon indexer not found. Please install it by running: "cargo install --git ${PHOTON_GIT_REPO} --locked"`;
34+
} else {
35+
return `\nLatest Photon indexer not found. Please install it by running: "cargo install photon-indexer --version ${PHOTON_VERSION} --locked"`;
36+
}
37+
}
638

739
export async function startIndexer(
840
rpcUrl: string,
@@ -16,9 +48,8 @@ export async function startIndexer(
1648
resolvedOrNull === null ||
1749
(checkPhotonVersion && !(await isExpectedPhotonVersion(PHOTON_VERSION)))
1850
) {
19-
const message = `Photon indexer not found. Please install it by running "cargo install photon-indexer --version ${PHOTON_VERSION} --locked"`;
20-
console.log(message);
21-
throw new Error(message);
51+
console.log(getPhotonInstallMessage());
52+
return exit(1);
2253
} else {
2354
console.log("Starting indexer...");
2455
const args: string[] = [
@@ -39,17 +70,3 @@ export async function startIndexer(
3970
export async function killIndexer() {
4071
await killProcess(INDEXER_PROCESS_NAME);
4172
}
42-
43-
const execAsync = util.promisify(exec);
44-
async function isExpectedPhotonVersion(
45-
requiredVersion: string,
46-
): Promise<boolean> {
47-
try {
48-
const { stdout } = await execAsync("photon --version");
49-
const version = stdout.trim();
50-
return version.includes(requiredVersion);
51-
} catch (error) {
52-
console.error("Error checking Photon version:", error);
53-
return false;
54-
}
55-
}

cli/src/utils/processProverServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export async function startProver(
122122
}
123123

124124
if ((!circuits || circuits.length === 0) && runMode == null) {
125-
runMode = "rpc";
125+
runMode = "local-rpc";
126126
args.push("--run-mode", runMode);
127127
console.log(`Starting prover with fallback ${runMode} mode...`);
128128
}

js/compressed-token/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lightprotocol/compressed-token",
3-
"version": "0.21.0",
3+
"version": "0.22.0",
44
"description": "JS client to interact with the compressed-token program",
55
"sideEffects": false,
66
"main": "dist/cjs/node/index.cjs",
@@ -85,7 +85,7 @@
8585
"test:unit:all:v1": "LIGHT_PROTOCOL_VERSION=V1 vitest run tests/unit --reporter=verbose",
8686
"test:unit:all:v2": "LIGHT_PROTOCOL_VERSION=V2 vitest run tests/unit --reporter=verbose",
8787
"test-all:verbose": "vitest run --reporter=verbose",
88-
"test-validator": "./../../cli/test_bin/run test-validator --prover-run-mode rpc",
88+
"test-validator": "./../../cli/test_bin/run test-validator",
8989
"test-validator-skip-prover": "./../../cli/test_bin/run test-validator --skip-prover",
9090
"test:e2e:create-mint": "pnpm test-validator && NODE_OPTIONS='--trace-deprecation' vitest run tests/e2e/create-mint.test.ts --reporter=verbose",
9191
"test:e2e:layout": "vitest run tests/e2e/layout.test.ts --reporter=verbose --bail=1",

0 commit comments

Comments
 (0)