Skip to content

Instantly share code, notes, and snippets.

@HAOYUatHZ
Last active May 9, 2021 02:15
Show Gist options
  • Save HAOYUatHZ/50ad93b412d15feb7c4fee8d87f0df4c to your computer and use it in GitHub Desktop.
Save HAOYUatHZ/50ad93b412d15feb7c4fee8d87f0df4c to your computer and use it in GitHub Desktop.
测试环境搭建

测试环境搭建

架构:https://app.diagrams.net/#G1-PE7MJgGUwYx9vljHBQnxdlffztkQdYu

prerequisite

scripts

#!/bin/bash

# example usage: ./deploy.sh 2 2 7 2 1 http://[::1]:50055

N_TXS=${1:-2}
BALANCE_LEVELS=${2:-2}
ORDER_LEVELS=${3:-7}
ACCOUNT_LEVELS=${4:-2}

PROVER_ID=${5:-1}
UPSTREAM=${6:-http://[::1]:50055}

cargo install --git https://github.com/Fluidex/plonkit
npm -g install snarkit

mkdir -p $HOME/repos
git clone https://github.com/Fluidex/plonkit.git $HOME/repos/Fluidex/plonkit
git clone https://github.com/Fluidex/prover-cluster.git $HOME/repos/Fluidex/prover-cluster

cd $HOME/repos/Fluidex/plonkit/test/circuits
snarkit compile poseidon

cd $HOME/repos/Fluidex/plonkit/test/circuits/poseidon
plonkit setup --power 20 --srs_monomial_form mon.key
plonkit dump-lagrange -c circuit.r1cs --srs_monomial_form mon.key --srs_lagrange_form lag.key
plonkit export-verification-key -c circuit.r1cs --srs_monomial_form mon.key

cd $HOME/repos/Fluidex/prover-cluster
cargo build --release
printf '
prover_id: %s
upstream: "%s"
poll_interval: 10000
circuit: "block"
r1cs: "%s/repos/Fluidex/plonkit/test/circuits/poseidon/circuit.r1cs"
srs_monomial_form: "%s/repos/Fluidex/plonkit/test/circuits/poseidon/mon.key"
srs_lagrange_form: "%s/repos/Fluidex/plonkit/test/circuits/poseidon/lag.key"
vk: "%s/repos/Fluidex/plonkit/test/circuits/poseidon/vk.bin"
' $PROVER_ID $UPSTREAM $HOME $HOME $HOME $HOME > $HOME/repos/Fluidex/prover-cluster/config/client.yaml
printf '
port: 50055
db: postgres://coordinator:coordinator_AA9944@127.0.0.1/prover_cluster
witgen:
  interval: 10000
  n_workers: 5
  circuits:
    block: "%s/repos/Fluidex/plonkit/test/circuits/poseidon/circuit"
' $HOME > $HOME/repos/Fluidex/prover-cluster/config/coordinator.yaml

在 prover-cluster/migrations/20210330142700_task.sql 中添加

insert into task (task_id, circuit, input, status) values (
'task_1',
'block',
'{ "foo": 3, "bar": 4 }'::jsonb,
'inited'
);

新开 3 个 terminal 分别

  • cd docker; docker-compose up
  • cargo run --bin coordinator
  • cargo run --bin client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment