diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e8a819bb..37600776 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -125,5 +125,8 @@ jobs: - name: test if: steps.git-diff.outputs.diff + env: + TEST_DATA_DIR: test-data run: | + rm -rf "node/${TEST_DATA_DIR}" cargo test --locked --package=ggxchain-node --release --no-default-features --features=${{ matrix.runtime }} diff --git a/Cargo.lock b/Cargo.lock index f63cbfab..be5fb092 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,6 +51,15 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" +[[package]] +name = "aead" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +dependencies = [ + "generic-array 0.14.7", +] + [[package]] name = "aead" version = "0.5.2" @@ -68,7 +77,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" dependencies = [ "cfg-if 1.0.0", - "cipher", + "cipher 0.4.4", "cpufeatures", ] @@ -78,9 +87,9 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ - "aead", + "aead 0.5.2", "aes", - "cipher", + "cipher 0.4.4", "ctr", "ghash", "subtle", @@ -330,7 +339,7 @@ dependencies = [ "derivative", "digest 0.10.7", "itertools 0.10.5", - "num-bigint", + "num-bigint 0.4.4", "num-traits", "paste", "rustc_version 0.4.0", @@ -353,7 +362,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ - "num-bigint", + "num-bigint 0.4.4", "num-traits", "proc-macro2", "quote", @@ -408,7 +417,7 @@ dependencies = [ "ark-serialize-derive", "ark-std", "digest 0.10.7", - "num-bigint", + "num-bigint 0.4.4", ] [[package]] @@ -728,6 +737,28 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite 0.2.13", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "async-task" version = "4.7.0" @@ -860,6 +891,12 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + [[package]] name = "base16ct" version = "0.2.0" @@ -948,6 +985,38 @@ dependencies = [ "serde", ] +[[package]] +name = "bincode2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f49f6183038e081170ebbbadee6678966c7d54728938a3e7de7f4e780770318f" +dependencies = [ + "byteorder", + "serde", +] + +[[package]] +name = "bindgen" +version = "0.64.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +dependencies = [ + "bitflags 1.3.2", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log 0.4.20", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 1.0.109", + "which", +] + [[package]] name = "bindgen" version = "0.65.1" @@ -1168,7 +1237,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding", + "block-padding 0.1.5", "byte-tools", "byteorder", "generic-array 0.12.4", @@ -1180,6 +1249,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ + "block-padding 0.2.1", "generic-array 0.14.7", ] @@ -1201,6 +1271,12 @@ dependencies = [ "byte-tools", ] +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + [[package]] name = "blocking" version = "1.5.1" @@ -1400,6 +1476,20 @@ dependencies = [ "semver 0.6.0", ] +[[package]] +name = "bulletproof-kzen" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1ad3c6d12dfa84b0f3d33d3aafccd81a8a493c449216cb5246b66c846900f3" +dependencies = [ + "curv-kzen", + "generic-array 0.14.7", + "itertools 0.7.11", + "serde", + "serde_derive", + "sha2 0.9.9", +] + [[package]] name = "bumpalo" version = "3.14.0" @@ -1551,6 +1641,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "castaway" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a17ed5635fc8536268e5d4de1e22e81ac34419e5f052d4d51f4e01dcc263fcc" +dependencies = [ + "rustversion", +] + [[package]] name = "cc" version = "1.0.83" @@ -1561,6 +1660,21 @@ dependencies = [ "libc", ] +[[package]] +name = "centipede" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c30db9451346358a37cbabe951e4dfdfb34b0c0804df4bfdfc2978cb790a512" +dependencies = [ + "bulletproof-kzen", + "curv-kzen", + "generic-array 0.14.7", + "rayon", + "serde", + "serde_derive", + "sha2 0.9.9", +] + [[package]] name = "cexpr" version = "0.6.0" @@ -1597,6 +1711,18 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +[[package]] +name = "chacha20" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +dependencies = [ + "cfg-if 1.0.0", + "cipher 0.3.0", + "cpufeatures", + "zeroize", +] + [[package]] name = "chacha20" version = "0.9.1" @@ -1604,20 +1730,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ "cfg-if 1.0.0", - "cipher", + "cipher 0.4.4", "cpufeatures", ] +[[package]] +name = "chacha20poly1305" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" +dependencies = [ + "aead 0.4.3", + "chacha20 0.8.2", + "cipher 0.3.0", + "poly1305 0.7.2", + "zeroize", +] + [[package]] name = "chacha20poly1305" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" dependencies = [ - "aead", - "chacha20", - "cipher", - "poly1305", + "aead 0.5.2", + "chacha20 0.9.1", + "cipher 0.4.4", + "poly1305 0.8.0", "zeroize", ] @@ -1648,6 +1787,15 @@ dependencies = [ "unsigned-varint", ] +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array 0.14.7", +] + [[package]] name = "cipher" version = "0.4.4" @@ -1707,7 +1855,7 @@ version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 2.0.48", @@ -1768,7 +1916,7 @@ dependencies = [ "coins-core", "digest 0.10.7", "hmac 0.12.1", - "k256", + "k256 0.13.3", "serde", "sha2 0.10.8", "thiserror", @@ -1827,6 +1975,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "compact_str" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b5c3ee2b4ffa00ac2b00d1645cd9229ade668139bccf95f15fadcf374127b" +dependencies = [ + "castaway", + "itoa 1.0.10", + "ryu", +] + [[package]] name = "compare_fields" version = "0.2.0" @@ -2152,6 +2311,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array 0.14.7", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -2195,13 +2366,19 @@ dependencies = [ "subtle", ] +[[package]] +name = "cryptoxide" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35f15e1a0699dd988fed910dd78fdc6407f44654cd12589c91fa44ea67d9159" + [[package]] name = "ctr" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ - "cipher", + "cipher 0.4.4", ] [[package]] @@ -2224,6 +2401,40 @@ dependencies = [ "traits", ] +[[package]] +name = "curv-kzen" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a616b5f766fd80307f0e83de6326ccd9fe7b3ba4225fe4e12ae3a692a939d07b" +dependencies = [ + "cryptoxide", + "curve25519-dalek 3.2.0", + "digest 0.9.0", + "ff-zeroize", + "generic-array 0.14.7", + "hex", + "hmac 0.11.0", + "lazy_static", + "merkle-cbt", + "num-integer", + "num-traits", + "p256", + "pairing-plus", + "rand 0.6.5", + "rand 0.7.3", + "rust-gmp-kzen", + "secp256k1 0.20.3", + "serde", + "serde_bytes", + "serde_derive", + "sha2 0.8.2", + "sha2 0.9.9", + "sha3 0.9.1", + "thiserror", + "typenum", + "zeroize", +] + [[package]] name = "curve25519-dalek" version = "2.1.3" @@ -2466,6 +2677,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "der" version = "0.7.8" @@ -2485,7 +2706,7 @@ dependencies = [ "asn1-rs", "displaydoc", "nom", - "num-bigint", + "num-bigint 0.4.4", "num-traits", "rusticata-macros", ] @@ -2661,6 +2882,149 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "dkg-gadget" +version = "0.0.1" +source = "git+https://github.com/ggxchain/dkg-substrate.git?branch=polkadot-v0.9.43#a09f56758f6d92407e62c08cfe1a6810ed3666df" +dependencies = [ + "async-stream", + "async-trait", + "atomic", + "auto_impl", + "bincode2", + "curv-kzen", + "dkg-logging", + "dkg-mock-blockchain", + "dkg-primitives", + "dkg-runtime-primitives", + "futures 0.3.30", + "hex", + "itertools 0.10.5", + "lazy_static", + "linked-hash-map", + "multi-party-ecdsa", + "parity-scale-codec", + "parking_lot 0.12.1", + "rand 0.8.5", + "round-based", + "sc-client-api", + "sc-keystore", + "sc-network", + "sc-network-common", + "sc-network-sync", + "scale-info", + "serde", + "serde_json", + "sp-api", + "sp-application-crypto 7.0.0", + "sp-arithmetic 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", + "sp-blockchain", + "sp-consensus", + "sp-core 7.0.0", + "sp-keystore 0.13.0", + "sp-runtime 7.0.0", + "strum 0.21.0", + "substrate-prometheus-endpoint", + "sync_wrapper", + "thiserror", + "tokio 1.35.1", + "tokio-stream", + "uuid 1.6.1", + "webb-proposals", + "wsts", +] + +[[package]] +name = "dkg-logging" +version = "0.1.0" +source = "git+https://github.com/ggxchain/dkg-substrate.git?branch=polkadot-v0.9.43#a09f56758f6d92407e62c08cfe1a6810ed3666df" +dependencies = [ + "hex", + "lazy_static", + "parking_lot 0.12.1", + "serde", + "serde_json", + "sp-core 7.0.0", + "tokio 1.35.1", + "tracing", + "tracing-filter", + "tracing-subscriber 0.3.18", +] + +[[package]] +name = "dkg-mock-blockchain" +version = "0.1.0" +source = "git+https://github.com/ggxchain/dkg-substrate.git?branch=polkadot-v0.9.43#a09f56758f6d92407e62c08cfe1a6810ed3666df" +dependencies = [ + "async-trait", + "atomic", + "bincode2", + "bytes 1.5.0", + "dkg-logging", + "dkg-runtime-primitives", + "futures 0.3.30", + "humantime-serde", + "log 0.4.20", + "parity-scale-codec", + "sc-client-api", + "sc-network", + "sc-utils 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", + "serde", + "sp-consensus", + "sp-runtime 7.0.0", + "tokio 1.35.1", + "tokio-util 0.7.10", + "toml 0.7.8", + "uuid 1.6.1", +] + +[[package]] +name = "dkg-primitives" +version = "0.0.1" +source = "git+https://github.com/ggxchain/dkg-substrate.git?branch=polkadot-v0.9.43#a09f56758f6d92407e62c08cfe1a6810ed3666df" +dependencies = [ + "chacha20poly1305 0.9.1", + "clap", + "curv-kzen", + "dkg-runtime-primitives", + "hex", + "libsecp256k1", + "log 0.4.20", + "multi-party-ecdsa", + "parity-scale-codec", + "rand 0.8.5", + "sc-cli", + "sc-service", + "serde_json", + "sha3 0.9.1", + "sp-core 7.0.0", + "sp-keystore 0.13.0", + "sp-runtime 7.0.0", +] + +[[package]] +name = "dkg-runtime-primitives" +version = "0.0.1" +source = "git+https://github.com/ggxchain/dkg-substrate.git?branch=polkadot-v0.9.43#a09f56758f6d92407e62c08cfe1a6810ed3666df" +dependencies = [ + "ethabi 18.0.0", + "ethereum", + "ethereum-types 0.14.1", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-application-crypto 7.0.0", + "sp-core 7.0.0", + "sp-io 7.0.0", + "sp-runtime 7.0.0", + "sp-std 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", + "tiny-keccak 2.0.2", + "webb-proposals", +] + [[package]] name = "doc-comment" version = "0.3.3" @@ -2736,18 +3100,30 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der 0.6.1", + "elliptic-curve 0.12.3", + "rfc6979 0.3.1", + "signature 1.6.4", +] + [[package]] name = "ecdsa" version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ - "der", + "der 0.7.8", "digest 0.10.7", - "elliptic-curve", - "rfc6979", + "elliptic-curve 0.13.8", + "rfc6979 0.4.0", "signature 2.2.0", - "spki", + "spki 0.7.3", ] [[package]] @@ -2765,7 +3141,7 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", + "pkcs8 0.10.2", "signature 2.2.0", ] @@ -2817,21 +3193,41 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct 0.1.1", + "crypto-bigint 0.4.9", + "der 0.6.1", + "digest 0.10.7", + "ff 0.12.1", + "generic-array 0.14.7", + "group 0.12.1", + "pkcs8 0.9.0", + "rand_core 0.6.4", + "sec1 0.3.0", + "subtle", + "zeroize", +] + [[package]] name = "elliptic-curve" version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ - "base16ct", - "crypto-bigint", + "base16ct 0.2.0", + "crypto-bigint 0.5.5", "digest 0.10.7", - "ff", + "ff 0.13.0", "generic-array 0.14.7", - "group", - "pkcs8", + "group 0.13.0", + "pkcs8 0.10.2", "rand_core 0.6.4", - "sec1", + "sec1 0.7.3", "subtle", "zeroize", ] @@ -2863,7 +3259,7 @@ dependencies = [ "base64 0.21.7", "bytes 1.5.0", "hex", - "k256", + "k256 0.13.3", "log 0.4.20", "rand 0.8.5", "rlp", @@ -2878,7 +3274,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 1.0.109", @@ -3010,7 +3406,7 @@ dependencies = [ "sha2 0.10.8", "sha3 0.10.8", "thiserror", - "uuid", + "uuid 0.8.2", ] [[package]] @@ -3088,7 +3484,7 @@ dependencies = [ "ethereum_hashing", "hex", "lazy_static", - "num-bigint", + "num-bigint 0.4.4", "serde", "serde_yaml", ] @@ -3356,10 +3752,10 @@ dependencies = [ "cargo_metadata 0.18.1", "chrono", "const-hex", - "elliptic-curve", + "elliptic-curve 0.13.8", "ethabi 18.0.0", "generic-array 0.14.7", - "k256", + "k256 0.13.3", "num_enum 0.7.2", "once_cell", "open-fastrlp", @@ -3466,7 +3862,7 @@ dependencies = [ "coins-bip32", "coins-bip39", "const-hex", - "elliptic-curve", + "elliptic-curve 0.13.8", "eth-keystore", "ethers-core", "rand 0.8.5", @@ -3859,6 +4255,16 @@ dependencies = [ "traits", ] +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "ff" version = "0.13.0" @@ -3869,6 +4275,32 @@ dependencies = [ "subtle", ] +[[package]] +name = "ff-zeroize" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c02169a2e8515aa316ce516eaaf6318a76617839fbf904073284bc2576b029ee" +dependencies = [ + "byteorder", + "ff_derive-zeroize", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "ff_derive-zeroize" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b24d4059bc0d0a0bf26b740aa21af1f96a984f0ab7a21356d00b32475388b53a" +dependencies = [ + "num-bigint 0.2.6", + "num-integer", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "fiat-crypto" version = "0.2.5" @@ -4285,7 +4717,7 @@ dependencies = [ "frame-metadata 15.1.0", "frame-support-procedural", "impl-trait-for-tuples", - "k256", + "k256 0.13.3", "log 0.4.20", "once_cell", "parity-scale-codec", @@ -4685,6 +5117,8 @@ dependencies = [ "bitcoin 1.2.0", "btc-relay-rpc", "clap", + "dkg-gadget", + "dkg-primitives", "env_logger 0.10.1", "eth-types", "ethers", @@ -4716,7 +5150,7 @@ dependencies = [ "mmr-gadget", "mmr-rpc", "nix 0.26.4", - "num-bigint", + "num-bigint 0.4.4", "oracle-rpc", "pallet-balances", "pallet-eth2-light-client-relayer-gadget", @@ -4789,6 +5223,7 @@ dependencies = [ "btc-relay-rpc-runtime-api", "clients-info", "currency", + "dkg-runtime-primitives", "escrow", "fee", "fp-evm", @@ -4828,6 +5263,9 @@ dependencies = [ "pallet-contracts-primitives", "pallet-conviction-voting", "pallet-dex", + "pallet-dkg-metadata", + "pallet-dkg-proposal-handler", + "pallet-dkg-proposals", "pallet-dynamic-fee", "pallet-election-provider-multi-phase", "pallet-eth2-light-client", @@ -5097,13 +5535,24 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff 0.12.1", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "group" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ - "ff", + "ff 0.13.0", "rand_core 0.6.4", "subtle", ] @@ -5280,6 +5729,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "heck" version = "0.4.1" @@ -5306,6 +5764,9 @@ name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] [[package]] name = "hex-literal" @@ -5470,6 +5931,16 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "humantime-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" +dependencies = [ + "humantime", + "serde", +] + [[package]] name = "hyper" version = "0.10.16" @@ -6031,6 +6502,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_ci" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" + [[package]] name = "issue" version = "1.2.0" @@ -6087,6 +6564,15 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", ] +[[package]] +name = "itertools" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d47946d458e94a1b7bcabbf6521ea7c037062c81f534615abcad76e84d4970d" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.10.5" @@ -6238,7 +6724,7 @@ version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44e8ab85614a08792b9bff6c8feee23be78c98d0182d4c622c05256ab553892a" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro-crate 1.1.3", "proc-macro2", "quote", @@ -6307,6 +6793,18 @@ dependencies = [ "simple_asn1", ] +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if 1.0.0", + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", + "sha2 0.10.8", +] + [[package]] name = "k256" version = "0.13.3" @@ -6314,8 +6812,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if 1.0.0", - "ecdsa", - "elliptic-curve", + "ecdsa 0.16.9", + "elliptic-curve 0.13.8", "once_cell", "sha2 0.10.8", "signature 2.2.0", @@ -6383,6 +6881,17 @@ dependencies = [ "smallvec 1.12.0", ] +[[package]] +name = "kzen-paillier" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90b7e469348f203838b2ed1d46f068ba63162e7a1e63be868763a80bbd5d046f" +dependencies = [ + "curv-kzen", + "rayon", + "serde", +] + [[package]] name = "kzg" version = "0.1.0" @@ -6798,7 +7307,7 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" dependencies = [ - "heck", + "heck 0.4.1", "quote", "syn 1.0.109", ] @@ -7184,6 +7693,15 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "matches" version = "0.1.10" @@ -7301,6 +7819,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" +[[package]] +name = "merkle-cbt" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171d2f700835121c3b04ccf0880882987a050fd5c7ae88148abf537d33dd3a56" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "merkle-generator" version = "0.1.0" @@ -7369,6 +7896,37 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "miette" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c90329e44f9208b55f45711f9558cec15d7ef8295cc65ecd6d4188ae8edc58c" +dependencies = [ + "atty", + "backtrace", + "miette-derive", + "once_cell", + "owo-colors", + "supports-color", + "supports-hyperlinks", + "supports-unicode", + "terminal_size", + "textwrap", + "thiserror", + "unicode-width", +] + +[[package]] +name = "miette-derive" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b5bc45b761bcf1b5e6e6c4128cd93b84c218721a8d9b894aa0aff4ed180174c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "milagro_bls" version = "1.5.0" @@ -7547,6 +8105,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "multi-party-ecdsa" +version = "0.8.2" +source = "git+https://github.com/webb-tools/multi-party-ecdsa.git#a9a666d7debc1fc416d835d0b99ed071da76ab9f" +dependencies = [ + "centipede", + "curv-kzen", + "derivative", + "kzen-paillier", + "log 0.4.20", + "round-based", + "serde", + "sha2 0.9.9", + "subtle", + "thiserror", + "zeroize", + "zk-paillier", +] + [[package]] name = "multiaddr" version = "0.17.1" @@ -7883,13 +8460,23 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi 0.3.9", +] + [[package]] name = "num" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" dependencies = [ - "num-bigint", + "num-bigint 0.4.4", "num-complex", "num-integer", "num-iter", @@ -7897,6 +8484,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg 1.1.0", + "num-integer", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.4" @@ -7967,7 +8565,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg 1.1.0", - "num-bigint", + "num-bigint 0.4.4", "num-integer", "num-traits", ] @@ -8357,6 +8955,12 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "owning_ref" version = "0.4.1" @@ -8366,6 +8970,61 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "p256" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" +dependencies = [ + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", + "sha2 0.10.8", +] + +[[package]] +name = "p256k1" +version = "5.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e81c2cb5a1936d3f26278f9d698932239d03ddf0d5818392d91cd5f98ffc79" +dependencies = [ + "bindgen 0.64.0", + "bitvec", + "bs58 0.4.0", + "cc", + "hex", + "itertools 0.10.5", + "num-traits", + "primitive-types", + "proc-macro2", + "quote", + "rand_core 0.6.4", + "rustfmt-wrapper", + "serde", + "sha2 0.10.8", + "syn 2.0.48", +] + +[[package]] +name = "pairing-plus" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58cda4f22e8e6720f3c254049960c8cc4f93cb82b5ade43bddd2622b5f39ea62" +dependencies = [ + "byteorder", + "digest 0.8.1", + "ff-zeroize", + "rand 0.4.6", + "rand_core 0.5.1", + "rand_xorshift 0.2.0", + "zeroize", +] + [[package]] name = "pallet-assets" version = "4.0.0-dev" @@ -8625,6 +9284,71 @@ dependencies = [ "sp-runtime 7.0.0", ] +[[package]] +name = "pallet-dkg-metadata" +version = "0.2.0" +source = "git+https://github.com/ggxchain/dkg-substrate.git?branch=polkadot-v0.9.43#a09f56758f6d92407e62c08cfe1a6810ed3666df" +dependencies = [ + "dkg-runtime-primitives", + "frame-support", + "frame-system", + "hex", + "libsecp256k1", + "log 0.4.20", + "pallet-session", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-io 7.0.0", + "sp-runtime 7.0.0", + "sp-std 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", + "webb-proposals", +] + +[[package]] +name = "pallet-dkg-proposal-handler" +version = "0.1.0" +source = "git+https://github.com/ggxchain/dkg-substrate.git?branch=polkadot-v0.9.43#a09f56758f6d92407e62c08cfe1a6810ed3666df" +dependencies = [ + "dkg-runtime-primitives", + "ethabi 18.0.0", + "frame-support", + "frame-system", + "log 0.4.20", + "pallet-dkg-metadata", + "parity-scale-codec", + "scale-info", + "sp-core 7.0.0", + "sp-io 7.0.0", + "sp-runtime 7.0.0", + "sp-staking", + "sp-std 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", + "webb-proposals", +] + +[[package]] +name = "pallet-dkg-proposals" +version = "1.0.0" +source = "git+https://github.com/ggxchain/dkg-substrate.git?branch=polkadot-v0.9.43#a09f56758f6d92407e62c08cfe1a6810ed3666df" +dependencies = [ + "dkg-runtime-primitives", + "frame-benchmarking", + "frame-support", + "frame-system", + "k256 0.11.6", + "log 0.4.20", + "pallet-balances", + "pallet-dkg-metadata", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-core 7.0.0", + "sp-io 7.0.0", + "sp-runtime 7.0.0", + "sp-staking", + "sp-std 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", +] + [[package]] name = "pallet-dynamic-fee" version = "4.0.0-dev" @@ -9009,7 +9733,7 @@ dependencies = [ "hex-literal 0.3.4", "libsecp256k1", "log 0.4.20", - "num-bigint", + "num-bigint 0.4.4", "num_enum 0.5.11", "pallet-balances", "pallet-evm", @@ -10042,14 +10766,24 @@ dependencies = [ "futures-io", ] +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der 0.6.1", + "spki 0.6.0", +] + [[package]] name = "pkcs8" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der", - "spki", + "der 0.7.8", + "spki 0.7.3", ] [[package]] @@ -10187,6 +10921,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "poly1305" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" +dependencies = [ + "cpufeatures", + "opaque-debug 0.3.0", + "universal-hash 0.4.1", +] + [[package]] name = "poly1305" version = "0.8.0" @@ -10195,7 +10940,17 @@ checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "cpufeatures", "opaque-debug 0.3.0", - "universal-hash", + "universal-hash 0.5.1", +] + +[[package]] +name = "polynomial" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27abb6e4638dcecc65a92b50d7f1d87dd6dea987ba71db987b6bf881f4877e9d" +dependencies = [ + "num-traits", + "serde", ] [[package]] @@ -10207,7 +10962,7 @@ dependencies = [ "cfg-if 1.0.0", "cpufeatures", "opaque-debug 0.3.0", - "universal-hash", + "universal-hash 0.5.1", ] [[package]] @@ -10520,7 +11275,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" dependencies = [ "bytes 1.5.0", - "heck", + "heck 0.4.1", "itertools 0.10.5", "lazy_static", "log 0.4.20", @@ -10856,6 +11611,15 @@ dependencies = [ "rand_core 0.3.1", ] +[[package]] +name = "rand_xorshift" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8" +dependencies = [ + "rand_core 0.5.1", +] + [[package]] name = "rand_xorshift" version = "0.3.0" @@ -11235,6 +11999,17 @@ dependencies = [ "sp-api", ] +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint 0.4.9", + "hmac 0.12.1", + "zeroize", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -11321,6 +12096,19 @@ dependencies = [ "librocksdb-sys", ] +[[package]] +name = "round-based" +version = "0.1.7" +source = "git+https://github.com/webb-tools/round-based-protocol#959126f9f6edce16d4ee95954091b93e33a83140" +dependencies = [ + "async-stream", + "futures 0.3.30", + "log 0.4.20", + "serde", + "thiserror", + "tokio 1.35.1", +] + [[package]] name = "rpassword" version = "7.3.1" @@ -11434,6 +12222,17 @@ dependencies = [ "smallvec 1.12.0", ] +[[package]] +name = "rust-gmp-kzen" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e654bb304958a567aefa09e83cc313251388202c40bfc245fac19a0e2dd8d08" +dependencies = [ + "libc", + "num-traits", + "serde", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -11476,6 +12275,19 @@ dependencies = [ "semver 1.0.21", ] +[[package]] +name = "rustfmt-wrapper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1adc9dfed5cc999077978cc7163b9282c5751c8d39827c4ea8c8c220ca5a440" +dependencies = [ + "serde", + "tempfile", + "thiserror", + "toml 0.8.8", + "toolchain_find", +] + [[package]] name = "rusticata-macros" version = "4.1.0" @@ -11709,7 +12521,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" dependencies = [ - "cipher", + "cipher 0.4.4", ] [[package]] @@ -11956,7 +12768,7 @@ dependencies = [ "fork-tree", "futures 0.3.30", "log 0.4.20", - "num-bigint", + "num-bigint 0.4.4", "num-rational", "num-traits", "parity-scale-codec", @@ -12788,8 +13600,8 @@ dependencies = [ "sp-tracing 6.0.0", "thiserror", "tracing", - "tracing-log", - "tracing-subscriber", + "tracing-log 0.1.4", + "tracing-subscriber 0.2.25", ] [[package]] @@ -13181,16 +13993,30 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct 0.1.1", + "der 0.6.1", + "generic-array 0.14.7", + "pkcs8 0.9.0", + "subtle", + "zeroize", +] + [[package]] name = "sec1" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ - "base16ct", - "der", + "base16ct 0.2.0", + "der 0.7.8", "generic-array 0.14.7", - "pkcs8", + "pkcs8 0.10.2", "subtle", "zeroize", ] @@ -13203,6 +14029,17 @@ dependencies = [ "secp256k1-sys 0.4.0", ] +[[package]] +name = "secp256k1" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d03ceae636d0fed5bae6a7f4f664354c5f4fcedf6eef053fef17e49f837d0a" +dependencies = [ + "rand 0.6.5", + "secp256k1-sys 0.4.2", + "serde", +] + [[package]] name = "secp256k1" version = "0.24.3" @@ -13230,6 +14067,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" +dependencies = [ + "cc", +] + [[package]] name = "secp256k1-sys" version = "0.6.1" @@ -13536,6 +14382,18 @@ dependencies = [ "opaque-debug 0.2.3", ] +[[package]] +name = "sha3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +dependencies = [ + "block-buffer 0.9.0", + "digest 0.9.0", + "keccak", + "opaque-debug 0.3.0", +] + [[package]] name = "sha3" version = "0.10.8" @@ -13575,6 +14433,10 @@ name = "signature" version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] [[package]] name = "signature" @@ -13605,7 +14467,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" dependencies = [ - "num-bigint", + "num-bigint 0.4.4", "num-traits", "thiserror", "time 0.3.17", @@ -13674,6 +14536,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + [[package]] name = "smol" version = "1.3.0" @@ -13720,7 +14588,7 @@ dependencies = [ "merlin 3.0.0", "no-std-net", "nom", - "num-bigint", + "num-bigint 0.4.4", "num-rational", "num-traits", "pbkdf2 0.12.2", @@ -13786,7 +14654,7 @@ checksum = "58021967fd0a5eeeb23b08df6cc244a4d4a5b4aec1d27c9e02fad1a58b4cd74e" dependencies = [ "aes-gcm", "blake2", - "chacha20poly1305", + "chacha20poly1305 0.10.1", "curve25519-dalek 4.1.1", "rand_core 0.6.4", "ring 0.17.7", @@ -15034,7 +15902,7 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", "tracing", "tracing-core", - "tracing-subscriber", + "tracing-subscriber 0.2.25", ] [[package]] @@ -15047,7 +15915,7 @@ dependencies = [ "sp-std 6.0.0", "tracing", "tracing-core", - "tracing-subscriber", + "tracing-subscriber 0.2.25", ] [[package]] @@ -15060,7 +15928,7 @@ dependencies = [ "sp-std 8.0.0", "tracing", "tracing-core", - "tracing-subscriber", + "tracing-subscriber 0.2.25", ] [[package]] @@ -15295,6 +16163,16 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der 0.6.1", +] + [[package]] name = "spki" version = "0.7.3" @@ -15302,7 +16180,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", - "der", + "der 0.7.8", ] [[package]] @@ -15451,6 +16329,15 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "strum" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf86bbcfd1fa9670b7a129f64fc0c9fcbbfe4f1bc4210e9e98fe71ffc12cde2" +dependencies = [ + "strum_macros 0.21.1", +] + [[package]] name = "strum" version = "0.24.1" @@ -15469,13 +16356,25 @@ dependencies = [ "strum_macros 0.25.3", ] +[[package]] +name = "strum_macros" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "strum_macros" version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -15488,7 +16387,7 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -15738,7 +16637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e2f231d97c145c564bd544212c0cc0c29c09ff516af199f4ce00c8e055f8138" dependencies = [ "frame-metadata 15.1.0", - "heck", + "heck 0.4.1", "hex", "jsonrpsee", "parity-scale-codec", @@ -15757,7 +16656,7 @@ version = "0.31.0" source = "git+https://github.com/paritytech/subxt?tag=v0.31.0#059723e4313d91e8ca0bcd84b0dd7dd66686ca50" dependencies = [ "frame-metadata 16.0.0", - "heck", + "heck 0.4.1", "hex", "jsonrpsee", "parity-scale-codec", @@ -15869,6 +16768,34 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "supports-color" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" +dependencies = [ + "atty", + "is_ci", +] + +[[package]] +name = "supports-hyperlinks" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "590b34f7c5f01ecc9d78dba4b3f445f31df750a67621cf31626f3b7441ce6406" +dependencies = [ + "atty", +] + +[[package]] +name = "supports-unicode" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8b945e45b417b125a8ec51f1b7df2f8df7920367700d1f98aedd21e5735f8b2" +dependencies = [ + "atty", +] + [[package]] name = "svm-rs" version = "0.3.3" @@ -15920,6 +16847,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "synstructure" version = "0.12.6" @@ -16057,6 +16990,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "termtree" version = "0.4.1" @@ -16084,6 +17027,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "textwrap" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.56" @@ -16725,6 +17679,19 @@ dependencies = [ "winnow", ] +[[package]] +name = "toolchain_find" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc8c9a7f0a2966e1acdaf0461023d0b01471eeead645370cf4c3f5cff153f2a" +dependencies = [ + "home", + "once_cell", + "regex", + "semver 1.0.21", + "walkdir", +] + [[package]] name = "tower" version = "0.4.13" @@ -16799,6 +17766,24 @@ dependencies = [ "valuable", ] +[[package]] +name = "tracing-filter" +version = "0.1.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558d46b3870ac7328dbe682541d286b46588b7430c08484b821db23c2ee799a8" +dependencies = [ + "compact_str", + "matchers 0.1.0", + "miette", + "once_cell", + "regex", + "thiserror", + "thread_local", + "tracing", + "tracing-core", + "tracing-subscriber 0.3.18", +] + [[package]] name = "tracing-futures" version = "0.2.5" @@ -16820,6 +17805,17 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log 0.4.20", + "once_cell", + "tracing-core", +] + [[package]] name = "tracing-serde" version = "0.1.3" @@ -16839,7 +17835,7 @@ dependencies = [ "ansi_term", "chrono", "lazy_static", - "matchers", + "matchers 0.0.1", "parking_lot 0.11.2", "regex", "serde", @@ -16849,7 +17845,28 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log", + "tracing-log 0.1.4", + "tracing-serde", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers 0.1.0", + "nu-ansi-term", + "once_cell", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec 1.12.0", + "thread_local", + "tracing", + "tracing-core", + "tracing-log 0.2.0", "tracing-serde", ] @@ -16869,7 +17886,7 @@ dependencies = [ "impl-trait-for-tuples", "interbtc-primitives", "log 0.4.20", - "num-bigint", + "num-bigint 0.4.4", "num-traits", "parity-scale-codec", "scale-info", @@ -17246,6 +18263,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + [[package]] name = "unicode-normalization" version = "0.1.22" @@ -17255,6 +18278,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + [[package]] name = "unicode-width" version = "0.1.11" @@ -17267,6 +18296,16 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "universal-hash" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +dependencies = [ + "generic-array 0.14.7", + "subtle", +] + [[package]] name = "universal-hash" version = "0.5.1" @@ -17357,6 +18396,16 @@ dependencies = [ "serde", ] +[[package]] +name = "uuid" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +dependencies = [ + "getrandom 0.2.12", + "serde", +] + [[package]] name = "valuable" version = "0.1.0" @@ -18827,6 +19876,25 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wsts" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08b241e8440197fcd6e214a26fcaac82d7cdfde3ae964586f4b1a7c41a21ba6f" +dependencies = [ + "bs58 0.5.0", + "hashbrown 0.14.3", + "hex", + "num-traits", + "p256k1", + "polynomial", + "primitive-types", + "rand_core 0.6.4", + "serde", + "sha2 0.10.8", + "thiserror", +] + [[package]] name = "wyz" version = "0.5.1" @@ -19046,6 +20114,23 @@ dependencies = [ "zstd 0.11.2+zstd.1.5.2", ] +[[package]] +name = "zk-paillier" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "072972ea8d7c9829c9d87492ac021cf4b665b90c6c9b58fbeb6f71d036e66a04" +dependencies = [ + "bit-vec", + "curv-kzen", + "digest 0.9.0", + "kzen-paillier", + "rand 0.6.5", + "rayon", + "serde", + "sha2 0.9.9", + "thiserror", +] + [[package]] name = "zstd" version = "0.11.2+zstd.1.5.2" diff --git a/Cargo.toml b/Cargo.toml index c45f5996..7da78fde 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -298,6 +298,14 @@ vault-registry-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.g # Dex pallet-dex = { path = "pallet/dex", default-features = false } +# DKG substrate +dkg-gadget = { git = "https://github.com/ggxchain/dkg-substrate.git", branch = "polkadot-v0.9.43" } +dkg-primitives = { git = "https://github.com/ggxchain/dkg-substrate.git", branch = "polkadot-v0.9.43" } +dkg-runtime-primitives = { git = "https://github.com/ggxchain/dkg-substrate.git", branch = "polkadot-v0.9.43", default-features = false } +pallet-dkg-metadata = { git = "https://github.com/ggxchain/dkg-substrate.git", branch = "polkadot-v0.9.43", default-features = false } +pallet-dkg-proposal-handler = { git = "https://github.com/ggxchain/dkg-substrate.git", branch = "polkadot-v0.9.43", default-features = false } +pallet-dkg-proposals = { git = "https://github.com/ggxchain/dkg-substrate.git", branch = "polkadot-v0.9.43", default-features = false } + # Supress warnings from the peerset in logs during syncing # The polkadot did the same in the next release. See: # * https://github.com/paritytech/substrate/pull/14274 diff --git a/flake.nix b/flake.nix index 6964d6ca..2af5fb10 100644 --- a/flake.nix +++ b/flake.nix @@ -391,6 +391,7 @@ nodePackages.markdownlint-cli2 jq awscli2 + gmp ]; inputsFrom = [ diff --git a/node/Cargo.toml b/node/Cargo.toml index e8934ba7..197c4dbf 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -100,6 +100,10 @@ replace-rpc.workspace = true reward-rpc.workspace = true vault-registry-rpc.workspace = true +# DKG +dkg-gadget = { workspace = true, optional = true } +dkg-primitives = { workspace = true, optional = true } + [dev-dependencies] alloy-rlp = { workspace = true } assert_cmd = { workspace = true } @@ -133,6 +137,8 @@ default = ["brooklyn"] sydney = ["fast-runtime", "ggxchain-runtime-sydney"] brooklyn = [ "ggxchain-runtime-brooklyn", + "dkg-gadget", + "dkg-primitives", ] fast-runtime = [ "ggxchain-runtime-sydney?/fast-runtime", diff --git a/node/src/benchmarking.rs b/node/src/benchmarking.rs index 072f5626..3b8fac4e 100644 --- a/node/src/benchmarking.rs +++ b/node/src/benchmarking.rs @@ -149,7 +149,11 @@ pub fn create_benchmark_extrinsic( )), frame_system::CheckNonce::::from(nonce), frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(0), + ( + pallet_transaction_payment::ChargeTransactionPayment::::from(0), + #[cfg(feature = "allowlist")] + account_filter::account_filter::AllowAccount::::new(), + ), ); let raw_payload = runtime::SignedPayload::from_raw( diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index be104966..c6da1da8 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -87,7 +87,14 @@ pub fn development_config() -> Result { ), ], // Initial PoA authorities + // DKG requires greater than 1 authorities + #[cfg(not(feature = "brooklyn"))] vec![ValidatorIdentity::from_seed("Alice")], + #[cfg(feature = "brooklyn")] + vec![ + ValidatorIdentity::from_seed("Alice"), + ValidatorIdentity::from_seed("Bob"), + ], CHAIN_ID, true, 0, diff --git a/node/src/cli.rs b/node/src/cli.rs index a9da5bfe..d5b09a73 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -54,6 +54,10 @@ pub struct Cli { #[clap(flatten)] pub relayer_cmd: pallet_eth2_light_client_relayer_gadget_cli::LightClientRelayerCmd, + + #[cfg(feature = "brooklyn")] + #[arg(long, short = 'o')] + pub output_path: Option, } #[derive(Debug, clap::Subcommand)] diff --git a/node/src/runtime/testnet.rs b/node/src/runtime/testnet.rs index 1cbaf898..f4d6ca48 100644 --- a/node/src/runtime/testnet.rs +++ b/node/src/runtime/testnet.rs @@ -30,6 +30,7 @@ impl ValidatorIdentity { grandpa: get_from_seed::(s), im_online: get_from_seed::(s), beefy: get_from_seed::(s), + dkg: get_from_seed::(s), }, } } @@ -50,6 +51,7 @@ impl ValidatorIdentity { grandpa: ed, im_online: sr.into(), beefy: ecdsa.into(), + dkg: ecdsa.into(), }, } } @@ -367,5 +369,15 @@ pub fn testnet_genesis( asset_ids: vec![8886, 999, 888, 777, 666, 667], native_asset_id: 8886, }, + dkg: DKGConfig { + authorities: initial_authorities + .iter() + .map(|x| x.session_keys.dkg.clone()) + .collect::<_>(), + keygen_threshold: 2, + signature_threshold: 1, + authority_ids: initial_authorities.into_iter().map(|x| x.id).collect::<_>(), + }, + dkg_proposals: Default::default(), } } diff --git a/node/src/service/brooklyn.rs b/node/src/service/brooklyn.rs index 2384d538..5adf94ff 100644 --- a/node/src/service/brooklyn.rs +++ b/node/src/service/brooklyn.rs @@ -19,7 +19,7 @@ use sc_client_api::{ backend::{Backend, StateBackend}, AuxStore, BlockchainEvents, StorageProvider, }; -use sc_network::NetworkService; +use sc_network::{NetworkService, NetworkStateInfo}; use sc_network_sync::SyncingService; use sc_rpc::SubscriptionTaskExecutor; use sc_service::{error::Error as ServiceError, Configuration, TaskManager, TransactionPool}; @@ -245,6 +245,7 @@ pub fn new_full(mut config: Configuration, cli: &Cli) -> Result Result Result Result, + debug_logger, + }; + + // Start the DKG gadget. + task_manager.spawn_essential_handle().spawn_blocking( + "dkg-gadget", + None, + dkg_gadget::start_dkg_gadget::<_, _, _>(dkg_params), + ); + } + // if the node isn't actively participating in consensus then it doesn't // need a keystore, regardless of which protocol we use below. let keystore_opt = if role.is_authority() { diff --git a/node/tests/common.rs b/node/tests/common.rs index d79f92ce..915cb975 100644 --- a/node/tests/common.rs +++ b/node/tests/common.rs @@ -29,6 +29,7 @@ use std::{ ops::{Deref, DerefMut}, path::Path, process::{self, Child, Command, ExitStatus}, + sync::atomic, time::Duration, }; @@ -54,6 +55,9 @@ pub const CHAIN_ID: u64 = 8886u64; #[cfg(feature = "brooklyn")] pub const CHAIN_ID: u64 = 888866u64; +static DEV_P2P_PORT: atomic::AtomicUsize = atomic::AtomicUsize::new(30333); +static DEV_RPC_PORT: atomic::AtomicUsize = atomic::AtomicUsize::new(9944); + /// Wait for the given `child` the given number of `secs`. /// /// Returns the `Some(exit status)` or `None` if the process did not finish in the given time. @@ -269,17 +273,78 @@ impl Node { } } -pub async fn start_node_for_local_chain(validator_name: &str, chain: &str) -> Node { - let base_path = tempdir().expect("could not create a temp dir"); +pub async fn start_dev_node() -> Node { + start_node_for_local_chain( + "alice", + "dev", + DEV_P2P_PORT.fetch_add(1, atomic::Ordering::SeqCst), + DEV_RPC_PORT.fetch_add(1, atomic::Ordering::SeqCst), + ) + .await +} + +pub async fn start_dev_nodes() -> (Node, Node) { + let (alice_p2p_port, bob_p2p_port, alice_rpc_port, bob_rpc_port) = ( + DEV_P2P_PORT.fetch_add(1, atomic::Ordering::SeqCst), + DEV_P2P_PORT.fetch_add(1, atomic::Ordering::SeqCst), + DEV_RPC_PORT.fetch_add(1, atomic::Ordering::SeqCst), + DEV_RPC_PORT.fetch_add(1, atomic::Ordering::SeqCst), + ); + ( + start_node_for_local_chain("alice", "dev", alice_p2p_port, alice_rpc_port).await, + start_node_for_local_chain("bob", "dev", bob_p2p_port, bob_rpc_port).await, + ) +} + +pub async fn start_node_for_local_chain( + validator_name: &str, + chain: &str, + p2p_port: usize, + rpc_port: usize, +) -> Node { + let base_path = match std::env::var("TEST_DATA_DIR") { + Ok(test_data_dir) => { + let dir = format!("{test_data_dir}/{chain}-{validator_name}-{rpc_port}"); + std::fs::create_dir_all(&dir).expect(&format!("could not create directory {dir}")); + dir + } + Err(_) => tempdir() + .expect("could not create a temp dir") + .path() + .to_str() + .unwrap() + .to_string(), + }; let (stderr_file, output_path) = tempfile::NamedTempFile::new().unwrap().keep().unwrap(); + let mut node_args = vec![ + format!("--{validator_name}"), + format!("--chain={chain}"), + format!("--port={p2p_port}"), + format!("--rpc-port={rpc_port}"), + format!("--base-path={base_path}"), + "--rpc-cors=all".to_string(), + ]; + match validator_name { + "alice" => node_args.push( + "--node-key=0000000000000000000000000000000000000000000000000000000000000001" + .to_string(), + ), + "bob" => { + const ALICE_NODE_ID: &str = "12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"; + node_args.push(format!( + "--bootnodes=/ip4/127.0.0.1/tcp/{}/p2p/{}", + p2p_port - 1, + ALICE_NODE_ID + )); + } + _ => (), + } + let cmd = Command::new(cargo_bin("ggxchain-node")) .stdout(process::Stdio::piped()) .stderr(process::Stdio::from(stderr_file)) - .args([&format!("--{validator_name}"), &format!("--chain={chain}")]) - .arg("--rpc-cors=all") - .arg("-d") - .arg(base_path.path()) + .args(node_args) .spawn() .unwrap(); diff --git a/node/tests/data/scale/eth_light_client_brooklyn.scale b/node/tests/data/scale/eth_light_client_brooklyn.scale index 001cdf47..9aeaaf72 100644 Binary files a/node/tests/data/scale/eth_light_client_brooklyn.scale and b/node/tests/data/scale/eth_light_client_brooklyn.scale differ diff --git a/node/tests/eth_light_client.rs b/node/tests/eth_light_client.rs index c62ed575..94d96e66 100644 --- a/node/tests/eth_light_client.rs +++ b/node/tests/eth_light_client.rs @@ -145,8 +145,7 @@ mod test { #[tokio::test] async fn eth_light_client_loads_data_and_accepts_merkle_proof( ) -> Result<(), Box> { - let mut alice = common::start_node_for_local_chain("alice", "dev").await; - println!("Alice ws url: {}", alice.ws_url); + let (mut alice, mut bob) = common::start_dev_nodes().await; common::wait_n_finalized_blocks_from(1, &alice.ws_url).await; @@ -156,6 +155,7 @@ mod test { load_light_client_data(&api, &alice_pair).await; alice.kill(); + bob.kill(); Ok(()) } @@ -163,7 +163,7 @@ mod test { #[tokio::test] async fn eth_light_client_data_could_be_fetched_from_evm_by_precompile( ) -> Result<(), Box> { - let mut alice = common::start_node_for_local_chain("alice", "dev").await; + let (mut alice, mut bob) = common::start_dev_nodes().await; let api = OnlineClient::::from_url(alice.ws_url.clone()).await?; let alice_pair = subxt_signer::sr25519::dev::alice(); @@ -209,6 +209,7 @@ mod test { } alice.kill(); + bob.kill(); Ok(()) } @@ -216,7 +217,7 @@ mod test { #[tokio::test] async fn eth_light_client_data_could_be_fetched_from_chain_extension( ) -> Result<(), Box> { - let mut alice = common::start_node_for_local_chain("alice", "dev").await; + let (mut alice, mut bob) = common::start_dev_nodes().await; let api = OnlineClient::::from_url(alice.ws_url.clone()).await?; let alice_pair = subxt_signer::sr25519::dev::alice(); @@ -234,6 +235,7 @@ mod test { .await; alice.kill(); + bob.kill(); Ok(()) } diff --git a/node/tests/evm_burn_token.rs b/node/tests/evm_burn_token.rs index 97f0caf0..bee03dbd 100644 --- a/node/tests/evm_burn_token.rs +++ b/node/tests/evm_burn_token.rs @@ -49,7 +49,7 @@ async fn _print_balances( #[cfg(unix)] #[tokio::test] async fn evm_burn_token_test() -> Result<(), Box> { - let mut alice = common::start_node_for_local_chain("alice", "dev").await; + let (mut alice, mut bob) = common::start_dev_nodes().await; // Let it produce some blocks. let _ = common::wait_n_finalized_blocks(1, 30, &alice.ws_url).await; @@ -95,6 +95,7 @@ async fn evm_burn_token_test() -> Result<(), Box> { // Stop the process alice.kill(); + bob.kill(); Ok(()) } diff --git a/node/tests/evm_set_session_keys.rs b/node/tests/evm_set_session_keys.rs index 567e7754..842cd156 100644 --- a/node/tests/evm_set_session_keys.rs +++ b/node/tests/evm_set_session_keys.rs @@ -12,6 +12,10 @@ pub mod common; use common::CHAIN_ID; +#[cfg(feature = "brooklyn")] +const SESSION_KEYS: &str= "dc2a5a4d7d9cd10807ba90f4cc2ca6af94414d3f9a4a7c47ae3371263ee9894706361d59c0503c78196ffb531c244edc78c6585680c6ca97068c850bea7a8abe2eeda6e65141736b2a609e6ee8dac17dc37c4ec3cc1f807e6552fce0ff60d32f0325ff58ef8784f6aef99c3870b697f8d7511f905d67f42d17fb5886718ba2f62a03ebc395e821e76e61e783b3325ce6fc84f3da4b61a8ee2759bf8a2a0f78c0f461"; + +#[cfg(not(feature = "brooklyn"))] const SESSION_KEYS: &str= "6a8357e87e163a03ed9c03ce2852bcf673121fc67c9fa7b839797879547c155c5c9479d0fea15172526450eb3bda80d9830fabf07e4fe4b7c020bfd0e6dbd321bc7e65505f0967481fb2c7d5226072d14efaae9d65c1d732548c1cf07d675927038602d835e19cd18df04a40a0c3991fa76f254b89fe9b98401961bde94f15bc6e"; type Client = SignerMiddleware, Wallet>; @@ -48,7 +52,7 @@ async fn call_set_session_key( #[cfg(unix)] #[tokio::test] async fn evm_set_session_key_test() -> Result<(), Box> { - let mut alice = common::start_node_for_local_chain("alice", "dev").await; + let (mut alice, mut bob) = common::start_dev_nodes().await; // Let it produce some blocks. let _ = common::wait_n_finalized_blocks(1, 30, &alice.ws_url).await; @@ -57,6 +61,10 @@ async fn evm_set_session_key_test() -> Result<(), Box> { alice.child.try_wait().unwrap().is_none(), "the process should still be running" ); + assert!( + bob.child.try_wait().unwrap().is_none(), + "the process should still be running" + ); let provider: Provider = Provider::::try_from(alice.http_url.clone())?; // Change to correct network @@ -77,6 +85,7 @@ async fn evm_set_session_key_test() -> Result<(), Box> { // Stop the process alice.kill(); + bob.kill(); Ok(()) } diff --git a/node/tests/evm_zk_verify_precompile.rs b/node/tests/evm_zk_verify_precompile.rs index 651d54e1..aa8850d7 100644 --- a/node/tests/evm_zk_verify_precompile.rs +++ b/node/tests/evm_zk_verify_precompile.rs @@ -87,7 +87,7 @@ async fn call_zk_groth16_verify( #[cfg(unix)] #[tokio::test] async fn evm_zk_verify_test() -> Result<(), Box> { - let mut alice = common::start_node_for_local_chain("alice", "dev").await; + let (mut alice, mut bob) = common::start_dev_nodes().await; // Let it produce some blocks. let _ = common::wait_n_finalized_blocks(1, 30, &alice.ws_url).await; @@ -111,6 +111,7 @@ async fn evm_zk_verify_test() -> Result<(), Box> { // Stop the process alice.kill(); + bob.kill(); Ok(()) } diff --git a/runtime/brooklyn/Cargo.toml b/runtime/brooklyn/Cargo.toml index 886d0e88..e2112ec3 100644 --- a/runtime/brooklyn/Cargo.toml +++ b/runtime/brooklyn/Cargo.toml @@ -154,6 +154,12 @@ vault-registry-rpc-runtime-api.workspace = true # Dex pallet-dex.workspace = true +# DKG +dkg-runtime-primitives.workspace = true +pallet-dkg-metadata.workspace = true +pallet-dkg-proposal-handler.workspace = true +pallet-dkg-proposals.workspace = true + [build-dependencies] substrate-wasm-builder.workspace = true @@ -288,6 +294,12 @@ std = [ #Dex "pallet-dex/std", + + # DKG + "pallet-dkg-metadata/std", + "pallet-dkg-proposal-handler/std", + "pallet-dkg-proposals/std", + "dkg-runtime-primitives/std", ] aura = [] allowlist = [] diff --git a/runtime/brooklyn/src/lib.rs b/runtime/brooklyn/src/lib.rs index edcd9705..8e9bba1a 100644 --- a/runtime/brooklyn/src/lib.rs +++ b/runtime/brooklyn/src/lib.rs @@ -23,10 +23,12 @@ pub mod governance; mod ibc; mod ink; pub mod light_client; +pub mod mpc; pub mod pos; mod prelude; - mod version; + +pub use mpc::DKGId; pub use version::VERSION; use core::cmp::Ordering; @@ -158,12 +160,15 @@ pub mod opaque { /// Opaque block identifier type. pub type BlockId = generic::BlockId; + // TODO: create migration + impl_opaque_keys! { pub struct SessionKeys { pub aura: Aura, pub grandpa: Grandpa, pub im_online: ImOnline, pub beefy: Beefy, + pub dkg: DKG, } } } @@ -194,6 +199,7 @@ pub type OptionalSignedExtension = ( pub type OptionalSignedExtension = (pallet_transaction_payment::ChargeTransactionPayment,); pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckTxVersion, frame_system::CheckGenesis, @@ -335,9 +341,7 @@ impl frame_system::Config for Runtime { type MaxConsumers = ConstU32<16>; } -parameter_types! { - pub const MaxAuthorities: u32 = 100; -} +pub type MaxAuthorities = dkg_runtime_primitives::CustomU32Getter<1024>; impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; @@ -580,6 +584,12 @@ construct_runtime!( System: frame_system, Timestamp: pallet_timestamp, RuntimeSpecification: chain_spec, + + // DKG / offchain worker - the order and position of these pallet should not change + DKG: pallet_dkg_metadata, + DKGProposals: pallet_dkg_proposals, + DKGProposalHandler: pallet_dkg_proposal_handler, + Balances: pallet_balances, Aura: pallet_aura, ImOnline: pallet_im_online, @@ -804,6 +814,105 @@ impl_runtime_apis! { } } + impl dkg_runtime_primitives::DKGApi for Runtime { + fn authority_set() -> dkg_runtime_primitives::AuthoritySet { + let authorities = DKG::authorities(); + let authority_set_id = DKG::authority_set_id(); + + dkg_runtime_primitives::AuthoritySet { + authorities, + id: authority_set_id + } + } + + fn queued_authority_set() -> dkg_runtime_primitives::AuthoritySet { + let queued_authorities = DKG::next_authorities(); + let queued_authority_set_id = DKG::authority_set_id() + 1u64; + + dkg_runtime_primitives::AuthoritySet { + authorities: queued_authorities, + id: queued_authority_set_id + } + } + + fn signature_threshold() -> u16 { + DKG::signature_threshold() + } + + fn keygen_threshold() -> u16 { + DKG::keygen_threshold() + } + + fn next_signature_threshold() -> u16 { + DKG::next_signature_threshold() + } + + fn next_keygen_threshold() -> u16 { + DKG::next_keygen_threshold() + } + + fn should_refresh(block_number: BlockNumber) -> bool { + DKG::should_refresh(block_number) + } + + fn next_dkg_pub_key() -> Option<(dkg_runtime_primitives::AuthoritySetId, Vec)> { + DKG::next_dkg_public_key().map(|pub_key| (pub_key.0, pub_key.1.into())) + } + + fn next_pub_key_sig() -> Option> { + DKG::next_public_key_signature().map(|pub_key_sig| pub_key_sig.into()) + } + + fn get_current_session_progress(block_number: BlockNumber) -> Option { + use frame_support::traits::EstimateNextSessionRotation; + as EstimateNextSessionRotation>::estimate_current_session_progress(block_number).0 + } + + fn dkg_pub_key() -> (dkg_runtime_primitives::AuthoritySetId, Vec) { + (DKG::dkg_public_key().0, DKG::dkg_public_key().1.into()) + } + + fn get_best_authorities() -> Vec<(u16, mpc::DKGId)> { + DKG::best_authorities().into() + } + + fn get_next_best_authorities() -> Vec<(u16, mpc::DKGId)> { + DKG::next_best_authorities().into() + } + + fn get_unsigned_proposal_batches() -> Vec> { + DKGProposalHandler::get_unsigned_proposal_batches() + } + + fn get_authority_accounts() -> (Vec, Vec) { + (DKG::current_authorities_accounts().into(), DKG::next_authorities_accounts().into()) + } + + fn get_reputations(authorities: Vec) -> Vec<(mpc::DKGId, mpc::Reputation)> { + authorities.iter().map(|a| (a.clone(), DKG::authority_reputations(a))).collect() + } + + fn get_keygen_jailed(set: Vec) -> Vec { + set.iter().filter(|a| pallet_dkg_metadata::JailedKeygenAuthorities::::contains_key(a)).cloned().collect() + } + + fn get_signing_jailed(set: Vec) -> Vec { + set.iter().filter(|a| pallet_dkg_metadata::JailedSigningAuthorities::::contains_key(a)).cloned().collect() + } + + fn refresh_nonce() -> u32 { + DKG::refresh_nonce() + } + + fn should_execute_new_keygen() -> (bool, bool) { + DKG::should_execute_new_keygen() + } + + fn should_submit_proposer_vote() -> bool { + DKG::should_submit_proposer_vote() + } + } + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction( source: TransactionSource, diff --git a/runtime/brooklyn/src/mpc.rs b/runtime/brooklyn/src/mpc.rs new file mode 100644 index 00000000..1f71d5d9 --- /dev/null +++ b/runtime/brooklyn/src/mpc.rs @@ -0,0 +1,155 @@ +use crate::{ + pos::{PeriodicSessions, SessionPeriod}, + prelude::*, + SignedPayload, +}; + +use super::{DKGProposalHandler, DKGProposals, Historical, Offences, DKG}; + +use dkg_runtime_primitives::{ + MaxKeyLength, MaxProposalLength, MaxReporters, MaxSignatureLength, TypedChainId, +}; + +pub use dkg_runtime_primitives::crypto::AuthorityId as DKGId; +use frame_support::PalletId; + +parameter_types! { + pub const DecayPercentage: Percent = Percent::from_percent(50); + pub const UnsignedPriority: u64 = 1 << 20; + pub const UnsignedInterval: BlockNumber = 1; + #[derive(Default, Clone, Encode, Decode, Debug, Eq, PartialEq, scale_info::TypeInfo, Ord, PartialOrd, scale_codec::MaxEncodedLen)] + pub const VoteLength: u32 = 64; +} + +pub type Reputation = u128; + +impl pallet_dkg_metadata::Config for Runtime { + type DKGId = DKGId; + type RuntimeEvent = RuntimeEvent; + type OnAuthoritySetChangeHandler = DKGProposals; + type OnDKGPublicKeyChangeHandler = (); + type OffChainAuthId = dkg_runtime_primitives::offchain::crypto::OffchainAuthId; + type NextSessionRotation = PeriodicSessions; + type KeygenJailSentence = SessionPeriod; + type SigningJailSentence = SessionPeriod; + type DecayPercentage = DecayPercentage; + type Reputation = Reputation; + type ForceOrigin = EnsureRoot; + type UnsignedPriority = UnsignedPriority; + type SessionPeriod = SessionPeriod; + type UnsignedInterval = UnsignedInterval; + type AuthorityIdOf = pallet_dkg_metadata::AuthorityIdOf; + type ProposalHandler = DKGProposalHandler; + type MaxKeyLength = MaxKeyLength; + type MaxSignatureLength = MaxSignatureLength; + type DKGAuthorityToMerkleLeaf = pallet_dkg_proposals::DKGEcdsaToEthereumAddress; + type MaxReporters = MaxReporters; + type MaxAuthorities = MaxAuthorities; + type VoteLength = VoteLength; + type MaxProposalLength = MaxProposalLength; + type WeightInfo = pallet_dkg_metadata::weights::WebbWeight; +} + +parameter_types! { + pub const ChainIdentifier: TypedChainId = TypedChainId::Substrate(888866); + pub storage ProposalLifetime: BlockNumber = Hours::get() / 5; + pub const DKGAccountId: PalletId = PalletId(*b"dw/dkgac"); + pub const RefreshDelay: Permill = Permill::from_percent(90); + pub const TimeToRestart: BlockNumber = 3; + pub storage UnsignedProposalExpiry: BlockNumber = SessionPeriod::get() / 4; +} + +impl pallet_dkg_proposal_handler::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type ForceOrigin = EnsureRoot; + type OffChainAuthId = dkg_runtime_primitives::offchain::crypto::OffchainAuthId; + type UnsignedProposalExpiry = UnsignedProposalExpiry; + type SignedProposalHandler = (DKG,); + type MaxProposalsPerBatch = dkg_runtime_primitives::CustomU32Getter<10>; + type BatchId = u32; + type ValidatorSet = Historical; + type ReportOffences = Offences; + type WeightInfo = pallet_dkg_proposal_handler::weights::WebbWeight; +} + +parameter_types! { + #[derive(Clone, Encode, Decode, Debug, Eq, PartialEq, scale_info::TypeInfo, Ord, PartialOrd)] + pub const MaxVotes : u32 = 100; + #[derive(Clone, Encode, Decode, Debug, Eq, PartialEq, scale_info::TypeInfo, Ord, PartialOrd, Serialize, Deserialize)] + pub const MaxResources : u32 = 1000; + #[derive(Clone, Encode, Decode, Debug, Eq, PartialEq, scale_info::TypeInfo, Ord, PartialOrd)] + pub const MaxProposers : u32 = 1000; +} + +impl pallet_dkg_proposals::Config for Runtime { + type AdminOrigin = frame_system::EnsureRoot; + type DKGAuthorityToMerkleLeaf = pallet_dkg_proposals::DKGEcdsaToEthereumAddress; + type DKGId = DKGId; + type ChainIdentifier = ChainIdentifier; + type RuntimeEvent = RuntimeEvent; + type NextSessionRotation = PeriodicSessions; + type MaxProposalLength = MaxProposalLength; + type ProposalLifetime = ProposalLifetime; + type ProposalHandler = DKGProposalHandler; + type Period = SessionPeriod; + type MaxVotes = MaxVotes; + type MaxResources = MaxResources; + type MaxProposers = MaxProposers; + type VotingKeySize = MaxKeyLength; + type WeightInfo = pallet_dkg_proposals::WebbWeight; +} + +impl frame_system::offchain::CreateSignedTransaction for Runtime +where + RuntimeCall: From, +{ + fn create_transaction>( + call: RuntimeCall, + public: ::Signer, + account: AccountId, + nonce: u32, + ) -> Option<( + RuntimeCall, + ::SignaturePayload, + )> { + use sp_runtime::traits::StaticLookup; + + let tip = 0; + // take the biggest period possible. + let period = BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + let current_block = System::block_number() + // The `System::block_number` is initialized with `n+1`, + // so the actual block number is `n`. + .saturating_sub(1); + let era = sp_runtime::generic::Era::mortal(period, current_block.into()); + let extra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(era), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + (pallet_transaction_payment::ChargeTransactionPayment::< + Runtime, + >::from(tip),), + ); + let raw_payload = SignedPayload::new(call, extra) + .map_err(|e| { + log::warn!("Unable to create signed payload: {:?}", e); + }) + .ok()?; + let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?; + let address = crate::Indices::unlookup(account); + let (call, extra, _) = raw_payload.deconstruct(); + Some((call, (address, signature, extra))) + } +} + +impl frame_system::offchain::SigningTypes for Runtime { + type Public = ::Signer; + type Signature = Signature; +} diff --git a/runtime/brooklyn/src/pos.rs b/runtime/brooklyn/src/pos.rs index 42ed0026..c5f396e6 100644 --- a/runtime/brooklyn/src/pos.rs +++ b/runtime/brooklyn/src/pos.rs @@ -109,7 +109,8 @@ parameter_types! { } -pub type PeriodicSessions = pallet_session::PeriodicSessions; +pub type PeriodicSessions = + pallet_dkg_metadata::DKGPeriodicSessions; impl pallet_treasury::Config for Runtime { type PalletId = TreasuryPalletId; diff --git a/runtime/brooklyn/src/prelude.rs b/runtime/brooklyn/src/prelude.rs index e35d4c1a..7ff9f125 100644 --- a/runtime/brooklyn/src/prelude.rs +++ b/runtime/brooklyn/src/prelude.rs @@ -1,6 +1,12 @@ pub use scale_codec::{Decode, Encode}; +pub use serde::{Deserialize, Serialize}; pub use super::{ - AccountId, Balance, Balances, Runtime, RuntimeEvent, RuntimeSpecification, GGX, MILLIGGX, + AccountId, Balance, Balances, BlockHashCount, BlockNumber, EpochDurationInBlocks, Hours, + MaxAuthorities, Runtime, RuntimeCall, RuntimeEvent, RuntimeSpecification, Signature, System, + UncheckedExtrinsic, GGX, MILLIGGX, }; + pub use frame_support::parameter_types; +pub use frame_system::EnsureRoot; +pub use sp_runtime::{traits, Perbill, Percent, Permill};