Skip to content

Commit

Permalink
Merge branch 'm2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysbalevicius committed Dec 10, 2024
2 parents 1f22ce3 + 83b064f commit 625175e
Show file tree
Hide file tree
Showing 14 changed files with 503 additions and 278 deletions.
4 changes: 1 addition & 3 deletions .dev/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ ENV RUST_BACKTRACE 1
ENV CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG true

RUN rustup update \
&& rustup update nightly \
&& rustup install nightly-2023-08-31 \
&& rustup override set nightly-2023-08-31 \
&& rustup target add wasm32-unknown-unknown --toolchain nightly-2023-08-31

RUN apt-get update -y && apt-get install -y \
Expand All @@ -29,4 +27,4 @@ COPY ./.dev/runtime/src/lib.rs ./node/runtime/src/lib.rs
COPY ./pallet ./node/pallets/infimum

WORKDIR /node
RUN cargo build --release
RUN RUSTUP_TOOLCHAIN=nightly-2023-08-31 cargo +nightly-2023-08-31 build --release
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ build
.dev/frontend-template
node_modules
target
**/*.zkey
cli/__tests__/data
*.tar.gz
37 changes: 15 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,22 @@ The Infimum project is intended to provide a private, receipt-free, and verifiab

#### Requirements:
- If you wish to run the tests with docker, you will need to have the [latest version](https://www.docker.com/) installed on your machine.
- To run the tests on your local machine, you will need to have cargo installed. In particular:
```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source ~/.cargo/env
rustup install nightly-2023-08-31
rustup override set nightly-2023-08-31
rustup default nightly-2023-08-31
rustup target add wasm32-unknown-unknown --toolchain nightly-2023-08-31
```
- To run the tests on your local machine, you will need to have [cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html) installed.

### Unit tests

You can run the tests locally if you have [`cargo`](https://doc.rust-lang.org/cargo/index.html) installed.
You can run the tests locally if you have [`cargo`](https://doc.rust-lang.org/cargo/getting-started/installation.html) installed.
```sh
cd /path/to/infimum

cargo +nightly test --manifest-path=./pallet/Cargo.toml
cargo test --manifest-path=./pallet/Cargo.toml
```

Alternatively, the unit tests can also be run with docker.

```sh
cd /path/to/infimum

# Confirmed to be working using `Docker version 24.0.2, build cb74dfc`
docker compose --profile test up
```

Expand All @@ -56,25 +47,27 @@ However in general the interaction flow is:
- A coordinator creates a poll using the `create_poll` extrinsic.
- Participants register for the poll during the registration period using the `register_as_participant` extrinsic.
- Participants interact with the poll during the interaction period using the `interact_with_poll` extrinsic.
- After the poll ends, the coordinator is then permitted:
- Merges the state trees using the `merge_poll_state` extrinsic. This calculates various public signals on chain which are later used to verify the zero-knowledge proofs.
- Generates proofs for the poll results offchain. The basic flow for compiling and generating proofs can be found in [circuits](https://github.com/rhysbalevicius/infimum/tree/main/circuits).
- After the poll ends, the coordinator is then permitted to:
- Merge the state trees using the `merge_poll_state` extrinsic. This calculates various public signals on chain which are later used to verify the zero-knowledge proofs.
- Generate proofs for the poll results (offchain). The basic flow for compiling and generating proofs can be found in [circuits](https://github.com/rhysbalevicius/infimum/tree/main/circuits).
- These proofs are then commited to the pallet storage using the `commit_outcome` extrinsic.
- After every proof has been successfully submitted a `PollOutcome` event is deposited with the `outcome_index` field set.

An end-to-end example of this flow can currently be found [here](https://github.com/rhysbalevicius/infimum/tree/main/cli/__tests__/e2e.test.ts). In order to run this example, you will first need to locally spin up a substrate node with the Infimum pallet. For your convenience, you can do so with:
```sh
cd /path/to/infimum

# Download the zkeys
curl --output ./cli/__tests__/data/process.zkey https://cdn.rhys.tech/infimum/process.zkey
curl --output ./cli/__tests__/data/tally.zkey https://cdn.rhys.tech/infimum/tally.zkey
# Download and extract the test data
curl --output e2e.tar.gz https://cdn.rhys.tech/infimum/e2e.tar.gz
tar xf e2e.tar.gz -C cli/__tests__
rm e2e.tar.gz

# Start the node
docker-compose start runtime-node

# Then open a new tab and navigate to the `cli` directory
cd cli
docker compose --profile node up
```
Then open a new terminal, navigate to the `cli` directory, and run the tests
```sh
cd /path/to/infimum/cli

# Install the dependencies
npm i
Expand Down
Binary file removed cli/__tests__/data/process.wasm
Binary file not shown.
Binary file removed cli/__tests__/data/tally.wasm
Binary file not shown.
134 changes: 0 additions & 134 deletions cli/__tests__/data/vk-process.json

This file was deleted.

114 changes: 0 additions & 114 deletions cli/__tests__/data/vk-tally.json

This file was deleted.

6 changes: 6 additions & 0 deletions cli/lib/pkg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# inf-lib

## Build
```
wasm-pack build --target nodejs
```
6 changes: 6 additions & 0 deletions cli/lib/pkg/inf_lib.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* tslint:disable */
/* eslint-disable */
export function bytes_be_to_bn(input_js: any): any;
export function bn_to_bytes_be(input_js: any): any;
export function serialize_vkey(vkey_js: any): any;
export function serialize_proof(proof_js: any): any;
Loading

0 comments on commit 625175e

Please sign in to comment.