diff --git a/Cargo.lock b/Cargo.lock index 696a1d8d..8c3c2fb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,11 +107,11 @@ dependencies = [ [[package]] name = "alloy-chains" -version = "0.1.40" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4932d790c723181807738cf1ac68198ab581cd699545b155601332541ee47bd" +checksum = "c660915971620592abe2c292c859957eb60e73a60c0eba34a6793eea60512cff" dependencies = [ - "alloy-primitives 0.8.9", + "alloy-primitives 0.8.10", "num_enum", "strum", ] @@ -192,8 +192,8 @@ dependencies = [ "alloy-serde", "c-kzg", "derive_more 0.99.18", - "ethereum_ssz 0.5.4", - "ethereum_ssz_derive 0.5.4", + "ethereum_ssz", + "ethereum_ssz_derive", "k256", "once_cell", "serde", @@ -280,7 +280,7 @@ dependencies = [ "cfg-if", "const-hex", "derive_more 0.99.18", - "ethereum_ssz 0.5.4", + "ethereum_ssz", "hex-literal", "itoa", "k256", @@ -294,9 +294,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71738eb20c42c5fb149571e76536a0f309d142f3957c28791662b96baf77a3d" +checksum = "8edae627382349b56cd6a7a2106f4fd69b243a9233e560c55c2e03cabb7e1d3c" dependencies = [ "bytes", "cfg-if", @@ -383,7 +383,7 @@ checksum = "2b09cae092c27b6f1bde952653a22708691802e57bfef4a2973b80bea21efd3f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -433,8 +433,8 @@ dependencies = [ "alloy-eips", "alloy-primitives 0.7.7", "alloy-rpc-types-engine", - "ethereum_ssz 0.5.4", - "ethereum_ssz_derive 0.5.4", + "ethereum_ssz", + "ethereum_ssz_derive", "serde", "serde_with", "thiserror", @@ -452,8 +452,8 @@ dependencies = [ "alloy-rlp", "alloy-rpc-types-eth", "alloy-serde", - "ethereum_ssz 0.5.4", - "ethereum_ssz_derive 0.5.4", + "ethereum_ssz", + "ethereum_ssz_derive", "jsonwebtoken", "rand 0.8.5", "serde", @@ -531,7 +531,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -548,7 +548,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", "syn-solidity", "tiny-keccak 2.0.2", ] @@ -566,7 +566,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.84", + "syn 2.0.85", "syn-solidity", ] @@ -656,7 +656,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.1.0", - "rustls 0.23.15", + "rustls 0.23.16", "serde_json", "tokio", "tokio-tungstenite", @@ -687,9 +687,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" dependencies = [ "anstyle", "anstyle-parse", @@ -702,36 +702,36 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -985,7 +985,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -996,7 +996,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -1056,7 +1056,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -1497,7 +1497,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -1514,9 +1514,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "concurrent-queue" @@ -1799,7 +1799,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -1847,7 +1847,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -1869,7 +1869,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -1976,7 +1976,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -1996,7 +1996,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", "unicode-xid", ] @@ -2087,7 +2087,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -2207,9 +2207,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.34" +version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ "cfg-if", ] @@ -2253,7 +2253,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -2351,49 +2351,25 @@ dependencies = [ [[package]] name = "ethereum_ssz" version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d3627f83d8b87b432a5fad9934b4565260722a141a2c40f371f8080adec9425" +source = "git+https://github.com/ncitron/ethereum_ssz?branch=stable-container#b92072f0390fc2c5d628c8c8e1828bd92ca2becf" dependencies = [ "ethereum-types 0.14.1", "itertools 0.10.5", "smallvec", ] -[[package]] -name = "ethereum_ssz" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "654bbebe60af1f6554e0e1216b8e336bc1a5ec483b7774d904e25e6e65a655c6" -dependencies = [ - "alloy-primitives 0.7.7", - "itertools 0.13.0", - "smallvec", -] - [[package]] name = "ethereum_ssz_derive" version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eccd5378ec34a07edd3d9b48088cbc63309d0367d14ba10b0cdb1d1791080ea" +source = "git+https://github.com/ncitron/ethereum_ssz?branch=stable-container#b92072f0390fc2c5d628c8c8e1828bd92ca2becf" dependencies = [ "darling 0.13.4", "proc-macro2", "quote", + "ssz_types", "syn 1.0.109", ] -[[package]] -name = "ethereum_ssz_derive" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21b5706b8763f5cbae4fbc407dacb8ce574ff619b98ff9d9c15adda2384681b" -dependencies = [ - "darling 0.20.10", - "proc-macro2", - "quote", - "syn 2.0.84", -] - [[package]] name = "event-listener" version = "2.5.3" @@ -2450,9 +2426,9 @@ dependencies = [ [[package]] name = "fdeflate" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8090f921a24b04994d9929e204f50b498a33ea6ba559ffaa05e04f7ee7fb5ab" +checksum = "07c6f4c64c1d33a3111c4466f7365ebdcc37c5bd1ea0d62aae2e3d722aacbedb" dependencies = [ "simd-adler32", ] @@ -2592,7 +2568,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -2700,7 +2676,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -3059,11 +3035,12 @@ dependencies = [ "alloy", "alloy-rlp", "bls12_381", - "ethereum_ssz 0.6.0", - "ethereum_ssz_derive 0.6.0", + "ethereum_ssz", + "ethereum_ssz_derive", "eyre", "getrandom 0.2.15", "serde", + "serde_json", "serde_yaml", "sha2 0.9.9", "snap", @@ -3147,8 +3124,8 @@ dependencies = [ "axum", "clap", "discv5", - "ethereum_ssz 0.6.0", - "ethereum_ssz_derive 0.6.0", + "ethereum_ssz", + "ethereum_ssz_derive", "eyre", "figment", "futures", @@ -3419,7 +3396,7 @@ dependencies = [ "http 1.1.0", "hyper 1.5.0", "hyper-util", - "rustls 0.23.15", + "rustls 0.23.16", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -3444,9 +3421,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" dependencies = [ "bytes", "futures-channel", @@ -4026,9 +4003,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "libp2p" @@ -4503,9 +4480,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "minicov" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71e683cd655513b99affab7d317deb690528255a0d5f717f1024093c12b169" +checksum = "def6d99771d7c499c26ad4d40eb6645eafd3a1553b35fc26ea5a489a45e82d9a" dependencies = [ "cc", "walkdir", @@ -4853,7 +4830,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -4956,7 +4933,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -5145,7 +5122,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -5196,29 +5173,29 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -5459,7 +5436,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", "version_check", "yansi", ] @@ -5484,7 +5461,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -5723,9 +5700,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -5767,9 +5744,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" dependencies = [ "base64 0.22.1", "bytes", @@ -5984,7 +5961,7 @@ dependencies = [ "ark-ff 0.3.0", "ark-ff 0.4.2", "bytes", - "ethereum_ssz 0.5.4", + "ethereum_ssz", "fastrlp", "num-bigint", "num-traits", @@ -6052,9 +6029,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" dependencies = [ "bitflags 2.6.0", "errno", @@ -6089,9 +6066,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.15" +version = "0.23.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" +checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" dependencies = [ "once_cell", "ring 0.17.8", @@ -6327,9 +6304,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.213" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" dependencies = [ "serde_derive", ] @@ -6347,13 +6324,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.213" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -6427,7 +6404,7 @@ dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -6662,12 +6639,11 @@ dependencies = [ [[package]] name = "ssz_types" version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e202ef3c07d9abc7b110a81206064e462758074242e8d176e3cb07415f01a3ad" +source = "git+https://github.com/ncitron/ssz_types?branch=stable-container#291aa1fdcc7182af6100bd02c4d9d4b469912439" dependencies = [ "derivative", "ethereum_serde_utils", - "ethereum_ssz 0.6.0", + "ethereum_ssz", "itertools 0.13.0", "serde", "serde_derive", @@ -6713,7 +6689,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -6762,9 +6738,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.84" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a2c4efbc0b0670e3d41f388e3cb936ff364bf681703b4c92ae26ca509966111" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", @@ -6780,7 +6756,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -6888,7 +6864,7 @@ checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -7010,7 +6986,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -7039,7 +7015,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.15", + "rustls 0.23.16", "rustls-pki-types", "tokio", ] @@ -7064,7 +7040,7 @@ checksum = "c6989540ced10490aaf14e6bad2e3d33728a2813310a0c71d1574304c49631cd" dependencies = [ "futures-util", "log", - "rustls 0.23.15", + "rustls 0.23.16", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -7193,7 +7169,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -7253,14 +7229,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] name = "tree_hash" version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f113108f55d589941862727b5a74f75276a54c157060983611d99f7f7fa6368" +source = "git+https://github.com/ncitron/tree_hash?branch=stable-container#92f5962e42a59176b6f40e3d83809b89650deb65" dependencies = [ "alloy-primitives 0.7.7", "ethereum_hashing", @@ -7270,13 +7245,13 @@ dependencies = [ [[package]] name = "tree_hash_derive" version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b623b16740c2ff75b04a705e726f436abab04eecb60a27b39eea55ec5e81e543" +source = "git+https://github.com/ncitron/tree_hash?branch=stable-container#92f5962e42a59176b6f40e3d83809b89650deb65" dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.84", + "ssz_types", + "syn 2.0.85", ] [[package]] @@ -7370,7 +7345,7 @@ dependencies = [ "httparse", "log", "rand 0.8.5", - "rustls 0.23.15", + "rustls 0.23.16", "rustls-pki-types", "sha1", "thiserror", @@ -7603,7 +7578,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", "wasm-bindgen-shared", ] @@ -7637,7 +7612,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7650,9 +7625,9 @@ checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-bindgen-test" -version = "0.3.43" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68497a05fb21143a08a7d24fc81763384a3072ee43c44e86aad1744d6adef9d9" +checksum = "d381749acb0943d357dcbd8f0b100640679883fcdeeef04def49daf8d33a5426" dependencies = [ "console_error_panic_hook", "js-sys", @@ -7665,13 +7640,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.43" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" +checksum = "c97b2ef2c8d627381e51c071c2ab328eac606d3f69dd82bcbca20a9e389d95f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -7691,9 +7666,9 @@ dependencies = [ [[package]] name = "wasmtimer" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f656cd8858a5164932d8a90f936700860976ec21eb00e0fe2aa8cab13f6b4cf" +checksum = "c7ed9d8b15c7fb594d72bfb4b5a276f3d2029333cd93a932f376f5937f6f80ee" dependencies = [ "futures", "js-sys", @@ -8134,7 +8109,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] [[package]] @@ -8154,5 +8129,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.84", + "syn 2.0.85", ] diff --git a/Cargo.toml b/Cargo.toml index 2e0a2684..ae77ba86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,8 +24,8 @@ default-members = ["cli"] [workspace.dependencies] # consensus ssz_types = "0.7.0" -ethereum_ssz_derive = "0.6.0" -ethereum_ssz = "0.6.0" +ethereum_ssz_derive = "0.5.4" +ethereum_ssz = "0.5.4" tree_hash_derive = "0.7.0" tree_hash = "0.7.0" sha2 = "0.9" @@ -111,6 +111,11 @@ rand = "0.8.5" [patch.crates-io] ethereum_hashing = { git = "https://github.com/ncitron/ethereum_hashing", rev = "7ee70944ed4fabe301551da8c447e4f4ae5e6c35" } +ssz_types = { git = "https://github.com/ncitron/ssz_types", branch = "stable-container" } +ethereum_ssz = { git = "https://github.com/ncitron/ethereum_ssz", branch = "stable-container" } +ethereum_ssz_derive = { git = "https://github.com/ncitron/ethereum_ssz", branch = "stable-container" } +tree_hash = { git = "https://github.com/ncitron/tree_hash", branch = "stable-container" } +tree_hash_derive = { git = "https://github.com/ncitron/tree_hash", branch = "stable-container" } ###################################### # Profiles diff --git a/ethereum/consensus-core/Cargo.toml b/ethereum/consensus-core/Cargo.toml index 48fe056b..7d783faa 100644 --- a/ethereum/consensus-core/Cargo.toml +++ b/ethereum/consensus-core/Cargo.toml @@ -26,6 +26,7 @@ superstruct.workspace = true thiserror.workspace = true tracing.workspace = true zduny-wasm-timer.workspace = true +serde_json.workspace = true [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2", features = ["js"] } diff --git a/ethereum/consensus-core/src/consensus_core.rs b/ethereum/consensus-core/src/consensus_core.rs index a9f0efe5..3a72c218 100644 --- a/ethereum/consensus-core/src/consensus_core.rs +++ b/ethereum/consensus-core/src/consensus_core.rs @@ -463,7 +463,9 @@ fn has_sync_update(update: &GenericUpdate) -> bool { } fn has_finality_update(update: &GenericUpdate) -> bool { - update.finalized_header.is_some() && update.finality_branch.is_some() + let normal = update.finalized_header.is_some() && update.finality_branch.is_some(); + let genesis = update.finalized_header.is_none() && update.finality_branch.is_some(); + normal || genesis } fn verify_sync_committee_signture( @@ -504,8 +506,13 @@ fn is_valid_header(header: &LightClientHeader, forks: &Forks) } }; - let proof_valid = - is_execution_payload_proof_valid(header.beacon(), execution, execution_branch); + let proof_valid = is_execution_payload_proof_valid( + header.beacon(), + execution, + execution_branch, + epoch, + forks, + ); proof_valid && valid_execution_type } else { diff --git a/ethereum/consensus-core/src/proof.rs b/ethereum/consensus-core/src/proof.rs index bceec095..6e50877f 100644 --- a/ethereum/consensus-core/src/proof.rs +++ b/ethereum/consensus-core/src/proof.rs @@ -15,7 +15,7 @@ pub fn is_finality_proof_valid( forks: &Forks, ) -> bool { let (index, depth) = if current_epoch >= forks.electra.epoch { - (41, 7) + (41, 9) } else { (41, 6) }; @@ -37,7 +37,7 @@ pub fn is_next_committee_proof_valid( forks: &Forks, ) -> bool { let (index, depth) = if current_epoch >= forks.electra.epoch { - (23, 6) + (23, 8) } else { (23, 5) }; @@ -59,7 +59,7 @@ pub fn is_current_committee_proof_valid( forks: &Forks, ) -> bool { let (index, depth) = if current_epoch >= forks.electra.epoch { - (22, 6) + (22, 8) } else { (22, 5) }; @@ -77,8 +77,22 @@ pub fn is_execution_payload_proof_valid( attested_header: &BeaconBlockHeader, execution: &ExecutionPayloadHeader, execution_branch: &[B256], + current_epoch: u64, + forks: &Forks, ) -> bool { - is_proof_valid(attested_header.body_root, execution, execution_branch, 4, 9) + let (index, depth) = if current_epoch >= forks.electra.epoch { + (9, 7) + } else { + (9, 4) + }; + + is_proof_valid( + attested_header.body_root, + execution, + execution_branch, + depth, + index, + ) } fn is_proof_valid( diff --git a/ethereum/consensus-core/src/types/mod.rs b/ethereum/consensus-core/src/types/mod.rs index 761c8657..f06763ce 100644 --- a/ethereum/consensus-core/src/types/mod.rs +++ b/ethereum/consensus-core/src/types/mod.rs @@ -8,21 +8,23 @@ use ssz_derive::{Decode, Encode}; use ssz_types::{serde_utils::quoted_u64_var_list, BitList, BitVector, FixedVector, VariableList}; use superstruct::superstruct; use tree_hash_derive::TreeHash; +use typenum::Unsigned; use crate::consensus_spec::ConsensusSpec; use self::{ bls::{PublicKey, Signature}, bytes::{ByteList, ByteVector}, + transaction::Transaction, }; pub mod bls; pub mod bytes; mod serde_utils; +pub mod transaction; pub type LogsBloom = ByteVector; pub type KZGCommitment = ByteVector; -pub type Transaction = ByteList; #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct LightClientStore { @@ -53,13 +55,17 @@ pub struct BeaconBlock { derive(Deserialize, Clone, Debug, Encode, TreeHash, Default), serde(deny_unknown_fields), serde(bound = "S: ConsensusSpec"), - ) + ), + specific_variant_attributes(Electra(tree_hash( + struct_behaviour = "profile", + max_fields = "typenum::U64" + ))) )] #[derive(Encode, TreeHash, Deserialize, Debug, Clone)] #[serde(untagged)] #[serde(bound = "S: ConsensusSpec")] #[ssz(enum_behaviour = "transparent")] -#[tree_hash(enum_behaviour = "transparent")] +#[tree_hash(enum_behaviour = "transparent_stable")] pub struct BeaconBlockBody { randao_reveal: Signature, eth1_data: Eth1Data, @@ -120,13 +126,17 @@ pub struct BlsToExecutionChange { derive(Default, Debug, Deserialize, Encode, TreeHash, Clone), serde(deny_unknown_fields), serde(bound = "S: ConsensusSpec"), - ) + ), + specific_variant_attributes(Electra(tree_hash( + struct_behaviour = "profile", + max_fields = "typenum::U64" + ))) )] #[derive(Debug, Deserialize, Clone, Encode, TreeHash)] #[serde(untagged)] #[serde(bound = "S: ConsensusSpec")] #[ssz(enum_behaviour = "transparent")] -#[tree_hash(enum_behaviour = "transparent")] +#[tree_hash(enum_behaviour = "transparent_stable")] pub struct ExecutionPayload { pub parent_hash: B256, pub fee_recipient: Address, @@ -155,6 +165,8 @@ pub struct ExecutionPayload { #[superstruct(only(Deneb, Electra))] #[serde(with = "serde_utils::u64")] pub excess_blob_gas: u64, + #[superstruct(only(Electra))] + pub system_logs_root: B256, #[ssz(skip_serializing, skip_deserializing)] #[tree_hash(skip_hashing)] #[serde(skip)] @@ -182,12 +194,16 @@ impl Default for ExecutionPayload { PartialEq ), serde(deny_unknown_fields), - ) + ), + specific_variant_attributes(Electra(tree_hash( + struct_behaviour = "profile", + max_fields = "typenum::U64" + ))) )] #[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq)] #[serde(untagged)] #[ssz(enum_behaviour = "transparent")] -#[tree_hash(enum_behaviour = "transparent")] +#[tree_hash(enum_behaviour = "transparent_stable")] pub struct ExecutionPayloadHeader { pub parent_hash: B256, pub fee_recipient: Address, @@ -216,6 +232,8 @@ pub struct ExecutionPayloadHeader { #[superstruct(only(Deneb, Electra))] #[serde(with = "serde_utils::u64")] pub excess_blob_gas: u64, + #[superstruct(only(Electra))] + pub system_logs_root: B256, } impl Default for ExecutionPayloadHeader { @@ -270,13 +288,17 @@ pub struct AttesterSlashing { variant_attributes( derive(Deserialize, Debug, Default, Encode, TreeHash, Clone,), serde(deny_unknown_fields), - ) + ), + specific_variant_attributes(Electra(tree_hash( + struct_behaviour = "profile", + max_fields = "typenum::U8" + ))) )] #[derive(Deserialize, Debug, Encode, TreeHash, Clone)] #[serde(bound = "S: ConsensusSpec")] #[serde(untagged)] #[ssz(enum_behaviour = "transparent")] -#[tree_hash(enum_behaviour = "transparent")] +#[tree_hash(enum_behaviour = "transparent_stable")] struct IndexedAttestation { #[serde(with = "quoted_u64_var_list")] #[superstruct(only(Base), partial_getter(rename = "attesting_indices_base"))] @@ -299,13 +321,18 @@ impl Default for IndexedAttestation { variant_attributes( derive(Deserialize, Debug, Encode, TreeHash, Clone,), serde(deny_unknown_fields), - ) + ), + specific_variant_attributes(Electra(tree_hash( + struct_behaviour = "profile", + max_fields = "typenum::U8" + ))), + //ref_attributes(derive(TreeHash), tree_hash(enum_behaviour = "transparent")), )] #[derive(Deserialize, Debug, Encode, TreeHash, Clone)] #[serde(bound = "S: ConsensusSpec")] #[serde(untagged)] #[ssz(enum_behaviour = "transparent")] -#[tree_hash(enum_behaviour = "transparent")] +#[tree_hash(enum_behaviour = "transparent_stable")] pub struct Attestation { #[superstruct(only(Base), partial_getter(rename = "aggregation_bits_base"))] aggregation_bits: BitList, @@ -373,6 +400,7 @@ pub struct Eth1Data { } #[derive(Deserialize, Debug, Default, Encode, TreeHash, Clone)] +#[tree_hash(struct_behaviour = "profile", max_fields = "typenum::U16")] pub struct ExecutionRequests { deposits: VariableList, withdrawals: VariableList, @@ -429,7 +457,7 @@ pub struct Bootstrap { only(Electra), partial_getter(rename = "current_sync_committee_branch_electra") )] - pub current_sync_committee_branch: FixedVector, + pub current_sync_committee_branch: FixedVector, } impl Bootstrap { @@ -546,7 +574,7 @@ pub struct LightClientHeader { #[superstruct(only(Capella, Deneb, Electra))] pub execution: ExecutionPayloadHeader, #[superstruct(only(Capella, Deneb, Electra))] - pub execution_branch: FixedVector, + pub execution_branch: FixedVector, } impl Default for LightClientHeader { diff --git a/ethereum/consensus-core/src/types/serde_utils.rs b/ethereum/consensus-core/src/types/serde_utils.rs index 7760b0dc..63f05281 100644 --- a/ethereum/consensus-core/src/types/serde_utils.rs +++ b/ethereum/consensus-core/src/types/serde_utils.rs @@ -17,6 +17,60 @@ pub mod u64 { } } +pub mod u64_opt { + use serde::{de::Error, Deserializer, Serializer}; + + pub fn serialize(value: &Option, serializer: S) -> Result + where + S: Serializer, + { + if let Some(value) = value { + serializer.serialize_str(&value.to_string()) + } else { + serializer.serialize_none() + } + } + + pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + let val: Option = serde::Deserialize::deserialize(deserializer)?; + if let Some(n) = val { + Ok(Some(n.parse().map_err(D::Error::custom)?)) + } else { + Ok(None) + } + } +} + +pub mod u8_opt { + use serde::{de::Error, Deserializer, Serializer}; + + pub fn serialize(value: &Option, serializer: S) -> Result + where + S: Serializer, + { + if let Some(value) = value { + serializer.serialize_str(&value.to_string()) + } else { + serializer.serialize_none() + } + } + + pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + let val: Option = serde::Deserialize::deserialize(deserializer)?; + if let Some(n) = val { + Ok(Some(n.parse().map_err(D::Error::custom)?)) + } else { + Ok(None) + } + } +} + pub mod u256 { use alloy::primitives::U256; use serde::{de::Error, Deserializer, Serializer}; @@ -36,3 +90,31 @@ pub mod u256 { val.parse().map_err(D::Error::custom) } } + +pub mod u256_opt { + use alloy::primitives::U256; + use serde::{de::Error, Deserializer, Serializer}; + + pub fn serialize(value: &Option, serializer: S) -> Result + where + S: Serializer, + { + if let Some(value) = value { + serializer.serialize_str(&value.to_string()) + } else { + serializer.serialize_none() + } + } + + pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + let val: Option = serde::Deserialize::deserialize(deserializer)?; + if let Some(n) = val { + Ok(Some(n.parse().map_err(D::Error::custom)?)) + } else { + Ok(None) + } + } +} diff --git a/ethereum/consensus-core/src/types/transaction.rs b/ethereum/consensus-core/src/types/transaction.rs new file mode 100644 index 00000000..7b4ec0ea --- /dev/null +++ b/ethereum/consensus-core/src/types/transaction.rs @@ -0,0 +1,130 @@ +use alloy::primitives::{Address, B256, U256}; +use serde::{Deserialize, Serialize}; +use ssz_derive::{Decode, Encode}; +use ssz_types::{BitVector, VariableList}; +use tree_hash_derive::TreeHash; +use typenum::Unsigned; + +use super::{ + bytes::{ByteList, ByteVector}, + serde_utils, +}; + +#[derive(Clone, PartialEq, Debug, Encode, Decode, TreeHash, Serialize, Deserialize)] +pub struct Transaction { + pub payload: TransactionPayload, + pub signature: ExecutionSignature, +} + +#[derive(Clone, PartialEq, Debug, Encode, Decode, TreeHash, Serialize, Deserialize, Default)] +#[ssz(struct_behaviour = "stable_container")] +#[ssz(max_fields = "typenum::U32")] +#[tree_hash(struct_behaviour = "stable_container")] +#[tree_hash(max_fields = "typenum::U32")] +#[serde(default)] +pub struct TransactionPayload { + // EIP-2718 + #[serde(rename = "type")] + #[serde(with = "serde_utils::u8_opt")] + pub tx_type: Option, + + // EIP-155 + #[serde(with = "serde_utils::u64_opt")] + pub chain_id: Option, + + #[serde(with = "serde_utils::u64_opt")] + pub nonce: Option, + pub max_fees_per_gas: Option, + #[serde(with = "serde_utils::u64_opt")] + pub gas: Option, + pub to: Option
, + #[serde(with = "serde_utils::u256_opt")] + pub value: Option, + pub input: Option>, + + // EIP-2930 + pub access_list: Option>, + + // EIP-1559 + pub max_priority_fees_per_gas: Option, + + // EIP-4844 + pub blob_versioned_hashes: Option>, + + // EIP-7702 + pub authorization_list: Option>, +} + +#[derive(Clone, PartialEq, Debug, Encode, Decode, TreeHash, Serialize, Deserialize, Default)] +#[ssz(struct_behaviour = "stable_container")] +#[ssz(max_fields = "typenum::U16")] +#[tree_hash(struct_behaviour = "stable_container")] +#[tree_hash(max_fields = "typenum::U16")] +#[serde(default)] +pub struct FeesPerGas { + #[serde(with = "serde_utils::u256_opt")] + pub regular: Option, + #[serde(with = "serde_utils::u256_opt")] + pub blob: Option, +} + +impl FeesPerGas { + pub fn amount(&self) -> U256 { + if let Some(amount) = self.regular { + return amount; + } + + if let Some(amount) = self.blob { + return amount; + } + + U256::ZERO + } +} + +#[derive(Clone, PartialEq, Debug, Encode, Decode, TreeHash, Serialize, Deserialize, Default)] +pub struct AccessTuple { + pub address: Address, + pub storage_keys: VariableList, +} + +#[derive(Clone, PartialEq, Debug, Encode, Decode, TreeHash, Serialize, Deserialize, Default)] +pub struct Authorization { + payload: AuthorizationPayload, + signature: ExecutionSignature, +} + +#[derive(Clone, PartialEq, Debug, Encode, Decode, TreeHash, Serialize, Deserialize, Default)] +#[ssz(struct_behaviour = "stable_container")] +#[ssz(max_fields = "typenum::U16")] +#[tree_hash(struct_behaviour = "stable_container")] +#[tree_hash(max_fields = "typenum::U16")] +pub struct AuthorizationPayload { + #[serde(with = "serde_utils::u8_opt")] + magic: Option, + #[serde(with = "serde_utils::u64_opt")] + chain_id: Option, + address: Option
, + #[serde(with = "serde_utils::u64_opt")] + nonce: Option, +} + +#[derive(Clone, PartialEq, Debug, Encode, Decode, TreeHash, Serialize, Deserialize, Default)] +#[ssz(struct_behaviour = "stable_container")] +#[ssz(max_fields = "typenum::U8")] +#[tree_hash(struct_behaviour = "stable_container")] +#[tree_hash(max_fields = "typenum::U8")] +pub struct ExecutionSignature { + pub secp256k1: Option>, +} + +#[test] +fn test_deserialize() { + use tree_hash::TreeHash; + + let data = "{\"payload\":{\"type\":\"2\",\"chain_id\":\"7061395750\",\"nonce\":\"0\",\"max_fees_per_gas\":{\"regular\":\"100000000000\"},\"gas\":\"100000\",\"to\":\"0x6eef24367483af2fdc5026d985e2827f19a7a140\",\"value\":\"10000000000000000000\",\"input\":\"0x\",\"access_list\":[],\"max_priority_fees_per_gas\":{\"regular\":\"2000000000\"}},\"signature\":{\"secp256k1\":\"0x6adf0ca6dcbed482a2b1e537a0ffa5a421f8fb1a0106d3fbffda6bf1f5b378013bbf182d5e8c70d91461153ad5c8f4de7f29c9335fa43dccdb022dfb7aefff7801\"}}"; + + let tx: Transaction = serde_json::from_str(data).unwrap(); + let hash = tx.tree_hash_root(); + println!("{:#?}", hash); +} diff --git a/ethereum/src/config/networks.rs b/ethereum/src/config/networks.rs index 23610cac..27aa77c4 100644 --- a/ethereum/src/config/networks.rs +++ b/ethereum/src/config/networks.rs @@ -23,6 +23,7 @@ pub enum Network { Sepolia, Holesky, PectraDevnet, + SszDevnet, } impl FromStr for Network { @@ -34,6 +35,7 @@ impl FromStr for Network { "sepolia" => Ok(Self::Sepolia), "holesky" => Ok(Self::Holesky), "pectra-devnet" => Ok(Self::PectraDevnet), + "ssz-devnet" => Ok(Self::SszDevnet), _ => Err(eyre::eyre!("network not recognized")), } } @@ -46,6 +48,7 @@ impl Display for Network { Self::Sepolia => "sepolia", Self::Holesky => "holesky", Self::PectraDevnet => "pectra-devnet", + Self::SszDevnet => "ssz-devnet", }; f.write_str(str) @@ -59,6 +62,7 @@ impl Network { Self::Sepolia => sepolia(), Self::Holesky => holesky(), Self::PectraDevnet => pectra_devnet(), + Self::SszDevnet => ssz_devnet(), } } @@ -252,6 +256,51 @@ pub fn pectra_devnet() -> BaseConfig { } } +pub fn ssz_devnet() -> BaseConfig { + BaseConfig { + default_checkpoint: b256!( + "809b44003e091e39cb2f276f8e4398ecc39733befa0478e9d3b30dde899d0398" + ), + rpc_port: 8545, + consensus_rpc: None, + chain: ChainConfig { + chain_id: 7061395750, + genesis_time: 1730378785, + genesis_root: b256!("fa54b7e42269605816b27366ffd77b960a20a21a17eb96917990db75db2efa63"), + }, + forks: Forks { + genesis: Fork { + epoch: 0, + fork_version: fixed_bytes!("10000000"), + }, + altair: Fork { + epoch: 0, + fork_version: fixed_bytes!("20000000"), + }, + bellatrix: Fork { + epoch: 0, + fork_version: fixed_bytes!("30000000"), + }, + capella: Fork { + epoch: 0, + fork_version: fixed_bytes!("40000000"), + }, + deneb: Fork { + epoch: 0, + fork_version: fixed_bytes!("50501529"), + }, + electra: Fork { + epoch: 1, + fork_version: fixed_bytes!("60501529"), + }, + }, + max_checkpoint_age: 1_209_600, // 14 days + #[cfg(not(target_arch = "wasm32"))] + data_dir: Some(data_dir(Network::SszDevnet)), + ..std::default::Default::default() + } +} + #[cfg(not(target_arch = "wasm32"))] fn data_dir(network: Network) -> PathBuf { home_dir() diff --git a/ethereum/src/consensus.rs b/ethereum/src/consensus.rs index 33770b56..220db074 100644 --- a/ethereum/src/consensus.rs +++ b/ethereum/src/consensus.rs @@ -2,14 +2,15 @@ use std::marker::PhantomData; use std::process; use std::sync::Arc; -use alloy::consensus::{Transaction as TxTrait, TxEnvelope}; +use alloy::consensus::TxEnvelope; use alloy::primitives::{b256, fixed_bytes, B256, U256, U64}; -use alloy::rlp::{encode, Decodable}; +use alloy::rlp::encode; use alloy::rpc::types::{Parity, Signature, Transaction}; use chrono::Duration; use eyre::eyre; use eyre::Result; use futures::future::join_all; +use revm::primitives::{AccessList, AccessListItem}; use tracing::{debug, error, info, warn}; use tree_hash::TreeHash; use triehash_ethereum::ordered_trie_root; @@ -241,16 +242,44 @@ impl> Inner { let finalized_slot = self.store.finalized_header.beacon().slot; let verified_block_hash = if slot == latest_slot { + let root = self + .store + .optimistic_header + .execution() + .unwrap() + .transactions_root(); + // println!("store slot: {}", self.store.optimistic_header.beacon().slot); + // println!("tx root in header: {}", root); self.store.optimistic_header.beacon().tree_hash_root() } else if slot == finalized_slot { + let root = self + .store + .finalized_header + .execution() + .unwrap() + .transactions_root(); + // println!("store slot: {}", self.store.finalized_header.beacon().slot); + // println!("tx root in header: {}", root); self.store.finalized_header.beacon().tree_hash_root() } else { return Err(ConsensusError::PayloadNotFound(slot).into()); }; + // println!("fetched block slot: {}", block.slot); + let calc_root = block + .body + .execution_payload() + .transactions() + .tree_hash_root(); + // println!("caluclated tx root: {}", calc_root); + for tx in block.body.execution_payload().transactions() { + // println!("tx hash: {}", tx.tree_hash_root()); + } + if verified_block_hash != block_hash { Err(ConsensusError::InvalidHeaderHash(block_hash, verified_block_hash).into()) } else { + // println!("txs: {:#?}", block.body.execution_payload().transactions()); Ok(block.body.execution_payload().clone()) } } @@ -302,6 +331,7 @@ impl> Inner { self.bootstrap(checkpoint).await?; let current_period = calc_sync_period::(self.store.finalized_header.beacon().slot); + println!("current period: {}", current_period); let updates = self .rpc .get_updates(current_period, MAX_REQUEST_LIGHT_CLIENT_UPDATES) @@ -529,102 +559,139 @@ fn payload_to_block(value: ExecutionPayload) -> Block= 2) == Some(true) { + ssz_tx + .payload + .max_fees_per_gas + .as_ref() + .map(|v| v.regular.map(|v| v.to())) + .flatten() + } else { + None + }; + + let max_priority_fee_per_gas = ssz_tx + .payload + .max_priority_fees_per_gas + .as_ref() + .map(|fee| fee.regular.map(|value| value.to())) + .flatten(); + + let blob_versioned_hashes = ssz_tx + .payload + .blob_versioned_hashes + .as_ref() + .map(|hashes| hashes.to_vec()); + + let max_fee_per_blob_gas = ssz_tx + .payload + .max_fees_per_gas + .as_ref() + .map(|fees| fees.blob.map(|v| v.to())) + .flatten(); + + let gas_price = if ssz_tx.payload.tx_type.map(|t| t < 2) == Some(true) { + ssz_tx + .payload + .max_fees_per_gas + .as_ref() + .ok_or(eyre::eyre!("invalid gas price"))? + .regular + .ok_or(eyre::eyre!("invalid gas price"))? + .to() + } else { + calculate_gas_price( + max_fee_per_gas.ok_or(eyre::eyre!("invalid gas price"))?, + max_priority_fee_per_gas.ok_or(eyre::eyre!("invalid gas price"))?, + value.base_fee_per_gas().to(), + ) + }; + + let input = ssz_tx + .payload + .input + .clone() + .unwrap_or_default() + .inner + .to_vec() + .into(); let mut tx = Transaction { - hash: *tx_envelope.tx_hash(), - nonce: tx_envelope.nonce(), + hash: B256::ZERO, + nonce: ssz_tx.payload.nonce.unwrap_or_default(), block_hash: Some(*value.block_hash()), block_number: Some(*value.block_number()), transaction_index: Some(i as u64), - to: tx_envelope.to().to().cloned(), - value: tx_envelope.value(), - gas_price: tx_envelope.gas_price(), - gas: tx_envelope.gas_limit(), - input: tx_envelope.input().to_vec().into(), - chain_id: tx_envelope.chain_id(), - transaction_type: Some(tx_envelope.tx_type().into()), + to: ssz_tx.payload.to, + value: ssz_tx.payload.value.unwrap_or_default(), + gas_price: Some(gas_price), + gas: ssz_tx.payload.gas.unwrap_or_default() as u128, + input, + signature: Some(signature), + from, + + // EIP-155 + chain_id: ssz_tx.payload.chain_id, + + // EIP-2718 + transaction_type: ssz_tx.payload.tx_type, + + // EIP-2930 + access_list, + + // EIP-1559 + max_fee_per_gas, + max_priority_fee_per_gas, + + // EIP-4844 + blob_versioned_hashes, + max_fee_per_blob_gas, + ..Default::default() }; - match tx_envelope { - TxEnvelope::Legacy(inner) => { - tx.from = inner.recover_signer().unwrap(); - tx.signature = Some(Signature { - r: inner.signature().r(), - s: inner.signature().s(), - v: U256::from(inner.signature().v().to_u64()), - y_parity: None, - }); - } - TxEnvelope::Eip2930(inner) => { - tx.from = inner.recover_signer().unwrap(); - tx.signature = Some(Signature { - r: inner.signature().r(), - s: inner.signature().s(), - v: U256::from(inner.signature().v().to_u64()), - y_parity: Some(Parity(inner.signature().v().to_u64() == 1)), - }); - tx.access_list = Some(inner.tx().access_list.clone()); - } - TxEnvelope::Eip1559(inner) => { - tx.from = inner.recover_signer().unwrap(); - tx.signature = Some(Signature { - r: inner.signature().r(), - s: inner.signature().s(), - v: U256::from(inner.signature().v().to_u64()), - y_parity: Some(Parity(inner.signature().v().to_u64() == 1)), - }); - - let tx_inner = inner.tx(); - tx.access_list = Some(tx_inner.access_list.clone()); - tx.max_fee_per_gas = Some(tx_inner.max_fee_per_gas); - tx.max_priority_fee_per_gas = Some(tx_inner.max_priority_fee_per_gas); - - tx.gas_price = Some(gas_price( - tx_inner.max_fee_per_gas, - tx_inner.max_priority_fee_per_gas, - value.base_fee_per_gas().to(), - )); - } - TxEnvelope::Eip4844(inner) => { - tx.from = inner.recover_signer().unwrap(); - tx.signature = Some(Signature { - r: inner.signature().r(), - s: inner.signature().s(), - v: U256::from(inner.signature().v().to_u64()), - y_parity: Some(Parity(inner.signature().v().to_u64() == 1)), - }); - - let tx_inner = inner.tx().tx(); - tx.access_list = Some(tx_inner.access_list.clone()); - tx.max_fee_per_gas = Some(tx_inner.max_fee_per_gas); - tx.max_priority_fee_per_gas = Some(tx_inner.max_priority_fee_per_gas); - tx.max_fee_per_blob_gas = Some(tx_inner.max_fee_per_blob_gas); - tx.gas_price = Some(tx_inner.max_fee_per_gas); - tx.blob_versioned_hashes = Some(tx_inner.blob_versioned_hashes.clone()); - - tx.gas_price = Some(gas_price( - tx_inner.max_fee_per_gas, - tx_inner.max_priority_fee_per_gas, - value.base_fee_per_gas().to(), - )); - } - _ => todo!(), - } + let consensus_tx = TxEnvelope::try_from(tx.clone())?; + let hash = consensus_tx.tx_hash(); + tx.hash = *hash; - tx + Ok(tx) }) + .filter_map(|value| value.ok()) .collect::>(); - let raw_txs = value.transactions().iter().map(|tx| tx.inner.to_vec()); - let txs_root = ordered_trie_root(raw_txs); - - let withdrawals = value.withdrawals().unwrap().iter().map(encode); - let withdrawals_root = ordered_trie_root(withdrawals); + let withdrawals_root = value + .withdrawals() + .map(|w| w.tree_hash_root()) + .unwrap_or_default(); Block { number: U64::from(*value.block_number()), @@ -646,16 +713,16 @@ fn payload_to_block(value: ExecutionPayload) -> Block u128 { +fn calculate_gas_price(max_fee: u128, max_prio_fee: u128, base_fee: u128) -> u128 { u128::min(max_fee, max_prio_fee + base_fee) } diff --git a/ethereum/src/rpc/http_rpc.rs b/ethereum/src/rpc/http_rpc.rs index e7a84214..180257cc 100644 --- a/ethereum/src/rpc/http_rpc.rs +++ b/ethereum/src/rpc/http_rpc.rs @@ -45,7 +45,7 @@ async fn get(req: &str) -> Result { let bytes = response.bytes().await?; let message: HttpRpcMessage = serde_json::from_slice(&bytes).map_err(|e| { if status.is_success() { - eyre::eyre!("deserialization error: {}", e) + eyre::eyre!("deserialization error: {}, raw response: {:?}", e, bytes) } else { eyre::eyre!("status: {}, raw response: {:?}", status.as_u16(), bytes) } @@ -84,6 +84,7 @@ impl ConsensusRpc for HttpRpc { } async fn get_updates(&self, period: u64, count: u8) -> Result>> { + println!("period: {}, updates: {}", period, count); let count = cmp::min(count, MAX_REQUEST_LIGHT_CLIENT_UPDATES); let req = format!( "{}/eth/v1/beacon/light_client/updates?start_period={}&count={}", @@ -92,6 +93,8 @@ impl ConsensusRpc for HttpRpc { let res: Vec> = get(&req).await.map_err(|e| RpcError::new("updates", e))?; + //println!("{:#?}", res.iter().map(|u| u.data.attested_header().beacon().slot)); + Ok(res.into_iter().map(|d| d.data).collect()) }