Skip to content
Merged
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
35 changes: 21 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# Light Protocol Program V3

## Setup

- In order to properly execute the prettier format pre-commit hook, you may first need to configure light-sdk-ts/husky/pre-commit as executable:
- `chmod ug+x ./light-sdk-ts/husky/* `

## Tests

*Requirements:*
_Requirements:_

- solana cli v1.11.10 or higher
- ``sh -c "$(curl -sSfL https://release.solana.com/v1.11.10/install)"``
- `sh -c "$(curl -sSfL https://release.solana.com/v1.11.10/install)"`
- clone of [solana](), checked out on `master` branch (the `alt_bn128` syscall
is not released yet) - to be sure that no recent changes can break the workflow,
you can check out commit
Expand All @@ -13,23 +19,25 @@
- `git checkout 656b150e575a4d16cfa9c9ff63b16edcf94f2e0d`
- anchor cli
https://project-serum.github.io/anchor/getting-started/installation.html
- ``npm i -g @project-serum/anchor-cli``
- `npm i -g @project-serum/anchor-cli`
- node v14

*Unit Tests:*
- ``cd anchor_programs/``
- ``cargo test``
- ``cd groth16-solana/``
- ``cargo test``
- ``cd light-verifier-sdk/``
- ``cargo test``
_Unit Tests:_

*Anchor tests:*
- `cd anchor_programs/`
- `cargo test`
- `cd groth16-solana/`
- `cargo test`
- `cd light-verifier-sdk/`
- `cargo test`

_Anchor tests:_

Tests are located in tests/ and will take several minutes to complete.
Several tests are skipped to decrease the overall testing time.
By default a deposit merkle tree update and withdrawal are executed with random values for deposits and fees. It is recommended to restart the validator before rerunning tests.
Further tests are:

- Initialize Merkle Tree Test
tests the configuration instructions and merkle tree initialization
- Deposit 10 utxos
Expand All @@ -39,7 +47,7 @@ Further tests are:
- Withdraw 10 utxos
tests and runs a withdrawal with 10 input utxos

- ``npm install``
- `npm install`

