diff --git a/Cargo.lock b/Cargo.lock index 4d453a27..1fbfdf89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,6 +36,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "alto-chain" version = "0.0.16" @@ -46,6 +52,7 @@ dependencies = [ "clap", "commonware-broadcast", "commonware-codec", + "commonware-coding", "commonware-consensus", "commonware-cryptography", "commonware-deployer", @@ -59,7 +66,7 @@ dependencies = [ "futures", "governor", "prometheus-client", - "rand", + "rand 0.8.5", "serde", "serde_yaml", "thiserror 2.0.12", @@ -79,7 +86,7 @@ dependencies = [ "commonware-cryptography", "commonware-utils", "futures", - "rand", + "rand 0.8.5", "reqwest", "thiserror 2.0.12", "tokio", @@ -99,7 +106,7 @@ dependencies = [ "commonware-cryptography", "commonware-utils", "futures", - "rand", + "rand 0.8.5", "thiserror 2.0.12", "tokio", "tracing", @@ -112,11 +119,12 @@ version = "0.0.16" dependencies = [ "bytes", "commonware-codec", + "commonware-coding", "commonware-consensus", "commonware-cryptography", "commonware-utils", "getrandom 0.2.15", - "rand", + "rand 0.8.5", "serde", "serde-wasm-bindgen", "thiserror 2.0.12", @@ -181,9 +189,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "arrayref" @@ -219,7 +227,7 @@ checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -522,8 +530,7 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "commonware-broadcast" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98d0d0909a8323c69cc0f5090cac4b2eb546f4cc29a60dc0dcfe238e75f79c19" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ "bytes", "commonware-codec", @@ -541,24 +548,42 @@ dependencies = [ [[package]] name = "commonware-codec" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d473c9be55b1143abebd3fa6a748fe9d35151df4614ea7f68b314e504559af08" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ "bytes", "paste", "thiserror 2.0.12", ] +[[package]] +name = "commonware-coding" +version = "0.0.63" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" +dependencies = [ + "bytes", + "commonware-codec", + "commonware-cryptography", + "commonware-storage", + "commonware-utils", + "futures", + "num-rational", + "rand 0.8.5", + "rand_core 0.6.4", + "rayon", + "reed-solomon-simd", + "thiserror 2.0.12", +] + [[package]] name = "commonware-consensus" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b3b1dd7e0596b23a50ef69a290d0ed4e187a3f16a6aa6f317af188cd8b2bb5" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ "bytes", "cfg-if", "commonware-broadcast", "commonware-codec", + "commonware-coding", "commonware-cryptography", "commonware-macros", "commonware-p2p", @@ -568,9 +593,12 @@ dependencies = [ "commonware-utils", "futures", "governor", + "pin-project", "prometheus-client", - "rand", + "rand 0.8.5", + "rand_core 0.6.4", "rand_distr", + "rayon", "thiserror 2.0.12", "tracing", ] @@ -578,8 +606,7 @@ dependencies = [ [[package]] name = "commonware-cryptography" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7157f6e4a84b7a70108f15bf402f539b48d52adf727b9938fe59f752efc5b3e" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ "blake3", "blst", @@ -591,9 +618,9 @@ dependencies = [ "ed25519-consensus", "getrandom 0.2.15", "p256", - "rand", - "rand_chacha", - "rand_core", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_core 0.6.4", "rayon", "sha2 0.10.8", "thiserror 2.0.12", @@ -604,8 +631,7 @@ dependencies = [ [[package]] name = "commonware-deployer" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b21c9dcdd56dcba27b0533c324a73791263e43bd2325cac3da0d20493d0e07b9" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ "cfg-if", "serde", @@ -615,14 +641,13 @@ dependencies = [ [[package]] name = "commonware-macros" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff368ef4db2d10686c1a89b7f4a3f1e7dddd9641a96cac42b72bf71a10360291" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ "futures", "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn", "tracing", "tracing-subscriber", ] @@ -630,8 +655,7 @@ dependencies = [ [[package]] name = "commonware-p2p" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "657c7a971cf269411914e2a32a77815d5990ae111f2804d6b15f5952f75270c6" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ "bytes", "commonware-codec", @@ -648,7 +672,7 @@ dependencies = [ "num-rational", "num-traits", "prometheus-client", - "rand", + "rand 0.8.5", "rand_distr", "thiserror 2.0.12", "tracing", @@ -657,8 +681,7 @@ dependencies = [ [[package]] name = "commonware-resolver" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e72ea84c5b43939cde251fba17627065d45cd9cedcb67f673c58291c5454e8f" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ "bimap", "bytes", @@ -672,7 +695,7 @@ dependencies = [ "futures", "governor", "prometheus-client", - "rand", + "rand 0.8.5", "thiserror 2.0.12", "tracing", ] @@ -680,8 +703,7 @@ dependencies = [ [[package]] name = "commonware-runtime" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de4d08e6e11088ed5b42e5ad93b18ffd745cbcc04c6ef7f723f5d237e146abc8" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ "async-lock", "axum", @@ -698,7 +720,7 @@ dependencies = [ "opentelemetry-otlp", "opentelemetry_sdk", "prometheus-client", - "rand", + "rand 0.8.5", "rayon", "sha2 0.10.8", "sysinfo", @@ -712,9 +734,9 @@ dependencies = [ [[package]] name = "commonware-storage" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3116985d7a761aa7bf26d5226d51b8de0eaa6458277963f3c5d903f4078d504" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ + "anyhow", "bytes", "cfg-if", "commonware-codec", @@ -735,8 +757,7 @@ dependencies = [ [[package]] name = "commonware-stream" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260076055c2a5eb1b734641603a9bc6bcd439bd6525055480c7d149e2a8dad70" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ "bytes", "chacha20poly1305", @@ -746,8 +767,8 @@ dependencies = [ "commonware-runtime", "commonware-utils", "futures", - "rand", - "rand_core", + "rand 0.8.5", + "rand_core 0.6.4", "thiserror 2.0.12", "x25519-dalek", "zeroize", @@ -756,8 +777,7 @@ dependencies = [ [[package]] name = "commonware-utils" version = "0.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "209c03e7057e9d4d5f0bade24685e2bc8845471b89e4ab54684f1af8c287ad3b" +source = "git+https://github.com/commonwarexyz/monorepo.git?branch=cl%2Fconsensus-coding-mk2#a15f4a845b8979c83fd55129914d747ea5e146c0" dependencies = [ "bytes", "cfg-if", @@ -768,7 +788,8 @@ dependencies = [ "num-integer", "num-rational", "num-traits", - "rand", + "pin-project", + "rand 0.8.5", "thiserror 2.0.12", ] @@ -820,35 +841,31 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.4.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" dependencies = [ "cfg-if", ] [[package]] name = "criterion" -version = "0.5.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +checksum = "e1c047a62b0cc3e145fa84415a3191f628e980b194c2755aa12300a4e6cbd928" dependencies = [ "anes", "cast", "ciborium", "clap", "criterion-plot", - "futures", - "is-terminal", - "itertools 0.10.5", + "itertools 0.13.0", "num-traits", - "once_cell", "oorandom", "plotters", "rayon", "regex", "serde", - "serde_derive", "serde_json", "tinytemplate", "walkdir", @@ -856,12 +873,12 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +checksum = "9b1bcc0dc7dfae599d84ad0b1a55f80cde8af3725da8313b528da95ef783e338" dependencies = [ "cast", - "itertools 0.10.5", + "itertools 0.13.0", ] [[package]] @@ -902,7 +919,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -914,7 +931,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "typenum", ] @@ -941,7 +958,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -952,18 +969,19 @@ checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" dependencies = [ "byteorder", "digest 0.9.0", - "rand_core", + "rand_core 0.6.4", "subtle-ng", "zeroize", ] [[package]] name = "dashmap" -version = "5.5.3" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" dependencies = [ "cfg-if", + "crossbeam-utils", "hashbrown 0.14.5", "lock_api", "once_cell", @@ -1009,7 +1027,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -1040,7 +1058,7 @@ checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" dependencies = [ "curve25519-dalek-ng", "hex", - "rand_core", + "rand_core 0.6.4", "sha2 0.9.9", "thiserror 1.0.69", "zeroize", @@ -1065,7 +1083,7 @@ dependencies = [ "generic-array", "group", "pkcs8", - "rand_core", + "rand_core 0.6.4", "sec1", "subtle", "zeroize", @@ -1129,7 +1147,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -1139,12 +1157,24 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "foreign-types" version = "0.3.2" @@ -1225,7 +1255,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -1295,8 +1325,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi 0.13.3+wasi-0.2.2", + "wasm-bindgen", "windows-targets", ] @@ -1314,22 +1346,25 @@ checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "governor" -version = "0.6.3" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a7f542ee6b35af73b06abc0dad1c1bae89964e4e253bc4b587b91c9637867b" +checksum = "6e23d5986fd4364c2fb7498523540618b4b8d92eec6c36a02e565f66748e2f79" dependencies = [ "cfg-if", "dashmap", - "futures", + "futures-sink", "futures-timer", - "no-std-compat", + "futures-util", + "getrandom 0.3.1", + "hashbrown 0.16.0", "nonzero_ext", "parking_lot", "portable-atomic", "quanta", - "rand", + "rand 0.9.2", "smallvec", "spinning_top", + "web-time", ] [[package]] @@ -1339,7 +1374,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -1385,16 +1420,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] -name = "hermit-abi" -version = "0.3.9" +name = "hashbrown" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] [[package]] name = "hermit-abi" -version = "0.5.0" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -1656,7 +1696,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -1705,17 +1745,6 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" -[[package]] -name = "is-terminal" -version = "0.4.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" -dependencies = [ - "hermit-abi 0.5.0", - "libc", - "windows-sys 0.59.0", -] - [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -1724,9 +1753,9 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" -version = "0.10.5" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] @@ -1773,9 +1802,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.172" +version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libm" @@ -1875,12 +1904,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "no-std-compat" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" - [[package]] name = "nonzero_ext" version = "0.3.0" @@ -1952,10 +1975,29 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", ] +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags", +] + +[[package]] +name = "objc2-io-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" +dependencies = [ + "libc", + "objc2-core-foundation", +] + [[package]] name = "object" version = "0.36.7" @@ -1967,9 +2009,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.3" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "oorandom" @@ -2006,7 +2048,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -2029,9 +2071,9 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.28.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "236e667b670a5cdf90c258f5a55794ec5ac5027e960c224bff8367a59e1e6426" +checksum = "b84bcd6ae87133e903af7ef497404dda70c60d0ea14895fc8a5e6722754fc2a0" dependencies = [ "futures-core", "futures-sink", @@ -2043,26 +2085,23 @@ dependencies = [ [[package]] name = "opentelemetry-http" -version = "0.28.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8863faf2910030d139fb48715ad5ff2f35029fc5f244f6d5f689ddcf4d26253" +checksum = "d7a6d09a73194e6b66df7c8f1b680f156d916a1a942abf2de06823dd02b7855d" dependencies = [ "async-trait", "bytes", "http 1.2.0", "opentelemetry", "reqwest", - "tracing", ] [[package]] name = "opentelemetry-otlp" -version = "0.28.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bef114c6d41bea83d6dc60eb41720eedd0261a67af57b66dd2b84ac46c01d91" +checksum = "7a2366db2dca4d2ad033cad11e6ee42844fd727007af5ad04a1730f4cb8163bf" dependencies = [ - "async-trait", - "futures-core", "http 1.2.0", "opentelemetry", "opentelemetry-http", @@ -2076,35 +2115,32 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.28.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f8870d3024727e99212eb3bb1762ec16e255e3e6f58eeb3dc8db1aa226746d" +checksum = "a7175df06de5eaee9909d4805a3d07e28bb752c34cab57fa9cff549da596b30f" dependencies = [ "opentelemetry", "opentelemetry_sdk", "prost", "tonic", + "tonic-prost", ] [[package]] name = "opentelemetry_sdk" -version = "0.28.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84dfad6042089c7fc1f6118b7040dc2eb4ab520abbf410b79dc481032af39570" +checksum = "e14ae4f5991976fd48df6d843de219ca6d31b01daaab2dad5af2badeded372bd" dependencies = [ - "async-trait", "futures-channel", "futures-executor", "futures-util", - "glob", "opentelemetry", "percent-encoding", - "rand", - "serde_json", + "rand 0.9.2", "thiserror 2.0.12", "tokio", "tokio-stream", - "tracing", ] [[package]] @@ -2183,7 +2219,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -2297,9 +2333,9 @@ dependencies = [ [[package]] name = "prometheus-client" -version = "0.22.3" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504ee9ff529add891127c4827eb481bd69dc0ebc72e9a682e187db4caa60c3ca" +checksum = "e4500adecd7af8e0e9f4dbce15cfee07ce913fbf6ad605cc468b83f2d531ee94" dependencies = [ "dtoa", "itoa", @@ -2309,20 +2345,20 @@ dependencies = [ [[package]] name = "prometheus-client-derive-encode" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" +checksum = "9adf1691c04c0a5ff46ff8f262b58beb07b0dbb61f96f9f54f6cbd82106ed87f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] name = "prost" -version = "0.13.5" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" +checksum = "7231bd9b3d3d33c86b58adbac74b5ec0ad9f496b19d22801d773636feaa95f3d" dependencies = [ "bytes", "prost-derive", @@ -2330,15 +2366,15 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.5" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" +checksum = "9120690fafc389a67ba3803df527d0ec9cbbc9cc45e4cc20b332996dfb672425" dependencies = [ "anyhow", "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -2372,8 +2408,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", ] [[package]] @@ -2383,7 +2429,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", ] [[package]] @@ -2395,6 +2451,15 @@ dependencies = [ "getrandom 0.2.15", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.1", +] + [[package]] name = "rand_distr" version = "0.4.3" @@ -2402,7 +2467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" dependencies = [ "num-traits", - "rand", + "rand 0.8.5", ] [[package]] @@ -2434,6 +2499,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "readme-rustdocifier" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08ad765b21a08b1a8e5cdce052719188a23772bcbefb3c439f0baaf62c56ceac" + [[package]] name = "redox_syscall" version = "0.5.10" @@ -2443,6 +2514,18 @@ dependencies = [ "bitflags", ] +[[package]] +name = "reed-solomon-simd" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cffef0520d30fbd4151fb20e262947ae47fb0ab276a744a19b6398438105a072" +dependencies = [ + "cpufeatures", + "fixedbitset", + "once_cell", + "readme-rustdocifier", +] + [[package]] name = "regex" version = "1.11.1" @@ -2730,7 +2813,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -2846,7 +2929,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest 0.10.7", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -2917,17 +3000,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.99" @@ -2956,20 +3028,20 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] name = "sysinfo" -version = "0.33.1" +version = "0.37.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fc858248ea01b66f19d8e8a6d55f41deaf91e9d495246fd01368d99935c6c01" +checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f" dependencies = [ - "core-foundation-sys", "libc", "memchr", "ntapi", - "rayon", + "objc2-core-foundation", + "objc2-io-kit", "windows", ] @@ -3034,7 +3106,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -3045,7 +3117,7 @@ checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -3113,7 +3185,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -3206,9 +3278,9 @@ dependencies = [ [[package]] name = "tonic" -version = "0.12.3" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" +checksum = "eb7613188ce9f7df5bfe185db26c5814347d110db17920415cf2fbcad85e7203" dependencies = [ "async-trait", "base64 0.22.1", @@ -3218,13 +3290,24 @@ dependencies = [ "http-body-util", "percent-encoding", "pin-project", - "prost", + "sync_wrapper", "tokio-stream", "tower-layer", "tower-service", "tracing", ] +[[package]] +name = "tonic-prost" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66bd50ad6ce1252d87ef024b3d64fe4c3cf54a86fb9ef4c631fdd0ded7aeaa67" +dependencies = [ + "bytes", + "prost", + "tonic", +] + [[package]] name = "tower" version = "0.5.2" @@ -3273,7 +3356,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -3299,15 +3382,16 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.29.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f2d2569dce9f3dfbbddee5906941e953bfcdf736a62da3377f5751650cc36" +checksum = "1e6e5658463dd88089aba75c7791e1d3120633b1bfde22478b28f625a9bb1b8e" dependencies = [ "js-sys", - "once_cell", "opentelemetry", "opentelemetry_sdk", + "rustversion", "smallvec", + "thiserror 2.0.12", "tracing", "tracing-core", "tracing-log", @@ -3365,7 +3449,7 @@ dependencies = [ "httparse", "log", "native-tls", - "rand", + "rand 0.8.5", "sha-1", "thiserror 1.0.69", "url", @@ -3524,7 +3608,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.99", + "syn", "wasm-bindgen-shared", ] @@ -3559,7 +3643,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3626,46 +3710,86 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.57.0" +version = "0.61.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" +dependencies = [ + "windows-collections", + "windows-core", + "windows-future", + "windows-link", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ "windows-core", - "windows-targets", ] [[package]] name = "windows-core" -version = "0.57.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ "windows-implement", "windows-interface", - "windows-result 0.1.2", - "windows-targets", + "windows-link", + "windows-result 0.3.4", + "windows-strings 0.4.2", +] + +[[package]] +name = "windows-future" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" +dependencies = [ + "windows-core", + "windows-link", + "windows-threading", ] [[package]] name = "windows-implement" -version = "0.57.0" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] name = "windows-interface" -version = "0.57.0" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-numerics" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" +dependencies = [ + "windows-core", + "windows-link", ] [[package]] @@ -3675,26 +3799,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ "windows-result 0.2.0", - "windows-strings", + "windows-strings 0.1.0", "windows-targets", ] [[package]] name = "windows-result" -version = "0.1.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" dependencies = [ "windows-targets", ] [[package]] name = "windows-result" -version = "0.2.0" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" dependencies = [ - "windows-targets", + "windows-link", ] [[package]] @@ -3707,6 +3831,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-sys" version = "0.52.0" @@ -3741,6 +3874,15 @@ dependencies = [ "windows_x86_64_msvc", ] +[[package]] +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -3826,7 +3968,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ "curve25519-dalek", - "rand_core", + "rand_core 0.6.4", "serde", "zeroize", ] @@ -3851,7 +3993,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", "synstructure", ] @@ -3873,7 +4015,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -3893,7 +4035,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", "synstructure", ] @@ -3914,7 +4056,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] @@ -3936,7 +4078,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.99", + "syn", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 50bf2c2c..bcfc6be8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,18 +15,19 @@ license = "MIT OR Apache-2.0" [workspace.dependencies] alto-client = { version = "0.0.16", path = "client" } alto-types = { version = "0.0.16", path = "types" } -commonware-broadcast ="0.0.63" -commonware-codec ="0.0.63" -commonware-consensus ="0.0.63" -commonware-cryptography ="0.0.63" -commonware-deployer = { version = "0.0.63", default-features = false } -commonware-macros ="0.0.63" -commonware-p2p ="0.0.63" -commonware-resolver ="0.0.63" -commonware-runtime ="0.0.63" -commonware-storage ="0.0.63" -commonware-stream ="0.0.63" -commonware-utils ="0.0.63" +commonware-broadcast = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } +commonware-codec = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } +commonware-consensus = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } +commonware-cryptography = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } +commonware-coding = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } +commonware-deployer = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2", default-features = false } +commonware-macros = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } +commonware-p2p = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } +commonware-resolver = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } +commonware-runtime = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } +commonware-storage = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } +commonware-stream = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } +commonware-utils = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" } thiserror = "2.0.12" bytes = "1.7.1" rand = "0.8.5" @@ -36,8 +37,8 @@ futures = "0.3.31" futures-util = "0.3.31" tracing = "0.1.41" tracing-subscriber = "0.3.19" -governor = "0.6.3" -prometheus-client = "0.22.3" +governor = "0.10.2" +prometheus-client = "0.24.0" clap = "4.5.18" [profile.bench] @@ -58,3 +59,7 @@ overflow-checks = true # Although overflow checks are enabled by default in "test", we explicitly # enable them here for clarity. overflow-checks = true + +[profile.profiling] +inherits = "release" +debug = true diff --git a/chain/Cargo.toml b/chain/Cargo.toml index acb63454..d4fe11c8 100644 --- a/chain/Cargo.toml +++ b/chain/Cargo.toml @@ -15,6 +15,7 @@ alto-types = { workspace = true } alto-client = { workspace = true } commonware-broadcast = { workspace = true } commonware-codec = { workspace = true } +commonware-coding = { workspace = true } commonware-consensus = { workspace = true } commonware-cryptography = { workspace = true } commonware-deployer = { workspace = true } diff --git a/chain/src/application.rs b/chain/src/application.rs new file mode 100644 index 00000000..1449bc2b --- /dev/null +++ b/chain/src/application.rs @@ -0,0 +1,86 @@ +use alto_types::{Block, PublicKey, Scheme}; +use commonware_consensus::{ + marshal::{ + ancestry::{AncestorStream, AncestryProvider}, + coding::types::CodingCommitment, + Update, + }, + simplex::types::Context, + Application, Block as _, Reporter, +}; +use commonware_cryptography::{Digestible, Hasher, Sha256}; +use commonware_runtime::{Clock, Metrics, Spawner}; +use commonware_utils::{SystemTimeExt, Acknowledgement}; +use futures::StreamExt; +use rand::Rng; +use tracing::info; + +/// Genesis message to use during initialization. +const GENESIS: &[u8] = b"commonware is neat"; + +#[derive(Clone)] +pub struct AltoApp { + genesis: Block, +} + +impl AltoApp { + pub fn new() -> Self { + let genesis = Block::new(Sha256::hash(GENESIS), 0, 0, Vec::new()); + Self { genesis } + } +} + +impl Default for AltoApp { + fn default() -> Self { + Self::new() + } +} + +impl Application for AltoApp +where + E: Rng + Spawner + Metrics + Clock, +{ + type SigningScheme = Scheme; + type Context = Context; + type Block = Block; + + async fn genesis(&mut self) -> Self::Block { + self.genesis.clone() + } + + async fn propose>( + &mut self, + (mut runtime_context, _context): (E, Self::Context), + mut ancestry: AncestorStream, + ) -> Option { + let parent = ancestry.next().await?; + + // Create a new block + let mut current = runtime_context.current().epoch_millis(); + if current <= parent.timestamp { + current = parent.timestamp + 1; + } + + // Generate some random data. + let mut junk = vec![0u8; 4 * 1024 * 1024]; + runtime_context.fill_bytes(&mut junk); + + Some(Block::new( + parent.digest(), + parent.height + 1, + current, + junk, + )) + } +} + +impl Reporter for AltoApp { + type Activity = Update; + + async fn report(&mut self, activity: Self::Activity) { + if let Update::Block(block, ack_rx) = activity { + info!(height = block.height(), "finalized block"); + ack_rx.acknowledge(); + } + } +} diff --git a/chain/src/application/actor.rs b/chain/src/application/actor.rs deleted file mode 100644 index 53733c27..00000000 --- a/chain/src/application/actor.rs +++ /dev/null @@ -1,209 +0,0 @@ -use super::{ - ingress::{Mailbox, Message}, - Config, -}; -use crate::utils::OneshotClosedFut; -use alto_types::{Block, Scheme}; -use commonware_consensus::{marshal, types::Round}; -use commonware_cryptography::{Committable, Digestible, Hasher, Sha256}; -use commonware_macros::select; -use commonware_runtime::{spawn_cell, Clock, ContextCell, Handle, Metrics, Spawner}; -use commonware_utils::SystemTimeExt; -use futures::StreamExt; -use futures::{channel::mpsc, future::try_join}; -use futures::{future, future::Either}; -use rand::Rng; -use std::sync::{Arc, Mutex}; -use tracing::{debug, info, warn}; - -/// Genesis message to use during initialization. -const GENESIS: &[u8] = b"commonware is neat"; - -/// Milliseconds in the future to allow for block timestamps. -const SYNCHRONY_BOUND: u64 = 500; - -/// Application actor. -pub struct Actor { - context: ContextCell, - hasher: Sha256, - mailbox: mpsc::Receiver, -} - -impl Actor { - /// Create a new application actor. - pub fn new(context: R, config: Config) -> (Self, Mailbox) { - let (sender, mailbox) = mpsc::channel(config.mailbox_size); - ( - Self { - context: ContextCell::new(context), - hasher: Sha256::new(), - mailbox, - }, - Mailbox::new(sender), - ) - } - - pub fn start(mut self, marshal: marshal::Mailbox) -> Handle<()> { - spawn_cell!(self.context, self.run(marshal).await) - } - - /// Run the application actor. - async fn run(mut self, mut marshal: marshal::Mailbox) { - // Compute genesis digest - self.hasher.update(GENESIS); - let genesis_parent = self.hasher.finalize(); - let genesis = Block::new(genesis_parent, 0, 0); - let genesis_digest = genesis.digest(); - let built: Option<(Round, Block)> = None; - let built = Arc::new(Mutex::new(built)); - while let Some(message) = self.mailbox.next().await { - match message { - Message::Genesis { response } => { - // Use the digest of the genesis message as the initial - // payload. - let _ = response.send(genesis_digest); - } - Message::Propose { - round, - parent, - mut response, - } => { - // Get the parent block - let parent_request = if parent.1 == genesis_digest { - Either::Left(future::ready(Ok(genesis.clone()))) - } else { - Either::Right( - marshal - .subscribe(Some(Round::new(round.epoch(), parent.0)), parent.1) - .await, - ) - }; - - // Wait for the parent block to be available or the request to be cancelled in a separate task (to - // continue processing other messages) - self.context.with_label("propose").spawn({ - let built = built.clone(); - move |context| async move { - let response_closed = OneshotClosedFut::new(&mut response); - select! { - parent = parent_request => { - // Get the parent block - let parent = parent.unwrap(); - - // Create a new block - let mut current = context.current().epoch_millis(); - if current <= parent.timestamp { - current = parent.timestamp + 1; - } - let block = Block::new(parent.digest(), parent.height+1, current); - let digest = block.digest(); - { - let mut built = built.lock().unwrap(); - *built = Some((round, block)); - } - - // Send the digest to the consensus - let result = response.send(digest); - info!(?round, ?digest, success=result.is_ok(), "proposed new block"); - }, - _ = response_closed => { - // The response was cancelled - warn!(?round, "propose aborted"); - } - } - } - }); - } - Message::Broadcast { payload } => { - // Check if the last built is equal - let Some(built) = built.lock().unwrap().clone() else { - warn!(?payload, "missing block to broadcast"); - continue; - }; - - // Send the block to the syncer - debug!( - ?payload, - round = ?built.0, - height = built.1.height, - "broadcast requested" - ); - marshal.broadcast(built.1.clone()).await; - } - Message::Verify { - round, - parent, - payload, - mut response, - } => { - // Get the parent and current block - let parent_request = if parent.1 == genesis_digest { - Either::Left(future::ready(Ok(genesis.clone()))) - } else { - Either::Right( - marshal - .subscribe(Some(Round::new(round.epoch(), parent.0)), parent.1) - .await, - ) - }; - - // Wait for the blocks to be available or the request to be cancelled in a separate task (to - // continue processing other messages) - self.context.with_label("verify").spawn({ - let mut marshal = marshal.clone(); - move |context| async move { - let requester = - try_join(parent_request, marshal.subscribe(None, payload).await); - let response_closed = OneshotClosedFut::new(&mut response); - select! { - result = requester => { - // Unwrap the results - let (parent, block) = result.unwrap(); - - // Verify the block - if block.height != parent.height + 1 { - let _ = response.send(false); - return; - } - if block.parent != parent.digest() { - let _ = response.send(false); - return; - } - if block.timestamp <= parent.timestamp { - let _ = response.send(false); - return; - } - let current = context.current().epoch_millis(); - if block.timestamp > current + SYNCHRONY_BOUND { - let _ = response.send(false); - return; - } - - // Persist the verified block - marshal.verified(round, block).await; - - // Send the verification result to the consensus - let _ = response.send(true); - }, - _ = response_closed => { - // The response was cancelled - warn!(?round, "verify aborted"); - } - } - } - }); - } - Message::Finalized { block } => { - // In an application that maintains state, you would compute the state transition function here. - // - // After an unclean shutdown, it is possible that the application may be asked to process a block it has already seen (which it can simply ignore). - info!( - height = block.height, - digest = ?block.commitment(), - "processed finalized block" - ); - } - } - } - } -} diff --git a/chain/src/application/ingress.rs b/chain/src/application/ingress.rs deleted file mode 100644 index 1a0564da..00000000 --- a/chain/src/application/ingress.rs +++ /dev/null @@ -1,125 +0,0 @@ -use alto_types::{Block, PublicKey}; -use commonware_consensus::{ - marshal::Update, - simplex::types::Context, - types::{Epoch, Round, View}, - Automaton, Relay, Reporter, -}; -use commonware_cryptography::sha256::Digest; -use futures::{ - channel::{mpsc, oneshot}, - SinkExt, -}; - -/// Messages sent to the application. -pub enum Message { - Genesis { - response: oneshot::Sender, - }, - Propose { - round: Round, - parent: (View, Digest), - response: oneshot::Sender, - }, - Broadcast { - payload: Digest, - }, - Verify { - round: Round, - parent: (View, Digest), - payload: Digest, - response: oneshot::Sender, - }, - Finalized { - block: Block, - }, -} - -/// Mailbox for the application. -#[derive(Clone)] -pub struct Mailbox { - sender: mpsc::Sender, -} - -impl Mailbox { - pub(super) fn new(sender: mpsc::Sender) -> Self { - Self { sender } - } -} - -impl Automaton for Mailbox { - type Digest = Digest; - type Context = Context; - - async fn genesis(&mut self, _epoch: Epoch) -> Self::Digest { - let (response, receiver) = oneshot::channel(); - self.sender - .send(Message::Genesis { response }) - .await - .expect("Failed to send genesis"); - receiver.await.expect("Failed to receive genesis") - } - - async fn propose( - &mut self, - context: Context, - ) -> oneshot::Receiver { - // If we linked payloads to their parent, we would include - // the parent in the `Context` in the payload. - let (response, receiver) = oneshot::channel(); - self.sender - .send(Message::Propose { - round: context.round, - parent: context.parent, - response, - }) - .await - .expect("Failed to send propose"); - receiver - } - - async fn verify( - &mut self, - context: Context, - payload: Self::Digest, - ) -> oneshot::Receiver { - // If we linked payloads to their parent, we would verify - // the parent included in the payload matches the provided `Context`. - let (response, receiver) = oneshot::channel(); - self.sender - .send(Message::Verify { - round: context.round, - parent: context.parent, - payload, - response, - }) - .await - .expect("Failed to send verify"); - receiver - } -} - -impl Relay for Mailbox { - type Digest = Digest; - - async fn broadcast(&mut self, digest: Self::Digest) { - self.sender - .send(Message::Broadcast { payload: digest }) - .await - .expect("Failed to send broadcast"); - } -} - -impl Reporter for Mailbox { - type Activity = Update; - - async fn report(&mut self, update: Self::Activity) { - let Update::Block(block) = update else { - return; - }; - self.sender - .send(Message::Finalized { block }) - .await - .expect("Failed to send finalized"); - } -} diff --git a/chain/src/application/mod.rs b/chain/src/application/mod.rs deleted file mode 100644 index 1728c19f..00000000 --- a/chain/src/application/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -mod actor; -pub use actor::Actor; -mod ingress; -pub use ingress::Mailbox; - -/// Configuration for the application. -pub struct Config { - /// Number of messages from consensus to hold in our backlog - /// before blocking. - pub mailbox_size: usize, -} diff --git a/chain/src/bin/setup.rs b/chain/src/bin/setup.rs index 1b25594e..5ed15a3c 100644 --- a/chain/src/bin/setup.rs +++ b/chain/src/bin/setup.rs @@ -339,8 +339,9 @@ fn generate_local( println!("To start validators, run:"); for (name, peer_config_file, _) in &configurations { let path = format!("{output}/{peer_config_file}"); - let command = - format!("cargo run --bin {BINARY_NAME} -- --peers={peers_path} --config={path}"); + let command = format!( + "cargo run --release --bin {BINARY_NAME} -- --peers={peers_path} --config={path}" + ); println!("{name}: {command}"); } println!("To view metrics, run:"); diff --git a/chain/src/bin/validator.rs b/chain/src/bin/validator.rs index edf01efd..0a17559c 100644 --- a/chain/src/bin/validator.rs +++ b/chain/src/bin/validator.rs @@ -3,7 +3,7 @@ use alto_client::Client; use alto_types::{EPOCH, NAMESPACE}; use clap::{Arg, Command}; use commonware_codec::{Decode, DecodeExt}; -use commonware_consensus::marshal; +use commonware_consensus::marshal::{self, coding::ingress::handler::Handler}; use commonware_cryptography::{ bls12381::primitives::{group, poly, variant::MinSig}, ed25519::{PrivateKey, PublicKey}, @@ -38,9 +38,9 @@ const ACTIVITY_TIMEOUT: u64 = 256; const SKIP_TIMEOUT: u64 = 32; const FETCH_TIMEOUT: Duration = Duration::from_secs(2); const FETCH_CONCURRENT: usize = 4; -const MAX_MESSAGE_SIZE: usize = 1024 * 1024; +const MAX_MESSAGE_SIZE: usize = 20 * 1024 * 1024; const MAX_FETCH_COUNT: usize = 16; -const MAX_FETCH_SIZE: usize = 512 * 1024; +const MAX_FETCH_SIZE: usize = 20 * 1024 * 1024; const BLOCKS_FREEZER_TABLE_INITIAL_SIZE: u32 = 2u32.pow(21); // 100MB const FINALIZED_FREEZER_TABLE_INITIAL_SIZE: u32 = 2u32.pow(21); // 100MB @@ -261,13 +261,15 @@ fn main() { max_fetch_size: MAX_FETCH_SIZE, fetch_concurrent: FETCH_CONCURRENT, fetch_rate_per_peer: resolver_limit, + concurrency: std::thread::available_parallelism().unwrap().get(), indexer, }; let engine = engine::Engine::new(context.with_label("engine"), engine_cfg).await; let marshal_resolver_cfg = marshal::resolver::p2p::Config { public_key: public_key.clone(), - manager: oracle, + manager: oracle.clone(), + blocker: oracle, mailbox_size: config.mailbox_size, requester_config: requester::Config { me: Some(public_key), @@ -280,7 +282,7 @@ fn main() { priority_responses: false, }; let marshal_resolver = - marshal::resolver::p2p::init(&context, marshal_resolver_cfg, marshal); + marshal::resolver::p2p::init(&context, marshal_resolver_cfg, marshal, Handler::new); // Start engine let engine = engine.start(pending, recovered, resolver, broadcaster, marshal_resolver); diff --git a/chain/src/engine.rs b/chain/src/engine.rs index f15adf46..197206fa 100644 --- a/chain/src/engine.rs +++ b/chain/src/engine.rs @@ -1,15 +1,28 @@ -use crate::{application, indexer, indexer::Indexer, StaticSchemeProvider}; -use alto_types::{Activity, Block, Evaluation, Scheme, EPOCH, EPOCH_LENGTH, NAMESPACE}; +use crate::{ + application::AltoApp, + indexer::{self, Indexer}, + StaticSchemeProvider, +}; +use alto_types::{Activity, Block, Evaluation, PublicKey, Scheme, EPOCH, EPOCH_LENGTH, NAMESPACE}; use commonware_broadcast::buffered; +use commonware_coding::ReedSolomon; use commonware_consensus::{ - marshal::{self, ingress::handler}, + marshal::{ + self, + coding::{ + self, + ingress::handler, + shards, + types::{CodingCommitment, Shard}, + Marshaled, + }, + }, simplex::{self, Engine as Consensus}, Reporters, }; use commonware_cryptography::{ bls12381::primitives::{group, poly::Poly}, - ed25519::PublicKey, - sha256::Digest, + Sha256, }; use commonware_p2p::{Blocker, Receiver, Sender}; use commonware_resolver::Resolver; @@ -27,8 +40,15 @@ use std::{num::NonZero, time::Duration}; use tracing::{error, warn}; /// Reporter type for [simplex::Engine]. -type Reporter = - Reporters, Option>>; +type Reporter = Reporters< + Activity, + Reporters< + Activity, + coding::Mailbox>, + shards::Mailbox, PublicKey>, + >, + Option>, +>; /// To better support peers near tip during network instability, we multiply /// the consensus activity timeout by this factor. @@ -43,7 +63,7 @@ const REPLAY_BUFFER: NonZero = NZUsize!(8 * 1024 * 1024); // 8MB const WRITE_BUFFER: NonZero = NZUsize!(1024 * 1024); // 1MB const BUFFER_POOL_PAGE_SIZE: NonZero = NZUsize!(4_096); // 4KB const BUFFER_POOL_CAPACITY: NonZero = NZUsize!(8_192); // 32MB -const MAX_REPAIR: u64 = 20; +const MAX_REPAIR: NonZero = NZU64!(20); /// Configuration for the [Engine]. pub struct Config, I: Indexer> { @@ -57,6 +77,7 @@ pub struct Config, I: Indexer> { pub participants: Ordered, pub mailbox_size: usize, pub deque_size: usize, + pub concurrency: usize, pub leader_timeout: Duration, pub notarization_timeout: Duration, @@ -80,21 +101,22 @@ pub struct Engine< > { context: ContextCell, - application: application::Actor, - application_mailbox: application::Mailbox, - buffer: buffered::Engine, - buffer_mailbox: buffered::Mailbox, - marshal: marshal::Actor, - marshal_mailbox: marshal::Mailbox, + buffer: buffered::Engine, Sha256>>, + shards: shards::Engine, Sha256, Block, PublicKey>, + shard_mailbox: shards::Mailbox, PublicKey>, + marshal: coding::Actor, StaticSchemeProvider, Scheme>, + marshaled: + Marshaled, PublicKey, StaticSchemeProvider>, + #[allow(clippy::type_complexity)] consensus: Consensus< E, PublicKey, Scheme, B, - Digest, - application::Mailbox, - application::Mailbox, + CodingCommitment, + Marshaled, PublicKey, StaticSchemeProvider>, + Marshaled, PublicKey, StaticSchemeProvider>, Reporter, >, } @@ -107,14 +129,6 @@ impl< { /// Create a new [Engine]. pub async fn new(context: E, cfg: Config) -> Self { - // Create the application - let (application, application_mailbox) = application::Actor::new( - context.with_label("application"), - application::Config { - mailbox_size: cfg.mailbox_size, - }, - ); - // Create the buffer let (buffer, buffer_mailbox) = buffered::Engine::new( context.with_label("buffer"), @@ -123,10 +137,21 @@ impl< mailbox_size: cfg.mailbox_size, deque_size: cfg.deque_size, priority: true, - codec_config: (), + codec_config: commonware_coding::CodecConfig { + maximum_shard_size: usize::MAX, + }, }, ); + // Create the shard engine + let (shards, shard_mailbox) = shards::Engine::new( + context.with_label("shards"), + buffer_mailbox, + (), + cfg.mailbox_size, + cfg.concurrency, + ); + // Create the buffer pool let buffer_pool = PoolRef::new(BUFFER_POOL_PAGE_SIZE, BUFFER_POOL_CAPACITY); @@ -134,7 +159,7 @@ impl< let scheme = Scheme::new(cfg.participants, &cfg.polynomial, cfg.share); // Create marshal - let (marshal, marshal_mailbox) = marshal::Actor::init( + let (marshal, marshal_mailbox) = coding::Actor::init( context.with_label("marshal"), marshal::Config { scheme_provider: scheme.clone().into(), @@ -156,15 +181,28 @@ impl< replay_buffer: REPLAY_BUFFER, write_buffer: WRITE_BUFFER, block_codec_config: (), + concurrency: cfg.concurrency, max_repair: MAX_REPAIR, _marker: PhantomData, }, ) .await; + // Create the application + let app = AltoApp::new(); + let marshaled = Marshaled::new( + context.with_label("marshaled"), + app, + marshal_mailbox.clone(), + shard_mailbox.clone(), + scheme.clone().into(), + EPOCH_LENGTH, + cfg.concurrency, + ); + // Create the reporter let reporter = ( - marshal_mailbox.clone(), + Reporters::from((marshal_mailbox.clone(), shard_mailbox.clone())), cfg.indexer.map(|indexer| { indexer::Pusher::new( context.with_label("indexer"), @@ -182,8 +220,8 @@ impl< epoch: EPOCH, namespace: NAMESPACE.to_vec(), scheme, - automaton: application_mailbox.clone(), - relay: application_mailbox.clone(), + automaton: marshaled.clone(), + relay: marshaled.clone(), reporter, partition: format!("{}-consensus", cfg.partition_prefix), mailbox_size: cfg.mailbox_size, @@ -193,7 +231,6 @@ impl< fetch_timeout: cfg.fetch_timeout, activity_timeout: cfg.activity_timeout, skip_timeout: cfg.skip_timeout, - max_fetch_count: cfg.max_fetch_count, fetch_concurrent: cfg.fetch_concurrent, fetch_rate_per_peer: cfg.fetch_rate_per_peer, replay_buffer: REPLAY_BUFFER, @@ -207,12 +244,12 @@ impl< Self { context: ContextCell::new(context), - application, - application_mailbox, buffer, - buffer_mailbox, + shards, + shard_mailbox, marshal, - marshal_mailbox, + + marshaled, consensus, } } @@ -273,16 +310,16 @@ impl< impl Resolver>, ), ) { - // Start the application - let application_handle = self.application.start(self.marshal_mailbox); - // Start the buffer let buffer_handle = self.buffer.start(broadcast); + // Start the shard engine + let shard_handle = self.shards.start(); + // Start marshal - let marshal_handle = - self.marshal - .start(self.application_mailbox, self.buffer_mailbox, marshal); + let marshal_handle = self + .marshal + .start(self.marshaled, self.shard_mailbox, marshal); // Start consensus // @@ -292,8 +329,8 @@ impl< // Wait for any actor to finish if let Err(e) = try_join_all(vec![ - application_handle, buffer_handle, + shard_handle, marshal_handle, consensus_handle, ]) diff --git a/chain/src/indexer.rs b/chain/src/indexer.rs index 829c277a..77943cce 100644 --- a/chain/src/indexer.rs +++ b/chain/src/indexer.rs @@ -1,5 +1,10 @@ use alto_types::{Activity, Block, Finalized, Identity, Notarized, Scheme, Seed, Seedable}; -use commonware_consensus::{marshal, Reporter, Viewable}; +use commonware_coding::ReedSolomon; +use commonware_consensus::{ + marshal::coding::{self, types::DigestOrCommitment}, + Reporter, Viewable, +}; +use commonware_cryptography::Sha256; use commonware_runtime::{Metrics, Spawner}; use std::future::Future; #[cfg(test)] @@ -100,12 +105,16 @@ impl Indexer for alto_client::Client { pub struct Pusher { context: E, indexer: I, - marshal: marshal::Mailbox, + marshal: coding::Mailbox>, } impl Pusher { /// Create a new [Pusher]. - pub fn new(context: E, indexer: I, marshal: marshal::Mailbox) -> Self { + pub fn new( + context: E, + indexer: I, + marshal: coding::Mailbox>, + ) -> Self { Self { context, indexer, @@ -142,7 +151,10 @@ impl Reporter for Pusher { move |_| async move { // Wait for block let block = marshal - .subscribe(Some(notarization.round()), notarization.proposal.payload) + .subscribe( + Some(notarization.round()), + DigestOrCommitment::Commitment(notarization.proposal.payload), + ) .await .await; let Ok(block) = block else { @@ -151,7 +163,7 @@ impl Reporter for Pusher { }; // Upload to indexer once we have it - let notarization = Notarized::new(notarization, block); + let notarization = Notarized::new(notarization, block.into_inner()); let result = indexer.notarized_upload(notarization).await; if let Err(e) = result { warn!(?e, "failed to upload notarization"); @@ -183,7 +195,10 @@ impl Reporter for Pusher { let mut marshal = self.marshal.clone(); move |_| async move { let block = marshal - .subscribe(Some(finalization.round()), finalization.proposal.payload) + .subscribe( + Some(finalization.round()), + DigestOrCommitment::Commitment(finalization.proposal.payload), + ) .await .await; let Ok(block) = block else { @@ -192,7 +207,7 @@ impl Reporter for Pusher { }; // Upload to indexer once we have it - let finalization = Finalized::new(finalization, block); + let finalization = Finalized::new(finalization, block.into_inner()); let result = indexer.finalized_upload(finalization).await; if let Err(e) = result { warn!(?e, "failed to upload finalization"); diff --git a/chain/src/lib.rs b/chain/src/lib.rs index a726cfc3..38ce46ec 100644 --- a/chain/src/lib.rs +++ b/chain/src/lib.rs @@ -61,7 +61,7 @@ impl From for StaticSchemeProvider { #[cfg(test)] mod tests { use super::*; - use commonware_consensus::marshal; + use commonware_consensus::marshal::{self, coding::ingress::handler::Handler}; use commonware_cryptography::{ bls12381::{ dkg::ops, @@ -110,7 +110,7 @@ mod tests { (Sender, Receiver), ), > { - oracle.update(0, validators.into()).await; + oracle.manager().update(0, validators.into()).await; let mut registrations = HashMap::new(); for validator in validators.iter() { let mut oracle = oracle.control(validator.clone()); @@ -177,7 +177,7 @@ mod tests { let (network, mut oracle) = Network::new( context.with_label("network"), simulated::Config { - max_size: 1024 * 1024, + max_size: 20 * 1024 * 1024, disconnect_on_block: true, tracked_peer_sets: Some(1), }, @@ -237,6 +237,7 @@ mod tests { fetch_concurrent: 10, fetch_rate_per_peer: Quota::per_second(NonZeroU32::new(10).unwrap()), indexer: None, + concurrency: 1, }; let engine = Engine::new(context.with_label(&uid), config).await; @@ -247,7 +248,8 @@ mod tests { // Configure marshal resolver let marshal_resolver_cfg = marshal::resolver::p2p::Config { public_key: public_key.clone(), - manager: oracle.clone(), + manager: oracle.manager(), + blocker: oracle.control(public_key.clone()), mailbox_size: 1024, requester_config: requester::Config { me: Some(public_key.clone()), @@ -260,8 +262,12 @@ mod tests { priority_responses: false, }; - let marshal_resolver = - marshal::resolver::p2p::init(&context, marshal_resolver_cfg, backfill); + let marshal_resolver = marshal::resolver::p2p::init( + &context, + marshal_resolver_cfg, + backfill, + Handler::new, + ); // Start engine engine.start(pending, recovered, resolver, broadcast, marshal_resolver); @@ -359,7 +365,7 @@ mod tests { let (network, mut oracle) = Network::new( context.with_label("network"), simulated::Config { - max_size: 1024 * 1024, + max_size: 20 * 1024 * 1024, disconnect_on_block: true, tracked_peer_sets: Some(1), }, @@ -431,6 +437,7 @@ mod tests { fetch_concurrent: 10, fetch_rate_per_peer: Quota::per_second(NonZeroU32::new(10).unwrap()), indexer: None, + concurrency: 1, }; let engine = Engine::new(context.with_label(&uid), config).await; @@ -441,7 +448,8 @@ mod tests { // Configure marshal resolver let marshal_resolver_cfg = marshal::resolver::p2p::Config { public_key: public_key.clone(), - manager: oracle.clone(), + manager: oracle.manager(), + blocker: oracle.control(public_key.clone()), mailbox_size: 1024, requester_config: requester::Config { me: Some(public_key.clone()), @@ -454,8 +462,12 @@ mod tests { priority_responses: false, }; - let marshal_resolver = - marshal::resolver::p2p::init(&context, marshal_resolver_cfg, backfill); + let marshal_resolver = marshal::resolver::p2p::init( + &context, + marshal_resolver_cfg, + backfill, + Handler::new, + ); // Start engine engine.start(pending, recovered, resolver, broadcast, marshal_resolver); @@ -537,6 +549,7 @@ mod tests { fetch_concurrent: 10, fetch_rate_per_peer: Quota::per_second(NonZeroU32::new(10).unwrap()), indexer: None, + concurrency: 1, }; let engine = Engine::new(context.with_label(&uid), config).await; @@ -547,7 +560,8 @@ mod tests { // Configure marshal resolver let marshal_resolver_cfg = marshal::resolver::p2p::Config { public_key: public_key.clone(), - manager: oracle, + manager: oracle.manager(), + blocker: oracle.control(public_key.clone()), mailbox_size: 1024, requester_config: requester::Config { me: Some(public_key.clone()), @@ -560,8 +574,12 @@ mod tests { priority_responses: false, }; - let marshal_resolver = - marshal::resolver::p2p::init(&context, marshal_resolver_cfg, backfill); + let marshal_resolver = marshal::resolver::p2p::init( + &context, + marshal_resolver_cfg, + backfill, + Handler::new, + ); // Start engine engine.start(pending, recovered, resolver, broadcast, marshal_resolver); @@ -631,7 +649,7 @@ mod tests { let (network, mut oracle) = Network::new( context.with_label("network"), simulated::Config { - max_size: 1024 * 1024, + max_size: 20 * 1024 * 1024, disconnect_on_block: true, tracked_peer_sets: Some(1), }, @@ -692,6 +710,7 @@ mod tests { fetch_concurrent: 10, fetch_rate_per_peer: Quota::per_second(NonZeroU32::new(10).unwrap()), indexer: None, + concurrency: 1, }; let engine = Engine::new(context.with_label(&uid), config).await; @@ -702,7 +721,8 @@ mod tests { // Configure marshal resolver let marshal_resolver_cfg = marshal::resolver::p2p::Config { public_key: public_key.clone(), - manager: oracle.clone(), + manager: oracle.manager(), + blocker: oracle.control(public_key.clone()), mailbox_size: 1024, requester_config: requester::Config { me: Some(public_key.clone()), @@ -715,8 +735,12 @@ mod tests { priority_responses: false, }; - let marshal_resolver = - marshal::resolver::p2p::init(&context, marshal_resolver_cfg, backfill); + let marshal_resolver = marshal::resolver::p2p::init( + &context, + marshal_resolver_cfg, + backfill, + Handler::new, + ); // Start engine engine.start(pending, recovered, resolver, broadcast, marshal_resolver); @@ -816,7 +840,7 @@ mod tests { let (network, mut oracle) = Network::new( context.with_label("network"), simulated::Config { - max_size: 1024 * 1024, + max_size: 20 * 1024 * 1024, disconnect_on_block: true, tracked_peer_sets: Some(1), }, @@ -885,6 +909,7 @@ mod tests { fetch_concurrent: 10, fetch_rate_per_peer: Quota::per_second(NonZeroU32::new(10).unwrap()), indexer: Some(indexer.clone()), + concurrency: 1, }; let engine = Engine::new(context.with_label(&uid), config).await; @@ -895,7 +920,8 @@ mod tests { // Configure marshal resolver let marshal_resolver_cfg = marshal::resolver::p2p::Config { public_key: public_key.clone(), - manager: oracle.clone(), + manager: oracle.manager(), + blocker: oracle.control(public_key.clone()), mailbox_size: 1024, requester_config: requester::Config { me: Some(public_key.clone()), @@ -908,8 +934,12 @@ mod tests { priority_responses: false, }; - let marshal_resolver = - marshal::resolver::p2p::init(&context, marshal_resolver_cfg, backfill); + let marshal_resolver = marshal::resolver::p2p::init( + &context, + marshal_resolver_cfg, + backfill, + Handler::new, + ); // Start engine engine.start(pending, recovered, resolver, broadcast, marshal_resolver); diff --git a/types/Cargo.toml b/types/Cargo.toml index 9c4bcbda..a032e5e4 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -25,6 +25,9 @@ wasm-bindgen = "0.2.100" serde = { version = "1.0.219", features = ["derive"] } serde-wasm-bindgen = "0.6.5" +[dev-dependencies] +commonware-coding = { workspace = true } + # Enable "js" feature when WASM is target [target.'cfg(target_arch = "wasm32")'.dependencies.getrandom] version = "0.2.15" diff --git a/types/src/block.rs b/types/src/block.rs index a5b237c9..3e3a47c2 100644 --- a/types/src/block.rs +++ b/types/src/block.rs @@ -1,7 +1,9 @@ use crate::consensus::{Finalization, Notarization, Scheme}; use bytes::{Buf, BufMut}; -use commonware_codec::{varint::UInt, EncodeSize, Error, Read, ReadExt, Write}; -use commonware_cryptography::{sha256::Digest, Committable, Digestible, Hasher, Sha256}; +use commonware_codec::{varint::UInt, EncodeSize, Error, RangeCfg, Read, ReadExt, Write}; +use commonware_cryptography::{ + sha256::Digest, sha256::Digest as Sha256Digest, Committable, Digestible, Hasher, Sha256, +}; use rand::rngs::OsRng; #[derive(Clone, Debug, PartialEq, Eq)] @@ -15,25 +17,30 @@ pub struct Block { /// The timestamp of the block (in milliseconds since the Unix epoch). pub timestamp: u64, + /// Junk data appended to the block. + pub junk: Vec, + /// Pre-computed digest of the block. digest: Digest, } impl Block { - fn compute_digest(parent: &Digest, height: u64, timestamp: u64) -> Digest { + fn compute_digest(parent: &Digest, height: u64, timestamp: u64, junk: &[u8]) -> Digest { let mut hasher = Sha256::new(); hasher.update(parent); hasher.update(&height.to_be_bytes()); hasher.update(×tamp.to_be_bytes()); + hasher.update(junk); hasher.finalize() } - pub fn new(parent: Digest, height: u64, timestamp: u64) -> Self { - let digest = Self::compute_digest(&parent, height, timestamp); + pub fn new(parent: Digest, height: u64, timestamp: u64, junk: Vec) -> Self { + let digest = Self::compute_digest(&parent, height, timestamp, junk.as_slice()); Self { parent, height, timestamp, + junk, digest, } } @@ -44,6 +51,7 @@ impl Write for Block { self.parent.write(writer); UInt(self.height).write(writer); UInt(self.timestamp).write(writer); + self.junk.write(writer); } } @@ -54,13 +62,15 @@ impl Read for Block { let parent = Digest::read(reader)?; let height = UInt::read(reader)?.into(); let timestamp = UInt::read(reader)?.into(); + let junk = Vec::::read_cfg(reader, &(RangeCfg::new(0..=usize::MAX), ()))?; // Pre-compute the digest - let digest = Self::compute_digest(&parent, height, timestamp); + let digest = Self::compute_digest(&parent, height, timestamp, junk.as_slice()); Ok(Self { parent, height, timestamp, + junk, digest, }) @@ -72,6 +82,7 @@ impl EncodeSize for Block { self.parent.encode_size() + UInt(self.height).encode_size() + UInt(self.timestamp).encode_size() + + self.junk.encode_size() } } @@ -122,7 +133,7 @@ impl Read for Notarized { let block = Block::read(buf)?; // Ensure the proof is for the block - if proof.proposal.payload != block.digest() { + if proof.proposal.payload.block_digest::() != block.digest() { return Err(Error::Invalid( "types::Notarized", "Proof payload does not match block digest", @@ -169,7 +180,7 @@ impl Read for Finalized { let block = Block::read(buf)?; // Ensure the proof is for the block - if proof.proposal.payload != block.digest() { + if proof.proposal.payload.block_digest::() != block.digest() { return Err(Error::Invalid( "types::Finalized", "Proof payload does not match block digest", diff --git a/types/src/consensus.rs b/types/src/consensus.rs index 3a43b079..0936e6f8 100644 --- a/types/src/consensus.rs +++ b/types/src/consensus.rs @@ -1,3 +1,4 @@ +use commonware_consensus::marshal::coding::types::CodingCommitment; use commonware_consensus::simplex::signing_scheme::bls12381_threshold; use commonware_consensus::simplex::types::{ Activity as CActivity, Finalization as CFinalization, Notarization as CNotarization, @@ -5,16 +6,15 @@ use commonware_consensus::simplex::types::{ use commonware_cryptography::{ bls12381::primitives::variant::{MinSig, Variant}, ed25519, - sha256::Digest, }; pub use commonware_consensus::simplex::signing_scheme::bls12381_threshold::Seedable; pub type Scheme = bls12381_threshold::Scheme; pub type Seed = bls12381_threshold::Seed; -pub type Notarization = CNotarization; -pub type Finalization = CFinalization; -pub type Activity = CActivity; +pub type Notarization = CNotarization; +pub type Finalization = CFinalization; +pub type Activity = CActivity; pub type PublicKey = ed25519::PublicKey; pub type Identity = ::Public; diff --git a/types/src/lib.rs b/types/src/lib.rs index 8df8472a..4c110619 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -57,13 +57,15 @@ impl Kind { mod tests { use super::*; use commonware_codec::{DecodeExt, Encode}; + use commonware_coding::ReedSolomon; use commonware_consensus::{ + marshal::coding::types::{coding_config_for_participants, CodedBlock}, simplex::types::{Finalization, Finalize, Notarization, Notarize, Proposal}, types::Round, }; use commonware_cryptography::{ bls12381::{dkg::ops, primitives::variant::MinSig}, - ed25519, Digestible, Hasher, PrivateKeyExt, Sha256, Signer, + ed25519, Committable, Hasher, PrivateKeyExt, Sha256, Signer, }; use commonware_utils::set::Ordered; use rand::{rngs::StdRng, SeedableRng}; @@ -82,10 +84,16 @@ mod tests { .map(|share| Scheme::new(participants.clone(), &polynomial, share)) .collect(); + let coding_config = coding_config_for_participants(n as u16); + // Create a block let digest = Sha256::hash(b"hello world"); - let block = Block::new(digest, 10, 100); - let proposal = Proposal::new(Round::new(EPOCH, 11), 8, block.digest()); + let block = CodedBlock::<_, ReedSolomon>::new( + Block::new(digest, 10, 100, Vec::new()), + coding_config, + 1, + ); + let proposal = Proposal::new(Round::new(EPOCH, 11), 8, block.commitment()); // Create a notarization let notarizes: Vec<_> = schemes @@ -93,7 +101,7 @@ mod tests { .map(|scheme| Notarize::sign(scheme, NAMESPACE, proposal.clone()).unwrap()) .collect(); let notarization = Notarization::from_notarizes(&schemes[0], ¬arizes).unwrap(); - let notarized = Notarized::new(notarization, block.clone()); + let notarized = Notarized::new(notarization, block.into_inner()); // Serialize and deserialize let encoded = notarized.encode(); @@ -118,10 +126,16 @@ mod tests { .map(|share| Scheme::new(participants.clone(), &polynomial, share)) .collect(); + let coding_config = coding_config_for_participants(n as u16); + // Create a block let digest = Sha256::hash(b"hello world"); - let block = Block::new(digest, 10, 100); - let proposal = Proposal::new(Round::new(EPOCH, 11), 8, block.digest()); + let block = CodedBlock::<_, ReedSolomon>::new( + Block::new(digest, 10, 100, Vec::new()), + coding_config, + 1, + ); + let proposal = Proposal::new(Round::new(EPOCH, 11), 8, block.commitment()); // Create a finalization let finalizes: Vec<_> = schemes @@ -129,7 +143,7 @@ mod tests { .map(|scheme| Finalize::sign(scheme, NAMESPACE, proposal.clone()).unwrap()) .collect(); let finalization = Finalization::from_finalizes(&schemes[0], &finalizes).unwrap(); - let finalized = Finalized::new(finalization, block.clone()); + let finalized = Finalized::new(finalization, block.into_inner()); // Serialize and deserialize let encoded = finalized.encode();