From 1fd4c091d9141de2017cce5ad3a2c3610682da2d Mon Sep 17 00:00:00 2001 From: Sergey <83376337+freak12techno@users.noreply.github.com> Date: Wed, 7 Aug 2024 11:19:05 +0300 Subject: [PATCH] add tally (#6) * add tally * removed print * add pool * fix name * add signing infos --- Cargo.lock | 413 +++++++++++++++++++++++----------------------------- Cargo.toml | 1 + src/main.rs | 148 +++++++++++++++++++ 3 files changed, 334 insertions(+), 228 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7c7862b..0d854be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -58,6 +58,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + [[package]] name = "android-tzdata" version = "0.1.1" @@ -73,15 +79,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "0.6.14" @@ -163,6 +160,7 @@ dependencies = [ "blake2", "derivative", "digest 0.10.7", + "rayon", "sha2 0.10.8", ] @@ -180,6 +178,7 @@ dependencies = [ "hashbrown 0.13.2", "itertools 0.10.5", "num-traits", + "rayon", "zeroize", ] @@ -192,7 +191,6 @@ dependencies = [ "ark-bls12-377", "ark-ec", "ark-ff", - "ark-r1cs-std", "ark-std", ] @@ -212,6 +210,7 @@ dependencies = [ "num-bigint", "num-traits", "paste", + "rayon", "rustc_version", "zeroize", ] @@ -252,6 +251,7 @@ dependencies = [ "ark-relations", "ark-serialize", "ark-std", + "rayon", ] [[package]] @@ -265,6 +265,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", + "rayon", ] [[package]] @@ -339,6 +340,7 @@ checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ "num-traits", "rand", + "rayon", ] [[package]] @@ -879,8 +881,8 @@ checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "cnidarium" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "async-trait", @@ -908,8 +910,8 @@ dependencies = [ [[package]] name = "cnidarium-component" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "async-trait", @@ -968,6 +970,31 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + [[package]] name = "crunchy" version = "0.2.2" @@ -1046,37 +1073,10 @@ dependencies = [ [[package]] name = "decaf377" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75bb0f9fde498b60e4563c9346bbd4527d4ff4930a43c404ceb4cf63166c9ea4" -dependencies = [ - "anyhow", - "ark-bls12-377", - "ark-ec", - "ark-ed-on-bls12-377", - "ark-ff", - "ark-groth16", - "ark-r1cs-std", - "ark-relations", - "ark-serialize", - "ark-snark", - "ark-std", - "hex", - "num-bigint", - "once_cell", - "thiserror", - "tracing", - "tracing-subscriber 0.2.25", - "zeroize", -] - -[[package]] -name = "decaf377" -version = "0.5.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a80011d442d81fccfbefb5bd0d20bf70f111ca544ffed943d335dacf6a85713" +checksum = "2097c5f69d06259112bea2024ddc41095c5001b503448f84ac169efc7cc8fd75" dependencies = [ - "anyhow", "ark-bls12-377", "ark-ec", "ark-ed-on-bls12-377", @@ -1087,36 +1087,37 @@ dependencies = [ "ark-serialize", "ark-snark", "ark-std", + "cfg-if", + "hashbrown 0.14.5", "hex", "num-bigint", "once_cell", - "thiserror", - "tracing", - "tracing-subscriber 0.2.25", + "rand_core", + "subtle", "zeroize", ] [[package]] name = "decaf377-fmd" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "ark-ff", "ark-serialize", "bitvec", "blake2b_simd 1.0.2", - "decaf377 0.5.0", + "decaf377", "rand_core", "thiserror", ] [[package]] name = "decaf377-ka" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "ark-ff", - "decaf377 0.5.0", + "decaf377", "hex", "rand_core", "thiserror", @@ -1126,20 +1127,20 @@ dependencies = [ [[package]] name = "decaf377-rdsa" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2356bb010273c2b6e4e928b2bb442ddaa255ec242c16ff46cf9c3811fefa5ace" +checksum = "437967a34e0699b50b986a72ce6c4e2e5930bde85ec8f3749701f7e50d6d32b0" dependencies = [ "ark-ff", "ark-serialize", "blake2b_simd 0.5.11", - "byteorder", - "decaf377 0.5.0", + "decaf377", "digest 0.9.0", "hex", "rand_core", "serde", "thiserror", + "zeroize", ] [[package]] @@ -1637,6 +1638,10 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] name = "heck" @@ -2053,9 +2058,9 @@ dependencies = [ [[package]] name = "ics23" -version = "0.11.1" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc3b8be84e7285c73b88effdc3294b552277d6b0ec728ee016c861b7b9a2c19c" +checksum = "18798160736c1e368938ba6967dbcb3c7afb3256b442a5506ba5222eebb68a5a" dependencies = [ "anyhow", "blake2", @@ -2386,15 +2391,6 @@ dependencies = [ "libc", ] -[[package]] -name = "matchers" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" -dependencies = [ - "regex-automata 0.1.10", -] - [[package]] name = "matchers" version = "0.1.0" @@ -2416,18 +2412,6 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" -[[package]] -name = "merlin" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" -dependencies = [ - "byteorder", - "keccak", - "rand_core", - "zeroize", -] - [[package]] name = "metrics" version = "0.22.3" @@ -2521,20 +2505,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - [[package]] name = "num-bigint" version = "0.4.6" @@ -2545,15 +2515,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - [[package]] name = "num-conv" version = "0.1.0" @@ -2580,28 +2541,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -2781,8 +2720,8 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "penumbra-asset" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "ark-ff", @@ -2794,7 +2733,7 @@ dependencies = [ "bech32", "blake2b_simd 1.0.2", "bytes", - "decaf377 0.5.0", + "decaf377", "decaf377-fmd", "decaf377-rdsa", "derivative", @@ -2819,8 +2758,8 @@ dependencies = [ [[package]] name = "penumbra-distributions" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "async-trait", @@ -2835,10 +2774,63 @@ dependencies = [ "tracing", ] +[[package]] +name = "penumbra-governance" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" +dependencies = [ + "anyhow", + "ark-ff", + "ark-groth16", + "ark-r1cs-std", + "ark-relations", + "ark-serialize", + "ark-snark", + "async-stream", + "async-trait", + "base64 0.21.7", + "blake2b_simd 1.0.2", + "bytes", + "cnidarium", + "cnidarium-component", + "decaf377", + "decaf377-rdsa", + "futures", + "ibc-types", + "im", + "metrics", + "once_cell", + "pbjson-types", + "penumbra-asset", + "penumbra-distributions", + "penumbra-ibc", + "penumbra-keys", + "penumbra-num", + "penumbra-proof-params", + "penumbra-proto", + "penumbra-sct", + "penumbra-shielded-pool", + "penumbra-stake", + "penumbra-tct", + "penumbra-txhash", + "rand", + "rand_chacha", + "rand_core", + "regex", + "serde", + "serde_json", + "tap", + "tendermint", + "thiserror", + "tokio", + "tonic", + "tracing", +] + [[package]] name = "penumbra-ibc" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "ark-ff", @@ -2873,8 +2865,8 @@ dependencies = [ [[package]] name = "penumbra-keys" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "aes", "anyhow", @@ -2889,7 +2881,7 @@ dependencies = [ "blake2b_simd 1.0.2", "bytes", "chacha20poly1305", - "decaf377 0.5.0", + "decaf377", "decaf377-fmd", "decaf377-ka", "decaf377-rdsa", @@ -2923,6 +2915,7 @@ dependencies = [ "chrono", "clap", "futures", + "penumbra-governance", "penumbra-proto", "penumbra-stake", "prost 0.13.1", @@ -2933,8 +2926,8 @@ dependencies = [ [[package]] name = "penumbra-num" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "ark-ff", @@ -2948,7 +2941,7 @@ dependencies = [ "bech32", "blake2b_simd 1.0.2", "bytes", - "decaf377 0.5.0", + "decaf377", "decaf377-fmd", "decaf377-rdsa", "derivative", @@ -2969,8 +2962,8 @@ dependencies = [ [[package]] name = "penumbra-proof-params" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "ark-ec", @@ -2982,7 +2975,7 @@ dependencies = [ "ark-snark", "ark-std", "bech32", - "decaf377 0.5.0", + "decaf377", "lazy_static", "num-bigint", "once_cell", @@ -2995,8 +2988,8 @@ dependencies = [ [[package]] name = "penumbra-proto" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "async-trait", @@ -3024,8 +3017,8 @@ dependencies = [ [[package]] name = "penumbra-sct" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "ark-ff", @@ -3039,7 +3032,7 @@ dependencies = [ "chrono", "cnidarium", "cnidarium-component", - "decaf377 0.5.0", + "decaf377", "decaf377-rdsa", "hex", "im", @@ -3060,8 +3053,8 @@ dependencies = [ [[package]] name = "penumbra-shielded-pool" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "ark-ff", @@ -3078,7 +3071,7 @@ dependencies = [ "chacha20poly1305", "cnidarium", "cnidarium-component", - "decaf377 0.5.0", + "decaf377", "decaf377-fmd", "decaf377-ka", "decaf377-rdsa", @@ -3114,8 +3107,8 @@ dependencies = [ [[package]] name = "penumbra-stake" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "ark-ff", @@ -3131,7 +3124,7 @@ dependencies = [ "bitvec", "cnidarium", "cnidarium-component", - "decaf377 0.5.0", + "decaf377", "decaf377-rdsa", "futures", "hex", @@ -3164,8 +3157,8 @@ dependencies = [ [[package]] name = "penumbra-tct" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "ark-ed-on-bls12-377", "ark-ff", @@ -3174,7 +3167,7 @@ dependencies = [ "ark-serialize", "async-trait", "blake2b_simd 1.0.2", - "decaf377 0.5.0", + "decaf377", "derivative", "futures", "hash_hasher", @@ -3192,11 +3185,12 @@ dependencies = [ [[package]] name = "penumbra-txhash" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra#e13cd3b8d788c1b71b2e02099baaf4c8a2428f53" +version = "0.79.3" +source = "git+https://github.com/penumbra-zone/penumbra#882a061bd69ce14b01711041bbc0c0ce209e2823" dependencies = [ "anyhow", "blake2b_simd 1.0.2", + "getrandom", "hex", "penumbra-proto", "penumbra-tct", @@ -3286,53 +3280,34 @@ checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" [[package]] name = "poseidon-parameters" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58236ff8bf455c13046c92f041e887c4fd0e64819387a81177d6c70ebeb41711" -dependencies = [ - "anyhow", - "ark-ff", - "num-integer", -] - -[[package]] -name = "poseidon-paramgen" -version = "0.4.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a69506f91189a68bff6c0e4f8c2beaf6b053430be7743059a0110477e9c28fda" +checksum = "f6df50e93cde74d26eb66c9674fccde32172e915a420fe2a73fda39ab377f709" dependencies = [ - "anyhow", - "ark-ff", - "ark-std", - "getrandom", - "merlin", - "num", - "num-bigint", - "poseidon-parameters", - "rand_core", + "decaf377", ] [[package]] name = "poseidon-permutation" -version = "0.5.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a022268b53cec1e99c4bd8c81be249709e971b78a433d9f5556e31f3cd7730b0" +checksum = "03c4e1e8d622017ece288f1a1b06f0bfeaacaa4166fa155a91103317299452e2" dependencies = [ "ark-ff", "ark-r1cs-std", "ark-relations", "ark-std", + "decaf377", "poseidon-parameters", ] [[package]] name = "poseidon377" -version = "0.6.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11dbcae1c9e4624576dd7631a1f2419a18afeaeef104263d70b6f20256ea5b72" +checksum = "ae0544874afdaf74b69efc90795c66ea7a494faeb2981a0585d46c757ee2fa94" dependencies = [ "ark-ec", - "ark-ed-on-bls12-377", "ark-ff", "ark-groth16", "ark-r1cs-std", @@ -3340,13 +3315,9 @@ dependencies = [ "ark-serialize", "ark-snark", "ark-std", - "decaf377 0.4.0", - "num-bigint", - "once_cell", + "decaf377", "poseidon-parameters", - "poseidon-paramgen", "poseidon-permutation", - "tracing", ] [[package]] @@ -3576,6 +3547,26 @@ dependencies = [ "rand_core", ] +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "redox_syscall" version = "0.5.2" @@ -4209,9 +4200,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" -version = "2.4.1" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "subtle-encoding" @@ -4623,17 +4614,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-log" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - [[package]] name = "tracing-log" version = "0.2.0" @@ -4645,36 +4625,13 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-serde" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" -dependencies = [ - "serde", - "tracing-core", -] - [[package]] name = "tracing-subscriber" version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" dependencies = [ - "ansi_term", - "chrono", - "lazy_static", - "matchers 0.0.1", - "regex", - "serde", - "serde_json", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", "tracing-core", - "tracing-log 0.1.4", - "tracing-serde", ] [[package]] @@ -4683,7 +4640,7 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ - "matchers 0.1.0", + "matchers", "nu-ansi-term", "once_cell", "regex", @@ -4692,7 +4649,7 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log 0.2.0", + "tracing-log", ] [[package]] @@ -4758,9 +4715,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "universal-hash" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ "generic-array", "subtle", diff --git a/Cargo.toml b/Cargo.toml index 2fd36cb..0a49de6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" rocket = { version = "=0.5.1", features = ["json", "tls"] } penumbra-proto = { git = "https://github.com/penumbra-zone/penumbra", features = ["rpc"] } penumbra-stake = { git = "https://github.com/penumbra-zone/penumbra" } +penumbra-governance = { git = "https://github.com/penumbra-zone/penumbra" } tonic = { version = "0.10", features = ["tls-webpki-roots", "tls"] } serde_json = { version = "1.0.96" } clap = { version = "4.5.8", features = ["derive"] } diff --git a/src/main.rs b/src/main.rs index ba4ef69..cdfc1fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,11 +29,14 @@ use penumbra_proto::{ ProposalListResponse, ValidatorVotesRequest, ValidatorVotesResponse, + AllTalliedDelegatorVotesForProposalRequest, + AllTalliedDelegatorVotesForProposalResponse, proposal_state::State as ProposalState, proposal_outcome::Outcome, proposal_state::Finished, Proposal, }, + penumbra::core::keys::v1::IdentityKey as ProtoIdentityKey, util::tendermint_proxy::v1::{ tendermint_proxy_service_client::TendermintProxyServiceClient, GetStatusRequest, @@ -142,6 +145,52 @@ async fn validators(status: Option, args: &State) -> Value { }) } +#[get("/cosmos/staking/v1beta1/pool")] +async fn pool(args: &State) -> Value { + let channel = Channel::from_shared(args.node.to_string()) + .unwrap() + .tls_config(ClientTlsConfig::new()) + .unwrap() + .connect() + .await + .unwrap(); + + let mut client = StakeQueryServiceClient::new(channel); + + let validators: Vec = client + .validator_info(ValidatorInfoRequest { + show_inactive: true, + ..Default::default() + }) + .await + .unwrap() + .into_inner() + .try_collect::>() + .await + .unwrap() + .into_iter() + .map(TryInto::try_into) + .collect::, _>>() + .unwrap(); + + let bonded_tokens: u128 = validators.iter() + .filter(|validator| validator.status.bonding_state == BondingState::Bonded) + .map(|validator| validator.status.voting_power.value()) + .sum(); + + let not_bonded_tokens: u128 = validators.iter() + .filter(|validator| validator.status.bonding_state != BondingState::Bonded) + .map(|validator| validator.status.voting_power.value()) + .sum(); + + json!({ + "pool": { + "bonded_tokens": bonded_tokens.to_string(), + "not_bonded_tokens": not_bonded_tokens.to_string(), + } + }) +} + #[get("/cosmos/slashing/v1beta1/params")] async fn slashing_params(args: &State) -> Value { let channel = Channel::from_shared(args.node.to_string()) @@ -252,6 +301,66 @@ async fn signing_info(identity_key: &str, args: &State) -> Value { }) } +#[get("/cosmos/slashing/v1beta1/signing_infos")] +async fn signing_infos(args: &State) -> Value { + let channel = Channel::from_shared(args.node.to_string()) + .unwrap() + .tls_config(ClientTlsConfig::new()) + .unwrap() + .connect() + .await + .unwrap(); + + let mut client = StakeQueryServiceClient::new(channel); + + let validators: Vec = client + .validator_info(ValidatorInfoRequest { + show_inactive: true, + ..Default::default() + }) + .await + .unwrap() + .into_inner() + .try_collect::>() + .await + .unwrap() + .into_iter() + .map(TryInto::try_into) + .collect::, _>>() + .unwrap(); + + let mut result: Vec<_> = vec![]; + for validator in validators { + let valcons = validator.validator.consensus_key.to_bech32("penumbravalcons"); + let identity_key: ProtoIdentityKey = validator.validator.identity_key.into(); + + let uptime: Uptime = client + .validator_uptime(ValidatorUptimeRequest { + identity_key: Option::from(identity_key), + }) + .await + .unwrap() + .into_inner() + .uptime + .unwrap() + .try_into() + .unwrap(); + + result.push(json!({ + "address": valcons, + "start_height": "0", + "index_offset": "0", + "jailed_until": "1970-01-01T00:00:00Z", + "tombstoned": false, + "missed_blocks_counter": uptime.num_missed_blocks() + })); + } + + json!({ + "info": result, + }) +} + async fn get_sync_info(channel: Channel) -> SyncInfo { let mut tendermint_client = TendermintProxyServiceClient::new(channel.clone()); let status_data: GetStatusResponse = tendermint_client @@ -332,6 +441,42 @@ fn map_proposal( }) } +#[get("/cosmos/gov/v1beta1/proposals//tally")] +async fn proposal_tally(proposal_id: u64, args: &State) -> Value { + let channel = Channel::from_shared(args.node.to_string()) + .unwrap() + .tls_config(ClientTlsConfig::new()) + .unwrap() + .connect() + .await + .unwrap(); + + let mut client = GovernanceQueryServiceClient::new(channel.clone()); + let tallies: Vec = client + .all_tallied_delegator_votes_for_proposal(AllTalliedDelegatorVotesForProposalRequest { proposal_id: proposal_id}) + .await + .unwrap() + .into_inner() + .try_collect::>() + .await + .unwrap(); + + let mut total = penumbra_governance::Tally::default(); + + for tally in tallies { + total += tally.tally.unwrap().into(); + } + + json!({ + "tally": { + "yes": total.yes().to_string(), + "no": total.no().to_string(), + "abstain": total.abstain().to_string(), + "no_with_veto": "0" + }, + }) +} + #[get("/cosmos/gov/v1beta1/proposals/")] async fn proposal(proposal_id: u64, args: &State) -> Value { let channel = Channel::from_shared(args.node.to_string()) @@ -520,10 +665,13 @@ fn rocket() -> _ { validators, staking_params, slashing_params, + pool, signing_info, + signing_infos, proposals, proposal, proposal_vote, + proposal_tally, ], ) }