- Assuming that your clones of `solana` and `light-protocol-onchain` git
repoitories share the same parent directory and you are currently in the
Expand All @@ -55,7 +63,6 @@ Further tests are:
--bpf-program 3KS2k14CmtnuVv2fvYcvdrNgC94Y11WETBpMUGgXyWZL ./light-system-programs/target/deploy/verifier_program_one.so
```

- ``anchor test --skip-build --skip-deploy --skip-local-validator``

- `anchor test --skip-build --skip-deploy --skip-local-validator`

Check logs in anchor_programs/.anchor/program-logs
5 changes: 5 additions & 0 deletions light-sdk-ts/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "all",
"tabWidth": 2,
"singleQuote": false
}
6 changes: 6 additions & 0 deletions light-sdk-ts/husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
cd light-sdk-ts
npm run format
# exit 1

22 changes: 22 additions & 0 deletions light-sdk-ts/package-lock.json

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

9 changes: 8 additions & 1 deletion light-sdk-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"build": "tsc",
"format": "prettier --write \"src/**/*.{ts,js}\"",
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check",
"prepare": "cd .. && husky install ./light-sdk-ts/husky"
},
"format-staged": {
"**/*.{js,jsx}": [
"prettier --write"
]
},
"keywords": [
"sdk",
Expand Down Expand Up @@ -36,6 +42,7 @@
"@types/mocha": "^9.0.0",
"@types/node-fetch": "^2.6.2",
"chai": "^4.3.4",
"husky": "^8.0.3",
"lodash": "^4.17.21",
"mocha": "^10.2.0",
"prettier": "^2.6.2",
Expand Down
34 changes: 17 additions & 17 deletions light-sdk-ts/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const CONSTANT_SECRET_AUTHKEY: Uint8Array = Uint8Array.from([
]);

export const FIELD_SIZE = new anchor.BN(
"21888242871839275222246405745257275088548364400416034343698204186575808495617"
"21888242871839275222246405745257275088548364400416034343698204186575808495617",
);
export const MERKLE_TREE_SIGNER_AUTHORITY = new PublicKey([
59, 42, 227, 2, 155, 13, 249, 77, 6, 97, 72, 159, 190, 119, 46, 110, 226, 42,
Expand All @@ -38,16 +38,16 @@ export const TYPE_SEED = { defined: "&[u8]" };
export const TYPE_INIT_DATA = { array: ["u8", 642] };

export const merkleTreeProgramId = new PublicKey(
"JA5cjkRJ1euVi9xLWsCJVzsRzEkT8vcC4rqw9sVAo5d6"
"JA5cjkRJ1euVi9xLWsCJVzsRzEkT8vcC4rqw9sVAo5d6",
);
export const verifierProgramZeroProgramId = new PublicKey(
"J1RRetZ4ujphU75LP8RadjXMf3sA12yC2R44CF7PmU7i"
"J1RRetZ4ujphU75LP8RadjXMf3sA12yC2R44CF7PmU7i",
);
export const verifierProgramOneProgramId = new PublicKey(
"3KS2k14CmtnuVv2fvYcvdrNgC94Y11WETBpMUGgXyWZL"
"3KS2k14CmtnuVv2fvYcvdrNgC94Y11WETBpMUGgXyWZL",
);
export const verifierProgramTwoProgramId = new PublicKey(
"GFDwN8PXuKZG2d2JLxRhbggXYe9eQHoGYoYK5K3G5tV8"
"GFDwN8PXuKZG2d2JLxRhbggXYe9eQHoGYoYK5K3G5tV8",
);

export type merkleTreeProgram = Program<MerkleTreeProgramIdl>;
Expand Down Expand Up @@ -85,41 +85,41 @@ export const DEFAULT_PROGRAMS = {

// TODO: make account object with important accounts
export const MERKLE_TREE_KEY = new PublicKey(
"DCxUdYgqjE6AR9m13VvqpkxJqGJYnk8jn8NEeD3QY3BU"
"DCxUdYgqjE6AR9m13VvqpkxJqGJYnk8jn8NEeD3QY3BU",
);
export const REGISTERED_VERIFIER_PDA = new PublicKey(
"Eo3jtUstuMCvapqXdWiYvoUJS1PJDtKVf6LdsMPdyoNn"
"Eo3jtUstuMCvapqXdWiYvoUJS1PJDtKVf6LdsMPdyoNn",
);
export const REGISTERED_VERIFIER_ONE_PDA = new PublicKey(
"CqUS5VyuGscwLMTbfUSAA1grmJYzDAkSR39zpbwW2oV5"
"CqUS5VyuGscwLMTbfUSAA1grmJYzDAkSR39zpbwW2oV5",
);
export const REGISTERED_VERIFIER_TWO_PDA = new PublicKey(
"7RCgKAJkaR4Qsgve8D7Q3MrVt8nVY5wdKsmTYVswtJWn"
"7RCgKAJkaR4Qsgve8D7Q3MrVt8nVY5wdKsmTYVswtJWn",
);
export const AUTHORITY = new PublicKey(
"KitaXMAzb8GPZcc6NW6mE7P6gV2fY3Bp8NqZWfeUwqM"
"KitaXMAzb8GPZcc6NW6mE7P6gV2fY3Bp8NqZWfeUwqM",
);
export const AUTHORITY_ONE = new PublicKey(
"EjGpk73m5KxndbUVXcoT3UQsPLp5eK4h1H8kXVHEbf3f"
"EjGpk73m5KxndbUVXcoT3UQsPLp5eK4h1H8kXVHEbf3f",
);
export const PRE_INSERTED_LEAVES_INDEX = new PublicKey(
"2MQ7XkirVZZhRQQKcaDiJsrXHCuRHjbu72sUEeW4eZjq"
"2MQ7XkirVZZhRQQKcaDiJsrXHCuRHjbu72sUEeW4eZjq",
);
export const TOKEN_AUTHORITY = new PublicKey(
"GUqBxNbKyB9SBnbBKYR5dajwuWTjTRUhWrZgeFkJND55"
"GUqBxNbKyB9SBnbBKYR5dajwuWTjTRUhWrZgeFkJND55",
);
export const REGISTERED_POOL_PDA_SPL = new PublicKey(
"2q4tXrgpsDffibmjfTGHU1gWCjYUfhwFnMyLX6dAhhr4"
"2q4tXrgpsDffibmjfTGHU1gWCjYUfhwFnMyLX6dAhhr4",
);
export const REGISTERED_POOL_PDA_SPL_TOKEN = new PublicKey(
"2mobV36eNyFGaMTKCHW1Jeoq64tUGuXqA4zGtY8SbxKh"
"2mobV36eNyFGaMTKCHW1Jeoq64tUGuXqA4zGtY8SbxKh",
);
export const REGISTERED_POOL_PDA_SOL = new PublicKey(
"Eti4Rjkx7ow88XkaFbxRStmwadTp8p9J2nSv7NhtuqDU"
"Eti4Rjkx7ow88XkaFbxRStmwadTp8p9J2nSv7NhtuqDU",
);
export const POOL_TYPE = new Uint8Array(32).fill(0);
export const MERKLE_TREE_AUTHORITY_PDA = new PublicKey(
"5EMc8sCbHeb1HtRFifcbCiXN66kX6Wddrd61EkdJun6Y"
"5EMc8sCbHeb1HtRFifcbCiXN66kX6Wddrd61EkdJun6Y",
);

export const FEE_ASSET = anchor.web3.SystemProgram.programId;
Expand Down
Loading