Skip to content

Commit

Permalink
chore: improving cli startup times (Lightprotocol#645)
Browse files Browse the repository at this point in the history
* remove circ dep rpc and testrpc

adapt transfer.test to test for merkleproof integrity

reproduced invalid merkleproofs

wip

add rpc-interop tests

rpc impl 0.12.0 endpoints

add new methods to testrpc

wip: test cov rpc interop

wip: added rem. methods, debug signature calls

debug: reproduce sig bug in getSignaturesForOwner

getMultipleCompressedAccountProofs upped tx amount to produce failure

make executedTxs counter more robust

0.14.0

inline doc rpc, rpc-interface, test-rpc

createRpc doc

web works

test-rpc

compressed-token bundled for web

rebuilt, pub c-token

update readme ctoken

wip

wip 0.2.1

fix init urls, builds, release versions

add maintainers to pkg

update readme

cli v

cli deps v, apachev2

move axios to deps, cli version bump to 0.2.1

bump required node version in readme

cli: strict photon version at runtime

add: --relax-indexer-version-constraint, upd: --skip-indexer, --skip-prover

upd readme

bump 0.2.2

dynamic awaits for server startup

12s startup

wip

* prettier

* rm dupe import

* rm prove and verify cmds. fix initTestEnv
  • Loading branch information
SwenSchaeferjohann authored Apr 30, 2024
1 parent 34d2450 commit 4d3d73e
Show file tree
Hide file tree
Showing 14 changed files with 302 additions and 310 deletions.
50 changes: 37 additions & 13 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
# Light CLI
# ZK Compression CLI

CLI to interact with Light Protocol and ZK compression.

## Requirements

- Ensure you have Node.js (v19.4.0 or later) and npm installed on your machine.
- Ensure you have Node >= v20.9.0 installed on your machine.

- You will need a valid Solana filesystem wallet set up at `~/.config/solana/id.json`.
If you don't have one yet, visit the [Solana documentation](https://docs.solanalabs.com/cli/wallets/file-system) for details.
The CLI will use this wallet as the default fee payer and mint authority.

## Installation

### Using npm

```bash
npm install -g @lightprotocol/cli
```

### Building from source

If you prefer to build the CLI from source, follow the steps below to install
the necessary prerequesites.

**1. Activate the Development Environment**

Ensure you are at the root of the monorepo.
Expand All @@ -30,25 +41,37 @@ Ensure you are at the root of the monorepo.
./scripts/build.sh
```

**3. Make your CLI available globally**

```bash
pnpm link --global
```

```bash
# Verify the CLI was correctly installed
which light
```

## Usage

**1. Navigate to the CLI directory and start the Light test validator**
**1. Once globally installed, start the Light test validator**

```bash
cd cli && light test-validator
light test-validator
```

This starts a Solana test-validator with the Light system programs and accounts, a prover server, and a photon indexer as background processes against a clean ledger.
This starts a Solana test-validator with the Light system programs and accounts, a prover server, and the Photon indexer as background processes against a clean ledger.

```bash
# Pass the -i flag to start without the indexer
light test-validator -i
# Pass --skip-indexer to start without the indexer
light test-validator --skip-indexer

# Pass --skip-prover to start without the prover
light test-validator --skip-prover

# Pass the -p flag to start without the prover
light test-validator -p
```

> **Note:** The CLI currently expects the photon indexer to run at port: `8784` and the gnark-prover at port: `3001`
> **Note:** The CLI currently runs the photon indexer and gnark-prover as background processes at port: `8784` and `3001` respectively.
**2. Ensure you have sufficient localnet funds**

Expand All @@ -61,7 +84,6 @@ solana address

# Print your balance
solana balance

```

Now you're all set up to run CLI commands :)
Expand Down Expand Up @@ -130,6 +152,8 @@ FLAGS

#### Compress native SOL

> **Note:** Ensure the SOL omnibus account of the Light system program is already initialized by running: `light init-sol-pool`
```bash
light compress-sol --amount 1000 --to "YOUR_WALLET_ADDRESS_BASE58"
```
Expand Down Expand Up @@ -161,5 +185,5 @@ FLAGS
### Support

- Always feel free to join the [Developer Discord](https://discord.gg/D2cEphnvcY) for help!
- For more info about the canonical indexer implementation built by Helius, refer to the [Photon codebase](https://github.com/helius-labs/photon).
- For more info about Light and ZK compression, refer to the [documentation](https://docs.lightprotocol.com/).
- For more info about the canonical indexer implementation built and maintained by Helius Labs, refer to the [Photon codebase](https://github.com/helius-labs/photon).
- For more info about Light, refer to the [documentation](https://docs.lightprotocol.com/).
33 changes: 18 additions & 15 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
{
"name": "@lightprotocol/cli",
"version": "0.1.1-alpha.23",
"description": "Light Protocol CLI",
"author": "@ananas-block, @shigoto-dev19, @sleepyqadir ",
"version": "0.2.2",
"description": "ZK Compression: Secure Scaling of State on Solana",
"maintainers": [
{
"name": "Light Protocol maintainers",
"email": "[email protected]"
}
],
"bin": {
"light": "./test_bin/run"
},
"license": "GPL-3.0",
"license": "Apache-2.0",
"main": "dist/index.js",
"files": [
"/accounts",
"/bin",
"/dist",
"/test_bin",
"./config.json",
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
],
"dependencies": {
"@coral-xyz/anchor": "0.28.0",
"@lightprotocol/compressed-token": "workspace:*",
"@lightprotocol/hasher.rs": "workspace:*",
"@lightprotocol/stateless.js": "workspace:*",
"@oclif/core": "^3.26.2",
"@oclif/plugin-autocomplete": "^3.0.13",
Expand All @@ -29,28 +35,24 @@
"@solana-developers/helpers": "^1.5.1",
"@solana/spl-token": "^0.3.11",
"@solana/web3.js": "^1.91.4",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"axios": "^1.6.8",
"buffer": "^6.0.3",
"case-anything": "^2.1.13",
"chai": "^4.4.1",
"cli-progress": "^3.12.0",
"cli-spinners": "^2.9.2",
"dotenv": "^16.4.5",
"ffjavascript": "^0.2.63",
"find-process": "^1.4.7",
"fs": "0.0.1-security",
"node-fetch": "^3.3.2",
"path": "^0.12.7",
"snake-case": "^3.0.4",
"tar": "^6.2.1",
"ts-mocha": "^10.0.0",
"tweetnacl": "^1.0.3",
"wait-on": "^7.2.0",
"which": "^4.0.0",
"zlib": "^1.0.5"
},
"devDependencies": {
"@lightprotocol/programs": "workspace:*",
"@oclif/test": "2.3.9",
"@types/bn.js": "^5.1.5",
"@types/chai": "^4.3.14",
Expand All @@ -59,8 +61,9 @@
"@types/node": "^20.12.7",
"@types/tar": "^6.1.12",
"@types/which": "^3.0.3",
"axios": "^1.6.8",
"chai": "^4.3.10",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"chai": "^4.4.1",
"eslint": "8.57.0",
"eslint-config-oclif": "5.1.1",
"eslint-config-oclif-typescript": "3.1.4",
Expand All @@ -69,6 +72,7 @@
"oclif": "4.8.0",
"prettier": "^3.0.3",
"shx": "^0.3.4",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typescript": "5.3.2"
Expand All @@ -95,7 +99,6 @@
"postpack": "shx rm -f oclif.manifest.json",
"prepack": "pnpm build && oclif manifest && oclif readme",
"test-utils": "mocha ./test/utils/index.test.ts -t 10000000 --exit",
"test-prove": "mocha ./test/commands/prove/index.test.ts -t 10000000 --exit",
"test-config": "mocha ./test/commands/config/index.test.ts -t 10000000 --exit",
"test-create-mint": "mocha ./test/commands/create-mint/index.test.ts -t 10000000 --exit",
"test-mint-to": "mocha ./test/commands/mint-to/index.test.ts -t 10000000 --exit",
Expand All @@ -107,7 +110,7 @@
"test-decompress-spl": "mocha ./test/commands/decompress-spl/index.test.ts -t 10000000 --exit",
"kill": "killall solana-test-validator || true && killall solana-test-val || true && sleep 1",
"test-cli": "pnpm test-config && pnpm kill",
"test": "pnpm kill && pnpm test-prove && pnpm test-cli && pnpm test-utils && pnpm test-create-mint && pnpm test-mint-to && pnpm test-transfer && pnpm test-compress-spl && pnpm test-decompress-spl && pnpm test-balance && pnpm test-compress-sol && pnpm test-decompress-sol",
"test": "pnpm kill && pnpm test-cli && pnpm test-utils && pnpm test-create-mint && pnpm test-mint-to && pnpm test-transfer && pnpm test-compress-spl && pnpm test-decompress-spl && pnpm test-balance && pnpm test-compress-sol && pnpm test-decompress-sol",
"install-local": "pnpm build && pnpm global remove @lightprotocol/cli || true && pnpm global add $PWD",
"version": "oclif readme && git add README.md"
},
Expand Down
52 changes: 0 additions & 52 deletions cli/src/commands/prove/index.ts

This file was deleted.

27 changes: 16 additions & 11 deletions cli/src/commands/test-validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,35 @@ class SetupCommand extends Command {
}

static flags = {
"without-indexer": Flags.boolean({
char: "i",
description: "Runs a test validator without indexer service.",
"skip-indexer": Flags.boolean({
description: "Runs a test validator without starting a new indexer.",
default: false,
}),
"without-prover": Flags.boolean({
char: "p",
description: "Runs a test validator without prover service.",
"skip-prover": Flags.boolean({
description:
"Runs a test validator without starting a new prover service.",
default: false,
}),
"skip-system-accounts": Flags.boolean({
char: "s",
description:
"Runs a test validator without initialized light system accounts.",
default: false,
}),
"prove-compressed-accounts": Flags.boolean({
description: "Enable proving of compressed accounts.",
default: true,
exclusive: ["without-prover"],
exclusive: ["skip-prover"],
}),
"prove-new-addresses": Flags.boolean({
description: "Enable proving of new addresses.",
default: false,
exclusive: ["without-prover"],
exclusive: ["skip-prover"],
}),
"relax-indexer-version-constraint": Flags.boolean({
description:
"Disables indexer version check. Only use if you know what you are doing.",
default: false,
exclusive: ["skip-indexer"],
}),
};

Expand All @@ -45,10 +49,11 @@ class SetupCommand extends Command {
loader.start();
await initTestEnv({
skipSystemAccounts: flags["skip-system-accounts"],
indexer: !flags["without-indexer"],
prover: !flags["without-prover"],
indexer: !flags["skip-indexer"],
prover: !flags["skip-prover"],
proveCompressedAccounts: flags["prove-compressed-accounts"],
proveNewAddresses: flags["prove-new-addresses"],
checkPhotonVersion: !flags["relax-indexer-version-constraint"],
});

this.log("\nSetup tasks completed successfully \x1b[32m✔\x1b[0m");
Expand Down
62 changes: 0 additions & 62 deletions cli/src/commands/verify/index.ts

This file was deleted.

Loading

0 comments on commit 4d3d73e

Please sign in to comment.