diff --git a/Cargo.lock b/Cargo.lock index 140828d972..c8f0ccd90d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "once_cell", @@ -31,9 +31,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -202,13 +202,13 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-recursion" -version = "1.0.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" +checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -230,18 +230,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -382,7 +382,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -408,9 +408,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "blake2" @@ -443,9 +443,9 @@ dependencies = [ [[package]] name = "bs58" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ "tinyvec", ] @@ -573,7 +573,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -682,7 +682,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "crossterm_winapi", "libc", "mio", @@ -1018,7 +1018,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1584,7 +1584,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", "redox_syscall", ] @@ -1704,9 +1704,9 @@ dependencies = [ [[package]] name = "metrics" -version = "0.22.1" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd71d9db2e4287c3407fa04378b8c2ee570aebe0854431562cdd89ca091854f4" +checksum = "2be3cbd384d4e955b231c895ce10685e3d8260c5ccffae898c96c723b0772835" dependencies = [ "ahash", "portable-atomic", @@ -1733,9 +1733,9 @@ dependencies = [ [[package]] name = "metrics-util" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece71ab046dcf45604e573329966ec1db5ff4b81cfa170a924ff4c959ab5451a" +checksum = "8b07a5eb561b8cbc16be2d216faf7757f9baf3bfb94dbb0fae3df8387a5bb47f" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -1813,7 +1813,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1916,7 +1916,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1999,7 +1999,7 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "foreign-types", "libc", @@ -2016,7 +2016,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2139,7 +2139,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2211,7 +2211,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2231,7 +2231,7 @@ checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.2", + "bitflags 2.5.0", "lazy_static", "num-traits", "rand", @@ -2343,7 +2343,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5659e52e4ba6e07b2dad9f1158f578ef84a73762625ddb51536019f34d180eb" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cassowary", "crossterm", "indoc", @@ -2362,7 +2362,7 @@ version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", ] [[package]] @@ -2451,9 +2451,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.26" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64", "bytes", @@ -2537,11 +2537,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -2743,7 +2743,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2876,9 +2876,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smol_str" @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "aleo-std", "anyhow", @@ -3790,9 +3790,9 @@ dependencies = [ "snarkvm-console", "snarkvm-ledger-authority", "snarkvm-ledger-block", - "snarkvm-ledger-coinbase", "snarkvm-ledger-committee", "snarkvm-ledger-narwhal", + "snarkvm-ledger-puzzle", "snarkvm-ledger-query", "snarkvm-ledger-store", "snarkvm-ledger-test-helpers", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "anyhow", "rand", @@ -3816,46 +3816,26 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "indexmap 2.2.5", "rayon", "serde_json", "snarkvm-console", "snarkvm-ledger-authority", - "snarkvm-ledger-coinbase", "snarkvm-ledger-committee", "snarkvm-ledger-narwhal-batch-header", "snarkvm-ledger-narwhal-subdag", "snarkvm-ledger-narwhal-transmission-id", + "snarkvm-ledger-puzzle", "snarkvm-synthesizer-program", "snarkvm-synthesizer-snark", ] -[[package]] -name = "snarkvm-ledger-coinbase" -version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" -dependencies = [ - "aleo-std", - "anyhow", - "bincode", - "blake2", - "indexmap 2.2.5", - "rayon", - "serde_json", - "snarkvm-algorithms", - "snarkvm-console", - "snarkvm-curves", - "snarkvm-fields", - "snarkvm-synthesizer-snark", - "snarkvm-utilities", -] - [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3863,6 +3843,7 @@ dependencies = [ "rand", "rand_chacha", "rand_distr", + "rayon", "serde_json", "snarkvm-console", "snarkvm-ledger-narwhal-batch-header", @@ -3873,7 +3854,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3886,7 +3867,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3899,9 +3880,10 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "indexmap 2.2.5", + "rayon", "serde_json", "snarkvm-console", "snarkvm-ledger-narwhal-transmission-id", @@ -3911,7 +3893,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "bytes", "serde_json", @@ -3922,7 +3904,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3937,29 +3919,64 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "bytes", "serde_json", "snarkvm-console", "snarkvm-ledger-block", - "snarkvm-ledger-coinbase", "snarkvm-ledger-narwhal-data", + "snarkvm-ledger-puzzle", ] [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "snarkvm-console", - "snarkvm-ledger-coinbase", + "snarkvm-ledger-puzzle", +] + +[[package]] +name = "snarkvm-ledger-puzzle" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +dependencies = [ + "aleo-std", + "anyhow", + "bincode", + "indexmap 2.2.5", + "lru", + "once_cell", + "parking_lot", + "rand", + "rand_chacha", + "rayon", + "serde_json", + "snarkvm-algorithms", + "snarkvm-console", +] + +[[package]] +name = "snarkvm-ledger-puzzle-epoch" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +dependencies = [ + "anyhow", + "colored", + "indexmap 2.2.5", + "rand", + "rand_chacha", + "rayon", + "snarkvm-console", + "snarkvm-ledger-puzzle", ] [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "async-trait", "reqwest", @@ -3972,7 +3989,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "aleo-std-storage", "anyhow", @@ -3987,9 +4004,9 @@ dependencies = [ "snarkvm-console", "snarkvm-ledger-authority", "snarkvm-ledger-block", - "snarkvm-ledger-coinbase", "snarkvm-ledger-committee", "snarkvm-ledger-narwhal-batch-certificate", + "snarkvm-ledger-puzzle", "snarkvm-synthesizer-program", "snarkvm-synthesizer-snark", "tracing", @@ -3998,7 +4015,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4013,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4022,7 +4039,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "aleo-std", "anyhow", @@ -4047,7 +4064,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "aleo-std", "anyhow", @@ -4062,6 +4079,8 @@ dependencies = [ "snarkvm-console", "snarkvm-ledger-block", "snarkvm-ledger-committee", + "snarkvm-ledger-puzzle", + "snarkvm-ledger-puzzle-epoch", "snarkvm-ledger-query", "snarkvm-ledger-store", "snarkvm-synthesizer-process", @@ -4073,7 +4092,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "aleo-std", "colored", @@ -4096,7 +4115,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "indexmap 2.2.5", "paste", @@ -4110,7 +4129,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "bincode", "once_cell", @@ -4123,7 +4142,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "aleo-std", "anyhow", @@ -4144,11 +4163,11 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4201,7 +4220,7 @@ dependencies = [ "proc-macro2", "quote 1.0.35", "structmeta-derive", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4212,7 +4231,7 @@ checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4234,7 +4253,7 @@ dependencies = [ "proc-macro2", "quote 1.0.35", "rustversion", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4267,9 +4286,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" dependencies = [ "proc-macro2", "quote 1.0.35", @@ -4349,7 +4368,7 @@ dependencies = [ "proc-macro2", "quote 1.0.35", "structmeta", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4369,7 +4388,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4484,7 +4503,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4566,7 +4585,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "bytes", "futures-util", "http 1.1.0", @@ -4633,7 +4652,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4951,7 +4970,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-shared", ] @@ -4985,7 +5004,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5214,7 +5233,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5234,5 +5253,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] diff --git a/Cargo.toml b/Cargo.toml index e97eed2eae..78f2d6a496 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "eefd27d" +rev = "81af174" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/node/bft/events/src/lib.rs b/node/bft/events/src/lib.rs index 33ba85c4a0..c6e5c04a8c 100644 --- a/node/bft/events/src/lib.rs +++ b/node/bft/events/src/lib.rs @@ -264,7 +264,7 @@ pub mod prop_tests { }; use snarkvm::{ console::{network::Network, types::Field}, - ledger::{coinbase::PuzzleCommitment, narwhal::TransmissionID}, + ledger::{narwhal::TransmissionID, puzzle::SolutionID}, prelude::{FromBytes, Rng, ToBytes, Uniform}, }; @@ -282,8 +282,8 @@ pub mod prop_tests { time::OffsetDateTime::now_utc().unix_timestamp() } - pub fn any_puzzle_commitment() -> BoxedStrategy> { - Just(0).prop_perturb(|_, mut rng| PuzzleCommitment::from_g1_affine(rng.gen())).boxed() + pub fn any_solution_id() -> BoxedStrategy> { + Just(0).prop_perturb(|_, mut rng| rng.gen::().into()).boxed() } pub fn any_transaction_id() -> BoxedStrategy<::TransactionID> { @@ -295,7 +295,7 @@ pub mod prop_tests { pub fn any_transmission_id() -> BoxedStrategy> { prop_oneof![ any_transaction_id().prop_map(TransmissionID::Transaction), - any_puzzle_commitment().prop_map(TransmissionID::Solution), + any_solution_id().prop_map(TransmissionID::Solution), ] .boxed() } diff --git a/node/bft/events/src/transmission_request.rs b/node/bft/events/src/transmission_request.rs index ec59c764c4..2fded63bb6 100644 --- a/node/bft/events/src/transmission_request.rs +++ b/node/bft/events/src/transmission_request.rs @@ -59,7 +59,7 @@ impl FromBytes for TransmissionRequest { #[cfg(test)] pub mod prop_tests { use crate::{ - prop_tests::{any_puzzle_commitment, any_transaction_id}, + prop_tests::{any_solution_id, any_transaction_id}, TransmissionRequest, }; use snarkvm::{ @@ -78,7 +78,7 @@ pub mod prop_tests { fn any_transmission_id() -> BoxedStrategy> { prop_oneof![ - any_puzzle_commitment().prop_map(TransmissionID::Solution), + any_solution_id().prop_map(TransmissionID::Solution), any_transaction_id().prop_map(TransmissionID::Transaction), ] .boxed() diff --git a/node/bft/events/src/transmission_response.rs b/node/bft/events/src/transmission_response.rs index 45c55a7edc..536f0067af 100644 --- a/node/bft/events/src/transmission_response.rs +++ b/node/bft/events/src/transmission_response.rs @@ -62,7 +62,7 @@ impl FromBytes for TransmissionResponse { #[cfg(test)] pub mod prop_tests { use crate::{ - prop_tests::{any_puzzle_commitment, any_transaction_id}, + prop_tests::{any_solution_id, any_transaction_id}, TransmissionResponse, }; use snarkvm::{ @@ -82,7 +82,7 @@ pub mod prop_tests { pub fn any_transmission() -> BoxedStrategy<(TransmissionID, Transmission)> { prop_oneof![ - (any_puzzle_commitment(), collection::vec(any::(), 256..=256)).prop_map(|(pc, bytes)| ( + (any_solution_id(), collection::vec(any::(), 256..=256)).prop_map(|(pc, bytes)| ( TransmissionID::Solution(pc), Transmission::Solution(Data::Buffer(Bytes::from(bytes))) )), diff --git a/node/bft/examples/simple_node.rs b/node/bft/examples/simple_node.rs index a7328c877e..9b2d22d748 100644 --- a/node/bft/examples/simple_node.rs +++ b/node/bft/examples/simple_node.rs @@ -27,9 +27,9 @@ use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, committee::{Committee, MIN_VALIDATOR_STAKE}, narwhal::{BatchHeader, Data}, + puzzle::{Solution, SolutionID}, }, prelude::{Field, Network, Uniform}, }; @@ -269,28 +269,27 @@ fn fire_unconfirmed_solutions(sender: &PrimarySender, node_id: u // This RNG samples *different* fake solutions for each node. let mut unique_rng = rand_chacha::ChaChaRng::seed_from_u64(node_id as u64); - // A closure to generate a commitment and solution. - fn sample(mut rng: impl Rng) -> (PuzzleCommitment, Data>) { - // Sample a random fake puzzle commitment. - // TODO (howardwu): Use a mutex to bring in the real 'proof target' and change this sampling to a while loop. - let commitment = PuzzleCommitment::::from_g1_affine(rng.gen()); + // A closure to generate a solution ID and solution. + fn sample(mut rng: impl Rng) -> (SolutionID, Data>) { + // Sample a random fake solution ID. + let solution_id = rng.gen::().into(); // Sample random fake solution bytes. let solution = Data::Buffer(Bytes::from((0..1024).map(|_| rng.gen::()).collect::>())); // Return the ID and solution. - (commitment, solution) + (solution_id, solution) } // Initialize a counter. let mut counter = 0; loop { - // Sample a random fake puzzle commitment and solution. - let (commitment, solution) = + // Sample a random fake solution ID and solution. + let (solution_id, solution) = if counter % 2 == 0 { sample(&mut shared_rng) } else { sample(&mut unique_rng) }; // Initialize a callback sender and receiver. let (callback, callback_receiver) = oneshot::channel(); // Send the fake solution. - if let Err(e) = tx_unconfirmed_solution.send((commitment, solution, callback)).await { + if let Err(e) = tx_unconfirmed_solution.send((solution_id, solution, callback)).await { error!("Failed to send unconfirmed solution: {e}"); } let _ = callback_receiver.await; diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index d5b80e8e17..5c19e83215 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -16,9 +16,9 @@ use crate::{fmt_id, spawn_blocking, LedgerService}; use snarkvm::{ ledger::{ block::{Block, Transaction}, - coinbase::{CoinbaseVerifyingKey, ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, store::ConsensusStorage, Ledger, }, @@ -37,14 +37,13 @@ use std::{ }, }; -/// The capacity of the LRU holiding the recently queried committees. +/// The capacity of the LRU holding the recently queried committees. const COMMITTEE_CACHE_SIZE: usize = 16; /// A core ledger service. #[allow(clippy::type_complexity)] pub struct CoreLedgerService> { ledger: Ledger, - coinbase_verifying_key: Arc>, committee_cache: Arc>>>, latest_leader: Arc)>>>, shutdown: Arc, @@ -53,9 +52,8 @@ pub struct CoreLedgerService> { impl> CoreLedgerService { /// Initializes a new core ledger service. pub fn new(ledger: Ledger, shutdown: Arc) -> Self { - let coinbase_verifying_key = Arc::new(ledger.coinbase_puzzle().coinbase_verifying_key().clone()); let committee_cache = Arc::new(Mutex::new(LruCache::new(COMMITTEE_CACHE_SIZE.try_into().unwrap()))); - Self { ledger, coinbase_verifying_key, committee_cache, latest_leader: Default::default(), shutdown } + Self { ledger, committee_cache, latest_leader: Default::default(), shutdown } } } @@ -125,7 +123,7 @@ impl> LedgerService for CoreLedgerService< } /// Returns the solution for the given solution ID. - fn get_solution(&self, solution_id: &PuzzleCommitment) -> Result> { + fn get_solution(&self, solution_id: &SolutionID) -> Result> { self.ledger.get_solution(solution_id) } @@ -203,7 +201,7 @@ impl> LedgerService for CoreLedgerService< fn contains_transmission(&self, transmission_id: &TransmissionID) -> Result { match transmission_id { TransmissionID::Ratification => Ok(false), - TransmissionID::Solution(puzzle_commitment) => self.ledger.contains_puzzle_commitment(puzzle_commitment), + TransmissionID::Solution(solution_id) => self.ledger.contains_solution_id(solution_id), TransmissionID::Transaction(transaction_id) => self.ledger.contains_transaction_id(transaction_id), } } @@ -241,14 +239,14 @@ impl> LedgerService for CoreLedgerService< } } } - (TransmissionID::Solution(expected_commitment), Transmission::Solution(solution_data)) => { + (TransmissionID::Solution(expected_solution_id), Transmission::Solution(solution_data)) => { match solution_data.clone().deserialize_blocking() { Ok(solution) => { - if solution.commitment() != expected_commitment { + if solution.id() != expected_solution_id { bail!( "Received mismatching solution ID - expected {}, found {}", - fmt_id(expected_commitment), - fmt_id(solution.commitment()), + fmt_id(expected_solution_id), + fmt_id(solution.id()), ); } @@ -269,30 +267,25 @@ impl> LedgerService for CoreLedgerService< } /// Checks the given solution is well-formed. - async fn check_solution_basic( - &self, - puzzle_commitment: PuzzleCommitment, - solution: Data>, - ) -> Result<()> { + async fn check_solution_basic(&self, solution_id: SolutionID, solution: Data>) -> Result<()> { // Deserialize the solution. let solution = spawn_blocking!(solution.deserialize_blocking())?; - // Ensure the puzzle commitment matches in the solution. - if puzzle_commitment != solution.commitment() { - bail!("Invalid solution - expected {puzzle_commitment}, found {}", solution.commitment()); + // Ensure the solution ID matches in the solution. + if solution_id != solution.id() { + bail!("Invalid solution - expected {solution_id}, found {}", solution.id()); } - // Retrieve the coinbase verifying key. - let coinbase_verifying_key = self.coinbase_verifying_key.clone(); - // Compute the current epoch challenge. - let epoch_challenge = self.ledger.latest_epoch_challenge()?; + // Compute the current epoch hash. + let epoch_hash = self.ledger.latest_epoch_hash()?; // Retrieve the current proof target. let proof_target = self.ledger.latest_proof_target(); - // Ensure that the prover solution is valid for the given epoch. - if !spawn_blocking!(solution.verify(&coinbase_verifying_key, &epoch_challenge, proof_target))? { - bail!("Invalid prover solution '{puzzle_commitment}' for the current epoch."); + // Ensure that the solution is valid for the given epoch. + let puzzle = self.ledger.puzzle().clone(); + match spawn_blocking!(puzzle.check_solution(&solution, epoch_hash, proof_target)) { + Ok(()) => Ok(()), + Err(e) => bail!("Invalid solution '{}' for the current epoch - {e}", fmt_id(solution_id)), } - Ok(()) } /// Checks the given transaction is well-formed and unique. diff --git a/node/bft/ledger-service/src/mock.rs b/node/bft/ledger-service/src/mock.rs index 9d04f74dfa..681c8cd89e 100644 --- a/node/bft/ledger-service/src/mock.rs +++ b/node/bft/ledger-service/src/mock.rs @@ -16,9 +16,9 @@ use crate::{fmt_id, LedgerService}; use snarkvm::{ ledger::{ block::{Block, Transaction}, - coinbase::{ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::{bail, ensure, Address, Field, Network, Result}, }; @@ -127,7 +127,7 @@ impl LedgerService for MockLedgerService { } /// Returns the solution for the given solution ID. - fn get_solution(&self, _solution_id: &PuzzleCommitment) -> Result> { + fn get_solution(&self, _solution_id: &SolutionID) -> Result> { unreachable!("MockLedgerService does not support get_solution") } @@ -180,12 +180,8 @@ impl LedgerService for MockLedgerService { } /// Checks the given solution is well-formed. - async fn check_solution_basic( - &self, - puzzle_commitment: PuzzleCommitment, - _solution: Data>, - ) -> Result<()> { - trace!("[MockLedgerService] Check solution basic {:?} - Ok", fmt_id(puzzle_commitment)); + async fn check_solution_basic(&self, solution_id: SolutionID, _solution: Data>) -> Result<()> { + trace!("[MockLedgerService] Check solution basic {:?} - Ok", fmt_id(solution_id)); Ok(()) } diff --git a/node/bft/ledger-service/src/prover.rs b/node/bft/ledger-service/src/prover.rs index 57e62c216f..2d3839a19c 100644 --- a/node/bft/ledger-service/src/prover.rs +++ b/node/bft/ledger-service/src/prover.rs @@ -16,9 +16,9 @@ use crate::LedgerService; use snarkvm::{ ledger::{ block::{Block, Transaction}, - coinbase::{ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::{bail, Address, Field, Network, Result}, }; @@ -98,7 +98,7 @@ impl LedgerService for ProverLedgerService { } /// Returns the solution for the given solution ID. - fn get_solution(&self, solution_id: &PuzzleCommitment) -> Result> { + fn get_solution(&self, solution_id: &SolutionID) -> Result> { bail!("Solution '{solution_id}' does not exist in prover") } @@ -149,11 +149,7 @@ impl LedgerService for ProverLedgerService { } /// Checks the given solution is well-formed. - async fn check_solution_basic( - &self, - _puzzle_commitment: PuzzleCommitment, - _solution: Data>, - ) -> Result<()> { + async fn check_solution_basic(&self, _solution_id: SolutionID, _solution: Data>) -> Result<()> { Ok(()) } diff --git a/node/bft/ledger-service/src/traits.rs b/node/bft/ledger-service/src/traits.rs index b419d32958..2bbad3387f 100644 --- a/node/bft/ledger-service/src/traits.rs +++ b/node/bft/ledger-service/src/traits.rs @@ -15,9 +15,9 @@ use snarkvm::{ ledger::{ block::{Block, Transaction}, - coinbase::{ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::{Address, Field, Network, Result}, }; @@ -62,7 +62,7 @@ pub trait LedgerService: Debug + Send + Sync { fn get_blocks(&self, heights: Range) -> Result>>; /// Returns the solution for the given solution ID. - fn get_solution(&self, solution_id: &PuzzleCommitment) -> Result>; + fn get_solution(&self, solution_id: &SolutionID) -> Result>; /// Returns the unconfirmed transaction for the given transaction ID. fn get_unconfirmed_transaction(&self, transaction_id: N::TransactionID) -> Result>; @@ -95,11 +95,7 @@ pub trait LedgerService: Debug + Send + Sync { ) -> Result<()>; /// Checks the given solution is well-formed. - async fn check_solution_basic( - &self, - puzzle_commitment: PuzzleCommitment, - solution: Data>, - ) -> Result<()>; + async fn check_solution_basic(&self, solution_id: SolutionID, solution: Data>) -> Result<()>; /// Checks the given transaction is well-formed and unique. async fn check_transaction_basic( diff --git a/node/bft/ledger-service/src/translucent.rs b/node/bft/ledger-service/src/translucent.rs index 6107d5120c..044cd95eec 100644 --- a/node/bft/ledger-service/src/translucent.rs +++ b/node/bft/ledger-service/src/translucent.rs @@ -18,9 +18,9 @@ use indexmap::IndexMap; use snarkvm::{ ledger::{ block::{Block, Transaction}, - coinbase::{ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, store::ConsensusStorage, Ledger, }, @@ -109,7 +109,7 @@ impl> LedgerService for TranslucentLedgerS } /// Returns the solution for the given solution ID. - fn get_solution(&self, solution_id: &PuzzleCommitment) -> Result> { + fn get_solution(&self, solution_id: &SolutionID) -> Result> { self.inner.get_solution(solution_id) } @@ -159,11 +159,7 @@ impl> LedgerService for TranslucentLedgerS } /// Always succeeds. - async fn check_solution_basic( - &self, - _puzzle_commitment: PuzzleCommitment, - _solution: Data>, - ) -> Result<()> { + async fn check_solution_basic(&self, _solution_id: SolutionID, _solution: Data>) -> Result<()> { Ok(()) } diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index bf363f0c18..fd96e86ae9 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -33,9 +33,9 @@ use snarkvm::{ console::account::Address, ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::{bail, ensure, Field, Network, Result}, }; @@ -183,7 +183,7 @@ impl BFT { } /// Returns the unconfirmed solutions. - pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { + pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { self.primary.unconfirmed_solutions() } diff --git a/node/bft/src/helpers/channels.rs b/node/bft/src/helpers/channels.rs index 932c123530..70c6ad617b 100644 --- a/node/bft/src/helpers/channels.rs +++ b/node/bft/src/helpers/channels.rs @@ -25,8 +25,8 @@ use snarkvm::{ console::network::*, ledger::{ block::{Block, Transaction}, - coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::Result, }; @@ -126,8 +126,7 @@ pub struct PrimarySender { pub tx_batch_signature: mpsc::Sender<(SocketAddr, BatchSignature)>, pub tx_batch_certified: mpsc::Sender<(SocketAddr, Data>)>, pub tx_primary_ping: mpsc::Sender<(SocketAddr, Data>)>, - pub tx_unconfirmed_solution: - mpsc::Sender<(PuzzleCommitment, Data>, oneshot::Sender>)>, + pub tx_unconfirmed_solution: mpsc::Sender<(SolutionID, Data>, oneshot::Sender>)>, pub tx_unconfirmed_transaction: mpsc::Sender<(N::TransactionID, Data>, oneshot::Sender>)>, } @@ -135,8 +134,8 @@ impl PrimarySender { /// Sends the unconfirmed solution to the primary. pub async fn send_unconfirmed_solution( &self, - solution_id: PuzzleCommitment, - solution: Data>, + solution_id: SolutionID, + solution: Data>, ) -> Result<()> { // Initialize a callback sender and receiver. let (callback_sender, callback_receiver) = oneshot::channel(); @@ -167,8 +166,7 @@ pub struct PrimaryReceiver { pub rx_batch_signature: mpsc::Receiver<(SocketAddr, BatchSignature)>, pub rx_batch_certified: mpsc::Receiver<(SocketAddr, Data>)>, pub rx_primary_ping: mpsc::Receiver<(SocketAddr, Data>)>, - pub rx_unconfirmed_solution: - mpsc::Receiver<(PuzzleCommitment, Data>, oneshot::Sender>)>, + pub rx_unconfirmed_solution: mpsc::Receiver<(SolutionID, Data>, oneshot::Sender>)>, pub rx_unconfirmed_transaction: mpsc::Receiver<(N::TransactionID, Data>, oneshot::Sender>)>, } diff --git a/node/bft/src/helpers/partition.rs b/node/bft/src/helpers/partition.rs index e668eb8c35..fd64cc0932 100644 --- a/node/bft/src/helpers/partition.rs +++ b/node/bft/src/helpers/partition.rs @@ -76,7 +76,7 @@ pub fn assign_to_workers( #[cfg(test)] mod tests { use super::*; - use snarkvm::prelude::coinbase::PuzzleCommitment; + use snarkvm::prelude::puzzle::SolutionID; type CurrentNetwork = snarkvm::prelude::MainnetV0; @@ -90,8 +90,8 @@ mod tests { ]); let hash = sha256d_to_u128(data); assert_eq!(hash, 274520597840828436951879875061540363633u128); - let transmission_id: TransmissionID = TransmissionID::Solution(PuzzleCommitment::default()); + let transmission_id: TransmissionID = TransmissionID::Solution(SolutionID::from(123456789)); let worker_id = assign_to_worker(transmission_id, 5).unwrap(); - assert_eq!(worker_id, 4); + assert_eq!(worker_id, 2); } } diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 4ea0d322b5..eecbd93c48 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -177,7 +177,7 @@ impl Pending { mod tests { use super::*; use snarkvm::{ - ledger::{coinbase::PuzzleCommitment, narwhal::TransmissionID}, + ledger::narwhal::TransmissionID, prelude::{Rng, TestRng}, }; @@ -198,27 +198,27 @@ mod tests { assert!(pending.is_empty()); assert_eq!(pending.len(), 0); - // Initialize the commitments. - let commitment_1 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); - let commitment_2 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); - let commitment_3 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Initialize the solution IDs. + let solution_id_1 = TransmissionID::Solution(rng.gen::().into()); + let solution_id_2 = TransmissionID::Solution(rng.gen::().into()); + let solution_id_3 = TransmissionID::Solution(rng.gen::().into()); // Initialize the SocketAddrs. let addr_1 = SocketAddr::from(([127, 0, 0, 1], 1234)); let addr_2 = SocketAddr::from(([127, 0, 0, 1], 2345)); let addr_3 = SocketAddr::from(([127, 0, 0, 1], 3456)); - // Insert the commitments. - assert!(pending.insert(commitment_1, addr_1, None)); - assert!(pending.insert(commitment_2, addr_2, None)); - assert!(pending.insert(commitment_3, addr_3, None)); + // Insert the solution IDs. + assert!(pending.insert(solution_id_1, addr_1, None)); + assert!(pending.insert(solution_id_2, addr_2, None)); + assert!(pending.insert(solution_id_3, addr_3, None)); // Check the number of SocketAddrs. assert_eq!(pending.len(), 3); assert!(!pending.is_empty()); // Check the items. - let ids = [commitment_1, commitment_2, commitment_3]; + let ids = [solution_id_1, solution_id_2, solution_id_3]; let peers = [addr_1, addr_2, addr_3]; for i in 0..3 { @@ -226,19 +226,19 @@ mod tests { assert!(pending.contains(id)); assert!(pending.contains_peer(id, peers[i])); } - let unknown_id = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + let unknown_id = TransmissionID::Solution(rng.gen::().into()); assert!(!pending.contains(unknown_id)); // Check get. - assert_eq!(pending.get(commitment_1), Some(HashSet::from([addr_1]))); - assert_eq!(pending.get(commitment_2), Some(HashSet::from([addr_2]))); - assert_eq!(pending.get(commitment_3), Some(HashSet::from([addr_3]))); + assert_eq!(pending.get(solution_id_1), Some(HashSet::from([addr_1]))); + assert_eq!(pending.get(solution_id_2), Some(HashSet::from([addr_2]))); + assert_eq!(pending.get(solution_id_3), Some(HashSet::from([addr_3]))); assert_eq!(pending.get(unknown_id), None); // Check remove. - assert!(pending.remove(commitment_1, None).is_some()); - assert!(pending.remove(commitment_2, None).is_some()); - assert!(pending.remove(commitment_3, None).is_some()); + assert!(pending.remove(solution_id_1, None).is_some()); + assert!(pending.remove(solution_id_2, None).is_some()); + assert!(pending.remove(solution_id_3, None).is_some()); assert!(pending.remove(unknown_id, None).is_none()); // Check empty again. @@ -256,8 +256,8 @@ mod tests { assert!(pending.is_empty()); assert_eq!(pending.len(), 0); - // Initialize the commitments. - let commitment_1 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Initialize the solution ID. + let solution_id_1 = TransmissionID::Solution(rng.gen::().into()); // Initialize the SocketAddrs. let addr_1 = SocketAddr::from(([127, 0, 0, 1], 1234)); @@ -269,29 +269,29 @@ mod tests { let (callback_sender_2, _) = oneshot::channel(); let (callback_sender_3, _) = oneshot::channel(); - // Insert the commitments. - assert!(pending.insert(commitment_1, addr_1, Some((callback_sender_1, true)))); - assert!(pending.insert(commitment_1, addr_2, Some((callback_sender_2, true)))); + // Insert the solution ID. + assert!(pending.insert(solution_id_1, addr_1, Some((callback_sender_1, true)))); + assert!(pending.insert(solution_id_1, addr_2, Some((callback_sender_2, true)))); // Sleep for a few seconds. thread::sleep(Duration::from_secs(CALLBACK_TIMEOUT_IN_SECS as u64 - 1)); - assert!(pending.insert(commitment_1, addr_3, Some((callback_sender_3, true)))); + assert!(pending.insert(solution_id_1, addr_3, Some((callback_sender_3, true)))); // Check that the number of callbacks has not changed. - assert_eq!(pending.num_callbacks(commitment_1), 3); + assert_eq!(pending.num_callbacks(solution_id_1), 3); // Wait for 2 seconds. thread::sleep(Duration::from_secs(2)); // Ensure that the expired callbacks have been removed. - assert_eq!(pending.num_callbacks(commitment_1), 1); + assert_eq!(pending.num_callbacks(solution_id_1), 1); // Wait for `CALLBACK_TIMEOUT_IN_SECS` seconds. thread::sleep(Duration::from_secs(CALLBACK_TIMEOUT_IN_SECS as u64)); // Ensure that the expired callbacks have been removed. - assert_eq!(pending.num_callbacks(commitment_1), 0); + assert_eq!(pending.num_callbacks(solution_id_1), 0); } #[test] @@ -302,8 +302,8 @@ mod tests { let pending = Pending::, ()>::new(); for _ in 0..ITERATIONS { - // Generate a commitment. - let commitment = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Generate a solution ID. + let solution_id = TransmissionID::Solution(rng.gen::().into()); // Check if the number of sent requests is correct. let mut expected_num_sent_requests = 0; for i in 0..ITERATIONS { @@ -317,11 +317,11 @@ mod tests { if is_sent_request { expected_num_sent_requests += 1; } - // Insert the commitment. - assert!(pending.insert(commitment, addr, Some((callback_sender, is_sent_request)))); + // Insert the solution ID. + assert!(pending.insert(solution_id, addr, Some((callback_sender, is_sent_request)))); } // Ensure that the number of sent requests is correct. - assert_eq!(pending.num_sent_requests(commitment), expected_num_sent_requests); + assert_eq!(pending.num_sent_requests(solution_id), expected_num_sent_requests); } } } diff --git a/node/bft/src/helpers/ready.rs b/node/bft/src/helpers/ready.rs index 70ad087224..6fa581ccdb 100644 --- a/node/bft/src/helpers/ready.rs +++ b/node/bft/src/helpers/ready.rs @@ -16,8 +16,8 @@ use snarkvm::{ console::prelude::*, ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{Data, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, }; @@ -80,7 +80,7 @@ impl Ready { } /// Returns the solutions in the ready queue. - pub fn solutions(&self) -> impl '_ + Iterator, Data>)> { + pub fn solutions(&self) -> impl '_ + Iterator, Data>)> { self.transmissions.read().clone().into_iter().filter_map(|(id, transmission)| match (id, transmission) { (TransmissionID::Solution(id), Transmission::Solution(solution)) => Some((id, solution)), _ => None, @@ -131,7 +131,7 @@ impl Ready { #[cfg(test)] mod tests { use super::*; - use snarkvm::ledger::{coinbase::PuzzleCommitment, narwhal::Data}; + use snarkvm::ledger::narwhal::Data; use ::bytes::Bytes; @@ -147,38 +147,38 @@ mod tests { // Initialize the ready queue. let ready = Ready::::new(); - // Initialize the commitments. - let commitment_1 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); - let commitment_2 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); - let commitment_3 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Initialize the solution IDs. + let solution_id_1 = TransmissionID::Solution(rng.gen::().into()); + let solution_id_2 = TransmissionID::Solution(rng.gen::().into()); + let solution_id_3 = TransmissionID::Solution(rng.gen::().into()); // Initialize the solutions. let solution_1 = Transmission::Solution(data(rng)); let solution_2 = Transmission::Solution(data(rng)); let solution_3 = Transmission::Solution(data(rng)); - // Insert the commitments. - assert!(ready.insert(commitment_1, solution_1.clone())); - assert!(ready.insert(commitment_2, solution_2.clone())); - assert!(ready.insert(commitment_3, solution_3.clone())); + // Insert the solution IDs. + assert!(ready.insert(solution_id_1, solution_1.clone())); + assert!(ready.insert(solution_id_2, solution_2.clone())); + assert!(ready.insert(solution_id_3, solution_3.clone())); // Check the number of transmissions. assert_eq!(ready.num_transmissions(), 3); // Check the transmission IDs. - let transmission_ids = vec![commitment_1, commitment_2, commitment_3].into_iter().collect::>(); + let transmission_ids = vec![solution_id_1, solution_id_2, solution_id_3].into_iter().collect::>(); assert_eq!(ready.transmission_ids(), transmission_ids); transmission_ids.iter().for_each(|id| assert!(ready.contains(*id))); - // Check that an unknown commitment is not in the ready queue. - let commitment_unknown = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); - assert!(!ready.contains(commitment_unknown)); + // Check that an unknown solution ID is not in the ready queue. + let solution_id_unknown = TransmissionID::Solution(rng.gen::().into()); + assert!(!ready.contains(solution_id_unknown)); // Check the transmissions. - assert_eq!(ready.get(commitment_1), Some(solution_1.clone())); - assert_eq!(ready.get(commitment_2), Some(solution_2.clone())); - assert_eq!(ready.get(commitment_3), Some(solution_3.clone())); - assert_eq!(ready.get(commitment_unknown), None); + assert_eq!(ready.get(solution_id_1), Some(solution_1.clone())); + assert_eq!(ready.get(solution_id_2), Some(solution_2.clone())); + assert_eq!(ready.get(solution_id_3), Some(solution_3.clone())); + assert_eq!(ready.get(solution_id_unknown), None); // Drain the ready queue. let transmissions = ready.drain(3); @@ -191,7 +191,7 @@ mod tests { // Check the transmissions. assert_eq!( transmissions, - vec![(commitment_1, solution_1), (commitment_2, solution_2), (commitment_3, solution_3)] + vec![(solution_id_1, solution_1), (solution_id_2, solution_2), (solution_id_3, solution_3)] .into_iter() .collect::>() ); @@ -210,15 +210,15 @@ mod tests { // Initialize the ready queue. let ready = Ready::::new(); - // Initialize the commitments. - let commitment = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Initialize the solution ID. + let solution_id = TransmissionID::Solution(rng.gen::().into()); - // Initialize the solutions. + // Initialize the solution. let solution = Transmission::Solution(data); - // Insert the commitments. - assert!(ready.insert(commitment, solution.clone())); - assert!(!ready.insert(commitment, solution)); + // Insert the solution ID. + assert!(ready.insert(solution_id, solution.clone())); + assert!(!ready.insert(solution_id, solution)); // Check the number of transmissions. assert_eq!(ready.num_transmissions(), 1); diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index f10efd0d1a..f69b45b56d 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -644,17 +644,17 @@ impl Storage { // Retrieve the transmission. match transmission_id { TransmissionID::Ratification => (), - TransmissionID::Solution(puzzle_commitment) => { + TransmissionID::Solution(solution_id) => { // Retrieve the solution. - match block.get_solution(puzzle_commitment) { + match block.get_solution(solution_id) { // Insert the solution. Some(solution) => missing_transmissions.insert(*transmission_id, (*solution).into()), // Otherwise, try to load the solution from the ledger. - None => match self.ledger.get_solution(puzzle_commitment) { + None => match self.ledger.get_solution(solution_id) { // Insert the solution. Ok(solution) => missing_transmissions.insert(*transmission_id, solution.into()), Err(_) => { - error!("Missing solution {puzzle_commitment} in block {}", block.height()); + error!("Missing solution {solution_id} in block {}", block.height()); continue; } }, @@ -960,9 +960,9 @@ pub mod prop_tests { use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ ledger::{ - coinbase::PuzzleCommitment, committee::prop_tests::{CommitteeContext, ValidatorSet}, narwhal::{BatchHeader, Data}, + puzzle::SolutionID, }, prelude::{Signature, Uniform}, }; @@ -1071,8 +1071,8 @@ pub mod prop_tests { .boxed() } - pub fn any_puzzle_commitment() -> BoxedStrategy> { - Just(0).prop_perturb(|_, rng| PuzzleCommitment::from_g1_affine(CryptoTestRng(rng).gen())).boxed() + pub fn any_solution_id() -> BoxedStrategy> { + Just(0).prop_perturb(|_, rng| CryptoTestRng(rng).gen::().into()).boxed() } pub fn any_transaction_id() -> BoxedStrategy<::TransactionID> { @@ -1086,7 +1086,7 @@ pub mod prop_tests { pub fn any_transmission_id() -> BoxedStrategy> { prop_oneof![ any_transaction_id().prop_map(TransmissionID::Transaction), - any_puzzle_commitment().prop_map(TransmissionID::Solution), + any_solution_id().prop_map(TransmissionID::Solution), ] .boxed() } diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index f91cd52bf4..7032dbd4f9 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -48,8 +48,8 @@ use snarkvm::{ }, ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{BatchCertificate, BatchHeader, Data, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::committee::Committee, }; @@ -256,7 +256,7 @@ impl Primary { } /// Returns the unconfirmed solutions. - pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { + pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { self.workers.iter().flat_map(|worker| worker.solutions()) } @@ -1029,9 +1029,9 @@ impl Primary { // Process the unconfirmed solutions. let self_ = self.clone(); self.spawn(async move { - while let Some((puzzle_commitment, prover_solution, callback)) = rx_unconfirmed_solution.recv().await { + while let Some((solution_id, solution, callback)) = rx_unconfirmed_solution.recv().await { // Compute the worker ID. - let Ok(worker_id) = assign_to_worker(puzzle_commitment, self_.num_workers()) else { + let Ok(worker_id) = assign_to_worker(solution_id, self_.num_workers()) else { error!("Unable to determine the worker ID for the unconfirmed solution"); continue; }; @@ -1040,7 +1040,7 @@ impl Primary { // Retrieve the worker. let worker = &self_.workers[worker_id as usize]; // Process the unconfirmed solution. - let result = worker.process_unconfirmed_solution(puzzle_commitment, prover_solution).await; + let result = worker.process_unconfirmed_solution(solution_id, solution).await; // Send the result to the callback. callback.send(result).ok(); }); @@ -1523,20 +1523,17 @@ mod tests { } // Creates a mock solution. - fn sample_unconfirmed_solution( - rng: &mut TestRng, - ) -> (PuzzleCommitment, Data>) { - // Sample a random fake puzzle commitment. - let affine = rng.gen(); - let commitment = PuzzleCommitment::::from_g1_affine(affine); + fn sample_unconfirmed_solution(rng: &mut TestRng) -> (SolutionID, Data>) { + // Sample a random fake solution ID. + let solution_id = rng.gen::().into(); // Vary the size of the solutions. let size = rng.gen_range(1024..10 * 1024); // Sample random fake solution bytes. let mut vec = vec![0u8; size]; rng.fill_bytes(&mut vec); let solution = Data::Buffer(Bytes::from(vec)); - // Return the ID and solution. - (commitment, solution) + // Return the solution ID and solution. + (solution_id, solution) } // Creates a mock transaction. @@ -1564,15 +1561,15 @@ mod tests { timestamp: i64, rng: &mut TestRng, ) -> Proposal { - let (solution_commitment, solution) = sample_unconfirmed_solution(rng); + let (solution_id, solution) = sample_unconfirmed_solution(rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(rng); // Retrieve the private key. let private_key = author.private_key(); // Prepare the transmission IDs. - let transmission_ids = [solution_commitment.into(), (&transaction_id).into()].into(); + let transmission_ids = [solution_id.into(), (&transaction_id).into()].into(); let transmissions = [ - (solution_commitment.into(), Transmission::Solution(solution)), + (solution_id.into(), Transmission::Solution(solution)), ((&transaction_id).into(), Transmission::Transaction(transaction)), ] .into(); @@ -1645,11 +1642,11 @@ mod tests { let private_key = author.private_key(); let committee_id = Field::rand(rng); - let (solution_commitment, solution) = sample_unconfirmed_solution(rng); + let (solution_id, solution) = sample_unconfirmed_solution(rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(rng); - let transmission_ids = [solution_commitment.into(), (&transaction_id).into()].into(); + let transmission_ids = [solution_id.into(), (&transaction_id).into()].into(); let transmissions = [ - (solution_commitment.into(), Transmission::Solution(solution)), + (solution_id.into(), Transmission::Solution(solution)), ((&transaction_id).into(), Transmission::Transaction(transaction)), ] .into(); @@ -1722,11 +1719,11 @@ mod tests { assert!(primary.proposed_batch.read().is_none()); // Generate a solution and a transaction. - let (solution_commitment, solution) = sample_unconfirmed_solution(&mut rng); + let (solution_id, solution) = sample_unconfirmed_solution(&mut rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); // Store it on one of the workers. - primary.workers[0].process_unconfirmed_solution(solution_commitment, solution).await.unwrap(); + primary.workers[0].process_unconfirmed_solution(solution_id, solution).await.unwrap(); primary.workers[0].process_unconfirmed_transaction(transaction_id, transaction).await.unwrap(); // Try to propose a batch again. This time, it should succeed. @@ -1749,11 +1746,11 @@ mod tests { assert!(primary.proposed_batch.read().is_none()); // Generate a solution and a transaction. - let (solution_commitment, solution) = sample_unconfirmed_solution(&mut rng); + let (solution_id, solution) = sample_unconfirmed_solution(&mut rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); // Store it on one of the workers. - primary.workers[0].process_unconfirmed_solution(solution_commitment, solution).await.unwrap(); + primary.workers[0].process_unconfirmed_solution(solution_id, solution).await.unwrap(); primary.workers[0].process_unconfirmed_transaction(transaction_id, transaction).await.unwrap(); // Propose a batch again. This time, it should succeed. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 25e0a9bd3b..6919986653 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -26,8 +26,8 @@ use snarkvm::{ console::prelude::*, ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{BatchHeader, Data, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, }; @@ -140,7 +140,7 @@ impl Worker { } /// Returns the solutions in the ready queue. - pub fn solutions(&self) -> impl '_ + Iterator, Data>)> { + pub fn solutions(&self) -> impl '_ + Iterator, Data>)> { self.ready.solutions() } @@ -303,24 +303,22 @@ impl Worker { /// Note: This method assumes the incoming solution is valid and does not exist in the ledger. pub(crate) async fn process_unconfirmed_solution( &self, - puzzle_commitment: PuzzleCommitment, - prover_solution: Data>, + solution_id: SolutionID, + solution: Data>, ) -> Result<()> { // Construct the transmission. - let transmission = Transmission::Solution(prover_solution.clone()); - // Remove the puzzle commitment from the pending queue. - self.pending.remove(puzzle_commitment, Some(transmission.clone())); + let transmission = Transmission::Solution(solution.clone()); + // Remove the solution ID from the pending queue. + self.pending.remove(solution_id, Some(transmission.clone())); // Check if the solution exists. - if self.contains_transmission(puzzle_commitment) { - bail!("Solution '{}' already exists.", fmt_id(puzzle_commitment)); + if self.contains_transmission(solution_id) { + bail!("Solution '{}' already exists.", fmt_id(solution_id)); } // Check that the solution is well-formed and unique. - if let Err(e) = self.ledger.check_solution_basic(puzzle_commitment, prover_solution).await { - bail!("Invalid unconfirmed solution '{}': {e}", fmt_id(puzzle_commitment)); - } - // Adds the prover solution to the ready queue. - if self.ready.insert(puzzle_commitment, transmission) { - trace!("Worker {} - Added unconfirmed solution '{}'", self.id, fmt_id(puzzle_commitment)); + self.ledger.check_solution_basic(solution_id, solution).await?; + // Adds the solution to the ready queue. + if self.ready.insert(solution_id, transmission) { + trace!("Worker {} - Added unconfirmed solution '{}'", self.id, fmt_id(solution_id)); } Ok(()) } @@ -340,9 +338,7 @@ impl Worker { bail!("Transaction '{}' already exists.", fmt_id(transaction_id)); } // Check that the transaction is well-formed and unique. - if let Err(e) = self.ledger.check_transaction_basic(transaction_id, transaction).await { - bail!("Invalid unconfirmed transaction '{}': {e}", fmt_id(transaction_id)); - } + self.ledger.check_transaction_basic(transaction_id, transaction).await?; // Adds the transaction to the ready queue. if self.ready.insert(&transaction_id, transmission) { trace!("Worker {} - Added unconfirmed transaction '{}'", self.id, fmt_id(transaction_id)); @@ -519,7 +515,7 @@ mod tests { fn get_block_round(&self, height: u32) -> Result; fn get_block(&self, height: u32) -> Result>; fn get_blocks(&self, heights: Range) -> Result>>; - fn get_solution(&self, solution_id: &PuzzleCommitment) -> Result>; + fn get_solution(&self, solution_id: &SolutionID) -> Result>; fn get_unconfirmed_transaction(&self, transaction_id: N::TransactionID) -> Result>; fn get_batch_certificate(&self, certificate_id: &Field) -> Result>; fn current_committee(&self) -> Result>; @@ -534,8 +530,8 @@ mod tests { ) -> Result<()>; async fn check_solution_basic( &self, - puzzle_commitment: PuzzleCommitment, - solution: Data>, + solution_id: SolutionID, + solution: Data>, ) -> Result<()>; async fn check_transaction_basic( &self, @@ -593,7 +589,7 @@ mod tests { // Create the Worker. let worker = Worker::new(0, Arc::new(gateway), storage, ledger, Default::default()).unwrap(); let data = |rng: &mut TestRng| Data::Buffer(Bytes::from((0..512).map(|_| rng.gen::()).collect::>())); - let transmission_id = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + let transmission_id = TransmissionID::Solution(rng.gen::().into()); let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); let transmission = Transmission::Solution(data(rng)); @@ -630,7 +626,7 @@ mod tests { // Create the Worker. let worker = Worker::new(0, Arc::new(gateway), storage, ledger, Default::default()).unwrap(); - let transmission_id = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + let transmission_id = TransmissionID::Solution(rng.gen::().into()); let worker_ = worker.clone(); let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; @@ -668,21 +664,21 @@ mod tests { // Create the Worker. let worker = Worker::new(0, Arc::new(gateway), storage, ledger, Default::default()).unwrap(); - let puzzle = PuzzleCommitment::from_g1_affine(rng.gen()); - let transmission_id = TransmissionID::Solution(puzzle); + let solution_id = rng.gen::().into(); + let transmission_id = TransmissionID::Solution(solution_id); let worker_ = worker.clone(); let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; assert!(worker.pending.contains(transmission_id)); let result = worker .process_unconfirmed_solution( - puzzle, + solution_id, Data::Buffer(Bytes::from((0..512).map(|_| rng.gen::()).collect::>())), ) .await; assert!(result.is_ok()); assert!(!worker.pending.contains(transmission_id)); - assert!(worker.ready.contains(puzzle)); + assert!(worker.ready.contains(solution_id)); } #[tokio::test] @@ -708,21 +704,21 @@ mod tests { // Create the Worker. let worker = Worker::new(0, Arc::new(gateway), storage, ledger, Default::default()).unwrap(); - let puzzle = PuzzleCommitment::from_g1_affine(rng.gen()); - let transmission_id = TransmissionID::Solution(puzzle); + let solution_id = rng.gen::().into(); + let transmission_id = TransmissionID::Solution(solution_id); let worker_ = worker.clone(); let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; assert!(worker.pending.contains(transmission_id)); let result = worker .process_unconfirmed_solution( - puzzle, + solution_id, Data::Buffer(Bytes::from((0..512).map(|_| rng.gen::()).collect::>())), ) .await; assert!(result.is_err()); - assert!(!worker.pending.contains(puzzle)); - assert!(!worker.ready.contains(puzzle)); + assert!(!worker.pending.contains(solution_id)); + assert!(!worker.ready.contains(solution_id)); } #[tokio::test] diff --git a/node/bft/tests/common/utils.rs b/node/bft/tests/common/utils.rs index b2d5d5520f..1fa074f102 100644 --- a/node/bft/tests/common/utils.rs +++ b/node/bft/tests/common/utils.rs @@ -18,7 +18,7 @@ use snarkvm::{ ledger::narwhal::Data, prelude::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, + puzzle::{Solution, SolutionID}, Field, Network, TestRng, @@ -30,7 +30,7 @@ use std::time::Duration; use ::bytes::Bytes; use rand::Rng; -use tokio::{sync::oneshot, task, task::JoinHandle, time::sleep}; +use tokio::{sync::oneshot, task::JoinHandle, time::sleep}; use tracing::*; use tracing_subscriber::{ layer::{Layer, SubscriberExt}, @@ -83,32 +83,29 @@ pub fn fire_unconfirmed_solutions( // This RNG samples *different* fake solutions for each node. let mut unique_rng = TestRng::fixed(node_id as u64); - // A closure to generate a commitment and solution. - async fn sample(mut rng: impl Rng) -> (PuzzleCommitment, Data>) { - // Sample a random fake puzzle commitment. - // TODO (howardwu): Use a mutex to bring in the real 'proof target' and change this sampling to a while loop. - let affine = rng.gen(); - let commitment = - task::spawn_blocking(move || PuzzleCommitment::::from_g1_affine(affine)).await.unwrap(); + // A closure to generate a solution ID and solution. + async fn sample(mut rng: impl Rng) -> (SolutionID, Data>) { + // Sample a random fake solution ID. + let solution_id = rng.gen::().into(); // Sample random fake solution bytes. let mut vec = vec![0u8; 1024]; rng.fill_bytes(&mut vec); let solution = Data::Buffer(Bytes::from(vec)); - // Return the ID and solution. - (commitment, solution) + // Return the solution ID and solution. + (solution_id, solution) } // Initialize a counter. let mut counter = 0; loop { - // Sample a random fake puzzle commitment and solution. - let (commitment, solution) = + // Sample a random fake solution ID and solution. + let (solution_id, solution) = if counter % 2 == 0 { sample(&mut shared_rng).await } else { sample(&mut unique_rng).await }; // Initialize a callback sender and receiver. let (callback, callback_receiver) = oneshot::channel(); // Send the fake solution. - if let Err(e) = tx_unconfirmed_solution.send((commitment, solution, callback)).await { + if let Err(e) = tx_unconfirmed_solution.send((solution_id, solution, callback)).await { error!("Failed to send unconfirmed solution: {e}"); } let _ = callback_receiver.await; diff --git a/node/cdn/Cargo.toml b/node/cdn/Cargo.toml index aff5c26cba..2078de4a59 100644 --- a/node/cdn/Cargo.toml +++ b/node/cdn/Cargo.toml @@ -60,5 +60,9 @@ features = [ "rt" ] [dependencies.tracing] version = "0.1" +[dev-dependencies.tokio] +version = "1.28" +features = [ "rt", "rt-multi-thread" ] + [dev-dependencies.tokio-test] version = "0.4" diff --git a/node/cdn/src/blocks.rs b/node/cdn/src/blocks.rs index 8772b43ec3..a1b4b91e3e 100644 --- a/node/cdn/src/blocks.rs +++ b/node/cdn/src/blocks.rs @@ -48,7 +48,7 @@ const MAXIMUM_PENDING_BLOCKS: u32 = BLOCKS_PER_FILE * CONCURRENT_REQUESTS * 2; /// Maximum number of attempts for a request to the CDN. const MAXIMUM_REQUEST_ATTEMPTS: u8 = 10; /// The supported network. -const NETWORK_ID: u16 = 3; +const NETWORK_ID: u16 = 0; /// Loads blocks from a CDN into the ledger. /// diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 75b02e89e0..b0c9fadd84 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -35,8 +35,8 @@ use snarkos_node_bft_storage_service::BFTPersistentStorage; use snarkvm::{ ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{BatchHeader, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::*, }; @@ -90,11 +90,11 @@ pub struct Consensus { /// The primary sender. primary_sender: Arc>>, /// The unconfirmed solutions queue. - solutions_queue: Arc, ProverSolution>>>, + solutions_queue: Arc, Solution>>>, /// The unconfirmed transactions queue. transactions_queue: Arc>>, /// The recently-seen unconfirmed solutions. - seen_solutions: Arc, ()>>>, + seen_solutions: Arc, ()>>>, /// The recently-seen unconfirmed transactions. seen_transactions: Arc>>, /// The spawned handles. @@ -199,7 +199,7 @@ impl Consensus { } /// Returns the unconfirmed solutions. - pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { + pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { self.bft.unconfirmed_solutions() } @@ -211,7 +211,7 @@ impl Consensus { impl Consensus { /// Adds the given unconfirmed solution to the memory pool. - pub async fn add_unconfirmed_solution(&self, solution: ProverSolution) -> Result<()> { + pub async fn add_unconfirmed_solution(&self, solution: Solution) -> Result<()> { #[cfg(feature = "metrics")] { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); @@ -219,7 +219,7 @@ impl Consensus { } // Process the unconfirmed solution. { - let solution_id = solution.commitment(); + let solution_id = solution.id(); // Check if the transaction was recently seen. if self.seen_solutions.lock().put(solution_id, ()).is_some() { @@ -255,7 +255,7 @@ impl Consensus { }; // Iterate over the solutions. for solution in solutions.into_iter() { - let solution_id = solution.commitment(); + let solution_id = solution.id(); trace!("Adding unconfirmed solution '{}' to the memory pool...", fmt_id(solution_id)); // Send the unconfirmed solution to the primary. if let Err(e) = self.primary_sender().send_unconfirmed_solution(solution_id, Data::Object(solution)).await { @@ -453,9 +453,9 @@ impl Consensus { // Send the transmission to the primary. match (transmission_id, transmission) { (TransmissionID::Ratification, Transmission::Ratification) => return Ok(()), - (TransmissionID::Solution(commitment), Transmission::Solution(solution)) => { + (TransmissionID::Solution(solution_id), Transmission::Solution(solution)) => { // Send the solution to the primary. - self.primary_sender().tx_unconfirmed_solution.send((commitment, solution, callback)).await?; + self.primary_sender().tx_unconfirmed_solution.send((solution_id, solution, callback)).await?; } (TransmissionID::Transaction(transaction_id), Transmission::Transaction(transaction)) => { // Send the transaction to the primary. diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index b8a5f4c3bd..27fe8ccb89 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -15,7 +15,7 @@ use super::*; use snarkos_node_router::messages::UnconfirmedSolution; use snarkvm::{ - ledger::coinbase::ProverSolution, + ledger::puzzle::Solution, prelude::{block::Transaction, Identifier, Plaintext}, }; @@ -335,24 +335,22 @@ impl, R: Routing> Rest { // POST /mainnet/solution/broadcast pub(crate) async fn solution_broadcast( State(rest): State, - Json(prover_solution): Json>, + Json(solution): Json>, ) -> Result { // If the consensus module is enabled, add the unconfirmed solution to the memory pool. if let Some(consensus) = rest.consensus { // Add the unconfirmed solution to the memory pool. - consensus.add_unconfirmed_solution(prover_solution).await?; + consensus.add_unconfirmed_solution(solution).await?; } - let commitment = prover_solution.commitment(); + let solution_id = solution.id(); // Prepare the unconfirmed solution message. - let message = Message::UnconfirmedSolution(UnconfirmedSolution { - solution_id: commitment, - solution: Data::Object(prover_solution), - }); + let message = + Message::UnconfirmedSolution(UnconfirmedSolution { solution_id, solution: Data::Object(solution) }); // Broadcast the unconfirmed solution message. rest.routing.propagate(message, &[]); - Ok(ErasedJson::pretty(commitment)) + Ok(ErasedJson::pretty(solution_id)) } } diff --git a/node/router/messages/src/lib.rs b/node/router/messages/src/lib.rs index 09b065a49d..8fe2c40d9a 100644 --- a/node/router/messages/src/lib.rs +++ b/node/router/messages/src/lib.rs @@ -64,8 +64,8 @@ pub use snarkos_node_bft_events::DataBlocks; use snarkos_node_sync_locators::BlockLocators; use snarkvm::prelude::{ block::{Header, Transaction}, - coinbase::{EpochChallenge, ProverSolution, PuzzleCommitment}, error, + puzzle::{Solution, SolutionID}, Address, FromBytes, Network, diff --git a/node/router/messages/src/puzzle_response.rs b/node/router/messages/src/puzzle_response.rs index dcc1aa803c..ecafccac1d 100644 --- a/node/router/messages/src/puzzle_response.rs +++ b/node/router/messages/src/puzzle_response.rs @@ -23,7 +23,7 @@ use std::borrow::Cow; #[derive(Clone, Debug, PartialEq, Eq)] pub struct PuzzleResponse { - pub epoch_challenge: EpochChallenge, + pub epoch_hash: N::BlockHash, pub block_header: Data>, } @@ -37,24 +37,24 @@ impl MessageTrait for PuzzleResponse { impl ToBytes for PuzzleResponse { fn write_le(&self, mut writer: W) -> io::Result<()> { - self.epoch_challenge.write_le(&mut writer)?; + self.epoch_hash.write_le(&mut writer)?; self.block_header.write_le(&mut writer) } } impl FromBytes for PuzzleResponse { fn read_le(mut reader: R) -> io::Result { - Ok(Self { epoch_challenge: EpochChallenge::read_le(&mut reader)?, block_header: Data::read_le(reader)? }) + Ok(Self { epoch_hash: N::BlockHash::read_le(&mut reader)?, block_header: Data::read_le(reader)? }) } } #[cfg(test)] pub mod prop_tests { - use crate::{challenge_response::prop_tests::any_genesis_header, EpochChallenge, PuzzleResponse}; + use crate::{challenge_response::prop_tests::any_genesis_header, PuzzleResponse}; use snarkvm::{ console::prelude::{FromBytes, ToBytes}, ledger::narwhal::Data, - prelude::{Rng, TestRng}, + prelude::{Network, Rng, TestRng}, }; use bytes::{Buf, BufMut, BytesMut}; @@ -63,19 +63,18 @@ pub mod prop_tests { type CurrentNetwork = snarkvm::prelude::MainnetV0; - pub fn any_epoch_challenge() -> BoxedStrategy> { + pub fn any_epoch_hash() -> BoxedStrategy<::BlockHash> { any::() .prop_map(|seed| { let mut rng = TestRng::fixed(seed); - let degree: u16 = rng.gen_range(1..=u16::MAX); - EpochChallenge::::new(rng.gen(), rng.gen(), degree as u32).unwrap() + rng.gen() }) .boxed() } pub fn any_puzzle_response() -> BoxedStrategy> { - (any_epoch_challenge(), any_genesis_header()) - .prop_map(|(epoch_challenge, bh)| PuzzleResponse { epoch_challenge, block_header: Data::Object(bh) }) + (any_epoch_hash(), any_genesis_header()) + .prop_map(|(epoch_hash, bh)| PuzzleResponse { epoch_hash, block_header: Data::Object(bh) }) .boxed() } @@ -85,7 +84,7 @@ pub mod prop_tests { PuzzleResponse::write_le(&original, &mut buf).unwrap(); let deserialized: PuzzleResponse = PuzzleResponse::read_le(buf.into_inner().reader()).unwrap(); - assert_eq!(original.epoch_challenge, deserialized.epoch_challenge); + assert_eq!(original.epoch_hash, deserialized.epoch_hash); assert_eq!( original.block_header.deserialize_blocking().unwrap(), deserialized.block_header.deserialize_blocking().unwrap(), diff --git a/node/router/messages/src/unconfirmed_solution.rs b/node/router/messages/src/unconfirmed_solution.rs index 43edaf948d..9caf066ab9 100644 --- a/node/router/messages/src/unconfirmed_solution.rs +++ b/node/router/messages/src/unconfirmed_solution.rs @@ -23,8 +23,8 @@ use std::borrow::Cow; #[derive(Clone, Debug, PartialEq, Eq)] pub struct UnconfirmedSolution { - pub solution_id: PuzzleCommitment, - pub solution: Data>, + pub solution_id: SolutionID, + pub solution: Data>, } impl MessageTrait for UnconfirmedSolution { @@ -44,16 +44,15 @@ impl ToBytes for UnconfirmedSolution { impl FromBytes for UnconfirmedSolution { fn read_le(mut reader: R) -> io::Result { - Ok(Self { solution_id: PuzzleCommitment::read_le(&mut reader)?, solution: Data::read_le(reader)? }) + Ok(Self { solution_id: SolutionID::read_le(&mut reader)?, solution: Data::read_le(reader)? }) } } #[cfg(test)] pub mod prop_tests { - use crate::{ProverSolution, PuzzleCommitment, UnconfirmedSolution}; + use crate::{Solution, SolutionID, UnconfirmedSolution}; use snarkvm::{ - algorithms::polycommit::kzg10::{KZGCommitment, KZGProof}, - ledger::{coinbase::PartialSolution, narwhal::Data}, + ledger::narwhal::Data, prelude::{Address, FromBytes, PrivateKey, Rng, TestRng, ToBytes}, }; @@ -63,26 +62,23 @@ pub mod prop_tests { type CurrentNetwork = snarkvm::prelude::MainnetV0; - pub fn any_solution_id() -> BoxedStrategy> { - any::() - .prop_map(|seed| PuzzleCommitment::::new(KZGCommitment(TestRng::fixed(seed).gen()))) - .boxed() + pub fn any_solution_id() -> BoxedStrategy> { + any::().prop_map(|seed| TestRng::fixed(seed).gen::().into()).boxed() } - pub fn any_prover_solution() -> BoxedStrategy> { + pub fn any_solution() -> BoxedStrategy> { any::() .prop_map(|seed| { let mut rng = TestRng::fixed(seed); let private_key = PrivateKey::::new(&mut rng).unwrap(); let address = Address::try_from(private_key).unwrap(); - let partial_solution = PartialSolution::new(address, rng.gen(), KZGCommitment(rng.gen())); - ProverSolution::new(partial_solution, KZGProof { w: rng.gen(), random_v: None }) + Solution::new(rng.gen(), address, rng.gen()).unwrap() }) .boxed() } pub fn any_unconfirmed_solution() -> BoxedStrategy> { - (any_solution_id(), any_prover_solution()) + (any_solution_id(), any_solution()) .prop_map(|(solution_id, ps)| UnconfirmedSolution { solution_id, solution: Data::Object(ps) }) .boxed() } diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index ae84ba21aa..204052e641 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -277,7 +277,7 @@ pub trait Heartbeat: Outbound { } } - /// This function updates the coinbase puzzle if network has updated. + /// This function updates the puzzle if network has updated. fn handle_puzzle_request(&self) { // No-op } diff --git a/node/router/src/helpers/cache.rs b/node/router/src/helpers/cache.rs index 20c958b9ae..29f46aa63d 100644 --- a/node/router/src/helpers/cache.rs +++ b/node/router/src/helpers/cache.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::messages::BlockRequest; -use snarkvm::prelude::{coinbase::PuzzleCommitment, Network}; +use snarkvm::prelude::{puzzle::SolutionID, Network}; use core::hash::Hash; use linked_hash_map::LinkedHashMap; @@ -27,8 +27,8 @@ use time::{Duration, OffsetDateTime}; /// The maximum number of items to store in a cache map. const MAX_CACHE_SIZE: usize = 1 << 17; -/// A helper containing the peer IP and solution commitment. -type SolutionKey = (SocketAddr, PuzzleCommitment); +/// A helper containing the peer IP and solution ID. +type SolutionKey = (SocketAddr, SolutionID); /// A helper containing the peer IP and transaction ID. type TransactionKey = (SocketAddr, ::TransactionID); @@ -40,7 +40,7 @@ pub struct Cache { seen_inbound_messages: RwLock>>, /// The map of peer IPs to their recent timestamps. seen_inbound_puzzle_requests: RwLock>>, - /// The map of solution commitments to their last seen timestamp. + /// The map of solution IDs to their last seen timestamp. seen_inbound_solutions: RwLock, OffsetDateTime>>, /// The map of transaction IDs to their last seen timestamp. seen_inbound_transactions: RwLock, OffsetDateTime>>, @@ -48,7 +48,7 @@ pub struct Cache { seen_outbound_block_requests: RwLock>>, /// The map of peer IPs to the number of puzzle requests. seen_outbound_puzzle_requests: RwLock>, - /// The map of solution commitments to their last seen timestamp. + /// The map of solution IDs to their last seen timestamp. seen_outbound_solutions: RwLock, OffsetDateTime>>, /// The map of transaction IDs to their last seen timestamp. seen_outbound_transactions: RwLock, OffsetDateTime>>, @@ -97,13 +97,9 @@ impl Cache { Self::retain_and_insert(&self.seen_inbound_puzzle_requests, peer_ip, 60) } - /// Inserts a solution commitment into the cache, returning the previously seen timestamp if it existed. - pub fn insert_inbound_solution( - &self, - peer_ip: SocketAddr, - solution: PuzzleCommitment, - ) -> Option { - Self::refresh_and_insert(&self.seen_inbound_solutions, (peer_ip, solution)) + /// Inserts a solution ID into the cache, returning the previously seen timestamp if it existed. + pub fn insert_inbound_solution(&self, peer_ip: SocketAddr, solution_id: SolutionID) -> Option { + Self::refresh_and_insert(&self.seen_inbound_solutions, (peer_ip, solution_id)) } /// Inserts a transaction ID into the cache, returning the previously seen timestamp if it existed. @@ -151,13 +147,9 @@ impl Cache { Self::decrement_counter(&self.seen_outbound_puzzle_requests, peer_ip) } - /// Inserts a solution commitment into the cache, returning the previously seen timestamp if it existed. - pub fn insert_outbound_solution( - &self, - peer_ip: SocketAddr, - solution: PuzzleCommitment, - ) -> Option { - Self::refresh_and_insert(&self.seen_outbound_solutions, (peer_ip, solution)) + /// Inserts a solution ID into the cache, returning the previously seen timestamp if it existed. + pub fn insert_outbound_solution(&self, peer_ip: SocketAddr, solution_id: SolutionID) -> Option { + Self::refresh_and_insert(&self.seen_outbound_solutions, (peer_ip, solution_id)) } /// Inserts a transaction ID into the cache, returning the previously seen timestamp if it existed. @@ -270,19 +262,19 @@ mod tests { fn test_inbound_solution() { let cache = Cache::::default(); let peer_ip = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 1234); - let solution = PuzzleCommitment::::default(); + let solution_id = SolutionID::::from(123456789); // Check that the cache is empty. assert_eq!(cache.seen_inbound_solutions.read().len(), 0); // Insert a solution. - assert!(cache.insert_inbound_solution(peer_ip, solution).is_none()); + assert!(cache.insert_inbound_solution(peer_ip, solution_id).is_none()); // Check that the cache contains the solution. assert_eq!(cache.seen_inbound_solutions.read().len(), 1); // Insert the same solution again. - assert!(cache.insert_inbound_solution(peer_ip, solution).is_some()); + assert!(cache.insert_inbound_solution(peer_ip, solution_id).is_some()); // Check that the cache still contains the solution. assert_eq!(cache.seen_inbound_solutions.read().len(), 1); @@ -314,19 +306,19 @@ mod tests { fn test_outbound_solution() { let cache = Cache::::default(); let peer_ip = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 1234); - let solution = PuzzleCommitment::::default(); + let solution_id = SolutionID::::from(123456789); // Check that the cache is empty. assert_eq!(cache.seen_outbound_solutions.read().len(), 0); // Insert a solution. - assert!(cache.insert_outbound_solution(peer_ip, solution).is_none()); + assert!(cache.insert_outbound_solution(peer_ip, solution_id).is_none()); // Check that the cache contains the solution. assert_eq!(cache.seen_outbound_solutions.read().len(), 1); // Insert the same solution again. - assert!(cache.insert_outbound_solution(peer_ip, solution).is_some()); + assert!(cache.insert_outbound_solution(peer_ip, solution_id).is_some()); // Check that the cache still contains the solution. assert_eq!(cache.seen_outbound_solutions.read().len(), 1); diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index e99072dfc2..ee7e265cc0 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -30,7 +30,7 @@ use crate::{ use snarkos_node_tcp::protocols::Reading; use snarkvm::prelude::{ block::{Block, Header, Transaction}, - coinbase::{EpochChallenge, ProverSolution}, + puzzle::Solution, Network, }; @@ -201,7 +201,7 @@ pub trait Inbound: Reading + Outbound { Err(error) => bail!("[PuzzleResponse] {error}"), }; // Process the puzzle response. - match self.puzzle_response(peer_ip, message.epoch_challenge, header) { + match self.puzzle_response(peer_ip, message.epoch_hash, header) { true => Ok(()), false => bail!("Peer '{peer_ip}' sent an invalid puzzle response"), } @@ -222,7 +222,7 @@ pub trait Inbound: Reading + Outbound { Err(error) => bail!("[UnconfirmedSolution] {error}"), }; // Check that the solution parameters match. - if message.solution_id != solution.commitment() { + if message.solution_id != solution.id() { bail!("Peer '{peer_ip}' is not following the 'UnconfirmedSolution' protocol") } // Handle the unconfirmed solution. @@ -316,14 +316,14 @@ pub trait Inbound: Reading + Outbound { fn puzzle_request(&self, peer_ip: SocketAddr) -> bool; /// Handles a `PuzzleResponse` message. - fn puzzle_response(&self, peer_ip: SocketAddr, _challenge: EpochChallenge, _header: Header) -> bool; + fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_hash: N::BlockHash, _header: Header) -> bool; /// Handles an `UnconfirmedSolution` message. async fn unconfirmed_solution( &self, peer_ip: SocketAddr, serialized: UnconfirmedSolution, - solution: ProverSolution, + solution: Solution, ) -> bool; /// Handles an `UnconfirmedTransaction` message. diff --git a/node/router/tests/common/router.rs b/node/router/tests/common/router.rs index 0ca9f721d4..9dfe4f9e01 100644 --- a/node/router/tests/common/router.rs +++ b/node/router/tests/common/router.rs @@ -39,7 +39,7 @@ use snarkos_node_tcp::{ }; use snarkvm::prelude::{ block::{Block, Header, Transaction}, - coinbase::{EpochChallenge, ProverSolution}, + puzzle::Solution, Network, }; @@ -179,7 +179,7 @@ impl Inbound for TestRouter { } /// Handles an `PuzzleResponse` message. - fn puzzle_response(&self, _peer_ip: SocketAddr, _epoch_challenge: EpochChallenge, _header: Header) -> bool { + fn puzzle_response(&self, _peer_ip: SocketAddr, _epoch_hash: N::BlockHash, _header: Header) -> bool { true } @@ -188,7 +188,7 @@ impl Inbound for TestRouter { &self, _peer_ip: SocketAddr, _serialized: UnconfirmedSolution, - _solution: ProverSolution, + _solution: Solution, ) -> bool { true } diff --git a/node/src/client/mod.rs b/node/src/client/mod.rs index 079613c2f9..385ab355fe 100644 --- a/node/src/client/mod.rs +++ b/node/src/client/mod.rs @@ -35,7 +35,7 @@ use snarkvm::{ console::network::Network, ledger::{ block::{Block, Header}, - coinbase::{CoinbasePuzzle, EpochChallenge, ProverSolution}, + puzzle::{Puzzle, Solution}, store::ConsensusStorage, Ledger, }, @@ -64,8 +64,8 @@ pub struct Client> { sync: Arc>, /// The genesis block. genesis: Block, - /// The coinbase puzzle. - coinbase_puzzle: CoinbasePuzzle, + /// The puzzle. + puzzle: Puzzle, /// The spawned handles. handles: Arc>>>, /// The shutdown signal. @@ -122,8 +122,6 @@ impl> Client { matches!(storage_mode, StorageMode::Development(_)), ) .await?; - // Load the coinbase puzzle. - let coinbase_puzzle = CoinbasePuzzle::::load()?; // Initialize the node. let mut node = Self { ledger: ledger.clone(), @@ -131,7 +129,7 @@ impl> Client { rest: None, sync: Arc::new(sync), genesis, - coinbase_puzzle, + puzzle: ledger.puzzle().clone(), handles: Default::default(), shutdown, }; diff --git a/node/src/client/router.rs b/node/src/client/router.rs index 6123f75e32..898b2bee82 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -235,11 +235,11 @@ impl> Inbound for Client { true } - /// Disconnects on receipt of a `PuzzleRequest` message. + /// Retrieves the latest epoch hash and latest block header, and returns the puzzle response to the peer. fn puzzle_request(&self, peer_ip: SocketAddr) -> bool { - // Retrieve the latest epoch challenge. - let epoch_challenge = match self.ledger.latest_epoch_challenge() { - Ok(epoch_challenge) => epoch_challenge, + // Retrieve the latest epoch hash. + let epoch_hash = match self.ledger.latest_epoch_hash() { + Ok(epoch_hash) => epoch_hash, Err(error) => { error!("Failed to prepare a puzzle request for '{peer_ip}': {error}"); return false; @@ -248,12 +248,12 @@ impl> Inbound for Client { // Retrieve the latest block header. let block_header = Data::Object(self.ledger.latest_header()); // Send the `PuzzleResponse` message to the peer. - Outbound::send(self, peer_ip, Message::PuzzleResponse(PuzzleResponse { epoch_challenge, block_header })); + Outbound::send(self, peer_ip, Message::PuzzleResponse(PuzzleResponse { epoch_hash, block_header })); true } - /// Saves the latest epoch challenge and latest block header in the node. - fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_challenge: EpochChallenge, _header: Header) -> bool { + /// Saves the latest epoch hash and latest block header in the node. + fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_hash: N::BlockHash, _header: Header) -> bool { debug!("Disconnecting '{peer_ip}' for the following reason - {:?}", DisconnectReason::ProtocolViolation); false } @@ -263,30 +263,28 @@ impl> Inbound for Client { &self, peer_ip: SocketAddr, serialized: UnconfirmedSolution, - solution: ProverSolution, + solution: Solution, ) -> bool { - // Retrieve the latest epoch challenge. - if let Ok(epoch_challenge) = self.ledger.latest_epoch_challenge() { + // Retrieve the latest epoch hash. + if let Ok(epoch_hash) = self.ledger.latest_epoch_hash() { // Retrieve the latest proof target. let proof_target = self.ledger.latest_block().header().proof_target(); - // Ensure that the prover solution is valid for the given epoch. - let coinbase_puzzle = self.coinbase_puzzle.clone(); - let is_valid = tokio::task::spawn_blocking(move || { - solution.verify(coinbase_puzzle.coinbase_verifying_key(), &epoch_challenge, proof_target) - }) - .await; + // Ensure that the solution is valid for the given epoch. + let puzzle = self.puzzle.clone(); + let is_valid = + tokio::task::spawn_blocking(move || puzzle.check_solution(&solution, epoch_hash, proof_target)).await; match is_valid { // If the solution is valid, propagate the `UnconfirmedSolution`. - Ok(Ok(true)) => { + Ok(Ok(())) => { let message = Message::UnconfirmedSolution(serialized); // Propagate the "UnconfirmedSolution". self.propagate(message, &[peer_ip]); } - Ok(Ok(false)) | Ok(Err(_)) => { - trace!("Invalid prover solution '{}' for the proof target.", solution.commitment()) + Ok(Err(_)) => { + trace!("Invalid solution '{}' for the proof target.", solution.id()) } - Err(error) => warn!("Failed to verify the prover solution: {error}"), + Err(error) => warn!("Failed to verify the solution: {error}"), } } true diff --git a/node/src/prover/mod.rs b/node/src/prover/mod.rs index 30b5c04a6d..18d9f33e92 100644 --- a/node/src/prover/mod.rs +++ b/node/src/prover/mod.rs @@ -34,10 +34,11 @@ use snarkvm::{ ledger::narwhal::Data, prelude::{ block::{Block, Header}, - coinbase::{CoinbasePuzzle, EpochChallenge, ProverSolution}, + puzzle::{Puzzle, Solution}, store::ConsensusStorage, Network, }, + synthesizer::VM, }; use aleo_std::StorageMode; @@ -46,6 +47,7 @@ use colored::Colorize; use core::{marker::PhantomData, time::Duration}; use parking_lot::{Mutex, RwLock}; use rand::{rngs::OsRng, CryptoRng, Rng}; +use snarkos_node_bft::helpers::fmt_id; use std::{ net::SocketAddr, sync::{ @@ -64,10 +66,10 @@ pub struct Prover> { sync: Arc>, /// The genesis block. genesis: Block, - /// The coinbase puzzle. - coinbase_puzzle: CoinbasePuzzle, - /// The latest epoch challenge. - latest_epoch_challenge: Arc>>>>, + /// The puzzle. + puzzle: Puzzle, + /// The latest epoch hash. + latest_epoch_hash: Arc>>, /// The latest block header. latest_block_header: Arc>>>, /// The number of puzzle instances. @@ -115,8 +117,6 @@ impl> Prover { matches!(storage_mode, StorageMode::Development(_)), ) .await?; - // Load the coinbase puzzle. - let coinbase_puzzle = CoinbasePuzzle::::load()?; // Compute the maximum number of puzzle instances. let max_puzzle_instances = num_cpus::get().saturating_sub(2).clamp(1, 6); // Initialize the node. @@ -124,8 +124,8 @@ impl> Prover { router, sync: Arc::new(sync), genesis, - coinbase_puzzle, - latest_epoch_challenge: Default::default(), + puzzle: VM::::new_puzzle()?, + latest_epoch_hash: Default::default(), latest_block_header: Default::default(), puzzle_instances: Default::default(), max_puzzle_instances: u8::try_from(max_puzzle_instances)?, @@ -135,8 +135,8 @@ impl> Prover { }; // Initialize the routing. node.initialize_routing().await; - // Initialize the coinbase puzzle. - node.initialize_coinbase_puzzle().await; + // Initialize the puzzle. + node.initialize_puzzle().await; // Initialize the notification message loop. node.handles.lock().push(crate::start_notification_message_loop()); // Pass the node to the signal handler. @@ -152,12 +152,12 @@ impl> NodeInterface for Prover { async fn shut_down(&self) { info!("Shutting down..."); - // Shut down the coinbase puzzle. - trace!("Shutting down the coinbase puzzle..."); + // Shut down the puzzle. + debug!("Shutting down the puzzle..."); self.shutdown.store(true, Ordering::Relaxed); // Abort the tasks. - trace!("Shutting down the prover..."); + debug!("Shutting down the prover..."); self.handles.lock().iter().for_each(|handle| handle.abort()); // Shut down the router. @@ -168,35 +168,35 @@ impl> NodeInterface for Prover { } impl> Prover { - /// Initialize a new instance of the coinbase puzzle. - async fn initialize_coinbase_puzzle(&self) { + /// Initialize a new instance of the puzzle. + async fn initialize_puzzle(&self) { for _ in 0..self.max_puzzle_instances { let prover = self.clone(); self.handles.lock().push(tokio::spawn(async move { - prover.coinbase_puzzle_loop().await; + prover.puzzle_loop().await; })); } } - /// Executes an instance of the coinbase puzzle. - async fn coinbase_puzzle_loop(&self) { + /// Executes an instance of the puzzle. + async fn puzzle_loop(&self) { loop { // If the node is not connected to any peers, then skip this iteration. if self.router.number_of_connected_peers() == 0 { - trace!("Skipping an iteration of the coinbase puzzle (no connected peers)"); + debug!("Skipping an iteration of the puzzle (no connected peers)"); tokio::time::sleep(Duration::from_secs(N::ANCHOR_TIME as u64)).await; continue; } - // If the number of instances of the coinbase puzzle exceeds the maximum, then skip this iteration. + // If the number of instances of the puzzle exceeds the maximum, then skip this iteration. if self.num_puzzle_instances() > self.max_puzzle_instances { // Sleep for a brief period of time. tokio::time::sleep(Duration::from_millis(500)).await; continue; } - // Read the latest epoch challenge. - let latest_epoch_challenge = self.latest_epoch_challenge.read().clone(); + // Read the latest epoch hash. + let latest_epoch_hash = *self.latest_epoch_hash.read(); // Read the latest state. let latest_state = self .latest_block_header @@ -204,20 +204,20 @@ impl> Prover { .as_ref() .map(|header| (header.coinbase_target(), header.proof_target())); - // If the latest epoch challenge and latest state exists, then proceed to generate a prover solution. - if let (Some(challenge), Some((coinbase_target, proof_target))) = (latest_epoch_challenge, latest_state) { - // Execute the coinbase puzzle. + // If the latest epoch hash and latest state exists, then proceed to generate a solution. + if let (Some(epoch_hash), Some((coinbase_target, proof_target))) = (latest_epoch_hash, latest_state) { + // Execute the puzzle. let prover = self.clone(); let result = tokio::task::spawn_blocking(move || { - prover.coinbase_puzzle_iteration(&challenge, coinbase_target, proof_target, &mut OsRng) + prover.puzzle_iteration(epoch_hash, coinbase_target, proof_target, &mut OsRng) }) .await; // If the prover found a solution, then broadcast it. if let Ok(Some((solution_target, solution))) = result { - info!("Found a Solution '{}' (Proof Target {solution_target})", solution.commitment()); - // Broadcast the prover solution. - self.broadcast_prover_solution(solution); + info!("Found a Solution '{}' (Proof Target {solution_target})", solution.id()); + // Broadcast the solution. + self.broadcast_solution(solution); } } else { // Otherwise, sleep for a brief period of time, to await for puzzle state. @@ -226,38 +226,34 @@ impl> Prover { // If the Ctrl-C handler registered the signal, stop the prover. if self.shutdown.load(Ordering::Relaxed) { - trace!("Shutting down the coinbase puzzle..."); + debug!("Shutting down the puzzle..."); break; } } } - /// Performs one iteration of the coinbase puzzle. - fn coinbase_puzzle_iteration( + /// Performs one iteration of the puzzle. + fn puzzle_iteration( &self, - epoch_challenge: &EpochChallenge, + epoch_hash: N::BlockHash, coinbase_target: u64, proof_target: u64, rng: &mut R, - ) -> Option<(u64, ProverSolution)> { + ) -> Option<(u64, Solution)> { // Increment the puzzle instances. self.increment_puzzle_instances(); - trace!( - "Proving 'CoinbasePuzzle' {}", - format!( - "(Epoch {}, Coinbase Target {coinbase_target}, Proof Target {proof_target})", - epoch_challenge.epoch_number(), - ) - .dimmed() + debug!( + "Proving 'Puzzle' for Epoch '{}' {}", + fmt_id(epoch_hash), + format!("(Coinbase Target {coinbase_target}, Proof Target {proof_target})").dimmed() ); - // Compute the prover solution. - let result = self - .coinbase_puzzle - .prove(epoch_challenge, self.address(), rng.gen(), Some(proof_target)) - .ok() - .and_then(|solution| solution.to_target().ok().map(|solution_target| (solution_target, solution))); + // Compute the solution. + let result = + self.puzzle.prove(epoch_hash, self.address(), rng.gen(), Some(proof_target)).ok().and_then(|solution| { + self.puzzle.get_proof_target(&solution).ok().map(|solution_target| (solution_target, solution)) + }); // Decrement the puzzle instances. self.decrement_puzzle_instances(); @@ -265,12 +261,12 @@ impl> Prover { result } - /// Broadcasts the prover solution to the network. - fn broadcast_prover_solution(&self, prover_solution: ProverSolution) { + /// Broadcasts the solution to the network. + fn broadcast_solution(&self, solution: Solution) { // Prepare the unconfirmed solution message. let message = Message::UnconfirmedSolution(UnconfirmedSolution { - solution_id: prover_solution.commitment(), - solution: Data::Object(prover_solution), + solution_id: solution.id(), + solution: Data::Object(solution), }); // Propagate the "UnconfirmedSolution". self.propagate(message, &[]); diff --git a/node/src/prover/router.rs b/node/src/prover/router.rs index f12a876166..a5e1489947 100644 --- a/node/src/prover/router.rs +++ b/node/src/prover/router.rs @@ -117,13 +117,13 @@ impl> Reading for Prover { impl> Routing for Prover {} impl> Heartbeat for Prover { - /// This function updates the coinbase puzzle if network has updated. + /// This function updates the puzzle if network has updated. fn handle_puzzle_request(&self) { // Find the sync peers. if let Some((sync_peers, _)) = self.sync.find_sync_peers() { // Choose the peer with the highest block height. if let Some((peer_ip, _)) = sync_peers.into_iter().max_by_key(|(_, height)| *height) { - // Request the coinbase puzzle from the peer. + // Request the puzzle from the peer. Outbound::send(self, peer_ip, Message::PuzzleRequest(PuzzleRequest)); } } @@ -192,25 +192,23 @@ impl> Inbound for Prover { false } - /// Saves the latest epoch challenge and latest block header in the node. - fn puzzle_response(&self, peer_ip: SocketAddr, epoch_challenge: EpochChallenge, header: Header) -> bool { - // Retrieve the epoch number. - let epoch_number = epoch_challenge.epoch_number(); + /// Saves the latest epoch hash and latest block header in the node. + fn puzzle_response(&self, peer_ip: SocketAddr, epoch_hash: N::BlockHash, header: Header) -> bool { // Retrieve the block height. let block_height = header.height(); info!( - "Coinbase Puzzle (Epoch {epoch_number}, Block {block_height}, Coinbase Target {}, Proof Target {})", + "Puzzle (Block {block_height}, Coinbase Target {}, Proof Target {})", header.coinbase_target(), header.proof_target() ); - // Save the latest epoch challenge in the node. - self.latest_epoch_challenge.write().replace(Arc::new(epoch_challenge)); + // Save the latest epoch hash in the node. + self.latest_epoch_hash.write().replace(epoch_hash); // Save the latest block header in the node. self.latest_block_header.write().replace(header); - trace!("Received 'PuzzleResponse' from '{peer_ip}' (Epoch {epoch_number}, Block {block_height})"); + trace!("Received 'PuzzleResponse' from '{peer_ip}' (Block {block_height})"); true } @@ -219,32 +217,30 @@ impl> Inbound for Prover { &self, peer_ip: SocketAddr, serialized: UnconfirmedSolution, - solution: ProverSolution, + solution: Solution, ) -> bool { - // Retrieve the latest epoch challenge. - let epoch_challenge = self.latest_epoch_challenge.read().clone(); + // Retrieve the latest epoch hash. + let epoch_hash = *self.latest_epoch_hash.read(); // Retrieve the latest proof target. let proof_target = self.latest_block_header.read().as_ref().map(|header| header.proof_target()); - if let (Some(epoch_challenge), Some(proof_target)) = (epoch_challenge, proof_target) { - // Ensure that the prover solution is valid for the given epoch. - let coinbase_puzzle = self.coinbase_puzzle.clone(); - let is_valid = tokio::task::spawn_blocking(move || { - solution.verify(coinbase_puzzle.coinbase_verifying_key(), &epoch_challenge, proof_target) - }) - .await; + if let (Some(epoch_hash), Some(proof_target)) = (epoch_hash, proof_target) { + // Ensure that the solution is valid for the given epoch. + let puzzle = self.puzzle.clone(); + let is_valid = + tokio::task::spawn_blocking(move || puzzle.check_solution(&solution, epoch_hash, proof_target)).await; match is_valid { // If the solution is valid, propagate the `UnconfirmedSolution`. - Ok(Ok(true)) => { + Ok(Ok(())) => { let message = Message::UnconfirmedSolution(serialized); // Propagate the "UnconfirmedSolution". self.propagate(message, &[peer_ip]); } - Ok(Ok(false)) | Ok(Err(_)) => { - trace!("Invalid prover solution '{}' for the proof target.", solution.commitment()) + Ok(Err(_)) => { + trace!("Invalid solution '{}' for the proof target.", solution.id()) } - Err(error) => warn!("Failed to verify the prover solution: {error}"), + Err(error) => warn!("Failed to verify the solution - {error}"), } } true diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 643254f2f9..6e4046c001 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -34,7 +34,7 @@ use snarkos_node_tcp::{ }; use snarkvm::prelude::{ block::{Block, Header}, - coinbase::ProverSolution, + puzzle::Solution, store::ConsensusStorage, Ledger, Network, diff --git a/node/src/validator/router.rs b/node/src/validator/router.rs index 3a01e6046e..fcbc057215 100644 --- a/node/src/validator/router.rs +++ b/node/src/validator/router.rs @@ -27,7 +27,7 @@ use snarkos_node_router::messages::{ use snarkos_node_tcp::{Connection, ConnectionSide, Tcp}; use snarkvm::{ ledger::narwhal::Data, - prelude::{block::Transaction, coinbase::EpochChallenge, error, Network}, + prelude::{block::Transaction, error, Network}, }; use std::{io, net::SocketAddr, time::Duration}; @@ -209,11 +209,11 @@ impl> Inbound for Validator { true } - /// Retrieves the latest epoch challenge and latest block header, and returns the puzzle response to the peer. + /// Retrieves the latest epoch hash and latest block header, and returns the puzzle response to the peer. fn puzzle_request(&self, peer_ip: SocketAddr) -> bool { - // Retrieve the latest epoch challenge. - let epoch_challenge = match self.ledger.latest_epoch_challenge() { - Ok(epoch_challenge) => epoch_challenge, + // Retrieve the latest epoch hash. + let epoch_hash = match self.ledger.latest_epoch_hash() { + Ok(epoch_hash) => epoch_hash, Err(error) => { error!("Failed to prepare a puzzle request for '{peer_ip}': {error}"); return false; @@ -222,12 +222,12 @@ impl> Inbound for Validator { // Retrieve the latest block header. let block_header = Data::Object(self.ledger.latest_header()); // Send the `PuzzleResponse` message to the peer. - Outbound::send(self, peer_ip, Message::PuzzleResponse(PuzzleResponse { epoch_challenge, block_header })); + Outbound::send(self, peer_ip, Message::PuzzleResponse(PuzzleResponse { epoch_hash, block_header })); true } /// Disconnects on receipt of a `PuzzleResponse` message. - fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_challenge: EpochChallenge, _header: Header) -> bool { + fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_hash: N::BlockHash, _header: Header) -> bool { debug!("Disconnecting '{peer_ip}' for the following reason - {:?}", DisconnectReason::ProtocolViolation); false } @@ -237,7 +237,7 @@ impl> Inbound for Validator { &self, peer_ip: SocketAddr, serialized: UnconfirmedSolution, - solution: ProverSolution, + solution: Solution, ) -> bool { // Add the unconfirmed solution to the memory pool. if let Err(error) = self.consensus.add_unconfirmed_solution(solution).await {