Skip to content

Commit 427e726

Browse files
add local-rpc mode as default for cli users
wip fix build.sh fix install.sh add deprecated getCachedActiveStateTreeInfo for backward compatibility update changelog wip wip fix using our cli fork reliably fix wip released js pkgs wip chore: adapt cli chore: bump cli version and constant to 0.27.0 verbose wip released 0.26.0 wip fix install.sh for ci
1 parent 1071f94 commit 427e726

File tree

20 files changed

+199
-109
lines changed

20 files changed

+199
-109
lines changed

cli/package.json

Lines changed: 21 additions & 45 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,30 @@
1717
"/accounts",
1818
"/bin",
1919
"!bin/cargo-generate",
20+
"!/bin/**/*.vkey",
21+
"/bin/proving-keys/combined_26_1_1.key",
22+
"/bin/proving-keys/combined_26_1_2.key",
23+
"/bin/proving-keys/combined_26_2_1.key",
24+
"/bin/proving-keys/combined_32_40_1_1.key",
25+
"/bin/proving-keys/combined_32_40_1_2.key",
26+
"/bin/proving-keys/combined_32_40_2_1.key",
27+
"/bin/proving-keys/inclusion_32_1.key",
28+
"/bin/proving-keys/inclusion_32_2.key",
29+
"/bin/proving-keys/inclusion_32_3.key",
30+
"/bin/proving-keys/inclusion_32_4.key",
31+
"/bin/proving-keys/mainnet_inclusion_26_1.key",
32+
"/bin/proving-keys/mainnet_inclusion_26_2.key",
33+
"/bin/proving-keys/mainnet_inclusion_26_3.key",
34+
"/bin/proving-keys/mainnet_inclusion_26_4.key",
35+
"/bin/proving-keys/non-inclusion_26_1.key",
36+
"/bin/proving-keys/non-inclusion_26_2.key",
37+
"/bin/proving-keys/non-inclusion_40_1.key",
38+
"/bin/proving-keys/non-inclusion_40_2.key",
2039
"/dist",
2140
"/test_bin",
2241
"./config.json",
2342
"/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"
43+
"/oclif.manifest.json"
6844
],
6945
"dependencies": {
7046
"@coral-xyz/anchor": "0.29.0",

cli/scripts/buildProver.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ build_prover() {
99
root_dir="$(git rev-parse --show-toplevel)"
1010
gnark_dir="${root_dir}/prover/server"
1111
out_dir="${root_dir}/cli/bin"
12+
cli_dir="${root_dir}/cli"
1213

1314
if [ ! -e "$out_dir" ]; then
1415
mkdir -p "$out_dir"
@@ -21,7 +22,27 @@ if [ ! -d "${gnark_dir}/proving-keys" ] || [ -z "$(ls -A "${gnark_dir}/proving-k
2122
exit 1
2223
fi
2324

24-
cp -r "${gnark_dir}/proving-keys" "$out_dir"
25+
# Create proving-keys directory in output
26+
mkdir -p "$out_dir/proving-keys"
27+
28+
# Dynamically read .key files from package.json files field
29+
# Extract all lines containing "/bin/proving-keys/" and ".key"
30+
key_files=$(node -e "
31+
const pkg = require('${cli_dir}/package.json');
32+
const keyFiles = pkg.files
33+
.filter(f => f.includes('/bin/proving-keys/') && f.endsWith('.key'))
34+
.map(f => f.split('/').pop());
35+
console.log(keyFiles.join(' '));
36+
")
37+
38+
# Copy only the specified .key files
39+
for key_file in $key_files; do
40+
if [ -f "${gnark_dir}/proving-keys/${key_file}" ]; then
41+
cp "${gnark_dir}/proving-keys/${key_file}" "$out_dir/proving-keys/${key_file}"
42+
else
43+
echo "WARNING: ${key_file} not found in ${gnark_dir}/proving-keys"
44+
fi
45+
done
2546

2647
cd "$gnark_dir"
2748

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",

js/compressed-token/src/actions/create-mint.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import {
1515
Rpc,
1616
buildAndSignTx,
17+
dedupeSigner,
1718
sendAndConfirmTx,
1819
} from '@lightprotocol/stateless.js';
1920

@@ -59,26 +60,27 @@ export async function createMint(
5960
feePayer: payer.publicKey,
6061
mint: keypair.publicKey,
6162
decimals,
62-
authority: getPublicKey(mintAuthority)!,
63-
freezeAuthority: getPublicKey(freezeAuthority),
63+
authority:
64+
'secretKey' in mintAuthority
65+
? mintAuthority.publicKey
66+
: mintAuthority,
67+
freezeAuthority:
68+
freezeAuthority && 'secretKey' in freezeAuthority
69+
? freezeAuthority.publicKey
70+
: (freezeAuthority ?? null),
6471
rentExemptBalance,
6572
tokenProgramId: resolvedTokenProgramId,
6673
});
6774

6875
const { blockhash } = await rpc.getLatestBlockhash();
6976

70-
// Get required additional signers that are Keypairs, not the payer.
71-
const additionalSigners = [mintAuthority, freezeAuthority]
72-
.filter(
77+
const additionalSigners = dedupeSigner(
78+
payer,
79+
[mintAuthority, freezeAuthority].filter(
7380
(signer): signer is Signer =>
74-
signer instanceof Keypair &&
75-
!signer.publicKey.equals(payer.publicKey),
76-
)
77-
.filter(
78-
(signer, index, array) =>
79-
array.findIndex(s => s.publicKey.equals(signer.publicKey)) ===
80-
index,
81-
);
81+
signer != undefined && 'secretKey' in signer,
82+
),
83+
);
8284

8385
const tx = buildAndSignTx(ixs, payer, blockhash, [
8486
...additionalSigners,
@@ -88,8 +90,3 @@ export async function createMint(
8890

8991
return { mint: keypair.publicKey, transactionSignature: txId };
9092
}
91-
92-
const getPublicKey = (
93-
signer: PublicKey | Signer | undefined,
94-
): PublicKey | null =>
95-
signer instanceof PublicKey ? signer : signer?.publicKey || null;

0 commit comments

Comments
 (0)