Skip to content

chore: add c-token wrappers for example-compressed-claim #1763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ members = [
"sdk-libs/sdk",
"sdk-libs/sdk-pinocchio",
"sdk-libs/sdk-types",
"sdk-libs/compressed-token-sdk",
"sdk-libs/compressed-token-client",
"sdk-libs/photon-api",
"sdk-libs/program-test",
"xtask",
Expand Down Expand Up @@ -175,6 +177,10 @@ account-compression = { path = "programs/account-compression", version = "2.0.0"
light-compressed-token = { path = "programs/compressed-token", version = "2.0.0", features = [
"cpi",
] }
light-compressed-token-client = { path = "sdk-libs/compressed-token-client", version = "0.1.0" }
light-system-program = { path = "anchor-programs/system", version = "2.0.0", features = [
"cpi",
] }
light-system-program-anchor = { path = "anchor-programs/system", version = "2.0.0", features = [
"cpi",
] }
Expand Down
66 changes: 21 additions & 45 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lightprotocol/zk-compression-cli",
"version": "0.25.0",
"version": "0.27.0",
"description": "ZK Compression: Secure Scaling on Solana",
"maintainers": [
{
Expand All @@ -17,54 +17,30 @@
"/accounts",
"/bin",
"!bin/cargo-generate",
"!/bin/**/*.vkey",
"/bin/proving-keys/combined_26_1_1.key",
"/bin/proving-keys/combined_26_1_2.key",
"/bin/proving-keys/combined_26_2_1.key",
"/bin/proving-keys/combined_32_40_1_1.key",
"/bin/proving-keys/combined_32_40_1_2.key",
"/bin/proving-keys/combined_32_40_2_1.key",
"/bin/proving-keys/inclusion_32_1.key",
"/bin/proving-keys/inclusion_32_2.key",
"/bin/proving-keys/inclusion_32_3.key",
"/bin/proving-keys/inclusion_32_4.key",
"/bin/proving-keys/mainnet_inclusion_26_1.key",
"/bin/proving-keys/mainnet_inclusion_26_2.key",
"/bin/proving-keys/mainnet_inclusion_26_3.key",
"/bin/proving-keys/mainnet_inclusion_26_4.key",
"/bin/proving-keys/non-inclusion_26_1.key",
"/bin/proving-keys/non-inclusion_26_2.key",
"/bin/proving-keys/non-inclusion_40_1.key",
"/bin/proving-keys/non-inclusion_40_2.key",
"/dist",
"/test_bin",
"./config.json",
"/npm-shrinkwrap.json",
"/oclif.manifest.json",
"bin/proving-keys/combined_26_1_1.key",
"bin/proving-keys/combined_26_1_1.vkey",
"bin/proving-keys/combined_26_1_10.key",
"bin/proving-keys/combined_26_1_10.vkey",
"bin/proving-keys/combined_26_10_1.key",
"bin/proving-keys/combined_26_10_1.vkey",
"bin/proving-keys/combined_26_10_10.key",
"bin/proving-keys/combined_26_10_10.vkey",
"bin/proving-keys/inclusion_26_1.key",
"bin/proving-keys/inclusion_26_1.vkey",
"bin/proving-keys/inclusion_26_10.key",
"bin/proving-keys/inclusion_26_10.vkey",
"bin/proving-keys/non-inclusion_26_1.key",
"bin/proving-keys/non-inclusion_26_1.vkey",
"bin/proving-keys/non-inclusion_26_10.key",
"bin/proving-keys/non-inclusion_26_10.vkey",
"!bin/proving-keys/update_26_10.key",
"!bin/proving-keys/update_26_10.vkey",
"!bin/proving-keys/address-append_40_1.key",
"!bin/proving-keys/address-append_40_1.vkey",
"!bin/proving-keys/address-append_40_10.key",
"!bin/proving-keys/address-append_40_10.vkey",
"!bin/proving-keys/append-with-proofs_26_10.key",
"!bin/proving-keys/append-with-proofs_26_10.vkey",
"!bin/proving-keys/append-with-subtrees_26_10.key",
"!bin/proving-keys/append-with-subtrees_26_10.vkey",
"!bin/proving-keys/non-inclusion_40_1.vkey",
"!bin/proving-keys/non-inclusion_40_2.vkey",
"!bin/proving-keys/non-inclusion_40_3.vkey",
"!bin/proving-keys/non-inclusion_40_4.vkey",
"!bin/proving-keys/non-inclusion_40_8.vkey",
"!bin/proving-keys/mainnet_inclusion_26_1.key",
"!bin/proving-keys/mainnet_inclusion_26_1.vkey",
"!bin/proving-keys/mainnet_inclusion_26_2.vkey",
"!bin/proving-keys/mainnet_inclusion_26_3.vkey",
"!bin/proving-keys/mainnet_inclusion_26_4.vkey",
"!bin/proving-keys/mainnet_inclusion_26_8.vkey",
"!bin/proving-keys/inclusion_32_1.key",
"!bin/proving-keys/inclusion_32_1.vkey",
"!bin/proving-keys/inclusion_32_2.vkey",
"!bin/proving-keys/inclusion_32_3.vkey",
"!bin/proving-keys/inclusion_32_4.vkey",
"!bin/proving-keys/inclusion_32_8.vkey"
"/oclif.manifest.json"
],
"dependencies": {
"@coral-xyz/anchor": "0.29.0",
Expand Down
23 changes: 22 additions & 1 deletion cli/scripts/buildProver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ build_prover() {
root_dir="$(git rev-parse --show-toplevel)"
gnark_dir="${root_dir}/prover/server"
out_dir="${root_dir}/cli/bin"
cli_dir="${root_dir}/cli"

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

cp -r "${gnark_dir}/proving-keys" "$out_dir"
# Create proving-keys directory in output
mkdir -p "$out_dir/proving-keys"

# Dynamically read .key files from package.json files field
# Extract all lines containing "/bin/proving-keys/" and ".key"
key_files=$(node -e "
const pkg = require('${cli_dir}/package.json');
const keyFiles = pkg.files
.filter(f => f.includes('/bin/proving-keys/') && f.endsWith('.key'))
.map(f => f.split('/').pop());
console.log(keyFiles.join(' '));
")

# Copy only the specified .key files
for key_file in $key_files; do
if [ -f "${gnark_dir}/proving-keys/${key_file}" ]; then
cp "${gnark_dir}/proving-keys/${key_file}" "$out_dir/proving-keys/${key_file}"
else
echo "WARNING: ${key_file} not found in ${gnark_dir}/proving-keys"
fi
done

cd "$gnark_dir"

Expand Down
28 changes: 19 additions & 9 deletions cli/src/commands/start-prover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ class StartProver extends Command {
}),
"run-mode": Flags.string({
description:
"Specify the running mode (forester, forester-test, rpc, full, or full-test)",
options: ["rpc", "forester", "forester-test", "full", "full-test"],
"Specify the running mode (local-rpc, forester, forester-test, rpc, or full). Default: local-rpc",
options: [
"local-rpc",
"rpc",
"forester",
"forester-test",
"full",
"full-test",
],
required: false,
}),
circuit: Flags.string({
Expand Down Expand Up @@ -63,13 +70,16 @@ class StartProver extends Command {
const proverPort = flags["prover-port"] || 3001;
const force = flags["force"] || false;
const redisUrl = flags["redisUrl"] || process.env.REDIS_URL || undefined;
await startProver(
proverPort,
flags["run-mode"],
flags["circuit"],
force,
redisUrl,
);

// TODO: remove this workaround.
// Force local-rpc mode when rpc is specified
let runMode = flags["run-mode"];
if (runMode === "rpc") {
runMode = "local-rpc";
this.log("Note: Running in local-rpc mode instead of rpc mode");
}

await startProver(proverPort, runMode, flags["circuit"], force, redisUrl);

const healthy = await healthCheck(proverPort, 10, 1000);
loader.stop();
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/test-validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ class SetupCommand extends Command {
}),
"prover-run-mode": Flags.string({
description:
"Specify the running mode for the prover (forester, forester-test, rpc, or full)",
"Specify the running mode for the prover (local-rpc, forester, forester-test, rpc, or full). Default: local-rpc",
options: [
"local-rpc",
"rpc",
"forester",
"forester-test",
Expand Down
9 changes: 7 additions & 2 deletions cli/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export const SOLANA_VALIDATOR_PROCESS_NAME = "solana-test-validator";
export const LIGHT_PROVER_PROCESS_NAME = "light-prover";
export const INDEXER_PROCESS_NAME = "photon";

export const PHOTON_VERSION = "0.50.0";
export const PHOTON_VERSION = "0.50.1";

// Set these to override Photon requirements with a specific git commit:
export const USE_PHOTON_FROM_GIT = true; // If true, will show git install command instead of crates.io.
export const PHOTON_GIT_REPO = "https://github.com/lightprotocol/photon.git";
export const PHOTON_GIT_COMMIT = "49b7e7f0d668babbc4d65fe8a0a7236df76f75a8"; // If empty, will use main branch.

export const LIGHT_PROTOCOL_PROGRAMS_DIR_ENV = "LIGHT_PROTOCOL_PROGRAMS_DIR";
export const BASE_PATH = "../../bin/";
Expand All @@ -29,7 +34,7 @@ export const SOLANA_SDK_VERSION = "2.2";
export const ANCHOR_VERSION = "0.31.1";
export const COMPRESSED_PROGRAM_TEMPLATE_TAG = "v0.3.1";
export const TOKIO_VERSION = "1.36.0";
export const LIGHT_CLI_VERSION = "0.26.0";
export const LIGHT_CLI_VERSION = "0.27.0";
export const SOLANA_CLI_VERSION = "2.2.15";

export const LIGHT_HASHER_VERSION = "3.1.0";
Expand Down
1 change: 1 addition & 0 deletions cli/src/utils/initTestEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export async function initTestEnv({
photonDatabaseUrl?: string;
limitLedgerSize?: number;
proverRunMode?:
| "local-rpc"
| "inclusion"
| "non-inclusion"
| "forester"
Expand Down
53 changes: 35 additions & 18 deletions cli/src/utils/processPhotonIndexer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
import which from "which";
import { killProcess, spawnBinary, waitForServers } from "./process";
import { INDEXER_PROCESS_NAME, PHOTON_VERSION } from "./constants";
import {
INDEXER_PROCESS_NAME,
PHOTON_VERSION,
USE_PHOTON_FROM_GIT,
PHOTON_GIT_REPO,
PHOTON_GIT_COMMIT,
} from "./constants";
import { exec } from "node:child_process";
import * as util from "node:util";
import { exit } from "node:process";

const execAsync = util.promisify(exec);

async function isExpectedPhotonVersion(
requiredVersion: string,
): Promise<boolean> {
try {
const { stdout } = await execAsync("photon --version");
const version = stdout.trim();
return version.includes(requiredVersion);
} catch (error) {
console.error("Error checking Photon version:", error);
return false;
}
}

function getPhotonInstallMessage(): string {
if (USE_PHOTON_FROM_GIT && PHOTON_GIT_COMMIT) {
return `\nLatest Photon indexer not found. Please install it by running: "cargo install --git ${PHOTON_GIT_REPO} --rev ${PHOTON_GIT_COMMIT} --locked"`;
} else if (USE_PHOTON_FROM_GIT) {
return `\nLatest Photon indexer not found. Please install it by running: "cargo install --git ${PHOTON_GIT_REPO} --locked"`;
} else {
return `\nLatest Photon indexer not found. Please install it by running: "cargo install photon-indexer --version ${PHOTON_VERSION} --locked"`;
}
}

export async function startIndexer(
rpcUrl: string,
Expand All @@ -16,9 +48,8 @@ export async function startIndexer(
resolvedOrNull === null ||
(checkPhotonVersion && !(await isExpectedPhotonVersion(PHOTON_VERSION)))
) {
const message = `Photon indexer not found. Please install it by running "cargo install photon-indexer --version ${PHOTON_VERSION} --locked"`;
console.log(message);
throw new Error(message);
console.log(getPhotonInstallMessage());
return exit(1);
} else {
console.log("Starting indexer...");
const args: string[] = [
Expand All @@ -39,17 +70,3 @@ export async function startIndexer(
export async function killIndexer() {
await killProcess(INDEXER_PROCESS_NAME);
}

const execAsync = util.promisify(exec);
async function isExpectedPhotonVersion(
requiredVersion: string,
): Promise<boolean> {
try {
const { stdout } = await execAsync("photon --version");
const version = stdout.trim();
return version.includes(requiredVersion);
} catch (error) {
console.error("Error checking Photon version:", error);
return false;
}
}
2 changes: 1 addition & 1 deletion cli/src/utils/processProverServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export async function startProver(
}

if ((!circuits || circuits.length === 0) && runMode == null) {
runMode = "rpc";
runMode = "local-rpc";
args.push("--run-mode", runMode);
console.log(`Starting prover with fallback ${runMode} mode...`);
}
Expand Down
4 changes: 2 additions & 2 deletions js/compressed-token/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lightprotocol/compressed-token",
"version": "0.21.0",
"version": "0.22.0",
"description": "JS client to interact with the compressed-token program",
"sideEffects": false,
"main": "dist/cjs/node/index.cjs",
Expand Down Expand Up @@ -85,7 +85,7 @@
"test:unit:all:v1": "LIGHT_PROTOCOL_VERSION=V1 vitest run tests/unit --reporter=verbose",
"test:unit:all:v2": "LIGHT_PROTOCOL_VERSION=V2 vitest run tests/unit --reporter=verbose",
"test-all:verbose": "vitest run --reporter=verbose",
"test-validator": "./../../cli/test_bin/run test-validator --prover-run-mode rpc",
"test-validator": "./../../cli/test_bin/run test-validator",
"test-validator-skip-prover": "./../../cli/test_bin/run test-validator --skip-prover",
"test:e2e:create-mint": "pnpm test-validator && NODE_OPTIONS='--trace-deprecation' vitest run tests/e2e/create-mint.test.ts --reporter=verbose",
"test:e2e:layout": "vitest run tests/e2e/layout.test.ts --reporter=verbose --bail=1",
Expand Down
Loading
Loading