diff --git a/Cargo.lock b/Cargo.lock index cb25eb92be7..0ccf7865894 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.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58047cc851e58c26224521d1ecda466e3d746ebca0274cd5427aa660a88c353" +checksum = "7198a527b4c4762cb88d54bcaeb0428f4298b72552c9c8ec4af614b4a4990c59" dependencies = [ "alloy-eips", "alloy-primitives", @@ -188,12 +194,34 @@ 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.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a3e14fa0d152d00bd8daf605eb74ad397efb0f54bd7155585823dddb4401e" +checksum = "159eab0e4e15b88571f55673af37314f4b8f17630dc1b393c3d70f2128a1d494" dependencies = [ + "alloy-eip2930", + "alloy-eip7702", "alloy-primitives", "alloy-rlp", "c-kzg", @@ -204,20 +232,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_arbitrary", "derive_more", + "getrandom", "hex-literal", "itoa", "k256 0.13.3", "keccak-asm", "proptest", + "proptest-derive", "rand", "ruint", "serde", @@ -226,9 +258,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 +269,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.76", ] [[package]] @@ -269,9 +301,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 +316,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 +412,7 @@ dependencies = [ "num-bigint", "num-traits", "paste", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "zeroize", ] @@ -484,15 +516,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 +538,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.76", "synstructure", ] @@ -524,7 +556,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -546,9 +578,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 +589,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]] @@ -582,7 +614,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -593,7 +625,7 @@ checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" dependencies = [ "futures", "pharos", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -652,7 +684,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -726,7 +758,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.7.4", "object", "rustc-demangle", ] @@ -777,6 +809,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" name = "beacon_chain" version = "0.2.0" dependencies = [ + "alloy-primitives", "bitvec 1.0.1", "bls", "criterion", @@ -911,9 +944,9 @@ dependencies = [ "proc-macro2", "quote", "regex", - "rustc-hash", + "rustc-hash 1.1.0", "shlex", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -1005,14 +1038,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 +1159,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 +1189,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 +1242,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 +1268,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 +1368,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 +1378,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 +1391,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.76", ] [[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 +1465,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 +1546,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 +1561,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 +1789,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 +1808,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 +1821,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -1832,7 +1869,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -1854,7 +1891,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -2019,7 +2056,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -2031,8 +2068,8 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", - "syn 2.0.72", + "rustc_version 0.4.1", + "syn 2.0.76", ] [[package]] @@ -2059,7 +2096,7 @@ dependencies = [ "dsl_auto_type", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -2079,7 +2116,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.76", ] [[package]] @@ -2192,7 +2229,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -2206,7 +2243,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -2217,9 +2254,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 +2313,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 +2423,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -2736,23 +2773,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 +2797,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.76", ] [[package]] @@ -2970,6 +3006,7 @@ dependencies = [ "ethereum_serde_utils", "ethereum_ssz", "ethers-core", + "fixed_bytes", "fork_choice", "hash-db", "hash256-std-hasher", @@ -3030,9 +3067,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 +3132,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 +3161,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 +3331,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -3445,7 +3489,7 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -3521,7 +3565,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.2.6", + "indexmap 2.4.0", "slab", "tokio", "tokio-util", @@ -3658,6 +3702,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 +4037,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 +4221,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -4252,20 +4299,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 +4332,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 +4389,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 +4449,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 +4563,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" @@ -4868,7 +4924,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -4925,9 +4981,9 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.45.1" +version = "0.45.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200cbe50349a44760927d50b431d77bed79b9c0a3959de1af8d24a63434b71e5" +checksum = "ddd5265f6b80f94d48a3963541aad183cc598a645755d2f1805a373e41e0716b" dependencies = [ "either", "futures", @@ -5009,9 +5065,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 +5126,7 @@ dependencies = [ name = "lighthouse_network" version = "0.2.0" dependencies = [ + "alloy-primitives", "async-channel", "bytes", "delay_map", @@ -5215,9 +5272,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 +5395,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 +5433,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 +5449,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 +5501,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 +5693,7 @@ dependencies = [ name = "network" version = "0.2.0" dependencies = [ + "alloy-primitives", "anyhow", "async-channel", "beacon_chain", @@ -5680,9 +5748,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 +5885,18 @@ dependencies = [ [[package]] name = "object" -version = "0.36.2" +version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" 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 +5974,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -6032,7 +6100,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 +6241,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 +6279,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -6288,17 +6356,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 +6441,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 +6513,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 +6579,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -6531,6 +6602,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.76", +] + [[package]] name = "proto_array" version = "0.2.0" @@ -6633,17 +6715,18 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" 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 +6734,14 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.3" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" dependencies = [ "bytes", "rand", "ring 0.17.8", - "rustc-hash", + "rustc-hash 2.0.0", "rustls 0.23.12", "slab", "thiserror", @@ -6675,14 +6758,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 +6877,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 +6913,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 +6924,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 +7141,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 +7205,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 +7228,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 +7260,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 +7292,7 @@ dependencies = [ "log", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.6", + "rustls-webpki 0.102.7", "subtle", "zeroize", ] @@ -7215,7 +7306,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 +7322,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 +7332,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 +7348,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", @@ -7341,7 +7432,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 +7584,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 +7603,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.76", ] [[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 +7642,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[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 +7694,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.4.0", "itoa", "ryu", "serde", @@ -7668,9 +7760,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 +8062,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 +8121,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 +8280,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 +8299,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -8235,7 +8328,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -8325,14 +8418,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 +8455,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 +8509,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -8490,7 +8584,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 +8628,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.1" +version = "1.39.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" +checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" dependencies = [ "backtrace", "bytes", @@ -8567,7 +8661,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -8665,21 +8759,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 +8784,22 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "toml_datetime", "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.21.1" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.2.6", - "toml_datetime", - "winnow 0.5.40", -] - -[[package]] -name = "toml_edit" -version = "0.22.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" -dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.15", + "winnow 0.6.18", ] [[package]] @@ -8737,15 +8820,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 +8862,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -8852,24 +8935,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.76", ] [[package]] @@ -8918,11 +9002,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 +9053,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ - "arbitrary", "byteorder", "crunchy", "hex", @@ -9020,15 +9103,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" @@ -9239,9 +9322,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 +9377,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 +9422,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.76", "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 +9460,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 +9470,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.76", "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 +9551,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 +9642,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 +9722,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 +9920,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 +9948,7 @@ dependencies = [ "js-sys", "log", "pharos", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "send_wrapper", "thiserror", "wasm-bindgen", @@ -9909,9 +10002,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 +10072,7 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] @@ -9990,7 +10084,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -10010,7 +10104,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -10054,9 +10148,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 9d744003360..1eda0ce0333 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; @@ -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 { @@ -3446,7 +3446,7 @@ impl BeaconChain { { 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() { @@ -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 = 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/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/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 4863982b552..36c5a9359dd 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 @@ -273,7 +273,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::>>() @@ -1155,7 +1154,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..81bddf6a927 100644 --- a/beacon_node/beacon_chain/src/execution_payload.rs +++ b/beacon_node/beacon_chain/src/execution_payload.rs @@ -505,7 +505,7 @@ where return Ok(BlockProposalContentsType::Full( BlockProposalContents::Payload { payload: FullPayload::default_at_fork(fork)?, - block_value: Uint256::zero(), + block_value: Uint256::ZERO, }, )); } @@ -523,7 +523,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 b28d221da7e..eb2d78685b2 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -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/payload_invalidation.rs b/beacon_node/beacon_chain/tests/payload_invalidation.rs index 4dc7d20e227..c7195e51ebf 100644 --- a/beacon_node/beacon_chain/tests/payload_invalidation.rs +++ b/beacon_node/beacon_chain/tests/payload_invalidation.rs @@ -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 216c3b7844f..041b31e2b08 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(), @@ -880,7 +883,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, @@ -909,7 +912,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 668efc513f4..dba8eb1ef32 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`. diff --git a/beacon_node/http_api/tests/broadcast_validation_tests.rs b/beacon_node/http_api/tests/broadcast_validation_tests.rs index 4b884bb5192..fdc873f773e 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; 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/lighthouse_network/Cargo.toml b/beacon_node/lighthouse_network/Cargo.toml index cb89d492d1d..b811b85ea22 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"] } 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/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 2d6d1d2a8f3..8f5143d7ed9 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -835,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; @@ -926,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), } } @@ -1687,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(); @@ -1810,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/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/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/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/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/tests.rs b/beacon_node/network/src/sync/block_lookups/tests.rs index 5d1f2dafc9a..4c63943e3f8 100644 --- a/beacon_node/network/src/sync/block_lookups/tests.rs +++ b/beacon_node/network/src/sync/block_lookups/tests.rs @@ -300,7 +300,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" ); } 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 fecd8e37442..a53b697ea77 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) => { let blobs = BlobSidecarList::from_ssz_bytes(blobs_bytes)?; @@ -1682,7 +1682,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() } @@ -1787,7 +1787,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); @@ -1882,7 +1882,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/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 10b00d5ba1d..e31427121ec 100644 --- a/consensus/types/src/chain_spec.rs +++ b/consensus/types/src/chain_spec.rs @@ -544,7 +544,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"), ); @@ -564,7 +564,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"), ); @@ -754,7 +754,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), @@ -900,7 +901,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], @@ -1074,10 +1075,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, @@ -1305,6 +1305,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")] @@ -1407,7 +1408,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, @@ -1925,7 +1926,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)[..]); } } @@ -2163,9 +2164,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/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/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/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 {