From ef0f6712f0f0551b68a11db52131af3670af3cea Mon Sep 17 00:00:00 2001 From: Michal Gralinski Date: Wed, 27 Dec 2023 16:06:35 +0100 Subject: [PATCH] Fixing e2d and unit tests --- .github/workflows/build.yml | 2 + README.md | 22 +- aleph-node | 2 +- cli/Cargo.lock | 14 + cli/Cargo.toml | 5 +- cli/lib/Cargo.lock | 824 ++++++++++++++++++++++ cli/lib/Cargo.toml | 19 + cli/{src => lib}/helpers.rs | 5 + cli/lib/lib.rs | 169 +++++ cli/src/bright_disputes.rs | 165 ++--- cli/src/bright_disputes_ink.rs | 15 +- cli/src/lib.rs | 23 - cli/src/main.rs | 19 +- contract/src/contract.rs | 142 +++- contract/src/dispute.rs | 102 +-- contract/src/dispute_round.rs | 17 +- doc/README_CLI.md | 68 +- tests/Cargo.lock | 1209 ++++++++++++++++++++++---------- tests/Cargo.toml | 16 +- tests/README.md | 4 +- tests/bright_disputes.rs | 95 ++- tests/bright_disputes_test.rs | 736 +++++++++++++++++-- 22 files changed, 2903 insertions(+), 770 deletions(-) create mode 100644 cli/lib/Cargo.lock create mode 100755 cli/lib/Cargo.toml rename cli/{src => lib}/helpers.rs (74%) create mode 100644 cli/lib/lib.rs delete mode 100644 cli/src/lib.rs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 38df007..3ee6e9e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,8 @@ jobs: with: toolchain: 1.69 override: true + - name: Updating submodules + run: git submodule update --init --recursive - name: Update Rust environment run: rustup component add rust-src --toolchain 1.69-x86_64-unknown-linux-gnu - name: Adding WebAssembly target diff --git a/README.md b/README.md index e0d510d..2995b60 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,12 @@ docker build -f docker/Dockerfile.testing --progress=plain . ``` ## E2E tests +Currently, we have four major tests for testing different endings of the dispute: +* No majority of votes. +* Verdict against the owner of the dispute. +* Verdict against the defendant of the dispute. +* Testing dispute rounds. + To run E2E tests on your local machine, first run a aleph-node, build and deploy smart contract. We can do it, by running `deploy.sh` script: ``` bash scripts/deploy.sh @@ -72,13 +78,13 @@ ink-wrapper -m ../contract/target/ink/bright_disputes.json --wasm-path ../contra Finally we can run a e2e tests by calling: ``` -cargo +nightly test --release +cargo +nightly-2023-04-19 test --release ``` -# TODO: -* Store priv keys for jurors and judge in the JSON file and print it on the cmd -* Judge should issue a verdict and point the banned juries... -* Run/Fix all unit test -* Run/Fix all e2e test -* Update documentation + show cases - +The output of the e2e test is: +``` +test bright_disputes_test::test_dispute_verdict_none ... ok +test bright_disputes_test::test_dispute_verdict_positive ... ok +test bright_disputes_test::test_dispute_verdict_negative ... ok +test bright_disputes_test::test_dispute_rounds ... ok +``` \ No newline at end of file diff --git a/aleph-node b/aleph-node index c5be0a8..302fb9c 160000 --- a/aleph-node +++ b/aleph-node @@ -1 +1 @@ -Subproject commit c5be0a8f8a491024365ebd8295e3124cf57fe05c +Subproject commit 302fb9c63a51646c0ad708dabbf61bb300e4e7a2 diff --git a/cli/Cargo.lock b/cli/Cargo.lock index 8a67864..7cd60a6 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -580,6 +580,19 @@ dependencies = [ "byte-tools", ] +[[package]] +name = "bright-disputes-lib" +version = "0.1.0" +dependencies = [ + "aleph_client", + "anyhow", + "ark-ed-on-bls12-381", + "ark-serialize", + "ark-std", + "ink_primitives", + "liminal-ark-relations", +] + [[package]] name = "bright_disputes_cli" version = "0.1.0" @@ -589,6 +602,7 @@ dependencies = [ "ark-ed-on-bls12-381", "ark-serialize", "ark-std", + "bright-disputes-lib", "clap", "ink-wrapper-types", "ink_primitives", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 9df5008..909a8dc 100755 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -6,10 +6,6 @@ edition = "2021" license = "MIT" publish = false -[lib] -name = "bright_disputes" -path = "src/lib.rs" - [dependencies] anyhow = "1.0" inquire = "0.6.2" @@ -22,6 +18,7 @@ tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3.16", features = ["fmt", "json", "env-filter"] } +bright-disputes-lib = { path="lib" } ark-std = { version = "^0.3.0", default-features = false } ark-ed-on-bls12-381 = { version = "^0.3.0", features = ["r1cs"] } ark-serialize = { version = "^0.3.0", default-features = false } diff --git a/cli/lib/Cargo.lock b/cli/lib/Cargo.lock new file mode 100644 index 0000000..958782b --- /dev/null +++ b/cli/lib/Cargo.lock @@ -0,0 +1,824 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "ark-bls12-381" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65be532f9dd1e98ad0150b037276cde464c6f371059e6dd02c0222395761f6aa" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-crypto-primitives" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff773c0ef8c655c98071d3026a63950798a66b2f45baef22d8334c1756f1bd18" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-nonnative-field", + "ark-r1cs-std", + "ark-relations", + "ark-serialize", + "ark-snark", + "ark-std", + "blake2", + "derivative", + "digest", + "tracing", +] + +[[package]] +name = "ark-ec" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea978406c4b1ca13c2db2373b05cc55429c3575b8b21f1b9ee859aa5b03dd42" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ed-on-bls12-381" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b7ada17db3854f5994e74e60b18e10e818594935ee7e1d329800c117b32970" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-r1cs-std", + "ark-std", +] + +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-gm17" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94713045868e99a606a89825ff5a901667ba707ad1966a32c7f3a4d4dbcc0e9a" +dependencies = [ + "ark-crypto-primitives", + "ark-ec", + "ark-ff", + "ark-poly", + "ark-relations", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-groth16" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f8fff7468e947130b5caf9bdd27de8b913cf30e15104b4f0cd301726b3d897" +dependencies = [ + "ark-crypto-primitives", + "ark-ec", + "ark-ff", + "ark-poly", + "ark-relations", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-marlin" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caa8510faa8e64f0a6841ee4b58efe2d56f7a80d86fa0ce9891bbb3aa20166d9" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-poly-commit", + "ark-relations", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "rand_chacha", +] + +[[package]] +name = "ark-nonnative-field" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "440ad4569974910adbeb84422b7e622b79e08d27142afd113785b7fcfb446186" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-r1cs-std", + "ark-relations", + "ark-std", + "derivative", + "num-bigint", + "num-integer", + "num-traits", + "tracing", +] + +[[package]] +name = "ark-poly" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0f78f47537c2f15706db7e98fe64cc1711dbf9def81218194e17239e53e5aa" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown", +] + +[[package]] +name = "ark-poly-commit" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a71ddfa72bad1446cab7bbecb6018dbbdc9abcbc3a0065483ae5186ad2a64dcd" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-nonnative-field", + "ark-poly", + "ark-relations", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "tracing", +] + +[[package]] +name = "ark-r1cs-std" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e8fdacb1931f238a0d866ced1e916a49d36de832fd8b83dc916b718ae72893" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-relations", + "ark-std", + "derivative", + "num-bigint", + "num-traits", + "tracing", +] + +[[package]] +name = "ark-relations" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cba4c1c99792a6834bd97f7fd76578ec2cd58d2afc5139a17e1d1bec65b38f6" +dependencies = [ + "ark-ff", + "ark-std", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd4e5f0bf8285d5ed538d27fab7411f3e297908fd93c62195de8bee3f199e82" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-snark" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc3dff1a5f67a9c0b34df32b079752d8dd17f1e9d06253da0453db6c1b7cc8a" +dependencies = [ + "ark-ff", + "ark-relations", + "ark-std", +] + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "blake2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +dependencies = [ + "crypto-mac", + "digest", + "opaque-debug", +] + +[[package]] +name = "bright-disputes-lib" +version = "0.1.0" +dependencies = [ + "anyhow", + "ark-ed-on-bls12-381", + "ark-serialize", + "liminal-ark-relations", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "libc" +version = "0.2.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" + +[[package]] +name = "liminal-ark-pnbr-poseidon-parameters" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8723da56ab98f2182cbd27b9c510ca3c7f7bd616a56ca0e6b8f1b4bbc2c5f2ee" +dependencies = [ + "anyhow", + "ark-ff", + "num-integer", +] + +[[package]] +name = "liminal-ark-pnbr-poseidon-permutation" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0419b780a13b09a1ed2db09c6c61752f24e5f341f77a93719cd8bc963b72d3" +dependencies = [ + "ark-ff", + "ark-std", + "liminal-ark-pnbr-poseidon-parameters", +] + +[[package]] +name = "liminal-ark-pnbr-sponge" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6c178b0470950ac7fb73646df0f6ef60452d7b0fb0819e41dbe66674abc622f" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-nonnative-field", + "ark-r1cs-std", + "ark-relations", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "rand_chacha", + "tracing", +] + +[[package]] +name = "liminal-ark-poseidon" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ff555fb3914d246c1d478b66d248d4e59daac3784f05c24a707a55d9a6bd2b" +dependencies = [ + "ark-bls12-381", + "ark-ff", + "ark-r1cs-std", + "ark-relations", + "liminal-ark-pnbr-poseidon-parameters", + "liminal-ark-pnbr-poseidon-permutation", + "liminal-ark-pnbr-sponge", + "paste", +] + +[[package]] +name = "liminal-ark-relation-macro" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fffc8341caed7e6993016cce8f08cb47a13117cc54b1bf0df6c739536d690f4" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "liminal-ark-relations" +version = "0.4.0" +dependencies = [ + "ark-bls12-381", + "ark-crypto-primitives", + "ark-ec", + "ark-ed-on-bls12-381", + "ark-ff", + "ark-gm17", + "ark-groth16", + "ark-marlin", + "ark-poly", + "ark-poly-commit", + "ark-r1cs-std", + "ark-relations", + "ark-serialize", + "ark-snark", + "ark-std", + "blake2", + "liminal-ark-poseidon", + "liminal-ark-relation-macro", + "paste", +] + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pest" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.41", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.41", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "tracing-core", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "ucd-trie" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.41", +] diff --git a/cli/lib/Cargo.toml b/cli/lib/Cargo.toml new file mode 100755 index 0000000..7f7b40f --- /dev/null +++ b/cli/lib/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "bright-disputes-lib" +version = "0.1.0" +authors = ["Michal Gralinski michal.gralinski@brightinventions.pl"] +edition = "2021" +license = "MIT" +publish = false + +[lib] +path = "lib.rs" + +[dependencies] +anyhow = "1.0" +ark-ed-on-bls12-381 = { version = "^0.3.0", features = ["r1cs"] } +ark-serialize = { version = "^0.3.0", default-features = false } +ark-std = { version = "^0.3.0", default-features = false } +ink_primitives = "4.3.0" +aleph_client = "3.0.0" +liminal-ark-relations = { version = "0.4.0", path = "../../aleph-node/relations/ark" } diff --git a/cli/src/helpers.rs b/cli/lib/helpers.rs similarity index 74% rename from cli/src/helpers.rs rename to cli/lib/helpers.rs index 5918aa2..cea931b 100644 --- a/cli/src/helpers.rs +++ b/cli/lib/helpers.rs @@ -5,6 +5,11 @@ pub fn to_ink_account_id(account_id: &AccountId) -> ink_primitives::AccountId { inner.into() } +pub fn account_id_to_ink(account_id: &ink_primitives::AccountId) -> AccountId { + let inner: [u8; 32] = *account_id.as_ref(); + inner.into() +} + #[allow(dead_code)] pub fn account_id_to_string(account_id: &ink_primitives::AccountId) -> String { let inner: [u8; 32] = *account_id.as_ref(); diff --git a/cli/lib/lib.rs b/cli/lib/lib.rs new file mode 100644 index 0000000..d368653 --- /dev/null +++ b/cli/lib/lib.rs @@ -0,0 +1,169 @@ +use std::{fs, path::Path}; + +// use aleph_client::AccountId; +use anyhow::Result; +use ark_ed_on_bls12_381::{EdwardsAffine as JubJubAffine, EdwardsProjective as JubJub}; +use ark_serialize::CanonicalDeserialize; +use ark_std::{vec::Vec, One, Zero}; +use ink_primitives::AccountId; +use liminal_ark_relations::{ + disputes::{ + ecdh::{Ecdh, EcdhScheme}, + field_to_vote, hash_to_field, make_shared_key_hash, make_two_to_one_hash, vote_to_filed, + VerdictNegativeRelationWithFullInput, VerdictNoneRelationWithFullInput, + VerdictPositiveRelationWithFullInput, VerdictRelation, VoteRelationWithFullInput, + MAX_VOTES_LEN, + }, + environment::{CircuitField, Groth16, ProvingSystem}, + serialization::serialize, + ConstraintSynthesizer, +}; + +pub mod helpers; + +pub struct PublicVote { + pub id: AccountId, + pub pub_key: Vec, + pub hashed_vote: [u64; 4], +} + +pub fn generate_proof( + circuit: impl ConstraintSynthesizer, + proving_key_file: &Path, +) -> Result> { + let pk_bytes = fs::read(proving_key_file)?; + let pk = <::ProvingKey>::deserialize(&*pk_bytes)?; + Ok(serialize(&Groth16::prove(&pk, circuit))) +} + +pub fn prepare_voting_inputs( + vote: u8, + votes_hash: [u64; 4], + judge_public_key: Vec, + juror_private_key: Vec, + vote_pk_file: &Path, +) -> Result<([u64; 4], [u64; 4], Vec)> { + let judge_pub_key = Ecdh::::deserialize_public_key(judge_public_key); + let juror_priv_key = Ecdh::::deserialize_private_key(juror_private_key); + let shared_key = Ecdh::::make_shared_key(judge_pub_key, juror_priv_key); + let hashed_shared_key = make_shared_key_hash(shared_key); + let encrypted_vote = vote_to_filed(vote) + hashed_shared_key; + let new_encrypted_all_votes = make_two_to_one_hash(encrypted_vote, hash_to_field(votes_hash)); + + let circuit = VoteRelationWithFullInput::new( + encrypted_vote.0 .0, + votes_hash, + new_encrypted_all_votes.0 .0, + vote, + hashed_shared_key.0 .0, + ); + let proof = generate_proof(circuit, vote_pk_file)?; + Ok((encrypted_vote.0 .0, new_encrypted_all_votes.0 .0, proof)) +} + +pub fn prepare_counting_inputs( + judge_private_key: Vec, + votes: Vec, + verdict_none_pk: &Path, + verdict_negative_pk: &Path, + verdict_positive_pk: &Path, +) -> Result<(u8, u8, VerdictRelation, [u64; 4], Vec, Vec)> { + let judge_priv_key = Ecdh::::deserialize_private_key(judge_private_key.clone()); + + let mut jurors_banned = Vec::::new(); + let mut decoded_votes = Vec::::new(); + let mut shared_keys = Vec::<[u64; 4]>::new(); + let mut all_votes_hashed = hash_to_field([1u64; 4]); + let mut hashed_votes = CircuitField::one(); + let mut sum_votes: u8 = 0; + for i in 0..MAX_VOTES_LEN as usize { + if let Some(vote) = votes.get(i) { + let juror_pub_key = Ecdh::::deserialize_public_key(vote.pub_key.clone()); + let shared_key = Ecdh::::make_shared_key(juror_pub_key, judge_priv_key); + let hashed_shared_key = make_shared_key_hash(shared_key); + shared_keys.push(hashed_shared_key.0 .0); + + let decode_vote = + field_to_vote(hash_to_field(vote.hashed_vote) - hashed_shared_key.clone()); + hashed_votes = make_two_to_one_hash(hash_to_field(vote.hashed_vote), hashed_votes); + all_votes_hashed = + make_two_to_one_hash(hash_to_field(vote.hashed_vote), all_votes_hashed); + sum_votes += decode_vote; + jurors_banned.push(vote.id.clone()); + decoded_votes.push(decode_vote); + } else { + let shared_key = Ecdh::::make_shared_key(JubJubAffine::zero(), judge_priv_key); + let hashed_shared_key = make_shared_key_hash(shared_key); + + decoded_votes.push(0u8); + shared_keys.push(hashed_shared_key.0 .0); + hashed_votes = + make_two_to_one_hash(vote_to_filed(0u8) + hashed_shared_key.clone(), hashed_votes); + } + } + + let votes_minimum: u8 = (0.75 * votes.len() as f32).ceil() as u8; + let votes_maximum: u8 = votes.len() as u8 - votes_minimum; + let verdict = if sum_votes >= votes_minimum { + jurors_banned = jurors_banned + .iter() + .enumerate() + .filter(|&(index, _)| decoded_votes[index] != 0) + .map(|(_, &ref value)| value.clone()) + .collect(); + VerdictRelation::Positive + } else if sum_votes <= votes_maximum { + jurors_banned = jurors_banned + .iter() + .enumerate() + .filter(|&(index, _)| decoded_votes[index] == 0) + .map(|(_, &ref value)| value.clone()) + .collect(); + VerdictRelation::Negative + } else { + VerdictRelation::None + }; + + let proof = match verdict { + VerdictRelation::Positive => generate_proof( + VerdictPositiveRelationWithFullInput::new( + votes_minimum, + VerdictRelation::Positive as u8, + hashed_votes.0 .0, + decoded_votes, + shared_keys, + ), + verdict_positive_pk, + )?, + VerdictRelation::Negative => generate_proof( + VerdictNegativeRelationWithFullInput::new( + votes_maximum, + VerdictRelation::Negative as u8, + hashed_votes.0 .0, + decoded_votes, + shared_keys, + ), + verdict_negative_pk, + )?, + VerdictRelation::None => generate_proof( + VerdictNoneRelationWithFullInput::new( + votes_minimum, + votes_maximum, + VerdictRelation::None as u8, + hashed_votes.0 .0, + decoded_votes, + shared_keys, + ), + verdict_none_pk, + )?, + }; + + Ok(( + votes_maximum, + votes_minimum, + verdict, + hashed_votes.0 .0, + jurors_banned, + proof, + )) +} diff --git a/cli/src/bright_disputes.rs b/cli/src/bright_disputes.rs index 50b8abf..3f6c1be 100644 --- a/cli/src/bright_disputes.rs +++ b/cli/src/bright_disputes.rs @@ -3,25 +3,20 @@ use std::path::Path; use aleph_client::{contract::ContractInstance, AccountId, SignedConnection}; use anyhow::{anyhow, Result}; -use ark_ed_on_bls12_381::EdwardsAffine as JubJubAffine; use ark_ed_on_bls12_381::EdwardsProjective as JubJub; -use ark_std::{vec::Vec, One, Zero}; +use ark_std::vec::Vec; +use bright_disputes_lib::{ + helpers::{account_id_to_string, to_ink_account_id}, + prepare_counting_inputs, prepare_voting_inputs, PublicVote, +}; use ink_wrapper_types::{Connection as _, SignedConnection as _}; -use liminal_ark_relations::environment::CircuitField; use liminal_ark_relations::disputes::{ ecdh::{Ecdh, EcdhScheme}, - field_to_vote, hash_to_field, make_shared_key_hash, make_two_to_one_hash, vote_to_filed, - VerdictNegativeRelationWithFullInput, VerdictNoneRelationWithFullInput, - VerdictPositiveRelationWithFullInput, VerdictRelation, VoteRelationWithFullInput, - MAX_VOTES_LEN, + VerdictRelation, }; use tracing::info; -use crate::{ - bright_disputes_ink::{Dispute, Instance, Verdict}, - generate_proof, - helpers::{account_id_to_string, to_ink_account_id}, -}; +use crate::bright_disputes_ink::{Dispute, Instance, Verdict}; impl From<&ContractInstance> for Instance { fn from(contract: &ContractInstance) -> Self { @@ -198,33 +193,19 @@ impl BrightDisputes { .get_juror_public_key(connection, dispute_id, judge_id) .await?; - let judge_pub_key = Ecdh::::deserialize_public_key(judge_pub_key); - let juror_priv_key = Ecdh::::deserialize_private_key(private_key); - let shared_key = Ecdh::::make_shared_key(judge_pub_key, juror_priv_key); - let hashed_shared_key = make_shared_key_hash(shared_key); - let encrypted_vote = vote_to_filed(vote) + hashed_shared_key; - let new_encrypted_all_votes = - make_two_to_one_hash(encrypted_vote, hash_to_field(dispute.votes_hash)); - - let circuit = VoteRelationWithFullInput::new( - encrypted_vote.0 .0, - dispute.votes_hash, - new_encrypted_all_votes.0 .0, + let (encrypted_vote, new_encrypted_all_votes, proof) = prepare_voting_inputs( vote, - hashed_shared_key.0 .0, - ); - let proof = generate_proof(circuit, vote_pk_file)?; + dispute.votes_hash, + judge_pub_key, + private_key, + vote_pk_file, + )?; info!(target: "bright_disputes_cli", "Proof generated"); let ink_contract: Instance = (&self.contract).into(); connection - .exec(ink_contract.vote( - dispute_id, - encrypted_vote.0 .0, - new_encrypted_all_votes.0 .0, - proof, - )) + .exec(ink_contract.vote(dispute_id, encrypted_vote, new_encrypted_all_votes, proof)) .await?; Ok(()) @@ -312,95 +293,45 @@ impl BrightDisputes { &self, connection: &SignedConnection, dispute_id: u32, - private_key: Vec, + judge_private_key: Vec, verdict_none_pk: &Path, verdict_negative_pk: &Path, verdict_positive_pk: &Path, ) -> Result<()> { let dispute = self.get_dispute(connection, dispute_id).await?; - let judge_priv_key = Ecdh::::deserialize_private_key(private_key.clone()); - - let mut jurors_banned = Vec::::new(); - let mut decoded_votes = Vec::::new(); - let mut shared_keys = Vec::<[u64; 4]>::new(); - let mut all_votes_hashed = hash_to_field([1u64; 4]); - let mut hashed_votes = CircuitField::one(); - let mut sum_votes: u8 = 0; - for i in 0..MAX_VOTES_LEN as usize { - if let Some(vote) = dispute.votes.get(i) { - let juror_pub_key = self - .get_juror_public_key(connection, dispute_id, vote.juror) - .await?; - let juror_pub_key = Ecdh::::deserialize_public_key(juror_pub_key); - let shared_key = Ecdh::::make_shared_key(juror_pub_key, judge_priv_key); - let hashed_shared_key = make_shared_key_hash(shared_key); - shared_keys.push(hashed_shared_key.0 .0); - - let decode_vote = - field_to_vote(hash_to_field(vote.vote) - hashed_shared_key.clone()); - hashed_votes = make_two_to_one_hash(hash_to_field(vote.vote), hashed_votes); - all_votes_hashed = make_two_to_one_hash(hash_to_field(vote.vote), all_votes_hashed); - if decode_vote > 0 { - jurors_banned.push(vote.juror); - } - sum_votes += decode_vote; - decoded_votes.push(decode_vote); - } else { - let shared_key = - Ecdh::::make_shared_key(JubJubAffine::zero(), judge_priv_key); - let hashed_shared_key = make_shared_key_hash(shared_key); - - decoded_votes.push(0u8); - shared_keys.push(hashed_shared_key.0 .0); - hashed_votes = make_two_to_one_hash( - vote_to_filed(0u8) + hashed_shared_key.clone(), - hashed_votes, - ); - } - } - let votes_minimum: u8 = (0.75 * dispute.juries.len() as f32).ceil() as u8; - let votes_maximum: u8 = dispute.juries.len() as u8 - votes_minimum; - let verdict = if sum_votes >= votes_maximum { - Verdict::Positive() - } else if sum_votes <= votes_minimum { - Verdict::Negative() - } else { - Verdict::None() - }; + let mut jurors_public_key = Vec::>::new(); + for vote in &dispute.votes { + let key = self + .get_juror_public_key(connection, dispute_id, vote.juror) + .await?; + jurors_public_key.push(key); + } - let proof = match verdict { - Verdict::Positive() => generate_proof( - VerdictPositiveRelationWithFullInput::new( - votes_minimum, - VerdictRelation::Positive as u8, - hashed_votes.0 .0, - decoded_votes, - shared_keys, - ), - verdict_positive_pk, - ), - Verdict::Negative() => generate_proof( - VerdictNegativeRelationWithFullInput::new( - votes_maximum, - VerdictRelation::Negative as u8, - hashed_votes.0 .0, - decoded_votes, - shared_keys, - ), - verdict_negative_pk, - ), - Verdict::None() => generate_proof( - VerdictNoneRelationWithFullInput::new( - votes_maximum, - votes_minimum, - VerdictRelation::None as u8, - hashed_votes.0 .0, - decoded_votes, - shared_keys, - ), + let votes: Vec = dispute + .votes + .iter() + .zip(jurors_public_key.iter()) + .map(|(&ref vote, &ref key)| PublicVote { + id: vote.juror, + pub_key: key.clone(), + hashed_vote: vote.vote, + }) + .collect(); + + let (votes_maximum, votes_minimum, verdict, hashed_votes, jurors_banned, proof) = + prepare_counting_inputs( + judge_private_key, + votes, verdict_none_pk, - ), + verdict_negative_pk, + verdict_positive_pk, + )?; + + let ink_verdict = match verdict { + VerdictRelation::Positive => Verdict::Positive(), + VerdictRelation::Negative => Verdict::Negative(), + VerdictRelation::None => Verdict::None(), }; info!(target: "bright_disputes_cli", "Proof generated"); @@ -411,10 +342,10 @@ impl BrightDisputes { dispute_id, votes_maximum, votes_minimum, - verdict, - hashed_votes.0 .0, + ink_verdict, + hashed_votes, jurors_banned, - proof.unwrap(), + proof, )) .await?; diff --git a/cli/src/bright_disputes_ink.rs b/cli/src/bright_disputes_ink.rs index 87e2818..3103470 100644 --- a/cli/src/bright_disputes_ink.rs +++ b/cli/src/bright_disputes_ink.rs @@ -4,8 +4,8 @@ use scale::Encode as _; #[allow(dead_code)] pub const CODE_HASH: [u8; 32] = [ - 130, 214, 182, 242, 229, 248, 203, 44, 209, 112, 26, 249, 97, 59, 55, 140, 79, 16, 61, 217, - 180, 9, 197, 216, 115, 133, 245, 120, 19, 53, 156, 20, + 134, 34, 57, 191, 103, 29, 44, 56, 12, 231, 88, 242, 64, 144, 53, 34, 131, 56, 170, 238, 192, + 142, 229, 240, 82, 204, 67, 181, 250, 239, 22, 82, ]; #[derive(Debug, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] @@ -214,6 +214,17 @@ impl Instance { ink_wrapper_types::ReadCall::new(self.account_id, data) } + /// Get juries pool + #[allow(dead_code, clippy::too_many_arguments)] + pub fn get_juries_pool( + &self, + ) -> ink_wrapper_types::ReadCall< + Result, ink_wrapper_types::InkLangError>, + > { + let data = vec![3, 234, 94, 249]; + ink_wrapper_types::ReadCall::new(self.account_id, data) + } + /// Get single dispute by id #[allow(dead_code, clippy::too_many_arguments)] pub fn remove_dispute(&self, dispute_id: u32) -> ink_wrapper_types::ExecCall { diff --git a/cli/src/lib.rs b/cli/src/lib.rs deleted file mode 100644 index 8cac42c..0000000 --- a/cli/src/lib.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::{fs, path::Path}; - -use anyhow::Result; -use ark_serialize::CanonicalDeserialize; -use liminal_ark_relations::{ - environment::{CircuitField, Groth16, ProvingSystem}, - serialization::serialize, - ConstraintSynthesizer, -}; - -pub mod application; -pub mod bright_disputes; -pub mod bright_disputes_ink; -pub mod helpers; - -pub fn generate_proof( - circuit: impl ConstraintSynthesizer, - proving_key_file: &Path, -) -> Result> { - let pk_bytes = fs::read(proving_key_file)?; - let pk = <::ProvingKey>::deserialize(&*pk_bytes)?; - Ok(serialize(&Groth16::prove(&pk, circuit))) -} diff --git a/cli/src/main.rs b/cli/src/main.rs index 1c5d0ba..16e00d5 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -2,19 +2,25 @@ use aleph_client::{ account_from_keypair, keypair_from_string, AccountId, Connection, SignedConnection, }; use anyhow::{anyhow, Result}; -use bright_disputes::{application::Application, bright_disputes::BrightDisputes}; +use bright_disputes_lib::helpers::to_ink_account_id; use clap::Parser; +use inquire::Text; use std::str::FromStr; use std::{env, io}; -extern crate bright_disputes; -use inquire::Text; use tracing::info; use tracing_subscriber::EnvFilter; -use crate::config::{Command::SetNode, ContractCmd}; - +mod application; +mod bright_disputes; +mod bright_disputes_ink; mod config; -mod helpers; + +use crate::{ + application::Application, + bright_disputes::BrightDisputes, + config::{Command::SetNode, ContractCmd}, +}; + use crate::{ config::{ Command, Config, @@ -25,7 +31,6 @@ use crate::{ UpdateOwnerDescription, Vote, }, }, - helpers::to_ink_account_id, Command::{Contract, SetContract}, }; diff --git a/contract/src/contract.rs b/contract/src/contract.rs index 4b920d9..fc1ef82 100755 --- a/contract/src/contract.rs +++ b/contract/src/contract.rs @@ -139,6 +139,12 @@ pub mod bright_disputes { .collect() } + /// Get juries pool + #[ink(message)] + pub fn get_juries_pool(&self) -> Vec { + self.juries_pool.clone() + } + /// Get single dispute by id #[ink(message)] pub fn remove_dispute(&mut self, dispute_id: DisputeId) -> Result<()> { @@ -258,15 +264,7 @@ pub mod bright_disputes { /// from this pool to participate in disputes. #[ink(message)] pub fn register_as_an_active_juror(&mut self) -> Result<()> { - let caller = ink::env::caller::(); - self.assert_juror_not_in_pool(caller)?; - - let juror = self - .juries - .get(caller) - .unwrap_or_else(|| Juror::create(caller)); - self.juries_pool.push(juror.id()); - self.update_juror(juror); + self.add_to_juries_pool(ink::env::caller::())?; Ok(()) } @@ -356,8 +354,8 @@ pub mod bright_disputes { ), Verdict::None => ( VerdictNoneRelationWithPublicInput::new( - votes_maximum, votes_minimum, + votes_maximum, VerdictRelation::None as u8, hashed_votes, ) @@ -420,6 +418,7 @@ pub mod bright_disputes { let judge = self.get_juror_or_assert(judge_id)?; if judge.is_requested_for_action(dispute_id) { dispute.move_to_banned(judge_id)?; + self.add_to_juries_pool(judge_id)?; } } @@ -428,6 +427,7 @@ pub mod bright_disputes { let juror = self.get_juror_or_assert(juror_id)?; if juror.is_requested_for_action(dispute_id) { dispute.move_to_banned(juror_id)?; + self.add_to_juries_pool(juror_id)?; } } @@ -470,11 +470,13 @@ pub mod bright_disputes { // Add judge if let Some(judge_id) = dispute.judge() { accounts.push(judge_id); + self.add_to_juries_pool(judge_id)?; } // Add juries, who were not banned. for juror_id in dispute.juries() { accounts.push(juror_id); + self.add_to_juries_pool(juror_id)?; } // Split deposit and transfer founds. @@ -550,6 +552,17 @@ pub mod bright_disputes { return Err(BrightDisputesError::NotRegisteredAsJuror); } + fn add_to_juries_pool(&mut self, juror_id: AccountId) -> Result<()> { + self.assert_juror_not_in_pool(juror_id)?; + let juror = self + .juries + .get(juror_id) + .unwrap_or_else(|| Juror::create(juror_id)); + self.juries_pool.push(juror.id()); + self.update_juror(juror); + Ok(()) + } + fn get_random_juries_from_pool( &self, except_juries: &Vec, @@ -608,6 +621,34 @@ pub mod bright_disputes { #[cfg(test)] mod tests { + mod mock { + use baby_liminal_extension::{ + BabyLiminalError, BabyLiminalExtension, VerificationKeyIdentifier, + }; + use ink::{prelude::vec::Vec, primitives::AccountId as AccountId32}; + + #[obce::mock] + impl BabyLiminalExtension for () { + fn store_key( + &mut self, + _: AccountId32, + _: VerificationKeyIdentifier, + _: Vec, + ) -> Result<(), BabyLiminalError> { + Ok(()) + } + + fn verify( + &mut self, + _: VerificationKeyIdentifier, + _: Vec, + _: Vec, + ) -> Result<(), BabyLiminalError> { + Ok(()) + } + } + } + use ink::env::{ test::{set_caller, set_value_transferred}, DefaultEnvironment, @@ -756,7 +797,7 @@ pub mod bright_disputes { ); } - /// Test if we can remove a single dispute. + // Test if we can remove a single dispute. #[ink::test] fn remove_dispute() { let accounts = ink::env::test::default_accounts::(); @@ -783,7 +824,7 @@ pub mod bright_disputes { .get_dispute(1) .expect("Failed to get dispute!"); dispute - .end_dispute(DisputeResult::Owner) + .end_dispute(DisputeResult::Owner, vec![]) .expect("Failed to end dispute!"); bright_disputes.update_dispute(dispute.clone()); let result = bright_disputes.remove_dispute(1); @@ -1024,7 +1065,7 @@ pub mod bright_disputes { // Check switching to next round when deadline appear. #[ink::test] fn vote() { - baby_liminal_extension::ink::mock_test::register_chain_extensions(()); + mock::register_chain_extensions(()); let accounts = ink::env::test::default_accounts::(); set_caller::(accounts.alice); @@ -1086,15 +1127,15 @@ pub mod bright_disputes { // Juries voting set_caller::(assigned_juries[0]); bright_disputes - .vote(dispute_id, 1, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); set_caller::(assigned_juries[1]); bright_disputes - .vote(dispute_id, 1, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); set_caller::(assigned_juries[2]); bright_disputes - .vote(dispute_id, 1, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); // Switch state to "CountingTheVotes" state @@ -1129,7 +1170,7 @@ pub mod bright_disputes { // Check dispute round progress #[ink::test] fn process_dispute_round() { - baby_liminal_extension::ink::mock_test::register_chain_extensions(()); + mock::register_chain_extensions(()); let accounts = ink::env::test::default_accounts::(); set_caller::(accounts.alice); @@ -1191,15 +1232,15 @@ pub mod bright_disputes { // Juries voting set_caller::(assigned_juries[0]); bright_disputes - .vote(dispute_id, 1, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); set_caller::(assigned_juries[1]); bright_disputes - .vote(dispute_id, 1, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); set_caller::(assigned_juries[2]); bright_disputes - .vote(dispute_id, 1, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); // Switch state to CountingTheVotes @@ -1209,19 +1250,35 @@ pub mod bright_disputes { // Failed to count the votes, only judge can do it. set_caller::(accounts.alice); - let result = bright_disputes.count_the_votes(3, dispute_id, vec![]); + let result = bright_disputes.issue_the_verdict( + dispute_id, + 0, + 0, + Verdict::Positive, + [0u64; 4], + vec![], + vec![], + ); assert_eq!(result, Err(BrightDisputesError::NotAuthorized)); // Count the votes, dispute ends set_caller::(juror_not_assigned[0]); - let result = bright_disputes.count_the_votes(3, dispute_id, vec![]); + let result = bright_disputes.issue_the_verdict( + dispute_id, + 0, + 0, + Verdict::Positive, + [0u64; 4], + vec![], + vec![], + ); assert_eq!(result, Ok(())); } // Check switching to next rounds. #[ink::test] fn process_dispute_round_next_round() { - baby_liminal_extension::ink::mock_test::register_chain_extensions(()); + mock::register_chain_extensions(()); let accounts = ink::env::test::default_accounts::(); set_caller::(accounts.alice); @@ -1284,15 +1341,15 @@ pub mod bright_disputes { // Juries voting set_caller::(assigned_juries[0]); bright_disputes - .vote(dispute_id, 1, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); set_caller::(assigned_juries[1]); bright_disputes - .vote(dispute_id, 1, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); set_caller::(assigned_juries[2]); bright_disputes - .vote(dispute_id, 0, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); // Switch state to "CountingTheVotes" state @@ -1302,7 +1359,15 @@ pub mod bright_disputes { // Majority of votes not reached, new round. set_caller::(juror_not_assigned[0]); - let result = bright_disputes.count_the_votes(3, dispute_id, vec![]); + let result = bright_disputes.issue_the_verdict( + dispute_id, + 0, + 0, + Verdict::None, + [0u64; 4], + vec![], + vec![], + ); assert_eq!(result, Ok(())); // New round @@ -1314,7 +1379,7 @@ pub mod bright_disputes { // Check deposit distribution #[ink::test] fn distribute_deposit() { - baby_liminal_extension::ink::mock_test::register_chain_extensions(()); + mock::register_chain_extensions(()); let accounts = ink::env::test::default_accounts::(); set_caller::(accounts.alice); @@ -1377,15 +1442,15 @@ pub mod bright_disputes { // Juries voting set_caller::(assigned_juries[0]); bright_disputes - .vote(dispute_id, 1, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); set_caller::(assigned_juries[1]); bright_disputes - .vote(dispute_id, 1, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); set_caller::(assigned_juries[2]); bright_disputes - .vote(dispute_id, 1, vec![]) + .vote(dispute_id, [0u64; 4], [0u64; 4], vec![]) .expect("Failed to vote"); // Switch state to CountingTheVotes @@ -1397,17 +1462,20 @@ pub mod bright_disputes { // Count the votes, dispute ends set_caller::(juror_not_assigned[0]); bright_disputes - .count_the_votes(3, dispute_id, vec![]) + .issue_the_verdict( + dispute_id, + 0, + 0, + Verdict::Positive, + [0u64; 4], + vec![], + vec![], + ) .expect("Failed process dispute round!"); set_caller::(accounts.bob); let result = bright_disputes.distribute_deposit(dispute_id); assert_eq!(result, Ok(())); } - - #[ink::test] - fn juror_public_key() { - // TODO !! - } } } diff --git a/contract/src/dispute.rs b/contract/src/dispute.rs index 3e3cca0..db4eaf6 100644 --- a/contract/src/dispute.rs +++ b/contract/src/dispute.rs @@ -151,7 +151,7 @@ impl Dispute { pub fn votes_hash(&self) -> VoteHash { return self.votes_hash; - } + } /// Getter dispute result pub fn get_dispute_result(&self) -> Option { @@ -513,100 +513,18 @@ mod tests { dispute.dispute_round = Some(DisputeRoundFake::voting(0u64)); // Only juror can vote - let result = dispute.vote(Vote::create(accounts.bob, 1)); + let result = dispute.vote(Vote::create(accounts.bob, [0u64; 4]), [0u64; 4]); assert_eq!(result, Err(BrightDisputesError::NotAuthorized)); // Success - let result = dispute.vote(Vote::create(accounts.charlie, 1)); + let result = dispute.vote(Vote::create(accounts.charlie, [0u64; 4]), [0u64; 4]); assert_eq!(result, Ok(())); // Juror can vote only once - let result = dispute.vote(Vote::create(accounts.charlie, 0)); + let result = dispute.vote(Vote::create(accounts.charlie, [0u64; 4]), [0u64; 4]); assert_eq!(result, Err(BrightDisputesError::JurorAlreadyVoted)); } - #[ink::test] - fn count_votes() { - let accounts = ink::env::test::default_accounts::(); - let mut dispute = default_test_running_dispute(); - - // Force "Voting" state - dispute.dispute_round = Some(DisputeRoundFake::voting(0u64)); - - let mut charlie = Juror::create(accounts.charlie); - dispute - .assign_juror(&mut charlie) - .expect("Unable to add juror!"); - - let mut eve = Juror::create(accounts.eve); - dispute - .assign_juror(&mut eve) - .expect("Unable to add juror!"); - - let mut frank = Juror::create(accounts.frank); - dispute - .assign_juror(&mut frank) - .expect("Unable to add juror!"); - - let mut django = Juror::create(accounts.django); - dispute - .assign_judge(&mut django) - .expect("Unable to add juror!"); - - // Force "Vote Counting" state - dispute.dispute_round = Some(DisputeRoundFake::counting(0u64)); - - // Test, only judge can count the votes. - set_caller::(accounts.alice); - let result = dispute.count_votes(); - assert_eq!(result, Err(BrightDisputesError::NotAuthorized)); - - set_caller::(accounts.bob); - let result = dispute.count_votes(); - assert_eq!(result, Err(BrightDisputesError::NotAuthorized)); - - set_caller::(accounts.charlie); - let result = dispute.count_votes(); - assert_eq!(result, Err(BrightDisputesError::NotAuthorized)); - - set_caller::(accounts.django); - let result = dispute.count_votes(); - assert_eq!(result, Err(BrightDisputesError::MajorityOfVotesNotReached)); - - // Force "Voting" state - dispute.dispute_round = Some(DisputeRoundFake::voting(0u64)); - - // Voting - dispute - .vote(Vote::create(accounts.charlie, 1)) - .expect("Failed to vote!"); - - dispute - .vote(Vote::create(accounts.eve, 1)) - .expect("Failed to vote!"); - - // Force "Vote Counting" state - dispute.dispute_round = Some(DisputeRoundFake::counting(0u64)); - - set_caller::(accounts.django); - let result = dispute.count_votes(); - assert_eq!(result, Err(BrightDisputesError::MajorityOfVotesNotReached)); - - // Force "Voting" state - dispute.dispute_round = Some(DisputeRoundFake::voting(0u64)); - - dispute - .vote(Vote::create(accounts.frank, 1)) - .expect("Failed to vote!"); - - // Force "Vote Counting" state - dispute.dispute_round = Some(DisputeRoundFake::counting(0u64)); - - set_caller::(accounts.django); - let result = dispute.count_votes(); - assert_eq!(result, Ok(DisputeResult::Owner)); - } - #[ink::test] fn assign_juror() { let accounts = ink::env::test::default_accounts::(); @@ -888,7 +806,7 @@ mod tests { ); dispute - .vote(Vote::create(accounts.charlie, 1)) + .vote(Vote::create(accounts.charlie, [0u64; 4]), [0u64; 4]) .expect("Failed to vote!"); assert_eq!(dispute.get_not_voted_juries(), vec![accounts.eve]); @@ -919,7 +837,7 @@ mod tests { .assign_juror(&mut charlie) .expect("Unable to add juror!"); dispute - .vote(Vote::create(accounts.charlie, 1)) + .vote(Vote::create(accounts.charlie, [0u64; 4]), [0u64; 4]) .expect("Failed to vote!"); let mut eve = Juror::create(accounts.eve); @@ -955,7 +873,7 @@ mod tests { set_caller::(accounts.alice); let mut dispute = Dispute::create(1, "".into(), accounts.bob, 15); - let result = dispute.end_dispute(DisputeResult::Owner); + let result = dispute.end_dispute(DisputeResult::Owner, vec![]); assert_eq!(result, Err(BrightDisputesError::InvalidDisputeState)); // Force "Voting" state @@ -968,7 +886,7 @@ mod tests { .assign_juror(&mut charlie) .expect("Unable to add juror!"); dispute - .vote(Vote::create(accounts.charlie, 1)) + .vote(Vote::create(accounts.charlie, [0u64; 4]), [0u64; 4]) .expect("Failed to vote!"); // Eve vote against Defendant @@ -977,10 +895,10 @@ mod tests { .assign_juror(&mut eve) .expect("Unable to add juror!"); dispute - .vote(Vote::create(accounts.eve, 0)) + .vote(Vote::create(accounts.eve, [0u64; 4]), [0u64; 4]) .expect("Failed to vote!"); - let result = dispute.end_dispute(DisputeResult::Owner); + let result = dispute.end_dispute(DisputeResult::Owner, vec![accounts.eve]); assert_eq!(result, Ok(())); assert_eq!(dispute.banned().len(), 1); diff --git a/contract/src/dispute_round.rs b/contract/src/dispute_round.rs index 893d622..e7adc3a 100644 --- a/contract/src/dispute_round.rs +++ b/contract/src/dispute_round.rs @@ -248,14 +248,6 @@ pub mod mock { state_deadline, } } - - pub fn counting(state_deadline: Timestamp) -> DisputeRound { - DisputeRound { - state: RoundState::CountingTheVotes, - number_of_juries: DisputeRound::INITIAL_NUMBER_OF_JURIES, - state_deadline, - } - } } } @@ -266,7 +258,6 @@ mod tests { use super::*; use crate::{ - dispute::DisputeResult, juror::{mock::JuriesMapMock, Juror}, vote::Vote, }; @@ -455,7 +446,7 @@ mod tests { for juror_id in dispute.juries() { set_caller::(juror_id); dispute - .vote(Vote::create(juror_id, 1)) + .vote(Vote::create(juror_id, [0u64; 4]), [0u64; 4]) .expect("Failed make a vote!"); } @@ -518,13 +509,13 @@ mod tests { let voters = dispute.juries(); dispute - .vote(Vote::create(voters[0], 1)) + .vote(Vote::create(voters[0], [0u64; 4]), [0u64; 4]) .expect("Failed make a vote!"); dispute - .vote(Vote::create(voters[1], 1)) + .vote(Vote::create(voters[1], [0u64; 4]), [0u64; 4]) .expect("Failed make a vote!"); dispute - .vote(Vote::create(voters[2], 1)) + .vote(Vote::create(voters[2], [0u64; 4]), [0u64; 4]) .expect("Failed make a vote!"); // Move to counting the votes state. diff --git a/doc/README_CLI.md b/doc/README_CLI.md index c7a4b96..adf331d 100644 --- a/doc/README_CLI.md +++ b/doc/README_CLI.md @@ -49,28 +49,66 @@ This call will start a dispute round, which will assign Jurors and the Judge to ``` based on the output: ``` -Dispute: 1 -Owner: 5FTyuyEQQZs8tCcPTUFqotkm2SYfDnpefn9FitRgmTHnFDBD -Defendant: 5HpJbr84AqocNWyq4WNAQLNLSNNoXVmqAhvrk8Tq7YX23j6p -Judge: 5GvG1edSDSrAG5HZ21N1BVGEgygpSujAAjuruyfyuCgsgEFr -Jurors: ["5H4SHcV6XVFiGF3QGdKFLES3xwUmN9jFdt5KVNapJtfWPPtT", "5G492oT3GwqTpz4ebV15JHERucL96zEp54TZZSm3ZQHGe9AE","5GjNM6gLeYxeB9aQoPxVVa7H494ijFsHTXTNo9dkNuTyDCeD"] +{ + Dispute: 1 + Owner: 5FTyuyEQQZs8tCcPTUFqotkm2SYfDnpefn9FitRgmTHnFDBD + Defendant: 5HpJbr84AqocNWyq4WNAQLNLSNNoXVmqAhvrk8Tq7YX23j6p + Judge: 5H4SHcV6XVFiGF3QGdKFLES3xwUmN9jFdt5KVNapJtfWPPtT + Jurors: ["5GvG1edSDSrAG5HZ21N1BVGEgygpSujAAjuruyfyuCgsgEFr", "5DZyhVcMqnfg78WK8EsUyu3tpLb2peARqVEoieEunsgH2iQb", "5FjEKpjdvNe8SbZjgUaF8qQD3mL9T5k8oCtGozMYkHi2aVCi"] +} +``` +we can find out which Jurors where picked from the active pool. In our case it was: //Juror1, //Juror2, //Juror3, and //Juror4 as a Judge. Now they need to confirm their participation in the dispute, we can do it by calling: +``` +../cli/target/release/bright_disputes_cli confirm-juror-participation //Juror1 1 +../cli/target/release/bright_disputes_cli confirm-juror-participation //Juror2 1 +../cli/target/release/bright_disputes_cli confirm-juror-participation //Juror3 1 +../cli/target/release/bright_disputes_cli confirm-judge-participation //Juror4 1 +``` +When confirming their participation, each juror will receive a unique pair of keys, which will be used for the further data encryption. In our case, this present: + +Juror1 +``` +Public key: [143,96,146,215,67,186,237,47,231,60,4,227,180,180,227,175,139,11,9,212,45,153,174,82,61,94,185,142,229,93,248,141] + +Private key: [179,168,214,171,19,120,215,166,1,175,173,235,85,161,223,244,253,121,185,141,92,32,171,52,154,20,21,152,97,250,190,6] +``` + +Juror2 +``` +Public key: [93,66,190,16,93,13,181,112,42,68,88,90,88,65,241,30,80,202,221,3,137,104,89,40,93,2,69,100,36,104,158,72] + +Private key: [250,71,107,70,4,169,48,81,216,97,222,161,213,137,52,53,250,3,165,188,184,58,181,151,160,0,153,178,252,164,62,7] +``` + +Juror3 +``` +Public key: [199,48,32,250,139,107,224,127,96,217,223,140,130,3,111,69,146,249,47,219,36,50,38,216,154,163,197,232,65,72,57,115] + +Private key: [214,199,173,149,198,9,55,208,20,165,65,187,65,103,253,211,174,91,92,193,21,244,157,43,215,163,41,161,15,65,106,4] ``` -we can find out which Jurors where picked from the active pool. In our case it was: //Juror4, //Juror5, //Juror6, and //Juror1 as a Judge. Now they need to confirm their participation in the dispute, we can do it by calling: + +Juror4 ``` -../cli/target/release/bright_disputes_cli confirm-juror-participation //Juror4 1 -../cli/target/release/bright_disputes_cli confirm-juror-participation //Juror5 1 -../cli/target/release/bright_disputes_cli confirm-juror-participation //Juror6 1 -../cli/target/release/bright_disputes_cli confirm-judge-participation //Juror1 1 +Public key: [209,186,95,203,236,84,246,136,3,232,135,235,5,218,13,168,128,89,67,143,5,125,187,223,178,40,113,238,18,97,242,81] + +Private key: [25,164,133,151,251,54,205,192,212,173,218,155,210,238,98,4,36,68,162,114,94,30,134,181,187,167,219,131,227,25,202,6] ``` + When all Jurors and Judge confirms participation in the dispute, we can proceed with the dispute round: ``` ../cli/target/release/bright_disputes_cli process-dispute-round //Owner 1 ``` -and start a `Voting` phase, where Jurors can vote against one of the parties: +and start a `Voting` phase, where Jurors can vote against one of the parties. For this dispute all jurors will vote against the owner: +``` +../cli/target/release/bright_disputes_cli vote //Juror1 1 1 179,168,214,171,19,120,215,166,1,175,173,235,85,161,223,244,253,121,185,141,92,32,171,52,154,20,21,152,97,250,190,6 +``` + +``` +../cli/target/release/bright_disputes_cli vote //Juror2 1 1 250,71,107,70,4,169,48,81,216,97,222,161,213,137,52,53,250,3,165,188,184,58,181,151,160,0,153,178,252,164,62,7 +``` + ``` -../cli/target/release/bright_disputes_cli vote //Juror4 1 1 -../cli/target/release/bright_disputes_cli vote //Juror5 1 1 -../cli/target/release/bright_disputes_cli vote //Juror6 1 1 +../cli/target/release/bright_disputes_cli vote //Juror3 1 1 214,199,173,149,198,9,55,208,20,165,65,187,65,103,253,211,174,91,92,193,21,244,157,43,215,163,41,161,15,65,106,4 ``` Once again we need to proceed with the dispute round: ``` @@ -78,7 +116,7 @@ Once again we need to proceed with the dispute round: ``` which moves us to the next phase which is `Counting the Votes`. Now the role of Judge came in, and he need to count the votes: ``` -../cli/target/release/bright_disputes_cli process-dispute-round //Juror1 1 +../cli/target/release/bright_disputes_cli count-the-votes //Juror4 1 25,164,133,151,251,54,205,192,212,173,218,155,210,238,98,4,36,68,162,114,94,30,134,181,187,167,219,131,227,25,202,6 ``` finally we can finish the dispute and distribute the deposit: ``` diff --git a/tests/Cargo.lock b/tests/Cargo.lock index 2e05c44..dd11a8a 100644 --- a/tests/Cargo.lock +++ b/tests/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -29,20 +29,20 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -94,9 +94,274 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59d2a3357dde987206219e78ecfbbb6e8dad06cbb65292758d3270e6254f7355" + +[[package]] +name = "ark-bls12-381" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65be532f9dd1e98ad0150b037276cde464c6f371059e6dd02c0222395761f6aa" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-crypto-primitives" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff773c0ef8c655c98071d3026a63950798a66b2f45baef22d8334c1756f1bd18" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-nonnative-field", + "ark-r1cs-std", + "ark-relations", + "ark-serialize", + "ark-snark", + "ark-std", + "blake2 0.9.2", + "derivative", + "digest 0.9.0", + "tracing", +] + +[[package]] +name = "ark-ec" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea978406c4b1ca13c2db2373b05cc55429c3575b8b21f1b9ee859aa5b03dd42" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ed-on-bls12-381" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b7ada17db3854f5994e74e60b18e10e818594935ee7e1d329800c117b32970" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-r1cs-std", + "ark-std", +] + +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-gm17" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94713045868e99a606a89825ff5a901667ba707ad1966a32c7f3a4d4dbcc0e9a" +dependencies = [ + "ark-crypto-primitives", + "ark-ec", + "ark-ff", + "ark-poly", + "ark-relations", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-groth16" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f8fff7468e947130b5caf9bdd27de8b913cf30e15104b4f0cd301726b3d897" +dependencies = [ + "ark-crypto-primitives", + "ark-ec", + "ark-ff", + "ark-poly", + "ark-relations", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-marlin" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caa8510faa8e64f0a6841ee4b58efe2d56f7a80d86fa0ce9891bbb3aa20166d9" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-poly-commit", + "ark-relations", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.9.0", + "rand_chacha 0.3.1", +] + +[[package]] +name = "ark-nonnative-field" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "440ad4569974910adbeb84422b7e622b79e08d27142afd113785b7fcfb446186" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-r1cs-std", + "ark-relations", + "ark-std", + "derivative", + "num-bigint", + "num-integer", + "num-traits", + "tracing", +] + +[[package]] +name = "ark-poly" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0f78f47537c2f15706db7e98fe64cc1711dbf9def81218194e17239e53e5aa" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.11.2", +] + +[[package]] +name = "ark-poly-commit" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "a71ddfa72bad1446cab7bbecb6018dbbdc9abcbc3a0065483ae5186ad2a64dcd" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-nonnative-field", + "ark-poly", + "ark-relations", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.9.0", + "tracing", +] + +[[package]] +name = "ark-r1cs-std" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e8fdacb1931f238a0d866ced1e916a49d36de832fd8b83dc916b718ae72893" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-relations", + "ark-std", + "derivative", + "num-bigint", + "num-traits", + "tracing", +] + +[[package]] +name = "ark-relations" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cba4c1c99792a6834bd97f7fd76578ec2cd58d2afc5139a17e1d1bec65b38f6" +dependencies = [ + "ark-ff", + "ark-std", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest 0.9.0", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd4e5f0bf8285d5ed538d27fab7411f3e297908fd93c62195de8bee3f199e82" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-snark" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc3dff1a5f67a9c0b34df32b079752d8dd17f1e9d06253da0453db6c1b7cc8a" +dependencies = [ + "ark-ff", + "ark-relations", + "ark-std", +] + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits", + "rand 0.8.5", +] [[package]] name = "array-bytes" @@ -124,22 +389,22 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-lock" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ "event-listener", ] [[package]] name = "async-trait" -version = "0.1.69" +version = "0.1.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b2d0f03b3640e3a630367e40c468cb7f309529c708ed1d88597047b0e7c6ef7" +checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.42", ] [[package]] @@ -150,9 +415,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -177,9 +442,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "beef" @@ -208,6 +473,17 @@ dependencies = [ "wyz", ] +[[package]] +name = "blake2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + [[package]] name = "blake2" version = "0.10.6" @@ -257,14 +533,32 @@ dependencies = [ ] [[package]] -name = "bright_disputes" +name = "bright-disputes-lib" +version = "0.1.0" +dependencies = [ + "aleph_client", + "anyhow", + "ark-ed-on-bls12-381", + "ark-serialize", + "ark-std", + "ink_primitives", + "liminal-ark-relations", +] + +[[package]] +name = "bright_disputes_tests" version = "0.1.0" dependencies = [ "aleph_client", "anyhow", + "ark-ed-on-bls12-381", + "ark-serialize", + "ark-std", "async-trait", + "bright-disputes-lib", "ink-wrapper-types", "ink_primitives", + "liminal-ark-relations", "once_cell", "parity-scale-codec", "rand 0.8.5", @@ -282,9 +576,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byte-slice-cast" @@ -300,21 +594,24 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -324,14 +621,14 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "winapi", + "windows-targets", ] [[package]] @@ -342,7 +639,7 @@ checksum = "e6aa9a99669a8f4eba55782175659dbb20459698c5a65a9f3efe7b9330dd667b" dependencies = [ "anyhow", "impl-serde", - "semver", + "semver 1.0.20", "serde", "serde_json", "url", @@ -356,7 +653,7 @@ checksum = "e4e3806efabf4c29f2aeff708e076cac60609ee6c5897299f163355b1cec242c" dependencies = [ "anyhow", "base58", - "blake2", + "blake2 0.10.6", "contract-metadata", "escape8259", "hex", @@ -377,9 +674,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -387,15 +684,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -577,9 +874,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.11" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" +checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "ed25519-zebra" @@ -597,9 +894,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "environmental" @@ -609,9 +906,9 @@ checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" [[package]] name = "equivalent" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "escape8259" @@ -654,9 +951,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -681,9 +978,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -696,9 +993,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -706,15 +1003,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -724,32 +1021,32 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.42", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-timer" @@ -759,9 +1056,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -809,9 +1106,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "js-sys", @@ -822,15 +1119,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "h2" -version = "0.3.20" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ "bytes", "fnv", @@ -838,7 +1135,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.1.0", "slab", "tokio", "tokio-util", @@ -860,6 +1157,15 @@ dependencies = [ "crunchy", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -871,9 +1177,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" @@ -883,9 +1189,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -926,9 +1232,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -937,9 +1243,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -954,15 +1260,15 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -984,10 +1290,11 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.2" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ + "futures-util", "http", "hyper", "log", @@ -1000,16 +1307,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -1029,9 +1336,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1084,12 +1391,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.3", ] [[package]] @@ -1109,36 +1416,36 @@ dependencies = [ [[package]] name = "ink_allocator" -version = "4.2.1" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cb3178f207f6a37c3512142c8c6c2561a2aac61d60baa934d08d1e55a67d4a8" +checksum = "870914970470fd77a3f42d3c5d1918b562817af127fd063ee8b1d9fbf59aa1fe" dependencies = [ "cfg-if", ] [[package]] name = "ink_engine" -version = "4.2.1" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c9abc50b932893113e782761ac719c46214ecd10c423a3f626dce30a0c61b45" +checksum = "722ec3a5eb557124b001c60ff8f961079f6d566af643edea579f152b15822fe5" dependencies = [ - "blake2", + "blake2 0.10.6", "derive_more", "ink_primitives", "parity-scale-codec", "secp256k1 0.27.0", - "sha2 0.10.7", + "sha2 0.10.8", "sha3", ] [[package]] name = "ink_env" -version = "4.2.0" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d5e1505c5deb7280743e4d7df72a91f52bbf4cb063f464c73f89dce00c70f92" +checksum = "584e73bc0982f6f1a067bb63ebc75262f6dc54ed2a17060efa73eaba84dc9308" dependencies = [ "arrayref", - "blake2", + "blake2 0.10.6", "cfg-if", "derive_more", "ink_allocator", @@ -1150,20 +1457,20 @@ dependencies = [ "parity-scale-codec", "paste", "rlibc", - "scale-decode 0.5.0", + "scale-decode 0.9.0", "scale-encode", "scale-info", "secp256k1 0.27.0", - "sha2 0.10.7", + "sha2 0.10.8", "sha3", "static_assertions", ] [[package]] name = "ink_metadata" -version = "4.2.1" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fb2b5ad83f725a6d0c8886ca737964d0013a193ca2d21c7e514fd427672416" +checksum = "3fddff95ce3e01f42002fdaf96edda691dbccb08c9ae76d7101daa1fa634e601" dependencies = [ "derive_more", "impl-serde", @@ -1175,23 +1482,23 @@ dependencies = [ [[package]] name = "ink_prelude" -version = "4.2.1" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6f174d742ff929abe66716ad8159f324441b4ff5161a3b0e282f416afbbac1" +checksum = "d8cfdf91d2b442f08efb34dd3780fd6fbd3d033f63b42f62684fe47534948ef6" dependencies = [ "cfg-if", ] [[package]] name = "ink_primitives" -version = "4.2.1" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b4e4772e1b9384233103c1f488df9854d24b3c16168bcf23613b7d98fb363f" +checksum = "6414bcad12ebf0c3abbbb192a09e4d06e22f662cf3e19545204e1b0684be12a1" dependencies = [ "derive_more", "ink_prelude", "parity-scale-codec", - "scale-decode 0.5.0", + "scale-decode 0.9.0", "scale-encode", "scale-info", "xxhash-rust", @@ -1199,9 +1506,9 @@ dependencies = [ [[package]] name = "ink_storage_traits" -version = "4.2.1" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4179f00b052e5955ab7535c1a69042a468771217e9db6a12de2cdbfcb03c861" +checksum = "a8dcb50f70377ac35c28d63b06383a0a3cbb79542ea4cdc5b00e3e2b3de4a549" dependencies = [ "ink_metadata", "ink_prelude", @@ -1230,9 +1537,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "joinery" @@ -1242,18 +1549,18 @@ checksum = "72167d68f5fce3b8655487b8038691a3c9984ee769590f93f2a631f4ad64e4f5" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] [[package]] name = "jsonrpsee" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d291e3a5818a2384645fd9756362e6d89cf0541b0b916fa7702ea4a9833608e" +checksum = "367a292944c07385839818bb71c8d76611138e2dedb0677d035b8da21d29c78b" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -1263,9 +1570,9 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965de52763f2004bc91ac5bcec504192440f0b568a5d621c59d9dbd6f886c3fb" +checksum = "c8b3815d9f5d5de348e5f162b316dc9cdf4548305ebb15b4eb9328e66cf27d7a" dependencies = [ "futures-util", "http", @@ -1284,9 +1591,9 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" +checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" dependencies = [ "anyhow", "async-lock", @@ -1307,9 +1614,9 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc345b0a43c6bc49b947ebeb936e886a419ee3d894421790c969cc56040542ad" +checksum = "7e5f9fabdd5d79344728521bb65e3106b49ec405a78b66fbff073b72b389fa43" dependencies = [ "async-trait", "hyper", @@ -1326,9 +1633,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd522fe1ce3702fd94812965d7bb7a3364b1c9aba743944c5a00529aae80f8c" +checksum = "245ba8e5aa633dd1c1e4fae72bce06e71f42d34c14a2767c6b4d173b57bee5e5" dependencies = [ "anyhow", "beef", @@ -1355,15 +1662,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libsecp256k1" @@ -1413,11 +1720,105 @@ dependencies = [ "libsecp256k1-core", ] +[[package]] +name = "liminal-ark-pnbr-poseidon-parameters" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8723da56ab98f2182cbd27b9c510ca3c7f7bd616a56ca0e6b8f1b4bbc2c5f2ee" +dependencies = [ + "anyhow", + "ark-ff", + "num-integer", +] + +[[package]] +name = "liminal-ark-pnbr-poseidon-permutation" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0419b780a13b09a1ed2db09c6c61752f24e5f341f77a93719cd8bc963b72d3" +dependencies = [ + "ark-ff", + "ark-std", + "liminal-ark-pnbr-poseidon-parameters", +] + +[[package]] +name = "liminal-ark-pnbr-sponge" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6c178b0470950ac7fb73646df0f6ef60452d7b0fb0819e41dbe66674abc622f" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-nonnative-field", + "ark-r1cs-std", + "ark-relations", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.9.0", + "rand_chacha 0.3.1", + "tracing", +] + +[[package]] +name = "liminal-ark-poseidon" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ff555fb3914d246c1d478b66d248d4e59daac3784f05c24a707a55d9a6bd2b" +dependencies = [ + "ark-bls12-381", + "ark-ff", + "ark-r1cs-std", + "ark-relations", + "liminal-ark-pnbr-poseidon-parameters", + "liminal-ark-pnbr-poseidon-permutation", + "liminal-ark-pnbr-sponge", + "paste", +] + +[[package]] +name = "liminal-ark-relation-macro" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fffc8341caed7e6993016cce8f08cb47a13117cc54b1bf0df6c739536d690f4" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "liminal-ark-relations" +version = "0.4.0" +dependencies = [ + "ark-bls12-381", + "ark-crypto-primitives", + "ark-ec", + "ark-ed-on-bls12-381", + "ark-ff", + "ark-gm17", + "ark-groth16", + "ark-marlin", + "ark-poly", + "ark-poly-commit", + "ark-r1cs-std", + "ark-relations", + "ark-serialize", + "ark-snark", + "ark-std", + "blake2 0.9.2", + "liminal-ark-poseidon", + "liminal-ark-relation-macro", + "paste", +] + [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -1425,9 +1826,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" @@ -1444,14 +1845,14 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memory-db" @@ -1499,9 +1900,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", @@ -1539,9 +1940,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -1582,9 +1983,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -1601,18 +2002,18 @@ dependencies = [ [[package]] name = "object" -version = "0.31.1" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -1647,9 +2048,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.3" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "756d439303e94fae44f288ba881ad29670c65b0c4b0e05674ca81061bb65f2c5" +checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -1662,11 +2063,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.3" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d884d78fcf214d70b1e239fcd1c6e5e95aa3be1881918da2e488cc946c7a476" +checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 2.0.1", "proc-macro2", "quote", "syn 1.0.109", @@ -1716,9 +2117,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", @@ -1729,9 +2130,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pbkdf2" @@ -1753,35 +2154,46 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pest" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] [[package]] name = "pin-project" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.42", ] [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -1797,9 +2209,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "primitive-types" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", @@ -1815,7 +2227,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +dependencies = [ + "toml_datetime", + "toml_edit 0.20.2", ] [[package]] @@ -1844,18 +2266,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.63" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" +checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.29" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -1926,7 +2348,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", ] [[package]] @@ -1949,42 +2371,43 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags", ] [[package]] name = "ref-cast" -version = "1.0.17" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85d07b1a5f16b5548f4255a978c94259971aff73f39e8d67e8250e8b2f6667c3" +checksum = "53313ec9f12686aeeffb43462c3ac77aa25f590a5f630eb2cde0de59417b29c7" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.17" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a930b010d9effee5834317bb7ff406b76af7724348fd572b38705b4bd099fa92" +checksum = "2566c4bf6845f2c2e83b27043c3f5dfcd5ba8f2937d6c00dc009bfb51a079dc4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.42", ] [[package]] name = "regex" -version = "1.8.4" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.2", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] @@ -1996,6 +2419,17 @@ dependencies = [ "regex-syntax 0.6.29", ] +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.2", +] + [[package]] name = "regex-syntax" version = "0.6.29" @@ -2004,23 +2438,22 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "ring" -version = "0.16.20" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", + "getrandom 0.2.11", "libc", - "once_cell", "spin", "untrusted", - "web-sys", - "winapi", + "windows-sys", ] [[package]] @@ -2047,16 +2480,25 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + [[package]] name = "rustls" -version = "0.20.8" +version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", + "rustls-webpki", "sct", - "webpki", ] [[package]] @@ -2073,24 +2515,34 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64 0.21.2", + "base64 0.21.5", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", ] [[package]] name = "rustversion" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "scale-bits" @@ -2103,6 +2555,16 @@ dependencies = [ "serde", ] +[[package]] +name = "scale-bits" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "036575c29af9b6e4866ffb7fa055dbf623fe7a9cc159b33786de6013a6969d89" +dependencies = [ + "parity-scale-codec", + "scale-info", +] + [[package]] name = "scale-decode" version = "0.4.0" @@ -2110,32 +2572,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d823d4be477fc33321f93d08fb6c2698273d044f01362dc27573a750deb7c233" dependencies = [ "parity-scale-codec", - "scale-bits", + "scale-bits 0.3.0", "scale-info", "thiserror", ] [[package]] name = "scale-decode" -version = "0.5.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e5527e4b3bf079d4c0b2f253418598c380722ba37ef20fac9088081407f2b6" +checksum = "7789f5728e4e954aaa20cadcc370b99096fb8645fca3c9333ace44bb18f30095" dependencies = [ + "derive_more", "parity-scale-codec", - "scale-bits", + "scale-bits 0.4.0", "scale-decode-derive", "scale-info", - "thiserror", + "smallvec", ] [[package]] name = "scale-decode-derive" -version = "0.5.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38741b2f78e4391b94eac6b102af0f6ea2b0f7fe65adb55d7f4004f507854db" +checksum = "27873eb6005868f8cc72dcfe109fae664cf51223d35387bc2f28be4c28d94c47" dependencies = [ "darling", - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2143,24 +2606,25 @@ dependencies = [ [[package]] name = "scale-encode" -version = "0.1.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15546e5efbb45f0fc2291f7e202dee8623274c5d8bbfdf9c6886cc8b44a7ced3" +checksum = "6d70cb4b29360105483fac1ed567ff95d65224a14dd275b6303ed0a654c78de5" dependencies = [ + "derive_more", "parity-scale-codec", "scale-encode-derive", "scale-info", - "thiserror", + "smallvec", ] [[package]] name = "scale-encode-derive" -version = "0.1.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd983cf0a9effd76138554ead18a6de542d1af175ac12fd5e91836c5c0268082" +checksum = "995491f110efdc6bea96d6a746140e32bfceb4ea47510750a5467295a4707a25" dependencies = [ "darling", - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2168,9 +2632,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "bitvec", "cfg-if", @@ -2182,11 +2646,11 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2201,7 +2665,7 @@ dependencies = [ "either", "frame-metadata", "parity-scale-codec", - "scale-bits", + "scale-bits 0.3.0", "scale-decode 0.4.0", "scale-info", "serde", @@ -2238,15 +2702,15 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ "ring", "untrusted", @@ -2299,9 +2763,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ "bitflags", "core-foundation", @@ -2312,9 +2776,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ "core-foundation-sys", "libc", @@ -2322,38 +2786,56 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" dependencies = [ "serde", ] +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "serde" -version = "1.0.166" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01b7404f9d441d3ad40e6a636a7782c377d2abdbe4fa2440e2edcc2f4f10db8" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.166" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dd83d6dde2b6b2d466e14d9d1acce8816dedee94f735eac6395808b3483c6d6" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.42", ] [[package]] name = "serde_json" -version = "1.0.99" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -2400,9 +2882,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -2421,36 +2903,36 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "socket2" -version = "0.4.9" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "winapi", + "windows-sys", ] [[package]] @@ -2507,7 +2989,7 @@ dependencies = [ "array-bytes", "base58", "bitflags", - "blake2", + "blake2 0.10.6", "byteorder", "dyn-clonable", "ed25519-zebra", @@ -2550,10 +3032,10 @@ version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49b9d1daa6aebfc144729b630885e91df92ff00560490ec065a56cb538e8895a" dependencies = [ - "blake2", + "blake2 0.10.6", "byteorder", "digest 0.10.7", - "sha2 0.10.7", + "sha2 0.10.8", "sha3", "sp-std", "twox-hash", @@ -2687,7 +3169,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a157f1ce0108b9b87f87e826726049d9b6253318b74410c814be7fc2af416b51" dependencies = [ "Inflector", - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2805,15 +3287,15 @@ dependencies = [ [[package]] name = "spin" -version = "0.5.2" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "ss58-registry" -version = "1.41.0" +version = "1.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfc443bad666016e012538782d9e3006213a7db43e9fb1dda91657dc06a6fa08" +checksum = "35935738370302d5e33963665b77541e4b990a3e919ec904c837a56cfc891de1" dependencies = [ "Inflector", "num-format", @@ -2838,9 +3320,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "substrate-bip39" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +checksum = "e620c7098893ba667438b47169c00aacdd9e7c10e042250ce2b60b087ec97328" dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", @@ -2865,7 +3347,7 @@ dependencies = [ "derivative", "frame-metadata", "futures", - "getrandom 0.2.10", + "getrandom 0.2.11", "hex", "jsonrpsee", "parity-scale-codec", @@ -2941,9 +3423,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.23" +version = "2.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" +checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" dependencies = [ "proc-macro2", "quote", @@ -2970,22 +3452,22 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.42", ] [[package]] @@ -3034,11 +3516,10 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", @@ -3052,31 +3533,30 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.42", ] [[package]] name = "tokio-rustls" -version = "0.23.4" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ "rustls", "tokio", - "webpki", ] [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -3095,11 +3575,22 @@ checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" [[package]] name = "toml_edit" -version = "0.19.11" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266f016b7f039eec8a1a80dfe6156b633d208b9fccca5e4db1d6775b0c4e34a7" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.1.0", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap 2.1.0", "toml_datetime", "winnow", ] @@ -3112,11 +3603,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -3124,20 +3614,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.42", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -3145,12 +3635,12 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -3210,9 +3700,9 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "twox-hash" @@ -3228,9 +3718,15 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "ucd-trie" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uint" @@ -3246,15 +3742,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -3273,15 +3769,15 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "untrusted" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -3324,9 +3820,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3334,24 +3830,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.42", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3359,22 +3855,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.42", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "wasmi" @@ -3409,34 +3905,11 @@ dependencies = [ "num-traits", ] -[[package]] -name = "web-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "webpki" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki-roots" -version = "0.22.6" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" -dependencies = [ - "webpki", -] +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" [[package]] name = "winapi" @@ -3461,10 +3934,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ "windows-targets", ] @@ -3480,9 +3953,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -3495,51 +3968,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.4.7" +version = "0.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" +checksum = "9b5c3db89721d50d0e2a673f5043fc4722f76dcc352d7b1ab8b8288bed4ed2c5" dependencies = [ "memchr", ] @@ -3555,9 +4028,9 @@ dependencies = [ [[package]] name = "xxhash-rust" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "735a71d46c4d68d71d4b24d03fdc2b98e38cea81730595801db779c04fe80d70" +checksum = "53be06678ed9e83edb1745eb72efc0bbcd7b5c3c35711a860906aed827a13d61" [[package]] name = "yap" @@ -3567,9 +4040,9 @@ checksum = "5fc77f52dc9e9b10d55d3f4462c3b7fc393c4f17975d641542833ab2d3bc26ef" [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] @@ -3582,5 +4055,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.42", ] diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 4a09ff9..4ca6672 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "bright_disputes" +name = "bright_disputes_tests" version = "0.1.0" authors = ["Bright Inventions"] edition = "2021" @@ -9,14 +9,20 @@ license = "MIT" path = "lib.rs" [dependencies] -ink-wrapper-types = "0.5.0" scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -ink_primitives = "4.0.1" -aleph_client = "3.0.0" async-trait = "0.1.68" # These are a couple dependencies we will use to write our tests tokio = { version = "1.25.0", features = ["macros"] } rand = "0.8.5" anyhow = "1.0.71" -once_cell = "1.17.1" \ No newline at end of file +once_cell = "1.17.1" + +bright-disputes-lib = { path="../cli/lib" } +ark-std = { version = "^0.3.0", default-features = false } +ark-ed-on-bls12-381 = { version = "^0.3.0", features = ["r1cs"] } +ark-serialize = { version = "^0.3.0", default-features = false } +aleph_client = "3.0.0" +ink-wrapper-types = "0.5.0" +ink_primitives = "4.3.0" +liminal-ark-relations = { version = "0.4.0", path = "../aleph-node/relations/ark" } diff --git a/tests/README.md b/tests/README.md index a91d15e..1d46bc2 100644 --- a/tests/README.md +++ b/tests/README.md @@ -31,5 +31,5 @@ cargo contract upload --manifest-path contract/Cargo.toml --suri //Alice --url w Now we can run e2e tests: ``` -cargo +nightly test --release -``` \ No newline at end of file +cargo +nightly-2023-04-19 test --release +``` diff --git a/tests/bright_disputes.rs b/tests/bright_disputes.rs index 3cf6126..3103470 100644 --- a/tests/bright_disputes.rs +++ b/tests/bright_disputes.rs @@ -4,14 +4,14 @@ use scale::Encode as _; #[allow(dead_code)] pub const CODE_HASH: [u8; 32] = [ - 179, 189, 99, 47, 197, 174, 131, 44, 115, 1, 178, 61, 71, 213, 130, 167, 213, 69, 39, 112, 144, - 89, 168, 255, 17, 165, 66, 233, 165, 43, 229, 145, + 134, 34, 57, 191, 103, 29, 44, 56, 12, 231, 88, 242, 64, 144, 53, 34, 131, 56, 170, 238, 192, + 142, 229, 240, 82, 204, 67, 181, 250, 239, 22, 82, ]; #[derive(Debug, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] pub struct Vote { pub juror: ink_primitives::AccountId, - pub vote: u8, + pub vote: [u64; 4], } #[derive(Debug, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] @@ -31,6 +31,7 @@ pub struct Dispute { pub juries: Vec, pub banned: Vec, pub votes: Vec, + pub votes_hash: [u64; 4], } #[derive(Debug, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] @@ -75,6 +76,7 @@ pub enum BrightDisputesError { JurorAlreadyAssignedToDispute(), JurorIsNotAssignedToDispute(), JurorAlreadyConfirmedDispute(), + JurorHasNotConfirmedDispute(), JurorInvalidState(), JurorNotExist(), JuriesPoolIsToSmall(), @@ -105,6 +107,21 @@ pub enum BabyLiminalError { VerifyErrorUnknown(), } +#[derive(Debug, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] +pub enum Verdict { + None(), + Negative(), + Positive(), +} + +#[derive(Debug, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] +pub enum Relation { + Vote(), + VerdictNegative(), + VerdictNone(), + VerdictPositive(), +} + #[derive(Debug, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] pub struct Extension(); @@ -197,6 +214,17 @@ impl Instance { ink_wrapper_types::ReadCall::new(self.account_id, data) } + /// Get juries pool + #[allow(dead_code, clippy::too_many_arguments)] + pub fn get_juries_pool( + &self, + ) -> ink_wrapper_types::ReadCall< + Result, ink_wrapper_types::InkLangError>, + > { + let data = vec![3, 234, 94, 249]; + ink_wrapper_types::ReadCall::new(self.account_id, data) + } + /// Get single dispute by id #[allow(dead_code, clippy::too_many_arguments)] pub fn remove_dispute(&self, dispute_id: u32) -> ink_wrapper_types::ExecCall { @@ -276,11 +304,18 @@ impl Instance { /// Voting, only juror can do it. #[allow(dead_code, clippy::too_many_arguments)] - pub fn vote(&self, dispute_id: u32, vote: u8, proof: Vec) -> ink_wrapper_types::ExecCall { + pub fn vote( + &self, + dispute_id: u32, + vote: [u64; 4], + hash_of_all_votes: [u64; 4], + proof: Vec, + ) -> ink_wrapper_types::ExecCall { let data = { let mut data = vec![8, 59, 226, 96]; dispute_id.encode_to(&mut data); vote.encode_to(&mut data); + hash_of_all_votes.encode_to(&mut data); proof.encode_to(&mut data); data }; @@ -307,10 +342,12 @@ impl Instance { pub fn confirm_juror_participation_in_dispute( &self, dispute_id: u32, + public_key: Vec, ) -> ink_wrapper_types::ExecCallNeedsValue { let data = { let mut data = vec![141, 200, 7, 55]; dispute_id.encode_to(&mut data); + public_key.encode_to(&mut data); data }; ink_wrapper_types::ExecCallNeedsValue::new(self.account_id, data) @@ -321,20 +358,36 @@ impl Instance { pub fn confirm_judge_participation_in_dispute( &self, dispute_id: u32, + public_key: Vec, ) -> ink_wrapper_types::ExecCallNeedsValue { let data = { let mut data = vec![178, 215, 24, 15]; dispute_id.encode_to(&mut data); + public_key.encode_to(&mut data); data }; ink_wrapper_types::ExecCallNeedsValue::new(self.account_id, data) } #[allow(dead_code, clippy::too_many_arguments)] - pub fn count_the_votes(&self, dispute_id: u32, proof: Vec) -> ink_wrapper_types::ExecCall { + pub fn issue_the_verdict( + &self, + dispute_id: u32, + votes_maximum: u8, + votes_minimum: u8, + verdict: Verdict, + hashed_votes: [u64; 4], + jurors_banned: Vec, + proof: Vec, + ) -> ink_wrapper_types::ExecCall { let data = { - let mut data = vec![231, 126, 247, 3]; + let mut data = vec![6, 210, 102, 105]; dispute_id.encode_to(&mut data); + votes_maximum.encode_to(&mut data); + votes_minimum.encode_to(&mut data); + verdict.encode_to(&mut data); + hashed_votes.encode_to(&mut data); + jurors_banned.encode_to(&mut data); proof.encode_to(&mut data); data }; @@ -362,4 +415,34 @@ impl Instance { }; ink_wrapper_types::ExecCall::new(self.account_id, data) } + + /// Register a verification key. + #[allow(dead_code, clippy::too_many_arguments)] + pub fn register_vk(&self, relation: Relation, vk: Vec) -> ink_wrapper_types::ExecCall { + let data = { + let mut data = vec![165, 234, 12, 120]; + relation.encode_to(&mut data); + vk.encode_to(&mut data); + data + }; + ink_wrapper_types::ExecCall::new(self.account_id, data) + } + + /// Get Juror/Judge public key if he is assigned to the dispute. + #[allow(dead_code, clippy::too_many_arguments)] + pub fn juror_public_key( + &self, + dispute_id: u32, + juror_id: ink_primitives::AccountId, + ) -> ink_wrapper_types::ReadCall< + Result, BrightDisputesError>, ink_wrapper_types::InkLangError>, + > { + let data = { + let mut data = vec![198, 90, 15, 199]; + dispute_id.encode_to(&mut data); + juror_id.encode_to(&mut data); + data + }; + ink_wrapper_types::ReadCall::new(self.account_id, data) + } } diff --git a/tests/bright_disputes_test.rs b/tests/bright_disputes_test.rs index b0516f8..b20ee65 100644 --- a/tests/bright_disputes_test.rs +++ b/tests/bright_disputes_test.rs @@ -1,28 +1,133 @@ use aleph_client::{SignedConnection, SignedConnectionApi}; use anyhow::Result; +use core::iter::zip; use ink_wrapper_types::{util::ToAccountId, Connection as _, SignedConnection as _}; use rand::RngCore as _; +use bright_disputes_lib::{prepare_counting_inputs, prepare_voting_inputs, PublicVote}; +use liminal_ark_relations::disputes::VerdictRelation; +use std::path::PathBuf; + use crate::{ - bright_disputes, - bright_disputes::{DisputeResult, DisputeState, RoundState}, + bright_disputes::{DisputeResult, DisputeState, Instance, RoundState, Verdict}, helpers::{alephs, create_new_connection, create_new_connections}, }; -async fn connect_and_deploy() -> Result<(SignedConnection, bright_disputes::Instance)> { +async fn connect_and_deploy() -> Result<(SignedConnection, Instance)> { let conn = create_new_connection().await?; let mut salt = vec![0; 32]; rand::thread_rng().fill_bytes(&mut salt); - let contract = conn - .instantiate(bright_disputes::Instance::new().with_salt(salt)) - .await?; + let contract = conn.instantiate(Instance::new().with_salt(salt)).await?; Ok((conn, contract)) } +#[derive(Clone)] +struct KeyPair { + pub public: Vec, + pub private: Vec, +} + +struct Setup { + vote_pk: PathBuf, + verdict_none_pk: PathBuf, + verdict_negative_pk: PathBuf, + verdict_positive_pk: PathBuf, + judge: KeyPair, + jurors: Vec, + jurors_extended: Vec, + jurors_large: Vec, +} + +impl Setup { + fn new() -> Self { + let juries_base = vec![ + KeyPair { + public: vec![ + 143, 96, 146, 215, 67, 186, 237, 47, 231, 60, 4, 227, 180, 180, 227, 175, 139, + 11, 9, 212, 45, 153, 174, 82, 61, 94, 185, 142, 229, 93, 248, 141, + ], + private: vec![ + 179, 168, 214, 171, 19, 120, 215, 166, 1, 175, 173, 235, 85, 161, 223, 244, + 253, 121, 185, 141, 92, 32, 171, 52, 154, 20, 21, 152, 97, 250, 190, 6, + ], + }, + KeyPair { + public: vec![ + 93, 66, 190, 16, 93, 13, 181, 112, 42, 68, 88, 90, 88, 65, 241, 30, 80, 202, + 221, 3, 137, 104, 89, 40, 93, 2, 69, 100, 36, 104, 158, 72, + ], + private: vec![ + 250, 71, 107, 70, 4, 169, 48, 81, 216, 97, 222, 161, 213, 137, 52, 53, 250, 3, + 165, 188, 184, 58, 181, 151, 160, 0, 153, 178, 252, 164, 62, 7, + ], + }, + KeyPair { + public: vec![ + 199, 48, 32, 250, 139, 107, 224, 127, 96, 217, 223, 140, 130, 3, 111, 69, 146, + 249, 47, 219, 36, 50, 38, 216, 154, 163, 197, 232, 65, 72, 57, 115, + ], + private: vec![ + 214, 199, 173, 149, 198, 9, 55, 208, 20, 165, 65, 187, 65, 103, 253, 211, 174, + 91, 92, 193, 21, 244, 157, 43, 215, 163, 41, 161, 15, 65, 106, 4, + ], + }, + ]; + + let juries_extended = vec![ + KeyPair { + public: vec![ + 80, 178, 234, 242, 171, 209, 22, 130, 199, 254, 117, 68, 133, 250, 75, 85, 234, + 102, 19, 27, 233, 156, 129, 188, 151, 189, 75, 102, 11, 7, 166, 10, + ], + private: vec![ + 129, 115, 160, 93, 168, 200, 122, 82, 174, 154, 170, 159, 113, 154, 16, 88, + 236, 9, 196, 177, 244, 70, 44, 155, 75, 214, 69, 78, 100, 219, 245, 3, + ], + }, + KeyPair { + public: vec![ + 16, 95, 167, 2, 64, 164, 179, 52, 113, 155, 196, 127, 52, 53, 166, 5, 162, 184, + 107, 58, 249, 150, 181, 89, 156, 141, 228, 36, 170, 156, 2, 159, + ], + private: vec![ + 109, 73, 196, 180, 234, 25, 39, 144, 20, 144, 101, 198, 157, 48, 146, 204, 169, + 91, 59, 90, 133, 23, 138, 171, 193, 194, 158, 189, 148, 150, 204, 1, + ], + }, + ]; + + Self { + vote_pk: "../scripts/docker/keys/vote.groth16.pk.bytes".into(), + verdict_none_pk: "../scripts/docker/keys/verdict_none.groth16.pk.bytes".into(), + verdict_negative_pk: "../scripts/docker/keys/verdict_negative.groth16.pk.bytes".into(), + verdict_positive_pk: "../scripts/docker/keys/verdict_positive.groth16.pk.bytes".into(), + judge: KeyPair { + public: vec![ + 209, 186, 95, 203, 236, 84, 246, 136, 3, 232, 135, 235, 5, 218, 13, 168, 128, + 89, 67, 143, 5, 125, 187, 223, 178, 40, 113, 238, 18, 97, 242, 81, + ], + private: vec![ + 25, 164, 133, 151, 251, 54, 205, 192, 212, 173, 218, 155, 210, 238, 98, 4, 36, + 68, 162, 114, 94, 30, 134, 181, 187, 167, 219, 131, 227, 25, 202, 6, + ], + }, + jurors: juries_base.clone(), + jurors_extended: juries_extended.clone(), + jurors_large: juries_base + .clone() + .into_iter() + .chain(juries_extended.clone()) + .collect(), + } + } +} + #[tokio::test] -async fn test_dispute_success() -> Result<()> { +async fn test_dispute_verdict_positive() -> Result<()> { + let setup = Setup::new(); + // Create dispute owner, deploy on establish connection. let (owner_conn, contract) = connect_and_deploy().await?; @@ -86,10 +191,10 @@ async fn test_dispute_success() -> Result<()> { assert_eq!(juries_conn.len(), 3); // Confirm all juries participation - for conn in &juries_conn { + for (juror, conn) in zip(&setup.jurors, &juries_conn) { conn.exec( contract - .confirm_juror_participation_in_dispute(dispute_id) + .confirm_juror_participation_in_dispute(dispute_id, juror.public.clone()) .with_value(escrow), ) .await?; @@ -99,7 +204,7 @@ async fn test_dispute_success() -> Result<()> { judge_conn .exec( contract - .confirm_judge_participation_in_dispute(dispute_id) + .confirm_judge_participation_in_dispute(dispute_id, setup.judge.public.clone()) .with_value(escrow), ) .await?; @@ -111,8 +216,21 @@ async fn test_dispute_success() -> Result<()> { .await?; // Voting - for conn in &juries_conn { - conn.exec(contract.vote(dispute_id, 1)).await?; + let mut votes_hash = [1u64; 4]; + for (juror, conn) in zip(&setup.jurors, &juries_conn) { + let vote: u8 = 1; + let (encrypted_vote, new_encrypted_all_votes, proof) = prepare_voting_inputs( + vote, + votes_hash, + setup.judge.public.clone(), + juror.private.clone(), + &setup.vote_pk, + )?; + + votes_hash = new_encrypted_all_votes.clone(); + + conn.exec(contract.vote(dispute_id, encrypted_vote, new_encrypted_all_votes, proof)) + .await?; } // Process dispute round, check if all juries votes and move to counting the votes @@ -120,9 +238,51 @@ async fn test_dispute_success() -> Result<()> { .exec(contract.process_dispute_round(dispute_id)) .await?; - // Process dispute round, count the votes and move to ending phase + // Get information about dispute, judge and juries + let dispute = owner_conn + .read(contract.get_dispute(dispute_id)) + .await?? + .expect("Unable to get dispute!"); + + let votes: Vec = dispute + .votes + .iter() + .enumerate() + .map(|(index, &ref vote)| { + let key = setup.jurors.get(index).unwrap(); + PublicVote { + id: vote.juror.clone(), + pub_key: key.public.clone(), + hashed_vote: vote.vote, + } + }) + .collect(); + + let (votes_maximum, votes_minimum, verdict, hashed_votes, jurors_banned, proof) = + prepare_counting_inputs( + setup.judge.private.clone(), + votes, + &setup.verdict_none_pk, + &setup.verdict_negative_pk, + &setup.verdict_positive_pk, + )?; + + let ink_verdict = match verdict { + VerdictRelation::Positive => Verdict::Positive(), + VerdictRelation::Negative => Verdict::Negative(), + VerdictRelation::None => Verdict::None(), + }; + judge_conn - .exec(contract.process_dispute_round(dispute_id)) + .exec(contract.issue_the_verdict( + dispute_id, + votes_maximum, + votes_minimum, + ink_verdict, + hashed_votes, + jurors_banned, + proof, + )) .await?; // Get dispute and check verdict @@ -135,8 +295,353 @@ async fn test_dispute_success() -> Result<()> { Ok(()) } +#[tokio::test] +async fn test_dispute_verdict_negative() -> Result<()> { + let setup = Setup::new(); + + // Create dispute owner, deploy on establish connection. + let (owner_conn, contract) = connect_and_deploy().await?; + + // Define escrow + let escrow = alephs(20); + + // Create a dispute defendant + let defendant_conn = create_new_connection().await?; + let defendant = defendant_conn.signer().account_id().to_account_id(); + + // Create a dispute + owner_conn + .exec( + contract + .create_dispute("".into(), defendant, escrow) + .with_value(escrow), + ) + .await?; + + let dispute_id = owner_conn.read(contract.get_last_dispute_id()).await??; + assert!(dispute_id == 1u32); + + // Defendant confirm dispute + defendant_conn + .exec( + contract + .confirm_defendant(dispute_id, "https://brightinventions.pl/".into()) + .with_value(escrow), + ) + .await?; + + // Create juries + let all_juries_conn: Vec = create_new_connections(4).await?; + + // Register as a juror + for conn in &all_juries_conn { + conn.exec(contract.register_as_an_active_juror()).await?; + } + + // Process dispute round, assign juries and judge to dispute + owner_conn + .exec(contract.process_dispute_round(dispute_id)) + .await?; + + // Get information about dispute, judge and juries + let dispute = owner_conn + .read(contract.get_dispute(dispute_id)) + .await?? + .expect("Unable to get dispute!"); + let juries_conn: Vec = all_juries_conn + .iter() + .filter(|&conn| dispute.juries.contains(&conn.account_id().to_account_id())) + .map(|conn| conn.clone()) + .collect(); + let judge_conn = all_juries_conn + .iter() + .find(|&conn| { + conn.account_id().to_account_id() == dispute.judge.expect("Jude not assigned!") + }) + .expect("Failed to find judge!"); + assert_eq!(juries_conn.len(), 3); + + // Confirm all juries participation + for (juror, conn) in zip(&setup.jurors, &juries_conn) { + conn.exec( + contract + .confirm_juror_participation_in_dispute(dispute_id, juror.public.clone()) + .with_value(escrow), + ) + .await?; + } + + // Confirm judge participation + judge_conn + .exec( + contract + .confirm_judge_participation_in_dispute(dispute_id, setup.judge.public.clone()) + .with_value(escrow), + ) + .await?; + + // Process dispute round, at this stage we check if all juries and judge confirmed their + // participation in the dispute, move to voting phase. + owner_conn + .exec(contract.process_dispute_round(dispute_id)) + .await?; + + // Voting + let mut votes_hash = [1u64; 4]; + for (juror, conn) in zip(&setup.jurors, &juries_conn) { + let vote: u8 = 0; + let (encrypted_vote, new_encrypted_all_votes, proof) = prepare_voting_inputs( + vote, + votes_hash, + setup.judge.public.clone(), + juror.private.clone(), + &setup.vote_pk, + )?; + + votes_hash = new_encrypted_all_votes.clone(); + + conn.exec(contract.vote(dispute_id, encrypted_vote, new_encrypted_all_votes, proof)) + .await?; + } + + // Process dispute round, check if all juries votes and move to counting the votes + owner_conn + .exec(contract.process_dispute_round(dispute_id)) + .await?; + + // Get information about dispute, judge and juries + let dispute = owner_conn + .read(contract.get_dispute(dispute_id)) + .await?? + .expect("Unable to get dispute!"); + + let votes: Vec = dispute + .votes + .iter() + .enumerate() + .map(|(index, &ref vote)| { + let key = setup.jurors.get(index).unwrap(); + PublicVote { + id: vote.juror.clone(), + pub_key: key.public.clone(), + hashed_vote: vote.vote, + } + }) + .collect(); + + let (votes_maximum, votes_minimum, verdict, hashed_votes, jurors_banned, proof) = + prepare_counting_inputs( + setup.judge.private.clone(), + votes, + &setup.verdict_none_pk, + &setup.verdict_negative_pk, + &setup.verdict_positive_pk, + )?; + + let ink_verdict = match verdict { + VerdictRelation::Positive => Verdict::Positive(), + VerdictRelation::Negative => Verdict::Negative(), + VerdictRelation::None => Verdict::None(), + }; + + judge_conn + .exec(contract.issue_the_verdict( + dispute_id, + votes_maximum, + votes_minimum, + ink_verdict, + hashed_votes, + jurors_banned, + proof, + )) + .await?; + + // Get dispute and check verdict + let dispute = owner_conn + .read(contract.get_dispute(dispute_id)) + .await?? + .expect("Unable to get dispute!"); + assert!(dispute.dispute_result.unwrap() == DisputeResult::Defendant()); + + Ok(()) +} + +#[tokio::test] +async fn test_dispute_verdict_none() -> Result<()> { + let setup = Setup::new(); + + // Create dispute owner, deploy on establish connection. + let (owner_conn, contract) = connect_and_deploy().await?; + + // Define escrow + let escrow = alephs(20); + + // Create a dispute defendant + let defendant_conn = create_new_connection().await?; + let defendant = defendant_conn.signer().account_id().to_account_id(); + + // Create a dispute + owner_conn + .exec( + contract + .create_dispute("".into(), defendant, escrow) + .with_value(escrow), + ) + .await?; + + let dispute_id = owner_conn.read(contract.get_last_dispute_id()).await??; + assert!(dispute_id == 1u32); + + // Defendant confirm dispute + defendant_conn + .exec( + contract + .confirm_defendant(dispute_id, "https://brightinventions.pl/".into()) + .with_value(escrow), + ) + .await?; + + // Create juries + let all_juries_conn: Vec = create_new_connections(4).await?; + + // Register as a juror + for conn in &all_juries_conn { + conn.exec(contract.register_as_an_active_juror()).await?; + } + + // Process dispute round, assign juries and judge to dispute + owner_conn + .exec(contract.process_dispute_round(dispute_id)) + .await?; + + // Get information about dispute, judge and juries + let dispute = owner_conn + .read(contract.get_dispute(dispute_id)) + .await?? + .expect("Unable to get dispute!"); + let juries_conn: Vec = all_juries_conn + .iter() + .filter(|&conn| dispute.juries.contains(&conn.account_id().to_account_id())) + .map(|conn| conn.clone()) + .collect(); + let judge_conn = all_juries_conn + .iter() + .find(|&conn| { + conn.account_id().to_account_id() == dispute.judge.expect("Jude not assigned!") + }) + .expect("Failed to find judge!"); + assert_eq!(juries_conn.len(), 3); + + // Confirm all juries participation + for (juror, conn) in zip(&setup.jurors, &juries_conn) { + conn.exec( + contract + .confirm_juror_participation_in_dispute(dispute_id, juror.public.clone()) + .with_value(escrow), + ) + .await?; + } + + // Confirm judge participation + judge_conn + .exec( + contract + .confirm_judge_participation_in_dispute(dispute_id, setup.judge.public.clone()) + .with_value(escrow), + ) + .await?; + + // Process dispute round, at this stage we check if all juries and judge confirmed their + // participation in the dispute, move to voting phase. + owner_conn + .exec(contract.process_dispute_round(dispute_id)) + .await?; + + // Voting + let mut votes_hash = [1u64; 4]; + let mut vote: u8 = 1; + for (juror, conn) in zip(&setup.jurors, &juries_conn) { + let (encrypted_vote, new_encrypted_all_votes, proof) = prepare_voting_inputs( + vote, + votes_hash, + setup.judge.public.clone(), + juror.private.clone(), + &setup.vote_pk, + )?; + + votes_hash = new_encrypted_all_votes.clone(); + + conn.exec(contract.vote(dispute_id, encrypted_vote, new_encrypted_all_votes, proof)) + .await?; + vote = (vote + 1) % 2; + } + + // Process dispute round, check if all juries votes and move to counting the votes + owner_conn + .exec(contract.process_dispute_round(dispute_id)) + .await?; + + // Get information about dispute, judge and juries + let dispute = owner_conn + .read(contract.get_dispute(dispute_id)) + .await?? + .expect("Unable to get dispute!"); + + let votes: Vec = dispute + .votes + .iter() + .enumerate() + .map(|(index, &ref vote)| { + let key = setup.jurors.get(index).unwrap(); + PublicVote { + id: vote.juror.clone(), + pub_key: key.public.clone(), + hashed_vote: vote.vote, + } + }) + .collect(); + + let (votes_maximum, votes_minimum, verdict, hashed_votes, jurors_banned, proof) = + prepare_counting_inputs( + setup.judge.private.clone(), + votes, + &setup.verdict_none_pk, + &setup.verdict_negative_pk, + &setup.verdict_positive_pk, + )?; + + let ink_verdict = match verdict { + VerdictRelation::Positive => Verdict::Positive(), + VerdictRelation::Negative => Verdict::Negative(), + VerdictRelation::None => Verdict::None(), + }; + + judge_conn + .exec(contract.issue_the_verdict( + dispute_id, + votes_maximum, + votes_minimum, + ink_verdict, + hashed_votes, + jurors_banned, + proof, + )) + .await?; + + // Get dispute and check verdict + let dispute = owner_conn + .read(contract.get_dispute(dispute_id)) + .await?? + .expect("Unable to get dispute!"); + assert!(dispute.dispute_result.is_none()); + + Ok(()) +} + #[tokio::test] async fn test_dispute_rounds() -> Result<()> { + let setup = Setup::new(); + // Create dispute owner, deploy on establish connection. let (owner_conn, contract) = connect_and_deploy().await?; @@ -186,7 +691,7 @@ async fn test_dispute_rounds() -> Result<()> { .read(contract.get_dispute(dispute_id)) .await?? .expect("Unable to get dispute!"); - let juries_conn: Vec = all_juries_conn + let mut juries_conn: Vec = all_juries_conn .iter() .filter(|&conn| dispute.juries.contains(&conn.account_id().to_account_id())) .map(|conn| conn.clone()) @@ -200,12 +705,16 @@ async fn test_dispute_rounds() -> Result<()> { assert_eq!(juries_conn.len(), 3); assert_eq!(dispute.juries.len(), 3); assert_eq!(dispute.dispute_round_counter, 0); + assert_eq!( + dispute.dispute_round.clone().unwrap().state, + RoundState::PickingJuriesAndJudge() + ); // Confirm all juries participation - for conn in &juries_conn { + for (juror, conn) in zip(&setup.jurors, &juries_conn) { conn.exec( contract - .confirm_juror_participation_in_dispute(dispute_id) + .confirm_juror_participation_in_dispute(dispute_id, juror.public.clone()) .with_value(escrow), ) .await?; @@ -215,7 +724,7 @@ async fn test_dispute_rounds() -> Result<()> { judge_conn .exec( contract - .confirm_judge_participation_in_dispute(dispute_id) + .confirm_judge_participation_in_dispute(dispute_id, setup.judge.public.clone()) .with_value(escrow), ) .await?; @@ -227,9 +736,23 @@ async fn test_dispute_rounds() -> Result<()> { .await?; // Voting, majority of votes is not reached - juries_conn[0].exec(contract.vote(dispute_id, 1)).await?; - juries_conn[1].exec(contract.vote(dispute_id, 1)).await?; - juries_conn[2].exec(contract.vote(dispute_id, 0)).await?; + let mut votes_hash = [1u64; 4]; + let mut vote: u8 = 1; + for (juror, conn) in zip(&setup.jurors, &juries_conn) { + let (encrypted_vote, new_encrypted_all_votes, proof) = prepare_voting_inputs( + vote, + votes_hash, + setup.judge.public.clone(), + juror.private.clone(), + &setup.vote_pk, + )?; + + votes_hash = new_encrypted_all_votes.clone(); + + conn.exec(contract.vote(dispute_id, encrypted_vote, new_encrypted_all_votes, proof)) + .await?; + vote = (vote + 1) % 2; + } // Process dispute round, check if all juries votes and move to counting the votes owner_conn @@ -247,12 +770,48 @@ async fn test_dispute_rounds() -> Result<()> { RoundState::CountingTheVotes() ); - // Process dispute round, count the votes and start new dispute round + // Counting the votes and issue the verdict + let votes: Vec = dispute + .votes + .iter() + .enumerate() + .map(|(index, &ref vote)| { + let key = setup.jurors.get(index).unwrap(); + PublicVote { + id: vote.juror.clone(), + pub_key: key.public.clone(), + hashed_vote: vote.vote, + } + }) + .collect(); + + let (votes_maximum, votes_minimum, verdict, hashed_votes, jurors_banned, proof) = + prepare_counting_inputs( + setup.judge.private.clone(), + votes, + &setup.verdict_none_pk, + &setup.verdict_negative_pk, + &setup.verdict_positive_pk, + )?; + + let ink_verdict = match verdict { + VerdictRelation::Positive => Verdict::Positive(), + VerdictRelation::Negative => Verdict::Negative(), + VerdictRelation::None => Verdict::None(), + }; + judge_conn - .exec(contract.process_dispute_round(dispute_id)) + .exec(contract.issue_the_verdict( + dispute_id, + votes_maximum, + votes_minimum, + ink_verdict, + hashed_votes, + jurors_banned, + proof, + )) .await?; - // Get information about dispute and juries let dispute = owner_conn .read(contract.get_dispute(dispute_id)) .await?? @@ -260,53 +819,50 @@ async fn test_dispute_rounds() -> Result<()> { assert_eq!(dispute.juries.len(), 3); assert_eq!(dispute.dispute_round.clone().unwrap().number_of_juries, 5); assert_eq!(dispute.dispute_round_counter, 1); + assert_eq!(dispute.state, DisputeState::Running()); + assert!(dispute.dispute_result.is_none()); + assert!(dispute.judge.is_some()); + assert_eq!( + dispute.dispute_round.clone().unwrap().state, + RoundState::AssignJuriesAndJudge() + ); // Process dispute round, assign juries to dispute owner_conn .exec(contract.process_dispute_round(dispute_id)) .await?; - // Get information about dispute and juries let dispute = owner_conn .read(contract.get_dispute(dispute_id)) .await?? .expect("Unable to get dispute!"); - let juries_round_two_conn: Vec = all_juries_conn - .iter() - .filter(|&conn| dispute.juries.contains(&conn.account_id().to_account_id())) - .map(|conn| conn.clone()) - .collect(); assert_eq!(dispute.juries.len(), 5); - assert_eq!(juries_round_two_conn.len(), 5); + assert_eq!(dispute.dispute_round.clone().unwrap().number_of_juries, 5); + assert_eq!( + dispute.dispute_round.clone().unwrap().state, + RoundState::PickingJuriesAndJudge() + ); - // New juries need to confirm participation in dispute - let diff_juries_conn: Vec = juries_round_two_conn + let new_juries_conn: Vec = all_juries_conn .iter() - .filter(|conn| { - juries_conn - .iter() - .find(|c| c.account_id() == conn.account_id()) - .is_none() + .filter(|&conn| { + conn.account_id().to_account_id() == *dispute.juries.get(3).expect("Jude not assigned!") + || conn.account_id().to_account_id() + == *dispute.juries.get(4).expect("Jude not assigned!") }) .map(|conn| conn.clone()) .collect(); - assert_eq!(diff_juries_conn.len(), 2); - assert_eq!( - dispute.dispute_round.clone().unwrap().state, - RoundState::PickingJuriesAndJudge() - ); - assert!(dispute.judge.is_some()); - assert_eq!(dispute.state, DisputeState::Running()); // Confirm juries participation in dispute. - for conn in &diff_juries_conn { + for (juror, conn) in zip(&setup.jurors_extended, &new_juries_conn) { conn.exec( contract - .confirm_juror_participation_in_dispute(dispute_id) + .confirm_juror_participation_in_dispute(dispute_id, juror.public.clone()) .with_value(escrow), ) .await?; } + juries_conn.extend(new_juries_conn); // Process dispute round, at this stage we check if all juries and judge confirmed their // participation in the dispute, move to voting phase. @@ -314,38 +870,78 @@ async fn test_dispute_rounds() -> Result<()> { .exec(contract.process_dispute_round(dispute_id)) .await?; - // Voting, majority of votes is not reached - juries_round_two_conn[0] - .exec(contract.vote(dispute_id, 1)) - .await?; - juries_round_two_conn[1] - .exec(contract.vote(dispute_id, 1)) - .await?; - juries_round_two_conn[2] - .exec(contract.vote(dispute_id, 1)) - .await?; - juries_round_two_conn[3] - .exec(contract.vote(dispute_id, 1)) - .await?; - juries_round_two_conn[4] - .exec(contract.vote(dispute_id, 0)) + // Voting + let mut votes_hash = [1u64; 4]; + for (juror, conn) in zip(&setup.jurors_large, &juries_conn) { + let vote: u8 = 1; + let (encrypted_vote, new_encrypted_all_votes, proof) = prepare_voting_inputs( + vote, + votes_hash, + setup.judge.public.clone(), + juror.private.clone(), + &setup.vote_pk, + )?; + + votes_hash = new_encrypted_all_votes.clone(); + + conn.exec(contract.vote(dispute_id, encrypted_vote, new_encrypted_all_votes, proof)) + .await?; + } + + // Process dispute round, check if all juries votes and move to counting the votes + owner_conn + .exec(contract.process_dispute_round(dispute_id)) .await?; - // Get information about dispute and juries let dispute = owner_conn .read(contract.get_dispute(dispute_id)) .await?? .expect("Unable to get dispute!"); - assert_eq!(dispute.votes.len(), 5); + assert_eq!( + dispute.dispute_round.clone().unwrap().state, + RoundState::CountingTheVotes() + ); - // Process dispute round, check if all juries votes and move to counting the votes - owner_conn - .exec(contract.process_dispute_round(dispute_id)) - .await?; + // Counting the votes and issue the verdict + let votes: Vec = dispute + .votes + .iter() + .enumerate() + .map(|(index, &ref vote)| { + let key = setup.jurors_large.get(index).unwrap(); + PublicVote { + id: vote.juror.clone(), + pub_key: key.public.clone(), + hashed_vote: vote.vote, + } + }) + .collect(); + + let (votes_maximum, votes_minimum, verdict, hashed_votes, jurors_banned, proof) = + prepare_counting_inputs( + setup.judge.private.clone(), + votes, + &setup.verdict_none_pk, + &setup.verdict_negative_pk, + &setup.verdict_positive_pk, + )?; + + let ink_verdict = match verdict { + VerdictRelation::Positive => Verdict::Positive(), + VerdictRelation::Negative => Verdict::Negative(), + VerdictRelation::None => Verdict::None(), + }; - // Process dispute round, count the votes and move to ending phase judge_conn - .exec(contract.process_dispute_round(dispute_id)) + .exec(contract.issue_the_verdict( + dispute_id, + votes_maximum, + votes_minimum, + ink_verdict, + hashed_votes, + jurors_banned, + proof, + )) .await?; // Get dispute and check verdict