reth-ethereum-forks crate (#5621)

Co-authored-by: root <root@Arindam>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Arindam Singh
2023-12-01 12:07:32 +00:00
committed by GitHub
parent 1067bb32d0
commit 2144b97df0
16 changed files with 359 additions and 200 deletions

237
Cargo.lock generated
View File

@ -140,9 +140,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]] [[package]]
name = "alloy-dyn-abi" name = "alloy-dyn-abi"
version = "0.5.0" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9fe14fb6dded4be3f44d053e59402a405bb231561e36a88bc2283a9829d81fe" checksum = "2a80060a7b7cbcb40c78fe763130078f6e8b49d7d9a5b0d0f9c508d28b094b60"
dependencies = [ dependencies = [
"alloy-json-abi", "alloy-json-abi",
"alloy-primitives", "alloy-primitives",
@ -158,9 +158,9 @@ dependencies = [
[[package]] [[package]]
name = "alloy-json-abi" name = "alloy-json-abi"
version = "0.5.0" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85cbbc8fcae58f39dbfbdc94ead48de0779910528889aebc074aed75959bffe7" checksum = "ef4dff5c682e16e398783e8da63956bdf22ce48841e6ca367f8a8a6b1f2ed989"
dependencies = [ dependencies = [
"alloy-primitives", "alloy-primitives",
"alloy-sol-type-parser", "alloy-sol-type-parser",
@ -170,9 +170,9 @@ dependencies = [
[[package]] [[package]]
name = "alloy-primitives" name = "alloy-primitives"
version = "0.5.0" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5def4b5e1bb8fe7ea37eeac1063246d4ef26f56cbdccf864a5a6bdcb80e91f4" checksum = "3a3877a2fa7474d9367d01ab43e33a4a4eeedf9bf7ec481533520686e956703b"
dependencies = [ dependencies = [
"alloy-rlp", "alloy-rlp",
"arbitrary", "arbitrary",
@ -218,9 +218,9 @@ dependencies = [
[[package]] [[package]]
name = "alloy-sol-macro" name = "alloy-sol-macro"
version = "0.5.0" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0acd5b8d2699b095a57a0ecea6a6a2045b8e5ed6f2607bfa3382961d2889e82" checksum = "123b602fbffdfb514183bcca2e5e7428b41ed5d59580ae70bf8eca937d165427"
dependencies = [ dependencies = [
"const-hex", "const-hex",
"dunce", "dunce",
@ -236,18 +236,18 @@ dependencies = [
[[package]] [[package]]
name = "alloy-sol-type-parser" name = "alloy-sol-type-parser"
version = "0.5.0" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc77699fb68c8a2cf18efb2c51df43e09b42b53886c6eb552951b19c41ebfc84" checksum = "e4648000cc0f043d0cdded1650bf4a1c075da0367cd9c80deda48db870985cbd"
dependencies = [ dependencies = [
"winnow", "winnow",
] ]
[[package]] [[package]]
name = "alloy-sol-types" name = "alloy-sol-types"
version = "0.5.0" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97d483e9c6db659cdb24fc736684ef68b743705fbdb0677c6404815361871b92" checksum = "8c4c333ed7d5a4d87e3b8ad2ce230d4f9347b9e43faf98ad16ba58bf318cd023"
dependencies = [ dependencies = [
"alloy-primitives", "alloy-primitives",
"alloy-sol-macro", "alloy-sol-macro",
@ -946,7 +946,7 @@ checksum = "f3e5afa991908cfbe79bd3109b824e473a1dc5f74f31fab91bb44c9e245daa77"
dependencies = [ dependencies = [
"boa_gc", "boa_gc",
"boa_macros", "boa_macros",
"hashbrown 0.14.2", "hashbrown 0.14.3",
"indexmap 2.1.0", "indexmap 2.1.0",
"once_cell", "once_cell",
"phf", "phf",
@ -999,9 +999,9 @@ checksum = "3190f92dfe48224adc92881c620f08ccf37ff62b91a094bb357fe53bd5e84647"
[[package]] [[package]]
name = "boyer-moore-magiclen" name = "boyer-moore-magiclen"
version = "0.2.18" version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "116d76fee857b03ecdd95d5f9555e46aa0cd34e5bb348a520e9445d151182a7e" checksum = "854f4a08ebbcc4d3d2b8b3863fdffdc9f2046bb1c43610ff9841a51dd5b70f55"
dependencies = [ dependencies = [
"debug-helper", "debug-helper",
] ]
@ -1239,9 +1239,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.4.8" version = "4.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -1249,9 +1249,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.4.8" version = "4.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -1450,9 +1450,9 @@ dependencies = [
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.3" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -1460,9 +1460,9 @@ dependencies = [
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.4" version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
[[package]] [[package]]
name = "cpp_demangle" name = "cpp_demangle"
@ -1842,7 +1842,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"hashbrown 0.14.2", "hashbrown 0.14.3",
"lock_api", "lock_api",
"once_cell", "once_cell",
"parking_lot_core 0.9.9", "parking_lot_core 0.9.9",
@ -2328,12 +2328,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.3.7" version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.48.0", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@ -3068,9 +3068,9 @@ dependencies = [
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.14.2" version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
dependencies = [ dependencies = [
"ahash", "ahash",
"allocator-api2", "allocator-api2",
@ -3092,7 +3092,7 @@ version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7"
dependencies = [ dependencies = [
"hashbrown 0.14.2", "hashbrown 0.14.3",
] ]
[[package]] [[package]]
@ -3606,7 +3606,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown 0.14.2", "hashbrown 0.14.3",
"serde", "serde",
] ]
@ -3758,9 +3758,9 @@ dependencies = [
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.65" version = "0.3.66"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca"
dependencies = [ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
@ -4071,7 +4071,7 @@ version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21"
dependencies = [ dependencies = [
"hashbrown 0.14.2", "hashbrown 0.14.3",
] ]
[[package]] [[package]]
@ -4080,7 +4080,7 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7" checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7"
dependencies = [ dependencies = [
"hashbrown 0.14.2", "hashbrown 0.14.3",
] ]
[[package]] [[package]]
@ -4161,9 +4161,9 @@ dependencies = [
[[package]] [[package]]
name = "memmap2" name = "memmap2"
version = "0.8.0" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed" checksum = "deaba38d7abf1d4cca21cc89e932e542ba2b9258664d2a9ef0e61512039c9375"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -4658,9 +4658,9 @@ dependencies = [
[[package]] [[package]]
name = "parity-scale-codec" name = "parity-scale-codec"
version = "3.6.5" version = "3.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bitvec", "bitvec",
@ -4673,11 +4673,11 @@ dependencies = [
[[package]] [[package]]
name = "parity-scale-codec-derive" name = "parity-scale-codec-derive"
version = "3.6.5" version = "3.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b"
dependencies = [ dependencies = [
"proc-macro-crate 1.3.1", "proc-macro-crate 2.0.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",
@ -5143,9 +5143,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.69" version = "1.0.70"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -5921,6 +5921,22 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "reth-ethereum-forks"
version = "0.1.0-alpha.12"
dependencies = [
"alloy-primitives",
"alloy-rlp",
"arbitrary",
"crc",
"proptest",
"proptest-derive",
"rand 0.8.5",
"reth-codecs",
"serde",
"thiserror",
]
[[package]] [[package]]
name = "reth-interfaces" name = "reth-interfaces"
version = "0.1.0-alpha.12" version = "0.1.0-alpha.12"
@ -6177,6 +6193,7 @@ dependencies = [
"rand 0.8.5", "rand 0.8.5",
"rayon", "rayon",
"reth-codecs", "reth-codecs",
"reth-ethereum-forks",
"reth-rpc-types", "reth-rpc-types",
"revm", "revm",
"revm-primitives", "revm-primitives",
@ -6641,7 +6658,7 @@ dependencies = [
"c-kzg", "c-kzg",
"derive_more", "derive_more",
"enumn", "enumn",
"hashbrown 0.14.2", "hashbrown 0.14.3",
"hex", "hex",
"once_cell", "once_cell",
"serde", "serde",
@ -6683,9 +6700,9 @@ dependencies = [
[[package]] [[package]]
name = "ring" name = "ring"
version = "0.17.5" version = "0.17.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" checksum = "684d5e6e18f669ccebf64a92236bb7db9a34f07be010e3627368182027180866"
dependencies = [ dependencies = [
"cc", "cc",
"getrandom 0.2.11", "getrandom 0.2.11",
@ -6849,7 +6866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9"
dependencies = [ dependencies = [
"log", "log",
"ring 0.17.5", "ring 0.17.6",
"rustls-webpki", "rustls-webpki",
"sct", "sct",
] ]
@ -6881,7 +6898,7 @@ version = "0.101.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
dependencies = [ dependencies = [
"ring 0.17.5", "ring 0.17.6",
"untrusted 0.9.0", "untrusted 0.9.0",
] ]
@ -7001,7 +7018,7 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
dependencies = [ dependencies = [
"ring 0.17.5", "ring 0.17.6",
"untrusted 0.9.0", "untrusted 0.9.0",
] ]
@ -7492,9 +7509,9 @@ dependencies = [
[[package]] [[package]]
name = "spki" name = "spki"
version = "0.7.2" version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
dependencies = [ dependencies = [
"base64ct", "base64ct",
"der", "der",
@ -7608,21 +7625,21 @@ dependencies = [
[[package]] [[package]]
name = "symbolic-common" name = "symbolic-common"
version = "12.7.0" version = "12.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39eac77836da383d35edbd9ff4585b4fc1109929ff641232f2e9a1aefdfc9e91" checksum = "9ba238da6058509cda85e388e8bf1caf522894ec38da490de9694fab9238c715"
dependencies = [ dependencies = [
"debugid", "debugid",
"memmap2 0.8.0", "memmap2 0.9.0",
"stable_deref_trait", "stable_deref_trait",
"uuid 1.6.1", "uuid 1.6.1",
] ]
[[package]] [[package]]
name = "symbolic-demangle" name = "symbolic-demangle"
version = "12.7.0" version = "12.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ee1608a1d13061fb0e307a316de29f6c6e737b05459fe6bbf5dd8d7837c4fb7" checksum = "9b7f36fed2b0d1f3db882e5edb9d1b6595dd8cc095f52f265b17291f09062b70"
dependencies = [ dependencies = [
"cpp_demangle", "cpp_demangle",
"rustc-demangle", "rustc-demangle",
@ -7653,9 +7670,9 @@ dependencies = [
[[package]] [[package]]
name = "syn-solidity" name = "syn-solidity"
version = "0.5.0" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e349ed2ca56eff703d7c3ea013771bcbab9ad2ad39dddf863fc51d820329dc41" checksum = "cf07302c875aa7e1ee4fb811fdf2a0436bb04640639539003dcab2e049a9d1fe"
dependencies = [ dependencies = [
"paste", "paste",
"proc-macro2", "proc-macro2",
@ -8615,9 +8632,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.88" version = "0.2.89"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"wasm-bindgen-macro", "wasm-bindgen-macro",
@ -8625,9 +8642,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-backend" name = "wasm-bindgen-backend"
version = "0.2.88" version = "0.2.89"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"log", "log",
@ -8640,9 +8657,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-futures" name = "wasm-bindgen-futures"
version = "0.4.38" version = "0.4.39"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"js-sys", "js-sys",
@ -8652,9 +8669,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.88" version = "0.2.89"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2"
dependencies = [ dependencies = [
"quote", "quote",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
@ -8662,9 +8679,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro-support" name = "wasm-bindgen-macro-support"
version = "0.2.88" version = "0.2.89"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -8675,9 +8692,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-shared" name = "wasm-bindgen-shared"
version = "0.2.88" version = "0.2.89"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f"
[[package]] [[package]]
name = "wasm-streams" name = "wasm-streams"
@ -8694,9 +8711,9 @@ dependencies = [
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.65" version = "0.3.66"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
@ -8800,6 +8817,15 @@ dependencies = [
"windows-targets 0.48.5", "windows-targets 0.48.5",
] ]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.0",
]
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"
version = "0.42.2" version = "0.42.2"
@ -8830,6 +8856,21 @@ dependencies = [
"windows_x86_64_msvc 0.48.5", "windows_x86_64_msvc 0.48.5",
] ]
[[package]]
name = "windows-targets"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
"windows_aarch64_gnullvm 0.52.0",
"windows_aarch64_msvc 0.52.0",
"windows_i686_gnu 0.52.0",
"windows_i686_msvc 0.52.0",
"windows_x86_64_gnu 0.52.0",
"windows_x86_64_gnullvm 0.52.0",
"windows_x86_64_msvc 0.52.0",
]
[[package]] [[package]]
name = "windows_aarch64_gnullvm" name = "windows_aarch64_gnullvm"
version = "0.42.2" version = "0.42.2"
@ -8842,6 +8883,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.42.2" version = "0.42.2"
@ -8854,6 +8901,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.42.2" version = "0.42.2"
@ -8866,6 +8919,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.42.2" version = "0.42.2"
@ -8878,6 +8937,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.42.2" version = "0.42.2"
@ -8890,6 +8955,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.42.2" version = "0.42.2"
@ -8902,6 +8973,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.42.2" version = "0.42.2"
@ -8914,6 +8991,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.5.19" version = "0.5.19"
@ -9029,18 +9112,18 @@ dependencies = [
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.7.26" version = "0.7.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" checksum = "f43de342578a3a14a9314a2dab1942cbfcbe5686e1f91acdc513058063eafe18"
dependencies = [ dependencies = [
"zerocopy-derive", "zerocopy-derive",
] ]
[[package]] [[package]]
name = "zerocopy-derive" name = "zerocopy-derive"
version = "0.7.26" version = "0.7.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" checksum = "e1012d89e3acb79fad7a799ce96866cfb8098b74638465ea1b1533d35900ca90"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -6,6 +6,7 @@ members = [
"crates/consensus/auto-seal/", "crates/consensus/auto-seal/",
"crates/consensus/beacon/", "crates/consensus/beacon/",
"crates/consensus/common/", "crates/consensus/common/",
"crates/ethereum-forks/",
"crates/interfaces/", "crates/interfaces/",
"crates/metrics/", "crates/metrics/",
"crates/metrics/metrics-derive/", "crates/metrics/metrics-derive/",
@ -102,6 +103,7 @@ reth-dns-discovery = { path = "crates/net/dns" }
reth-downloaders = { path = "crates/net/downloaders" } reth-downloaders = { path = "crates/net/downloaders" }
reth-ecies = { path = "crates/net/ecies" } reth-ecies = { path = "crates/net/ecies" }
reth-eth-wire = { path = "crates/net/eth-wire" } reth-eth-wire = { path = "crates/net/eth-wire" }
reth-ethereum-forks = { path = "crates/ethereum-forks" }
reth-interfaces = { path = "crates/interfaces" } reth-interfaces = { path = "crates/interfaces" }
reth-ipc = { path = "crates/rpc/ipc" } reth-ipc = { path = "crates/rpc/ipc" }
reth-libmdbx = { path = "crates/storage/libmdbx-rs" } reth-libmdbx = { path = "crates/storage/libmdbx-rs" }

View File

@ -0,0 +1,41 @@
[package]
name = "reth-ethereum-forks"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
description = "Ethereum fork types used in reth."
[dependencies]
# reth
reth-codecs.workspace = true
# ethereum
alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
alloy-rlp = { workspace = true, features = ["arrayvec"] }
# used for forkid
crc = "3"
# misc
serde.workspace = true
thiserror.workspace = true
# arbitrary utils
arbitrary = { workspace = true, features = ["derive"], optional = true }
proptest = { workspace = true, optional = true }
proptest-derive = { workspace = true, optional = true }
[dev-dependencies]
rand.workspace = true
arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
proptest-derive.workspace = true
[features]
arbitrary = ["dep:arbitrary", "dep:proptest", "dep:proptest-derive"]
optimism = ["reth-codecs/optimism"]

View File

@ -2,9 +2,8 @@
//! //!
//! Previously version of Apache licenced [`ethereum-forkid`](https://crates.io/crates/ethereum-forkid). //! Previously version of Apache licenced [`ethereum-forkid`](https://crates.io/crates/ethereum-forkid).
#![deny(missing_docs)] use crate::Head;
use alloy_primitives::{hex, BlockNumber, B256};
use crate::{hex, BlockNumber, Head, B256};
use alloy_rlp::*; use alloy_rlp::*;
use crc::*; use crc::*;
use reth_codecs::derive_arbitrary; use reth_codecs::derive_arbitrary;
@ -72,10 +71,12 @@ where
} }
} }
// TODO: Move /// How to filter forks.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub enum ForkFilterKey { pub enum ForkFilterKey {
/// By block number activation.
Block(BlockNumber), Block(BlockNumber),
/// By timestamp activation.
Time(u64), Time(u64),
} }
@ -379,7 +380,7 @@ impl Cache {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{hex_literal::hex, revm_primitives::b256}; use alloy_primitives::b256;
const GENESIS_HASH: B256 = const GENESIS_HASH: B256 =
b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"); b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3");

View File

@ -1,6 +1,5 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ChainSpec, ForkCondition, ForkFilter, ForkId};
use std::{fmt::Display, str::FromStr}; use std::{fmt::Display, str::FromStr};
/// The name of an Ethereum hardfork. /// The name of an Ethereum hardfork.
@ -52,25 +51,6 @@ pub enum Hardfork {
Cancun, Cancun,
} }
impl Hardfork {
/// Get the [ForkId] for this hardfork in the given spec, if the fork is activated at any point.
pub fn fork_id(&self, spec: &ChainSpec) -> Option<ForkId> {
match spec.fork(*self) {
ForkCondition::Never => None,
_ => Some(spec.fork_id(&spec.satisfy(spec.fork(*self)))),
}
}
/// Get the [ForkFilter] for this hardfork in the given spec, if the fork is activated at any
/// point.
pub fn fork_filter(&self, spec: &ChainSpec) -> Option<ForkFilter> {
match spec.fork(*self) {
ForkCondition::Never => None,
_ => Some(spec.fork_filter(spec.satisfy(spec.fork(*self)))),
}
}
}
impl FromStr for Hardfork { impl FromStr for Hardfork {
type Err = String; type Err = String;
@ -115,8 +95,6 @@ impl Display for Hardfork {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{Chain, Genesis};
use std::collections::BTreeMap;
#[test] #[test]
fn check_hardfork_from_str() { fn check_hardfork_from_str() {
@ -181,34 +159,4 @@ mod tests {
fn check_nonexistent_hardfork_from_str() { fn check_nonexistent_hardfork_from_str() {
assert!(Hardfork::from_str("not a hardfork").is_err()); assert!(Hardfork::from_str("not a hardfork").is_err());
} }
#[test]
fn check_fork_id_chainspec_with_fork_condition_never() {
let spec = ChainSpec {
chain: Chain::mainnet(),
genesis: Genesis::default(),
genesis_hash: None,
hardforks: BTreeMap::from([(Hardfork::Frontier, ForkCondition::Never)]),
paris_block_and_final_difficulty: None,
deposit_contract: None,
..Default::default()
};
assert_eq!(Hardfork::Frontier.fork_id(&spec), None);
}
#[test]
fn check_fork_filter_chainspec_with_fork_condition_never() {
let spec = ChainSpec {
chain: Chain::mainnet(),
genesis: Genesis::default(),
genesis_hash: None,
hardforks: BTreeMap::from([(Hardfork::Shanghai, ForkCondition::Never)]),
paris_block_and_final_difficulty: None,
deposit_contract: None,
..Default::default()
};
assert_eq!(Hardfork::Shanghai.fork_filter(&spec), None);
}
} }

View File

@ -0,0 +1,24 @@
use alloy_primitives::{BlockNumber, B256, U256};
use serde::{Deserialize, Serialize};
/// Describes the current head block.
///
/// The head block is the highest fully synced block.
///
/// Note: This is a slimmed down version of Header, primarily for communicating the highest block
/// with the P2P network and the RPC.
#[derive(
Debug, Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize,
)]
pub struct Head {
/// The number of the head block.
pub number: BlockNumber,
/// The hash of the head block.
pub hash: B256,
/// The difficulty of the head block.
pub difficulty: U256,
/// The total difficulty at the head block.
pub total_difficulty: U256,
/// The timestamp of the head block.
pub timestamp: u64,
}

View File

@ -0,0 +1,28 @@
//! Ethereum fork types used in reth.
//!
//! This crate contains Ethereum fork types and helper functions.
//!
//! ## Feature Flags
//!
//! - `arbitrary`: Adds `proptest` and `arbitrary` support for primitive types.
#![doc(
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
#![warn(missing_debug_implementations, missing_docs, unreachable_pub, rustdoc::all)]
#![deny(unused_must_use, rust_2018_idioms, unused_crate_dependencies)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![allow(clippy::non_canonical_clone_impl)]
mod forkid;
mod hardfork;
mod head;
pub use forkid::{ForkFilter, ForkFilterKey, ForkHash, ForkId, ForkTransition, ValidationError};
pub use hardfork::Hardfork;
pub use head::Head;
#[cfg(any(test, feature = "arbitrary"))]
pub use arbitrary;

View File

@ -462,7 +462,7 @@ mod tests {
let mut builder = EnrBuilder::new("v4"); let mut builder = EnrBuilder::new("v4");
let mut buf = Vec::new(); let mut buf = Vec::new();
let fork_id = Hardfork::Frontier.fork_id(&MAINNET).unwrap(); let fork_id = MAINNET.hardfork_fork_id(Hardfork::Frontier).unwrap();
fork_id.encode(&mut buf); fork_id.encode(&mut buf);
builder.ip4(Ipv4Addr::LOCALHOST).udp4(30303).tcp4(30303).add_value(b"eth", &buf); builder.ip4(Ipv4Addr::LOCALHOST).udp4(30303).tcp4(30303).add_value(b"eth", &buf);
let enr = builder.build(&secret_key).unwrap(); let enr = builder.build(&secret_key).unwrap();

View File

@ -17,7 +17,7 @@ use reth_primitives::{Chain, ForkId, B256, U256};
/// .total_difficulty(U256::from(100)) /// .total_difficulty(U256::from(100))
/// .blockhash(B256::from(MAINNET_GENESIS_HASH)) /// .blockhash(B256::from(MAINNET_GENESIS_HASH))
/// .genesis(B256::from(MAINNET_GENESIS_HASH)) /// .genesis(B256::from(MAINNET_GENESIS_HASH))
/// .forkid(Hardfork::Paris.fork_id(&MAINNET).unwrap()) /// .forkid(MAINNET.hardfork_fork_id(Hardfork::Paris).unwrap())
/// .build(); /// .build();
/// ///
/// assert_eq!( /// assert_eq!(
@ -28,7 +28,7 @@ use reth_primitives::{Chain, ForkId, B256, U256};
/// total_difficulty: U256::from(100), /// total_difficulty: U256::from(100),
/// blockhash: B256::from(MAINNET_GENESIS_HASH), /// blockhash: B256::from(MAINNET_GENESIS_HASH),
/// genesis: B256::from(MAINNET_GENESIS_HASH), /// genesis: B256::from(MAINNET_GENESIS_HASH),
/// forkid: Hardfork::Paris.fork_id(&MAINNET).unwrap(), /// forkid: MAINNET.hardfork_fork_id(Hardfork::Paris).unwrap(),
/// } /// }
/// ); /// );
/// ``` /// ```

View File

@ -137,8 +137,8 @@ impl Default for Status {
total_difficulty: U256::from(17_179_869_184u64), total_difficulty: U256::from(17_179_869_184u64),
blockhash: mainnet_genesis, blockhash: mainnet_genesis,
genesis: mainnet_genesis, genesis: mainnet_genesis,
forkid: Hardfork::Frontier forkid: MAINNET
.fork_id(&MAINNET) .hardfork_fork_id(Hardfork::Frontier)
.expect("The Frontier hardfork should always exist"), .expect("The Frontier hardfork should always exist"),
} }
} }

View File

@ -926,8 +926,8 @@ mod tests {
secret_key, secret_key,
local_peer_id, local_peer_id,
status: StatusBuilder::default().build(), status: StatusBuilder::default().build(),
fork_filter: Hardfork::Frontier fork_filter: MAINNET
.fork_filter(&MAINNET) .hardfork_fork_filter(Hardfork::Frontier)
.expect("The Frontier fork filter should exist on mainnet"), .expect("The Frontier fork filter should exist on mainnet"),
bandwidth_meter: BandwidthMeter::default(), bandwidth_meter: BandwidthMeter::default(),
} }

View File

@ -2,18 +2,19 @@
name = "reth-primitives" name = "reth-primitives"
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true homepage.workspace = true
license.workspace = true
repository.workspace = true repository.workspace = true
rust-version.workspace = true
description = "Commonly used types in reth." description = "Commonly used types in reth."
[dependencies] [dependencies]
# reth # reth
reth-codecs.workspace = true reth-codecs.workspace = true
reth-ethereum-forks.workspace = true
reth-rpc-types.workspace = true reth-rpc-types.workspace = true
revm-primitives.workspace = true
revm.workspace = true revm.workspace = true
revm-primitives.workspace = true
# ethereum # ethereum
alloy-primitives = { workspace = true, features = ["rand", "rlp"] } alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
@ -33,28 +34,28 @@ crc = "3"
tracing.workspace = true tracing.workspace = true
# misc # misc
bytes.workspace = true
byteorder = "1" byteorder = "1"
bytes.workspace = true
clap = { workspace = true, features = ["derive"], optional = true } clap = { workspace = true, features = ["derive"], optional = true }
derive_more = "0.99"
itertools = "0.11"
modular-bitfield = "0.11.2"
num_enum = "0.7"
once_cell.workspace = true
rayon.workspace = true
serde.workspace = true serde.workspace = true
serde_json.workspace = true serde_json.workspace = true
serde_with = "3.3.0" serde_with = "3.3.0"
thiserror.workspace = true
sucds = "~0.6"
modular-bitfield = "0.11.2"
derive_more = "0.99"
url = "2.3"
once_cell.workspace = true
zstd = { version = "0.12", features = ["experimental"] }
rayon.workspace = true
tempfile.workspace = true
sha2 = "0.10.7" sha2 = "0.10.7"
itertools = "0.11" sucds = "~0.6"
num_enum = "0.7" tempfile.workspace = true
thiserror.workspace = true
url = "2.3"
zstd = { version = "0.12", features = ["experimental"] }
# `test-utils` feature # `test-utils` feature
plain_hasher = { version = "0.2", optional = true }
hash-db = { version = "~0.15", optional = true } hash-db = { version = "~0.15", optional = true }
plain_hasher = { version = "0.2", optional = true }
# arbitrary utils # arbitrary utils
arbitrary = { workspace = true, features = ["derive"], optional = true } arbitrary = { workspace = true, features = ["derive"], optional = true }
@ -63,32 +64,39 @@ proptest-derive = { workspace = true, optional = true }
strum = { workspace = true, features = ["derive"] } strum = { workspace = true, features = ["derive"] }
[dev-dependencies] [dev-dependencies]
serde_json.workspace = true
test-fuzz = "4"
rand.workspace = true
revm-primitives = { workspace = true, features = ["arbitrary"] }
arbitrary = { workspace = true, features = ["derive"] } arbitrary = { workspace = true, features = ["derive"] }
assert_matches.workspace = true
proptest.workspace = true proptest.workspace = true
proptest-derive.workspace = true proptest-derive.workspace = true
assert_matches.workspace = true rand.workspace = true
revm-primitives = { workspace = true, features = ["arbitrary"] }
serde_json.workspace = true
test-fuzz = "4"
toml.workspace = true toml.workspace = true
triehash = "0.8" triehash = "0.8"
plain_hasher = "0.2"
hash-db = "~0.15" hash-db = "~0.15"
plain_hasher = "0.2"
# necessary so we don't hit a "undeclared 'std'": # necessary so we don't hit a "undeclared 'std'":
# https://github.com/paradigmxyz/reth/pull/177#discussion_r1021172198 # https://github.com/paradigmxyz/reth/pull/177#discussion_r1021172198
secp256k1.workspace = true
criterion.workspace = true criterion.workspace = true
pprof = { workspace = true, features = ["flamegraph", "frame-pointer", "criterion"] } pprof = { workspace = true, features = ["flamegraph", "frame-pointer", "criterion"] }
secp256k1.workspace = true
[features] [features]
default = ["c-kzg"] default = ["c-kzg"]
arbitrary = ["revm-primitives/arbitrary", "reth-rpc-types/arbitrary", "dep:arbitrary", "dep:proptest", "dep:proptest-derive"] arbitrary = [
"revm-primitives/arbitrary",
"reth-rpc-types/arbitrary",
"reth-ethereum-forks/arbitrary",
"dep:arbitrary",
"dep:proptest",
"dep:proptest-derive",
]
c-kzg = ["dep:c-kzg", "revm/c-kzg", "revm-primitives/c-kzg"] c-kzg = ["dep:c-kzg", "revm/c-kzg", "revm-primitives/c-kzg"]
clap = ["dep:clap"] clap = ["dep:clap"]
optimism = ["reth-codecs/optimism", "revm-primitives/optimism", "revm/optimism"] optimism = ["reth-codecs/optimism", "revm-primitives/optimism", "reth-ethereum-forks/optimism", "revm/optimism"]
test-utils = ["dep:plain_hasher", "dep:hash-db", "dep:ethers-core"] test-utils = ["dep:plain_hasher", "dep:hash-db", "dep:ethers-core"]
[[bench]] [[bench]]

View File

@ -3,12 +3,10 @@ use crate::{
EIP1559_DEFAULT_BASE_FEE_MAX_CHANGE_DENOMINATOR, EIP1559_DEFAULT_ELASTICITY_MULTIPLIER, EIP1559_DEFAULT_BASE_FEE_MAX_CHANGE_DENOMINATOR, EIP1559_DEFAULT_ELASTICITY_MULTIPLIER,
EIP1559_INITIAL_BASE_FEE, EMPTY_RECEIPTS, EMPTY_TRANSACTIONS, EMPTY_WITHDRAWALS, EIP1559_INITIAL_BASE_FEE, EMPTY_RECEIPTS, EMPTY_TRANSACTIONS, EMPTY_WITHDRAWALS,
}, },
forkid::ForkFilterKey,
header::Head,
proofs::genesis_state_root, proofs::genesis_state_root,
revm_primitives::{address, b256}, revm_primitives::{address, b256},
Address, BlockNumber, Chain, ForkFilter, ForkHash, ForkId, Genesis, Hardfork, Header, Address, BlockNumber, Chain, ForkFilter, ForkFilterKey, ForkHash, ForkId, Genesis, Hardfork,
SealedHeader, B256, EMPTY_OMMER_ROOT_HASH, U256, Head, Header, SealedHeader, B256, EMPTY_OMMER_ROOT_HASH, U256,
}; };
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -561,6 +559,7 @@ impl ChainSpec {
} }
/// Returns `true` if this chain contains Optimism configuration. /// Returns `true` if this chain contains Optimism configuration.
#[inline]
pub fn is_optimism(&self) -> bool { pub fn is_optimism(&self) -> bool {
self.chain.is_optimism() self.chain.is_optimism()
} }
@ -671,6 +670,7 @@ impl ChainSpec {
/// ///
/// Note: technically this would also be valid for the block before the paris upgrade, but this /// Note: technically this would also be valid for the block before the paris upgrade, but this
/// edge case is omitted here. /// edge case is omitted here.
#[inline]
pub fn final_paris_total_difficulty(&self, block_number: u64) -> Option<U256> { pub fn final_paris_total_difficulty(&self, block_number: u64) -> Option<U256> {
self.paris_block_and_final_difficulty.and_then(|(activated_at, final_difficulty)| { self.paris_block_and_final_difficulty.and_then(|(activated_at, final_difficulty)| {
if block_number >= activated_at { if block_number >= activated_at {
@ -681,19 +681,38 @@ impl ChainSpec {
}) })
} }
/// Get the fork filter for the given hardfork
pub fn hardfork_fork_filter(&self, fork: Hardfork) -> Option<ForkFilter> {
match self.fork(fork) {
ForkCondition::Never => None,
_ => Some(self.fork_filter(self.satisfy(self.fork(fork)))),
}
}
/// Returns the forks in this specification and their activation conditions. /// Returns the forks in this specification and their activation conditions.
pub fn hardforks(&self) -> &BTreeMap<Hardfork, ForkCondition> { pub fn hardforks(&self) -> &BTreeMap<Hardfork, ForkCondition> {
&self.hardforks &self.hardforks
} }
/// Get the fork id for the given hardfork. /// Get the fork id for the given hardfork.
#[inline]
pub fn hardfork_fork_id(&self, fork: Hardfork) -> Option<ForkId> { pub fn hardfork_fork_id(&self, fork: Hardfork) -> Option<ForkId> {
fork.fork_id(self) match self.fork(fork) {
ForkCondition::Never => None,
_ => Some(self.fork_id(&self.satisfy(self.fork(fork)))),
}
} }
/// Convenience method to get the fork id for [Hardfork::Shanghai] from a given chainspec. /// Convenience method to get the fork id for [Hardfork::Shanghai] from a given chainspec.
#[inline]
pub fn shanghai_fork_id(&self) -> Option<ForkId> { pub fn shanghai_fork_id(&self) -> Option<ForkId> {
Hardfork::Shanghai.fork_id(self) self.hardfork_fork_id(Hardfork::Shanghai)
}
/// Convenience method to get the fork id for [Hardfork::Cancun] from a given chainspec.
#[inline]
pub fn cancun_fork_id(&self) -> Option<ForkId> {
self.hardfork_fork_id(Hardfork::Cancun)
} }
/// Get the fork condition for the given fork. /// Get the fork condition for the given fork.
@ -2749,4 +2768,34 @@ Post-merge hard forks (timestamp based):
serde_json::from_str(&serialized_chain_spec).unwrap(); serde_json::from_str(&serialized_chain_spec).unwrap();
assert!(matches!(deserialized_chain_spec, AllGenesisFormats::Reth(_))) assert!(matches!(deserialized_chain_spec, AllGenesisFormats::Reth(_)))
} }
#[test]
fn check_fork_id_chainspec_with_fork_condition_never() {
let spec = ChainSpec {
chain: Chain::mainnet(),
genesis: Genesis::default(),
genesis_hash: None,
hardforks: BTreeMap::from([(Hardfork::Frontier, ForkCondition::Never)]),
paris_block_and_final_difficulty: None,
deposit_contract: None,
..Default::default()
};
assert_eq!(spec.hardfork_fork_id(Hardfork::Frontier), None);
}
#[test]
fn check_fork_filter_chainspec_with_fork_condition_never() {
let spec = ChainSpec {
chain: Chain::mainnet(),
genesis: Genesis::default(),
genesis_hash: None,
hardforks: BTreeMap::from([(Hardfork::Shanghai, ForkCondition::Never)]),
paris_block_and_final_difficulty: None,
deposit_contract: None,
..Default::default()
};
assert_eq!(spec.hardfork_fork_filter(Hardfork::Shanghai), None);
}
} }

View File

@ -14,28 +14,6 @@ use std::{
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
}; };
/// Describes the current head block.
///
/// The head block is the highest fully synced block.
///
/// Note: This is a slimmed down version of [Header], primarily for communicating the highest block
/// with the P2P network and the RPC.
#[derive(
Debug, Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize,
)]
pub struct Head {
/// The number of the head block.
pub number: BlockNumber,
/// The hash of the head block.
pub hash: B256,
/// The difficulty of the head block.
pub difficulty: U256,
/// The total difficulty at the head block.
pub total_difficulty: U256,
/// The timestamp of the head block.
pub timestamp: u64,
}
/// Block header /// Block header
#[main_codec] #[main_codec]
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]

View File

@ -25,10 +25,8 @@ mod compression;
pub mod constants; pub mod constants;
pub mod eip4844; pub mod eip4844;
mod error; mod error;
mod forkid;
pub mod fs; pub mod fs;
mod genesis; mod genesis;
mod hardfork;
mod header; mod header;
mod integer_list; mod integer_list;
mod log; mod log;
@ -67,10 +65,8 @@ pub use constants::{
KECCAK_EMPTY, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH, KECCAK_EMPTY, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH,
}; };
pub use error::{GotExpected, GotExpectedBoxed}; pub use error::{GotExpected, GotExpectedBoxed};
pub use forkid::{ForkFilter, ForkHash, ForkId, ForkTransition, ValidationError};
pub use genesis::{ChainConfig, Genesis, GenesisAccount}; pub use genesis::{ChainConfig, Genesis, GenesisAccount};
pub use hardfork::Hardfork; pub use header::{Header, HeadersDirection, SealedHeader};
pub use header::{Head, Header, HeadersDirection, SealedHeader};
pub use integer_list::IntegerList; pub use integer_list::IntegerList;
pub use log::{logs_bloom, Log}; pub use log::{logs_bloom, Log};
pub use net::{ pub use net::{
@ -113,6 +109,7 @@ pub use alloy_primitives::{
Address, BlockHash, BlockNumber, Bloom, BloomInput, Bytes, ChainId, Selector, StorageKey, Address, BlockHash, BlockNumber, Bloom, BloomInput, Bytes, ChainId, Selector, StorageKey,
StorageValue, TxHash, TxIndex, TxNumber, B128, B256, B512, B64, U128, U256, U64, U8, StorageValue, TxHash, TxIndex, TxNumber, B128, B256, B512, B64, U128, U256, U64, U8,
}; };
pub use reth_ethereum_forks::*;
pub use revm_primitives::{self, JumpMap}; pub use revm_primitives::{self, JumpMap};
#[doc(hidden)] #[doc(hidden)]

View File

@ -102,7 +102,7 @@ async fn handshake_eth(p2p_stream: AuthedP2PStream) -> eyre::Result<(AuthedEthSt
let status = Status::builder() let status = Status::builder()
.chain(Chain::mainnet()) .chain(Chain::mainnet())
.genesis(MAINNET_GENESIS_HASH) .genesis(MAINNET_GENESIS_HASH)
.forkid(Hardfork::Shanghai.fork_id(&MAINNET).unwrap()) .forkid(MAINNET.hardfork_fork_id(Hardfork::Shanghai).unwrap())
.build(); .build();
let status = Status { version: p2p_stream.shared_capabilities().eth()?.version(), ..status }; let status = Status { version: p2p_stream.shared_capabilities().eth()?.version(), ..status };