From dd1b5fd82c700fe32eb8e32a7a9bd9a979ea7f62 Mon Sep 17 00:00:00 2001 From: Jonas Bostoen Date: Sun, 16 Apr 2023 15:47:31 +0200 Subject: [PATCH] feat: implement Capella upgrade --- Cargo.lock | 434 +++++++++++++------- Cargo.toml | 33 +- examples/main.rs | 4 +- src/config.rs | 2 +- src/discovery/mod.rs | 4 +- src/metrics.rs | 8 - src/network/gossipsub_scoring_parameters.rs | 4 +- src/network/utils.rs | 2 +- src/rpc/codec/base.rs | 3 + src/rpc/codec/ssz_snappy.rs | 27 +- src/rpc/protocol.rs | 27 +- src/service.rs | 30 +- src/types/pubsub.rs | 8 +- 13 files changed, 389 insertions(+), 197 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f47e18..4f92557 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,6 +103,15 @@ version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" +[[package]] +name = "arbitrary" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "arc-swap" version = "1.5.1" @@ -135,7 +144,7 @@ checksum = "677d1d8ab452a3936018a687b20e6f7cf5363d713b732b8884001317b0e48aa3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -209,9 +218,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitvec" -version = "0.20.4" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", "radium", @@ -249,8 +258,9 @@ dependencies = [ [[package]] name = "bls" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ + "arbitrary", "blst", "eth2_hashing", "eth2_serde_utils", @@ -331,11 +341,11 @@ dependencies = [ [[package]] name = "cached_tree_hash" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "eth2_hashing", "eth2_ssz", - "eth2_ssz_derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "eth2_ssz_derive", "eth2_ssz_types", "ethereum-types", "smallvec", @@ -421,7 +431,7 @@ dependencies = [ [[package]] name = "clap_utils" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "clap", "dirs", @@ -448,28 +458,28 @@ dependencies = [ [[package]] name = "compare_fields" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" [[package]] name = "compare_fields_derive" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "quote", - "syn", + "syn 1.0.107", ] [[package]] name = "consentry" version = "0.1.0" dependencies = [ - "delay_map", + "delay_map 0.1.2", "directory", "dirs", - "discv5", + "discv5 0.1.0", "error-chain", "eth2_ssz", - "eth2_ssz_derive 0.3.0 (git+https://github.com/sigp/lighthouse?tag=v3.3.0)", + "eth2_ssz_derive", "eth2_ssz_types", "exit-future", "fnv", @@ -495,14 +505,14 @@ dependencies = [ "smallvec", "snap", "strum", - "superstruct", + "superstruct 0.5.0", "task_executor", "tempfile", "tiny-keccak", "tokio", "tokio-io-timeout", "tokio-stream", - "tokio-util", + "tokio-util 0.6.10", "tracing", "tracing-subscriber 0.2.25", "types", @@ -691,7 +701,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.107", ] [[package]] @@ -708,7 +718,7 @@ checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -732,7 +742,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn", + "syn 1.0.107", ] [[package]] @@ -743,7 +753,7 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -759,7 +769,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c4d75d3abfe4830dcbf9bcb1b926954e121669f74dd1ca7aa0183b1755d83f6" dependencies = [ "futures", - "tokio-util", + "tokio-util 0.6.10", +] + +[[package]] +name = "delay_map" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4355c25cbf99edcb6b4a0e906f6bdc6956eda149e84455bea49696429b2f8e8" +dependencies = [ + "futures", + "tokio-util 0.7.7", ] [[package]] @@ -780,7 +800,18 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", +] + +[[package]] +name = "derive_arbitrary" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cdeb9ec472d588e539a818b2dee436825730da08ad0017c4b1a17676bdc8b7" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.107", ] [[package]] @@ -806,7 +837,7 @@ dependencies = [ [[package]] name = "directory" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "clap", "clap_utils", @@ -863,11 +894,11 @@ dependencies = [ "aes", "aes-gcm", "arrayvec", - "delay_map", - "enr", + "delay_map 0.1.2", + "enr 0.6.2", "fnv", "futures", - "hashlink", + "hashlink 0.7.0", "hex", "hkdf", "lazy_static", @@ -881,7 +912,40 @@ dependencies = [ "socket2", "tokio", "tokio-stream", - "tokio-util", + "tokio-util 0.6.10", + "tracing", + "tracing-subscriber 0.3.16", + "uint", + "zeroize", +] + +[[package]] +name = "discv5" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b009a99b85b58900df46435307fc5c4c845af7e182582b1fbf869572fa9fce69" +dependencies = [ + "aes", + "aes-gcm", + "arrayvec", + "delay_map 0.3.0", + "enr 0.7.0", + "fnv", + "futures", + "hashlink 0.7.0", + "hex", + "hkdf", + "lazy_static", + "lru", + "more-asserts", + "parking_lot 0.11.2", + "rand 0.8.5", + "rlp", + "smallvec", + "socket2", + "tokio", + "tokio-stream", + "tokio-util 0.6.10", "tracing", "tracing-subscriber 0.3.16", "uint", @@ -975,6 +1039,26 @@ dependencies = [ "zeroize", ] +[[package]] +name = "enr" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "492a7e5fc2504d5fdce8e124d3e263b244a68b283cac67a69eda0cd43e0aebad" +dependencies = [ + "base64", + "bs58", + "bytes", + "ed25519-dalek", + "hex", + "k256", + "log", + "rand 0.8.5", + "rlp", + "serde", + "sha3", + "zeroize", +] + [[package]] name = "enum-as-inner" version = "0.4.0" @@ -984,7 +1068,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -1010,7 +1094,7 @@ dependencies = [ [[package]] name = "eth2_config" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "paste", "types", @@ -1019,7 +1103,7 @@ dependencies = [ [[package]] name = "eth2_hashing" version = "0.3.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "cpufeatures", "lazy_static", @@ -1030,7 +1114,7 @@ dependencies = [ [[package]] name = "eth2_interop_keypairs" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "bls", "eth2_hashing", @@ -1045,9 +1129,9 @@ dependencies = [ [[package]] name = "eth2_network_config" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ - "enr", + "discv5 0.2.2", "eth2_config", "eth2_ssz", "serde_yaml", @@ -1058,7 +1142,7 @@ dependencies = [ [[package]] name = "eth2_serde_utils" version = "0.1.1" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "ethereum-types", "hex", @@ -1070,7 +1154,7 @@ dependencies = [ [[package]] name = "eth2_ssz" version = "0.4.1" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "ethereum-types", "itertools", @@ -1079,32 +1163,21 @@ dependencies = [ [[package]] name = "eth2_ssz_derive" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "635b86d2c941bb71e7419a571e1763d65c93e51a1bafc400352e3bef6ff59fc9" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "eth2_ssz_derive" -version = "0.3.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +version = "0.3.1" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] name = "eth2_ssz_types" version = "0.2.2" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ + "arbitrary", "derivative", "eth2_serde_utils", "eth2_ssz", @@ -1117,9 +1190,9 @@ dependencies = [ [[package]] name = "ethbloom" -version = "0.11.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb684ac8fa8f6c5759f788862bb22ec6fe3cb392f6bfd08e3c64b603661e3f8" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" dependencies = [ "crunchy", "fixed-hash", @@ -1130,9 +1203,9 @@ dependencies = [ [[package]] name = "ethereum-types" -version = "0.12.1" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05136f7057fe789f06e6d41d07b34e6f70d8c86e5693b60f97aaa6553553bdaf" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" dependencies = [ "ethbloom", "fixed-hash", @@ -1200,10 +1273,11 @@ dependencies = [ [[package]] name = "fixed-hash" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ + "arbitrary", "byteorder", "rand 0.8.5", "rustc-hex", @@ -1244,15 +1318,15 @@ dependencies = [ [[package]] name = "funty" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", @@ -1265,9 +1339,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -1275,15 +1349,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-executor" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" dependencies = [ "futures-core", "futures-task", @@ -1293,19 +1367,19 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -1321,15 +1395,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-timer" @@ -1339,9 +1413,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", @@ -1422,7 +1496,7 @@ dependencies = [ "proc-macro-hack", "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -1469,6 +1543,15 @@ dependencies = [ "hashbrown 0.11.2", ] +[[package]] +name = "hashlink" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" +dependencies = [ + "hashbrown 0.12.3", +] + [[package]] name = "heck" version = "0.4.0" @@ -1624,9 +1707,9 @@ dependencies = [ [[package]] name = "impl-codec" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "161ebdfec3c8e3b52bf61c4f3550a1eea4f9579d10dc1b936f3171ebdcd6c443" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" dependencies = [ "parity-scale-codec", ] @@ -1642,9 +1725,9 @@ dependencies = [ [[package]] name = "impl-serde" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" dependencies = [ "serde", ] @@ -1657,7 +1740,7 @@ checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -1682,7 +1765,7 @@ dependencies = [ [[package]] name = "int_to_bytes" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "bytes", ] @@ -2016,7 +2099,7 @@ checksum = "a0eddc4497a8b5a506013c40e8189864f9c3a00db2b25671f428ae9007f3ba32" dependencies = [ "heck", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2118,9 +2201,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.22.2" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290b64917f8b0cb885d9de0f9959fe1f775d7fa12f1da2db9001c1c8ab60f89d" +checksum = "29f835d03d717946d28b1d1ed632eb6f0e24a299388ee623d0c23118d3e8a7fa" dependencies = [ "cc", "pkg-config", @@ -2141,7 +2224,7 @@ dependencies = [ [[package]] name = "lighthouse_metrics" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "lazy_static", "prometheus", @@ -2150,7 +2233,7 @@ dependencies = [ [[package]] name = "lighthouse_version" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "git-version", "target_info", @@ -2271,7 +2354,7 @@ dependencies = [ [[package]] name = "merkle_proof" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "eth2_hashing", "ethereum-types", @@ -2279,6 +2362,29 @@ dependencies = [ "safe_arith", ] +[[package]] +name = "metastruct" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "734788dec2091fe9afa39530ca2ea7994f4a2c9aff3dbfebb63f2c1945c6f10b" +dependencies = [ + "metastruct_macro", +] + +[[package]] +name = "metastruct_macro" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ded15e7570c2a507a23e6c3a1c8d74507b779476e43afe93ddfc261d44173d" +dependencies = [ + "darling", + "itertools", + "proc-macro2", + "quote", + "smallvec", + "syn 1.0.107", +] + [[package]] name = "miniz_oxide" version = "0.6.2" @@ -2347,7 +2453,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.107", "synstructure", ] @@ -2486,9 +2592,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "2.3.1" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909" +checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" dependencies = [ "arrayvec", "bitvec", @@ -2500,14 +2606,14 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "2.3.1" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1557010476e0595c9b568d16dcfb81b93cdeb157612726f5170d31aa707bed27" +checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2607,7 +2713,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2686,14 +2792,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c8992a85d8e93a28bdf76137db888d3874e3b230dee5ed8bebac4c9f7617773" dependencies = [ "proc-macro2", - "syn", + "syn 1.0.107", ] [[package]] name = "primitive-types" -version = "0.10.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ "fixed-hash", "impl-codec", @@ -2721,7 +2827,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.107", "version_check", ] @@ -2744,9 +2850,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.49" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -2786,7 +2892,7 @@ checksum = "66a455fbcb954c1a7decf3c586e860fd7889cddf4b8e164be736dbac95a953cd" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2816,7 +2922,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn", + "syn 1.0.107", "tempfile", "which", ] @@ -2844,7 +2950,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2889,7 +2995,7 @@ checksum = "608c156fd8e97febc07dc9c2e2c80bf74cfc6ef26893eae3daf8bc2bc94a4b7f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2905,18 +3011,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] [[package]] name = "radium" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" [[package]] name = "rand" @@ -3129,16 +3235,15 @@ dependencies = [ [[package]] name = "rusqlite" -version = "0.25.4" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4b1eaf239b47034fb450ee9cdedd7d0226571689d8823030c4b6c2cb407152" +checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" dependencies = [ "bitflags", "fallible-iterator", "fallible-streaming-iterator", - "hashlink", + "hashlink 0.8.1", "libsqlite3-sys", - "memchr", "smallvec", ] @@ -3210,7 +3315,7 @@ checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" [[package]] name = "safe_arith" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" [[package]] name = "scopeguard" @@ -3289,7 +3394,7 @@ checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -3322,7 +3427,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -3619,7 +3724,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 1.0.107", ] [[package]] @@ -3639,13 +3744,27 @@ dependencies = [ "proc-macro2", "quote", "smallvec", - "syn", + "syn 1.0.107", +] + +[[package]] +name = "superstruct" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b9e5728aa1a87141cefd4e7509903fc01fa0dcb108022b1e841a67c5159fc5" +dependencies = [ + "darling", + "itertools", + "proc-macro2", + "quote", + "smallvec", + "syn 1.0.107", ] [[package]] name = "swap_or_not_shuffle" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "eth2_hashing", "ethereum-types", @@ -3662,6 +3781,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.12.6" @@ -3670,7 +3800,7 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", "unicode-xid", ] @@ -3695,7 +3825,7 @@ checksum = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" [[package]] name = "task_executor" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "exit-future", "futures", @@ -3743,10 +3873,10 @@ dependencies = [ [[package]] name = "test_random_derive" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -3775,7 +3905,7 @@ checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -3896,7 +4026,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -3926,6 +4056,20 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-util" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite 0.2.9", + "slab", + "tokio", +] + [[package]] name = "toml" version = "0.5.10" @@ -3956,7 +4100,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -4046,13 +4190,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebeb235c5847e2f82cfe0f07eb971d1e5f6804b18dac2ae16349cc604380f82f" dependencies = [ "quote", - "syn", + "syn 1.0.107", ] [[package]] name = "tree_hash" version = "0.4.1" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "eth2_hashing", "ethereum-types", @@ -4062,11 +4206,11 @@ dependencies = [ [[package]] name = "tree_hash_derive" version = "0.4.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ "darling", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -4123,8 +4267,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "types" version = "0.2.1" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" dependencies = [ + "arbitrary", "bls", "cached_tree_hash", "compare_fields", @@ -4134,7 +4279,7 @@ dependencies = [ "eth2_interop_keypairs", "eth2_serde_utils", "eth2_ssz", - "eth2_ssz_derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "eth2_ssz_derive", "eth2_ssz_types", "ethereum-types", "hex", @@ -4144,6 +4289,7 @@ dependencies = [ "log", "maplit", "merkle_proof", + "metastruct", "parking_lot 0.12.1", "rand 0.8.5", "rand_xorshift", @@ -4158,7 +4304,7 @@ dependencies = [ "serde_yaml", "slog", "smallvec", - "superstruct", + "superstruct 0.6.0", "swap_or_not_shuffle", "tempfile", "test_random_derive", @@ -4178,6 +4324,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ + "arbitrary", "byteorder", "crunchy", "hex", @@ -4234,7 +4381,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35581ff83d4101e58b582e607120c7f5ffb17e632a980b1f38334d76b36908b2" dependencies = [ "bytes", - "tokio-util", + "tokio-util 0.6.10", ] [[package]] @@ -4256,7 +4403,7 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "unused_port" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?tag=v3.3.0#bf533c8e42cc73c35730e285c21df8add0195369" +source = "git+https://github.com/sigp/lighthouse?tag=v4.0.1#a53830fd60a119bf3f659b253360af8027128e83" [[package]] name = "url" @@ -4338,7 +4485,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.107", "wasm-bindgen-shared", ] @@ -4372,7 +4519,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4561,9 +4708,12 @@ dependencies = [ [[package]] name = "wyz" -version = "0.2.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] [[package]] name = "x25519-dalek" @@ -4616,7 +4766,7 @@ checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", "synstructure", ] diff --git a/Cargo.toml b/Cargo.toml index 8249cfd..d3bcc9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,22 +9,22 @@ edition = "2021" [dependencies] discv5 = { version = "0.1.0", features = ["libp2p"] } unsigned-varint = { version = "0.6.0", features = ["codec"] } -types = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } -eth2_ssz_types = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } +types = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } +eth2_ssz_types = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } serde = { version = "1.0.116", features = ["derive"] } serde_derive = "1" -eth2_ssz = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } -eth2_ssz_derive = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } +eth2_ssz = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } +eth2_ssz_derive = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } slog = { version = "2.5.2", features = ["max_level_trace"] } -lighthouse_version = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } +lighthouse_version = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } tokio = { version = "1.14.0", features = ["time", "macros"] } tokio-stream = "0.1" -futures = "0.3.7" +futures = "0.3.28" error-chain = "0.12.4" dirs = "3.0.1" fnv = "1.0.7" lazy_static = "1.4.0" -lighthouse_metrics = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } +lighthouse_metrics = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } smallvec = "1.6.1" tokio-io-timeout = "1.1.1" lru = "0.7.1" @@ -34,14 +34,14 @@ snap = "1.0.1" hex = "0.4.2" tokio-util = { version = "0.6.2", features = ["codec", "compat", "time"] } tiny-keccak = "2.0.2" -task_executor = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } +task_executor = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } rand = "0.8.5" -directory = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } +directory = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } regex = "1.5.5" strum = { version = "0.24.0", features = ["derive"] } superstruct = "0.5.0" prometheus-client = "0.18.0" -unused_port = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } +unused_port = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } delay_map = "0.1.1" tracing = { version = "0.1" } tracing-subscriber = { version = "0.2", features = ["fmt", "env-filter"] } @@ -64,13 +64,14 @@ features = [ # Some lighthouse patches [patch.crates-io] -eth2_ssz = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } -eth2_ssz_types = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } -eth2_serde_utils = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } -eth2_hashing = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } +eth2_ssz = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } +eth2_ssz_types = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } +eth2_ssz_derive = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } +eth2_serde_utils = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } +eth2_hashing = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } -tree_hash = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } -tree_hash_derive = { git = "https://github.com/sigp/lighthouse", tag = "v3.3.0" } +tree_hash = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } +tree_hash_derive = { git = "https://github.com/sigp/lighthouse", tag = "v4.0.1" } [dev-dependencies] slog-term = "2.6.0" diff --git a/examples/main.rs b/examples/main.rs index c5abe95..65255cc 100644 --- a/examples/main.rs +++ b/examples/main.rs @@ -26,8 +26,8 @@ async fn main() { .message() .execution_payload() .unwrap() - .execution_payload - .block_number; + .execution_payload_ref() + .block_number(); println!( "Received block {} (source peer: {:?}", diff --git a/src/config.rs b/src/config.rs index 71566b8..29037c4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -296,7 +296,7 @@ pub fn gossipsub_config(network_load: u8, fork_context: Arc) -> Gos match fork_context.current_fork() { // according to: https://github.com/ethereum/consensus-specs/blob/dev/specs/merge/p2p-interface.md#the-gossip-domain-gossipsub // the derivation of the message-id remains the same in the merge - ForkName::Altair | ForkName::Merge => { + ForkName::Altair | ForkName::Merge | ForkName::Capella => { let topic_len_bytes = topic_bytes.len().to_le_bytes(); let mut vec = Vec::with_capacity( prefix.len() + topic_len_bytes.len() + topic_bytes.len() + message.data.len(), diff --git a/src/discovery/mod.rs b/src/discovery/mod.rs index 9a30688..a267e43 100644 --- a/src/discovery/mod.rs +++ b/src/discovery/mod.rs @@ -1062,14 +1062,14 @@ mod tests { use crate::rpc::methods::{MetaData, MetaDataV2}; use enr::EnrBuilder; use types::{BitVector, MinimalEthSpec, SubnetId}; - use unused_port::unused_udp_port; + use unused_port::unused_udp4_port; type E = MinimalEthSpec; async fn build_discovery() -> Discovery { let keypair = libp2p::identity::Keypair::generate_secp256k1(); let config = NetworkConfig { - discovery_port: unused_udp_port().unwrap(), + discovery_port: unused_udp4_port().unwrap(), ..Default::default() }; let enr_key: CombinedKey = CombinedKey::from_libp2p(&keypair).unwrap(); diff --git a/src/metrics.rs b/src/metrics.rs index 2ee224d..90584ea 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -165,11 +165,3 @@ pub fn check_nat() { inc_counter(&NAT_OPEN); } } - -pub fn scrape_discovery_metrics() { - let metrics = discv5::metrics::Metrics::from(discv5::Discv5::raw_metrics()); - set_float_gauge(&DISCOVERY_REQS, metrics.unsolicited_requests_per_second); - set_gauge(&DISCOVERY_SESSIONS, metrics.active_sessions as i64); - set_gauge(&DISCOVERY_SENT_BYTES, metrics.bytes_sent as i64); - set_gauge(&DISCOVERY_RECV_BYTES, metrics.bytes_recv as i64); -} diff --git a/src/network/gossipsub_scoring_parameters.rs b/src/network/gossipsub_scoring_parameters.rs index 71a3953..88becd6 100644 --- a/src/network/gossipsub_scoring_parameters.rs +++ b/src/network/gossipsub_scoring_parameters.rs @@ -270,11 +270,11 @@ impl PeerScoreSettings { let modulo_smaller = max( 1, - smaller_committee_size / self.target_aggregators_per_committee as usize, + smaller_committee_size / self.target_aggregators_per_committee, ); let modulo_larger = max( 1, - (smaller_committee_size + 1) / self.target_aggregators_per_committee as usize, + (smaller_committee_size + 1) / self.target_aggregators_per_committee, ); Ok(( diff --git a/src/network/utils.rs b/src/network/utils.rs index 064602f..7ffc3dc 100644 --- a/src/network/utils.rs +++ b/src/network/utils.rs @@ -88,7 +88,7 @@ fn keypair_from_hex(hex_bytes: &str) -> error::Result { hex_bytes.to_string() }; - hex::decode(&hex_bytes) + hex::decode(hex_bytes) .map_err(|e| format!("Failed to parse p2p secret key bytes: {:?}", e).into()) .and_then(keypair_from_bytes) } diff --git a/src/rpc/codec/base.rs b/src/rpc/codec/base.rs index 53f85d9..6c6ce2d 100644 --- a/src/rpc/codec/base.rs +++ b/src/rpc/codec/base.rs @@ -193,14 +193,17 @@ mod tests { let mut chain_spec = Spec::default_spec(); let altair_fork_epoch = Epoch::new(1); let merge_fork_epoch = Epoch::new(2); + let capella_fork_epoch = Epoch::new(3); chain_spec.altair_fork_epoch = Some(altair_fork_epoch); chain_spec.bellatrix_fork_epoch = Some(merge_fork_epoch); + chain_spec.capella_fork_epoch = Some(capella_fork_epoch); let current_slot = match fork_name { ForkName::Base => Slot::new(0), ForkName::Altair => altair_fork_epoch.start_slot(Spec::slots_per_epoch()), ForkName::Merge => merge_fork_epoch.start_slot(Spec::slots_per_epoch()), + ForkName::Capella => capella_fork_epoch.start_slot(Spec::slots_per_epoch()), }; ForkContext::new::(current_slot, Hash256::zero(), &chain_spec) } diff --git a/src/rpc/codec/ssz_snappy.rs b/src/rpc/codec/ssz_snappy.rs index a46a05a..c3b9b56 100644 --- a/src/rpc/codec/ssz_snappy.rs +++ b/src/rpc/codec/ssz_snappy.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use tokio_util::codec::{Decoder, Encoder}; use types::{ EthSpec, ForkContext, ForkName, SignedBeaconBlock, SignedBeaconBlockAltair, - SignedBeaconBlockBase, SignedBeaconBlockMerge, + SignedBeaconBlockBase, SignedBeaconBlockCapella, SignedBeaconBlockMerge, }; use unsigned_varint::codec::Uvi; @@ -407,6 +407,10 @@ fn context_bytes( return match **ref_box_block { // NOTE: If you are adding another fork type here, be sure to modify the // `fork_context.to_context_bytes()` function to support it as well! + SignedBeaconBlock::Capella { .. } => { + // Capella context being `None` implies that "merge never happened". + fork_context.to_context_bytes(ForkName::Capella) + } SignedBeaconBlock::Merge { .. } => { // Merge context being `None` implies that "merge never happened". fork_context.to_context_bytes(ForkName::Merge) @@ -441,7 +445,7 @@ fn handle_length( // Note: length-prefix of > 10 bytes(uint64) would be a decoding error match uvi_codec.decode(bytes).map_err(RPCError::from)? { Some(length) => { - *len = Some(length as usize); + *len = Some(length); Ok(Some(length)) } None => Ok(None), // need more bytes to decode length @@ -586,6 +590,11 @@ fn handle_v2_response( decoded_buffer, )?), )))), + ForkName::Capella => Ok(Some(RPCResponse::BlocksByRange(Arc::new( + SignedBeaconBlock::Capella(SignedBeaconBlockCapella::from_ssz_bytes( + decoded_buffer, + )?), + )))), }, Protocol::BlocksByRoot => match fork_name { ForkName::Altair => Ok(Some(RPCResponse::BlocksByRoot(Arc::new( @@ -601,6 +610,11 @@ fn handle_v2_response( decoded_buffer, )?), )))), + ForkName::Capella => Ok(Some(RPCResponse::BlocksByRoot(Arc::new( + SignedBeaconBlock::Capella(SignedBeaconBlockCapella::from_ssz_bytes( + decoded_buffer, + )?), + )))), }, _ => Err(RPCError::ErrorResponse( RPCResponseErrorCode::InvalidRequest, @@ -625,9 +639,9 @@ fn context_bytes_to_fork_name( ) }) } + #[cfg(test)] mod tests { - use super::*; use crate::rpc::{protocol::*, MetaData}; use crate::{ @@ -636,8 +650,8 @@ mod tests { }; use std::sync::Arc; use types::{ - BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, Epoch, ForkContext, - FullPayload, Hash256, Signature, SignedBeaconBlock, Slot, + BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, EmptyBlock, Epoch, + ForkContext, FullPayload, Hash256, Signature, SignedBeaconBlock, Slot, }; use snap::write::FrameEncoder; @@ -650,14 +664,17 @@ mod tests { let mut chain_spec = Spec::default_spec(); let altair_fork_epoch = Epoch::new(1); let merge_fork_epoch = Epoch::new(2); + let capella_fork_epoch = Epoch::new(3); chain_spec.altair_fork_epoch = Some(altair_fork_epoch); chain_spec.bellatrix_fork_epoch = Some(merge_fork_epoch); + chain_spec.capella_fork_epoch = Some(capella_fork_epoch); let current_slot = match fork_name { ForkName::Base => Slot::new(0), ForkName::Altair => altair_fork_epoch.start_slot(Spec::slots_per_epoch()), ForkName::Merge => merge_fork_epoch.start_slot(Spec::slots_per_epoch()), + ForkName::Capella => capella_fork_epoch.start_slot(Spec::slots_per_epoch()), }; ForkContext::new::(current_slot, Hash256::zero(), &chain_spec) } diff --git a/src/rpc/protocol.rs b/src/rpc/protocol.rs index 8196021..d0c227b 100644 --- a/src/rpc/protocol.rs +++ b/src/rpc/protocol.rs @@ -21,8 +21,9 @@ use tokio_util::{ compat::{Compat, FuturesAsyncReadCompatExt}, }; use types::{ - BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, EthSpec, ForkContext, - ForkName, Hash256, MainnetEthSpec, Signature, SignedBeaconBlock, + BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockCapella, BeaconBlockMerge, + EmptyBlock, EthSpec, ForkContext, ForkName, Hash256, MainnetEthSpec, Signature, + SignedBeaconBlock, }; lazy_static! { @@ -61,6 +62,14 @@ lazy_static! { .as_ssz_bytes() .len(); + pub static ref SIGNED_BEACON_BLOCK_CAPELLA_MAX_WITHOUT_PAYLOAD: usize = SignedBeaconBlock::::from_block( + BeaconBlock::Capella(BeaconBlockCapella::full(&MainnetEthSpec::default_spec())), + Signature::empty(), + ) + .as_ssz_bytes() + .len(); + + /// The `BeaconBlockMerge` block has an `ExecutionPayload` field which has a max size ~16 GiB for future proofing. /// We calculate the value from its fields instead of constructing the block and checking the length. /// Note: This is only the theoretical upper bound. We further bound the max size we receive over the network @@ -68,9 +77,13 @@ lazy_static! { pub static ref SIGNED_BEACON_BLOCK_MERGE_MAX: usize = // Size of a full altair block *SIGNED_BEACON_BLOCK_ALTAIR_MAX - + types::ExecutionPayload::::max_execution_payload_size() // adding max size of execution payload (~16gb) + + types::ExecutionPayload::::max_execution_payload_merge_size() // adding max size of execution payload (~16gb) + ssz::BYTES_PER_LENGTH_OFFSET; // Adding the additional ssz offset for the `ExecutionPayload` field + pub static ref SIGNED_BEACON_BLOCK_CAPELLA_MAX: usize = *SIGNED_BEACON_BLOCK_CAPELLA_MAX_WITHOUT_PAYLOAD + + types::ExecutionPayload::::max_execution_payload_capella_size() // adding max size of execution payload (~16gb) + + ssz::BYTES_PER_LENGTH_OFFSET; // Adding the additional ssz offset for the `ExecutionPayload` field + pub static ref BLOCKS_BY_ROOT_REQUEST_MIN: usize = VariableList::::from(Vec::::new()) .as_ssz_bytes() @@ -102,6 +115,7 @@ lazy_static! { pub(crate) const MAX_RPC_SIZE: usize = 1_048_576; // 1M /// The maximum bytes that can be sent across the RPC post-merge. pub(crate) const MAX_RPC_SIZE_POST_MERGE: usize = 10 * 1_048_576; // 10M +pub(crate) const MAX_RPC_SIZE_POST_CAPELLA: usize = 10 * 1_048_576; // 10M /// The protocol prefix the RPC protocol id. const PROTOCOL_PREFIX: &str = "/eth2/beacon_chain/req"; /// Time allowed for the first byte of a request to arrive before we time out (Time To First Byte). @@ -113,8 +127,9 @@ const REQUEST_TIMEOUT: u64 = 15; /// Returns the maximum bytes that can be sent across the RPC. pub fn max_rpc_size(fork_context: &ForkContext) -> usize { match fork_context.current_fork() { - ForkName::Merge => MAX_RPC_SIZE_POST_MERGE, ForkName::Altair | ForkName::Base => MAX_RPC_SIZE, + ForkName::Merge => MAX_RPC_SIZE_POST_MERGE, + ForkName::Capella => MAX_RPC_SIZE_POST_CAPELLA, } } @@ -135,6 +150,10 @@ pub fn rpc_block_limits_by_fork(current_fork: ForkName) -> RpcLimits { *SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and merge blocks *SIGNED_BEACON_BLOCK_MERGE_MAX, // Merge block is larger than base and altair blocks ), + ForkName::Capella => RpcLimits::new( + *SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and merge blocks + *SIGNED_BEACON_BLOCK_CAPELLA_MAX, // Capella block is larger than base, altair and merge blocks + ), } } diff --git a/src/service.rs b/src/service.rs index a6426e2..16edabb 100644 --- a/src/service.rs +++ b/src/service.rs @@ -109,17 +109,17 @@ impl Service { discovery_port: self.cfg.discovery_port, boot_nodes_enr: self.cfg.boot_enrs, target_peers: self.cfg.max_peers, + network_load: 5, ..Default::default() }; // Specify the fork - let fork = ForkName::Merge; + let fork = ForkName::Capella; // Populate the chain spec let mainnet_spec = ChainSpec::mainnet(); - // Get the merge slot - let merge_slot = mainnet_spec + let capella_slot = mainnet_spec .fork_epoch(fork) .unwrap() .start_slot(MainnetEthSpec::slots_per_epoch()); @@ -130,15 +130,21 @@ impl Service { .unwrap(); // Build the merge fork context - let merge_fork_context = - ForkContext::new::(merge_slot, genesis_validators_root, &mainnet_spec); + let capella_fork_context = ForkContext::new::( + capella_slot, + genesis_validators_root, + &mainnet_spec, + ); + + let fork_digest = capella_fork_context.to_context_bytes(fork).unwrap(); + info!(slot = ?capella_slot, "Fork digest: {:?}", fork_digest); // Build the network service context let ctx = Context { config: &network_config, enr_fork_id: mainnet_spec - .enr_fork_id::(merge_slot, genesis_validators_root), - fork_context: Arc::new(merge_fork_context), + .enr_fork_id::(capella_slot, genesis_validators_root), + fork_context: Arc::new(capella_fork_context), chain_spec: &mainnet_spec, gossipsub_registry: None, }; @@ -147,17 +153,17 @@ impl Service { // Set a random default status (for now) let mut highest_status = StatusMessage { - fork_digest: [74, 38, 197, 139], + fork_digest, finalized_root: Hash256::from_str( - "0x6e1fbcfc857c0f849e4570009422edf1d56e29b16098b632fa8bee1b7e7f353c", + "0xb6adca904a0674b7263f8f9518b2a0dff5ee6089ee92890e742d0a64a2cbbb43", ) .unwrap(), - finalized_epoch: Epoch::new(169022), + finalized_epoch: Epoch::new(194863), head_root: Hash256::from_str( - "0xf4cc483036e8ec382ccc85639695b0bb12ed11e9c8af2daf5b0c5340b015ca4e", + "0xb41d25d17ef959d15aabdc01df99e2ec94dd600a0ac218d5b79b2a95cb14acad", ) .unwrap(), - head_slot: Slot::new(5408793), + head_slot: Slot::new(6235698), }; let mut epoch_blocks: VecDeque<(Slot, Hash256)> = VecDeque::with_capacity(3); diff --git a/src/types/pubsub.rs b/src/types/pubsub.rs index 21dcac1..e671383 100644 --- a/src/types/pubsub.rs +++ b/src/types/pubsub.rs @@ -11,8 +11,8 @@ use std::sync::Arc; pub use types::{ Attestation, AttesterSlashing, EthSpec, ForkContext, ForkName, ProposerSlashing, SignedAggregateAndProof, SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase, - SignedBeaconBlockMerge, SignedContributionAndProof, SignedVoluntaryExit, SubnetId, - SyncCommitteeMessage, SyncSubnetId, + SignedBeaconBlockCapella, SignedBeaconBlockMerge, SignedContributionAndProof, + SignedVoluntaryExit, SubnetId, SyncCommitteeMessage, SyncSubnetId, }; #[derive(Debug, Clone, PartialEq)] @@ -167,6 +167,10 @@ impl PubsubMessage { SignedBeaconBlockMerge::from_ssz_bytes(data) .map_err(|e| format!("{:?}", e))?, ), + Some(ForkName::Capella) => SignedBeaconBlock::::Capella( + SignedBeaconBlockCapella::from_ssz_bytes(data) + .map_err(|e| format!("{:?}", e))?, + ), None => { return Err(format!( "Unknown gossipsub fork digest: {:?}",