diff --git a/Cargo.lock b/Cargo.lock index cb25eb92be7..d76b1987806 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,6 +72,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "adler32" version = "1.2.0" @@ -178,9 +184,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-consensus" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58047cc851e58c26224521d1ecda466e3d746ebca0274cd5427aa660a88c353" +checksum = "4177d135789e282e925092be8939d421b701c6d92c0a16679faa659d9166289d" dependencies = [ "alloy-eips", "alloy-primitives", @@ -188,15 +194,38 @@ dependencies = [ "c-kzg", ] +[[package]] +name = "alloy-eip2930" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0069cf0642457f87a01a014f6dc29d5d893cd4fd8fddf0c3cdfad1bb3ebafc41" +dependencies = [ + "alloy-primitives", + "alloy-rlp", +] + +[[package]] +name = "alloy-eip7702" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d319bb544ca6caeab58c39cea8921c55d924d4f68f2c60f24f914673f9a74a" +dependencies = [ + "alloy-primitives", + "alloy-rlp", +] + [[package]] name = "alloy-eips" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a3e14fa0d152d00bd8daf605eb74ad397efb0f54bd7155585823dddb4401e" +checksum = "499ee14d296a133d142efd215eb36bf96124829fe91cf8f5d4e5ccdd381eae00" dependencies = [ + "alloy-eip2930", + "alloy-eip7702", "alloy-primitives", "alloy-rlp", "c-kzg", + "derive_more 1.0.0", "once_cell", "serde", "sha2 0.10.8", @@ -204,20 +233,24 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.7" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" +checksum = "a767e59c86900dd7c3ce3ecef04f3ace5ac9631ee150beb8b7d22f7fa3bbb2d7" dependencies = [ "alloy-rlp", + "arbitrary", "bytes", "cfg-if", "const-hex", - "derive_more", + "derive_arbitrary", + "derive_more 0.99.18", + "getrandom", "hex-literal", "itoa", "k256 0.13.3", "keccak-asm", "proptest", + "proptest-derive", "rand", "ruint", "serde", @@ -226,9 +259,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a43b18702501396fa9bcdeecd533bc85fac75150d308fc0f6800a01e6234a003" +checksum = "26154390b1d205a4a7ac7352aa2eb4f81f391399d4e2f546fb81a2f8bb383f62" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -237,13 +270,13 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83524c1f6162fcb5b0decf775498a125066c86dda6066ed609531b0e912f85a" +checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -269,9 +302,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -284,33 +317,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -380,7 +413,7 @@ dependencies = [ "num-bigint", "num-traits", "paste", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "zeroize", ] @@ -484,15 +517,15 @@ checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "asn1-rs" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ad1373757efa0f70ec53939aabc7152e1591cb485208052993070ac8d2429d" +checksum = "5493c3bedbacf7fd7382c6346bbd66687d12bbaad3a89a2d2c303ee6cf20b048" dependencies = [ "asn1-rs-derive", "asn1-rs-impl", @@ -506,13 +539,13 @@ dependencies = [ [[package]] name = "asn1-rs-derive" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" +checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", "synstructure", ] @@ -524,7 +557,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -546,9 +579,9 @@ dependencies = [ [[package]] name = "async-io" -version = "2.3.3" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" +checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" dependencies = [ "async-lock", "cfg-if", @@ -557,10 +590,10 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix 0.38.34", + "rustix 0.38.35", "slab", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -576,13 +609,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -593,20 +626,7 @@ checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" dependencies = [ "futures", "pharos", - "rustc_version 0.4.0", -] - -[[package]] -name = "asynchronous-codec" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" -dependencies = [ - "bytes", - "futures-sink", - "futures-util", - "memchr", - "pin-project-lite", + "rustc_version 0.4.1", ] [[package]] @@ -652,7 +672,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -726,7 +746,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.7.4", "object", "rustc-demangle", ] @@ -777,6 +797,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" name = "beacon_chain" version = "0.2.0" dependencies = [ + "alloy-primitives", "bitvec 1.0.1", "bls", "criterion", @@ -911,9 +932,9 @@ dependencies = [ "proc-macro2", "quote", "regex", - "rustc-hash", + "rustc-hash 1.1.0", "shlex", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -1005,14 +1026,16 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" name = "bls" version = "0.2.0" dependencies = [ + "alloy-primitives", "arbitrary", "blst", - "ethereum-types 0.14.1", "ethereum_hashing", "ethereum_serde_utils", "ethereum_ssz", + "fixed_bytes", "hex", "rand", + "safe_arith", "serde", "tree_hash", "zeroize", @@ -1124,9 +1147,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" dependencies = [ "serde", ] @@ -1154,23 +1177,24 @@ dependencies = [ [[package]] name = "c-kzg" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf100c4cea8f207e883ff91ca886d621d8a166cb04971dfaa9bb8fd99ed95df" +checksum = "f0307f72feab3300336fb803a57134159f6e20139af1357f36c54cb90d8e8928" dependencies = [ "blst", "cc", "glob", "hex", "libc", + "once_cell", "serde", ] [[package]] name = "camino" -version = "1.1.7" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" dependencies = [ "serde", ] @@ -1206,12 +1230,13 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.6" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" dependencies = [ "jobserver", "libc", + "shlex", ] [[package]] @@ -1231,9 +1256,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cfg_aliases" -version = "0.1.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chacha20" @@ -1331,9 +1356,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.10" +version = "4.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6b81fb3c84f5563d509c59b5a48d935f689e993afa90fe39047f05adef9142" +checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" dependencies = [ "clap_builder", "clap_derive", @@ -1341,9 +1366,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.10" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca6706fd5224857d9ac5eb9355f6683563cc0541c7cd9d014043b57cbec78ac" +checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" dependencies = [ "anstream", "anstyle", @@ -1354,30 +1379,30 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.8" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "clap_utils" version = "0.1.0" dependencies = [ + "alloy-primitives", "clap", "dirs", "eth2_network_config", - "ethereum-types 0.14.1", "ethereum_ssz", "hex", "serde", @@ -1428,18 +1453,18 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.50" +version = "0.1.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a" dependencies = [ "cc", ] [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "compare_fields" @@ -1509,9 +1534,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "core2" @@ -1524,9 +1549,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" dependencies = [ "libc", ] @@ -1752,12 +1777,12 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" +checksum = "90eeab0aa92f3f9b4e87f258c72b139c207d251f9cbc1080a0086b86a8870dd3" dependencies = [ - "nix 0.28.0", - "windows-sys 0.52.0", + "nix 0.29.0", + "windows-sys 0.59.0", ] [[package]] @@ -1771,7 +1796,7 @@ dependencies = [ "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "subtle", "zeroize", ] @@ -1784,7 +1809,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -1832,7 +1857,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -1854,7 +1879,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -2019,7 +2044,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -2031,8 +2056,28 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", - "syn 2.0.72", + "rustc_version 0.4.1", + "syn 2.0.77", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", ] [[package]] @@ -2059,7 +2104,7 @@ dependencies = [ "dsl_auto_type", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -2079,7 +2124,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "209c735641a413bc68c4923a9d6ad4bcb3ca306b794edaa7eb0b3228a99ffb25" dependencies = [ - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -2170,7 +2215,7 @@ dependencies = [ "hex", "hkdf", "lazy_static", - "libp2p", + "libp2p 0.53.2", "lru", "more-asserts", "parking_lot 0.11.2", @@ -2192,7 +2237,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -2206,7 +2251,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -2217,9 +2262,9 @@ checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" [[package]] name = "dunce" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "ecdsa" @@ -2276,13 +2321,13 @@ dependencies = [ name = "ef_tests" version = "0.2.0" dependencies = [ + "alloy-primitives", "beacon_chain", "bls", "compare_fields", "compare_fields_derive", "derivative", "eth2_network_config", - "ethereum-types 0.14.1", "ethereum_ssz", "ethereum_ssz_derive", "execution_layer", @@ -2386,7 +2431,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -2736,23 +2781,22 @@ dependencies = [ [[package]] name = "ethereum_hashing" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea7b408432c13f71af01197b1d3d0069c48a27bfcfbe72a81fc346e47f6defb" +checksum = "c853bd72c9e5787f8aafc3df2907c2ed03cff3150c3acd94e2e53a98ab70a8ab" dependencies = [ "cpufeatures", - "lazy_static", "ring 0.17.8", "sha2 0.10.8", ] [[package]] name = "ethereum_serde_utils" -version = "0.5.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de4d5951468846963c24e8744c133d44f39dff2cd3a233f6be22b370d08a524f" +checksum = "70cbccfccf81d67bff0ab36e591fa536c8a935b078a7b0e58c1d00d418332fc9" dependencies = [ - "ethereum-types 0.14.1", + "alloy-primitives", "hex", "serde", "serde_derive", @@ -2761,25 +2805,25 @@ dependencies = [ [[package]] name = "ethereum_ssz" -version = "0.5.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d3627f83d8b87b432a5fad9934b4565260722a141a2c40f371f8080adec9425" +checksum = "1e999563461faea0ab9bc0024e5e66adcee35881f3d5062f52f31a4070fe1522" dependencies = [ - "ethereum-types 0.14.1", - "itertools 0.10.5", + "alloy-primitives", + "itertools 0.13.0", "smallvec", ] [[package]] name = "ethereum_ssz_derive" -version = "0.5.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eccd5378ec34a07edd3d9b48088cbc63309d0367d14ba10b0cdb1d1791080ea" +checksum = "f3deae99c8e74829a00ba7a92d49055732b3c1f093f2ccfa3cbc621679b6fa91" dependencies = [ - "darling 0.13.4", + "darling 0.20.10", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.77", ] [[package]] @@ -2970,6 +3014,7 @@ dependencies = [ "ethereum_serde_utils", "ethereum_ssz", "ethers-core", + "fixed_bytes", "fork_choice", "hash-db", "hash256-std-hasher", @@ -3030,9 +3075,9 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fastrlp" @@ -3095,7 +3140,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" dependencies = [ "memoffset", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -3124,22 +3169,29 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ - "arbitrary", "byteorder", "rand", "rustc-hex", "static_assertions", ] +[[package]] +name = "fixed_bytes" +version = "0.1.0" +dependencies = [ + "alloy-primitives", + "safe_arith", +] + [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide", + "miniz_oxide 0.8.0", ] [[package]] @@ -3287,7 +3339,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -3445,7 +3497,7 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -3459,7 +3511,7 @@ name = "gossipsub" version = "0.5.0" dependencies = [ "async-channel", - "asynchronous-codec 0.7.0", + "asynchronous-codec", "base64 0.21.7", "byteorder", "bytes", @@ -3471,10 +3523,10 @@ dependencies = [ "getrandom", "hashlink 0.9.1", "hex_fmt", - "libp2p", + "libp2p 0.54.1", "prometheus-client", "quick-protobuf", - "quick-protobuf-codec 0.3.1", + "quick-protobuf-codec", "quickcheck", "rand", "regex", @@ -3521,7 +3573,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.2.6", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", @@ -3658,6 +3710,9 @@ name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] [[package]] name = "hex-literal" @@ -3990,9 +4045,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" dependencies = [ "bytes", "futures-util", @@ -4174,9 +4229,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -4252,20 +4307,20 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi 0.4.0", "libc", "windows-sys 0.52.0", ] [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" @@ -4285,6 +4340,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -4333,9 +4397,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] @@ -4393,9 +4457,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47a3633291834c4fbebf8673acbc1b04ec9d151418ff9b8e26dcd79129928758" +checksum = "422fbc7ff2f2f5bdffeb07718e5a5324dca72b0c9293d50df4026652385e3314" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -4507,9 +4571,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libflate" @@ -4558,7 +4622,7 @@ source = "git+https://github.com/sigp/libmdbx-rs?rev=e6ff4b9377c1619bcf0bfdf52be dependencies = [ "bitflags 1.3.2", "byteorder", - "derive_more", + "derive_more 0.99.18", "indexmap 1.9.3", "libc", "mdbx-sys", @@ -4578,9 +4642,31 @@ dependencies = [ "futures-timer", "getrandom", "instant", - "libp2p-allow-block-list", - "libp2p-connection-limits", - "libp2p-core", + "libp2p-allow-block-list 0.3.0", + "libp2p-connection-limits 0.3.1", + "libp2p-core 0.41.3", + "libp2p-identity", + "libp2p-swarm 0.44.2", + "multiaddr", + "pin-project", + "rw-stream-sink", + "thiserror", +] + +[[package]] +name = "libp2p" +version = "0.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbe80f9c7e00526cd6b838075b9c171919404a4732cb2fa8ece0a093223bfc4" +dependencies = [ + "bytes", + "either", + "futures", + "futures-timer", + "getrandom", + "libp2p-allow-block-list 0.4.0", + "libp2p-connection-limits 0.4.0", + "libp2p-core 0.42.0", "libp2p-dns", "libp2p-identify", "libp2p-identity", @@ -4589,7 +4675,7 @@ dependencies = [ "libp2p-noise", "libp2p-plaintext", "libp2p-quic", - "libp2p-swarm", + "libp2p-swarm 0.45.1", "libp2p-tcp", "libp2p-upnp", "libp2p-yamux", @@ -4605,9 +4691,21 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "107b238b794cb83ab53b74ad5dcf7cca3200899b72fe662840cfb52f5b0a32e6" dependencies = [ - "libp2p-core", + "libp2p-core 0.41.3", + "libp2p-identity", + "libp2p-swarm 0.44.2", + "void", +] + +[[package]] +name = "libp2p-allow-block-list" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1027ccf8d70320ed77e984f273bc8ce952f623762cb9bf2d126df73caef8041" +dependencies = [ + "libp2p-core 0.42.0", "libp2p-identity", - "libp2p-swarm", + "libp2p-swarm 0.45.1", "void", ] @@ -4617,9 +4715,21 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7cd50a78ccfada14de94cbacd3ce4b0138157f376870f13d3a8422cd075b4fd" dependencies = [ - "libp2p-core", + "libp2p-core 0.41.3", "libp2p-identity", - "libp2p-swarm", + "libp2p-swarm 0.44.2", + "void", +] + +[[package]] +name = "libp2p-connection-limits" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d003540ee8baef0d254f7b6bfd79bac3ddf774662ca0abf69186d517ef82ad8" +dependencies = [ + "libp2p-core 0.42.0", + "libp2p-identity", + "libp2p-swarm 0.45.1", "void", ] @@ -4651,16 +4761,44 @@ dependencies = [ "web-time", ] +[[package]] +name = "libp2p-core" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a61f26c83ed111104cd820fe9bc3aaabbac5f1652a1d213ed6e900b7918a1298" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "libp2p-identity", + "multiaddr", + "multihash", + "multistream-select", + "once_cell", + "parking_lot 0.12.3", + "pin-project", + "quick-protobuf", + "rand", + "rw-stream-sink", + "smallvec", + "thiserror", + "tracing", + "unsigned-varint 0.8.0", + "void", + "web-time", +] + [[package]] name = "libp2p-dns" -version = "0.41.1" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17cbcf7160ff35c3e8e560de4a068fe9d6cb777ea72840e48eb76ff9576c4b6" +checksum = "97f37f30d5c7275db282ecd86e54f29dd2176bd3ac656f06abf43bedb21eb8bd" dependencies = [ "async-trait", "futures", "hickory-resolver", - "libp2p-core", + "libp2p-core 0.42.0", "libp2p-identity", "parking_lot 0.12.3", "smallvec", @@ -4669,21 +4807,21 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.44.2" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5d635ebea5ca0c3c3e77d414ae9b67eccf2a822be06091b9c1a0d13029a1e2f" +checksum = "1711b004a273be4f30202778856368683bd9a83c4c7dcc8f848847606831a4e3" dependencies = [ - "asynchronous-codec 0.7.0", + "asynchronous-codec", "either", "futures", "futures-bounded", "futures-timer", - "libp2p-core", + "libp2p-core 0.42.0", "libp2p-identity", - "libp2p-swarm", + "libp2p-swarm 0.45.1", "lru", "quick-protobuf", - "quick-protobuf-codec 0.3.1", + "quick-protobuf-codec", "smallvec", "thiserror", "tracing", @@ -4715,17 +4853,17 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.45.1" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49007d9a339b3e1d7eeebc4d67c05dbf23d300b7d091193ec2d3f26802d7faf2" +checksum = "14b8546b6644032565eb29046b42744aee1e9f261ed99671b2c93fb140dba417" dependencies = [ "data-encoding", "futures", "hickory-proto", "if-watch", - "libp2p-core", + "libp2p-core 0.42.0", "libp2p-identity", - "libp2p-swarm", + "libp2p-swarm 0.45.1", "rand", "smallvec", "socket2 0.5.7", @@ -4736,50 +4874,50 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.14.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdac91ae4f291046a3b2660c039a2830c931f84df2ee227989af92f7692d3357" +checksum = "77ebafa94a717c8442d8db8d3ae5d1c6a15e30f2d347e0cd31d057ca72e42566" dependencies = [ "futures", - "instant", - "libp2p-core", + "libp2p-core 0.42.0", "libp2p-identify", "libp2p-identity", - "libp2p-swarm", + "libp2p-swarm 0.45.1", "pin-project", "prometheus-client", + "web-time", ] [[package]] name = "libp2p-mplex" -version = "0.41.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e895765e27e30217b25f7cb7ac4686dad1ff80bf2fdeffd1d898566900a924" +checksum = "41187ab8f6c835ad864edf94224f666f636ee2d270601422c1441f739e0abccc" dependencies = [ - "asynchronous-codec 0.6.2", + "asynchronous-codec", "bytes", "futures", - "libp2p-core", + "libp2p-core 0.42.0", "libp2p-identity", "nohash-hasher", "parking_lot 0.12.3", "rand", "smallvec", "tracing", - "unsigned-varint 0.7.2", + "unsigned-varint 0.8.0", ] [[package]] name = "libp2p-noise" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecd0545ce077f6ea5434bcb76e8d0fe942693b4380aaad0d34a358c2bd05793" +checksum = "36b137cb1ae86ee39f8e5d6245a296518912014eaa87427d24e6ff58cfc1b28c" dependencies = [ - "asynchronous-codec 0.7.0", + "asynchronous-codec", "bytes", "curve25519-dalek", "futures", - "libp2p-core", + "libp2p-core 0.42.0", "libp2p-identity", "multiaddr", "multihash", @@ -4797,31 +4935,31 @@ dependencies = [ [[package]] name = "libp2p-plaintext" -version = "0.41.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67330af40b67217e746d42551913cfb7ad04c74fa300fb329660a56318590b3f" +checksum = "5b63d926c6be56a2489e0e7316b17fe95a70bc5c4f3e85740bb3e67c0f3c6a44" dependencies = [ - "asynchronous-codec 0.6.2", + "asynchronous-codec", "bytes", "futures", - "libp2p-core", + "libp2p-core 0.42.0", "libp2p-identity", "quick-protobuf", - "quick-protobuf-codec 0.2.0", + "quick-protobuf-codec", "tracing", ] [[package]] name = "libp2p-quic" -version = "0.10.3" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c67296ad4e092e23f92aea3d2bdb6f24eab79c0929ed816dfb460ea2f4567d2b" +checksum = "46352ac5cd040c70e88e7ff8257a2ae2f891a4076abad2c439584a31c15fd24e" dependencies = [ "bytes", "futures", "futures-timer", "if-watch", - "libp2p-core", + "libp2p-core 0.42.0", "libp2p-identity", "libp2p-tls", "parking_lot 0.12.3", @@ -4846,7 +4984,28 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core", + "libp2p-core 0.41.3", + "libp2p-identity", + "lru", + "multistream-select", + "once_cell", + "rand", + "smallvec", + "tracing", + "void", +] + +[[package]] +name = "libp2p-swarm" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7dd6741793d2c1fb2088f67f82cf07261f25272ebe3c0b0c311e0c6b50e851a" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "libp2p-core 0.42.0", "libp2p-identity", "libp2p-swarm-derive", "lru", @@ -4857,31 +5016,32 @@ dependencies = [ "tokio", "tracing", "void", + "web-time", ] [[package]] name = "libp2p-swarm-derive" -version = "0.34.2" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5daceb9dd908417b6dfcfe8e94098bc4aac54500c282e78120b885dadc09b999" +checksum = "206e0aa0ebe004d778d79fb0966aa0de996c19894e2c0605ba2f8524dd4443d8" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] name = "libp2p-tcp" -version = "0.41.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b2460fc2748919adff99ecbc1aab296e4579e41f374fb164149bd2c9e529d4c" +checksum = "ad964f312c59dcfcac840acd8c555de8403e295d39edf96f5240048b5fcaa314" dependencies = [ "futures", "futures-timer", "if-watch", "libc", - "libp2p-core", + "libp2p-core 0.42.0", "libp2p-identity", "socket2 0.5.7", "tokio", @@ -4890,13 +5050,13 @@ dependencies = [ [[package]] name = "libp2p-tls" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b7b831e55ce2aa6c354e6861a85fdd4dd0a2b97d5e276fabac0e4810a71776" +checksum = "47b23dddc2b9c355f73c1e36eb0c3ae86f7dc964a3715f0731cfad352db4d847" dependencies = [ "futures", "futures-rustls", - "libp2p-core", + "libp2p-core 0.42.0", "libp2p-identity", "rcgen", "ring 0.17.8", @@ -4909,15 +5069,15 @@ dependencies = [ [[package]] name = "libp2p-upnp" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccf04b0e3ff3de52d07d5fd6c3b061d0e7f908ffc683c32d9638caedce86fc8" +checksum = "01bf2d1b772bd3abca049214a3304615e6a36fa6ffc742bdd1ba774486200b8f" dependencies = [ "futures", "futures-timer", "igd-next", - "libp2p-core", - "libp2p-swarm", + "libp2p-core 0.42.0", + "libp2p-swarm 0.45.1", "tokio", "tracing", "void", @@ -4925,13 +5085,13 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.45.1" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200cbe50349a44760927d50b431d77bed79b9c0a3959de1af8d24a63434b71e5" +checksum = "788b61c80789dba9760d8c669a5bedb642c8267555c803fabd8396e4ca5c5882" dependencies = [ "either", "futures", - "libp2p-core", + "libp2p-core 0.42.0", "thiserror", "tracing", "yamux 0.12.1", @@ -5009,9 +5169,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.18" +version = "1.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c15da26e5af7e25c90b37a2d75cdbf940cf4a55316de9d84c679c9b8bfabf82e" +checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" dependencies = [ "cc", "pkg-config", @@ -5070,6 +5230,7 @@ dependencies = [ name = "lighthouse_network" version = "0.2.0" dependencies = [ + "alloy-primitives", "async-channel", "bytes", "delay_map", @@ -5085,7 +5246,7 @@ dependencies = [ "gossipsub", "hex", "itertools 0.10.5", - "libp2p", + "libp2p 0.54.1", "libp2p-mplex", "lighthouse_metrics", "lighthouse_version", @@ -5215,9 +5376,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" dependencies = [ "hashbrown 0.14.5", ] @@ -5338,8 +5499,9 @@ dependencies = [ name = "merkle_proof" version = "0.2.0" dependencies = [ - "ethereum-types 0.14.1", + "alloy-primitives", "ethereum_hashing", + "fixed_bytes", "quickcheck", "quickcheck_macros", "safe_arith", @@ -5375,7 +5537,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd01039851e82f8799046eabbb354056283fb265c8ec0996af940f4e85a380ff" dependencies = [ "serde", - "toml 0.8.15", + "toml 0.8.19", ] [[package]] @@ -5391,17 +5553,17 @@ dependencies = [ [[package]] name = "milhouse" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3826d3602a3674b07e080ce1982350e454ec253d73f156bd927ac1b652293f4d" +checksum = "f68e33f98199224d1073f7c1468ea6abfea30736306fb79c7181a881e97ea32f" dependencies = [ + "alloy-primitives", "arbitrary", "derivative", - "ethereum-types 0.14.1", "ethereum_hashing", "ethereum_ssz", "ethereum_ssz_derive", - "itertools 0.10.5", + "itertools 0.13.0", "parking_lot 0.12.3", "rayon", "serde", @@ -5443,11 +5605,20 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "mio" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi 0.3.9", "libc", @@ -5626,6 +5797,7 @@ dependencies = [ name = "network" version = "0.2.0" dependencies = [ + "alloy-primitives", "anyhow", "async-channel", "beacon_chain", @@ -5680,9 +5852,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -5817,18 +5989,18 @@ dependencies = [ [[package]] name = "object" -version = "0.36.2" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] [[package]] name = "oid-registry" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c958dd45046245b9c3c2547369bb634eb461670b2e7e0de552905801a648d1d" +checksum = "a8d8034d9489cdaf79228eb9f6a3b8d7bb32ba00d6645ebd48eef4077ceb5bd9" dependencies = [ "asn1-rs", ] @@ -5906,7 +6078,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -6032,7 +6204,7 @@ version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", "syn 1.0.109", @@ -6173,7 +6345,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" dependencies = [ "futures", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -6211,7 +6383,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -6288,17 +6460,17 @@ dependencies = [ [[package]] name = "polling" -version = "3.7.2" +version = "3.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b" +checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi 0.4.0", "pin-project-lite", - "rustix 0.38.34", + "rustix 0.38.35", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -6373,9 +6545,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "pq-sys" @@ -6442,11 +6617,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.21.1", + "toml_edit 0.22.20", ] [[package]] @@ -6508,7 +6683,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -6531,6 +6706,17 @@ dependencies = [ "unarray", ] +[[package]] +name = "proptest-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "proto_array" version = "0.2.0" @@ -6558,7 +6744,7 @@ checksum = "5e617cc9058daa5e1fe5a0d23ed745773a5ee354111dad1ec0235b0cc16b6730" dependencies = [ "cfg-if", "darwin-libproc", - "derive_more", + "derive_more 0.99.18", "glob", "mach2", "nix 0.24.3", @@ -6583,26 +6769,13 @@ dependencies = [ "byteorder", ] -[[package]] -name = "quick-protobuf-codec" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ededb1cd78531627244d51dd0c7139fbe736c7d57af0092a76f0ffb2f56e98" -dependencies = [ - "asynchronous-codec 0.6.2", - "bytes", - "quick-protobuf", - "thiserror", - "unsigned-varint 0.7.2", -] - [[package]] name = "quick-protobuf-codec" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15a0580ab32b169745d7a39db2ba969226ca16738931be152a3209b409de2474" dependencies = [ - "asynchronous-codec 0.7.0", + "asynchronous-codec", "bytes", "quick-protobuf", "thiserror", @@ -6633,17 +6806,18 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.2" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +checksum = "a2d2fb862b7ba45e615c1429def928f2e15f815bdf933b27a2d3824e224c1f46" dependencies = [ "bytes", "futures-io", "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash", + "rustc-hash 2.0.0", "rustls 0.23.12", + "socket2 0.5.7", "thiserror", "tokio", "tracing", @@ -6651,14 +6825,14 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.3" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +checksum = "ea0a9b3a42929fad8a7c3de7f86ce0814cfa893328157672680e9fb1145549c5" dependencies = [ "bytes", "rand", "ring 0.17.8", - "rustc-hash", + "rustc-hash 2.0.0", "rustls 0.23.12", "slab", "thiserror", @@ -6675,14 +6849,15 @@ dependencies = [ "libc", "once_cell", "socket2 0.5.7", + "tracing", "windows-sys 0.52.0", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -6793,9 +6968,9 @@ dependencies = [ [[package]] name = "redb" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6dd20d3cdeb9c7d2366a0b16b93b35b75aec15309fbeb7ce477138c9f68c8c0" +checksum = "58323dc32ea52a8ae105ff94bc0460c5d906307533ba3401aa63db3cbe491fe5" dependencies = [ "libc", ] @@ -6829,9 +7004,9 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", @@ -6840,9 +7015,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -7057,6 +7232,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" dependencies = [ "alloy-rlp", + "arbitrary", "ark-ff 0.3.0", "ark-ff 0.4.2", "bytes", @@ -7120,6 +7296,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -7137,9 +7319,9 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver 1.0.23", ] @@ -7169,9 +7351,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" dependencies = [ "bitflags 2.6.0", "errno", @@ -7201,7 +7383,7 @@ dependencies = [ "log", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.6", + "rustls-webpki 0.102.7", "subtle", "zeroize", ] @@ -7215,7 +7397,7 @@ dependencies = [ "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.6", + "rustls-webpki 0.102.7", "subtle", "zeroize", ] @@ -7231,9 +7413,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ "base64 0.22.1", "rustls-pki-types", @@ -7241,9 +7423,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" [[package]] name = "rustls-webpki" @@ -7257,9 +7439,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.6" +version = "0.102.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" +checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -7330,7 +7512,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "cfg-if", - "derive_more", + "derive_more 0.99.18", "parity-scale-codec 3.6.12", "scale-info-derive", ] @@ -7341,7 +7523,7 @@ version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", "syn 1.0.109", @@ -7493,9 +7675,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -7512,22 +7694,23 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -7550,14 +7733,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -7602,7 +7785,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.5.0", "itoa", "ryu", "serde", @@ -7668,9 +7851,9 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9b57fd861253bff08bb1919e995f90ba8f4889de2726091c8876f3a4e823b40" +checksum = "57d79b758b7cb2085612b11a235055e485605a5103faccdd633f35bd7aee69dd" dependencies = [ "cc", "cfg-if", @@ -7970,7 +8153,7 @@ dependencies = [ "curve25519-dalek", "rand_core", "ring 0.17.8", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "sha2 0.10.8", "subtle", ] @@ -8029,15 +8212,15 @@ dependencies = [ [[package]] name = "ssz_types" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625b20de2d4b3891e6972f4ce5061cb11bd52b3479270c4b177c134b571194a9" +checksum = "35e0719d2b86ac738a55ae71a8429f52aa2741da988f1fd0975b4cc610fd1e08" dependencies = [ "arbitrary", "derivative", "ethereum_serde_utils", "ethereum_ssz", - "itertools 0.10.5", + "itertools 0.13.0", "serde", "serde_derive", "smallvec", @@ -8188,9 +8371,10 @@ dependencies = [ name = "swap_or_not_shuffle" version = "0.2.0" dependencies = [ + "alloy-primitives", "criterion", - "ethereum-types 0.14.1", "ethereum_hashing", + "fixed_bytes", ] [[package]] @@ -8206,9 +8390,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -8235,7 +8419,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -8325,14 +8509,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", - "rustix 0.38.34", - "windows-sys 0.52.0", + "once_cell", + "rustix 0.38.35", + "windows-sys 0.59.0", ] [[package]] @@ -8361,7 +8546,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.38.34", + "rustix 0.38.35", "windows-sys 0.48.0", ] @@ -8415,7 +8600,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -8490,7 +8675,7 @@ dependencies = [ "once_cell", "pbkdf2 0.11.0", "rand", - "rustc-hash", + "rustc-hash 1.1.0", "sha2 0.10.8", "thiserror", "unicode-normalization", @@ -8534,9 +8719,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.1" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -8567,7 +8752,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -8665,21 +8850,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.15" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.16", + "toml_edit 0.22.20", ] [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] @@ -8690,33 +8875,22 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", - "toml_datetime", - "winnow 0.5.40", -] - -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.2.6", + "indexmap 2.5.0", "toml_datetime", "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.22.16" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.5.0", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.15", + "winnow 0.6.18", ] [[package]] @@ -8737,15 +8911,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -8779,7 +8953,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -8852,24 +9026,25 @@ dependencies = [ [[package]] name = "tree_hash" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134d6b24a5b829f30b5ee7de05ba7384557f5f6b00e29409cdf2392f93201bfa" +checksum = "373495c23db675a5192de8b610395e1bec324d596f9e6111192ce903dc11403a" dependencies = [ - "ethereum-types 0.14.1", + "alloy-primitives", "ethereum_hashing", "smallvec", ] [[package]] name = "tree_hash_derive" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce7bccc538359a213436af7bc95804bdbf1c2a21d80e22953cbe9e096837ff1" +checksum = "b0857056ca4eb5de8c417309be42bcff6017b47e86fbaddde609b4633f66061e" dependencies = [ - "darling 0.13.4", + "darling 0.20.10", + "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.77", ] [[package]] @@ -8918,11 +9093,11 @@ dependencies = [ "criterion", "derivative", "eth2_interop_keypairs", - "ethereum-types 0.14.1", "ethereum_hashing", "ethereum_serde_utils", "ethereum_ssz", "ethereum_ssz_derive", + "fixed_bytes", "hex", "int_to_bytes", "itertools 0.10.5", @@ -8969,7 +9144,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ - "arbitrary", "byteorder", "crunchy", "hex", @@ -9020,15 +9194,15 @@ dependencies = [ [[package]] name = "unicode-properties" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291" +checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524" [[package]] name = "unicode-xid" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" [[package]] name = "universal-hash" @@ -9061,10 +9235,6 @@ name = "unsigned-varint" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" -dependencies = [ - "asynchronous-codec 0.6.2", - "bytes", -] [[package]] name = "unsigned-varint" @@ -9072,6 +9242,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06" dependencies = [ + "asynchronous-codec", "bytes", "tokio-util", ] @@ -9239,9 +9410,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "void" @@ -9294,7 +9465,7 @@ dependencies = [ "mime_guess", "percent-encoding", "pin-project", - "rustls-pemfile 2.1.2", + "rustls-pemfile 2.1.3", "scoped-tls", "serde", "serde_json", @@ -9339,34 +9510,35 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", @@ -9376,9 +9548,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -9386,22 +9558,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-streams" @@ -9467,9 +9639,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", @@ -9558,11 +9730,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -9638,6 +9810,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -9827,9 +10008,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.15" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "557404e450152cd6795bb558bca69e43c585055f4606e3bcae5894fc6dac9ba0" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] @@ -9855,7 +10036,7 @@ dependencies = [ "js-sys", "log", "pharos", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "send_wrapper", "thiserror", "wasm-bindgen", @@ -9909,9 +10090,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" +checksum = "539a77ee7c0de333dcc6da69b177380a0b81e0dacfa4f7344c465a36871ee601" [[package]] name = "xmltree" @@ -9979,6 +10160,7 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] @@ -9990,7 +10172,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -10010,7 +10192,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -10054,9 +10236,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.12+zstd.1.5.6" +version = "2.0.13+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index c696163387b..8c6aa308c1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,6 +52,7 @@ members = [ "database_manager", "consensus/int_to_bytes", + "consensus/fixed_bytes", "consensus/fork_choice", "consensus/proto_array", "consensus/safe_arith", @@ -94,9 +95,9 @@ resolver = "2" edition = "2021" [workspace.dependencies] -alloy-primitives = "0.7.7" +alloy-primitives = "0.8" alloy-rlp = "0.3.4" -alloy-consensus = "0.2.0" +alloy-consensus = "0.3.0" anyhow = "1" arbitrary = { version = "1", features = ["derive"] } async-channel = "1.9.0" @@ -118,11 +119,10 @@ rust_eth_kzg = "0.5.1" discv5 = { version = "0.4.1", features = ["libp2p"] } env_logger = "0.9" error-chain = "0.12" -ethereum-types = "0.14" -ethereum_hashing = "0.6.0" -ethereum_serde_utils = "0.5.2" -ethereum_ssz = "0.5" -ethereum_ssz_derive = "0.5" +ethereum_hashing = "0.7.0" +ethereum_serde_utils = "0.7" +ethereum_ssz = "0.7" +ethereum_ssz_derive = "0.7" ethers-core = "1" ethers-providers = { version = "1", default-features = false } exit-future = "0.2" @@ -137,7 +137,7 @@ libsecp256k1 = "0.7" log = "0.4" lru = "0.12" maplit = "1" -milhouse = "0.1" +milhouse = "0.3" num_cpus = "1" parking_lot = "0.12" paste = "1" @@ -163,7 +163,7 @@ slog-term = "2" sloggers = { version = "2", features = ["json"] } smallvec = { version = "1.11.2", features = ["arbitrary"] } snap = "1" -ssz_types = "0.6" +ssz_types = "0.8" strum = { version = "0.24", features = ["derive"] } superstruct = "0.8" syn = "1" @@ -177,8 +177,8 @@ tracing-appender = "0.2" tracing-core = "0.1" tracing-log = "0.2" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -tree_hash = "0.6" -tree_hash_derive = "0.6" +tree_hash = "0.8" +tree_hash_derive = "0.8" url = "2" uuid = { version = "0.8", features = ["serde", "v4"] } warp = { version = "0.3.7", default-features = false, features = ["tls"] } @@ -205,6 +205,7 @@ eth2_keystore = { path = "crypto/eth2_keystore" } eth2_network_config = { path = "common/eth2_network_config" } eth2_wallet = { path = "crypto/eth2_wallet" } execution_layer = { path = "beacon_node/execution_layer" } +fixed_bytes = { path = "consensus/fixed_bytes" } filesystem = { path = "common/filesystem" } fork_choice = { path = "consensus/fork_choice" } genesis = { path = "beacon_node/genesis" } @@ -240,11 +241,11 @@ validator_client = { path = "validator_client" } validator_dir = { path = "common/validator_dir" } warp_utils = { path = "common/warp_utils" } -[patch.crates-io] -quick-protobuf = { git = "https://github.com/sigp/quick-protobuf.git", rev = "681f413312404ab6e51f0b46f39b0075c6f4ebfd" } - [profile.maxperf] inherits = "release" lto = "fat" codegen-units = 1 incremental = false + +[patch.crates-io] +quick-protobuf = { git = "https://github.com/sigp/quick-protobuf.git", rev = "681f413312404ab6e51f0b46f39b0075c6f4ebfd" } diff --git a/beacon_node/beacon_chain/Cargo.toml b/beacon_node/beacon_chain/Cargo.toml index 5ad56cba55c..0dc941df90c 100644 --- a/beacon_node/beacon_chain/Cargo.toml +++ b/beacon_node/beacon_chain/Cargo.toml @@ -23,6 +23,7 @@ serde_json = { workspace = true } criterion = { workspace = true } [dependencies] +alloy-primitives = { workspace = true } bitvec = { workspace = true } bls = { workspace = true } derivative = { workspace = true } diff --git a/beacon_node/beacon_chain/src/attester_cache.rs b/beacon_node/beacon_chain/src/attester_cache.rs index b5012e8e4e4..7f356bd6211 100644 --- a/beacon_node/beacon_chain/src/attester_cache.rs +++ b/beacon_node/beacon_chain/src/attester_cache.rs @@ -19,8 +19,8 @@ use types::{ beacon_state::{ compute_committee_index_in_epoch, compute_committee_range_in_epoch, epoch_committee_count, }, - BeaconState, BeaconStateError, ChainSpec, Checkpoint, Epoch, EthSpec, Hash256, RelativeEpoch, - Slot, + BeaconState, BeaconStateError, ChainSpec, Checkpoint, Epoch, EthSpec, FixedBytesExtended, + Hash256, RelativeEpoch, Slot, }; type JustifiedCheckpoint = Checkpoint; diff --git a/beacon_node/beacon_chain/src/beacon_block_streamer.rs b/beacon_node/beacon_chain/src/beacon_block_streamer.rs index b68423422e9..0ce33f16891 100644 --- a/beacon_node/beacon_chain/src/beacon_block_streamer.rs +++ b/beacon_node/beacon_chain/src/beacon_block_streamer.rs @@ -715,7 +715,9 @@ mod tests { use std::sync::LazyLock; use std::time::Duration; use tokio::sync::mpsc; - use types::{ChainSpec, Epoch, EthSpec, Hash256, Keypair, MinimalEthSpec, Slot}; + use types::{ + ChainSpec, Epoch, EthSpec, FixedBytesExtended, Hash256, Keypair, MinimalEthSpec, Slot, + }; const VALIDATOR_COUNT: usize = 48; diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 2785eac0a44..854055cad73 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -134,10 +134,10 @@ pub type ForkChoiceError = fork_choice::Error; type HashBlockTuple = (Hash256, RpcBlock); // These keys are all zero because they get stored in different columns, see `DBColumn` type. -pub const BEACON_CHAIN_DB_KEY: Hash256 = Hash256::zero(); -pub const OP_POOL_DB_KEY: Hash256 = Hash256::zero(); -pub const ETH1_CACHE_DB_KEY: Hash256 = Hash256::zero(); -pub const FORK_CHOICE_DB_KEY: Hash256 = Hash256::zero(); +pub const BEACON_CHAIN_DB_KEY: Hash256 = Hash256::ZERO; +pub const OP_POOL_DB_KEY: Hash256 = Hash256::ZERO; +pub const ETH1_CACHE_DB_KEY: Hash256 = Hash256::ZERO; +pub const FORK_CHOICE_DB_KEY: Hash256 = Hash256::ZERO; /// Defines how old a block can be before it's no longer a candidate for the early attester cache. const EARLY_ATTESTER_CACHE_HISTORIC_SLOTS: u64 = 4; @@ -206,7 +206,7 @@ impl TryInto for AvailabilityProcessingStatus { } /// The result of a chain segment processing. -pub enum ChainSegmentResult { +pub enum ChainSegmentResult { /// Processing this chain segment finished successfully. Successful { imported_blocks: Vec<(Hash256, Slot)>, @@ -215,7 +215,7 @@ pub enum ChainSegmentResult { /// have been imported. Failed { imported_blocks: Vec<(Hash256, Slot)>, - error: BlockError, + error: BlockError, }, } @@ -528,7 +528,7 @@ impl BeaconBlockResponseWrapper { } pub fn consensus_block_value_wei(&self) -> Uint256 { - Uint256::from(self.consensus_block_value_gwei()) * 1_000_000_000 + Uint256::from(self.consensus_block_value_gwei()) * Uint256::from(1_000_000_000) } pub fn is_blinded(&self) -> bool { @@ -2159,7 +2159,7 @@ impl BeaconChain { self: &Arc, blob_sidecar: Arc>, subnet_id: u64, - ) -> Result, GossipBlobError> { + ) -> Result, GossipBlobError> { metrics::inc_counter(&metrics::BLOBS_SIDECAR_PROCESSING_REQUESTS); let _timer = metrics::start_timer(&metrics::BLOBS_SIDECAR_GOSSIP_VERIFICATION_TIMES); GossipVerifiedBlob::new(blob_sidecar, subnet_id, self).map(|v| { @@ -2698,7 +2698,7 @@ impl BeaconChain { pub fn filter_chain_segment( self: &Arc, chain_segment: Vec>, - ) -> Result>, ChainSegmentResult> { + ) -> Result>, ChainSegmentResult> { // This function will never import any blocks. let imported_blocks = vec![]; let mut filtered_chain_segment = Vec::with_capacity(chain_segment.len()); @@ -2805,7 +2805,7 @@ impl BeaconChain { self: &Arc, chain_segment: Vec>, notify_execution_layer: NotifyExecutionLayer, - ) -> ChainSegmentResult { + ) -> ChainSegmentResult { let mut imported_blocks = vec![]; // Filter uninteresting blocks from the chain segment in a blocking task. @@ -2938,7 +2938,7 @@ impl BeaconChain { pub async fn verify_block_for_gossip( self: &Arc, block: Arc>, - ) -> Result, BlockError> { + ) -> Result, BlockError> { let chain = self.clone(); self.task_executor .clone() @@ -2986,7 +2986,7 @@ impl BeaconChain { pub async fn process_gossip_blob( self: &Arc, blob: GossipVerifiedBlob, - ) -> Result> { + ) -> Result { let block_root = blob.block_root(); // If this block has already been imported to forkchoice it must have been available, so @@ -3026,7 +3026,7 @@ impl BeaconChain { AvailabilityProcessingStatus, DataColumnsToPublish, ), - BlockError, + BlockError, > { let Ok((slot, block_root)) = data_columns .iter() @@ -3062,7 +3062,7 @@ impl BeaconChain { slot: Slot, block_root: Hash256, blobs: FixedBlobSidecarList, - ) -> Result> { + ) -> Result { // If this block has already been imported to forkchoice it must have been available, so // we don't need to process its blobs again. if self @@ -3099,7 +3099,7 @@ impl BeaconChain { AvailabilityProcessingStatus, DataColumnsToPublish, ), - BlockError, + BlockError, > { let Ok((slot, block_root)) = custody_columns .iter() @@ -3133,8 +3133,8 @@ impl BeaconChain { fn remove_notified( &self, block_root: &Hash256, - r: Result>, - ) -> Result> { + r: Result, + ) -> Result { let has_missing_components = matches!(r, Ok(AvailabilityProcessingStatus::MissingComponents(_, _))); if !has_missing_components { @@ -3148,8 +3148,8 @@ impl BeaconChain { fn remove_notified_custody_columns

( &self, block_root: &Hash256, - r: Result<(AvailabilityProcessingStatus, P), BlockError>, - ) -> Result<(AvailabilityProcessingStatus, P), BlockError> { + r: Result<(AvailabilityProcessingStatus, P), BlockError>, + ) -> Result<(AvailabilityProcessingStatus, P), BlockError> { let has_missing_components = matches!( r, Ok((AvailabilityProcessingStatus::MissingComponents(_, _), _)) @@ -3168,7 +3168,7 @@ impl BeaconChain { unverified_block: B, block_source: BlockImportSource, notify_execution_layer: NotifyExecutionLayer, - ) -> Result> { + ) -> Result { self.reqresp_pre_import_cache .write() .insert(block_root, unverified_block.block_cloned()); @@ -3204,8 +3204,8 @@ impl BeaconChain { unverified_block: B, notify_execution_layer: NotifyExecutionLayer, block_source: BlockImportSource, - publish_fn: impl FnOnce() -> Result<(), BlockError> + Send + 'static, - ) -> Result> { + publish_fn: impl FnOnce() -> Result<(), BlockError> + Send + 'static, + ) -> Result { // Start the Prometheus timer. let _full_timer = metrics::start_timer(&metrics::BLOCK_PROCESSING_TIMES); @@ -3326,7 +3326,7 @@ impl BeaconChain { pub async fn into_executed_block( self: Arc, execution_pending_block: ExecutionPendingBlock, - ) -> Result, BlockError> { + ) -> Result, BlockError> { let ExecutionPendingBlock { block, import_data, @@ -3381,7 +3381,7 @@ impl BeaconChain { async fn check_block_availability_and_import( self: &Arc, block: AvailabilityPendingExecutedBlock, - ) -> Result> { + ) -> Result { let slot = block.block.slot(); let availability = self .data_availability_checker @@ -3394,7 +3394,7 @@ impl BeaconChain { async fn check_gossip_blob_availability_and_import( self: &Arc, blob: GossipVerifiedBlob, - ) -> Result> { + ) -> Result { let slot = blob.slot(); if let Some(slasher) = self.slasher.as_ref() { slasher.accept_block_header(blob.signed_block_header()); @@ -3416,7 +3416,7 @@ impl BeaconChain { AvailabilityProcessingStatus, DataColumnsToPublish, ), - BlockError, + BlockError, > { if let Some(slasher) = self.slasher.as_ref() { for data_colum in &data_columns { @@ -3440,17 +3440,17 @@ impl BeaconChain { slot: Slot, block_root: Hash256, blobs: FixedBlobSidecarList, - ) -> Result> { + ) -> Result { // Need to scope this to ensure the lock is dropped before calling `process_availability` // Even an explicit drop is not enough to convince the borrow checker. { let mut slashable_cache = self.observed_slashable.write(); for header in blobs - .into_iter() + .iter() .filter_map(|b| b.as_ref().map(|b| b.signed_block_header.clone())) .unique() { - if verify_header_signature::>(self, &header).is_ok() { + if verify_header_signature::(self, &header).is_ok() { slashable_cache .observe_slashable( header.message.slot, @@ -3484,7 +3484,7 @@ impl BeaconChain { AvailabilityProcessingStatus, DataColumnsToPublish, ), - BlockError, + BlockError, > { // Need to scope this to ensure the lock is dropped before calling `process_availability` // Even an explicit drop is not enough to convince the borrow checker. @@ -3493,7 +3493,7 @@ impl BeaconChain { // Assumes all items in custody_columns are for the same block_root if let Some(column) = custody_columns.first() { let header = &column.signed_block_header; - if verify_header_signature::>(self, header).is_ok() { + if verify_header_signature::(self, header).is_ok() { slashable_cache .observe_slashable( header.message.slot, @@ -3530,7 +3530,7 @@ impl BeaconChain { self: &Arc, slot: Slot, availability: Availability, - ) -> Result> { + ) -> Result { match availability { Availability::Available(block) => { // Block is fully available, import into fork choice @@ -3545,7 +3545,7 @@ impl BeaconChain { pub async fn import_available_block( self: &Arc, block: Box>, - ) -> Result> { + ) -> Result { let AvailableExecutedBlock { block, import_data, @@ -3624,7 +3624,7 @@ impl BeaconChain { parent_block: SignedBlindedBeaconBlock, parent_eth1_finalization_data: Eth1FinalizationData, mut consensus_context: ConsensusContext, - ) -> Result> { + ) -> Result { // ----------------------------- BLOCK NOT YET ATTESTABLE ---------------------------------- // Everything in this initial section is on the hot path between processing the block and // being able to attest to it. DO NOT add any extra processing in this initial section @@ -3934,7 +3934,7 @@ impl BeaconChain { block: BeaconBlockRef, block_root: Hash256, state: &BeaconState, - ) -> Result<(), BlockError> { + ) -> Result<(), BlockError> { // Only perform the weak subjectivity check if it was configured. let Some(wss_checkpoint) = self.config.weak_subjectivity_checkpoint else { return Ok(()); @@ -4269,7 +4269,7 @@ impl BeaconChain { &self, block_root: Hash256, state: &mut BeaconState, - ) -> Result<(), BlockError> { + ) -> Result<(), BlockError> { for relative_epoch in [RelativeEpoch::Current, RelativeEpoch::Next] { let shuffling_id = AttestationShufflingId::new(block_root, state, relative_epoch)?; @@ -5425,7 +5425,7 @@ impl BeaconChain { }, }), None, - Uint256::zero(), + Uint256::ZERO, ), BeaconState::Altair(_) => ( BeaconBlock::Altair(BeaconBlockAltair { @@ -5448,7 +5448,7 @@ impl BeaconChain { }, }), None, - Uint256::zero(), + Uint256::ZERO, ), BeaconState::Bellatrix(_) => { let block_proposal_contents = @@ -7042,8 +7042,8 @@ impl From for Error { } } -impl ChainSegmentResult { - pub fn into_block_error(self) -> Result<(), BlockError> { +impl ChainSegmentResult { + pub fn into_block_error(self) -> Result<(), BlockError> { match self { ChainSegmentResult::Failed { error, .. } => Err(error), ChainSegmentResult::Successful { .. } => Ok(()), diff --git a/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs b/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs index f746b68996f..a6aedda19d0 100644 --- a/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs +++ b/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs @@ -17,7 +17,7 @@ use store::{Error as StoreError, HotColdDB, ItemStore}; use superstruct::superstruct; use types::{ AbstractExecPayload, BeaconBlockRef, BeaconState, BeaconStateError, Checkpoint, Epoch, EthSpec, - Hash256, Slot, + FixedBytesExtended, Hash256, Slot, }; #[derive(Debug)] diff --git a/beacon_node/beacon_chain/src/bellatrix_readiness.rs b/beacon_node/beacon_chain/src/bellatrix_readiness.rs index 60b1abaf098..c2e387c422f 100644 --- a/beacon_node/beacon_chain/src/bellatrix_readiness.rs +++ b/beacon_node/beacon_chain/src/bellatrix_readiness.rs @@ -64,7 +64,7 @@ impl MergeConfig { /// Instantiate `self` from the values in a `ChainSpec`. pub fn from_chainspec(spec: &ChainSpec) -> Self { let mut params = MergeConfig::default(); - if spec.terminal_total_difficulty != Uint256::max_value() { + if spec.terminal_total_difficulty != Uint256::MAX { params.terminal_total_difficulty = Some(spec.terminal_total_difficulty); } if spec.terminal_block_hash != ExecutionBlockHash::zero() { diff --git a/beacon_node/beacon_chain/src/blob_verification.rs b/beacon_node/beacon_chain/src/blob_verification.rs index ceeb32427e6..358c4c8acf2 100644 --- a/beacon_node/beacon_chain/src/blob_verification.rs +++ b/beacon_node/beacon_chain/src/blob_verification.rs @@ -22,7 +22,7 @@ use types::{ /// An error occurred while validating a gossip blob. #[derive(Debug)] -pub enum GossipBlobError { +pub enum GossipBlobError { /// The blob sidecar is from a slot that is later than the current slot (with respect to the /// gossip clock disparity). /// @@ -95,7 +95,7 @@ pub enum GossipBlobError { /// ## Peer scoring /// /// We cannot process the blob without validating its parent, the peer isn't necessarily faulty. - BlobParentUnknown(Arc>), + BlobParentUnknown { parent_root: Hash256 }, /// Invalid kzg commitment inclusion proof /// ## Peer scoring @@ -145,28 +145,19 @@ pub enum GossipBlobError { NotFinalizedDescendant { block_parent_root: Hash256 }, } -impl std::fmt::Display for GossipBlobError { +impl std::fmt::Display for GossipBlobError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - GossipBlobError::BlobParentUnknown(blob_sidecar) => { - write!( - f, - "BlobParentUnknown(parent_root:{})", - blob_sidecar.block_parent_root() - ) - } - other => write!(f, "{:?}", other), - } + write!(f, "{:?}", self) } } -impl From for GossipBlobError { +impl From for GossipBlobError { fn from(e: BeaconChainError) -> Self { GossipBlobError::BeaconChainError(e) } } -impl From for GossipBlobError { +impl From for GossipBlobError { fn from(e: BeaconStateError) -> Self { GossipBlobError::BeaconChainError(BeaconChainError::BeaconStateError(e)) } @@ -187,12 +178,12 @@ impl GossipVerifiedBlob { blob: Arc>, subnet_id: u64, chain: &BeaconChain, - ) -> Result> { + ) -> Result { let header = blob.signed_block_header.clone(); // We only process slashing info if the gossip verification failed // since we do not process the blob any further in that case. validate_blob_sidecar_for_gossip(blob, subnet_id, chain).map_err(|e| { - process_block_slash_info::<_, GossipBlobError>( + process_block_slash_info::<_, GossipBlobError>( chain, BlockSlashInfo::from_early_error_blob(header, e), ) @@ -381,7 +372,7 @@ pub fn validate_blob_sidecar_for_gossip( blob_sidecar: Arc>, subnet: u64, chain: &BeaconChain, -) -> Result, GossipBlobError> { +) -> Result, GossipBlobError> { let blob_slot = blob_sidecar.slot(); let blob_index = blob_sidecar.index; let block_parent_root = blob_sidecar.block_parent_root(); @@ -463,7 +454,9 @@ pub fn validate_blob_sidecar_for_gossip( // We have already verified that the blob is past finalization, so we can // just check fork choice for the block's parent. let Some(parent_block) = fork_choice.get_block(&block_parent_root) else { - return Err(GossipBlobError::BlobParentUnknown(blob_sidecar)); + return Err(GossipBlobError::BlobParentUnknown { + parent_root: block_parent_root, + }); }; // Do not process a blob that does not descend from the finalized root. @@ -513,7 +506,7 @@ pub fn validate_blob_sidecar_for_gossip( )) })?; - let state = cheap_state_advance_to_obtain_committees::<_, GossipBlobError>( + let state = cheap_state_advance_to_obtain_committees::<_, GossipBlobError>( &mut parent_state, Some(parent_state_root), blob_slot, diff --git a/beacon_node/beacon_chain/src/block_times_cache.rs b/beacon_node/beacon_chain/src/block_times_cache.rs index 3b75046f3a4..af122ccdc06 100644 --- a/beacon_node/beacon_chain/src/block_times_cache.rs +++ b/beacon_node/beacon_chain/src/block_times_cache.rs @@ -294,6 +294,7 @@ impl BlockTimesCache { #[cfg(test)] mod test { use super::*; + use types::FixedBytesExtended; #[test] fn observed_time_uses_minimum() { diff --git a/beacon_node/beacon_chain/src/block_verification.rs b/beacon_node/beacon_chain/src/block_verification.rs index ef3e3363364..603e11c4696 100644 --- a/beacon_node/beacon_chain/src/block_verification.rs +++ b/beacon_node/beacon_chain/src/block_verification.rs @@ -143,14 +143,14 @@ const WRITE_BLOCK_PROCESSING_SSZ: bool = cfg!(feature = "write_ssz_files"); /// - The block is malformed/invalid (indicated by all results other than `BeaconChainError`. /// - We encountered an error whilst trying to verify the block (a `BeaconChainError`). #[derive(Debug)] -pub enum BlockError { +pub enum BlockError { /// The parent block was unknown. /// /// ## Peer scoring /// /// It's unclear if this block is valid, but it cannot be processed without already knowing /// its parent. - ParentUnknown(RpcBlock), + ParentUnknown { parent_root: Hash256 }, /// The block slot is greater than the present slot. /// /// ## Peer scoring @@ -327,7 +327,7 @@ pub enum BlockError { InternalError(String), } -impl From for BlockError { +impl From for BlockError { fn from(e: AvailabilityCheckError) -> Self { Self::AvailabilityCheck(e) } @@ -435,30 +435,25 @@ impl From for ExecutionPayloadError { } } -impl From for BlockError { +impl From for BlockError { fn from(e: ExecutionPayloadError) -> Self { BlockError::ExecutionPayloadError(e) } } -impl From for BlockError { +impl From for BlockError { fn from(e: InconsistentFork) -> Self { BlockError::InconsistentFork(e) } } -impl std::fmt::Display for BlockError { +impl std::fmt::Display for BlockError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - BlockError::ParentUnknown(block) => { - write!(f, "ParentUnknown(parent_root:{})", block.parent_root()) - } - other => write!(f, "{:?}", other), - } + write!(f, "{:?}", self) } } -impl From for BlockError { +impl From for BlockError { fn from(e: BlockSignatureVerifierError) -> Self { match e { // Make a special distinction for `IncorrectBlockProposer` since it indicates an @@ -475,31 +470,31 @@ impl From for BlockError { } } -impl From for BlockError { +impl From for BlockError { fn from(e: BeaconChainError) -> Self { BlockError::BeaconChainError(e) } } -impl From for BlockError { +impl From for BlockError { fn from(e: BeaconStateError) -> Self { BlockError::BeaconChainError(BeaconChainError::BeaconStateError(e)) } } -impl From for BlockError { +impl From for BlockError { fn from(e: SlotProcessingError) -> Self { BlockError::BeaconChainError(BeaconChainError::SlotProcessingError(e)) } } -impl From for BlockError { +impl From for BlockError { fn from(e: DBError) -> Self { BlockError::BeaconChainError(BeaconChainError::DBError(e)) } } -impl From for BlockError { +impl From for BlockError { fn from(e: ArithError) -> Self { BlockError::BeaconChainError(BeaconChainError::ArithError(e)) } @@ -523,8 +518,8 @@ pub enum BlockSlashInfo { SignatureValid(SignedBeaconBlockHeader, TErr), } -impl BlockSlashInfo> { - pub fn from_early_error_block(header: SignedBeaconBlockHeader, e: BlockError) -> Self { +impl BlockSlashInfo { + pub fn from_early_error_block(header: SignedBeaconBlockHeader, e: BlockError) -> Self { match e { BlockError::ProposalSignatureInvalid => BlockSlashInfo::SignatureInvalid(e), // `InvalidSignature` could indicate any signature in the block, so we want @@ -534,8 +529,8 @@ impl BlockSlashInfo> { } } -impl BlockSlashInfo> { - pub fn from_early_error_blob(header: SignedBeaconBlockHeader, e: GossipBlobError) -> Self { +impl BlockSlashInfo { + pub fn from_early_error_blob(header: SignedBeaconBlockHeader, e: GossipBlobError) -> Self { match e { GossipBlobError::ProposalSignatureInvalid => BlockSlashInfo::SignatureInvalid(e), // `InvalidSignature` could indicate any signature in the block, so we want @@ -603,7 +598,7 @@ pub(crate) fn process_block_slash_info( mut chain_segment: Vec<(Hash256, RpcBlock)>, chain: &BeaconChain, -) -> Result>, BlockError> { +) -> Result>, BlockError> { if chain_segment.is_empty() { return Ok(vec![]); } @@ -618,7 +613,7 @@ pub fn signature_verify_chain_segment( .map(|(_, block)| block.slot()) .unwrap_or_else(|| slot); - let state = cheap_state_advance_to_obtain_committees::<_, BlockError>( + let state = cheap_state_advance_to_obtain_committees::<_, BlockError>( &mut parent.pre_state, parent.beacon_state_root, highest_slot, @@ -688,8 +683,7 @@ pub struct SignatureVerifiedBlock { } /// Used to await the result of executing payload with a remote EE. -type PayloadVerificationHandle = - JoinHandle>>>; +type PayloadVerificationHandle = JoinHandle>>; /// A wrapper around a `SignedBeaconBlock` that indicates that this block is fully verified and /// ready to import into the `BeaconChain`. The validation includes: @@ -705,14 +699,14 @@ type PayloadVerificationHandle = pub struct ExecutionPendingBlock { pub block: MaybeAvailableBlock, pub import_data: BlockImportData, - pub payload_verification_handle: PayloadVerificationHandle, + pub payload_verification_handle: PayloadVerificationHandle, } pub trait IntoGossipVerifiedBlockContents: Sized { fn into_gossip_verified_block( self, chain: &BeaconChain, - ) -> Result, BlockContentsError>; + ) -> Result, BlockContentsError>; fn inner_block(&self) -> &SignedBeaconBlock; } @@ -720,7 +714,7 @@ impl IntoGossipVerifiedBlockContents for GossipVerifiedB fn into_gossip_verified_block( self, _chain: &BeaconChain, - ) -> Result, BlockContentsError> { + ) -> Result, BlockContentsError> { Ok(self) } fn inner_block(&self) -> &SignedBeaconBlock { @@ -732,7 +726,7 @@ impl IntoGossipVerifiedBlockContents for PublishBlockReq fn into_gossip_verified_block( self, chain: &BeaconChain, - ) -> Result, BlockContentsError> { + ) -> Result, BlockContentsError> { let (block, blobs) = self.deconstruct(); let peer_das_enabled = chain.spec.is_peer_das_enabled_for_epoch(block.epoch()); @@ -764,7 +758,7 @@ fn build_gossip_verified_blobs( chain: &BeaconChain, block: &Arc>>, blobs: Option<(KzgProofs, BlobsList)>, -) -> Result>, BlockContentsError> { +) -> Result>, BlockContentsError> { blobs .map(|(kzg_proofs, blobs)| { let mut gossip_verified_blobs = vec![]; @@ -781,7 +775,7 @@ fn build_gossip_verified_blobs( let max_len = chain.spec.max_blobs_per_block(block.epoch()) as usize; let gossip_verified_blobs = RuntimeVariableList::from_vec(gossip_verified_blobs, max_len); - Ok::<_, BlockContentsError>(gossip_verified_blobs) + Ok::<_, BlockContentsError>(gossip_verified_blobs) }) .transpose() } @@ -790,7 +784,7 @@ fn build_gossip_verified_data_columns( chain: &BeaconChain, block: &SignedBeaconBlock>, blobs: Option>, -) -> Result>, BlockContentsError> { +) -> Result>, BlockContentsError> { blobs // Only attempt to build data columns if blobs is non empty to avoid skewing the metrics. .filter(|b| !b.is_empty()) @@ -820,7 +814,7 @@ fn build_gossip_verified_data_columns( chain.spec.number_of_columns, ) .map_err(DataColumnSidecarError::SszError)?; - Ok::<_, BlockContentsError>(gossip_verified_data_columns) + Ok::<_, BlockContentsError>(gossip_verified_data_columns) }) .transpose() } @@ -834,7 +828,7 @@ pub trait IntoExecutionPendingBlock: Sized { block_root: Hash256, chain: &Arc>, notify_execution_layer: NotifyExecutionLayer, - ) -> Result, BlockError> { + ) -> Result, BlockError> { self.into_execution_pending_block_slashable(block_root, chain, notify_execution_layer) .map(|execution_pending| { // Supply valid block to slasher. @@ -843,9 +837,7 @@ pub trait IntoExecutionPendingBlock: Sized { } execution_pending }) - .map_err(|slash_info| { - process_block_slash_info::<_, BlockError>(chain, slash_info) - }) + .map_err(|slash_info| process_block_slash_info::<_, BlockError>(chain, slash_info)) } /// Convert the block to fully-verified form while producing data to aid checking slashability. @@ -854,7 +846,7 @@ pub trait IntoExecutionPendingBlock: Sized { block_root: Hash256, chain: &Arc>, notify_execution_layer: NotifyExecutionLayer, - ) -> Result, BlockSlashInfo>>; + ) -> Result, BlockSlashInfo>; fn block(&self) -> &SignedBeaconBlock; fn block_cloned(&self) -> Arc>; @@ -868,7 +860,7 @@ impl GossipVerifiedBlock { pub fn new( block: Arc>, chain: &BeaconChain, - ) -> Result> { + ) -> Result { // If the block is valid for gossip we don't supply it to the slasher here because // we assume it will be transformed into a fully verified block. We *do* need to supply // it to the slasher if an error occurs, because that's the end of this block's journey, @@ -878,7 +870,7 @@ impl GossipVerifiedBlock { // but it's way quicker to calculate root of the header since the hash of the tree rooted // at `BeaconBlockBody` is already computed in the header. Self::new_without_slasher_checks(block, &header, chain).map_err(|e| { - process_block_slash_info::<_, BlockError>( + process_block_slash_info::<_, BlockError>( chain, BlockSlashInfo::from_early_error_block(header, e), ) @@ -890,7 +882,7 @@ impl GossipVerifiedBlock { block: Arc>, block_header: &SignedBeaconBlockHeader, chain: &BeaconChain, - ) -> Result> { + ) -> Result { // Ensure the block is the correct structure for the fork at `block.slot()`. block .fork_name(&chain.spec) @@ -939,7 +931,7 @@ impl GossipVerifiedBlock { let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch()); let (parent_block, block) = - verify_parent_block_is_known::(block_root, &fork_choice_read_lock, block)?; + verify_parent_block_is_known::(&fork_choice_read_lock, block)?; drop(fork_choice_read_lock); // Track the number of skip slots between the block and its parent. @@ -999,7 +991,7 @@ impl GossipVerifiedBlock { ); // The state produced is only valid for determining proposer/attester shuffling indices. - let state = cheap_state_advance_to_obtain_committees::<_, BlockError>( + let state = cheap_state_advance_to_obtain_committees::<_, BlockError>( &mut parent.pre_state, parent.beacon_state_root, block.slot(), @@ -1108,7 +1100,7 @@ impl IntoExecutionPendingBlock for GossipVerifiedBlock>, notify_execution_layer: NotifyExecutionLayer, - ) -> Result, BlockSlashInfo>> { + ) -> Result, BlockSlashInfo> { let execution_pending = SignatureVerifiedBlock::from_gossip_verified_block_check_slashable(self, chain)?; execution_pending.into_execution_pending_block_slashable( @@ -1136,7 +1128,7 @@ impl SignatureVerifiedBlock { block: MaybeAvailableBlock, block_root: Hash256, chain: &BeaconChain, - ) -> Result> { + ) -> Result { // Ensure the block is the correct structure for the fork at `block.slot()`. block .as_block() @@ -1148,7 +1140,7 @@ impl SignatureVerifiedBlock { let (mut parent, block) = load_parent(block, chain)?; - let state = cheap_state_advance_to_obtain_committees::<_, BlockError>( + let state = cheap_state_advance_to_obtain_committees::<_, BlockError>( &mut parent.pre_state, parent.beacon_state_root, block.slot(), @@ -1181,7 +1173,7 @@ impl SignatureVerifiedBlock { block: MaybeAvailableBlock, block_root: Hash256, chain: &BeaconChain, - ) -> Result>> { + ) -> Result> { let header = block.signed_block_header(); Self::new(block, block_root, chain) .map_err(|e| BlockSlashInfo::from_early_error_block(header, e)) @@ -1192,14 +1184,14 @@ impl SignatureVerifiedBlock { pub fn from_gossip_verified_block( from: GossipVerifiedBlock, chain: &BeaconChain, - ) -> Result> { + ) -> Result { let (mut parent, block) = if let Some(parent) = from.parent { (parent, from.block) } else { load_parent(from.block, chain)? }; - let state = cheap_state_advance_to_obtain_committees::<_, BlockError>( + let state = cheap_state_advance_to_obtain_committees::<_, BlockError>( &mut parent.pre_state, parent.beacon_state_root, block.slot(), @@ -1235,7 +1227,7 @@ impl SignatureVerifiedBlock { pub fn from_gossip_verified_block_check_slashable( from: GossipVerifiedBlock, chain: &BeaconChain, - ) -> Result>> { + ) -> Result> { let header = from.block.signed_block_header(); Self::from_gossip_verified_block(from, chain) .map_err(|e| BlockSlashInfo::from_early_error_block(header, e)) @@ -1257,7 +1249,7 @@ impl IntoExecutionPendingBlock for SignatureVerifiedBloc block_root: Hash256, chain: &Arc>, notify_execution_layer: NotifyExecutionLayer, - ) -> Result, BlockSlashInfo>> { + ) -> Result, BlockSlashInfo> { let header = self.block.signed_block_header(); let (parent, block) = if let Some(parent) = self.parent { (parent, self.block) @@ -1294,7 +1286,7 @@ impl IntoExecutionPendingBlock for Arc>, notify_execution_layer: NotifyExecutionLayer, - ) -> Result, BlockSlashInfo>> { + ) -> Result, BlockSlashInfo> { // Perform an early check to prevent wasting time on irrelevant blocks. let block_root = check_block_relevancy(&self, block_root, chain) .map_err(|e| BlockSlashInfo::SignatureNotChecked(self.signed_block_header(), e))?; @@ -1328,7 +1320,7 @@ impl IntoExecutionPendingBlock for RpcBlock block_root: Hash256, chain: &Arc>, notify_execution_layer: NotifyExecutionLayer, - ) -> Result, BlockSlashInfo>> { + ) -> Result, BlockSlashInfo> { // Perform an early check to prevent wasting time on irrelevant blocks. let block_root = check_block_relevancy(self.as_block(), block_root, chain) .map_err(|e| BlockSlashInfo::SignatureNotChecked(self.signed_block_header(), e))?; @@ -1369,7 +1361,7 @@ impl ExecutionPendingBlock { mut consensus_context: ConsensusContext, chain: &Arc>, notify_execution_layer: NotifyExecutionLayer, - ) -> Result> { + ) -> Result { chain .observed_slashable .write() @@ -1405,7 +1397,9 @@ impl ExecutionPendingBlock { // because it will revert finalization. Note that the finalized block is stored in fork // choice, so we will not reject any child of the finalized block (this is relevant during // genesis). - return Err(BlockError::ParentUnknown(block.into_rpc_block())); + return Err(BlockError::ParentUnknown { + parent_root: block.parent_root(), + }); } /* @@ -1782,7 +1776,7 @@ impl ExecutionPendingBlock { fn check_block_against_anchor_slot( block: BeaconBlockRef<'_, T::EthSpec>, chain: &BeaconChain, -) -> Result<(), BlockError> { +) -> Result<(), BlockError> { if let Some(anchor_slot) = chain.store.get_anchor_slot() { if block.slot() <= anchor_slot { return Err(BlockError::WeakSubjectivityConflict); @@ -1799,7 +1793,7 @@ fn check_block_against_finalized_slot( block: BeaconBlockRef<'_, T::EthSpec>, block_root: Hash256, chain: &BeaconChain, -) -> Result<(), BlockError> { +) -> Result<(), BlockError> { // The finalized checkpoint is being read from fork choice, rather than the cached head. // // Fork choice has the most up-to-date view of finalization and there's no point importing a @@ -1834,7 +1828,7 @@ pub fn check_block_is_finalized_checkpoint_or_descendant< chain: &BeaconChain, fork_choice: &BeaconForkChoice, block: B, -) -> Result> { +) -> Result { if fork_choice.is_finalized_checkpoint_or_descendant(block.parent_root()) { Ok(block) } else { @@ -1855,7 +1849,9 @@ pub fn check_block_is_finalized_checkpoint_or_descendant< block_parent_root: block.parent_root(), }) } else { - Err(BlockError::ParentUnknown(block.into_rpc_block())) + Err(BlockError::ParentUnknown { + parent_root: block.parent_root(), + }) } } } @@ -1871,7 +1867,7 @@ pub fn check_block_relevancy( signed_block: &SignedBeaconBlock, block_root: Hash256, chain: &BeaconChain, -) -> Result> { +) -> Result { let block = signed_block.message(); // Do not process blocks from the future. @@ -1939,17 +1935,15 @@ pub fn get_block_header_root(block_header: &SignedBeaconBlockHeader) -> Hash256 /// fork choice. #[allow(clippy::type_complexity)] fn verify_parent_block_is_known( - block_root: Hash256, fork_choice_read_lock: &RwLockReadGuard>, block: Arc>, -) -> Result<(ProtoBlock, Arc>), BlockError> { +) -> Result<(ProtoBlock, Arc>), BlockError> { if let Some(proto_block) = fork_choice_read_lock.get_block(&block.parent_root()) { Ok((proto_block, block)) } else { - Err(BlockError::ParentUnknown(RpcBlock::new_without_blobs( - Some(block_root), - block, - ))) + Err(BlockError::ParentUnknown { + parent_root: block.parent_root(), + }) } } @@ -1961,7 +1955,7 @@ fn verify_parent_block_is_known( fn load_parent>( block: B, chain: &BeaconChain, -) -> Result<(PreProcessingSnapshot, B), BlockError> { +) -> Result<(PreProcessingSnapshot, B), BlockError> { // Reject any block if its parent is not known to fork choice. // // A block that is not in fork choice is either: @@ -1977,7 +1971,9 @@ fn load_parent>( .fork_choice_read_lock() .contains_block(&block.parent_root()) { - return Err(BlockError::ParentUnknown(block.into_rpc_block())); + return Err(BlockError::ParentUnknown { + parent_root: block.parent_root(), + }); } let db_read_timer = metrics::start_timer(&metrics::BLOCK_PROCESSING_DB_READ); @@ -2073,7 +2069,7 @@ pub trait BlockBlobError: From + From + Debu fn proposer_signature_invalid() -> Self; } -impl BlockBlobError for BlockError { +impl BlockBlobError for BlockError { fn not_later_than_parent_error(block_slot: Slot, parent_slot: Slot) -> Self { BlockError::BlockIsNotLaterThanParent { block_slot, @@ -2090,7 +2086,7 @@ impl BlockBlobError for BlockError { } } -impl BlockBlobError for GossipBlobError { +impl BlockBlobError for GossipBlobError { fn not_later_than_parent_error(blob_slot: Slot, parent_slot: Slot) -> Self { GossipBlobError::BlobIsNotLaterThanParent { blob_slot, diff --git a/beacon_node/beacon_chain/src/block_verification_types.rs b/beacon_node/beacon_chain/src/block_verification_types.rs index 00442ff9668..68ddbf1a42c 100644 --- a/beacon_node/beacon_chain/src/block_verification_types.rs +++ b/beacon_node/beacon_chain/src/block_verification_types.rs @@ -379,39 +379,39 @@ pub type GossipVerifiedBlockContents = ( ); #[derive(Debug)] -pub enum BlockContentsError { - BlockError(BlockError), - BlobError(GossipBlobError), +pub enum BlockContentsError { + BlockError(BlockError), + BlobError(GossipBlobError), BlobSidecarError(blob_sidecar::BlobSidecarError), DataColumnError(GossipDataColumnError), DataColumnSidecarError(data_column_sidecar::DataColumnSidecarError), } -impl From> for BlockContentsError { - fn from(value: BlockError) -> Self { +impl From for BlockContentsError { + fn from(value: BlockError) -> Self { Self::BlockError(value) } } -impl From> for BlockContentsError { - fn from(value: GossipBlobError) -> Self { +impl From for BlockContentsError { + fn from(value: GossipBlobError) -> Self { Self::BlobError(value) } } -impl From for BlockContentsError { +impl From for BlockContentsError { fn from(value: GossipDataColumnError) -> Self { Self::DataColumnError(value) } } -impl From for BlockContentsError { +impl From for BlockContentsError { fn from(value: data_column_sidecar::DataColumnSidecarError) -> Self { Self::DataColumnSidecarError(value) } } -impl std::fmt::Display for BlockContentsError { +impl std::fmt::Display for BlockContentsError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { BlockContentsError::BlockError(err) => { @@ -444,7 +444,6 @@ pub trait AsBlock { fn as_block(&self) -> &SignedBeaconBlock; fn block_cloned(&self) -> Arc>; fn canonical_root(&self) -> Hash256; - fn into_rpc_block(self) -> RpcBlock; } impl AsBlock for Arc> { @@ -483,10 +482,6 @@ impl AsBlock for Arc> { fn canonical_root(&self) -> Hash256 { SignedBeaconBlock::canonical_root(self) } - - fn into_rpc_block(self) -> RpcBlock { - RpcBlock::new_without_blobs(None, self) - } } impl AsBlock for MaybeAvailableBlock { @@ -529,15 +524,6 @@ impl AsBlock for MaybeAvailableBlock { fn canonical_root(&self) -> Hash256 { self.as_block().canonical_root() } - - fn into_rpc_block(self) -> RpcBlock { - match self { - MaybeAvailableBlock::Available(available_block) => available_block.into_rpc_block(), - MaybeAvailableBlock::AvailabilityPending { block_root, block } => { - RpcBlock::new_without_blobs(Some(block_root), block) - } - } - } } impl AsBlock for AvailableBlock { @@ -576,36 +562,6 @@ impl AsBlock for AvailableBlock { fn canonical_root(&self) -> Hash256 { self.block().canonical_root() } - - fn into_rpc_block(self) -> RpcBlock { - let number_of_columns = self.spec.number_of_columns; - let (block_root, block, blobs_opt, data_columns_opt) = self.deconstruct(); - // Circumvent the constructor here, because an Available block will have already had - // consistency checks performed. - let inner = match (blobs_opt, data_columns_opt) { - (None, None) => RpcBlockInner::Block(block), - (Some(blobs), _) => RpcBlockInner::BlockAndBlobs(block, blobs), - (_, Some(data_columns)) => RpcBlockInner::BlockAndCustodyColumns( - block, - RuntimeVariableList::new( - data_columns - .into_iter() - // TODO(das): This is an ugly hack that should be removed. After updating - // store types to handle custody data columns this should not be required. - // It's okay-ish because available blocks must have all the required custody - // columns. - .map(|d| CustodyDataColumn::from_asserted_custody(d)) - .collect(), - number_of_columns, - ) - .expect("data column list is within bounds"), - ), - }; - RpcBlock { - block_root, - block: inner, - } - } } impl AsBlock for RpcBlock { @@ -644,8 +600,4 @@ impl AsBlock for RpcBlock { fn canonical_root(&self) -> Hash256 { self.as_block().canonical_root() } - - fn into_rpc_block(self) -> RpcBlock { - self - } } diff --git a/beacon_node/beacon_chain/src/builder.rs b/beacon_node/beacon_chain/src/builder.rs index 84c6dea3680..d38530b9049 100644 --- a/beacon_node/beacon_chain/src/builder.rs +++ b/beacon_node/beacon_chain/src/builder.rs @@ -39,8 +39,8 @@ use std::time::Duration; use store::{Error as StoreError, HotColdDB, ItemStore, KeyValueStoreOp}; use task_executor::{ShutdownReason, TaskExecutor}; use types::{ - BeaconBlock, BeaconState, BlobSidecarList, ChainSpec, Checkpoint, Epoch, EthSpec, Hash256, - Signature, SignedBeaconBlock, Slot, + BeaconBlock, BeaconState, BlobSidecarList, ChainSpec, Checkpoint, Epoch, EthSpec, + FixedBytesExtended, Hash256, Signature, SignedBeaconBlock, Slot, }; /// An empty struct used to "witness" all the `BeaconChainTypes` traits. It has no user-facing @@ -1292,7 +1292,7 @@ mod test { } for v in state.validators() { - let creds = v.withdrawal_credentials.as_bytes(); + let creds = v.withdrawal_credentials.as_slice(); assert_eq!( creds[0], spec.bls_withdrawal_prefix_byte, "first byte of withdrawal creds should be bls prefix" diff --git a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs index 2ff64dac97d..ad027a45dd0 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs @@ -267,7 +267,6 @@ impl PendingComponents { let num_blobs_expected = diet_executed_block.num_blobs_expected(); let Some(verified_blobs) = verified_blobs .into_iter() - .cloned() .map(|b| b.map(|b| b.to_blob())) .take(num_blobs_expected) .collect::>>() @@ -1161,7 +1160,9 @@ mod pending_components_tests { use rand::SeedableRng; use state_processing::ConsensusContext; use types::test_utils::TestRandom; - use types::{BeaconState, ForkName, MainnetEthSpec, SignedBeaconBlock, Slot}; + use types::{ + BeaconState, FixedBytesExtended, ForkName, MainnetEthSpec, SignedBeaconBlock, Slot, + }; type E = MainnetEthSpec; diff --git a/beacon_node/beacon_chain/src/eth1_chain.rs b/beacon_node/beacon_chain/src/eth1_chain.rs index 20706ab8200..9e1bcbe6fa8 100644 --- a/beacon_node/beacon_chain/src/eth1_chain.rs +++ b/beacon_node/beacon_chain/src/eth1_chain.rs @@ -685,7 +685,7 @@ fn is_candidate_block(block: &Eth1Block, period_start: u64, spec: &ChainSpec) -> #[cfg(test)] mod test { use super::*; - use types::{DepositData, MinimalEthSpec, Signature}; + use types::{DepositData, FixedBytesExtended, MinimalEthSpec, Signature}; type E = MinimalEthSpec; diff --git a/beacon_node/beacon_chain/src/execution_payload.rs b/beacon_node/beacon_chain/src/execution_payload.rs index a6e0d247dc2..b9b98bfbc00 100644 --- a/beacon_node/beacon_chain/src/execution_payload.rs +++ b/beacon_node/beacon_chain/src/execution_payload.rs @@ -62,7 +62,7 @@ impl PayloadNotifier { block: Arc>, state: &BeaconState, notify_execution_layer: NotifyExecutionLayer, - ) -> Result> { + ) -> Result { let payload_verification_status = if is_execution_enabled(state, block.message().body()) { // Perform the initial stages of payload verification. // @@ -110,9 +110,7 @@ impl PayloadNotifier { }) } - pub async fn notify_new_payload( - self, - ) -> Result> { + pub async fn notify_new_payload(self) -> Result { if let Some(precomputed_status) = self.payload_verification_status { Ok(precomputed_status) } else { @@ -133,7 +131,7 @@ impl PayloadNotifier { async fn notify_new_payload<'a, T: BeaconChainTypes>( chain: &Arc>, block: BeaconBlockRef<'a, T::EthSpec>, -) -> Result> { +) -> Result { let execution_layer = chain .execution_layer .as_ref() @@ -237,7 +235,7 @@ pub async fn validate_merge_block<'a, T: BeaconChainTypes>( chain: &Arc>, block: BeaconBlockRef<'a, T::EthSpec>, allow_optimistic_import: AllowOptimisticImport, -) -> Result<(), BlockError> { +) -> Result<(), BlockError> { let spec = &chain.spec; let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch()); let execution_payload = block.execution_payload()?; @@ -335,7 +333,7 @@ pub fn validate_execution_payload_for_gossip( parent_block: &ProtoBlock, block: BeaconBlockRef<'_, T::EthSpec>, chain: &BeaconChain, -) -> Result<(), BlockError> { +) -> Result<(), BlockError> { // Only apply this validation if this is a Bellatrix beacon block. if let Ok(execution_payload) = block.body().execution_payload() { // This logic should match `is_execution_enabled`. We use only the execution block hash of @@ -505,7 +503,7 @@ where return Ok(BlockProposalContentsType::Full( BlockProposalContents::Payload { payload: FullPayload::default_at_fork(fork)?, - block_value: Uint256::zero(), + block_value: Uint256::ZERO, }, )); } @@ -523,7 +521,7 @@ where return Ok(BlockProposalContentsType::Full( BlockProposalContents::Payload { payload: FullPayload::default_at_fork(fork)?, - block_value: Uint256::zero(), + block_value: Uint256::ZERO, }, )); } diff --git a/beacon_node/beacon_chain/src/head_tracker.rs b/beacon_node/beacon_chain/src/head_tracker.rs index 71e2473cdcf..9c06ef33a18 100644 --- a/beacon_node/beacon_chain/src/head_tracker.rs +++ b/beacon_node/beacon_chain/src/head_tracker.rs @@ -105,7 +105,7 @@ impl SszHeadTracker { mod test { use super::*; use ssz::{Decode, Encode}; - use types::{BeaconBlock, EthSpec, MainnetEthSpec}; + use types::{BeaconBlock, EthSpec, FixedBytesExtended, MainnetEthSpec}; type E = MainnetEthSpec; diff --git a/beacon_node/beacon_chain/src/historical_blocks.rs b/beacon_node/beacon_chain/src/historical_blocks.rs index 4b63ac6915a..1372211b175 100644 --- a/beacon_node/beacon_chain/src/historical_blocks.rs +++ b/beacon_node/beacon_chain/src/historical_blocks.rs @@ -11,7 +11,7 @@ use std::iter; use std::time::Duration; use store::metadata::DataColumnInfo; use store::{chunked_vector::BlockRoots, AnchorInfo, BlobInfo, ChunkWriter, KeyValueStore}; -use types::{Hash256, Slot}; +use types::{FixedBytesExtended, Hash256, Slot}; /// Use a longer timeout on the pubkey cache. /// diff --git a/beacon_node/beacon_chain/src/metrics.rs b/beacon_node/beacon_chain/src/metrics.rs index 3394946255f..3da2bea36c8 100644 --- a/beacon_node/beacon_chain/src/metrics.rs +++ b/beacon_node/beacon_chain/src/metrics.rs @@ -1,6 +1,7 @@ use crate::observed_attesters::SlotSubcommitteeIndex; use crate::types::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT; use crate::{BeaconChain, BeaconChainError, BeaconChainTypes}; +use bls::FixedBytesExtended; pub use lighthouse_metrics::*; use slot_clock::SlotClock; use std::sync::LazyLock; diff --git a/beacon_node/beacon_chain/src/migrate.rs b/beacon_node/beacon_chain/src/migrate.rs index 08b2a51720d..fcb8fb1c897 100644 --- a/beacon_node/beacon_chain/src/migrate.rs +++ b/beacon_node/beacon_chain/src/migrate.rs @@ -14,8 +14,8 @@ use store::iter::RootsIterator; use store::{Error, ItemStore, StoreItem, StoreOp}; pub use store::{HotColdDB, MemoryStore}; use types::{ - BeaconState, BeaconStateError, BeaconStateHash, Checkpoint, Epoch, EthSpec, Hash256, - SignedBeaconBlockHash, Slot, + BeaconState, BeaconStateError, BeaconStateHash, Checkpoint, Epoch, EthSpec, FixedBytesExtended, + Hash256, SignedBeaconBlockHash, Slot, }; /// Compact at least this frequently, finalization permitting (7 days). diff --git a/beacon_node/beacon_chain/src/naive_aggregation_pool.rs b/beacon_node/beacon_chain/src/naive_aggregation_pool.rs index 211aecfe63d..7e23edbae8d 100644 --- a/beacon_node/beacon_chain/src/naive_aggregation_pool.rs +++ b/beacon_node/beacon_chain/src/naive_aggregation_pool.rs @@ -48,7 +48,7 @@ impl TreeHash for AttestationKey { // Combine the hash of the data with the hash of the index let mut hasher = MerkleHasher::with_leaves(2); hasher - .write(self.data_root.as_bytes()) + .write(self.data_root.as_slice()) .expect("should write data hash"); hasher .write(&index.to_le_bytes()) @@ -582,7 +582,8 @@ mod tests { use tree_hash::TreeHash; use types::{ test_utils::{generate_deterministic_keypair, test_random_instance}, - Attestation, AttestationBase, AttestationElectra, Fork, Hash256, SyncCommitteeMessage, + Attestation, AttestationBase, AttestationElectra, FixedBytesExtended, Fork, Hash256, + SyncCommitteeMessage, }; type E = types::MainnetEthSpec; diff --git a/beacon_node/beacon_chain/src/observed_aggregates.rs b/beacon_node/beacon_chain/src/observed_aggregates.rs index 00476bfe7af..038edfe27f0 100644 --- a/beacon_node/beacon_chain/src/observed_aggregates.rs +++ b/beacon_node/beacon_chain/src/observed_aggregates.rs @@ -473,7 +473,7 @@ where #[cfg(not(debug_assertions))] mod tests { use super::*; - use types::{test_utils::test_random_instance, AttestationBase, Hash256}; + use types::{test_utils::test_random_instance, AttestationBase, FixedBytesExtended, Hash256}; type E = types::MainnetEthSpec; diff --git a/beacon_node/beacon_chain/src/observed_attesters.rs b/beacon_node/beacon_chain/src/observed_attesters.rs index a1c6adc3e07..efb95f57a96 100644 --- a/beacon_node/beacon_chain/src/observed_attesters.rs +++ b/beacon_node/beacon_chain/src/observed_attesters.rs @@ -619,6 +619,7 @@ impl SlotSubcommitteeIndex { #[cfg(test)] mod tests { use super::*; + use types::FixedBytesExtended; type E = types::MainnetEthSpec; diff --git a/beacon_node/beacon_chain/src/otb_verification_service.rs b/beacon_node/beacon_chain/src/otb_verification_service.rs index b934c553e6c..31034a7d59b 100644 --- a/beacon_node/beacon_chain/src/otb_verification_service.rs +++ b/beacon_node/beacon_chain/src/otb_verification_service.rs @@ -64,7 +64,7 @@ impl OptimisticTransitionBlock { store .as_ref() .hot_db - .key_delete(OTBColumn.into(), self.root.as_bytes()) + .key_delete(OTBColumn.into(), self.root.as_slice()) } fn is_canonical( diff --git a/beacon_node/beacon_chain/src/schema_change/migration_schema_v21.rs b/beacon_node/beacon_chain/src/schema_change/migration_schema_v21.rs index 4042d328207..fcc8b9884ac 100644 --- a/beacon_node/beacon_chain/src/schema_change/migration_schema_v21.rs +++ b/beacon_node/beacon_chain/src/schema_change/migration_schema_v21.rs @@ -62,7 +62,7 @@ pub fn downgrade_from_v21( message: format!("{e:?}"), })?; - let db_key = get_key_for_col(DBColumn::PubkeyCache.into(), key.as_bytes()); + let db_key = get_key_for_col(DBColumn::PubkeyCache.into(), key.as_slice()); ops.push(KeyValueStoreOp::PutKeyValue( db_key, pubkey_bytes.as_ssz_bytes(), diff --git a/beacon_node/beacon_chain/src/test_utils.rs b/beacon_node/beacon_chain/src/test_utils.rs index cd2e355cafe..cd54a2b3ce7 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -1986,7 +1986,7 @@ where slot: Slot, block_root: Hash256, block_contents: SignedBlockContentsTuple, - ) -> Result> { + ) -> Result { self.set_current_slot(slot); let (block, blob_items) = block_contents; @@ -2013,7 +2013,7 @@ where pub async fn process_block_result( &self, block_contents: SignedBlockContentsTuple, - ) -> Result> { + ) -> Result { let (block, blob_items) = block_contents; let sidecars = blob_items @@ -2098,7 +2098,7 @@ where SignedBlockContentsTuple, BeaconState, ), - BlockError, + BlockError, > { self.set_current_slot(slot); let (block_contents, new_state) = self.make_block(state, slot).await; @@ -2144,7 +2144,7 @@ where state: BeaconState, state_root: Hash256, validators: &[usize], - ) -> Result<(SignedBeaconBlockHash, BeaconState), BlockError> { + ) -> Result<(SignedBeaconBlockHash, BeaconState), BlockError> { self.add_attested_block_at_slot_with_sync( slot, state, @@ -2162,7 +2162,7 @@ where state_root: Hash256, validators: &[usize], sync_committee_strategy: SyncCommitteeStrategy, - ) -> Result<(SignedBeaconBlockHash, BeaconState), BlockError> { + ) -> Result<(SignedBeaconBlockHash, BeaconState), BlockError> { let (block_hash, block, state) = self.add_block_at_slot(slot, state).await?; self.attest_block(&state, state_root, block_hash, &block.0, validators); @@ -2627,6 +2627,7 @@ pub fn generate_rand_block_and_blobs( let inner = map_fork_name!(fork_name, BeaconBlock, <_>::random_for_test(rng)); let mut block = SignedBeaconBlock::from_block(inner, types::Signature::random_for_test(rng)); + let mut blob_sidecars = vec![]; let bundle = match block { diff --git a/beacon_node/beacon_chain/src/validator_pubkey_cache.rs b/beacon_node/beacon_chain/src/validator_pubkey_cache.rs index 576fbf0fd1f..917c20bfa5a 100644 --- a/beacon_node/beacon_chain/src/validator_pubkey_cache.rs +++ b/beacon_node/beacon_chain/src/validator_pubkey_cache.rs @@ -7,7 +7,7 @@ use ssz_derive::{Decode, Encode}; use std::collections::HashMap; use std::marker::PhantomData; use store::{DBColumn, Error as StoreError, StoreItem, StoreOp}; -use types::{BeaconState, Hash256, PublicKey, PublicKeyBytes}; +use types::{BeaconState, FixedBytesExtended, Hash256, PublicKey, PublicKeyBytes}; /// Provides a mapping of `validator_index -> validator_publickey`. /// diff --git a/beacon_node/beacon_chain/tests/attestation_verification.rs b/beacon_node/beacon_chain/tests/attestation_verification.rs index a52437e003a..335884d57a9 100644 --- a/beacon_node/beacon_chain/tests/attestation_verification.rs +++ b/beacon_node/beacon_chain/tests/attestation_verification.rs @@ -24,8 +24,8 @@ use types::{ signed_aggregate_and_proof::SignedAggregateAndProofRefMut, test_utils::generate_deterministic_keypair, Address, AggregateSignature, Attestation, AttestationRef, AttestationRefMut, BeaconStateError, BitList, ChainSpec, Epoch, EthSpec, - ForkName, Hash256, Keypair, MainnetEthSpec, SecretKey, SelectionProof, SignedAggregateAndProof, - Slot, SubnetId, Unsigned, + FixedBytesExtended, ForkName, Hash256, Keypair, MainnetEthSpec, SecretKey, SelectionProof, + SignedAggregateAndProof, Slot, SubnetId, Unsigned, }; pub type E = MainnetEthSpec; diff --git a/beacon_node/beacon_chain/tests/block_verification.rs b/beacon_node/beacon_chain/tests/block_verification.rs index 1c494d99bf5..faa4d74a182 100644 --- a/beacon_node/beacon_chain/tests/block_verification.rs +++ b/beacon_node/beacon_chain/tests/block_verification.rs @@ -1098,8 +1098,8 @@ async fn block_gossip_verification() { assert!( matches!( unwrap_err(harness.chain.verify_block_for_gossip(Arc::new(SignedBeaconBlock::from_block(block, signature))).await), - BlockError::ParentUnknown(block) - if block.parent_root() == parent_root + BlockError::ParentUnknown {parent_root: p} + if p == parent_root ), "should not import a block for an unknown parent" ); diff --git a/beacon_node/beacon_chain/tests/payload_invalidation.rs b/beacon_node/beacon_chain/tests/payload_invalidation.rs index 4dc7d20e227..b455c3bace4 100644 --- a/beacon_node/beacon_chain/tests/payload_invalidation.rs +++ b/beacon_node/beacon_chain/tests/payload_invalidation.rs @@ -212,7 +212,7 @@ impl InvalidPayloadRig { .unwrap(); } - async fn import_block_parametric) -> bool>( + async fn import_block_parametric bool>( &mut self, new_payload_response: Payload, forkchoice_response: Payload, @@ -1280,7 +1280,7 @@ struct OptimisticTransitionSetup { impl OptimisticTransitionSetup { async fn new(num_blocks: usize, ttd: u64) -> Self { let mut spec = E::default_spec(); - spec.terminal_total_difficulty = ttd.into(); + spec.terminal_total_difficulty = Uint256::from(ttd); let mut rig = InvalidPayloadRig::new_with_spec(spec).enable_attestations(); rig.move_to_terminal_block(); @@ -1323,7 +1323,7 @@ async fn build_optimistic_chain( // Build a brand-new testing harness. We will apply the blocks from the previous harness to // this one. let mut spec = E::default_spec(); - spec.terminal_total_difficulty = rig_ttd.into(); + spec.terminal_total_difficulty = Uint256::from(rig_ttd); let rig = InvalidPayloadRig::new_with_spec(spec); let spec = &rig.harness.chain.spec; diff --git a/beacon_node/beacon_chain/tests/store_tests.rs b/beacon_node/beacon_chain/tests/store_tests.rs index 740aada413d..95bf7f1ce84 100644 --- a/beacon_node/beacon_chain/tests/store_tests.rs +++ b/beacon_node/beacon_chain/tests/store_tests.rs @@ -1093,7 +1093,7 @@ async fn delete_blocks_and_states() { assert_eq!( harness.head_block_root(), - honest_head.into(), + Hash256::from(honest_head), "the honest chain should be the canonical chain", ); diff --git a/beacon_node/beacon_chain/tests/sync_committee_verification.rs b/beacon_node/beacon_chain/tests/sync_committee_verification.rs index 5cbb26ffbf5..f8da2e8da1c 100644 --- a/beacon_node/beacon_chain/tests/sync_committee_verification.rs +++ b/beacon_node/beacon_chain/tests/sync_committee_verification.rs @@ -13,8 +13,8 @@ use store::{SignedContributionAndProof, SyncCommitteeMessage}; use tree_hash::TreeHash; use types::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT; use types::{ - AggregateSignature, Epoch, EthSpec, Hash256, Keypair, MainnetEthSpec, SecretKey, Slot, - SyncContributionData, SyncSelectionProof, SyncSubnetId, Unsigned, + AggregateSignature, Epoch, EthSpec, FixedBytesExtended, Hash256, Keypair, MainnetEthSpec, + SecretKey, Slot, SyncContributionData, SyncSelectionProof, SyncSubnetId, Unsigned, }; pub type E = MainnetEthSpec; diff --git a/beacon_node/eth1/src/block_cache.rs b/beacon_node/eth1/src/block_cache.rs index 0ccdb4fc0eb..9c840aea210 100644 --- a/beacon_node/eth1/src/block_cache.rs +++ b/beacon_node/eth1/src/block_cache.rs @@ -195,6 +195,8 @@ impl BlockCache { #[cfg(test)] mod tests { + use types::FixedBytesExtended; + use super::*; fn get_block(i: u64, interval_secs: u64) -> Eth1Block { diff --git a/beacon_node/eth1/src/deposit_cache.rs b/beacon_node/eth1/src/deposit_cache.rs index b443f739e81..a2d4a1cf06d 100644 --- a/beacon_node/eth1/src/deposit_cache.rs +++ b/beacon_node/eth1/src/deposit_cache.rs @@ -471,7 +471,7 @@ impl DepositCache { pub mod tests { use super::*; use execution_layer::http::deposit_log::Log; - use types::{EthSpec, MainnetEthSpec}; + use types::{EthSpec, FixedBytesExtended, MainnetEthSpec}; /// The data from a deposit event, using the v0.8.3 version of the deposit contract. pub const EXAMPLE_LOG: &[u8] = &[ diff --git a/beacon_node/eth1/tests/test.rs b/beacon_node/eth1/tests/test.rs index cd35c521b65..3ad9b34381a 100644 --- a/beacon_node/eth1/tests/test.rs +++ b/beacon_node/eth1/tests/test.rs @@ -10,7 +10,10 @@ use sensitive_url::SensitiveUrl; use std::ops::Range; use std::time::Duration; use tree_hash::TreeHash; -use types::{DepositData, EthSpec, Hash256, Keypair, MainnetEthSpec, MinimalEthSpec, Signature}; +use types::{ + DepositData, EthSpec, FixedBytesExtended, Hash256, Keypair, MainnetEthSpec, MinimalEthSpec, + Signature, +}; const DEPOSIT_CONTRACT_TREE_DEPTH: usize = 32; diff --git a/beacon_node/execution_layer/Cargo.toml b/beacon_node/execution_layer/Cargo.toml index e93d1480d80..93d8086149d 100644 --- a/beacon_node/execution_layer/Cargo.toml +++ b/beacon_node/execution_layer/Cargo.toml @@ -51,3 +51,4 @@ eth2_network_config = { workspace = true } alloy-rlp = { workspace = true } alloy-consensus = { workspace = true } lighthouse_version = { workspace = true } +fixed_bytes = { workspace = true } diff --git a/beacon_node/execution_layer/src/block_hash.rs b/beacon_node/execution_layer/src/block_hash.rs index 10edb7b2fd4..cdc172cff47 100644 --- a/beacon_node/execution_layer/src/block_hash.rs +++ b/beacon_node/execution_layer/src/block_hash.rs @@ -77,7 +77,7 @@ mod test { use super::*; use hex::FromHex; use std::str::FromStr; - use types::{Address, Hash256, Hash64}; + use types::{Address, Hash256, Hash64, Uint256}; fn test_rlp_encoding( header: &ExecutionBlockHeader, @@ -105,15 +105,15 @@ mod test { transactions_root: Hash256::from_str("50f738580ed699f0469702c7ccc63ed2e51bc034be9479b7bff4e68dee84accf").unwrap(), receipts_root: Hash256::from_str("29b0562f7140574dd0d50dee8a271b22e1a0a7b78fca58f7c60370d8317ba2a9").unwrap(), logs_bloom: <[u8; 256]>::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), - difficulty: 0x020000.into(), - number: 0x01_u64.into(), - gas_limit: 0x016345785d8a0000_u64.into(), - gas_used: 0x015534_u64.into(), + difficulty: Uint256::from(0x020000), + number: Uint256::from(0x01_u64), + gas_limit: Uint256::from(0x016345785d8a0000_u64), + gas_used: Uint256::from(0x015534_u64), timestamp: 0x079e, extra_data: vec![0x42], mix_hash: Hash256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - nonce: Hash64::zero(), - base_fee_per_gas: 0x036b_u64.into(), + nonce: Hash64::ZERO, + base_fee_per_gas: Uint256::from(0x036b_u64), withdrawals_root: None, blob_gas_used: None, excess_blob_gas: None, @@ -136,15 +136,15 @@ mod test { transactions_root: Hash256::from_str("50f738580ed699f0469702c7ccc63ed2e51bc034be9479b7bff4e68dee84accf").unwrap(), receipts_root: Hash256::from_str("29b0562f7140574dd0d50dee8a271b22e1a0a7b78fca58f7c60370d8317ba2a9").unwrap(), logs_bloom: <[u8; 256]>::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), - difficulty: 0x00.into(), - number: 0x01_u64.into(), - gas_limit: 0x016345785d8a0000_u64.into(), - gas_used: 0x015534_u64.into(), + difficulty: Uint256::from(0x00), + number: Uint256::from(0x01_u64), + gas_limit: Uint256::from(0x016345785d8a0000_u64), + gas_used: Uint256::from(0x015534_u64), timestamp: 0x079e, extra_data: vec![0x42], mix_hash: Hash256::from_str("0000000000000000000000000000000000000000000000000000000000020000").unwrap(), - nonce: Hash64::zero(), - base_fee_per_gas: 0x036b_u64.into(), + nonce: Hash64::ZERO, + base_fee_per_gas: Uint256::from(0x036b_u64), withdrawals_root: None, blob_gas_used: None, excess_blob_gas: None, @@ -168,15 +168,15 @@ mod test { transactions_root: Hash256::from_str("0223f0cb35f184d2ac409e89dc0768ad738f777bd1c85d3302ca50f307180c94").unwrap(), receipts_root: Hash256::from_str("371c76821b1cc21232574604eac5349d51647eb530e2a45d4f6fe2c501351aa5").unwrap(), logs_bloom: <[u8; 256]>::from_hex("1a2c559955848d2662a0634cb40c7a6192a1524f11061203689bcbcdec901b054084d4f4d688009d24c10918e0089b48e72fe2d7abafb903889d10c3827c6901096612d259801b1b7ba1663a4201f5f88f416a9997c55bcc2c54785280143b057a008764c606182e324216822a2d5913e797a05c16cc1468d001acf3783b18e00e0203033e43106178db554029e83ca46402dc49d929d7882a04a0e7215041bdabf7430bd10ef4bb658a40f064c63c4816660241c2480862f26742fdf9ca41637731350301c344e439428182a03e384484e6d65d0c8a10117c6739ca201b60974519a1ae6b0c3966c0f650b449d10eae065dab2c83ab4edbab5efdea50bbc801").unwrap().into(), - difficulty: 0.into(), - number: 16182891.into(), - gas_limit: 0x1c9c380.into(), - gas_used: 0xe9b752.into(), + difficulty: Uint256::ZERO, + number: Uint256::from(16182891), + gas_limit: Uint256::from(0x1c9c380), + gas_used: Uint256::from(0xe9b752), timestamp: 0x6399bf63, extra_data: hex::decode("496c6c756d696e61746520446d6f63726174697a6520447374726962757465").unwrap(), mix_hash: Hash256::from_str("bf5289894b2ceab3549f92f063febbac896b280ddb18129a57cff13113c11b13").unwrap(), - nonce: Hash64::zero(), - base_fee_per_gas: 0x34187b238_u64.into(), + nonce: Hash64::ZERO, + base_fee_per_gas: Uint256::from(0x34187b238_u64), withdrawals_root: None, blob_gas_used: None, excess_blob_gas: None, @@ -198,15 +198,15 @@ mod test { transactions_root: Hash256::from_str("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(), receipts_root: Hash256::from_str("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(), logs_bloom:<[u8; 256]>::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), - difficulty: 0.into(), - number: 97.into(), - gas_limit: 27482534.into(), - gas_used: 0.into(), + difficulty: Uint256::ZERO, + number: Uint256::from(97), + gas_limit: Uint256::from(27482534), + gas_used: Uint256::ZERO, timestamp: 1692132829u64, extra_data: hex::decode("d883010d00846765746888676f312e32302e37856c696e7578").unwrap(), mix_hash: Hash256::from_str("0b493c22d2ad4ca76c77ae6ad916af429b42b1dc98fdcb8e5ddbd049bbc5d623").unwrap(), - nonce: Hash64::zero(), - base_fee_per_gas: 2374u64.into(), + nonce: Hash64::ZERO, + base_fee_per_gas: Uint256::from(2374u64), withdrawals_root: Some(Hash256::from_str("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap()), blob_gas_used: Some(0x0u64), excess_blob_gas: Some(0x0u64), @@ -228,15 +228,15 @@ mod test { transactions_root: Hash256::from_str("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(), receipts_root: Hash256::from_str("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(), logs_bloom:<[u8; 256]>::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), - difficulty: 0.into(), - number: 97.into(), - gas_limit: 27482534.into(), - gas_used: 0.into(), + difficulty: Uint256::ZERO, + number: Uint256::from(97), + gas_limit: Uint256::from(27482534), + gas_used: Uint256::ZERO, timestamp: 1692132829u64, extra_data: hex::decode("d883010d00846765746888676f312e32302e37856c696e7578").unwrap(), mix_hash: Hash256::from_str("0b493c22d2ad4ca76c77ae6ad916af429b42b1dc98fdcb8e5ddbd049bbc5d623").unwrap(), - nonce: Hash64::zero(), - base_fee_per_gas: 2374u64.into(), + nonce: Hash64::ZERO, + base_fee_per_gas: Uint256::from(2374u64), withdrawals_root: Some(Hash256::from_str("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap()), blob_gas_used: Some(0x0u64), excess_blob_gas: Some(0x0u64), diff --git a/beacon_node/execution_layer/src/engine_api.rs b/beacon_node/execution_layer/src/engine_api.rs index 316b0dfa86a..8cfe6e9efde 100644 --- a/beacon_node/execution_layer/src/engine_api.rs +++ b/beacon_node/execution_layer/src/engine_api.rs @@ -154,6 +154,7 @@ pub struct ExecutionBlock { pub block_hash: ExecutionBlockHash, #[serde(rename = "number", with = "serde_utils::u64_hex_be")] pub block_number: u64, + pub parent_hash: ExecutionBlockHash, pub total_difficulty: Uint256, #[serde(with = "serde_utils::u64_hex_be")] @@ -175,6 +176,7 @@ pub struct ExecutionBlock { pub struct ExecutionBlockWithTransactions { pub parent_hash: ExecutionBlockHash, #[serde(alias = "miner")] + #[serde(with = "serde_utils::address_hex")] pub fee_recipient: Address, pub state_root: Hash256, pub receipts_root: Hash256, diff --git a/beacon_node/execution_layer/src/engine_api/http.rs b/beacon_node/execution_layer/src/engine_api/http.rs index 1838d13bb06..5bc1343a0eb 100644 --- a/beacon_node/execution_layer/src/engine_api/http.rs +++ b/beacon_node/execution_layer/src/engine_api/http.rs @@ -877,7 +877,7 @@ impl HttpJsonRpc { // Set the V1 payload values from the EE to be zero. This simulates // the pre-block-value functionality of always choosing the builder // block. - block_value: Uint256::zero(), + block_value: Uint256::ZERO, })) } @@ -1414,7 +1414,7 @@ mod test { use std::future::Future; use std::str::FromStr; use std::sync::Arc; - use types::{MainnetEthSpec, Unsigned}; + use types::{FixedBytesExtended, MainnetEthSpec, Unsigned}; struct Tester { server: MockServer, diff --git a/beacon_node/execution_layer/src/engine_api/json_structures.rs b/beacon_node/execution_layer/src/engine_api/json_structures.rs index 00572150e05..dbf889bbc8c 100644 --- a/beacon_node/execution_layer/src/engine_api/json_structures.rs +++ b/beacon_node/execution_layer/src/engine_api/json_structures.rs @@ -73,6 +73,7 @@ pub struct JsonPayloadIdResponse { #[serde(bound = "E: EthSpec", rename_all = "camelCase", untagged)] pub struct JsonExecutionPayload { pub parent_hash: ExecutionBlockHash, + #[serde(with = "serde_utils::address_hex")] pub fee_recipient: Address, pub state_root: Hash256, pub receipts_root: Hash256, @@ -91,6 +92,7 @@ pub struct JsonExecutionPayload { pub extra_data: VariableList, #[serde(with = "serde_utils::u256_hex_be")] pub base_fee_per_gas: Uint256, + pub block_hash: ExecutionBlockHash, #[serde(with = "ssz_types::serde_utils::list_of_hex_var_list")] pub transactions: Transactions, @@ -449,6 +451,7 @@ pub struct JsonWithdrawal { pub index: u64, #[serde(with = "serde_utils::u64_hex_be")] pub validator_index: u64, + #[serde(with = "serde_utils::address_hex")] pub address: Address, #[serde(with = "serde_utils::u64_hex_be")] pub amount: u64, @@ -488,7 +491,7 @@ impl<'a> From<&'a JsonWithdrawal> for EncodableJsonWithdrawal<'a> { Self { index: json_withdrawal.index, validator_index: json_withdrawal.validator_index, - address: json_withdrawal.address.as_bytes(), + address: json_withdrawal.address.as_slice(), amount: json_withdrawal.amount, } } @@ -509,6 +512,7 @@ pub struct JsonPayloadAttributes { #[serde(with = "serde_utils::u64_hex_be")] pub timestamp: u64, pub prev_randao: Hash256, + #[serde(with = "serde_utils::address_hex")] pub suggested_fee_recipient: Address, #[superstruct(only(V2, V3))] pub withdrawals: Vec, @@ -598,7 +602,9 @@ impl From> for BlobsBundle { #[serde(rename_all = "camelCase")] pub struct JsonForkchoiceStateV1 { pub head_block_hash: ExecutionBlockHash, + pub safe_block_hash: ExecutionBlockHash, + pub finalized_block_hash: ExecutionBlockHash, } @@ -823,6 +829,7 @@ impl From> for ExecutionPayloadBody { pub struct TransitionConfigurationV1 { #[serde(with = "serde_utils::u256_hex_be")] pub terminal_total_difficulty: Uint256, + pub terminal_block_hash: ExecutionBlockHash, #[serde(with = "serde_utils::u64_hex_be")] pub terminal_block_number: u64, diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index 0da9225173c..6e3aca39594 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -18,6 +18,7 @@ pub use engines::{EngineState, ForkchoiceState}; use eth2::types::FullPayloadContents; use eth2::types::{builder_bid::SignedBuilderBid, BlobsBundle, ForkVersionedResponse}; use ethers_core::types::Transaction as EthersTransaction; +use fixed_bytes::UintExtended; use fork_choice::ForkchoiceUpdateParameters; use lru::LruCache; use payload_status::process_payload_status; @@ -1132,9 +1133,8 @@ impl ExecutionLayer { let relay_value = *relay.data.message.value(); let boosted_relay_value = match builder_boost_factor { - Some(builder_boost_factor) => { - (relay_value / 100).saturating_mul(builder_boost_factor.into()) - } + Some(builder_boost_factor) => (relay_value / Uint256::from(100)) + .saturating_mul(Uint256::from(builder_boost_factor)), None => relay_value, }; @@ -2196,15 +2196,11 @@ fn verify_builder_bid( let is_signature_valid = bid.data.verify_signature(spec); let header = &bid.data.message.header(); - // Avoid logging values that we can't represent with our Prometheus library. - let payload_value_gwei = bid.data.message.value() / 1_000_000_000; - if payload_value_gwei <= Uint256::from(i64::MAX) { - metrics::set_gauge_vec( - &metrics::EXECUTION_LAYER_PAYLOAD_BIDS, - &[metrics::BUILDER], - payload_value_gwei.low_u64() as i64, - ); - } + metrics::set_gauge_vec( + &metrics::EXECUTION_LAYER_PAYLOAD_BIDS, + &[metrics::BUILDER], + bid.data.message.value().to_i64(), + ); let expected_withdrawals_root = payload_attributes .withdrawals() diff --git a/beacon_node/execution_layer/src/test_utils/execution_block_generator.rs b/beacon_node/execution_layer/src/test_utils/execution_block_generator.rs index a18ac711aa7..86c44dc158b 100644 --- a/beacon_node/execution_layer/src/test_utils/execution_block_generator.rs +++ b/beacon_node/execution_layer/src/test_utils/execution_block_generator.rs @@ -23,7 +23,8 @@ use tree_hash_derive::TreeHash; use types::{ Blob, ChainSpec, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadBellatrix, ExecutionPayloadCapella, ExecutionPayloadDeneb, ExecutionPayloadElectra, - ExecutionPayloadHeader, ForkName, Hash256, Transaction, Transactions, Uint256, + ExecutionPayloadHeader, FixedBytesExtended, ForkName, Hash256, Transaction, Transactions, + Uint256, }; use super::DEFAULT_TERMINAL_BLOCK; @@ -107,7 +108,9 @@ impl Block { #[serde(rename_all = "camelCase")] pub struct PoWBlock { pub block_number: u64, + pub block_hash: ExecutionBlockHash, + pub parent_hash: ExecutionBlockHash, pub total_difficulty: Uint256, pub timestamp: u64, @@ -581,7 +584,7 @@ impl ExecutionBlockGenerator { gas_used: GAS_USED, timestamp: pa.timestamp, extra_data: "block gen was here".as_bytes().to_vec().into(), - base_fee_per_gas: Uint256::one(), + base_fee_per_gas: Uint256::from(1u64), block_hash: ExecutionBlockHash::zero(), transactions: vec![].into(), }), @@ -598,7 +601,7 @@ impl ExecutionBlockGenerator { gas_used: GAS_USED, timestamp: pa.timestamp, extra_data: "block gen was here".as_bytes().to_vec().into(), - base_fee_per_gas: Uint256::one(), + base_fee_per_gas: Uint256::from(1u64), block_hash: ExecutionBlockHash::zero(), transactions: vec![].into(), }), @@ -614,7 +617,7 @@ impl ExecutionBlockGenerator { gas_used: GAS_USED, timestamp: pa.timestamp, extra_data: "block gen was here".as_bytes().to_vec().into(), - base_fee_per_gas: Uint256::one(), + base_fee_per_gas: Uint256::from(1u64), block_hash: ExecutionBlockHash::zero(), transactions: vec![].into(), withdrawals: pa.withdrawals.clone().into(), @@ -634,7 +637,7 @@ impl ExecutionBlockGenerator { gas_used: GAS_USED, timestamp: pa.timestamp, extra_data: "block gen was here".as_bytes().to_vec().into(), - base_fee_per_gas: Uint256::one(), + base_fee_per_gas: Uint256::from(1u64), block_hash: ExecutionBlockHash::zero(), transactions: vec![].into(), withdrawals: pa.withdrawals.clone().into(), @@ -653,7 +656,7 @@ impl ExecutionBlockGenerator { gas_used: GAS_USED, timestamp: pa.timestamp, extra_data: "block gen was here".as_bytes().to_vec().into(), - base_fee_per_gas: Uint256::one(), + base_fee_per_gas: Uint256::from(1u64), block_hash: ExecutionBlockHash::zero(), transactions: vec![].into(), withdrawals: pa.withdrawals.clone().into(), @@ -881,7 +884,7 @@ mod test { const DIFFICULTY_INCREMENT: u64 = 1; let mut generator: ExecutionBlockGenerator = ExecutionBlockGenerator::new( - TERMINAL_DIFFICULTY.into(), + Uint256::from(TERMINAL_DIFFICULTY), TERMINAL_BLOCK, ExecutionBlockHash::zero(), None, @@ -910,7 +913,7 @@ mod test { assert_eq!( block.total_difficulty().unwrap(), - (i * DIFFICULTY_INCREMENT).into() + Uint256::from(i * DIFFICULTY_INCREMENT) ); assert_eq!(generator.block_by_hash(block.block_hash()).unwrap(), block); diff --git a/beacon_node/execution_layer/src/test_utils/handle_rpc.rs b/beacon_node/execution_layer/src/test_utils/handle_rpc.rs index b1788498424..81c69caf829 100644 --- a/beacon_node/execution_layer/src/test_utils/handle_rpc.rs +++ b/beacon_node/execution_layer/src/test_utils/handle_rpc.rs @@ -330,14 +330,14 @@ pub async fn handle_rpc( JsonExecutionPayload::V1(execution_payload) => { serde_json::to_value(JsonGetPayloadResponseV1 { execution_payload, - block_value: DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI.into(), + block_value: Uint256::from(DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI), }) .unwrap() } JsonExecutionPayload::V2(execution_payload) => { serde_json::to_value(JsonGetPayloadResponseV2 { execution_payload, - block_value: DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI.into(), + block_value: Uint256::from(DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI), }) .unwrap() } @@ -350,7 +350,7 @@ pub async fn handle_rpc( JsonExecutionPayload::V3(execution_payload) => { serde_json::to_value(JsonGetPayloadResponseV3 { execution_payload, - block_value: DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI.into(), + block_value: Uint256::from(DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI), blobs_bundle: maybe_blobs .ok_or(( "No blobs returned despite V3 Payload".to_string(), @@ -367,7 +367,7 @@ pub async fn handle_rpc( JsonExecutionPayload::V4(execution_payload) => { serde_json::to_value(JsonGetPayloadResponseV4 { execution_payload, - block_value: DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI.into(), + block_value: Uint256::from(DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI), blobs_bundle: maybe_blobs .ok_or(( "No blobs returned despite V4 Payload".to_string(), diff --git a/beacon_node/execution_layer/src/test_utils/mock_builder.rs b/beacon_node/execution_layer/src/test_utils/mock_builder.rs index c9ae1e60cdc..46830256b09 100644 --- a/beacon_node/execution_layer/src/test_utils/mock_builder.rs +++ b/beacon_node/execution_layer/src/test_utils/mock_builder.rs @@ -20,9 +20,9 @@ use types::builder_bid::{ }; use types::{ Address, BeaconState, ChainSpec, EthSpec, ExecPayload, ExecutionPayload, - ExecutionPayloadHeaderRefMut, ForkName, ForkVersionedResponse, Hash256, PublicKeyBytes, - Signature, SignedBlindedBeaconBlock, SignedRoot, SignedValidatorRegistrationData, Slot, - Uint256, + ExecutionPayloadHeaderRefMut, FixedBytesExtended, ForkName, ForkVersionedResponse, Hash256, + PublicKeyBytes, Signature, SignedBlindedBeaconBlock, SignedRoot, + SignedValidatorRegistrationData, Slot, Uint256, }; use types::{ExecutionBlockHash, SecretKey}; use warp::{Filter, Rejection}; diff --git a/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs b/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs index da9b2817f69..a9f1313e462 100644 --- a/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs +++ b/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs @@ -4,10 +4,10 @@ use crate::{ }, *, }; -use keccak_hash::H256; +use alloy_primitives::B256 as H256; use kzg::Kzg; use tempfile::NamedTempFile; -use types::MainnetEthSpec; +use types::{FixedBytesExtended, MainnetEthSpec}; pub struct MockExecutionLayer { pub server: MockServer, @@ -19,7 +19,7 @@ pub struct MockExecutionLayer { impl MockExecutionLayer { pub fn default_params(executor: TaskExecutor) -> Self { let mut spec = MainnetEthSpec::default_spec(); - spec.terminal_total_difficulty = DEFAULT_TERMINAL_DIFFICULTY.into(); + spec.terminal_total_difficulty = Uint256::from(DEFAULT_TERMINAL_DIFFICULTY); spec.terminal_block_hash = ExecutionBlockHash::zero(); spec.terminal_block_hash_activation_epoch = Epoch::new(0); Self::new( diff --git a/beacon_node/execution_layer/src/test_utils/mod.rs b/beacon_node/execution_layer/src/test_utils/mod.rs index c6bcdf4e444..fe847ec3eda 100644 --- a/beacon_node/execution_layer/src/test_utils/mod.rs +++ b/beacon_node/execution_layer/src/test_utils/mod.rs @@ -88,7 +88,7 @@ impl Default for MockExecutionConfig { fn default() -> Self { Self { jwt_key: JwtKey::random(), - terminal_difficulty: DEFAULT_TERMINAL_DIFFICULTY.into(), + terminal_difficulty: Uint256::from(DEFAULT_TERMINAL_DIFFICULTY), terminal_block: DEFAULT_TERMINAL_BLOCK, terminal_block_hash: ExecutionBlockHash::zero(), server_config: Config::default(), @@ -111,7 +111,7 @@ impl MockServer { Self::new( &runtime::Handle::current(), JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap(), - DEFAULT_TERMINAL_DIFFICULTY.into(), + Uint256::from(DEFAULT_TERMINAL_DIFFICULTY), DEFAULT_TERMINAL_BLOCK, ExecutionBlockHash::zero(), None, // FIXME(capella): should this be the default? diff --git a/beacon_node/genesis/src/eth1_genesis_service.rs b/beacon_node/genesis/src/eth1_genesis_service.rs index 9a4f85c064c..3347f6c6c2a 100644 --- a/beacon_node/genesis/src/eth1_genesis_service.rs +++ b/beacon_node/genesis/src/eth1_genesis_service.rs @@ -13,7 +13,7 @@ use std::sync::{ }; use std::time::Duration; use tokio::time::sleep; -use types::{BeaconState, ChainSpec, Deposit, Eth1Data, EthSpec, Hash256}; +use types::{BeaconState, ChainSpec, Deposit, Eth1Data, EthSpec, FixedBytesExtended, Hash256}; /// The number of blocks that are pulled per request whilst waiting for genesis. const BLOCKS_PER_GENESIS_POLL: usize = 99; diff --git a/beacon_node/genesis/src/interop.rs b/beacon_node/genesis/src/interop.rs index 4c78b8efd8f..90c4ad6e665 100644 --- a/beacon_node/genesis/src/interop.rs +++ b/beacon_node/genesis/src/interop.rs @@ -180,12 +180,12 @@ mod test { for v in state.validators() { let creds = v.withdrawal_credentials; assert_eq!( - creds.as_bytes()[0], + creds.as_slice()[0], spec.bls_withdrawal_prefix_byte, "first byte of withdrawal creds should be bls prefix" ); assert_eq!( - &creds.as_bytes()[1..], + &creds.as_slice()[1..], &hash(&v.pubkey.as_ssz_bytes())[1..], "rest of withdrawal creds should be pubkey hash" ) @@ -242,7 +242,7 @@ mod test { for (index, v) in state.validators().iter().enumerate() { let withdrawal_credientials = v.withdrawal_credentials; - let creds = withdrawal_credientials.as_bytes(); + let creds = withdrawal_credientials.as_slice(); if index % 2 == 0 { assert_eq!( creds[0], spec.bls_withdrawal_prefix_byte, diff --git a/beacon_node/genesis/tests/tests.rs b/beacon_node/genesis/tests/tests.rs index f33794814b4..b5c6d85afeb 100644 --- a/beacon_node/genesis/tests/tests.rs +++ b/beacon_node/genesis/tests/tests.rs @@ -6,7 +6,9 @@ use genesis::{Eth1Config, Eth1GenesisService}; use sensitive_url::SensitiveUrl; use state_processing::is_valid_genesis_state; use std::time::Duration; -use types::{test_utils::generate_deterministic_keypair, Hash256, MinimalEthSpec}; +use types::{ + test_utils::generate_deterministic_keypair, FixedBytesExtended, Hash256, MinimalEthSpec, +}; pub fn new_env() -> Environment { EnvironmentBuilder::minimal() diff --git a/beacon_node/http_api/src/block_id.rs b/beacon_node/http_api/src/block_id.rs index 63d00edbff6..d29c89fa7c0 100644 --- a/beacon_node/http_api/src/block_id.rs +++ b/beacon_node/http_api/src/block_id.rs @@ -5,7 +5,10 @@ use eth2::types::BlockId as CoreBlockId; use std::fmt; use std::str::FromStr; use std::sync::Arc; -use types::{BlobSidecarList, EthSpec, Hash256, SignedBeaconBlock, SignedBlindedBeaconBlock, Slot}; +use types::{ + BlobSidecarList, EthSpec, FixedBytesExtended, Hash256, SignedBeaconBlock, + SignedBlindedBeaconBlock, Slot, +}; /// Wraps `eth2::types::BlockId` and provides a simple way to obtain a block or root for a given /// `BlockId`. @@ -274,10 +277,27 @@ impl BlockId { warp_utils::reject::custom_not_found(format!("beacon block with root {}", root)) })?; + // Error if the block is pre-Deneb and lacks blobs. + let blob_kzg_commitments = block.message().body().blob_kzg_commitments().map_err(|_| { + warp_utils::reject::custom_bad_request( + "block is pre-Deneb and has no blobs".to_string(), + ) + })?; + // Return the `BlobSidecarList` identified by `self`. - let blob_sidecar_list = chain - .get_blobs(&root) - .map_err(warp_utils::reject::beacon_chain_error)?; + let blob_sidecar_list = if !blob_kzg_commitments.is_empty() { + chain + .store + .get_blobs(&root) + .map_err(|e| warp_utils::reject::beacon_chain_error(e.into()))? + .ok_or_else(|| { + warp_utils::reject::custom_not_found(format!( + "no blobs stored for block {root}" + )) + })? + } else { + BlobSidecarList::empty_uninitialized() + }; let blob_sidecar_list_filtered = match indices.indices { Some(vec) => { diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 102d138aa3a..22e9931043e 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -714,7 +714,14 @@ pub fn serve( task_spawner: TaskSpawner, chain: Arc>, query_res: Result| { - task_spawner.blocking_json_task(Priority::P1, move || { + // Prioritise requests for validators at the head. These should be fast to service + // and could be required by the validator client. + let priority = if let StateId(eth2::types::StateId::Head) = state_id { + Priority::P0 + } else { + Priority::P1 + }; + task_spawner.blocking_json_task(priority, move || { let query = query_res?; crate::validators::get_beacon_state_validators( state_id, @@ -737,7 +744,14 @@ pub fn serve( task_spawner: TaskSpawner, chain: Arc>, query: ValidatorsRequestBody| { - task_spawner.blocking_json_task(Priority::P1, move || { + // Prioritise requests for validators at the head. These should be fast to service + // and could be required by the validator client. + let priority = if let StateId(eth2::types::StateId::Head) = state_id { + Priority::P0 + } else { + Priority::P1 + }; + task_spawner.blocking_json_task(priority, move || { crate::validators::get_beacon_state_validators( state_id, chain, @@ -763,7 +777,14 @@ pub fn serve( task_spawner: TaskSpawner, chain: Arc>, validator_id: ValidatorId| { - task_spawner.blocking_json_task(Priority::P1, move || { + // Prioritise requests for validators at the head. These should be fast to service + // and could be required by the validator client. + let priority = if let StateId(eth2::types::StateId::Head) = state_id { + Priority::P0 + } else { + Priority::P1 + }; + task_spawner.blocking_json_task(priority, move || { let (data, execution_optimistic, finalized) = state_id .map_state_and_execution_optimistic_and_finalized( &chain, diff --git a/beacon_node/http_api/src/publish_blocks.rs b/beacon_node/http_api/src/publish_blocks.rs index a53bb7340df..791d0eae3ae 100644 --- a/beacon_node/http_api/src/publish_blocks.rs +++ b/beacon_node/http_api/src/publish_blocks.rs @@ -548,7 +548,7 @@ fn check_slashable( block_root: Hash256, block_clone: &SignedBeaconBlock>, log_clone: &Logger, -) -> Result<(), BlockError> { +) -> Result<(), BlockError> { let slashable_cache = chain_clone.observed_slashable.read(); if let Some(blobs) = blobs_opt.as_ref() { blobs.iter().try_for_each(|blob| { diff --git a/beacon_node/http_api/tests/broadcast_validation_tests.rs b/beacon_node/http_api/tests/broadcast_validation_tests.rs index 4b884bb5192..59cdbb1c99e 100644 --- a/beacon_node/http_api/tests/broadcast_validation_tests.rs +++ b/beacon_node/http_api/tests/broadcast_validation_tests.rs @@ -7,7 +7,7 @@ use eth2::types::{BroadcastValidation, PublishBlockRequest}; use http_api::test_utils::InteractiveTester; use http_api::{publish_blinded_block, publish_block, reconstruct_block, ProvenancedBlock}; use std::sync::Arc; -use types::{Epoch, EthSpec, ForkName, Hash256, MainnetEthSpec, Slot}; +use types::{Epoch, EthSpec, FixedBytesExtended, ForkName, Hash256, MainnetEthSpec, Slot}; use warp::Rejection; use warp_utils::reject::CustomBadRequest; @@ -81,9 +81,7 @@ pub async fn gossip_invalid() { /* mandated by Beacon API spec */ assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()) - ); + assert_server_message_error(error_response, "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()); } /// This test checks that a block that is valid from a gossip perspective is accepted when using `broadcast_validation=gossip`. @@ -268,10 +266,7 @@ pub async fn consensus_invalid() { /* mandated by Beacon API spec */ assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()) - ); + assert_server_message_error(error_response, "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()); } /// This test checks that a block that is only valid from a gossip perspective is rejected when using `broadcast_validation=consensus`. @@ -317,10 +312,7 @@ pub async fn consensus_gossip() { /* mandated by Beacon API spec */ assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string()) - ); + assert_server_message_error(error_response, "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string()); } /// This test checks that a block that is valid from both a gossip and consensus perspective, but nonetheless equivocates, is accepted when using `broadcast_validation=consensus`. @@ -489,10 +481,7 @@ pub async fn equivocation_invalid() { /* mandated by Beacon API spec */ assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()) - ); + assert_server_message_error(error_response, "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()); } /// This test checks that a block that is valid from both a gossip and consensus perspective is rejected when using `broadcast_validation=consensus_and_equivocation`. @@ -566,9 +555,9 @@ pub async fn equivocation_consensus_early_equivocation() { let error_response: eth2::Error = response.err().unwrap(); assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: BlockError(Slashable)".to_string()) + assert_server_message_error( + error_response, + "BAD_REQUEST: BlockError(Slashable)".to_string(), ); } @@ -616,10 +605,7 @@ pub async fn equivocation_gossip() { /* mandated by Beacon API spec */ assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string()) - ); + assert_server_message_error(error_response, "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string()); } /// This test checks that a block that is valid from both a gossip and consensus perspective but @@ -797,10 +783,7 @@ pub async fn blinded_gossip_invalid() { /* mandated by Beacon API spec */ assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()) - ); + assert_server_message_error(error_response, "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()); } /// This test checks that a block that is valid from a gossip perspective is accepted when using `broadcast_validation=gossip`. @@ -978,10 +961,7 @@ pub async fn blinded_consensus_invalid() { /* mandated by Beacon API spec */ assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()) - ); + assert_server_message_error(error_response, "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()); } /// This test checks that a block that is only valid from a gossip perspective is rejected when using `broadcast_validation=consensus`. @@ -1027,10 +1007,7 @@ pub async fn blinded_consensus_gossip() { /* mandated by Beacon API spec */ assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string()) - ); + assert_server_message_error(error_response, "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string()); } /// This test checks that a block that is valid from both a gossip and consensus perspective is accepted when using `broadcast_validation=consensus`. @@ -1122,10 +1099,7 @@ pub async fn blinded_equivocation_invalid() { /* mandated by Beacon API spec */ assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()) - ); + assert_server_message_error(error_response, "BAD_REQUEST: BlockError(NotFinalizedDescendant { block_parent_root: 0x0000000000000000000000000000000000000000000000000000000000000000 })".to_string()); } /// This test checks that a block that is valid from both a gossip and consensus perspective is rejected when using `broadcast_validation=consensus_and_equivocation`. @@ -1195,9 +1169,9 @@ pub async fn blinded_equivocation_consensus_early_equivocation() { let error_response: eth2::Error = response.err().unwrap(); assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: BlockError(Slashable)".to_string()) + assert_server_message_error( + error_response, + "BAD_REQUEST: BlockError(Slashable)".to_string(), ); } @@ -1246,9 +1220,7 @@ pub async fn blinded_equivocation_gossip() { /* mandated by Beacon API spec */ assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST)); - assert!( - matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string()) - ); + assert_server_message_error(error_response, "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string()); } /// This test checks that a block that is valid from both a gossip and @@ -1401,3 +1373,10 @@ pub async fn blinded_equivocation_full_pass() { .chain .block_is_known_to_fork_choice(&block.canonical_root())); } + +fn assert_server_message_error(error_response: eth2::Error, expected_message: String) { + let eth2::Error::ServerMessage(err) = error_response else { + panic!("Not a eth2::Error::ServerMessage"); + }; + assert_eq!(err.message, expected_message); +} diff --git a/beacon_node/http_api/tests/fork_tests.rs b/beacon_node/http_api/tests/fork_tests.rs index db8a0ab2b54..b5b3edf892e 100644 --- a/beacon_node/http_api/tests/fork_tests.rs +++ b/beacon_node/http_api/tests/fork_tests.rs @@ -10,7 +10,7 @@ use http_api::test_utils::*; use std::collections::HashSet; use types::{ test_utils::{generate_deterministic_keypair, generate_deterministic_keypairs}, - Address, ChainSpec, Epoch, EthSpec, Hash256, MinimalEthSpec, Slot, + Address, ChainSpec, Epoch, EthSpec, FixedBytesExtended, Hash256, MinimalEthSpec, Slot, }; type E = MinimalEthSpec; diff --git a/beacon_node/http_api/tests/interactive_tests.rs b/beacon_node/http_api/tests/interactive_tests.rs index 2f417cf7ba5..9ff411cf1c9 100644 --- a/beacon_node/http_api/tests/interactive_tests.rs +++ b/beacon_node/http_api/tests/interactive_tests.rs @@ -18,8 +18,8 @@ use std::collections::HashMap; use std::sync::Arc; use std::time::Duration; use types::{ - Address, Epoch, EthSpec, ExecPayload, ExecutionBlockHash, ForkName, MainnetEthSpec, - MinimalEthSpec, ProposerPreparationData, Slot, + Address, Epoch, EthSpec, ExecPayload, ExecutionBlockHash, FixedBytesExtended, ForkName, + Hash256, MainnetEthSpec, MinimalEthSpec, ProposerPreparationData, Slot, Uint256, }; type E = MainnetEthSpec; @@ -394,7 +394,7 @@ pub async fn proposer_boost_re_org_test( // Test using the latest fork so that we simulate conditions as similar to mainnet as possible. let mut spec = ForkName::latest().make_genesis_spec(E::default_spec()); - spec.terminal_total_difficulty = 1.into(); + spec.terminal_total_difficulty = Uint256::from(1); // Ensure there are enough validators to have `attesters_per_slot`. let attesters_per_slot = 10; @@ -639,18 +639,20 @@ pub async fn proposer_boost_re_org_test( if should_re_org { // Block C should build on A. - assert_eq!(block_c.parent_root(), block_a_root.into()); + assert_eq!(block_c.parent_root(), Hash256::from(block_a_root)); } else { // Block C should build on B. assert_eq!(block_c.parent_root(), block_b_root); } // Applying block C should cause it to become head regardless (re-org or continuation). - let block_root_c = harness - .process_block_result((block_c.clone(), block_c_blobs)) - .await - .unwrap() - .into(); + let block_root_c = Hash256::from( + harness + .process_block_result((block_c.clone(), block_c_blobs)) + .await + .unwrap(), + ); + assert_eq!(harness.head_block_root(), block_root_c); // Check the fork choice updates that were sent. @@ -814,7 +816,7 @@ pub async fn fork_choice_before_proposal() { // Due to proposer boost, the head should be C during slot C. assert_eq!( harness.chain.canonical_head.cached_head().head_block_root(), - block_root_c.into() + Hash256::from(block_root_c) ); // Ensure that building a block via the HTTP API re-runs fork choice and builds block D upon B. @@ -841,10 +843,10 @@ pub async fn fork_choice_before_proposal() { // Head is now B. assert_eq!( harness.chain.canonical_head.cached_head().head_block_root(), - block_root_b.into() + Hash256::from(block_root_b) ); // D's parent is B. - assert_eq!(block_d.parent_root(), block_root_b.into()); + assert_eq!(block_d.parent_root(), Hash256::from(block_root_b)); } // Test that attestations to unknown blocks are requeued and processed when their block arrives. diff --git a/beacon_node/http_api/tests/status_tests.rs b/beacon_node/http_api/tests/status_tests.rs index 801cd44074d..8f962995300 100644 --- a/beacon_node/http_api/tests/status_tests.rs +++ b/beacon_node/http_api/tests/status_tests.rs @@ -6,7 +6,7 @@ use beacon_chain::{ use eth2::StatusCode; use execution_layer::{PayloadStatusV1, PayloadStatusV1Status}; use http_api::test_utils::InteractiveTester; -use types::{EthSpec, ExecPayload, ForkName, MinimalEthSpec, Slot}; +use types::{EthSpec, ExecPayload, ForkName, MinimalEthSpec, Slot, Uint256}; type E = MinimalEthSpec; @@ -14,7 +14,7 @@ type E = MinimalEthSpec; async fn post_merge_tester(chain_depth: u64, validator_count: u64) -> InteractiveTester { // Test using latest fork so that we simulate conditions as similar to mainnet as possible. let mut spec = ForkName::latest().make_genesis_spec(E::default_spec()); - spec.terminal_total_difficulty = 1.into(); + spec.terminal_total_difficulty = Uint256::from(1); let tester = InteractiveTester::::new(Some(spec), validator_count as usize).await; let harness = &tester.harness; diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 62c196d9177..6e6f72b6c08 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -1667,6 +1667,93 @@ impl ApiTester { self } + /// Test fetching of blob sidecars that are not available in the database due to pruning. + /// + /// If `zero_blobs` is false, test a block with >0 blobs, which should be unavailable. + /// If `zero_blobs` is true, then test a block with 0 blobs, which should still be available. + pub async fn test_get_blob_sidecars_pruned(self, zero_blobs: bool) -> Self { + // Prune all blobs prior to the database's split epoch. + let store = &self.chain.store; + let split_epoch = store.get_split_slot().epoch(E::slots_per_epoch()); + let force_prune = true; + self.chain + .store + .try_prune_blobs(force_prune, split_epoch) + .unwrap(); + + let oldest_blob_slot = store.get_blob_info().oldest_blob_slot.unwrap(); + + assert_ne!( + oldest_blob_slot, 0, + "blob pruning should have pruned some blobs" + ); + + // Find a block with either 0 blobs or 1+ depending on the value of `zero_blobs`. + let mut test_slot = None; + for slot in 0..oldest_blob_slot.as_u64() { + let block_id = BlockId(CoreBlockId::Slot(Slot::new(slot))); + let (block, _, _) = block_id.blinded_block(&self.chain).unwrap(); + let num_blobs = block.num_expected_blobs(); + + if (zero_blobs && num_blobs == 0) || (!zero_blobs && num_blobs > 0) { + test_slot = Some(Slot::new(slot)); + break; + } + } + let test_slot = test_slot.expect(&format!( + "should be able to find a block matching zero_blobs={zero_blobs}" + )); + + match self + .client + .get_blobs::(CoreBlockId::Slot(test_slot), None) + .await + { + Ok(result) => { + if zero_blobs { + assert_eq!( + &result.unwrap().data[..], + &[], + "empty blobs are always available" + ); + } else { + assert_eq!(result, None, "blobs should have been pruned"); + } + } + Err(e) => panic!("failed with non-404 status: {e:?}"), + } + + self + } + + pub async fn test_get_blob_sidecars_pre_deneb(self) -> Self { + let oldest_blob_slot = self.chain.store.get_blob_info().oldest_blob_slot.unwrap(); + assert_ne!( + oldest_blob_slot, 0, + "oldest_blob_slot should be non-zero and post-Deneb" + ); + let test_slot = oldest_blob_slot - 1; + assert!( + !self + .chain + .spec + .fork_name_at_slot::(test_slot) + .deneb_enabled(), + "Deneb should not be enabled at {test_slot}" + ); + + match self + .client + .get_blobs::(CoreBlockId::Slot(test_slot), None) + .await + { + Ok(result) => panic!("queries for pre-Deneb slots should fail. got: {result:?}"), + Err(e) => assert_eq!(e.status().unwrap(), 400), + } + + self + } + pub async fn test_beacon_blocks_attestations(self) -> Self { for block_id in self.interesting_block_ids() { let result = self @@ -6846,6 +6933,36 @@ async fn get_blob_sidecars() { .await; } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn get_blob_sidecars_pruned() { + let mut config = ApiTesterConfig::default(); + config.spec.altair_fork_epoch = Some(Epoch::new(0)); + config.spec.bellatrix_fork_epoch = Some(Epoch::new(0)); + config.spec.capella_fork_epoch = Some(Epoch::new(0)); + config.spec.deneb_fork_epoch = Some(Epoch::new(0)); + + ApiTester::new_from_config(config) + .await + .test_get_blob_sidecars_pruned(false) + .await + .test_get_blob_sidecars_pruned(true) + .await; +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn get_blob_sidecars_pre_deneb() { + let mut config = ApiTesterConfig::default(); + config.spec.altair_fork_epoch = Some(Epoch::new(0)); + config.spec.bellatrix_fork_epoch = Some(Epoch::new(0)); + config.spec.capella_fork_epoch = Some(Epoch::new(0)); + config.spec.deneb_fork_epoch = Some(Epoch::new(1)); + + ApiTester::new_from_config(config) + .await + .test_get_blob_sidecars_pre_deneb() + .await; +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn post_validator_liveness_epoch() { ApiTester::new() diff --git a/beacon_node/lighthouse_network/Cargo.toml b/beacon_node/lighthouse_network/Cargo.toml index cb89d492d1d..c666b8b4552 100644 --- a/beacon_node/lighthouse_network/Cargo.toml +++ b/beacon_node/lighthouse_network/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Sigma Prime "] edition = { workspace = true } [dependencies] +alloy-primitives = { workspace = true} discv5 = { workspace = true } gossipsub = { workspace = true } unsigned-varint = { version = "0.8", features = ["codec"] } @@ -46,10 +47,10 @@ itertools = { workspace = true } # Local dependencies void = "1.0.2" -libp2p-mplex = "0.41" +libp2p-mplex = "0.42" [dependencies.libp2p] -version = "0.53" +version = "0.54" default-features = false features = ["identify", "yamux", "noise", "dns", "tcp", "tokio", "plaintext", "secp256k1", "macros", "ecdsa", "metrics", "quic", "upnp"] diff --git a/beacon_node/lighthouse_network/gossipsub/Cargo.toml b/beacon_node/lighthouse_network/gossipsub/Cargo.toml index ef8fb1b12b5..a01d60dae99 100644 --- a/beacon_node/lighthouse_network/gossipsub/Cargo.toml +++ b/beacon_node/lighthouse_network/gossipsub/Cargo.toml @@ -27,7 +27,7 @@ futures-timer = "3.0.2" getrandom = "0.2.12" hashlink.workspace = true hex_fmt = "0.3.0" -libp2p = { version = "0.53", default-features = false } +libp2p = { version = "0.54", default-features = false } quick-protobuf = "0.8" quick-protobuf-codec = "0.3" rand = "0.8" diff --git a/beacon_node/lighthouse_network/gossipsub/src/behaviour.rs b/beacon_node/lighthouse_network/gossipsub/src/behaviour.rs index 0a3b7a9f529..94a7ee1fc39 100644 --- a/beacon_node/lighthouse_network/gossipsub/src/behaviour.rs +++ b/beacon_node/lighthouse_network/gossipsub/src/behaviour.rs @@ -35,7 +35,11 @@ use hashlink::LinkedHashMap; use prometheus_client::registry::Registry; use rand::{seq::SliceRandom, thread_rng}; -use libp2p::core::{multiaddr::Protocol::Ip4, multiaddr::Protocol::Ip6, Endpoint, Multiaddr}; +use libp2p::core::{ + multiaddr::Protocol::{Ip4, Ip6}, + transport::PortUse, + Endpoint, Multiaddr, +}; use libp2p::identity::Keypair; use libp2p::identity::PeerId; use libp2p::swarm::{ @@ -3161,6 +3165,7 @@ where peer_id: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { // By default we assume a peer is only a floodsub peer. // diff --git a/beacon_node/lighthouse_network/gossipsub/src/behaviour/tests.rs b/beacon_node/lighthouse_network/gossipsub/src/behaviour/tests.rs index a378198be33..19d09cd890f 100644 --- a/beacon_node/lighthouse_network/gossipsub/src/behaviour/tests.rs +++ b/beacon_node/lighthouse_network/gossipsub/src/behaviour/tests.rs @@ -220,6 +220,7 @@ where ConnectedPoint::Dialer { address, role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, } } else { ConnectedPoint::Listener { @@ -284,6 +285,7 @@ where let fake_endpoint = ConnectedPoint::Dialer { address: Multiaddr::empty(), role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }; // this is not relevant // peer_connections.connections should never be empty. @@ -296,6 +298,7 @@ where connection_id, endpoint: &fake_endpoint, remaining_established: active_connections, + cause: None, })); } } @@ -635,6 +638,7 @@ fn test_join() { endpoint: &ConnectedPoint::Dialer { address, role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }, failed_addresses: &[], other_established: 0, @@ -4181,6 +4185,7 @@ fn test_scoring_p6() { endpoint: &ConnectedPoint::Dialer { address: addr.clone(), role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }, failed_addresses: &[], other_established: 0, @@ -4202,6 +4207,7 @@ fn test_scoring_p6() { endpoint: &ConnectedPoint::Dialer { address: addr2.clone(), role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }, failed_addresses: &[], other_established: 1, @@ -4232,6 +4238,7 @@ fn test_scoring_p6() { endpoint: &ConnectedPoint::Dialer { address: addr, role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }, failed_addresses: &[], other_established: 2, diff --git a/beacon_node/lighthouse_network/src/discovery/mod.rs b/beacon_node/lighthouse_network/src/discovery/mod.rs index 7b297d243bd..c92a8bd2b45 100644 --- a/beacon_node/lighthouse_network/src/discovery/mod.rs +++ b/beacon_node/lighthouse_network/src/discovery/mod.rs @@ -18,6 +18,7 @@ pub use libp2p::identity::{Keypair, PublicKey}; use enr::{ATTESTATION_BITFIELD_ENR_KEY, ETH2_ENR_KEY, SYNC_COMMITTEE_BITFIELD_ENR_KEY}; use futures::prelude::*; use futures::stream::FuturesUnordered; +use libp2p::core::transport::PortUse; use libp2p::multiaddr::Protocol; use libp2p::swarm::behaviour::{DialFailure, FromSwarm}; use libp2p::swarm::THandlerInEvent; @@ -983,6 +984,7 @@ impl NetworkBehaviour for Discovery { _peer: PeerId, _addr: &Multiaddr, _role_override: libp2p::core::Endpoint, + _port_use: PortUse, ) -> Result, libp2p::swarm::ConnectionDenied> { Ok(ConnectionHandler) } diff --git a/beacon_node/lighthouse_network/src/discovery/subnet_predicate.rs b/beacon_node/lighthouse_network/src/discovery/subnet_predicate.rs index 8bc5e25fde9..e198b3ee17f 100644 --- a/beacon_node/lighthouse_network/src/discovery/subnet_predicate.rs +++ b/beacon_node/lighthouse_network/src/discovery/subnet_predicate.rs @@ -41,7 +41,7 @@ where .map_or(false, |b| b.get(*s.deref() as usize).unwrap_or(false)), Subnet::DataColumn(s) => { let mut subnets = DataColumnSubnetId::compute_custody_subnets::( - enr.node_id().raw().into(), + enr.node_id().raw(), custody_subnet_count, &spec, ); diff --git a/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs b/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs index 3858a2a5392..d9df8e7c4bb 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs @@ -4,6 +4,7 @@ use std::net::IpAddr; use std::task::{Context, Poll}; use futures::StreamExt; +use libp2p::core::transport::PortUse; use libp2p::core::ConnectedPoint; use libp2p::identity::PeerId; use libp2p::swarm::behaviour::{ConnectionClosed, ConnectionEstablished, DialFailure, FromSwarm}; @@ -214,6 +215,7 @@ impl NetworkBehaviour for PeerManager { peer_id: PeerId, addr: &libp2p::Multiaddr, _role_override: libp2p::core::Endpoint, + _port_use: PortUse, ) -> Result, libp2p::swarm::ConnectionDenied> { trace!(self.log, "Outbound connection"; "peer_id" => %peer_id, "multiaddr" => %addr); match self.ban_status(&peer_id) { diff --git a/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs index fbde8f9bc87..6e76fd4bb00 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs @@ -791,10 +791,9 @@ impl PeerDB { ) => { // Update the ENR if one exists, and compute the custody subnets if let Some(enr) = enr { - let node_id = enr.node_id().raw().into(); let custody_subnet_count = enr.custody_subnet_count::(&self.spec); let custody_subnets = DataColumnSubnetId::compute_custody_subnets::( - node_id, + enr.node_id().raw(), custody_subnet_count, &self.spec, ) diff --git a/beacon_node/lighthouse_network/src/peer_manager/peerdb/peer_info.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb/peer_info.rs index 5ff8f74dd46..1ea3f8ed5fc 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/peerdb/peer_info.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/peerdb/peer_info.rs @@ -374,7 +374,7 @@ impl PeerInfo { if self.custody_subnets.is_empty() { if let Ok(custody_subnet_count) = meta_data.custody_subnet_count() { let custody_subnets = DataColumnSubnetId::compute_custody_subnets::( - node_id.raw().into(), + node_id.raw(), std::cmp::min(*custody_subnet_count, spec.data_column_sidecar_subnet_count), spec, ) diff --git a/beacon_node/lighthouse_network/src/rpc/codec/base.rs b/beacon_node/lighthouse_network/src/rpc/codec/base.rs index 42a31d3480a..4b9e8d50975 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/base.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/base.rs @@ -176,7 +176,7 @@ mod tests { use crate::rpc::protocol::*; use std::sync::Arc; - use types::{Epoch, ForkContext, ForkName, Hash256, Slot}; + use types::{Epoch, FixedBytesExtended, ForkContext, ForkName, Hash256, Slot}; use unsigned_varint::codec::Uvi; type Spec = types::MainnetEthSpec; diff --git a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs index eb97152acd2..8f5143d7ed9 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -426,11 +426,12 @@ fn context_bytes( RPCResponse::BlobsByRange(_) | RPCResponse::BlobsByRoot(_) => { return fork_context.to_context_bytes(ForkName::Deneb); } - RPCResponse::DataColumnsByRoot(_) | RPCResponse::DataColumnsByRange(_) => { + RPCResponse::DataColumnsByRoot(d) | RPCResponse::DataColumnsByRange(d) => { // TODO(das): Remove deneb fork after `peerdas-devnet-2`. - return if fork_context.spec.eip7594_fork_epoch - == fork_context.spec.deneb_fork_epoch - { + return if matches!( + fork_context.spec.fork_name_at_slot::(d.slot()), + ForkName::Deneb + ) { fork_context.to_context_bytes(ForkName::Deneb) } else { fork_context.to_context_bytes(ForkName::Electra) @@ -834,8 +835,8 @@ mod tests { use crate::types::{EnrAttestationBitfield, EnrSyncCommitteeBitfield}; use types::{ blob_sidecar::BlobIdentifier, BeaconBlock, BeaconBlockAltair, BeaconBlockBase, - BeaconBlockBellatrix, DataColumnIdentifier, EmptyBlock, Epoch, FullPayload, Signature, - Slot, + BeaconBlockBellatrix, DataColumnIdentifier, EmptyBlock, Epoch, FixedBytesExtended, + FullPayload, Signature, Slot, }; type Spec = types::MainnetEthSpec; @@ -925,9 +926,9 @@ mod tests { fn status_message() -> StatusMessage { StatusMessage { fork_digest: [0; 4], - finalized_root: Hash256::from_low_u64_be(0), + finalized_root: Hash256::zero(), finalized_epoch: Epoch::new(1), - head_root: Hash256::from_low_u64_be(0), + head_root: Hash256::zero(), head_slot: Slot::new(1), } } @@ -1686,9 +1687,9 @@ mod tests { // Status message is 84 bytes uncompressed. `max_compressed_len` is 32 + 84 + 84/6 = 130. let status_message_bytes = StatusMessage { fork_digest: [0; 4], - finalized_root: Hash256::from_low_u64_be(0), + finalized_root: Hash256::zero(), finalized_epoch: Epoch::new(1), - head_root: Hash256::from_low_u64_be(0), + head_root: Hash256::zero(), head_slot: Slot::new(1), } .as_ssz_bytes(); @@ -1809,9 +1810,9 @@ mod tests { // Status message is 84 bytes uncompressed. `max_compressed_len` is 32 + 84 + 84/6 = 130. let status_message_bytes = StatusMessage { fork_digest: [0; 4], - finalized_root: Hash256::from_low_u64_be(0), + finalized_root: Hash256::zero(), finalized_epoch: Epoch::new(1), - head_root: Hash256::from_low_u64_be(0), + head_root: Hash256::zero(), head_slot: Slot::new(1), } .as_ssz_bytes(); diff --git a/beacon_node/lighthouse_network/src/rpc/mod.rs b/beacon_node/lighthouse_network/src/rpc/mod.rs index 4fe3778f0a4..cd591554a36 100644 --- a/beacon_node/lighthouse_network/src/rpc/mod.rs +++ b/beacon_node/lighthouse_network/src/rpc/mod.rs @@ -6,6 +6,7 @@ use futures::future::FutureExt; use handler::RPCHandler; +use libp2p::core::transport::PortUse; use libp2p::swarm::{ handler::ConnectionHandler, CloseConnection, ConnectionId, NetworkBehaviour, NotifyHandler, ToSwarm, @@ -259,6 +260,7 @@ where peer_id: PeerId, _addr: &libp2p::Multiaddr, _role_override: libp2p::core::Endpoint, + _port_use: PortUse, ) -> Result, libp2p::swarm::ConnectionDenied> { let protocol = SubstreamProtocol::new( RPCProtocol { diff --git a/beacon_node/lighthouse_network/src/service/mod.rs b/beacon_node/lighthouse_network/src/service/mod.rs index 35758f1688c..a95912ff060 100644 --- a/beacon_node/lighthouse_network/src/service/mod.rs +++ b/beacon_node/lighthouse_network/src/service/mod.rs @@ -1661,7 +1661,11 @@ impl Network { /// Handle an identify event. fn inject_identify_event(&mut self, event: identify::Event) -> Option> { match event { - identify::Event::Received { peer_id, mut info } => { + identify::Event::Received { + peer_id, + mut info, + connection_id: _, + } => { if info.listen_addrs.len() > MAX_IDENTIFY_ADDRESSES { debug!( self.log, diff --git a/beacon_node/lighthouse_network/src/types/globals.rs b/beacon_node/lighthouse_network/src/types/globals.rs index 178ba64641c..c76e0a18577 100644 --- a/beacon_node/lighthouse_network/src/types/globals.rs +++ b/beacon_node/lighthouse_network/src/types/globals.rs @@ -121,18 +121,24 @@ impl NetworkGlobals { /// Compute custody data columns the node is assigned to custody. pub fn custody_columns(&self) -> Vec { let enr = self.local_enr(); - let node_id = enr.node_id().raw().into(); let custody_subnet_count = enr.custody_subnet_count::(&self.spec); - DataColumnSubnetId::compute_custody_columns::(node_id, custody_subnet_count, &self.spec) - .collect() + DataColumnSubnetId::compute_custody_columns::( + enr.node_id().raw(), + custody_subnet_count, + &self.spec, + ) + .collect() } /// Compute custody data column subnets the node is assigned to custody. pub fn custody_subnets(&self) -> impl Iterator { let enr = self.local_enr(); - let node_id = enr.node_id().raw().into(); let custody_subnet_count = enr.custody_subnet_count::(&self.spec); - DataColumnSubnetId::compute_custody_subnets::(node_id, custody_subnet_count, &self.spec) + DataColumnSubnetId::compute_custody_subnets::( + enr.node_id().raw(), + custody_subnet_count, + &self.spec, + ) } /// Returns a connected peer that: diff --git a/beacon_node/lighthouse_network/tests/common.rs b/beacon_node/lighthouse_network/tests/common.rs index 25431226ca6..660d786169f 100644 --- a/beacon_node/lighthouse_network/tests/common.rs +++ b/beacon_node/lighthouse_network/tests/common.rs @@ -9,7 +9,8 @@ use std::sync::Arc; use std::sync::Weak; use tokio::runtime::Runtime; use types::{ - ChainSpec, EnrForkId, Epoch, EthSpec, ForkContext, ForkName, Hash256, MinimalEthSpec, Slot, + ChainSpec, EnrForkId, Epoch, EthSpec, FixedBytesExtended, ForkContext, ForkName, Hash256, + MinimalEthSpec, Slot, }; type E = MinimalEthSpec; diff --git a/beacon_node/lighthouse_network/tests/rpc_tests.rs b/beacon_node/lighthouse_network/tests/rpc_tests.rs index 12a1c593930..25d249960d2 100644 --- a/beacon_node/lighthouse_network/tests/rpc_tests.rs +++ b/beacon_node/lighthouse_network/tests/rpc_tests.rs @@ -15,8 +15,8 @@ use tokio::runtime::Runtime; use tokio::time::sleep; use types::{ BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockBellatrix, BlobSidecar, ChainSpec, - EmptyBlock, Epoch, EthSpec, ForkContext, ForkName, Hash256, MinimalEthSpec, Signature, - SignedBeaconBlock, Slot, + EmptyBlock, Epoch, EthSpec, FixedBytesExtended, ForkContext, ForkName, Hash256, MinimalEthSpec, + Signature, SignedBeaconBlock, Slot, }; type E = MinimalEthSpec; @@ -77,18 +77,18 @@ fn test_tcp_status_rpc() { // Dummy STATUS RPC message let rpc_request = Request::Status(StatusMessage { fork_digest: [0; 4], - finalized_root: Hash256::from_low_u64_be(0), + finalized_root: Hash256::zero(), finalized_epoch: Epoch::new(1), - head_root: Hash256::from_low_u64_be(0), + head_root: Hash256::zero(), head_slot: Slot::new(1), }); // Dummy STATUS RPC message let rpc_response = Response::Status(StatusMessage { fork_digest: [0; 4], - finalized_root: Hash256::from_low_u64_be(0), + finalized_root: Hash256::zero(), finalized_epoch: Epoch::new(1), - head_root: Hash256::from_low_u64_be(0), + head_root: Hash256::zero(), head_slot: Slot::new(1), }); @@ -756,12 +756,12 @@ fn test_tcp_blocks_by_root_chunked_rpc() { // BlocksByRoot Request let rpc_request = Request::BlocksByRoot(BlocksByRootRequest::new( vec![ - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), ], &spec, )); @@ -894,16 +894,16 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() { // BlocksByRoot Request let rpc_request = Request::BlocksByRoot(BlocksByRootRequest::new( vec![ - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), - Hash256::from_low_u64_be(0), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), + Hash256::zero(), ], &spec, )); diff --git a/beacon_node/network/Cargo.toml b/beacon_node/network/Cargo.toml index 511cbc3e3c7..192fdd644c3 100644 --- a/beacon_node/network/Cargo.toml +++ b/beacon_node/network/Cargo.toml @@ -14,6 +14,7 @@ eth2 = { workspace = true } gossipsub = { workspace = true } [dependencies] +alloy-primitives = { workspace = true } async-channel = { workspace = true } anyhow = { workspace = true } beacon_chain = { workspace = true } diff --git a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs index d5d83d540a0..62f1371c811 100644 --- a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs @@ -780,7 +780,7 @@ impl NetworkBeaconProcessor { metrics::set_gauge(&metrics::BEACON_BLOB_DELAY_GOSSIP, delay.as_millis() as i64); match self .chain - .verify_blob_sidecar_for_gossip(blob_sidecar, blob_index) + .verify_blob_sidecar_for_gossip(blob_sidecar.clone(), blob_index) { Ok(gossip_verified_blob) => { metrics::inc_counter(&metrics::BEACON_PROCESSOR_GOSSIP_BLOB_VERIFIED_TOTAL); @@ -825,16 +825,19 @@ impl NetworkBeaconProcessor { } Err(err) => { match err { - GossipBlobError::BlobParentUnknown(blob) => { + GossipBlobError::BlobParentUnknown { parent_root } => { debug!( self.log, "Unknown parent hash for blob"; "action" => "requesting parent", - "block_root" => %blob.block_root(), - "parent_root" => %blob.block_parent_root(), + "block_root" => %root, + "parent_root" => %parent_root, "commitment" => %commitment, ); - self.send_sync_message(SyncMessage::UnknownParentBlob(peer_id, blob)); + self.send_sync_message(SyncMessage::UnknownParentBlob( + peer_id, + blob_sidecar, + )); } GossipBlobError::KzgNotInitialized | GossipBlobError::PubkeyCacheTimeout @@ -1224,7 +1227,7 @@ impl NetworkBeaconProcessor { ); return None; } - Err(BlockError::ParentUnknown(block)) => { + Err(BlockError::ParentUnknown { .. }) => { debug!( self.log, "Unknown parent for gossip block"; @@ -1516,7 +1519,7 @@ impl NetworkBeaconProcessor { "block_root" => %block_root, ); } - Err(BlockError::ParentUnknown(_)) => { + Err(BlockError::ParentUnknown { .. }) => { // This should not occur. It should be checked by `should_forward_block`. // Do not send sync message UnknownParentBlock to prevent conflicts with the // BlockComponentProcessed message below. If this error ever happens, lookup sync @@ -3131,7 +3134,7 @@ impl NetworkBeaconProcessor { invalid_block_storage: &InvalidBlockStorage, block_root: Hash256, block: &SignedBeaconBlock, - error: &BlockError, + error: &BlockError, log: &Logger, ) { if let InvalidBlockStorage::Enabled(base_dir) = invalid_block_storage { diff --git a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs index 0defe7ad879..dde6f2e3130 100644 --- a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs @@ -15,7 +15,7 @@ use std::collections::{hash_map::Entry, HashMap}; use std::sync::Arc; use tokio_stream::StreamExt; use types::blob_sidecar::BlobIdentifier; -use types::{Epoch, EthSpec, ForkName, Hash256, Slot}; +use types::{Epoch, EthSpec, FixedBytesExtended, ForkName, Hash256, Slot}; impl NetworkBeaconProcessor { /* Auxiliary functions */ diff --git a/beacon_node/network/src/network_beacon_processor/sync_methods.rs b/beacon_node/network/src/network_beacon_processor/sync_methods.rs index 508576d9f52..c21054dab50 100644 --- a/beacon_node/network/src/network_beacon_processor/sync_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/sync_methods.rs @@ -706,15 +706,12 @@ impl NetworkBeaconProcessor { } /// Helper function to handle a `BlockError` from `process_chain_segment` - fn handle_failed_chain_segment( - &self, - error: BlockError, - ) -> Result<(), ChainSegmentFailed> { + fn handle_failed_chain_segment(&self, error: BlockError) -> Result<(), ChainSegmentFailed> { match error { - BlockError::ParentUnknown(block) => { + BlockError::ParentUnknown { parent_root, .. } => { // blocks should be sequential and all parents should exist Err(ChainSegmentFailed { - message: format!("Block has an unknown parent: {}", block.parent_root()), + message: format!("Block has an unknown parent: {}", parent_root), // Peers are faulty if they send non-sequential blocks. peer_action: Some(PeerAction::LowToleranceError), }) diff --git a/beacon_node/network/src/persisted_dht.rs b/beacon_node/network/src/persisted_dht.rs index 289bf14335e..e1085c4f0c1 100644 --- a/beacon_node/network/src/persisted_dht.rs +++ b/beacon_node/network/src/persisted_dht.rs @@ -4,7 +4,7 @@ use store::{DBColumn, Error as StoreError, HotColdDB, ItemStore, StoreItem}; use types::{EthSpec, Hash256}; /// 32-byte key for accessing the `DhtEnrs`. All zero because `DhtEnrs` has its own column. -pub const DHT_DB_KEY: Hash256 = Hash256::zero(); +pub const DHT_DB_KEY: Hash256 = Hash256::ZERO; pub fn load_dht, Cold: ItemStore>( store: Arc>, diff --git a/beacon_node/network/src/service.rs b/beacon_node/network/src/service.rs index db5fc7636ec..5b9a3125ea5 100644 --- a/beacon_node/network/src/service.rs +++ b/beacon_node/network/src/service.rs @@ -809,7 +809,7 @@ impl NetworkService { } } else { for column_subnet in DataColumnSubnetId::compute_custody_subnets::( - self.network_globals.local_enr().node_id().raw().into(), + self.network_globals.local_enr().node_id().raw(), self.network_globals .local_enr() .custody_subnet_count::<::EthSpec>( diff --git a/beacon_node/network/src/service/tests.rs b/beacon_node/network/src/service/tests.rs index b5731876968..fec5f3f83f7 100644 --- a/beacon_node/network/src/service/tests.rs +++ b/beacon_node/network/src/service/tests.rs @@ -176,7 +176,7 @@ mod tests { // Make sure the service is subscribed to the topics. let (old_topic1, old_topic2) = { let mut subnets = SubnetId::compute_subnets_for_epoch::( - network_globals.local_enr().node_id().raw().into(), + network_globals.local_enr().node_id().raw(), beacon_chain.epoch().unwrap(), &spec, ) diff --git a/beacon_node/network/src/status.rs b/beacon_node/network/src/status.rs index 865f8ee933f..1210926d34f 100644 --- a/beacon_node/network/src/status.rs +++ b/beacon_node/network/src/status.rs @@ -1,5 +1,5 @@ use beacon_chain::{BeaconChain, BeaconChainTypes}; -use types::{EthSpec, Hash256}; +use types::{EthSpec, FixedBytesExtended, Hash256}; use lighthouse_network::rpc::StatusMessage; /// Trait to produce a `StatusMessage` representing the state of the given `beacon_chain`. diff --git a/beacon_node/network/src/subnet_service/attestation_subnets.rs b/beacon_node/network/src/subnet_service/attestation_subnets.rs index 830c43cbb18..432a2b7fb7c 100644 --- a/beacon_node/network/src/subnet_service/attestation_subnets.rs +++ b/beacon_node/network/src/subnet_service/attestation_subnets.rs @@ -315,7 +315,7 @@ impl AttestationService { })?; let (subnets, next_subscription_epoch) = SubnetId::compute_subnets_for_epoch::( - self.node_id.raw().into(), + self.node_id.raw(), current_epoch, &self.beacon_chain.spec, ) diff --git a/beacon_node/network/src/sync/block_lookups/mod.rs b/beacon_node/network/src/sync/block_lookups/mod.rs index 7a5cda20692..e31adb783c9 100644 --- a/beacon_node/network/src/sync/block_lookups/mod.rs +++ b/beacon_node/network/src/sync/block_lookups/mod.rs @@ -473,7 +473,7 @@ impl BlockLookups { pub fn on_processing_result( &mut self, process_type: BlockProcessType, - result: BlockProcessingResult, + result: BlockProcessingResult, cx: &mut SyncNetworkContext, ) { let lookup_result = match process_type { @@ -493,7 +493,7 @@ impl BlockLookups { pub fn on_processing_result_inner>( &mut self, lookup_id: SingleLookupId, - result: BlockProcessingResult, + result: BlockProcessingResult, cx: &mut SyncNetworkContext, ) -> Result { let Some(lookup) = self.single_block_lookups.get_mut(&lookup_id) else { @@ -556,16 +556,14 @@ impl BlockLookups { error!(self.log, "Beacon chain error processing lookup component"; "block_root" => %block_root, "error" => ?e); Action::Drop } - BlockError::ParentUnknown(block) => { + BlockError::ParentUnknown { parent_root, .. } => { // Reverts the status of this request to `AwaitingProcessing` holding the // downloaded data. A future call to `continue_requests` will re-submit it // once there are no pending parent requests. // Note: `BlockError::ParentUnknown` is only returned when processing // blocks, not blobs. request_state.revert_to_awaiting_processing()?; - Action::ParentUnknown { - parent_root: block.parent_root(), - } + Action::ParentUnknown { parent_root } } ref e @ BlockError::ExecutionPayloadError(ref epe) if !epe.penalize_peer() => { // These errors indicate that the execution layer is offline diff --git a/beacon_node/network/src/sync/block_lookups/parent_chain.rs b/beacon_node/network/src/sync/block_lookups/parent_chain.rs index 7f4fe5119f6..009b5e2ff74 100644 --- a/beacon_node/network/src/sync/block_lookups/parent_chain.rs +++ b/beacon_node/network/src/sync/block_lookups/parent_chain.rs @@ -118,7 +118,7 @@ pub(crate) fn find_oldest_fork_ancestor( #[cfg(test)] mod tests { use super::{compute_parent_chains, find_oldest_fork_ancestor, Node}; - use types::Hash256; + use types::{FixedBytesExtended, Hash256}; fn h(n: u64) -> Hash256 { Hash256::from_low_u64_be(n) diff --git a/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs b/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs index b17bcedc5f5..4ae55d5aafe 100644 --- a/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs +++ b/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs @@ -221,11 +221,11 @@ impl SingleBlockLookup { // with this `req_id`. request.get_state_mut().on_download_start(req_id)? } - LookupRequestResult::NoRequestNeeded => { + LookupRequestResult::NoRequestNeeded(reason) => { // Lookup sync event safety: Advances this request to the terminal `Processed` // state. If all requests reach this state, the request is marked as completed // in `Self::continue_requests`. - request.get_state_mut().on_completed_request()? + request.get_state_mut().on_completed_request(reason)? } // Sync will receive a future event to make progress on the request, do nothing now LookupRequestResult::Pending(reason) => { @@ -357,13 +357,13 @@ pub struct DownloadResult { #[derive(IntoStaticStr)] pub enum State { - AwaitingDownload(&'static str), + AwaitingDownload(/* reason */ &'static str), Downloading(ReqId), AwaitingProcess(DownloadResult), /// Request is processing, sent by lookup sync Processing(DownloadResult), /// Request is processed - Processed, + Processed(/* reason */ &'static str), } /// Object representing the state of a single block or blob lookup request. @@ -554,7 +554,7 @@ impl SingleLookupRequestState { pub fn on_processing_success(&mut self) -> Result<(), LookupRequestError> { match &self.state { State::Processing(_) => { - self.state = State::Processed; + self.state = State::Processed("processing success"); Ok(()) } other => Err(LookupRequestError::BadState(format!( @@ -564,10 +564,10 @@ impl SingleLookupRequestState { } /// Mark a request as complete without any download or processing - pub fn on_completed_request(&mut self) -> Result<(), LookupRequestError> { + pub fn on_completed_request(&mut self, reason: &'static str) -> Result<(), LookupRequestError> { match &self.state { State::AwaitingDownload { .. } => { - self.state = State::Processed; + self.state = State::Processed(reason); Ok(()) } other => Err(LookupRequestError::BadState(format!( @@ -598,11 +598,11 @@ impl std::fmt::Display for State { impl std::fmt::Debug for State { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::AwaitingDownload(status) => write!(f, "AwaitingDownload({:?})", status), + Self::AwaitingDownload(reason) => write!(f, "AwaitingDownload({})", reason), Self::Downloading(req_id) => write!(f, "Downloading({:?})", req_id), Self::AwaitingProcess(d) => write!(f, "AwaitingProcess({:?})", d.peer_group), Self::Processing(d) => write!(f, "Processing({:?})", d.peer_group), - Self::Processed { .. } => write!(f, "Processed"), + Self::Processed(reason) => write!(f, "Processed({})", reason), } } } diff --git a/beacon_node/network/src/sync/block_lookups/tests.rs b/beacon_node/network/src/sync/block_lookups/tests.rs index 9572bf7f444..6d852b2572d 100644 --- a/beacon_node/network/src/sync/block_lookups/tests.rs +++ b/beacon_node/network/src/sync/block_lookups/tests.rs @@ -9,7 +9,7 @@ use super::*; use crate::sync::block_lookups::common::ResponseType; use beacon_chain::blob_verification::GossipVerifiedBlob; -use beacon_chain::block_verification_types::{BlockImportData, RpcBlock}; +use beacon_chain::block_verification_types::BlockImportData; use beacon_chain::builder::Witness; use beacon_chain::data_availability_checker::Availability; use beacon_chain::eth1_chain::CachingEth1Backend; @@ -211,11 +211,7 @@ impl TestRig { fn trigger_unknown_parent_block(&mut self, peer_id: PeerId, block: Arc>) { let block_root = block.canonical_root(); - self.send_sync_message(SyncMessage::UnknownParentBlock( - peer_id, - RpcBlock::new_without_blobs(Some(block_root), block), - block_root, - )) + self.send_sync_message(SyncMessage::UnknownParentBlock(peer_id, block, block_root)) } fn trigger_unknown_parent_blob(&mut self, peer_id: PeerId, blob: BlobSidecar) { @@ -300,7 +296,7 @@ impl TestRig { fn expect_no_active_sampling(&mut self) { assert_eq!( self.sync_manager.active_sampling_requests(), - vec![], + Vec::::new(), "expected no active sampling" ); } @@ -440,12 +436,12 @@ impl TestRig { *parent_chain.last().unwrap() } - fn parent_block_processed(&mut self, chain_hash: Hash256, result: BlockProcessingResult) { + fn parent_block_processed(&mut self, chain_hash: Hash256, result: BlockProcessingResult) { let id = self.find_single_lookup_for(self.find_oldest_parent_lookup(chain_hash)); self.single_block_component_processed(id, result); } - fn parent_blob_processed(&mut self, chain_hash: Hash256, result: BlockProcessingResult) { + fn parent_blob_processed(&mut self, chain_hash: Hash256, result: BlockProcessingResult) { let id = self.find_single_lookup_for(self.find_oldest_parent_lookup(chain_hash)); self.single_blob_component_processed(id, result); } @@ -457,7 +453,7 @@ impl TestRig { ); } - fn single_block_component_processed(&mut self, id: Id, result: BlockProcessingResult) { + fn single_block_component_processed(&mut self, id: Id, result: BlockProcessingResult) { self.send_sync_message(SyncMessage::BlockComponentProcessed { process_type: BlockProcessType::SingleBlock { id }, result, @@ -472,7 +468,7 @@ impl TestRig { ) } - fn single_blob_component_processed(&mut self, id: Id, result: BlockProcessingResult) { + fn single_blob_component_processed(&mut self, id: Id, result: BlockProcessingResult) { self.send_sync_message(SyncMessage::BlockComponentProcessed { process_type: BlockProcessType::SingleBlob { id }, result, @@ -1440,7 +1436,9 @@ fn test_single_block_lookup_becomes_parent_request() { // parent request after processing. rig.single_block_component_processed( id.lookup_id, - BlockError::ParentUnknown(RpcBlock::new_without_blobs(None, block)).into(), + BlockProcessingResult::Err(BlockError::ParentUnknown { + parent_root: block.parent_root(), + }), ); assert_eq!(rig.active_single_lookups_count(), 2); // 2 = current + parent rig.expect_block_parent_request(parent_root); @@ -1661,7 +1659,9 @@ fn test_parent_lookup_too_deep_grow_ancestor() { // the processing result rig.parent_block_processed( chain_hash, - BlockError::ParentUnknown(RpcBlock::new_without_blobs(None, block)).into(), + BlockProcessingResult::Err(BlockError::ParentUnknown { + parent_root: block.parent_root(), + }), ) } @@ -1685,7 +1685,10 @@ fn test_parent_lookup_too_deep_grow_tip() { rig.expect_block_process(ResponseType::Block); rig.single_block_component_processed( id.lookup_id, - BlockError::ParentUnknown(RpcBlock::new_without_blobs(None, block)).into(), + BlockError::ParentUnknown { + parent_root: block.parent_root(), + } + .into(), ); } @@ -1840,7 +1843,9 @@ fn test_same_chain_race_condition() { rig.log(&format!("Block {i} ParentUnknown")); rig.parent_block_processed( chain_hash, - BlockError::ParentUnknown(RpcBlock::new_without_blobs(None, block)).into(), + BlockProcessingResult::Err(BlockError::ParentUnknown { + parent_root: block.parent_root(), + }), ) } } @@ -1967,6 +1972,7 @@ fn sampling_happy_path() { } #[test] +#[ignore] // Ignoring due to flakiness https://github.com/sigp/lighthouse/issues/6319 fn sampling_with_retries() { let Some(mut r) = TestRig::test_setup_after_peerdas() else { return; @@ -2129,7 +2135,7 @@ mod deneb_only { RequestTrigger::GossipUnknownParentBlock { .. } => { rig.send_sync_message(SyncMessage::UnknownParentBlock( peer_id, - RpcBlock::new_without_blobs(Some(block_root), block.clone()), + block.clone(), block_root, )); @@ -2411,7 +2417,9 @@ mod deneb_only { .unwrap(); self.rig.parent_block_processed( self.block_root, - BlockProcessingResult::Err(BlockError::ParentUnknown(block)), + BlockProcessingResult::Err(BlockError::ParentUnknown { + parent_root: block.parent_root(), + }), ); assert_eq!(self.rig.active_parent_lookups_count(), 1); self diff --git a/beacon_node/network/src/sync/manager.rs b/beacon_node/network/src/sync/manager.rs index 866268b6fd3..454185b52a0 100644 --- a/beacon_node/network/src/sync/manager.rs +++ b/beacon_node/network/src/sync/manager.rs @@ -48,7 +48,6 @@ use crate::sync::block_lookups::{ use crate::sync::block_sidecar_coupling::RangeBlockComponentsRequest; use crate::sync::network_context::PeerGroup; use beacon_chain::block_verification_types::AsBlock; -use beacon_chain::block_verification_types::RpcBlock; use beacon_chain::validator_monitor::timestamp_now; use beacon_chain::{ AvailabilityProcessingStatus, BeaconChain, BeaconChainTypes, BlockError, EngineState, @@ -115,7 +114,7 @@ pub enum SyncMessage { }, /// A block with an unknown parent has been received. - UnknownParentBlock(PeerId, RpcBlock, Hash256), + UnknownParentBlock(PeerId, Arc>, Hash256), /// A blob with an unknown parent has been received. UnknownParentBlob(PeerId, Arc>), @@ -150,7 +149,7 @@ pub enum SyncMessage { /// Block processed BlockComponentProcessed { process_type: BlockProcessType, - result: BlockProcessingResult, + result: BlockProcessingResult, }, /// Sample data column verified @@ -182,9 +181,9 @@ impl BlockProcessType { } #[derive(Debug)] -pub enum BlockProcessingResult { +pub enum BlockProcessingResult { Ok(AvailabilityProcessingStatus), - Err(BlockError), + Err(BlockError), Ignored, } @@ -1189,10 +1188,8 @@ impl SyncManager { } } -impl From>> - for BlockProcessingResult -{ - fn from(result: Result>) -> Self { +impl From> for BlockProcessingResult { + fn from(result: Result) -> Self { match result { Ok(status) => BlockProcessingResult::Ok(status), Err(e) => BlockProcessingResult::Err(e), @@ -1200,8 +1197,8 @@ impl From>> } } -impl From> for BlockProcessingResult { - fn from(e: BlockError) -> Self { +impl From for BlockProcessingResult { + fn from(e: BlockError) -> Self { BlockProcessingResult::Err(e) } } diff --git a/beacon_node/network/src/sync/network_context.rs b/beacon_node/network/src/sync/network_context.rs index 84e968a5951..4b255fee4d4 100644 --- a/beacon_node/network/src/sync/network_context.rs +++ b/beacon_node/network/src/sync/network_context.rs @@ -28,7 +28,6 @@ use rand::thread_rng; use requests::ActiveDataColumnsByRootRequest; pub use requests::LookupVerifyError; use slog::{debug, error, warn}; -use slot_clock::SlotClock; use std::collections::hash_map::Entry; use std::collections::HashMap; use std::sync::Arc; @@ -155,8 +154,9 @@ pub enum LookupRequestResult { /// A request is sent. Sync MUST receive an event from the network in the future for either: /// completed response or failed request RequestSent(I), - /// No request is sent, and no further action is necessary to consider this request completed - NoRequestNeeded, + /// No request is sent, and no further action is necessary to consider this request completed. + /// Includes a reason why this request is not needed. + NoRequestNeeded(&'static str), /// No request is sent, but the request is not completed. Sync MUST receive some future event /// that makes progress on the request. For example: request is processing from a different /// source (i.e. block received from gossip) and sync MUST receive an event with that processing @@ -556,7 +556,9 @@ impl SyncNetworkContext { // Block is fully validated. If it's not yet imported it's waiting for missing block // components. Consider this request completed and do nothing. BlockProcessStatus::ExecutionValidated { .. } => { - return Ok(LookupRequestResult::NoRequestNeeded) + return Ok(LookupRequestResult::NoRequestNeeded( + "block execution validated", + )) } } @@ -607,21 +609,6 @@ impl SyncNetworkContext { block_root: Hash256, downloaded_block: Option>>, ) -> Result { - // Check if we are into deneb, and before peerdas - if !self - .chain - .data_availability_checker - .blobs_required_for_epoch( - // TODO(das): use the block's slot - self.chain - .slot_clock - .now_or_genesis() - .ok_or(RpcRequestSendError::SlotClockError)? - .epoch(T::EthSpec::slots_per_epoch()), - ) - { - return Ok(LookupRequestResult::NoRequestNeeded); - } let Some(block) = downloaded_block.or_else(|| { // If the block is already being processed or fully validated, retrieve how many blobs // it expects. Consider any stage of the block. If the block root has been validated, we @@ -649,9 +636,14 @@ impl SyncNetworkContext { let expected_blobs = block.num_expected_blobs(); let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch()); - // Check if we are into peerdas + // Check if we are in deneb, before peerdas and inside da window if !self.chain.should_fetch_blobs(block_epoch) { - return Ok(LookupRequestResult::NoRequestNeeded); + return Ok(LookupRequestResult::NoRequestNeeded("blobs not required")); + } + + // No data required for this block + if expected_blobs == 0 { + return Ok(LookupRequestResult::NoRequestNeeded("no data")); } let imported_blob_indexes = self @@ -666,7 +658,7 @@ impl SyncNetworkContext { if indices.is_empty() { // No blobs required, do not issue any request - return Ok(LookupRequestResult::NoRequestNeeded); + return Ok(LookupRequestResult::NoRequestNeeded("no indices to fetch")); } let req_id = self.next_id(); @@ -762,14 +754,14 @@ impl SyncNetworkContext { let expected_blobs = block.num_expected_blobs(); let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch()); - // Check if we are into peerdas + // Check if we are into peerdas and inside da window if !self.chain.should_fetch_custody_columns(block_epoch) { - return Ok(LookupRequestResult::NoRequestNeeded); + return Ok(LookupRequestResult::NoRequestNeeded("columns not required")); } // No data required for this block if expected_blobs == 0 { - return Ok(LookupRequestResult::NoRequestNeeded); + return Ok(LookupRequestResult::NoRequestNeeded("no data")); } let custody_indexes_imported = self @@ -788,7 +780,7 @@ impl SyncNetworkContext { if custody_indexes_to_fetch.is_empty() { // No indexes required, do not issue any request - return Ok(LookupRequestResult::NoRequestNeeded); + return Ok(LookupRequestResult::NoRequestNeeded("no indices to fetch")); } let req_id = self.next_id(); diff --git a/beacon_node/network/src/sync/network_context/custody.rs b/beacon_node/network/src/sync/network_context/custody.rs index b1038c74703..dfe409f043d 100644 --- a/beacon_node/network/src/sync/network_context/custody.rs +++ b/beacon_node/network/src/sync/network_context/custody.rs @@ -296,7 +296,7 @@ impl ActiveCustodyRequest { self.active_batch_columns_requests .insert(req_id, ActiveBatchColumnsRequest { indices, peer_id }); } - LookupRequestResult::NoRequestNeeded => unreachable!(), + LookupRequestResult::NoRequestNeeded(_) => unreachable!(), LookupRequestResult::Pending(_) => unreachable!(), } } diff --git a/beacon_node/network/src/sync/range_sync/range.rs b/beacon_node/network/src/sync/range_sync/range.rs index c8bb9b3b09a..beb04fac28b 100644 --- a/beacon_node/network/src/sync/range_sync/range.rs +++ b/beacon_node/network/src/sync/range_sync/range.rs @@ -406,7 +406,7 @@ mod tests { use std::collections::HashSet; use store::MemoryStore; use tokio::sync::mpsc; - use types::{ForkName, MinimalEthSpec as E}; + use types::{FixedBytesExtended, ForkName, MinimalEthSpec as E}; #[derive(Debug)] struct FakeStorage { diff --git a/beacon_node/operation_pool/src/reward_cache.rs b/beacon_node/operation_pool/src/reward_cache.rs index 9e4c424bd7d..dd9902353f8 100644 --- a/beacon_node/operation_pool/src/reward_cache.rs +++ b/beacon_node/operation_pool/src/reward_cache.rs @@ -1,6 +1,8 @@ use crate::OpPoolError; use bitvec::vec::BitVec; -use types::{BeaconState, BeaconStateError, Epoch, EthSpec, Hash256, ParticipationFlags}; +use types::{ + BeaconState, BeaconStateError, Epoch, EthSpec, FixedBytesExtended, Hash256, ParticipationFlags, +}; #[derive(Debug, PartialEq, Eq, Clone)] struct Initialization { diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 13f672d2144..76802b9acd4 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -390,7 +390,7 @@ impl HotColdDB, LevelDB> { pub fn iter_temporary_state_roots(&self) -> impl Iterator> + '_ { let column = DBColumn::BeaconStateTemporary; let start_key = - BytesKey::from_vec(get_key_for_col(column.into(), Hash256::zero().as_bytes())); + BytesKey::from_vec(get_key_for_col(column.into(), Hash256::zero().as_slice())); let keys_iter = self.hot_db.keys_iter(); keys_iter.seek(&start_key); @@ -473,7 +473,7 @@ impl, Cold: ItemStore> HotColdDB blinded_block: &SignedBeaconBlock>, ops: &mut Vec, ) { - let db_key = get_key_for_col(DBColumn::BeaconBlock.into(), key.as_bytes()); + let db_key = get_key_for_col(DBColumn::BeaconBlock.into(), key.as_slice()); ops.push(KeyValueStoreOp::PutKeyValue( db_key, blinded_block.as_ssz_bytes(), @@ -597,7 +597,7 @@ impl, Cold: ItemStore> HotColdDB decoder: impl FnOnce(&[u8]) -> Result, ssz::DecodeError>, ) -> Result>, Error> { self.hot_db - .get_bytes(DBColumn::BeaconBlock.into(), block_root.as_bytes())? + .get_bytes(DBColumn::BeaconBlock.into(), block_root.as_slice())? .map(|block_bytes| decoder(&block_bytes)) .transpose() .map_err(|e| e.into()) @@ -611,7 +611,7 @@ impl, Cold: ItemStore> HotColdDB fork_name: ForkName, ) -> Result>, Error> { let column = ExecutionPayload::::db_column().into(); - let key = block_root.as_bytes(); + let key = block_root.as_slice(); match self.hot_db.get_bytes(column, key)? { Some(bytes) => Ok(Some(ExecutionPayload::from_ssz_bytes(&bytes, fork_name)?)), @@ -637,30 +637,30 @@ impl, Cold: ItemStore> HotColdDB /// Check if the blobs for a block exists on disk. pub fn blobs_exist(&self, block_root: &Hash256) -> Result { self.blobs_db - .key_exists(DBColumn::BeaconBlob.into(), block_root.as_bytes()) + .key_exists(DBColumn::BeaconBlob.into(), block_root.as_slice()) } /// Determine whether a block exists in the database. pub fn block_exists(&self, block_root: &Hash256) -> Result { self.hot_db - .key_exists(DBColumn::BeaconBlock.into(), block_root.as_bytes()) + .key_exists(DBColumn::BeaconBlock.into(), block_root.as_slice()) } /// Delete a block from the store and the block cache. pub fn delete_block(&self, block_root: &Hash256) -> Result<(), Error> { self.block_cache.lock().delete(block_root); self.hot_db - .key_delete(DBColumn::BeaconBlock.into(), block_root.as_bytes())?; + .key_delete(DBColumn::BeaconBlock.into(), block_root.as_slice())?; self.hot_db - .key_delete(DBColumn::ExecPayload.into(), block_root.as_bytes())?; + .key_delete(DBColumn::ExecPayload.into(), block_root.as_slice())?; self.blobs_db - .key_delete(DBColumn::BeaconBlob.into(), block_root.as_bytes()) + .key_delete(DBColumn::BeaconBlob.into(), block_root.as_slice()) } pub fn put_blobs(&self, block_root: &Hash256, blobs: BlobSidecarList) -> Result<(), Error> { self.blobs_db.put_bytes( DBColumn::BeaconBlob.into(), - block_root.as_bytes(), + block_root.as_slice(), &blobs.as_ssz_bytes(), )?; self.block_cache.lock().put_blobs(*block_root, blobs); @@ -673,7 +673,7 @@ impl, Cold: ItemStore> HotColdDB blobs: BlobSidecarList, ops: &mut Vec, ) { - let db_key = get_key_for_col(DBColumn::BeaconBlob.into(), key.as_bytes()); + let db_key = get_key_for_col(DBColumn::BeaconBlob.into(), key.as_slice()); ops.push(KeyValueStoreOp::PutKeyValue(db_key, blobs.as_ssz_bytes())); } @@ -996,17 +996,17 @@ impl, Cold: ItemStore> HotColdDB StoreOp::DeleteStateTemporaryFlag(state_root) => { let db_key = - get_key_for_col(TemporaryFlag::db_column().into(), state_root.as_bytes()); + get_key_for_col(TemporaryFlag::db_column().into(), state_root.as_slice()); key_value_batch.push(KeyValueStoreOp::DeleteKey(db_key)); } StoreOp::DeleteBlock(block_root) => { - let key = get_key_for_col(DBColumn::BeaconBlock.into(), block_root.as_bytes()); + let key = get_key_for_col(DBColumn::BeaconBlock.into(), block_root.as_slice()); key_value_batch.push(KeyValueStoreOp::DeleteKey(key)); } StoreOp::DeleteBlobs(block_root) => { - let key = get_key_for_col(DBColumn::BeaconBlob.into(), block_root.as_bytes()); + let key = get_key_for_col(DBColumn::BeaconBlob.into(), block_root.as_slice()); key_value_batch.push(KeyValueStoreOp::DeleteKey(key)); } @@ -1022,18 +1022,18 @@ impl, Cold: ItemStore> HotColdDB StoreOp::DeleteState(state_root, slot) => { let state_summary_key = - get_key_for_col(DBColumn::BeaconStateSummary.into(), state_root.as_bytes()); + get_key_for_col(DBColumn::BeaconStateSummary.into(), state_root.as_slice()); key_value_batch.push(KeyValueStoreOp::DeleteKey(state_summary_key)); if slot.map_or(true, |slot| slot % E::slots_per_epoch() == 0) { let state_key = - get_key_for_col(DBColumn::BeaconState.into(), state_root.as_bytes()); + get_key_for_col(DBColumn::BeaconState.into(), state_root.as_slice()); key_value_batch.push(KeyValueStoreOp::DeleteKey(state_key)); } } StoreOp::DeleteExecutionPayload(block_root) => { - let key = get_key_for_col(DBColumn::ExecPayload.into(), block_root.as_bytes()); + let key = get_key_for_col(DBColumn::ExecPayload.into(), block_root.as_slice()); key_value_batch.push(KeyValueStoreOp::DeleteKey(key)); } @@ -1455,7 +1455,7 @@ impl, Cold: ItemStore> HotColdDB fn load_restore_point(&self, state_root: &Hash256) -> Result, Error> { let partial_state_bytes = self .cold_db - .get_bytes(DBColumn::BeaconState.into(), state_root.as_bytes())? + .get_bytes(DBColumn::BeaconState.into(), state_root.as_slice())? .ok_or(HotColdDBError::MissingRestorePoint(*state_root))?; let mut partial_state: PartialBeaconState = PartialBeaconState::from_ssz_bytes(&partial_state_bytes, &self.spec)?; @@ -1666,7 +1666,7 @@ impl, Cold: ItemStore> HotColdDB match self .blobs_db - .get_bytes(DBColumn::BeaconBlob.into(), block_root.as_bytes())? + .get_bytes(DBColumn::BeaconBlob.into(), block_root.as_slice())? { Some(ref blobs_bytes) => { // We insert a VariableList of BlobSidecars into the db, but retrieve @@ -1695,7 +1695,7 @@ impl, Cold: ItemStore> HotColdDB /// Fetch all keys in the data_column column with prefix `block_root` pub fn get_data_column_keys(&self, block_root: Hash256) -> Result, Error> { self.blobs_db - .iter_raw_keys(DBColumn::BeaconDataColumn, block_root.as_bytes()) + .iter_raw_keys(DBColumn::BeaconDataColumn, block_root.as_slice()) .map(|key| key.and_then(|key| parse_data_column_key(key).map(|key| key.1))) .collect() } @@ -1800,7 +1800,7 @@ impl, Cold: ItemStore> HotColdDB mut ops: Vec, ) -> Result<(), Error> { let column = SchemaVersion::db_column().into(); - let key = SCHEMA_VERSION_KEY.as_bytes(); + let key = SCHEMA_VERSION_KEY.as_slice(); let db_key = get_key_for_col(column, key); let op = KeyValueStoreOp::PutKeyValue(db_key, schema_version.as_store_bytes()); ops.push(op); @@ -1895,7 +1895,7 @@ impl, Cold: ItemStore> HotColdDB } else { KeyValueStoreOp::DeleteKey(get_key_for_col( DBColumn::BeaconMeta.into(), - ANCHOR_INFO_KEY.as_bytes(), + ANCHOR_INFO_KEY.as_slice(), )) } } diff --git a/beacon_node/store/src/impls/beacon_state.rs b/beacon_node/store/src/impls/beacon_state.rs index f752bf39795..48c289f2b2d 100644 --- a/beacon_node/store/src/impls/beacon_state.rs +++ b/beacon_node/store/src/impls/beacon_state.rs @@ -13,7 +13,7 @@ pub fn store_full_state( }; metrics::inc_counter_by(&metrics::BEACON_STATE_WRITE_BYTES, bytes.len() as u64); metrics::inc_counter(&metrics::BEACON_STATE_WRITE_COUNT); - let key = get_key_for_col(DBColumn::BeaconState.into(), state_root.as_bytes()); + let key = get_key_for_col(DBColumn::BeaconState.into(), state_root.as_slice()); ops.push(KeyValueStoreOp::PutKeyValue(key, bytes)); Ok(()) } @@ -25,7 +25,7 @@ pub fn get_full_state, E: EthSpec>( ) -> Result>, Error> { let total_timer = metrics::start_timer(&metrics::BEACON_STATE_READ_TIMES); - match db.get_bytes(DBColumn::BeaconState.into(), state_root.as_bytes())? { + match db.get_bytes(DBColumn::BeaconState.into(), state_root.as_slice())? { Some(bytes) => { let overhead_timer = metrics::start_timer(&metrics::BEACON_STATE_READ_OVERHEAD_TIMES); let container = StorageContainer::from_ssz_bytes(&bytes, spec)?; diff --git a/beacon_node/store/src/iter.rs b/beacon_node/store/src/iter.rs index 03090ca14c5..a7e0c09ed1f 100644 --- a/beacon_node/store/src/iter.rs +++ b/beacon_node/store/src/iter.rs @@ -385,6 +385,7 @@ mod test { use beacon_chain::test_utils::BeaconChainHarness; use beacon_chain::types::{ChainSpec, MainnetEthSpec}; use sloggers::{null::NullLoggerBuilder, Build}; + use types::FixedBytesExtended; fn get_state() -> BeaconState { let harness = BeaconChainHarness::builder(E::default()) diff --git a/beacon_node/store/src/lib.rs b/beacon_node/store/src/lib.rs index e8631cc5ec1..60dddeb1760 100644 --- a/beacon_node/store/src/lib.rs +++ b/beacon_node/store/src/lib.rs @@ -151,7 +151,7 @@ pub fn get_col_from_key(key: &[u8]) -> Option { } pub fn get_data_column_key(block_root: &Hash256, column_index: &ColumnIndex) -> Vec { - let mut result = block_root.as_bytes().to_vec(); + let mut result = block_root.as_slice().to_vec(); result.extend_from_slice(&column_index.to_le_bytes()); result } @@ -183,7 +183,7 @@ pub trait ItemStore: KeyValueStore + Sync + Send + Sized + 'stati /// Store an item in `Self`. fn put(&self, key: &Hash256, item: &I) -> Result<(), Error> { let column = I::db_column().into(); - let key = key.as_bytes(); + let key = key.as_slice(); self.put_bytes(column, key, &item.as_store_bytes()) .map_err(Into::into) @@ -191,7 +191,7 @@ pub trait ItemStore: KeyValueStore + Sync + Send + Sized + 'stati fn put_sync(&self, key: &Hash256, item: &I) -> Result<(), Error> { let column = I::db_column().into(); - let key = key.as_bytes(); + let key = key.as_slice(); self.put_bytes_sync(column, key, &item.as_store_bytes()) .map_err(Into::into) @@ -200,7 +200,7 @@ pub trait ItemStore: KeyValueStore + Sync + Send + Sized + 'stati /// Retrieve an item from `Self`. fn get(&self, key: &Hash256) -> Result, Error> { let column = I::db_column().into(); - let key = key.as_bytes(); + let key = key.as_slice(); match self.get_bytes(column, key)? { Some(bytes) => Ok(Some(I::from_store_bytes(&bytes[..])?)), @@ -211,7 +211,7 @@ pub trait ItemStore: KeyValueStore + Sync + Send + Sized + 'stati /// Returns `true` if the given key represents an item in `Self`. fn exists(&self, key: &Hash256) -> Result { let column = I::db_column().into(); - let key = key.as_bytes(); + let key = key.as_slice(); self.key_exists(column, key) } @@ -219,7 +219,7 @@ pub trait ItemStore: KeyValueStore + Sync + Send + Sized + 'stati /// Remove an item from `Self`. fn delete(&self, key: &Hash256) -> Result<(), Error> { let column = I::db_column().into(); - let key = key.as_bytes(); + let key = key.as_slice(); self.key_delete(column, key) } @@ -366,7 +366,7 @@ pub trait StoreItem: Sized { fn from_store_bytes(bytes: &[u8]) -> Result; fn as_kv_store_op(&self, key: Hash256) -> KeyValueStoreOp { - let db_key = get_key_for_col(Self::db_column().into(), key.as_bytes()); + let db_key = get_key_for_col(Self::db_column().into(), key.as_slice()); KeyValueStoreOp::PutKeyValue(db_key, self.as_store_bytes()) } } diff --git a/beacon_node/store/src/partial_beacon_state.rs b/beacon_node/store/src/partial_beacon_state.rs index 8f40b4b9241..8a66ec121e1 100644 --- a/beacon_node/store/src/partial_beacon_state.rs +++ b/beacon_node/store/src/partial_beacon_state.rs @@ -323,7 +323,7 @@ impl PartialBeaconState { /// Prepare the partial state for storage in the KV database. pub fn as_kv_store_op(&self, state_root: Hash256) -> KeyValueStoreOp { - let db_key = get_key_for_col(DBColumn::BeaconState.into(), state_root.as_bytes()); + let db_key = get_key_for_col(DBColumn::BeaconState.into(), state_root.as_slice()); KeyValueStoreOp::PutKeyValue(db_key, self.as_ssz_bytes()) } diff --git a/book/src/checkpoint-sync.md b/book/src/checkpoint-sync.md index 2bf028acfec..8dd63f77c9b 100644 --- a/book/src/checkpoint-sync.md +++ b/book/src/checkpoint-sync.md @@ -158,9 +158,9 @@ curl -H "Accept: application/octet-stream" "http://localhost:5052/eth/v2/beacon/ curl -H "Accept: application/octet-stream" "http://localhost:5052/eth/v1/beacon/blob_sidecars/$SLOT" > blobs.ssz ``` -where `$SLOT` is the slot number. It can be specified as `head` or `finalized` as well. +where `$SLOT` is the slot number. A slot which is an epoch boundary slot (i.e., first slot of an epoch) should always be used for manual checkpoint sync. -_Both_ the state and block must be provided and the state **must** match the block. The +If the block contains blobs, all state, block and blobs must be provided and must point to the same slot. The state may be from the same slot as the block (unadvanced), or advanced to an epoch boundary, in which case it will be assumed to be finalized at that epoch. diff --git a/book/src/faq.md b/book/src/faq.md index 4c58c2e16d1..04e5ce5bc8f 100644 --- a/book/src/faq.md +++ b/book/src/faq.md @@ -14,7 +14,6 @@ - [My beacon node logs `WARN Error signalling fork choice waiter`, what should I do?](#bn-fork-choice) - [My beacon node logs `ERRO Aggregate attestation queue full`, what should I do?](#bn-queue-full) - [My beacon node logs `WARN Failed to finalize deposit cache`, what should I do?](#bn-deposit-cache) -- [My beacon node logs `WARN Could not verify blob sidecar for gossip`, what does it mean?](#bn-blob) ## [Validator](#validator-1) @@ -203,16 +202,6 @@ This suggests that the computer resources are being overwhelmed. It could be due This is a known [bug](https://github.com/sigp/lighthouse/issues/3707) that will fix by itself. -### My beacon node logs `WARN Could not verify blob sidecar for gossip`, what does it mean? - -An example of the full log is shown below: - -```text -Jun 07 23:05:12.170 WARN Could not verify blob sidecar for gossip. Ignoring the blob sidecar, commitment: 0xaa97…6f54, index: 1, root: 0x93b8…c47c, slot: 9248017, error: PastFinalizedSlot { blob_slot: Slot(9248017), finalized_slot: Slot(9248032) }, module: network::network_beacon_processor::gossip_methods:720 -``` - -The `PastFinalizedSlot` indicates that the time at which the node received the blob has past the finalization period. This could be due to a peer sending an earlier blob. The log will be gone when Lighthouse eventually drops the peer. - ## Validator ### Why does it take so long for a validator to be activated? @@ -281,28 +270,7 @@ limit](https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beac it will only allow the number of validators to increase (churn) by a certain amount. If a new validator isn't within the churn limit from the front of the queue, they will need to wait another epoch (6.4 minutes) for their next chance. This -repeats until the queue is cleared. The churn limit is summarised in the table below: - -

- -| Number of active validators | Validators activated per epoch | Validators activated per day | -|----------------|----|------| -| 327679 or less | 4 | 900 | -| 327680-393215 | 5 | 1125 | -| 393216-458751 | 6 | 1350 | -| 458752-524287 | 7 | 1575 | -| 524288-589823 | 8 | 1800 | -| 589824-655359 | 9 | 2025 | -| 655360-720895 | 10 | 2250 | -| 720896-786431 | 11 | 2475 | -| 786432-851967 | 12 | 2700 | -| 851968-917503 | 13 | 2925 | -| 917504-983039 | 14 | 3150 | -| 983040-1048575 | 15 | 3375 | - -
- -For example, the number of active validators on Mainnet is about 574000 on May 2023. This means that 8 validators can be activated per epoch or 1800 per day (it is noted that the same applies to the exit queue). If, for example, there are 9000 validators waiting to be activated, this means that the waiting time can take up to 5 days. +repeats until the queue is cleared. The churn limit for validators joining the beacon chain is capped at 8 per epoch or 1800 per day. If, for example, there are 9000 validators waiting to be activated, this means that the waiting time can take up to 5 days. Once a validator has been activated, congratulations! It's time to produce blocks and attestations! diff --git a/common/clap_utils/Cargo.toml b/common/clap_utils/Cargo.toml index e4dfb2a5560..73823ae24e9 100644 --- a/common/clap_utils/Cargo.toml +++ b/common/clap_utils/Cargo.toml @@ -7,12 +7,12 @@ edition = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +alloy-primitives = { workspace = true } clap = { workspace = true } hex = { workspace = true } dirs = { workspace = true } eth2_network_config = { workspace = true } ethereum_ssz = { workspace = true } -ethereum-types = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } serde_yaml = { workspace = true } diff --git a/common/clap_utils/src/lib.rs b/common/clap_utils/src/lib.rs index ea56e7e672a..cba7399c9bf 100644 --- a/common/clap_utils/src/lib.rs +++ b/common/clap_utils/src/lib.rs @@ -1,9 +1,9 @@ //! A helper library for parsing values from `clap::ArgMatches`. +use alloy_primitives::U256 as Uint256; use clap::builder::styling::*; use clap::ArgMatches; use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK}; -use ethereum_types::U256 as Uint256; use ssz::Decode; use std::path::PathBuf; use std::str::FromStr; @@ -36,7 +36,7 @@ pub fn get_eth2_network_config(cli_args: &ArgMatches) -> Result(cli_args, "terminal-total-difficulty-override")? { let stripped = string.replace(',', ""); - let terminal_total_difficulty = Uint256::from_dec_str(&stripped).map_err(|e| { + let terminal_total_difficulty = Uint256::from_str(&stripped).map_err(|e| { format!( "Could not parse --terminal-total-difficulty-override as decimal value: {:?}", e diff --git a/common/eth2/src/lighthouse_vc/std_types.rs b/common/eth2/src/lighthouse_vc/std_types.rs index ab90d336fa4..ee05c298399 100644 --- a/common/eth2/src/lighthouse_vc/std_types.rs +++ b/common/eth2/src/lighthouse_vc/std_types.rs @@ -8,6 +8,7 @@ pub use slashing_protection::interchange::Interchange; #[derive(Debug, Deserialize, Serialize, PartialEq)] pub struct GetFeeRecipientResponse { pub pubkey: PublicKeyBytes, + #[serde(with = "serde_utils::address_hex")] pub ethaddress: Address, } diff --git a/common/eth2/src/lighthouse_vc/types.rs b/common/eth2/src/lighthouse_vc/types.rs index d903d7b73d7..1921549bcb5 100644 --- a/common/eth2/src/lighthouse_vc/types.rs +++ b/common/eth2/src/lighthouse_vc/types.rs @@ -163,6 +163,7 @@ pub struct Web3SignerValidatorRequest { #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct UpdateFeeRecipientRequest { + #[serde(with = "serde_utils::address_hex")] pub ethaddress: Address, } diff --git a/common/eth2/src/types.rs b/common/eth2/src/types.rs index 793d839ceea..3925d2deda8 100644 --- a/common/eth2/src/types.rs +++ b/common/eth2/src/types.rs @@ -563,6 +563,7 @@ pub struct BlockHeaderData { pub struct DepositContractData { #[serde(with = "serde_utils::quoted_u64")] pub chain_id: u64, + #[serde(with = "serde_utils::address_hex")] pub address: Address, } @@ -1035,6 +1036,7 @@ pub struct SsePayloadAttributes { #[superstruct(getter(copy))] pub prev_randao: Hash256, #[superstruct(getter(copy))] + #[serde(with = "serde_utils::address_hex")] pub suggested_fee_recipient: Address, #[superstruct(only(V2, V3))] pub withdrawals: Vec, @@ -1050,6 +1052,7 @@ pub struct SseExtendedPayloadAttributesGeneric { pub parent_block_root: Hash256, #[serde(with = "serde_utils::quoted_u64")] pub parent_block_number: u64, + pub parent_block_hash: ExecutionBlockHash, pub payload_attributes: T, } @@ -1790,12 +1793,12 @@ impl TryFrom<&HeaderMap> for ProduceBlockV3Metadata { })?; let execution_payload_value = parse_required_header(headers, EXECUTION_PAYLOAD_VALUE_HEADER, |s| { - Uint256::from_dec_str(s) + Uint256::from_str_radix(s, 10) .map_err(|e| format!("invalid {EXECUTION_PAYLOAD_VALUE_HEADER}: {e:?}")) })?; let consensus_block_value = parse_required_header(headers, CONSENSUS_BLOCK_VALUE_HEADER, |s| { - Uint256::from_dec_str(s) + Uint256::from_str_radix(s, 10) .map_err(|e| format!("invalid {CONSENSUS_BLOCK_VALUE_HEADER}: {e:?}")) })?; diff --git a/common/eth2_network_config/src/lib.rs b/common/eth2_network_config/src/lib.rs index fb8c6938cdb..472ac55ca09 100644 --- a/common/eth2_network_config/src/lib.rs +++ b/common/eth2_network_config/src/lib.rs @@ -462,7 +462,7 @@ mod tests { use super::*; use ssz::Encode; use tempfile::Builder as TempBuilder; - use types::{Eth1Data, GnosisEthSpec, MainnetEthSpec}; + use types::{Eth1Data, FixedBytesExtended, GnosisEthSpec, MainnetEthSpec}; type E = MainnetEthSpec; diff --git a/consensus/fixed_bytes/Cargo.toml b/consensus/fixed_bytes/Cargo.toml new file mode 100644 index 00000000000..e5201a04551 --- /dev/null +++ b/consensus/fixed_bytes/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "fixed_bytes" +version = "0.1.0" +authors = ["Eitan Seri-Levi "] +edition = { workspace = true } + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +alloy-primitives = { workspace = true } +safe_arith = { workspace = true } diff --git a/consensus/fixed_bytes/src/lib.rs b/consensus/fixed_bytes/src/lib.rs new file mode 100644 index 00000000000..efd3e593b93 --- /dev/null +++ b/consensus/fixed_bytes/src/lib.rs @@ -0,0 +1,160 @@ +use alloy_primitives::FixedBytes; +use safe_arith::SafeArith; + +pub type Hash64 = alloy_primitives::B64; +pub type Hash256 = alloy_primitives::B256; +pub type Uint256 = alloy_primitives::U256; +pub type Address = alloy_primitives::Address; + +pub trait UintExtended { + fn to_i64(self) -> i64; +} + +pub trait FixedBytesExtended { + fn from_low_u64_be(value: u64) -> Self; + fn from_low_u64_le(value: u64) -> Self; + fn to_low_u64_le(&self) -> u64; + fn zero() -> Self; +} + +impl FixedBytesExtended for FixedBytes { + fn from_low_u64_be(value: u64) -> Self { + let value_bytes = value.to_be_bytes(); + let mut buffer = [0x0; N]; + let bytes_to_copy = value_bytes.len().min(buffer.len()); + // Panic-free because bytes_to_copy <= buffer.len() + let start_index = buffer + .len() + .safe_sub(bytes_to_copy) + .expect("bytes_to_copy <= buffer.len()"); + // Panic-free because start_index <= buffer.len() + // and bytes_to_copy <= value_bytes.len() + buffer + .get_mut(start_index..) + .expect("start_index <= buffer.len()") + .copy_from_slice( + value_bytes + .get(..bytes_to_copy) + .expect("bytes_to_copy <= value_byte.len()"), + ); + Self::from(buffer) + } + + fn from_low_u64_le(value: u64) -> Self { + let value_bytes = value.to_le_bytes(); + let mut buffer = [0x0; N]; + let bytes_to_copy = value_bytes.len().min(buffer.len()); + // Panic-free because bytes_to_copy <= buffer.len(), + // and bytes_to_copy <= value_bytes.len() + buffer + .get_mut(..bytes_to_copy) + .expect("bytes_to_copy <= buffer.len()") + .copy_from_slice( + value_bytes + .get(..bytes_to_copy) + .expect("bytes_to_copy <= value_byte.len()"), + ); + Self::from(buffer) + } + + fn zero() -> Self { + Self::ZERO + } + + /// Trims FixedBytes to its first 8 bytes and converts to u64 + fn to_low_u64_le(&self) -> u64 { + let mut result = [0u8; 8]; + let bytes = self.as_slice(); + // Panic-free because result.len() == bytes[0..8].len() + result.copy_from_slice(&bytes[0..8]); + u64::from_le_bytes(result) + } +} + +impl FixedBytesExtended for alloy_primitives::Address { + fn from_low_u64_be(value: u64) -> Self { + FixedBytes::<20>::from_low_u64_be(value).into() + } + + fn from_low_u64_le(value: u64) -> Self { + FixedBytes::<20>::from_low_u64_le(value).into() + } + + fn zero() -> Self { + FixedBytes::<20>::zero().into() + } + + fn to_low_u64_le(&self) -> u64 { + FixedBytes::<20>::to_low_u64_le(self) + } +} + +impl UintExtended for Uint256 { + /// Trims the Uint256 to its first 8 bytes and converts to i64 + fn to_i64(self) -> i64 { + let mut result = [0u8; 8]; + let bytes = self.to_le_bytes::<32>(); + // Panic-free because result.len() == bytes[0..8].len() + result.copy_from_slice(&bytes[0..8]); + i64::from_le_bytes(result) + } +} + +#[cfg(test)] +mod test { + use super::*; + use alloy_primitives::bytes::Buf; + + #[test] + fn from_low_u64_be() { + let values = [0, 1, 0xff, 1 << 16, u64::MAX, u64::MAX - 1]; + for value in values { + assert_eq!( + (&Hash256::from_low_u64_be(value).as_slice()[24..]).get_u64(), + value + ); + } + } + + #[test] + fn from_low_u64_le() { + let values = [0, 1, 0xff, 1 << 16, u64::MAX, u64::MAX - 1]; + for value in values { + assert_eq!( + u64::from_le_bytes( + Hash256::from_low_u64_le(value).as_slice()[0..8] + .try_into() + .unwrap() + ), + value + ); + } + } + + #[test] + fn to_low_u64_le() { + let values = [0, 1, 0xff, 1 << 16, u64::MAX, u64::MAX - 1]; + for value in values { + assert_eq!(Hash256::from_low_u64_le(value).to_low_u64_le(), value); + } + } + + #[test] + fn to_i64_in_range() { + let values = [0, 1, 0xff, 1 << 16, i64::MAX, i64::MAX - 1]; + for value in values { + assert_eq!(Uint256::from(value).to_i64(), value); + } + } + + #[test] + fn to_i64_out_of_range() { + let values = [u128::MAX, 1 << 70, 1 << 80, i64::MAX as u128 + 1]; + for value in values { + assert_eq!( + Uint256::from(value).to_i64(), + i64::from_le_bytes(value.to_le_bytes()[0..8].try_into().unwrap()) + ); + } + } +} diff --git a/consensus/fork_choice/src/fork_choice.rs b/consensus/fork_choice/src/fork_choice.rs index 1482e2beb45..ca59a6adfb6 100644 --- a/consensus/fork_choice/src/fork_choice.rs +++ b/consensus/fork_choice/src/fork_choice.rs @@ -16,8 +16,8 @@ use std::time::Duration; use types::{ consts::bellatrix::INTERVALS_PER_SLOT, AbstractExecPayload, AttestationShufflingId, AttesterSlashingRef, BeaconBlockRef, BeaconState, BeaconStateError, ChainSpec, Checkpoint, - Epoch, EthSpec, ExecPayload, ExecutionBlockHash, Hash256, IndexedAttestationRef, RelativeEpoch, - SignedBeaconBlock, Slot, + Epoch, EthSpec, ExecPayload, ExecutionBlockHash, FixedBytesExtended, Hash256, + IndexedAttestationRef, RelativeEpoch, SignedBeaconBlock, Slot, }; #[derive(Debug)] diff --git a/consensus/fork_choice/tests/tests.rs b/consensus/fork_choice/tests/tests.rs index 19faf69bcb4..b1ef833be0f 100644 --- a/consensus/fork_choice/tests/tests.rs +++ b/consensus/fork_choice/tests/tests.rs @@ -16,8 +16,8 @@ use std::time::Duration; use store::MemoryStore; use types::{ test_utils::generate_deterministic_keypair, BeaconBlockRef, BeaconState, ChainSpec, Checkpoint, - Epoch, EthSpec, ForkName, Hash256, IndexedAttestation, MainnetEthSpec, RelativeEpoch, - SignedBeaconBlock, Slot, SubnetId, + Epoch, EthSpec, FixedBytesExtended, ForkName, Hash256, IndexedAttestation, MainnetEthSpec, + RelativeEpoch, SignedBeaconBlock, Slot, SubnetId, }; pub type E = MainnetEthSpec; diff --git a/consensus/merkle_proof/Cargo.toml b/consensus/merkle_proof/Cargo.toml index 15f65dfe4f6..c2c6bf270a6 100644 --- a/consensus/merkle_proof/Cargo.toml +++ b/consensus/merkle_proof/Cargo.toml @@ -5,13 +5,14 @@ authors = ["Michael Sproul "] edition = { workspace = true } [dependencies] -ethereum-types = { workspace = true } +alloy-primitives = { workspace = true } ethereum_hashing = { workspace = true } safe_arith = { workspace = true } +fixed_bytes = { workspace = true } [dev-dependencies] quickcheck = { workspace = true } quickcheck_macros = { workspace = true } [features] -arbitrary = ["ethereum-types/arbitrary"] +arbitrary = ["alloy-primitives/arbitrary"] diff --git a/consensus/merkle_proof/src/lib.rs b/consensus/merkle_proof/src/lib.rs index b9457fffab8..b01f3f4429f 100644 --- a/consensus/merkle_proof/src/lib.rs +++ b/consensus/merkle_proof/src/lib.rs @@ -1,8 +1,10 @@ use ethereum_hashing::{hash, hash32_concat, ZERO_HASHES}; -use ethereum_types::H256; use safe_arith::ArithError; use std::sync::LazyLock; +type H256 = fixed_bytes::Hash256; +pub use fixed_bytes::FixedBytesExtended; + const MAX_TREE_DEPTH: usize = 32; const EMPTY_SLICE: &[H256] = &[]; @@ -86,8 +88,8 @@ impl MerkleTree { let left_subtree = MerkleTree::create(left_leaves, depth - 1); let right_subtree = MerkleTree::create(right_leaves, depth - 1); let hash = H256::from_slice(&hash32_concat( - left_subtree.hash().as_bytes(), - right_subtree.hash().as_bytes(), + left_subtree.hash().as_slice(), + right_subtree.hash().as_slice(), )); Node(hash, Box::new(left_subtree), Box::new(right_subtree)) @@ -143,9 +145,9 @@ impl MerkleTree { // All other possibilities are invalid MerkleTrees (_, _) => return Err(MerkleTreeError::Invalid), }; - hash.assign_from_slice(&hash32_concat( - left.hash().as_bytes(), - right.hash().as_bytes(), + hash.copy_from_slice(&hash32_concat( + left.hash().as_slice(), + right.hash().as_slice(), )); } Finalized(_) => return Err(MerkleTreeError::FinalizedNodePushed), @@ -274,8 +276,8 @@ impl MerkleTree { }; let hash = H256::from_slice(&hash32_concat( - left.hash().as_bytes(), - right.hash().as_bytes(), + left.hash().as_slice(), + right.hash().as_slice(), )); Ok(MerkleTree::Node(hash, Box::new(left), Box::new(right))) } @@ -369,15 +371,15 @@ pub fn verify_merkle_proof( pub fn merkle_root_from_branch(leaf: H256, branch: &[H256], depth: usize, index: usize) -> H256 { assert_eq!(branch.len(), depth, "proof length should equal depth"); - let mut merkle_root = leaf.as_bytes().to_vec(); + let mut merkle_root = leaf.as_slice().to_vec(); for (i, leaf) in branch.iter().enumerate().take(depth) { let ith_bit = (index >> i) & 0x01; if ith_bit == 1 { - merkle_root = hash32_concat(leaf.as_bytes(), &merkle_root)[..].to_vec(); + merkle_root = hash32_concat(leaf.as_slice(), &merkle_root)[..].to_vec(); } else { let mut input = merkle_root; - input.extend_from_slice(leaf.as_bytes()); + input.extend_from_slice(leaf.as_slice()); merkle_root = hash(&input); } } @@ -433,7 +435,6 @@ mod tests { } let leaves_iter = int_leaves.into_iter().map(H256::from_low_u64_be); - let mut merkle_tree = MerkleTree::create(&[], depth); let proofs_ok = leaves_iter.enumerate().all(|(i, leaf)| { @@ -465,10 +466,10 @@ mod tests { let leaf_b10 = H256::from([0xCC; 32]); let leaf_b11 = H256::from([0xDD; 32]); - let node_b0x = H256::from_slice(&hash32_concat(leaf_b00.as_bytes(), leaf_b01.as_bytes())); - let node_b1x = H256::from_slice(&hash32_concat(leaf_b10.as_bytes(), leaf_b11.as_bytes())); + let node_b0x = H256::from_slice(&hash32_concat(leaf_b00.as_slice(), leaf_b01.as_slice())); + let node_b1x = H256::from_slice(&hash32_concat(leaf_b10.as_slice(), leaf_b11.as_slice())); - let root = H256::from_slice(&hash32_concat(node_b0x.as_bytes(), node_b1x.as_bytes())); + let root = H256::from_slice(&hash32_concat(node_b0x.as_slice(), node_b1x.as_slice())); let tree = MerkleTree::create(&[leaf_b00, leaf_b01, leaf_b10, leaf_b11], 2); assert_eq!(tree.hash(), root); @@ -482,10 +483,10 @@ mod tests { let leaf_b10 = H256::from([0xCC; 32]); let leaf_b11 = H256::from([0xDD; 32]); - let node_b0x = H256::from_slice(&hash32_concat(leaf_b00.as_bytes(), leaf_b01.as_bytes())); - let node_b1x = H256::from_slice(&hash32_concat(leaf_b10.as_bytes(), leaf_b11.as_bytes())); + let node_b0x = H256::from_slice(&hash32_concat(leaf_b00.as_slice(), leaf_b01.as_slice())); + let node_b1x = H256::from_slice(&hash32_concat(leaf_b10.as_slice(), leaf_b11.as_slice())); - let root = H256::from_slice(&hash32_concat(node_b0x.as_bytes(), node_b1x.as_bytes())); + let root = H256::from_slice(&hash32_concat(node_b0x.as_slice(), node_b1x.as_slice())); // Run some proofs assert!(verify_merkle_proof( diff --git a/consensus/proto_array/src/fork_choice_test_definition.rs b/consensus/proto_array/src/fork_choice_test_definition.rs index 57648499753..d99ace05f95 100644 --- a/consensus/proto_array/src/fork_choice_test_definition.rs +++ b/consensus/proto_array/src/fork_choice_test_definition.rs @@ -8,8 +8,8 @@ use crate::{InvalidationOperation, JustifiedBalances}; use serde::{Deserialize, Serialize}; use std::collections::BTreeSet; use types::{ - AttestationShufflingId, Checkpoint, Epoch, EthSpec, ExecutionBlockHash, Hash256, - MainnetEthSpec, Slot, + AttestationShufflingId, Checkpoint, Epoch, EthSpec, ExecutionBlockHash, FixedBytesExtended, + Hash256, MainnetEthSpec, Slot, }; pub use execution_status::*; diff --git a/consensus/proto_array/src/fork_choice_test_definition/no_votes.rs b/consensus/proto_array/src/fork_choice_test_definition/no_votes.rs index 27a7969e49b..de84fbdd128 100644 --- a/consensus/proto_array/src/fork_choice_test_definition/no_votes.rs +++ b/consensus/proto_array/src/fork_choice_test_definition/no_votes.rs @@ -1,3 +1,5 @@ +use types::FixedBytesExtended; + use super::*; pub fn get_no_votes_test_definition() -> ForkChoiceTestDefinition { diff --git a/consensus/proto_array/src/proto_array.rs b/consensus/proto_array/src/proto_array.rs index 74f3a986c9d..38ea1411994 100644 --- a/consensus/proto_array/src/proto_array.rs +++ b/consensus/proto_array/src/proto_array.rs @@ -7,8 +7,8 @@ use ssz_derive::{Decode, Encode}; use std::collections::{HashMap, HashSet}; use superstruct::superstruct; use types::{ - AttestationShufflingId, ChainSpec, Checkpoint, Epoch, EthSpec, ExecutionBlockHash, Hash256, - Slot, + AttestationShufflingId, ChainSpec, Checkpoint, Epoch, EthSpec, ExecutionBlockHash, + FixedBytesExtended, Hash256, Slot, }; // Define a "legacy" implementation of `Option` which uses four bytes for encoding the union diff --git a/consensus/proto_array/src/proto_array_fork_choice.rs b/consensus/proto_array/src/proto_array_fork_choice.rs index 606269aee08..88d46603117 100644 --- a/consensus/proto_array/src/proto_array_fork_choice.rs +++ b/consensus/proto_array/src/proto_array_fork_choice.rs @@ -15,8 +15,8 @@ use std::{ fmt, }; use types::{ - AttestationShufflingId, ChainSpec, Checkpoint, Epoch, EthSpec, ExecutionBlockHash, Hash256, - Slot, + AttestationShufflingId, ChainSpec, Checkpoint, Epoch, EthSpec, ExecutionBlockHash, + FixedBytesExtended, Hash256, Slot, }; pub const DEFAULT_PRUNE_THRESHOLD: usize = 256; @@ -993,7 +993,7 @@ fn compute_deltas( #[cfg(test)] mod test_compute_deltas { use super::*; - use types::MainnetEthSpec; + use types::{FixedBytesExtended, MainnetEthSpec}; /// Gives a hash that is not the zero hash (unless i is `usize::MAX)`. fn hash_from_index(i: usize) -> Hash256 { diff --git a/consensus/state_processing/src/all_caches.rs b/consensus/state_processing/src/all_caches.rs index b915091405b..e49eb395c40 100644 --- a/consensus/state_processing/src/all_caches.rs +++ b/consensus/state_processing/src/all_caches.rs @@ -1,6 +1,8 @@ use crate::common::update_progressive_balances_cache::initialize_progressive_balances_cache; use crate::epoch_cache::initialize_epoch_cache; -use types::{BeaconState, ChainSpec, EpochCacheError, EthSpec, Hash256, RelativeEpoch}; +use types::{ + BeaconState, ChainSpec, EpochCacheError, EthSpec, FixedBytesExtended, Hash256, RelativeEpoch, +}; /// Mixin trait for the beacon state that provides operations on *all* caches. /// diff --git a/consensus/state_processing/src/epoch_cache.rs b/consensus/state_processing/src/epoch_cache.rs index 0e940fabe4f..5af5e639fd2 100644 --- a/consensus/state_processing/src/epoch_cache.rs +++ b/consensus/state_processing/src/epoch_cache.rs @@ -3,7 +3,9 @@ use crate::common::base::SqrtTotalActiveBalance; use crate::common::{altair, base}; use safe_arith::SafeArith; use types::epoch_cache::{EpochCache, EpochCacheError, EpochCacheKey}; -use types::{ActivationQueue, BeaconState, ChainSpec, EthSpec, ForkName, Hash256}; +use types::{ + ActivationQueue, BeaconState, ChainSpec, EthSpec, FixedBytesExtended, ForkName, Hash256, +}; /// Precursor to an `EpochCache`. pub struct PreEpochCache { diff --git a/consensus/state_processing/src/per_block_processing/verify_bls_to_execution_change.rs b/consensus/state_processing/src/per_block_processing/verify_bls_to_execution_change.rs index 1e8f25ed10b..24024fa8990 100644 --- a/consensus/state_processing/src/per_block_processing/verify_bls_to_execution_change.rs +++ b/consensus/state_processing/src/per_block_processing/verify_bls_to_execution_change.rs @@ -30,7 +30,7 @@ pub fn verify_bls_to_execution_change( verify!( validator .withdrawal_credentials - .as_bytes() + .as_slice() .first() .map(|byte| *byte == spec.bls_withdrawal_prefix_byte) .unwrap_or(false), @@ -41,7 +41,7 @@ pub fn verify_bls_to_execution_change( // future. let pubkey_hash = hash(address_change.from_bls_pubkey.as_serialized()); verify!( - validator.withdrawal_credentials.as_bytes().get(1..) == pubkey_hash.get(1..), + validator.withdrawal_credentials.as_slice().get(1..) == pubkey_hash.get(1..), Invalid::WithdrawalCredentialsMismatch ); diff --git a/consensus/state_processing/src/per_epoch_processing/tests.rs b/consensus/state_processing/src/per_epoch_processing/tests.rs index 14bbfbc071d..8c240548b04 100644 --- a/consensus/state_processing/src/per_epoch_processing/tests.rs +++ b/consensus/state_processing/src/per_epoch_processing/tests.rs @@ -2,7 +2,7 @@ use crate::per_epoch_processing::process_epoch; use beacon_chain::test_utils::BeaconChainHarness; use beacon_chain::types::{EthSpec, MinimalEthSpec}; -use bls::Hash256; +use bls::{FixedBytesExtended, Hash256}; use env_logger::{Builder, Env}; use types::Slot; diff --git a/consensus/state_processing/src/state_advance.rs b/consensus/state_processing/src/state_advance.rs index 721907cac93..4d38e7797e6 100644 --- a/consensus/state_processing/src/state_advance.rs +++ b/consensus/state_processing/src/state_advance.rs @@ -5,7 +5,7 @@ //! duplication and protect against some easy-to-make mistakes when performing state advances. use crate::*; -use types::{BeaconState, ChainSpec, EthSpec, Hash256, Slot}; +use types::{BeaconState, ChainSpec, EthSpec, FixedBytesExtended, Hash256, Slot}; #[derive(Debug, PartialEq)] pub enum Error { diff --git a/consensus/swap_or_not_shuffle/Cargo.toml b/consensus/swap_or_not_shuffle/Cargo.toml index ea9b603c5bc..aff0225edd4 100644 --- a/consensus/swap_or_not_shuffle/Cargo.toml +++ b/consensus/swap_or_not_shuffle/Cargo.toml @@ -12,8 +12,10 @@ harness = false criterion = { workspace = true } [dependencies] +alloy-primitives = { workspace = true } ethereum_hashing = { workspace = true } -ethereum-types = { workspace = true } +fixed_bytes = { workspace = true } [features] -arbitrary = ["ethereum-types/arbitrary"] +arbitrary = ["alloy-primitives/arbitrary"] +getrandom = ["alloy-primitives/getrandom"] diff --git a/consensus/swap_or_not_shuffle/src/compute_shuffled_index.rs b/consensus/swap_or_not_shuffle/src/compute_shuffled_index.rs index 5f25c517b0e..a7f25ea65f7 100644 --- a/consensus/swap_or_not_shuffle/src/compute_shuffled_index.rs +++ b/consensus/swap_or_not_shuffle/src/compute_shuffled_index.rs @@ -87,7 +87,7 @@ fn bytes_to_int64(slice: &[u8]) -> u64 { #[cfg(test)] mod tests { use super::*; - use ethereum_types::H256 as Hash256; + use alloy_primitives::B256 as Hash256; #[test] #[ignore] diff --git a/consensus/swap_or_not_shuffle/src/lib.rs b/consensus/swap_or_not_shuffle/src/lib.rs index e9a131ab059..c6af6b77516 100644 --- a/consensus/swap_or_not_shuffle/src/lib.rs +++ b/consensus/swap_or_not_shuffle/src/lib.rs @@ -20,4 +20,4 @@ mod shuffle_list; pub use compute_shuffled_index::compute_shuffled_index; pub use shuffle_list::shuffle_list; -type Hash256 = ethereum_types::H256; +type Hash256 = fixed_bytes::Hash256; diff --git a/consensus/types/Cargo.toml b/consensus/types/Cargo.toml index c6c89de5704..c1559a407cf 100644 --- a/consensus/types/Cargo.toml +++ b/consensus/types/Cargo.toml @@ -9,14 +9,13 @@ name = "benches" harness = false [dependencies] -alloy-primitives = { workspace = true, features = ["rlp"] } +alloy-primitives = { workspace = true, features = ["rlp", "getrandom"] } merkle_proof = { workspace = true } bls = { workspace = true, features = ["arbitrary"] } kzg = { workspace = true } compare_fields = { workspace = true } compare_fields_derive = { workspace = true } eth2_interop_keypairs = { path = "../../common/eth2_interop_keypairs" } -ethereum-types = { workspace = true, features = ["arbitrary"] } ethereum_hashing = { workspace = true } hex = { workspace = true } int_to_bytes = { workspace = true } @@ -31,7 +30,7 @@ ethereum_ssz_derive = { workspace = true } ssz_types = { workspace = true, features = ["arbitrary"] } swap_or_not_shuffle = { workspace = true, features = ["arbitrary"] } test_random_derive = { path = "../../common/test_random_derive" } -tree_hash = { workspace = true, features = ["arbitrary"] } +tree_hash = { workspace = true } tree_hash_derive = { workspace = true } rand_xorshift = "0.3.0" serde_yaml = { workspace = true } @@ -53,6 +52,7 @@ maplit = { workspace = true } alloy-rlp = { version = "0.3.4", features = ["derive"] } milhouse = { workspace = true } rpds = { workspace = true } +fixed_bytes = { workspace = true } [dev-dependencies] criterion = { workspace = true } diff --git a/consensus/types/benches/benches.rs b/consensus/types/benches/benches.rs index 56c48e6cb1c..effc6a21068 100644 --- a/consensus/types/benches/benches.rs +++ b/consensus/types/benches/benches.rs @@ -4,8 +4,8 @@ use rayon::prelude::*; use ssz::Encode; use std::sync::Arc; use types::{ - test_utils::generate_deterministic_keypair, BeaconState, Epoch, Eth1Data, EthSpec, Hash256, - MainnetEthSpec, Validator, + test_utils::generate_deterministic_keypair, BeaconState, Epoch, Eth1Data, EthSpec, + FixedBytesExtended, Hash256, MainnetEthSpec, Validator, }; fn get_state(validator_count: usize) -> BeaconState { diff --git a/consensus/types/src/attestation.rs b/consensus/types/src/attestation.rs index b8aa2560329..3801a2b5d2b 100644 --- a/consensus/types/src/attestation.rs +++ b/consensus/types/src/attestation.rs @@ -412,13 +412,7 @@ impl AttestationBase { pub fn extend_aggregation_bits( &self, ) -> Result, ssz_types::Error> { - let mut extended_aggregation_bits: BitList = - BitList::with_capacity(self.aggregation_bits.len())?; - - for (i, bit) in self.aggregation_bits.iter().enumerate() { - extended_aggregation_bits.set(i, bit)?; - } - Ok(extended_aggregation_bits) + self.aggregation_bits.resize::() } } diff --git a/consensus/types/src/beacon_block.rs b/consensus/types/src/beacon_block.rs index 300faf32f22..4a6816c024d 100644 --- a/consensus/types/src/beacon_block.rs +++ b/consensus/types/src/beacon_block.rs @@ -507,7 +507,7 @@ impl> BeaconBlockCapella message: BlsToExecutionChange { validator_index: 0, from_bls_pubkey: PublicKeyBytes::empty(), - to_execution_address: Address::zero(), + to_execution_address: Address::ZERO, }, signature: Signature::empty() }; @@ -637,7 +637,7 @@ impl> BeaconBlockElectra message: BlsToExecutionChange { validator_index: 0, from_bls_pubkey: PublicKeyBytes::empty(), - to_execution_address: Address::zero(), + to_execution_address: Address::ZERO, }, signature: Signature::empty() }; diff --git a/consensus/types/src/beacon_state.rs b/consensus/types/src/beacon_state.rs index b8ebe101205..a08f6d720c7 100644 --- a/consensus/types/src/beacon_state.rs +++ b/consensus/types/src/beacon_state.rs @@ -1,6 +1,7 @@ use self::committee_cache::get_active_validator_indices; use crate::historical_summary::HistoricalSummary; use crate::test_utils::TestRandom; +use crate::FixedBytesExtended; use crate::*; use compare_fields::CompareFields; use compare_fields_derive::CompareFields; @@ -1038,7 +1039,7 @@ impl BeaconState { let epoch = slot.epoch(E::slots_per_epoch()); let mut preimage = self .get_seed(epoch, Domain::BeaconProposer, spec)? - .as_bytes() + .as_slice() .to_vec(); preimage.append(&mut int_to_bytes8(slot.as_u64())); Ok(hash(&preimage)) @@ -1099,14 +1100,14 @@ impl BeaconState { let shuffled_index = compute_shuffled_index( i.safe_rem(active_validator_count)?, active_validator_count, - seed.as_bytes(), + seed.as_slice(), spec.shuffle_round_count, ) .ok_or(Error::UnableToShuffle)?; let candidate_index = *active_validator_indices .get(shuffled_index) .ok_or(Error::ShuffleIndexOutOfBounds(shuffled_index))?; - let random_byte = Self::shuffling_random_byte(i, seed.as_bytes())?; + let random_byte = Self::shuffling_random_byte(i, seed.as_slice())?; let effective_balance = self.get_validator(candidate_index)?.effective_balance; if effective_balance.safe_mul(MAX_RANDOM_BYTE)? >= max_effective_balance.safe_mul(u64::from(random_byte))? @@ -1528,7 +1529,7 @@ impl BeaconState { let mut preimage = [0; NUM_DOMAIN_BYTES + NUM_EPOCH_BYTES + NUM_MIX_BYTES]; preimage[0..NUM_DOMAIN_BYTES].copy_from_slice(&domain_bytes); preimage[NUM_DOMAIN_BYTES..MIX_OFFSET].copy_from_slice(&epoch_bytes); - preimage[MIX_OFFSET..].copy_from_slice(mix.as_bytes()); + preimage[MIX_OFFSET..].copy_from_slice(mix.as_slice()); Ok(Hash256::from_slice(&hash(&preimage))) } @@ -2214,8 +2215,9 @@ impl BeaconState { .get_mut(validator_index) .ok_or(Error::UnknownValidator(validator_index))?; if validator.has_eth1_withdrawal_credential(spec) { - validator.withdrawal_credentials.as_fixed_bytes_mut()[0] = + AsMut::<[u8; 32]>::as_mut(&mut validator.withdrawal_credentials)[0] = spec.compounding_withdrawal_prefix_byte; + self.queue_excess_active_balance(validator_index, spec)?; } Ok(()) diff --git a/consensus/types/src/beacon_state/tests.rs b/consensus/types/src/beacon_state/tests.rs index 7d67e96bbc8..3ad3ccf5617 100644 --- a/consensus/types/src/beacon_state/tests.rs +++ b/consensus/types/src/beacon_state/tests.rs @@ -3,8 +3,8 @@ use crate::test_utils::*; use beacon_chain::test_utils::{BeaconChainHarness, EphemeralHarnessType}; use beacon_chain::types::{ test_utils::TestRandom, BeaconState, BeaconStateAltair, BeaconStateBase, BeaconStateError, - ChainSpec, Domain, Epoch, EthSpec, Hash256, Keypair, MainnetEthSpec, MinimalEthSpec, - RelativeEpoch, Slot, Vector, + ChainSpec, Domain, Epoch, EthSpec, FixedBytesExtended, Hash256, Keypair, MainnetEthSpec, + MinimalEthSpec, RelativeEpoch, Slot, Vector, }; use ssz::Encode; use std::ops::Mul; diff --git a/consensus/types/src/bls_to_execution_change.rs b/consensus/types/src/bls_to_execution_change.rs index e6426e125ff..07d71b360f9 100644 --- a/consensus/types/src/bls_to_execution_change.rs +++ b/consensus/types/src/bls_to_execution_change.rs @@ -23,6 +23,7 @@ pub struct BlsToExecutionChange { #[serde(with = "serde_utils::quoted_u64")] pub validator_index: u64, pub from_bls_pubkey: PublicKeyBytes, + #[serde(with = "serde_utils::address_hex")] pub to_execution_address: Address, } diff --git a/consensus/types/src/chain_spec.rs b/consensus/types/src/chain_spec.rs index 2c28c3d31d7..a8c74b852c6 100644 --- a/consensus/types/src/chain_spec.rs +++ b/consensus/types/src/chain_spec.rs @@ -545,7 +545,7 @@ impl ChainSpec { let mut result = [0; 4]; let root = Self::compute_fork_data_root(current_version, genesis_validators_root); result.copy_from_slice( - root.as_bytes() + root.as_slice() .get(0..4) .expect("root hash is at least 4 bytes"), ); @@ -565,7 +565,7 @@ impl ChainSpec { domain[0..4].copy_from_slice(&int_to_bytes4(domain_constant)); domain[4..].copy_from_slice( Self::compute_fork_data_root(fork_version, genesis_validators_root) - .as_bytes() + .as_slice() .get(..28) .expect("fork has is 32 bytes so first 28 bytes should exist"), ); @@ -765,7 +765,8 @@ impl ChainSpec { proportional_slashing_multiplier_bellatrix: 3, bellatrix_fork_version: [0x02, 0x00, 0x00, 0x00], bellatrix_fork_epoch: Some(Epoch::new(144896)), - terminal_total_difficulty: Uint256::from_dec_str("58750000000000000000000") + terminal_total_difficulty: "58750000000000000000000" + .parse() .expect("terminal_total_difficulty is a valid integer"), terminal_block_hash: ExecutionBlockHash::zero(), terminal_block_hash_activation_epoch: Epoch::new(u64::MAX), @@ -912,7 +913,7 @@ impl ChainSpec { .expect("subtraction does not overflow") // Add 1 since the spec declares `2**256 - 2**10` and we use // `Uint256::MAX` which is `2*256- 1`. - .checked_add(Uint256::one()) + .checked_add(Uint256::from(2u64.pow(0))) .expect("addition does not overflow"), // Capella capella_fork_version: [0x03, 0x00, 0x00, 0x01], @@ -1086,10 +1087,9 @@ impl ChainSpec { proportional_slashing_multiplier_bellatrix: 3, bellatrix_fork_version: [0x02, 0x00, 0x00, 0x64], bellatrix_fork_epoch: Some(Epoch::new(385536)), - terminal_total_difficulty: Uint256::from_dec_str( - "8626000000000000000000058750000000000000000000", - ) - .expect("terminal_total_difficulty is a valid integer"), + terminal_total_difficulty: "8626000000000000000000058750000000000000000000" + .parse() + .expect("terminal_total_difficulty is a valid integer"), terminal_block_hash: ExecutionBlockHash::zero(), terminal_block_hash_activation_epoch: Epoch::new(u64::MAX), safe_slots_to_import_optimistically: 128u64, @@ -1318,6 +1318,7 @@ pub struct Config { deposit_chain_id: u64, #[serde(with = "serde_utils::quoted_u64")] deposit_network_id: u64, + #[serde(with = "serde_utils::address_hex")] deposit_contract_address: Address, #[serde(default = "default_gossip_max_size")] @@ -1423,7 +1424,7 @@ fn default_electra_fork_version() -> [u8; 4] { /// /// Taken from https://github.com/ethereum/consensus-specs/blob/d5e4828aecafaf1c57ef67a5f23c4ae7b08c5137/configs/mainnet.yaml#L15-L16 const fn default_terminal_total_difficulty() -> Uint256 { - ethereum_types::U256([ + Uint256::from_limbs([ 18446744073709550592, 18446744073709551615, 18446744073709551615, @@ -1950,7 +1951,7 @@ mod tests { let domain2 = spec.compute_domain(domain_type, version, genesis_validators_root); assert_eq!(domain1, domain2); - assert_eq!(&domain1.as_bytes()[0..4], &int_to_bytes4(raw_domain)[..]); + assert_eq!(&domain1.as_slice()[0..4], &int_to_bytes4(raw_domain)[..]); } } @@ -2188,9 +2189,8 @@ mod yaml_tests { fn test_total_terminal_difficulty() { assert_eq!( Ok(default_terminal_total_difficulty()), - Uint256::from_dec_str( - "115792089237316195423570985008687907853269984665640564039457584007913129638912" - ) + "115792089237316195423570985008687907853269984665640564039457584007913129638912" + .parse() ); } diff --git a/consensus/types/src/data_column_subnet_id.rs b/consensus/types/src/data_column_subnet_id.rs index dd58c6c36b4..df964cf8de7 100644 --- a/consensus/types/src/data_column_subnet_id.rs +++ b/consensus/types/src/data_column_subnet_id.rs @@ -1,7 +1,7 @@ //! Identifies each data column subnet by an integer identifier. use crate::data_column_sidecar::ColumnIndex; use crate::{ChainSpec, EthSpec}; -use ethereum_types::U256; +use alloy_primitives::U256; use itertools::Itertools; use safe_arith::{ArithError, SafeArith}; use serde::{Deserialize, Serialize}; @@ -38,7 +38,7 @@ impl DataColumnSubnetId { /// Compute required subnets to subscribe to given the node id. #[allow(clippy::arithmetic_side_effects)] pub fn compute_custody_subnets( - node_id: U256, + raw_node_id: [u8; 32], custody_subnet_count: u64, spec: &ChainSpec, ) -> impl Iterator { @@ -46,10 +46,10 @@ impl DataColumnSubnetId { // value, but here we assume it is valid. let mut subnets: HashSet = HashSet::new(); - let mut current_id = node_id; + let mut current_id = U256::from_be_slice(&raw_node_id); while (subnets.len() as u64) < custody_subnet_count { let mut node_id_bytes = [0u8; 32]; - current_id.to_little_endian(&mut node_id_bytes); + node_id_bytes.copy_from_slice(current_id.as_le_slice()); let hash = ethereum_hashing::hash_fixed(&node_id_bytes); let hash_prefix: [u8; 8] = hash[0..8] .try_into() @@ -62,19 +62,19 @@ impl DataColumnSubnetId { } if current_id == U256::MAX { - current_id = U256::zero() + current_id = U256::ZERO } - current_id += U256::one() + current_id += U256::from(1u64) } subnets.into_iter().map(DataColumnSubnetId::new) } pub fn compute_custody_columns( - node_id: U256, + raw_node_id: [u8; 32], custody_subnet_count: u64, spec: &ChainSpec, ) -> impl Iterator { - Self::compute_custody_subnets::(node_id, custody_subnet_count, spec) + Self::compute_custody_subnets::(raw_node_id, custody_subnet_count, spec) .flat_map(|subnet| subnet.columns::(spec)) .sorted() } @@ -134,6 +134,7 @@ mod test { use crate::data_column_subnet_id::DataColumnSubnetId; use crate::EthSpec; use crate::MainnetEthSpec; + use crate::Uint256; type E = MainnetEthSpec; @@ -153,7 +154,7 @@ mod test { "103822458477361691467064888613019442068586830412598673713899771287914656699997", ] .into_iter() - .map(|v| ethereum_types::U256::from_dec_str(v).unwrap()) + .map(|v| Uint256::from_str_radix(v, 10).unwrap().to_be_bytes::<32>()) .collect::>(); let custody_requirement = 4; diff --git a/consensus/types/src/deposit_tree_snapshot.rs b/consensus/types/src/deposit_tree_snapshot.rs index 1793be1c7c8..df1064daba0 100644 --- a/consensus/types/src/deposit_tree_snapshot.rs +++ b/consensus/types/src/deposit_tree_snapshot.rs @@ -40,7 +40,7 @@ impl Default for DepositTreeSnapshot { fn default() -> Self { let mut result = Self { finalized: vec![], - deposit_root: Hash256::default(), + deposit_root: Hash256::zero(), deposit_count: 0, execution_block_hash: Hash256::zero(), execution_block_height: 0, @@ -60,7 +60,7 @@ impl DepositTreeSnapshot { for height in 0..DEPOSIT_TREE_DEPTH { deposit_root = if (size & 1) == 1 { index = index.checked_sub(1)?; - hash32_concat(self.finalized.get(index)?.as_bytes(), &deposit_root) + hash32_concat(self.finalized.get(index)?.as_slice(), &deposit_root) } else { hash32_concat(&deposit_root, ZERO_HASHES.get(height)?) }; diff --git a/consensus/types/src/execution_block_hash.rs b/consensus/types/src/execution_block_hash.rs index b2401f0c0f1..677b3d3408d 100644 --- a/consensus/types/src/execution_block_hash.rs +++ b/consensus/types/src/execution_block_hash.rs @@ -1,4 +1,5 @@ use crate::test_utils::TestRandom; +use crate::FixedBytesExtended; use crate::Hash256; use derivative::Derivative; use rand::RngCore; @@ -20,7 +21,7 @@ use std::fmt; )] #[derivative(Debug = "transparent")] #[serde(transparent)] -pub struct ExecutionBlockHash(pub Hash256); +pub struct ExecutionBlockHash(#[serde(with = "serde_utils::b256_hex")] pub Hash256); impl ExecutionBlockHash { pub fn zero() -> Self { diff --git a/consensus/types/src/execution_block_header.rs b/consensus/types/src/execution_block_header.rs index 2e5a498214c..694162d6ffd 100644 --- a/consensus/types/src/execution_block_header.rs +++ b/consensus/types/src/execution_block_header.rs @@ -74,14 +74,14 @@ impl ExecutionBlockHeader { transactions_root: rlp_transactions_root, receipts_root: payload.receipts_root(), logs_bloom: payload.logs_bloom().clone().into(), - difficulty: Uint256::zero(), - number: payload.block_number().into(), - gas_limit: payload.gas_limit().into(), - gas_used: payload.gas_used().into(), + difficulty: Uint256::ZERO, + number: Uint256::saturating_from(payload.block_number()), + gas_limit: Uint256::saturating_from(payload.gas_limit()), + gas_used: Uint256::saturating_from(payload.gas_used()), timestamp: payload.timestamp(), extra_data: payload.extra_data().clone().into(), mix_hash: payload.prev_randao(), - nonce: Hash64::zero(), + nonce: Hash64::ZERO, base_fee_per_gas: payload.base_fee_per_gas(), withdrawals_root: rlp_withdrawals_root, blob_gas_used: rlp_blob_gas_used, @@ -101,15 +101,15 @@ pub struct EncodableExecutionBlockHeader<'a> { pub transactions_root: &'a [u8], pub receipts_root: &'a [u8], pub logs_bloom: &'a [u8], - pub difficulty: alloy_primitives::U256, - pub number: alloy_primitives::U256, - pub gas_limit: alloy_primitives::U256, - pub gas_used: alloy_primitives::U256, + pub difficulty: Uint256, + pub number: Uint256, + pub gas_limit: Uint256, + pub gas_used: Uint256, pub timestamp: u64, pub extra_data: &'a [u8], pub mix_hash: &'a [u8], pub nonce: &'a [u8], - pub base_fee_per_gas: alloy_primitives::U256, + pub base_fee_per_gas: Uint256, pub withdrawals_root: Option<&'a [u8]>, pub blob_gas_used: Option, pub excess_blob_gas: Option, @@ -119,45 +119,33 @@ pub struct EncodableExecutionBlockHeader<'a> { impl<'a> From<&'a ExecutionBlockHeader> for EncodableExecutionBlockHeader<'a> { fn from(header: &'a ExecutionBlockHeader) -> Self { let mut encodable = Self { - parent_hash: header.parent_hash.as_bytes(), - ommers_hash: header.ommers_hash.as_bytes(), - beneficiary: header.beneficiary.as_bytes(), - state_root: header.state_root.as_bytes(), - transactions_root: header.transactions_root.as_bytes(), - receipts_root: header.receipts_root.as_bytes(), + parent_hash: header.parent_hash.as_slice(), + ommers_hash: header.ommers_hash.as_slice(), + beneficiary: header.beneficiary.as_slice(), + state_root: header.state_root.as_slice(), + transactions_root: header.transactions_root.as_slice(), + receipts_root: header.receipts_root.as_slice(), logs_bloom: header.logs_bloom.as_slice(), - difficulty: U256Shim(header.difficulty).into(), - number: U256Shim(header.number).into(), - gas_limit: U256Shim(header.gas_limit).into(), - gas_used: U256Shim(header.gas_used).into(), + difficulty: header.difficulty, + number: header.number, + gas_limit: header.gas_limit, + gas_used: header.gas_used, timestamp: header.timestamp, extra_data: header.extra_data.as_slice(), - mix_hash: header.mix_hash.as_bytes(), - nonce: header.nonce.as_bytes(), - base_fee_per_gas: U256Shim(header.base_fee_per_gas).into(), + mix_hash: header.mix_hash.as_slice(), + nonce: header.nonce.as_slice(), + base_fee_per_gas: header.base_fee_per_gas, withdrawals_root: None, blob_gas_used: header.blob_gas_used, excess_blob_gas: header.excess_blob_gas, parent_beacon_block_root: None, }; if let Some(withdrawals_root) = &header.withdrawals_root { - encodable.withdrawals_root = Some(withdrawals_root.as_bytes()); + encodable.withdrawals_root = Some(withdrawals_root.as_slice()); } if let Some(parent_beacon_block_root) = &header.parent_beacon_block_root { - encodable.parent_beacon_block_root = Some(parent_beacon_block_root.as_bytes()) + encodable.parent_beacon_block_root = Some(parent_beacon_block_root.as_slice()) } encodable } } - -// TODO(alloy) this shim can be removed once we fully migrate -// from ethereum types to alloy primitives -struct U256Shim(Uint256); - -impl From for alloy_primitives::U256 { - fn from(value: U256Shim) -> Self { - let mut buffer: [u8; 32] = [0; 32]; - value.0.to_little_endian(&mut buffer); - Self::from_le_slice(&buffer) - } -} diff --git a/consensus/types/src/execution_payload.rs b/consensus/types/src/execution_payload.rs index 90940fbb9b9..4d41d568308 100644 --- a/consensus/types/src/execution_payload.rs +++ b/consensus/types/src/execution_payload.rs @@ -57,6 +57,7 @@ pub struct ExecutionPayload { #[superstruct(getter(copy))] pub parent_hash: ExecutionBlockHash, #[superstruct(getter(copy))] + #[serde(with = "serde_utils::address_hex")] pub fee_recipient: Address, #[superstruct(getter(copy))] pub state_root: Hash256, diff --git a/consensus/types/src/execution_payload_header.rs b/consensus/types/src/execution_payload_header.rs index 28bbfb9c048..90dd8c54e21 100644 --- a/consensus/types/src/execution_payload_header.rs +++ b/consensus/types/src/execution_payload_header.rs @@ -47,6 +47,7 @@ pub struct ExecutionPayloadHeader { #[superstruct(getter(copy))] pub parent_hash: ExecutionBlockHash, #[superstruct(getter(copy))] + #[serde(with = "serde_utils::address_hex")] pub fee_recipient: Address, #[superstruct(getter(copy))] pub state_root: Hash256, diff --git a/consensus/types/src/graffiti.rs b/consensus/types/src/graffiti.rs index 3d8f411cafb..08f8573c6d1 100644 --- a/consensus/types/src/graffiti.rs +++ b/consensus/types/src/graffiti.rs @@ -90,7 +90,11 @@ impl From for Graffiti { graffiti .get_mut(..graffiti_len) .expect("graffiti_len <= GRAFFITI_BYTES_LEN") - .copy_from_slice(graffiti_bytes); + .copy_from_slice( + graffiti_bytes + .get(..graffiti_len) + .expect("graffiti_len <= GRAFFITI_BYTES_LEN"), + ); graffiti.into() } } @@ -180,6 +184,6 @@ impl TreeHash for Graffiti { impl TestRandom for Graffiti { fn random_for_test(rng: &mut impl RngCore) -> Self { - Self::from(Hash256::random_for_test(rng).to_fixed_bytes()) + Self::from(Hash256::random_for_test(rng).0) } } diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index 68d48ec7c8b..afc64e86a82 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -109,8 +109,6 @@ pub mod light_client_header; pub mod non_zero_usize; pub mod runtime_var_list; -use ethereum_types::{H160, H256}; - pub use crate::activation_queue::ActivationQueue; pub use crate::aggregate_and_proof::{ AggregateAndProof, AggregateAndProofBase, AggregateAndProofElectra, AggregateAndProofRef, @@ -254,17 +252,18 @@ pub use crate::voluntary_exit::VoluntaryExit; pub use crate::withdrawal::Withdrawal; pub use crate::withdrawal_credentials::WithdrawalCredentials; pub use crate::withdrawal_request::WithdrawalRequest; +pub use fixed_bytes::FixedBytesExtended; pub type CommitteeIndex = u64; -pub type Hash256 = H256; -pub type Uint256 = ethereum_types::U256; -pub type Address = H160; +pub type Hash256 = fixed_bytes::Hash256; +pub type Uint256 = fixed_bytes::Uint256; +pub type Address = fixed_bytes::Address; pub type ForkVersion = [u8; 4]; pub type BLSFieldElement = Uint256; pub type Blob = FixedVector::BytesPerBlob>; pub type KzgProofs = VariableList::MaxBlobCommitmentsPerBlock>; pub type VersionedHash = Hash256; -pub type Hash64 = ethereum_types::H64; +pub type Hash64 = alloy_primitives::B64; pub use bls::{ AggregatePublicKey, AggregateSignature, Keypair, PublicKey, PublicKeyBytes, SecretKey, diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index a1d5f85eac0..c0de114b357 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -130,8 +130,8 @@ impl LightClientHeader { pub fn ssz_max_var_len_for_fork(fork_name: ForkName) -> usize { match fork_name { - ForkName::Base | ForkName::Altair | ForkName::Bellatrix => 0, - ForkName::Capella | ForkName::Deneb | ForkName::Electra => { + ForkName::Base | ForkName::Altair => 0, + ForkName::Bellatrix | ForkName::Capella | ForkName::Deneb | ForkName::Electra => { ExecutionPayloadHeader::::ssz_max_var_len_for_fork(fork_name) } } diff --git a/consensus/types/src/proposer_preparation_data.rs b/consensus/types/src/proposer_preparation_data.rs index 2828b0d4d55..477fb3b9d15 100644 --- a/consensus/types/src/proposer_preparation_data.rs +++ b/consensus/types/src/proposer_preparation_data.rs @@ -9,5 +9,6 @@ pub struct ProposerPreparationData { #[serde(with = "serde_utils::quoted_u64")] pub validator_index: u64, /// The fee-recipient address. + #[serde(with = "serde_utils::address_hex")] pub fee_recipient: Address, } diff --git a/consensus/types/src/runtime_var_list.rs b/consensus/types/src/runtime_var_list.rs index aa43e3fe759..2bca5df2d9e 100644 --- a/consensus/types/src/runtime_var_list.rs +++ b/consensus/types/src/runtime_var_list.rs @@ -298,6 +298,15 @@ impl std::ops::DerefMut for RuntimeFixedList { } } +impl IntoIterator for RuntimeFixedList { + type Item = T; + type IntoIter = std::vec::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.vec.into_iter() + } +} + impl<'a, T> IntoIterator for &'a RuntimeFixedList { type Item = &'a T; type IntoIter = std::slice::Iter<'a, T>; diff --git a/consensus/types/src/subnet_id.rs b/consensus/types/src/subnet_id.rs index b2a6b6a2a00..9bfe6fb261c 100644 --- a/consensus/types/src/subnet_id.rs +++ b/consensus/types/src/subnet_id.rs @@ -1,5 +1,6 @@ //! Identifies each shard by an integer identifier. use crate::{AttestationRef, ChainSpec, CommitteeIndex, Epoch, EthSpec, Slot}; +use alloy_primitives::{bytes::Buf, U256}; use safe_arith::{ArithError, SafeArith}; use serde::{Deserialize, Serialize}; use std::ops::{Deref, DerefMut}; @@ -77,7 +78,7 @@ impl SubnetId { /// along with the first epoch in which these subscriptions are no longer valid. #[allow(clippy::arithmetic_side_effects)] pub fn compute_subnets_for_epoch( - node_id: ethereum_types::U256, + raw_node_id: [u8; 32], epoch: Epoch, spec: &ChainSpec, ) -> Result<(impl Iterator, Epoch), &'static str> { @@ -85,10 +86,13 @@ impl SubnetId { let subscription_duration = spec.epochs_per_subnet_subscription; let prefix_bits = spec.attestation_subnet_prefix_bits as u64; let shuffling_prefix_bits = spec.attestation_subnet_shuffling_prefix_bits as u64; + let node_id = U256::from_be_slice(&raw_node_id); // calculate the prefixes used to compute the subnet and shuffling - let node_id_prefix = (node_id >> (256 - prefix_bits)).as_u64(); - let shuffling_prefix = (node_id >> (256 - (prefix_bits + shuffling_prefix_bits))).as_u64(); + let node_id_prefix = (node_id >> (256 - prefix_bits)).as_le_slice().get_u64_le(); + let shuffling_prefix = (node_id >> (256 - (prefix_bits + shuffling_prefix_bits))) + .as_le_slice() + .get_u64_le(); // number of groups the shuffling creates let shuffling_groups = 1 << shuffling_prefix_bits; @@ -170,6 +174,8 @@ impl AsRef for SubnetId { #[cfg(test)] mod tests { + use crate::Uint256; + use super::*; /// A set of tests compared to the python specification @@ -188,7 +194,7 @@ mod tests { "60930578857433095740782970114409273483106482059893286066493409689627770333527", "103822458477361691467064888613019442068586830412598673713899771287914656699997", ] - .map(|v| ethereum_types::U256::from_dec_str(v).unwrap()); + .map(|v| Uint256::from_str_radix(v, 10).unwrap().to_be_bytes::<32>()); let epochs = [ 54321u64, 1017090249, 1827566880, 846255942, 766597383, 1204990115, 1616209495, @@ -222,7 +228,7 @@ mod tests { for x in 0..node_ids.len() { println!("Test: {}", x); println!( - "NodeId: {}\n Epoch: {}\n, expected_update_time: {}\n, expected_subnets: {:?}", + "NodeId: {:?}\n Epoch: {}\n, expected_update_time: {}\n, expected_subnets: {:?}", node_ids[x], epochs[x], expected_valid_time[x], expected_subnets[x] ); diff --git a/consensus/types/src/sync_selection_proof.rs b/consensus/types/src/sync_selection_proof.rs index 0b32c6981b6..4adb90b26e2 100644 --- a/consensus/types/src/sync_selection_proof.rs +++ b/consensus/types/src/sync_selection_proof.rs @@ -105,7 +105,7 @@ impl From for SyncSelectionProof { #[cfg(test)] mod test { use super::*; - use crate::MainnetEthSpec; + use crate::{FixedBytesExtended, MainnetEthSpec}; use eth2_interop_keypairs::keypair; #[test] diff --git a/consensus/types/src/test_utils/test_random/uint256.rs b/consensus/types/src/test_utils/test_random/uint256.rs index 5eccc0a9fa5..30077f0e0f6 100644 --- a/consensus/types/src/test_utils/test_random/uint256.rs +++ b/consensus/types/src/test_utils/test_random/uint256.rs @@ -4,6 +4,6 @@ impl TestRandom for Uint256 { fn random_for_test(rng: &mut impl RngCore) -> Self { let mut key_bytes = [0; 32]; rng.fill_bytes(&mut key_bytes); - Self::from_little_endian(&key_bytes[..]) + Self::from_le_slice(&key_bytes[..]) } } diff --git a/consensus/types/src/validator.rs b/consensus/types/src/validator.rs index 4173e18526e..3c6037e23e3 100644 --- a/consensus/types/src/validator.rs +++ b/consensus/types/src/validator.rs @@ -1,6 +1,6 @@ use crate::{ - test_utils::TestRandom, Address, BeaconState, ChainSpec, Checkpoint, Epoch, EthSpec, ForkName, - Hash256, PublicKeyBytes, + test_utils::TestRandom, Address, BeaconState, ChainSpec, Checkpoint, Epoch, EthSpec, + FixedBytesExtended, ForkName, Hash256, PublicKeyBytes, }; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; @@ -129,7 +129,7 @@ impl Validator { /// Returns `true` if the validator has eth1 withdrawal credential. pub fn has_eth1_withdrawal_credential(&self, spec: &ChainSpec) -> bool { self.withdrawal_credentials - .as_bytes() + .as_slice() .first() .map(|byte| *byte == spec.eth1_address_withdrawal_prefix_byte) .unwrap_or(false) @@ -145,7 +145,7 @@ impl Validator { self.has_execution_withdrawal_credential(spec) .then(|| { self.withdrawal_credentials - .as_bytes() + .as_slice() .get(12..) .map(Address::from_slice) }) @@ -158,7 +158,7 @@ impl Validator { pub fn change_withdrawal_credentials(&mut self, execution_address: &Address, spec: &ChainSpec) { let mut bytes = [0u8; 32]; bytes[0] = spec.eth1_address_withdrawal_prefix_byte; - bytes[12..].copy_from_slice(execution_address.as_bytes()); + bytes[12..].copy_from_slice(execution_address.as_slice()); self.withdrawal_credentials = Hash256::from(bytes); } @@ -283,7 +283,7 @@ impl Default for Validator { fn default() -> Self { Self { pubkey: PublicKeyBytes::empty(), - withdrawal_credentials: Hash256::default(), + withdrawal_credentials: Hash256::zero(), activation_eligibility_epoch: Epoch::from(u64::MAX), activation_epoch: Epoch::from(u64::MAX), exit_epoch: Epoch::from(u64::MAX), @@ -299,7 +299,7 @@ pub fn is_compounding_withdrawal_credential( spec: &ChainSpec, ) -> bool { withdrawal_credentials - .as_bytes() + .as_slice() .first() .map(|prefix_byte| *prefix_byte == spec.compounding_withdrawal_prefix_byte) .unwrap_or(false) diff --git a/consensus/types/src/validator_registration_data.rs b/consensus/types/src/validator_registration_data.rs index 174014df8ec..cdafd355e7c 100644 --- a/consensus/types/src/validator_registration_data.rs +++ b/consensus/types/src/validator_registration_data.rs @@ -12,6 +12,7 @@ pub struct SignedValidatorRegistrationData { #[derive(PartialEq, Debug, Serialize, Deserialize, Clone, Encode, Decode, TreeHash)] pub struct ValidatorRegistrationData { + #[serde(with = "serde_utils::address_hex")] pub fee_recipient: Address, #[serde(with = "serde_utils::quoted_u64")] pub gas_limit: u64, diff --git a/consensus/types/src/withdrawal.rs b/consensus/types/src/withdrawal.rs index 3e611565541..7f98ff1e60a 100644 --- a/consensus/types/src/withdrawal.rs +++ b/consensus/types/src/withdrawal.rs @@ -24,6 +24,7 @@ pub struct Withdrawal { pub index: u64, #[serde(with = "serde_utils::quoted_u64")] pub validator_index: u64, + #[serde(with = "serde_utils::address_hex")] pub address: Address, #[serde(with = "serde_utils::quoted_u64")] pub amount: u64, diff --git a/consensus/types/src/withdrawal_credentials.rs b/consensus/types/src/withdrawal_credentials.rs index 8d42d4eafd4..52d51ed559c 100644 --- a/consensus/types/src/withdrawal_credentials.rs +++ b/consensus/types/src/withdrawal_credentials.rs @@ -13,7 +13,7 @@ impl WithdrawalCredentials { pub fn eth1(withdrawal_address: Address, spec: &ChainSpec) -> Self { let mut withdrawal_credentials = [0; 32]; withdrawal_credentials[0] = spec.eth1_address_withdrawal_prefix_byte; - withdrawal_credentials[12..].copy_from_slice(withdrawal_address.as_bytes()); + withdrawal_credentials[12..].copy_from_slice(withdrawal_address.as_slice()); Self(Hash256::from_slice(&withdrawal_credentials)) } } @@ -39,7 +39,7 @@ mod test { get_withdrawal_credentials(&keypair.pk, spec.bls_withdrawal_prefix_byte); let hash: Hash256 = credentials.into(); assert_eq!(hash[0], spec.bls_withdrawal_prefix_byte); - assert_eq!(hash.as_bytes(), &manually_generated_credentials); + assert_eq!(hash.as_slice(), &manually_generated_credentials); } #[test] diff --git a/consensus/types/src/withdrawal_request.rs b/consensus/types/src/withdrawal_request.rs index 2f69e9b1504..b6db0efb26d 100644 --- a/consensus/types/src/withdrawal_request.rs +++ b/consensus/types/src/withdrawal_request.rs @@ -20,6 +20,7 @@ use tree_hash_derive::TreeHash; TestRandom, )] pub struct WithdrawalRequest { + #[serde(with = "serde_utils::address_hex")] pub source_address: Address, pub validator_pubkey: PublicKeyBytes, #[serde(with = "serde_utils::quoted_u64")] diff --git a/crypto/bls/Cargo.toml b/crypto/bls/Cargo.toml index 7aa8e02dcab..b65b51230c3 100644 --- a/crypto/bls/Cargo.toml +++ b/crypto/bls/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Paul Hauner "] edition = { workspace = true } [dependencies] +alloy-primitives = { workspace = true } ethereum_ssz = { workspace = true } tree_hash = { workspace = true } rand = { workspace = true } @@ -12,10 +13,11 @@ serde = { workspace = true } ethereum_serde_utils = { workspace = true } hex = { workspace = true } ethereum_hashing = { workspace = true } -ethereum-types = { workspace = true } arbitrary = { workspace = true } zeroize = { workspace = true } blst = { version = "0.3.3", optional = true } +safe_arith = { workspace = true } +fixed_bytes = { workspace = true } [features] arbitrary = [] diff --git a/crypto/bls/src/impls/blst.rs b/crypto/bls/src/impls/blst.rs index 54c7ad2944e..baa704e05a9 100644 --- a/crypto/bls/src/impls/blst.rs +++ b/crypto/bls/src/impls/blst.rs @@ -68,7 +68,7 @@ pub fn verify_signature_sets<'a>( } // Grab a slice of the message, to satisfy the blst API. - msgs_refs.push(set.message.as_bytes()); + msgs_refs.push(set.message.as_slice()); if let Some(point) = set.signature.point() { // Subgroup check the signature @@ -196,7 +196,7 @@ impl TSignature for blst_core::Signature { fn verify(&self, pubkey: &blst_core::PublicKey, msg: Hash256) -> bool { // Public keys have already been checked for subgroup and infinity // Check Signature inside function for subgroup - self.verify(true, msg.as_bytes(), DST, &[], pubkey, false) == BLST_ERROR::BLST_SUCCESS + self.verify(true, msg.as_slice(), DST, &[], pubkey, false) == BLST_ERROR::BLST_SUCCESS } } @@ -256,7 +256,7 @@ impl TAggregateSignature], ) -> bool { let pubkeys = pubkeys.iter().map(|pk| pk.point()).collect::>(); - let msgs = msgs.iter().map(|hash| hash.as_bytes()).collect::>(); + let msgs = msgs.iter().map(|hash| hash.as_slice()).collect::>(); let signature = self.0.clone().to_signature(); // Public keys have already been checked for subgroup and infinity // Check Signature inside function for subgroup @@ -287,7 +287,7 @@ impl TSecretKey for blst_core::Secre } fn sign(&self, msg: Hash256) -> blst_core::Signature { - self.sign(msg.as_bytes(), DST, &[]) + self.sign(msg.as_slice(), DST, &[]) } fn serialize(&self) -> ZeroizeHash { diff --git a/crypto/bls/src/lib.rs b/crypto/bls/src/lib.rs index af269b943d7..6ea85548c0d 100644 --- a/crypto/bls/src/lib.rs +++ b/crypto/bls/src/lib.rs @@ -44,7 +44,8 @@ pub use zeroize_hash::ZeroizeHash; #[cfg(feature = "supranational")] use blst::BLST_ERROR as BlstError; -pub type Hash256 = ethereum_types::H256; +pub type Hash256 = fixed_bytes::Hash256; +pub use fixed_bytes::FixedBytesExtended; #[derive(Clone, Debug, PartialEq)] pub enum Error { diff --git a/crypto/bls/tests/tests.rs b/crypto/bls/tests/tests.rs index dac2e97f407..26215771b5f 100644 --- a/crypto/bls/tests/tests.rs +++ b/crypto/bls/tests/tests.rs @@ -1,4 +1,4 @@ -use bls::{Hash256, INFINITY_SIGNATURE, SECRET_KEY_BYTES_LEN}; +use bls::{FixedBytesExtended, Hash256, INFINITY_SIGNATURE, SECRET_KEY_BYTES_LEN}; use ssz::{Decode, Encode}; use std::borrow::Cow; use std::fmt::Debug; diff --git a/lcli/src/generate_bootnode_enr.rs b/lcli/src/generate_bootnode_enr.rs index 26e17ba73ee..e1acac12dfe 100644 --- a/lcli/src/generate_bootnode_enr.rs +++ b/lcli/src/generate_bootnode_enr.rs @@ -8,7 +8,7 @@ use std::io::Write; use std::path::PathBuf; use std::{fs, net::Ipv4Addr}; use std::{fs::File, num::NonZeroU16}; -use types::{ChainSpec, EnrForkId, Epoch, EthSpec, Hash256}; +use types::{ChainSpec, EnrForkId, Epoch, EthSpec, FixedBytesExtended, Hash256}; pub fn run(matches: &ArgMatches, spec: &ChainSpec) -> Result<(), String> { let ip: Ipv4Addr = clap_utils::parse_required(matches, "ip")?; diff --git a/scripts/local_testnet/network_params_das_local.yaml b/scripts/local_testnet/network_params_das.yaml similarity index 81% rename from scripts/local_testnet/network_params_das_local.yaml rename to scripts/local_testnet/network_params_das.yaml index d1b646a34a3..ab2f07a24ec 100644 --- a/scripts/local_testnet/network_params_das_local.yaml +++ b/scripts/local_testnet/network_params_das.yaml @@ -3,13 +3,13 @@ participants: cl_image: lighthouse:local cl_extra_params: - --subscribe-all-data-column-subnets - - --target-peers=2 + - --target-peers=3 count: 2 - cl_type: lighthouse cl_image: lighthouse:local cl_extra_params: - - --target-peers=2 - count: 1 + - --target-peers=3 + count: 2 network_params: eip7594_fork_epoch: 0 seconds_per_slot: 6 @@ -18,3 +18,4 @@ global_log_level: debug additional_services: - dora - goomy_blob + - prometheus_grafana diff --git a/scripts/local_testnet/network_params_das_devnet_1.yaml b/scripts/local_testnet/network_params_das_devnet_1.yaml deleted file mode 100644 index fcd131a06ca..00000000000 --- a/scripts/local_testnet/network_params_das_devnet_1.yaml +++ /dev/null @@ -1,8 +0,0 @@ -participants: - - cl_type: lighthouse - cl_image: lighthouse:local -network_params: - network: peerdas-devnet-1 -global_log_level: debug -additional_services: - - prometheus_grafana \ No newline at end of file diff --git a/scripts/local_testnet/network_params_das_interop.yaml b/scripts/local_testnet/network_params_das_interop.yaml deleted file mode 100644 index 0c8f9d7f49d..00000000000 --- a/scripts/local_testnet/network_params_das_interop.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# Full configuration reference [here](https://github.com/ethpandaops/ethereum-package?tab=readme-ov-file#configuration). -participants: - - cl_type: prysm - cl_image: ethpandaops/prysm-beacon-chain:peerDAS - - - cl_type: lighthouse - cl_extra_params: [ - --subscribe-all-data-column-subnets, - ] - cl_image: lighthouse:local - - - cl_type: lighthouse - cl_image: lighthouse:local - - - cl_type: teku - cl_image: ethpandaops/teku:nashatyrev-das - -# - cl_type: nimbus -# cl_image: ethpandaops/nimbus-eth2:kzgpeerdas -# -# - cl_type: grandine -# cl_image: ethpandaops/grandine:das -# -# - cl_type: lodestar -# cl_image: ethpandaops/lodestar:peerDAS -network_params: - eip7594_fork_epoch: 0 - eip7594_fork_version: "0x50000038" - data_column_sidecar_subnet_count: 128 - samples_per_slot: 16 - custody_requirement: 4 -snooper_enabled: false -global_log_level: debug -ethereum_metrics_exporter_enabled: true -additional_services: - - dora - - goomy_blob - - prometheus_grafana diff --git a/scripts/local_testnet/start_local_testnet.sh b/scripts/local_testnet/start_local_testnet.sh index 330df76d813..f90132764e4 100755 --- a/scripts/local_testnet/start_local_testnet.sh +++ b/scripts/local_testnet/start_local_testnet.sh @@ -7,6 +7,7 @@ set -Eeuo pipefail SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" ENCLAVE_NAME=local-testnet NETWORK_PARAMS_FILE=$SCRIPT_DIR/network_params.yaml +ETHEREUM_PKG_VERSION=4.2.0 BUILD_IMAGE=true BUILDER_PROPOSALS=false @@ -80,6 +81,6 @@ if [ "$KEEP_ENCLAVE" = false ]; then kurtosis enclave rm -f $ENCLAVE_NAME 2>/dev/null || true fi -kurtosis run --enclave $ENCLAVE_NAME github.com/ethpandaops/ethereum-package --args-file $NETWORK_PARAMS_FILE +kurtosis run --enclave $ENCLAVE_NAME github.com/ethpandaops/ethereum-package@$ETHEREUM_PKG_VERSION --args-file $NETWORK_PARAMS_FILE echo "Started!" diff --git a/slasher/src/database.rs b/slasher/src/database.rs index b5d7ab5ce80..20b4a337711 100644 --- a/slasher/src/database.rs +++ b/slasher/src/database.rs @@ -174,7 +174,7 @@ impl IndexedAttestationIdKey { let mut data = [0; INDEXED_ATTESTATION_ID_KEY_SIZE]; data[0..8].copy_from_slice(&target_epoch.as_u64().to_be_bytes()); data[8..INDEXED_ATTESTATION_ID_KEY_SIZE] - .copy_from_slice(indexed_attestation_root.as_bytes()); + .copy_from_slice(indexed_attestation_root.as_slice()); Self { target_and_root: data, } diff --git a/slasher/src/test_utils.rs b/slasher/src/test_utils.rs index 453d0e66670..8054c0ad59a 100644 --- a/slasher/src/test_utils.rs +++ b/slasher/src/test_utils.rs @@ -3,8 +3,9 @@ use std::sync::Arc; use types::{ indexed_attestation::{IndexedAttestationBase, IndexedAttestationElectra}, AggregateSignature, AttestationData, AttesterSlashing, AttesterSlashingBase, - AttesterSlashingElectra, BeaconBlockHeader, ChainSpec, Checkpoint, Epoch, EthSpec, Hash256, - IndexedAttestation, MainnetEthSpec, Signature, SignedBeaconBlockHeader, Slot, + AttesterSlashingElectra, BeaconBlockHeader, ChainSpec, Checkpoint, Epoch, EthSpec, + FixedBytesExtended, Hash256, IndexedAttestation, MainnetEthSpec, Signature, + SignedBeaconBlockHeader, Slot, }; pub type E = MainnetEthSpec; diff --git a/testing/ef_tests/Cargo.toml b/testing/ef_tests/Cargo.toml index fc4614f5d45..6012283e111 100644 --- a/testing/ef_tests/Cargo.toml +++ b/testing/ef_tests/Cargo.toml @@ -11,11 +11,11 @@ fake_crypto = ["bls/fake_crypto"] portable = ["beacon_chain/portable"] [dependencies] +alloy-primitives = { workspace = true } bls = { workspace = true } compare_fields = { workspace = true } compare_fields_derive = { workspace = true } derivative = { workspace = true } -ethereum-types = { workspace = true } hex = { workspace = true } kzg = { workspace = true } rayon = { workspace = true } diff --git a/testing/ef_tests/src/cases/common.rs b/testing/ef_tests/src/cases/common.rs index 8b253919805..e16f5b257f9 100644 --- a/testing/ef_tests/src/cases/common.rs +++ b/testing/ef_tests/src/cases/common.rs @@ -17,7 +17,7 @@ macro_rules! uint_wrapper { type Error = String; fn try_from(s: String) -> Result { - <$wrapped_type>::from_dec_str(&s) + <$wrapped_type>::from_str_radix(&s, 10) .map(|x| Self { x }) .map_err(|e| format!("{:?}", e)) } @@ -43,8 +43,8 @@ macro_rules! uint_wrapper { }; } -uint_wrapper!(TestU128, ethereum_types::U128); -uint_wrapper!(TestU256, ethereum_types::U256); +uint_wrapper!(DecimalU128, alloy_primitives::U128); +uint_wrapper!(DecimalU256, alloy_primitives::U256); /// Trait for types that can be used in SSZ static tests. pub trait SszStaticType: diff --git a/testing/ef_tests/src/cases/get_custody_columns.rs b/testing/ef_tests/src/cases/get_custody_columns.rs index efe5b147e44..d31e72a473d 100644 --- a/testing/ef_tests/src/cases/get_custody_columns.rs +++ b/testing/ef_tests/src/cases/get_custody_columns.rs @@ -1,5 +1,5 @@ use super::*; -use ethereum_types::U256; +use alloy_primitives::U256; use serde::Deserialize; use std::marker::PhantomData; use types::DataColumnSubnetId; @@ -23,10 +23,11 @@ impl LoadCase for GetCustodyColumns { impl Case for GetCustodyColumns { fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> { let spec = E::default_spec(); - let node_id = U256::from_dec_str(&self.node_id) + let node_id = U256::from_str_radix(&self.node_id, 10) .map_err(|e| Error::FailedToParseTest(format!("{e:?}")))?; + let raw_node_id = node_id.to_be_bytes::<32>(); let computed = DataColumnSubnetId::compute_custody_columns::( - node_id, + raw_node_id, self.custody_subnet_count, &spec, ) diff --git a/testing/ef_tests/src/cases/ssz_generic.rs b/testing/ef_tests/src/cases/ssz_generic.rs index 7933fc65c70..3dc2f179684 100644 --- a/testing/ef_tests/src/cases/ssz_generic.rs +++ b/testing/ef_tests/src/cases/ssz_generic.rs @@ -1,7 +1,7 @@ #![allow(non_snake_case)] use super::*; -use crate::cases::common::{SszStaticType, TestU128, TestU256}; +use crate::cases::common::{DecimalU128, DecimalU256, SszStaticType}; use crate::cases::ssz_static::{check_serialization, check_tree_hash}; use crate::decode::{log_file_access, snappy_decode_file, yaml_decode_file}; use serde::{de::Error as SerdeError, Deserialize, Deserializer}; @@ -56,8 +56,8 @@ macro_rules! type_dispatch { "uint16" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* u16>, $($rest)*), "uint32" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* u32>, $($rest)*), "uint64" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* u64>, $($rest)*), - "uint128" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* TestU128>, $($rest)*), - "uint256" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* TestU256>, $($rest)*), + "uint128" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* DecimalU128>, $($rest)*), + "uint256" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* DecimalU256>, $($rest)*), _ => Err(Error::FailedToParseTest(format!("unsupported: {}", $value))), } }; @@ -231,7 +231,7 @@ fn ssz_generic_test(path: &Path) -> R check_serialization(&value, &serialized, T::from_ssz_bytes)?; if let Some(ref meta) = meta { - check_tree_hash(&meta.root, value.tree_hash_root().as_bytes())?; + check_tree_hash(&meta.root, value.tree_hash_root().as_slice())?; } } // Invalid diff --git a/testing/ef_tests/src/cases/ssz_static.rs b/testing/ef_tests/src/cases/ssz_static.rs index e17aa469bfc..c80977a8ac7 100644 --- a/testing/ef_tests/src/cases/ssz_static.rs +++ b/testing/ef_tests/src/cases/ssz_static.rs @@ -104,7 +104,7 @@ pub fn check_tree_hash(expected_str: &str, actual_root: &[u8]) -> Result<(), Err impl Case for SszStatic { fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> { check_serialization(&self.value, &self.serialized, T::from_ssz_bytes)?; - check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?; + check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_slice())?; Ok(()) } } @@ -118,7 +118,7 @@ impl Case for SszStaticTHC> { let mut state = self.value.clone(); let cached_tree_hash_root = state.update_tree_hash_cache().unwrap(); - check_tree_hash(&self.roots.root, cached_tree_hash_root.as_bytes())?; + check_tree_hash(&self.roots.root, cached_tree_hash_root.as_slice())?; Ok(()) } @@ -130,7 +130,7 @@ impl Case for SszStaticWithSpec> { check_serialization(&self.value, &self.serialized, |bytes| { BeaconBlock::from_ssz_bytes(bytes, spec) })?; - check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?; + check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_slice())?; Ok(()) } } @@ -141,7 +141,7 @@ impl Case for SszStaticWithSpec> { check_serialization(&self.value, &self.serialized, |bytes| { SignedBeaconBlock::from_ssz_bytes(bytes, spec) })?; - check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?; + check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_slice())?; Ok(()) } } diff --git a/testing/eth1_test_rig/src/lib.rs b/testing/eth1_test_rig/src/lib.rs index 55a71605940..015a632ff40 100644 --- a/testing/eth1_test_rig/src/lib.rs +++ b/testing/eth1_test_rig/src/lib.rs @@ -19,8 +19,8 @@ use ethers_core::{ pub use ethers_providers::{Http, Middleware, Provider}; use std::time::Duration; use tokio::time::sleep; -use types::DepositData; use types::{test_utils::generate_deterministic_keypair, EthSpec, Hash256, Keypair, Signature}; +use types::{DepositData, FixedBytesExtended}; pub const DEPLOYER_ACCOUNTS_INDEX: usize = 0; pub const DEPOSIT_ACCOUNTS_INDEX: usize = 0; diff --git a/testing/execution_engine_integration/Cargo.toml b/testing/execution_engine_integration/Cargo.toml index 43d24cd1237..159561d5dd8 100644 --- a/testing/execution_engine_integration/Cargo.toml +++ b/testing/execution_engine_integration/Cargo.toml @@ -14,8 +14,8 @@ execution_layer = { workspace = true } sensitive_url = { workspace = true } types = { workspace = true } unused_port = { workspace = true } -ethers-core = { workspace = true } ethers-providers = { workspace = true } +ethers-core = { workspace = true } deposit_contract = { workspace = true } reqwest = { workspace = true } hex = { workspace = true } diff --git a/testing/execution_engine_integration/src/test_rig.rs b/testing/execution_engine_integration/src/test_rig.rs index c7d5e704524..f3f5a72cb60 100644 --- a/testing/execution_engine_integration/src/test_rig.rs +++ b/testing/execution_engine_integration/src/test_rig.rs @@ -18,7 +18,7 @@ use tokio::time::sleep; use types::payload::BlockProductionVersion; use types::{ Address, ChainSpec, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadHeader, - ForkName, Hash256, MainnetEthSpec, PublicKeyBytes, Slot, Uint256, + FixedBytesExtended, ForkName, Hash256, MainnetEthSpec, PublicKeyBytes, Slot, Uint256, }; const EXECUTION_ENGINE_START_TIMEOUT: Duration = Duration::from_secs(60); @@ -115,7 +115,7 @@ impl TestRig { let (shutdown_tx, _) = futures::channel::mpsc::channel(1); let executor = TaskExecutor::new(Arc::downgrade(&runtime), exit, log.clone(), shutdown_tx); let mut spec = TEST_FORK.make_genesis_spec(MainnetEthSpec::default_spec()); - spec.terminal_total_difficulty = Uint256::zero(); + spec.terminal_total_difficulty = Uint256::ZERO; let fee_recipient = None; diff --git a/testing/execution_engine_integration/src/transactions.rs b/testing/execution_engine_integration/src/transactions.rs index 62b77d5024b..fd458ad205d 100644 --- a/testing/execution_engine_integration/src/transactions.rs +++ b/testing/execution_engine_integration/src/transactions.rs @@ -3,7 +3,7 @@ use ethers_core::types::{ transaction::{eip2718::TypedTransaction, eip2930::AccessList}, Address, Bytes, Eip1559TransactionRequest, TransactionRequest, U256, }; -use types::{DepositData, EthSpec, Hash256, Keypair, Signature}; +use types::{DepositData, EthSpec, FixedBytesExtended, Hash256, Keypair, Signature}; /// Hardcoded deposit contract address based on sender address and nonce pub const DEPOSIT_CONTRACT_ADDRESS: &str = "64f43BEc7F86526686C931d65362bB8698872F90"; diff --git a/testing/state_transition_vectors/src/main.rs b/testing/state_transition_vectors/src/main.rs index 58637b92d9e..7f0f697d61d 100644 --- a/testing/state_transition_vectors/src/main.rs +++ b/testing/state_transition_vectors/src/main.rs @@ -13,7 +13,7 @@ use std::sync::LazyLock; use types::{ test_utils::generate_deterministic_keypairs, BeaconState, EthSpec, Keypair, SignedBeaconBlock, }; -use types::{Hash256, MainnetEthSpec, Slot}; +use types::{FixedBytesExtended, Hash256, MainnetEthSpec, Slot}; type E = MainnetEthSpec; diff --git a/validator_client/slashing_protection/src/attestation_tests.rs b/validator_client/slashing_protection/src/attestation_tests.rs index a162c4e150e..b577ccd9d85 100644 --- a/validator_client/slashing_protection/src/attestation_tests.rs +++ b/validator_client/slashing_protection/src/attestation_tests.rs @@ -2,7 +2,7 @@ use crate::test_utils::*; use crate::*; -use types::{AttestationData, Checkpoint, Epoch, Slot}; +use types::{AttestationData, Checkpoint, Epoch, FixedBytesExtended, Slot}; pub fn build_checkpoint(epoch_num: u64) -> Checkpoint { Checkpoint { diff --git a/validator_client/slashing_protection/src/bin/test_generator.rs b/validator_client/slashing_protection/src/bin/test_generator.rs index c95cb6917c5..ff5866f9866 100644 --- a/validator_client/slashing_protection/src/bin/test_generator.rs +++ b/validator_client/slashing_protection/src/bin/test_generator.rs @@ -7,7 +7,7 @@ use slashing_protection::SUPPORTED_INTERCHANGE_FORMAT_VERSION; use std::fs::{self, File}; use std::io::Write; use std::path::Path; -use types::{Epoch, Hash256, Slot}; +use types::{Epoch, FixedBytesExtended, Hash256, Slot}; fn metadata(genesis_validators_root: Hash256) -> InterchangeMetadata { InterchangeMetadata { diff --git a/validator_client/slashing_protection/src/block_tests.rs b/validator_client/slashing_protection/src/block_tests.rs index abd452a0b67..b3273015f42 100644 --- a/validator_client/slashing_protection/src/block_tests.rs +++ b/validator_client/slashing_protection/src/block_tests.rs @@ -2,7 +2,7 @@ use super::*; use crate::test_utils::*; -use types::{BeaconBlockHeader, Slot}; +use types::{BeaconBlockHeader, FixedBytesExtended, Slot}; pub fn block(slot: u64) -> BeaconBlockHeader { BeaconBlockHeader { diff --git a/validator_client/slashing_protection/src/extra_interchange_tests.rs b/validator_client/slashing_protection/src/extra_interchange_tests.rs index dd1c1882158..0f88ec8b1dc 100644 --- a/validator_client/slashing_protection/src/extra_interchange_tests.rs +++ b/validator_client/slashing_protection/src/extra_interchange_tests.rs @@ -3,6 +3,7 @@ use crate::test_utils::pubkey; use crate::*; use tempfile::tempdir; +use types::FixedBytesExtended; #[test] fn export_non_existent_key() { diff --git a/validator_client/slashing_protection/src/interchange_test.rs b/validator_client/slashing_protection/src/interchange_test.rs index d99647bc936..e1ac841905f 100644 --- a/validator_client/slashing_protection/src/interchange_test.rs +++ b/validator_client/slashing_protection/src/interchange_test.rs @@ -6,7 +6,7 @@ use crate::{ use serde::{Deserialize, Serialize}; use std::collections::HashSet; use tempfile::tempdir; -use types::{Epoch, Hash256, PublicKeyBytes, Slot}; +use types::{Epoch, FixedBytesExtended, Hash256, PublicKeyBytes, Slot}; #[derive(Debug, Clone, Deserialize, Serialize)] #[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] diff --git a/validator_client/slashing_protection/src/lib.rs b/validator_client/slashing_protection/src/lib.rs index e5606d4042a..51dd3e31642 100644 --- a/validator_client/slashing_protection/src/lib.rs +++ b/validator_client/slashing_protection/src/lib.rs @@ -130,6 +130,8 @@ impl Display for NotSafe { #[cfg(test)] mod test { + use types::FixedBytesExtended; + use super::*; #[test] diff --git a/validator_client/slashing_protection/src/slashing_database.rs b/validator_client/slashing_protection/src/slashing_database.rs index 04554786f6f..baaf930c68b 100644 --- a/validator_client/slashing_protection/src/slashing_database.rs +++ b/validator_client/slashing_protection/src/slashing_database.rs @@ -513,7 +513,7 @@ impl SlashingDatabase { txn.execute( "INSERT INTO signed_blocks (validator_id, slot, signing_root) VALUES (?1, ?2, ?3)", - params![validator_id, slot, signing_root.to_hash256_raw().as_bytes()], + params![validator_id, slot, signing_root.to_hash256_raw().as_slice()], )?; Ok(()) } @@ -539,7 +539,7 @@ impl SlashingDatabase { validator_id, att_source_epoch, att_target_epoch, - att_signing_root.to_hash256_raw().as_bytes() + att_signing_root.to_hash256_raw().as_slice() ], )?; Ok(()) diff --git a/validator_client/slashing_protection/src/test_utils.rs b/validator_client/slashing_protection/src/test_utils.rs index efdeb9bc6ba..8cbca12a10b 100644 --- a/validator_client/slashing_protection/src/test_utils.rs +++ b/validator_client/slashing_protection/src/test_utils.rs @@ -3,8 +3,8 @@ use tempfile::{tempdir, TempDir}; use types::{test_utils::generate_deterministic_keypair, AttestationData, BeaconBlockHeader}; pub const DEFAULT_VALIDATOR_INDEX: usize = 0; -pub const DEFAULT_DOMAIN: Hash256 = Hash256::zero(); -pub const DEFAULT_GENESIS_VALIDATORS_ROOT: Hash256 = Hash256::zero(); +pub const DEFAULT_DOMAIN: Hash256 = Hash256::ZERO; +pub const DEFAULT_GENESIS_VALIDATORS_ROOT: Hash256 = Hash256::ZERO; pub fn pubkey(index: usize) -> PublicKeyBytes { generate_deterministic_keypair(index).pk.compress() diff --git a/validator_client/slashing_protection/tests/migration.rs b/validator_client/slashing_protection/tests/migration.rs index cd3561f2114..3d4ec7ea9a8 100644 --- a/validator_client/slashing_protection/tests/migration.rs +++ b/validator_client/slashing_protection/tests/migration.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use std::fs; use std::path::{Path, PathBuf}; use tempfile::tempdir; -use types::Hash256; +use types::{FixedBytesExtended, Hash256}; fn test_data_dir() -> PathBuf { Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("migration-tests") diff --git a/validator_manager/src/create_validators.rs b/validator_manager/src/create_validators.rs index 8946303f4e1..d06fce1d094 100644 --- a/validator_manager/src/create_validators.rs +++ b/validator_manager/src/create_validators.rs @@ -716,16 +716,16 @@ pub mod tests { assert_eq!(deposit.pubkey, validator_pubkey.clone().into()); if let Some(address) = config.eth1_withdrawal_address { assert_eq!( - deposit.withdrawal_credentials.as_bytes()[0], + deposit.withdrawal_credentials.as_slice()[0], spec.eth1_address_withdrawal_prefix_byte ); assert_eq!( - &deposit.withdrawal_credentials.as_bytes()[12..], - address.as_bytes() + &deposit.withdrawal_credentials.as_slice()[12..], + address.as_slice() ); } else { assert_eq!( - deposit.withdrawal_credentials.as_bytes()[0], + deposit.withdrawal_credentials.as_slice()[0], spec.bls_withdrawal_prefix_byte ); } diff --git a/watch/src/database/watch_types.rs b/watch/src/database/watch_types.rs index 0b3ba2c304d..c2b67084c94 100644 --- a/watch/src/database/watch_types.rs +++ b/watch/src/database/watch_types.rs @@ -72,7 +72,7 @@ impl WatchHash { } pub fn as_bytes(&self) -> &[u8] { - self.0.as_bytes() + self.0.as_slice() } pub fn from_bytes(src: &[u8]) -> Result {