feat: config (#496)

* feat: default reth dirs

* docs: clarify txpool config docs

* feat: `serde` feature for `reth-consensus`

* feat: add missing hardforks

* feat: full chain specification

* feat: `DbPath` type

* feat: custom chain specs

* feat: `--debug.tip` option

* feat: basic stage config

* fix: resize db geometry

* refactor: don't commit in headers stage

* chore: remove headers dl timeout

* feat: loading of config

* refactor(config): `stage` -> `stages`
This commit is contained in:
Bjerg
2022-12-19 21:27:26 +01:00
committed by GitHub
parent 516d744bdd
commit 13bb41517d
21 changed files with 1356 additions and 140 deletions

113
Cargo.lock generated
View File

@ -88,9 +88,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
[[package]]
name = "anyhow"
version = "1.0.66"
version = "1.0.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
checksum = "7724808837b77f4b4de9d283820f9d98bcf496d5692934b857a2399d31ff22e6"
[[package]]
name = "aquamarine"
@ -144,9 +144,9 @@ dependencies = [
[[package]]
name = "async-trait"
version = "0.1.59"
version = "0.1.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364"
checksum = "677d1d8ab452a3936018a687b20e6f7cf5363d713b732b8884001317b0e48aa3"
dependencies = [
"proc-macro2",
"quote",
@ -395,7 +395,7 @@ checksum = "982a0cf6a99c350d7246035613882e376d58cebe571785abc5da4f648d53ac0a"
dependencies = [
"camino",
"cargo-platform",
"semver 1.0.14",
"semver 1.0.15",
"serde",
"serde_json",
"thiserror",
@ -570,6 +570,18 @@ dependencies = [
"syn",
]
[[package]]
name = "confy"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e37668cb35145dcfaa1931a5f37fde375eeae8068b4c0d2f289da28a270b2d2c"
dependencies = [
"directories",
"serde",
"thiserror",
"toml",
]
[[package]]
name = "const-oid"
version = "0.9.1"
@ -938,6 +950,15 @@ dependencies = [
"subtle",
]
[[package]]
name = "directories"
version = "4.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs"
version = "4.0.0"
@ -947,6 +968,16 @@ dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
dependencies = [
"cfg-if",
"dirs-sys-next",
]
[[package]]
name = "dirs-sys"
version = "0.3.7"
@ -958,6 +989,17 @@ dependencies = [
"winapi",
]
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]]
name = "discv5"
version = "0.1.0"
@ -2033,9 +2075,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "1.0.4"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
[[package]]
name = "js-sys"
@ -2790,9 +2832,9 @@ dependencies = [
[[package]]
name = "paste"
version = "1.0.10"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1c2c742266c2f1041c914ba65355a83ae8747b05f208319784083583494b4b"
checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"
[[package]]
name = "peeking_take_while"
@ -2991,9 +3033,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.47"
version = "1.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
checksum = "e9d89e5dba24725ae5678020bf8f1357a9aa7ff10736b551adbcd3f8d17d766f"
dependencies = [
"unicode-ident",
]
@ -3037,9 +3079,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.21"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
checksum = "556d0f47a940e895261e77dc200d5eadfc6ef644c179c6f5edfc105e3a2292c8"
dependencies = [
"proc-macro2",
]
@ -3265,6 +3307,8 @@ name = "reth"
version = "0.1.0"
dependencies = [
"clap 4.0.29",
"confy",
"dirs-next",
"eyre",
"futures",
"metrics-exporter-prometheus",
@ -3315,6 +3359,7 @@ dependencies = [
"reth-primitives",
"reth-provider",
"reth-rlp",
"serde",
"thiserror",
"tokio",
]
@ -3902,7 +3947,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver 1.0.14",
"semver 1.0.15",
]
[[package]]
@ -3954,15 +3999,15 @@ dependencies = [
[[package]]
name = "rustversion"
version = "1.0.9"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
checksum = "4378ea89513870b6e2303ec50618e97da0fa43cdd9ded83ad3b6bad2693c08c6"
[[package]]
name = "ryu"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
[[package]]
name = "same-file"
@ -4090,9 +4135,9 @@ dependencies = [
[[package]]
name = "semver"
version = "1.0.14"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4"
checksum = "3bfa246f936730408c0abee392cc1a50b118ece708c7f630516defd64480c7d8"
dependencies = [
"serde",
]
@ -4120,18 +4165,18 @@ checksum = "930c0acf610d3fdb5e2ab6213019aaa04e227ebe9547b0649ba599b16d788bd7"
[[package]]
name = "serde"
version = "1.0.150"
version = "1.0.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e326c9ec8042f1b5da33252c8a37e9ffbd2c9bef0155215b6e6c80c790e05f91"
checksum = "97fed41fc1a24994d044e6db6935e69511a1153b52c15eb42493b26fa87feba0"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.150"
version = "1.0.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42a3df25b0713732468deadad63ab9da1f1fd75a48a15024b50363f128db627e"
checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8"
dependencies = [
"proc-macro2",
"quote",
@ -4140,9 +4185,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.89"
version = "1.0.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
checksum = "8778cc0b528968fe72abec38b5db5a20a70d148116cd9325d2bc5f5180ca3faf"
dependencies = [
"itoa",
"ryu",
@ -4460,9 +4505,9 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.105"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908"
checksum = "09ee3a69cd2c7e06684677e5629b3878b253af05e4714964204279c6bc02cf0b"
dependencies = [
"proc-macro2",
"quote",
@ -4575,18 +4620,18 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
[[package]]
name = "thiserror"
version = "1.0.37"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.37"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f"
dependencies = [
"proc-macro2",
"quote",
@ -4972,9 +5017,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
[[package]]
name = "unicode-ident"
version = "1.0.5"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
[[package]]
name = "unicode-normalization"

View File

@ -9,34 +9,39 @@ readme = "README.md"
[dependencies]
# reth
reth-primitives = { path = "../../crates/primitives" }
reth-db = {path = "../../crates/storage/db", features = ["mdbx", "test-utils"]}
reth-db = {path = "../../crates/storage/db", features = ["mdbx", "test-utils"] }
# TODO: Temporary use of the test-utils feature
reth-provider = {path = "../../crates/storage/provider", features = ["test-utils"]}
reth-stages = {path = "../../crates/stages"}
reth-interfaces = {path = "../../crates/interfaces", features = ["test-utils"] }
reth-transaction-pool = {path = "../../crates/transaction-pool"}
reth-consensus = {path = "../../crates/consensus"}
reth-executor = { path = "../../crates/executor"}
reth-provider = { path = "../../crates/storage/provider", features = ["test-utils"] }
reth-stages = { path = "../../crates/stages"}
reth-interfaces = { path = "../../crates/interfaces", features = ["test-utils"] }
reth-transaction-pool = { path = "../../crates/transaction-pool" }
reth-consensus = { path = "../../crates/consensus", features = ["serde"] }
reth-executor = { path = "../../crates/executor" }
reth-rpc = {path = "../../crates/net/rpc"}
reth-rlp = { path = "../../crates/common/rlp" }
reth-network = {path = "../../crates/net/network"}
reth-downloaders = {path = "../../crates/net/downloaders"}
reth-network = {path = "../../crates/net/network" }
reth-downloaders = {path = "../../crates/net/downloaders" }
# tracing
tracing = "0.1"
tracing-futures = "0.2"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
# misc
# io
walkdir = "2.3"
serde = "1.0"
serde_json = "1.0"
shellexpand = "2.1"
dirs-next = "2.0.0"
confy = "0.5"
# rpc/metrics
metrics-exporter-prometheus = { version = "0.11.0", features = ["http-listener"] }
metrics-util = "0.14.0"
# misc
eyre = "0.6.8"
clap = { version = "4.0", features = ["derive", "cargo"] }
thiserror = "1.0"
tokio = { version = "1.21", features = ["sync", "macros", "rt-multi-thread"] }
serde = "1.0"
serde_json = "1.0"
walkdir = "2.3"
futures = "0.3.25"
metrics-exporter-prometheus = { version = "0.11.0", features = ["http-listener"] }
metrics-util = "0.14.0"

View File

@ -0,0 +1,810 @@
{
"config": {
"chainId": 5,
"homesteadBlock": 0,
"daoForkSupport": true,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 1561651,
"berlinBlock": 4460644,
"londonBlock": 5062605,
"terminalTotalDifficulty": 10790000
},
"nonce": "0x0",
"timestamp": "0x5c51a607",
"extraData": "0x22466c6578692069732061207468696e6722202d204166726900000000000000e0a2bd4258d2768837baa26a28fe71dc079f84c70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0xa00000",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"stateRoot": "0x5d6cded585e73c4e322c30c2f782a336316f17dd85a4863b9d838d2d4b8b3008",
"alloc": {
"0000000000000000000000000000000000000000": {
"balance": "0x1"
},
"0000000000000000000000000000000000000001": {
"balance": "0x1"
},
"0000000000000000000000000000000000000002": {
"balance": "0x1"
},
"0000000000000000000000000000000000000003": {
"balance": "0x1"
},
"0000000000000000000000000000000000000004": {
"balance": "0x1"
},
"0000000000000000000000000000000000000005": {
"balance": "0x1"
},
"0000000000000000000000000000000000000006": {
"balance": "0x1"
},
"0000000000000000000000000000000000000007": {
"balance": "0x1"
},
"0000000000000000000000000000000000000008": {
"balance": "0x1"
},
"0000000000000000000000000000000000000009": {
"balance": "0x1"
},
"000000000000000000000000000000000000000a": {
"balance": "0x1"
},
"000000000000000000000000000000000000000b": {
"balance": "0x1"
},
"000000000000000000000000000000000000000c": {
"balance": "0x1"
},
"000000000000000000000000000000000000000d": {
"balance": "0x1"
},
"000000000000000000000000000000000000000e": {
"balance": "0x1"
},
"000000000000000000000000000000000000000f": {
"balance": "0x1"
},
"0000000000000000000000000000000000000010": {
"balance": "0x1"
},
"0000000000000000000000000000000000000011": {
"balance": "0x1"
},
"0000000000000000000000000000000000000012": {
"balance": "0x1"
},
"0000000000000000000000000000000000000013": {
"balance": "0x1"
},
"0000000000000000000000000000000000000014": {
"balance": "0x1"
},
"0000000000000000000000000000000000000015": {
"balance": "0x1"
},
"0000000000000000000000000000000000000016": {
"balance": "0x1"
},
"0000000000000000000000000000000000000017": {
"balance": "0x1"
},
"0000000000000000000000000000000000000018": {
"balance": "0x1"
},
"0000000000000000000000000000000000000019": {
"balance": "0x1"
},
"000000000000000000000000000000000000001a": {
"balance": "0x1"
},
"000000000000000000000000000000000000001b": {
"balance": "0x1"
},
"000000000000000000000000000000000000001c": {
"balance": "0x1"
},
"000000000000000000000000000000000000001d": {
"balance": "0x1"
},
"000000000000000000000000000000000000001e": {
"balance": "0x1"
},
"000000000000000000000000000000000000001f": {
"balance": "0x1"
},
"0000000000000000000000000000000000000020": {
"balance": "0x1"
},
"0000000000000000000000000000000000000021": {
"balance": "0x1"
},
"0000000000000000000000000000000000000022": {
"balance": "0x1"
},
"0000000000000000000000000000000000000023": {
"balance": "0x1"
},
"0000000000000000000000000000000000000024": {
"balance": "0x1"
},
"0000000000000000000000000000000000000025": {
"balance": "0x1"
},
"0000000000000000000000000000000000000026": {
"balance": "0x1"
},
"0000000000000000000000000000000000000027": {
"balance": "0x1"
},
"0000000000000000000000000000000000000028": {
"balance": "0x1"
},
"0000000000000000000000000000000000000029": {
"balance": "0x1"
},
"000000000000000000000000000000000000002a": {
"balance": "0x1"
},
"000000000000000000000000000000000000002b": {
"balance": "0x1"
},
"000000000000000000000000000000000000002c": {
"balance": "0x1"
},
"000000000000000000000000000000000000002d": {
"balance": "0x1"
},
"000000000000000000000000000000000000002e": {
"balance": "0x1"
},
"000000000000000000000000000000000000002f": {
"balance": "0x1"
},
"0000000000000000000000000000000000000030": {
"balance": "0x1"
},
"0000000000000000000000000000000000000031": {
"balance": "0x1"
},
"0000000000000000000000000000000000000032": {
"balance": "0x1"
},
"0000000000000000000000000000000000000033": {
"balance": "0x1"
},
"0000000000000000000000000000000000000034": {
"balance": "0x1"
},
"0000000000000000000000000000000000000035": {
"balance": "0x1"
},
"0000000000000000000000000000000000000036": {
"balance": "0x1"
},
"0000000000000000000000000000000000000037": {
"balance": "0x1"
},
"0000000000000000000000000000000000000038": {
"balance": "0x1"
},
"0000000000000000000000000000000000000039": {
"balance": "0x1"
},
"000000000000000000000000000000000000003a": {
"balance": "0x1"
},
"000000000000000000000000000000000000003b": {
"balance": "0x1"
},
"000000000000000000000000000000000000003c": {
"balance": "0x1"
},
"000000000000000000000000000000000000003d": {
"balance": "0x1"
},
"000000000000000000000000000000000000003e": {
"balance": "0x1"
},
"000000000000000000000000000000000000003f": {
"balance": "0x1"
},
"0000000000000000000000000000000000000040": {
"balance": "0x1"
},
"0000000000000000000000000000000000000041": {
"balance": "0x1"
},
"0000000000000000000000000000000000000042": {
"balance": "0x1"
},
"0000000000000000000000000000000000000043": {
"balance": "0x1"
},
"0000000000000000000000000000000000000044": {
"balance": "0x1"
},
"0000000000000000000000000000000000000045": {
"balance": "0x1"
},
"0000000000000000000000000000000000000046": {
"balance": "0x1"
},
"0000000000000000000000000000000000000047": {
"balance": "0x1"
},
"0000000000000000000000000000000000000048": {
"balance": "0x1"
},
"0000000000000000000000000000000000000049": {
"balance": "0x1"
},
"000000000000000000000000000000000000004a": {
"balance": "0x1"
},
"000000000000000000000000000000000000004b": {
"balance": "0x1"
},
"000000000000000000000000000000000000004c": {
"balance": "0x1"
},
"000000000000000000000000000000000000004d": {
"balance": "0x1"
},
"000000000000000000000000000000000000004e": {
"balance": "0x1"
},
"000000000000000000000000000000000000004f": {
"balance": "0x1"
},
"0000000000000000000000000000000000000050": {
"balance": "0x1"
},
"0000000000000000000000000000000000000051": {
"balance": "0x1"
},
"0000000000000000000000000000000000000052": {
"balance": "0x1"
},
"0000000000000000000000000000000000000053": {
"balance": "0x1"
},
"0000000000000000000000000000000000000054": {
"balance": "0x1"
},
"0000000000000000000000000000000000000055": {
"balance": "0x1"
},
"0000000000000000000000000000000000000056": {
"balance": "0x1"
},
"0000000000000000000000000000000000000057": {
"balance": "0x1"
},
"0000000000000000000000000000000000000058": {
"balance": "0x1"
},
"0000000000000000000000000000000000000059": {
"balance": "0x1"
},
"000000000000000000000000000000000000005a": {
"balance": "0x1"
},
"000000000000000000000000000000000000005b": {
"balance": "0x1"
},
"000000000000000000000000000000000000005c": {
"balance": "0x1"
},
"000000000000000000000000000000000000005d": {
"balance": "0x1"
},
"000000000000000000000000000000000000005e": {
"balance": "0x1"
},
"000000000000000000000000000000000000005f": {
"balance": "0x1"
},
"0000000000000000000000000000000000000060": {
"balance": "0x1"
},
"0000000000000000000000000000000000000061": {
"balance": "0x1"
},
"0000000000000000000000000000000000000062": {
"balance": "0x1"
},
"0000000000000000000000000000000000000063": {
"balance": "0x1"
},
"0000000000000000000000000000000000000064": {
"balance": "0x1"
},
"0000000000000000000000000000000000000065": {
"balance": "0x1"
},
"0000000000000000000000000000000000000066": {
"balance": "0x1"
},
"0000000000000000000000000000000000000067": {
"balance": "0x1"
},
"0000000000000000000000000000000000000068": {
"balance": "0x1"
},
"0000000000000000000000000000000000000069": {
"balance": "0x1"
},
"000000000000000000000000000000000000006a": {
"balance": "0x1"
},
"000000000000000000000000000000000000006b": {
"balance": "0x1"
},
"000000000000000000000000000000000000006c": {
"balance": "0x1"
},
"000000000000000000000000000000000000006d": {
"balance": "0x1"
},
"000000000000000000000000000000000000006e": {
"balance": "0x1"
},
"000000000000000000000000000000000000006f": {
"balance": "0x1"
},
"0000000000000000000000000000000000000070": {
"balance": "0x1"
},
"0000000000000000000000000000000000000071": {
"balance": "0x1"
},
"0000000000000000000000000000000000000072": {
"balance": "0x1"
},
"0000000000000000000000000000000000000073": {
"balance": "0x1"
},
"0000000000000000000000000000000000000074": {
"balance": "0x1"
},
"0000000000000000000000000000000000000075": {
"balance": "0x1"
},
"0000000000000000000000000000000000000076": {
"balance": "0x1"
},
"0000000000000000000000000000000000000077": {
"balance": "0x1"
},
"0000000000000000000000000000000000000078": {
"balance": "0x1"
},
"0000000000000000000000000000000000000079": {
"balance": "0x1"
},
"000000000000000000000000000000000000007a": {
"balance": "0x1"
},
"000000000000000000000000000000000000007b": {
"balance": "0x1"
},
"000000000000000000000000000000000000007c": {
"balance": "0x1"
},
"000000000000000000000000000000000000007d": {
"balance": "0x1"
},
"000000000000000000000000000000000000007e": {
"balance": "0x1"
},
"000000000000000000000000000000000000007f": {
"balance": "0x1"
},
"0000000000000000000000000000000000000080": {
"balance": "0x1"
},
"0000000000000000000000000000000000000081": {
"balance": "0x1"
},
"0000000000000000000000000000000000000082": {
"balance": "0x1"
},
"0000000000000000000000000000000000000083": {
"balance": "0x1"
},
"0000000000000000000000000000000000000084": {
"balance": "0x1"
},
"0000000000000000000000000000000000000085": {
"balance": "0x1"
},
"0000000000000000000000000000000000000086": {
"balance": "0x1"
},
"0000000000000000000000000000000000000087": {
"balance": "0x1"
},
"0000000000000000000000000000000000000088": {
"balance": "0x1"
},
"0000000000000000000000000000000000000089": {
"balance": "0x1"
},
"000000000000000000000000000000000000008a": {
"balance": "0x1"
},
"000000000000000000000000000000000000008b": {
"balance": "0x1"
},
"000000000000000000000000000000000000008c": {
"balance": "0x1"
},
"000000000000000000000000000000000000008d": {
"balance": "0x1"
},
"000000000000000000000000000000000000008e": {
"balance": "0x1"
},
"000000000000000000000000000000000000008f": {
"balance": "0x1"
},
"0000000000000000000000000000000000000090": {
"balance": "0x1"
},
"0000000000000000000000000000000000000091": {
"balance": "0x1"
},
"0000000000000000000000000000000000000092": {
"balance": "0x1"
},
"0000000000000000000000000000000000000093": {
"balance": "0x1"
},
"0000000000000000000000000000000000000094": {
"balance": "0x1"
},
"0000000000000000000000000000000000000095": {
"balance": "0x1"
},
"0000000000000000000000000000000000000096": {
"balance": "0x1"
},
"0000000000000000000000000000000000000097": {
"balance": "0x1"
},
"0000000000000000000000000000000000000098": {
"balance": "0x1"
},
"0000000000000000000000000000000000000099": {
"balance": "0x1"
},
"000000000000000000000000000000000000009a": {
"balance": "0x1"
},
"000000000000000000000000000000000000009b": {
"balance": "0x1"
},
"000000000000000000000000000000000000009c": {
"balance": "0x1"
},
"000000000000000000000000000000000000009d": {
"balance": "0x1"
},
"000000000000000000000000000000000000009e": {
"balance": "0x1"
},
"000000000000000000000000000000000000009f": {
"balance": "0x1"
},
"00000000000000000000000000000000000000a0": {
"balance": "0x1"
},
"00000000000000000000000000000000000000a1": {
"balance": "0x1"
},
"00000000000000000000000000000000000000a2": {
"balance": "0x1"
},
"00000000000000000000000000000000000000a3": {
"balance": "0x1"
},
"00000000000000000000000000000000000000a4": {
"balance": "0x1"
},
"00000000000000000000000000000000000000a5": {
"balance": "0x1"
},
"00000000000000000000000000000000000000a6": {
"balance": "0x1"
},
"00000000000000000000000000000000000000a7": {
"balance": "0x1"
},
"00000000000000000000000000000000000000a8": {
"balance": "0x1"
},
"00000000000000000000000000000000000000a9": {
"balance": "0x1"
},
"00000000000000000000000000000000000000aa": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ab": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ac": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ad": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ae": {
"balance": "0x1"
},
"00000000000000000000000000000000000000af": {
"balance": "0x1"
},
"00000000000000000000000000000000000000b0": {
"balance": "0x1"
},
"00000000000000000000000000000000000000b1": {
"balance": "0x1"
},
"00000000000000000000000000000000000000b2": {
"balance": "0x1"
},
"00000000000000000000000000000000000000b3": {
"balance": "0x1"
},
"00000000000000000000000000000000000000b4": {
"balance": "0x1"
},
"00000000000000000000000000000000000000b5": {
"balance": "0x1"
},
"00000000000000000000000000000000000000b6": {
"balance": "0x1"
},
"00000000000000000000000000000000000000b7": {
"balance": "0x1"
},
"00000000000000000000000000000000000000b8": {
"balance": "0x1"
},
"00000000000000000000000000000000000000b9": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ba": {
"balance": "0x1"
},
"00000000000000000000000000000000000000bb": {
"balance": "0x1"
},
"00000000000000000000000000000000000000bc": {
"balance": "0x1"
},
"00000000000000000000000000000000000000bd": {
"balance": "0x1"
},
"00000000000000000000000000000000000000be": {
"balance": "0x1"
},
"00000000000000000000000000000000000000bf": {
"balance": "0x1"
},
"00000000000000000000000000000000000000c0": {
"balance": "0x1"
},
"00000000000000000000000000000000000000c1": {
"balance": "0x1"
},
"00000000000000000000000000000000000000c2": {
"balance": "0x1"
},
"00000000000000000000000000000000000000c3": {
"balance": "0x1"
},
"00000000000000000000000000000000000000c4": {
"balance": "0x1"
},
"00000000000000000000000000000000000000c5": {
"balance": "0x1"
},
"00000000000000000000000000000000000000c6": {
"balance": "0x1"
},
"00000000000000000000000000000000000000c7": {
"balance": "0x1"
},
"00000000000000000000000000000000000000c8": {
"balance": "0x1"
},
"00000000000000000000000000000000000000c9": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ca": {
"balance": "0x1"
},
"00000000000000000000000000000000000000cb": {
"balance": "0x1"
},
"00000000000000000000000000000000000000cc": {
"balance": "0x1"
},
"00000000000000000000000000000000000000cd": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ce": {
"balance": "0x1"
},
"00000000000000000000000000000000000000cf": {
"balance": "0x1"
},
"00000000000000000000000000000000000000d0": {
"balance": "0x1"
},
"00000000000000000000000000000000000000d1": {
"balance": "0x1"
},
"00000000000000000000000000000000000000d2": {
"balance": "0x1"
},
"00000000000000000000000000000000000000d3": {
"balance": "0x1"
},
"00000000000000000000000000000000000000d4": {
"balance": "0x1"
},
"00000000000000000000000000000000000000d5": {
"balance": "0x1"
},
"00000000000000000000000000000000000000d6": {
"balance": "0x1"
},
"00000000000000000000000000000000000000d7": {
"balance": "0x1"
},
"00000000000000000000000000000000000000d8": {
"balance": "0x1"
},
"00000000000000000000000000000000000000d9": {
"balance": "0x1"
},
"00000000000000000000000000000000000000da": {
"balance": "0x1"
},
"00000000000000000000000000000000000000db": {
"balance": "0x1"
},
"00000000000000000000000000000000000000dc": {
"balance": "0x1"
},
"00000000000000000000000000000000000000dd": {
"balance": "0x1"
},
"00000000000000000000000000000000000000de": {
"balance": "0x1"
},
"00000000000000000000000000000000000000df": {
"balance": "0x1"
},
"00000000000000000000000000000000000000e0": {
"balance": "0x1"
},
"00000000000000000000000000000000000000e1": {
"balance": "0x1"
},
"00000000000000000000000000000000000000e2": {
"balance": "0x1"
},
"00000000000000000000000000000000000000e3": {
"balance": "0x1"
},
"00000000000000000000000000000000000000e4": {
"balance": "0x1"
},
"00000000000000000000000000000000000000e5": {
"balance": "0x1"
},
"00000000000000000000000000000000000000e6": {
"balance": "0x1"
},
"00000000000000000000000000000000000000e7": {
"balance": "0x1"
},
"00000000000000000000000000000000000000e8": {
"balance": "0x1"
},
"00000000000000000000000000000000000000e9": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ea": {
"balance": "0x1"
},
"00000000000000000000000000000000000000eb": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ec": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ed": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ee": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ef": {
"balance": "0x1"
},
"00000000000000000000000000000000000000f0": {
"balance": "0x1"
},
"00000000000000000000000000000000000000f1": {
"balance": "0x1"
},
"00000000000000000000000000000000000000f2": {
"balance": "0x1"
},
"00000000000000000000000000000000000000f3": {
"balance": "0x1"
},
"00000000000000000000000000000000000000f4": {
"balance": "0x1"
},
"00000000000000000000000000000000000000f5": {
"balance": "0x1"
},
"00000000000000000000000000000000000000f6": {
"balance": "0x1"
},
"00000000000000000000000000000000000000f7": {
"balance": "0x1"
},
"00000000000000000000000000000000000000f8": {
"balance": "0x1"
},
"00000000000000000000000000000000000000f9": {
"balance": "0x1"
},
"00000000000000000000000000000000000000fa": {
"balance": "0x1"
},
"00000000000000000000000000000000000000fb": {
"balance": "0x1"
},
"00000000000000000000000000000000000000fc": {
"balance": "0x1"
},
"00000000000000000000000000000000000000fd": {
"balance": "0x1"
},
"00000000000000000000000000000000000000fe": {
"balance": "0x1"
},
"00000000000000000000000000000000000000ff": {
"balance": "0x1"
},
"4c2ae482593505f0163cdefc073e81c63cda4107": {
"balance": "0x152d02c7e14af6800000"
},
"a8e8f14732658e4b51e8711931053a8a69baf2b1": {
"balance": "0x152d02c7e14af6800000"
},
"d9a5179f091d85051d3c982785efd1455cec8699": {
"balance": "0x84595161401484a000000"
},
"e0a2bd4258d2768837baa26a28fe71dc079f84c7": {
"balance": "0x4a47e3c12448f4ad000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}

View File

@ -1,4 +1,22 @@
{
"config": {
"chainId": 1,
"homesteadBlock": 1150000,
"daoForkBlock": 1920000,
"daoForkSupport": true,
"eip150Block": 2463000,
"eip155Block": 2675000,
"eip158Block": 2675000,
"byzantiumBlock": 4370000,
"constantinopleBlock": 7280000,
"petersburgBlock": 7280000,
"istanbulBlock": 9069000,
"muirGlacierBlock": 9200000,
"berlinBlock": 12244000,
"londonBlock": 12965000,
"parisBlock": 15537394,
"terminalTotalDifficulty": 58750000000000000000000
},
"nonce": "0x42",
"timestamp": "0x0",
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",

View File

@ -0,0 +1,46 @@
{
"config": {
"chainId": 11155111,
"homesteadBlock": 0,
"daoForkSupport": true,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"terminalTotalDifficulty": 17000000000000000
},
"nonce": "0x00",
"timestamp": "0x6159af19",
"extraData": "0x5365706f6c69612c20417468656e732c204174746963612c2047726565636521",
"gasLimit": "0x1c9c380",
"difficulty": "0x20000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"stateRoot": "0x5eb6e371a698b8d68f665192350ffcecbbbf322916f4b51bd79bb6887da3f494",
"alloc":{
"0xa2A6d93439144FFE4D27c9E088dCD8b783946263": {"balance": "0xD3C21BCECCEDA1000000"},
"0xBc11295936Aa79d594139de1B2e12629414F3BDB": {"balance": "0xD3C21BCECCEDA1000000"},
"0x7cF5b79bfe291A67AB02b393E456cCc4c266F753": {"balance": "0xD3C21BCECCEDA1000000"},
"0xaaec86394441f915bce3e6ab399977e9906f3b69": {"balance": "0xD3C21BCECCEDA1000000"},
"0xF47CaE1CF79ca6758Bfc787dbD21E6bdBe7112B8": {"balance": "0xD3C21BCECCEDA1000000"},
"0xd7eDDB78ED295B3C9629240E8924fb8D8874ddD8": {"balance": "0xD3C21BCECCEDA1000000"},
"0x8b7F0977Bb4f0fBE7076FA22bC24acA043583F5e": {"balance": "0xD3C21BCECCEDA1000000"},
"0xe2e2659028143784d557bcec6ff3a0721048880a": {"balance": "0xD3C21BCECCEDA1000000"},
"0xd9a5179f091d85051d3c982785efd1455cec8699": {"balance": "0xD3C21BCECCEDA1000000"},
"0xbeef32ca5b9a198d27B4e02F4c70439fE60356Cf": {"balance": "0xD3C21BCECCEDA1000000"},
"0x0000006916a87b82333f4245046623b23794c65c": {"balance": "0x84595161401484A000000"},
"0xb21c33de1fab3fa15499c62b59fe0cc3250020d1": {"balance": "0x52B7D2DCC80CD2E4000000"},
"0x10F5d45854e038071485AC9e402308cF80D2d2fE": {"balance": "0x52B7D2DCC80CD2E4000000"},
"0xd7d76c58b3a519e9fA6Cc4D22dC017259BC49F1E": {"balance": "0x52B7D2DCC80CD2E4000000"},
"0x799D329e5f583419167cD722962485926E338F4a": {"balance": "0xDE0B6B3A7640000"}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}

View File

@ -24,7 +24,7 @@ pub async fn run() -> eyre::Result<()> {
/// Commands to be executed
#[derive(Subcommand)]
pub enum Commands {
/// Main node command
/// Start the node
#[command(name = "node")]
Node(node::Command),
/// Runs Ethereum blockchain tests

80
bin/reth/src/config.rs Normal file
View File

@ -0,0 +1,80 @@
//! Configuration files.
use serde::{Deserialize, Serialize};
/// Configuration for the reth node.
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct Config {
/// Configuration for each stage in the pipeline.
// TODO(onbjerg): Can we make this easier to maintain when we add/remove stages?
pub stages: StageConfig,
}
/// Configuration for each stage in the pipeline.
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct StageConfig {
/// Header stage configuration.
pub headers: HeadersConfig,
/// Body stage configuration.
pub bodies: BodiesConfig,
/// Sender recovery stage configuration.
pub senders: SendersConfig,
}
/// Header stage configuration.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct HeadersConfig {
/// The maximum number of headers to download before committing progress to the database.
pub commit_threshold: u64,
/// The maximum number of headers to request from a peer at a time.
pub downloader_batch_size: u64,
/// The number of times to retry downloading a set of headers.
pub downloader_retries: usize,
}
impl Default for HeadersConfig {
fn default() -> Self {
Self { commit_threshold: 10_000, downloader_batch_size: 1000, downloader_retries: 5 }
}
}
/// Body stage configuration.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct BodiesConfig {
/// The maximum number of bodies to download before committing progress to the database.
pub commit_threshold: u64,
/// The maximum number of bodies to request from a peer at a time.
pub downloader_batch_size: usize,
/// The number of times to retry downloading a set of bodies.
pub downloader_retries: usize,
/// The maximum number of body requests to have in flight at a time.
///
/// The maximum number of bodies downloaded at the same time is `downloader_batch_size *
/// downloader_concurrency`.
pub downloader_concurrency: usize,
}
impl Default for BodiesConfig {
fn default() -> Self {
Self {
commit_threshold: 5_000,
downloader_batch_size: 200,
downloader_retries: 5,
downloader_concurrency: 10,
}
}
}
/// Sender recovery stage configuration.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct SendersConfig {
/// The maximum number of blocks to process before committing progress to the database.
pub commit_threshold: u64,
/// The maximum number of transactions to recover senders for concurrently.
pub batch_size: usize,
}
impl Default for SendersConfig {
fn default() -> Self {
Self { commit_threshold: 5_000, batch_size: 1000 }
}
}

View File

@ -1,6 +1,5 @@
//! Database debugging tool
use crate::util::parse_path;
use crate::dirs::DbPath;
use clap::{Parser, Subcommand};
use eyre::{Result, WrapErr};
use reth_db::{
@ -12,16 +11,20 @@ use reth_db::{
};
use reth_interfaces::test_utils::generators::random_block_range;
use reth_provider::insert_canonical_block;
use std::path::PathBuf;
use tracing::info;
/// `reth db` command
#[derive(Debug, Parser)]
pub struct Command {
/// The path to the database folder.
// TODO: This should use dirs-next
#[arg(long, value_name = "PATH", default_value = "~/.reth/db", value_parser = parse_path)]
db: PathBuf,
///
/// Defaults to the OS-specific data directory:
///
/// - Linux: `$XDG_DATA_HOME/reth/db` or `$HOME/.local/share/reth/db`
/// - Windows: `{FOLDERID_RoamingAppData}/reth/db`
/// - macOS: `$HOME/Library/Application Support/reth/db`
#[arg(long, value_name = "PATH", verbatim_doc_comment, default_value_t)]
db: DbPath,
#[clap(subcommand)]
command: Subcommands,
@ -64,7 +67,7 @@ impl Command {
// TODO: Auto-impl for Database trait
let db = reth_db::mdbx::Env::<reth_db::mdbx::WriteMap>::open(
&self.db,
self.db.as_ref(),
reth_db::mdbx::EnvKind::RW,
)?;

95
bin/reth/src/dirs.rs Normal file
View File

@ -0,0 +1,95 @@
//! reth data directories.
use crate::util::parse_path;
use std::{
env::VarError,
fmt::{Debug, Display, Formatter},
path::{Path, PathBuf},
str::FromStr,
};
/// Returns the path to the reth data directory.
///
/// Refer to [dirs_next::data_dir] for cross-platform behavior.
pub fn data_dir() -> Option<PathBuf> {
dirs_next::data_dir().map(|root| root.join("reth"))
}
/// Returns the path to the reth database.
///
/// Refer to [dirs_next::data_dir] for cross-platform behavior.
pub fn database_path() -> Option<PathBuf> {
data_dir().map(|root| root.join("db"))
}
/// Returns the path to the reth configuration directory.
///
/// Refer to [dirs_next::config_dir] for cross-platform behavior.
pub fn config_dir() -> Option<PathBuf> {
dirs_next::config_dir().map(|root| root.join("reth"))
}
/// A wrapper type that either parses a user-given path for the reth database or defaults to an
/// OS-specific path.
#[derive(Clone, Debug)]
pub struct DbPath(PathBuf);
impl Display for DbPath {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0.display())
}
}
impl Default for DbPath {
fn default() -> Self {
Self(database_path().expect("Could not determine default database path. Set one manually."))
}
}
impl FromStr for DbPath {
type Err = shellexpand::LookupError<VarError>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self(parse_path(s)?))
}
}
impl AsRef<Path> for DbPath {
fn as_ref(&self) -> &Path {
self.0.as_path()
}
}
/// A wrapper type that either parses a user-given path for the reth config or defaults to an
/// OS-specific path.
#[derive(Clone, Debug)]
pub struct ConfigPath(PathBuf);
impl Display for ConfigPath {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0.display())
}
}
impl Default for ConfigPath {
fn default() -> Self {
Self(
config_dir()
.expect("Could not determine default database path. Set one manually.")
.join("reth.toml"),
)
}
}
impl FromStr for ConfigPath {
type Err = shellexpand::LookupError<VarError>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self(parse_path(s)?))
}
}
impl AsRef<Path> for ConfigPath {
fn as_ref(&self) -> &Path {
self.0.as_path()
}
}

View File

@ -7,7 +7,9 @@
//! Rust Ethereum (reth) binary executable.
pub mod cli;
pub mod config;
pub mod db;
pub mod dirs;
pub mod node;
pub mod test_eth_chain;
pub mod util;

View File

@ -1,7 +1,11 @@
//! Main node command
//!
//! Starts the client
use crate::util::{chainspec::Genesis, parse_path};
use crate::{
config::Config,
dirs::{ConfigPath, DbPath},
util::chainspec::{chain_spec_value_parser, ChainSpecification, Genesis},
};
use clap::{crate_version, Parser};
use eyre::WrapErr;
use metrics_exporter_prometheus::PrometheusBuilder;
@ -21,41 +25,67 @@ use reth_network::{
error::NetworkError,
NetworkConfig, NetworkHandle, NetworkManager,
};
use reth_primitives::{hex_literal::hex, Account, Header, H256};
use reth_primitives::{Account, Header, H256};
use reth_provider::{db_provider::ProviderImpl, BlockProvider, HeaderProvider};
use reth_stages::stages::{bodies::BodyStage, headers::HeaderStage, senders::SendersStage};
use std::{
net::SocketAddr,
path::{Path, PathBuf},
sync::Arc,
};
use std::{net::SocketAddr, path::Path, sync::Arc};
use tracing::{debug, info};
// TODO: Move this out somewhere
const MAINNET_GENESIS: &str = include_str!("../../res/chainspec/mainnet.json");
/// Start the client
#[derive(Debug, Parser)]
pub struct Command {
/// The path to the database folder.
// TODO: This should use dirs-next
#[arg(long, value_name = "PATH", default_value = "~/.reth/db", value_parser = parse_path)]
db: PathBuf,
///
/// Defaults to the OS-specific data directory:
///
/// - Linux: `$XDG_DATA_HOME/reth/db` or `$HOME/.local/share/reth/db`
/// - Windows: `{FOLDERID_RoamingAppData}/reth/db`
/// - macOS: `$HOME/Library/Application Support/reth/db`
#[arg(long, value_name = "PATH", verbatim_doc_comment, default_value_t)]
db: DbPath,
/// The path to the configuration file to use.
#[arg(long, value_name = "FILE", verbatim_doc_comment, default_value_t)]
config: ConfigPath,
/// The chain this node is running.
///
/// Possible values are either a built-in chain or the path to a chain specification file.
///
/// Built-in chains:
/// - mainnet
/// - goerli
/// - sepolia
#[arg(
long,
value_name = "CHAIN_OR_PATH",
verbatim_doc_comment,
default_value = "mainnet",
value_parser = chain_spec_value_parser
)]
chain: ChainSpecification,
/// Enable Prometheus metrics.
///
/// The metrics will be served at the given interface and port.
#[clap(long, value_name = "SOCKET")]
metrics: Option<SocketAddr>,
/// Set the chain tip manually for testing purposes.
///
/// NOTE: This is a temporary flag
#[arg(long = "debug.tip")]
tip: Option<H256>,
}
impl Command {
/// Execute `node` command
// TODO: RPC, metrics
// TODO: RPC
pub async fn execute(&self) -> eyre::Result<()> {
let config: Config = confy::load_path(&self.config)?;
info!("reth {} starting", crate_version!());
info!("Opening database at {}", &self.db.display());
info!("Opening database at {}", &self.db);
let db = Arc::new(init_db(&self.db)?);
info!("Database open");
@ -72,13 +102,12 @@ impl Command {
.wrap_err("Couldn't set metrics recorder.")?;
}
// TODO: More info from chainspec (chain ID etc.)
let consensus = Arc::new(EthConsensus::new(consensus_config()));
let genesis_hash =
init_genesis(db.clone(), serde_json::from_str(MAINNET_GENESIS).unwrap())?;
let chain_id = self.chain.consensus.chain_id;
let consensus = Arc::new(EthConsensus::new(self.chain.consensus.clone()));
let genesis_hash = init_genesis(db.clone(), self.chain.genesis.clone())?;
info!("Connecting to p2p");
let network = start_network(network_config(db.clone(), genesis_hash)).await?;
let network = start_network(network_config(db.clone(), chain_id, genesis_hash)).await?;
// TODO: Are most of these Arcs unnecessary? For example, fetch client is completely
// cloneable on its own
@ -88,43 +117,51 @@ impl Command {
.push(
HeaderStage {
downloader: headers::linear::LinearDownloadBuilder::default()
.batch_size(config.stages.headers.downloader_batch_size)
.retries(config.stages.headers.downloader_retries)
.build(consensus.clone(), fetch_client.clone()),
consensus: consensus.clone(),
client: fetch_client.clone(),
network_handle: network.clone(),
commit_threshold: 100,
commit_threshold: config.stages.headers.commit_threshold,
},
false,
)
.push(
BodyStage {
downloader: Arc::new(bodies::concurrent::ConcurrentDownloader::new(
fetch_client.clone(),
consensus.clone(),
)),
downloader: Arc::new(
bodies::concurrent::ConcurrentDownloader::new(
fetch_client.clone(),
consensus.clone(),
)
.with_batch_size(config.stages.bodies.downloader_batch_size)
.with_retries(config.stages.bodies.downloader_retries)
.with_concurrency(config.stages.bodies.downloader_concurrency),
),
consensus: consensus.clone(),
commit_threshold: 100,
commit_threshold: config.stages.bodies.commit_threshold,
},
false,
)
.push(SendersStage { batch_size: 100, commit_threshold: 1000 }, false);
.push(
SendersStage {
batch_size: config.stages.senders.batch_size,
commit_threshold: config.stages.senders.commit_threshold,
},
false,
);
if let Some(tip) = self.tip {
debug!("Tip manually set: {}", tip);
consensus.notify_fork_choice_state(ForkchoiceState {
head_block_hash: tip,
safe_block_hash: tip,
finalized_block_hash: tip,
})?;
}
// Run pipeline
info!("Starting pipeline");
// TODO: This is a temporary measure to set the fork choice state, but this should be
// handled by the engine API
consensus.notify_fork_choice_state(ForkchoiceState {
// NOTE: This is block 50,000. The first transaction ever is in block 46,147
head_block_hash: H256(hex!(
"0e30a7c0c1cee426011e274abc746c1ad3c48757433eb0139755658482498aa9"
)),
safe_block_hash: H256(hex!(
"0e30a7c0c1cee426011e274abc746c1ad3c48757433eb0139755658482498aa9"
)),
finalized_block_hash: H256(hex!(
"0e30a7c0c1cee426011e274abc746c1ad3c48757433eb0139755658482498aa9"
)),
})?;
pipeline.run(db.clone()).await?;
info!("Finishing up");
@ -183,19 +220,16 @@ fn init_genesis<DB: Database>(db: Arc<DB>, genesis: Genesis) -> Result<H256, ret
// TODO: This should be based on some external config
fn network_config<DB: Database>(
db: Arc<DB>,
chain_id: u64,
genesis_hash: H256,
) -> NetworkConfig<ProviderImpl<DB>> {
NetworkConfig::builder(Arc::new(ProviderImpl::new(db)), rng_secret_key())
.boot_nodes(mainnet_nodes())
.genesis_hash(genesis_hash)
.chain_id(chain_id)
.build()
}
// TODO: This should be based on some external config
fn consensus_config() -> reth_consensus::Config {
reth_consensus::Config::default()
}
/// Starts the networking stack given a [NetworkConfig] and returns a handle to the network.
async fn start_network<C>(config: NetworkConfig<C>) -> Result<NetworkHandle, NetworkError>
where

View File

@ -3,7 +3,18 @@ use reth_primitives::{
Address, Bytes, Header, H256, U256,
};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::{collections::HashMap, path::PathBuf};
/// Defines a chain, including it's genesis block, chain ID and fork block numbers.
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct ChainSpecification {
/// Consensus configuration.
#[serde(rename = "config")]
pub consensus: reth_consensus::Config,
/// The genesis block of the chain.
#[serde(flatten)]
pub genesis: Genesis,
}
/// The genesis block specification.
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
@ -58,3 +69,17 @@ pub struct GenesisAccount {
/// The balance of the account at genesis.
pub balance: U256,
}
/// Clap value parser for [ChainSpecification]s that takes either a built-in chainspec or the path
/// to a custom one.
pub fn chain_spec_value_parser(s: &str) -> Result<ChainSpecification, eyre::Error> {
Ok(match s {
"mainnet" => serde_json::from_str(include_str!("../../res/chainspec/mainnet.json"))?,
"goerli" => serde_json::from_str(include_str!("../../res/chainspec/goerli.json"))?,
"sepolia" => serde_json::from_str(include_str!("../../res/chainspec/mainnet.json"))?,
_ => {
let raw = std::fs::read_to_string(PathBuf::from(shellexpand::full(s)?.into_owned()))?;
serde_json::from_str(&raw)?
}
})
}

View File

@ -18,4 +18,10 @@ async-trait = "0.1.57"
thiserror = "1.0.37"
eyre = "0.6.8"
auto_impl = "1.0"
tokio = { version = "1.21.2", features = ["sync"] }
tokio = { version = "1.21.2", features = ["sync"] }
# io
serde = { version = "1.0", optional = true }
[features]
serde = ["dep:serde"]

View File

@ -1,6 +1,9 @@
//! Reth block execution/validation configuration and constants
use reth_primitives::BlockNumber;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Initial base fee as defined in: https://eips.ethereum.org/EIPS/eip-1559
pub const EIP1559_INITIAL_BASE_FEE: u64 = 1_000_000_000;
/// Base fee max change denominator as defined in: https://eips.ethereum.org/EIPS/eip-1559
@ -8,32 +11,67 @@ pub const EIP1559_BASE_FEE_MAX_CHANGE_DENOMINATOR: u64 = 8;
/// Elasticity multiplier as defined in: https://eips.ethereum.org/EIPS/eip-1559
pub const EIP1559_ELASTICITY_MULTIPLIER: u64 = 2;
/// Configuration for consensus
/// Common configuration for consensus algorithms.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct Config {
/// Spurious dragon ethereum update block.
pub spurious_dragon_hard_fork_block: BlockNumber,
/// EIP-2728 hard fork number.
pub berlin_hard_fork_block: BlockNumber,
/// EIP-1559 hard fork number.
pub london_hard_fork_block: BlockNumber,
/// The Merge/Paris hard fork block number.
pub paris_hard_fork_block: BlockNumber,
/// Blockchain identifier introduced in EIP-155: Simple replay attack protection.
pub chain_id: u64,
/// Merge terminal total dificulty after the paris hardfork got activated.
/// Homestead switch block.
pub homestead_block: BlockNumber,
/// TheDAO hard-fork switch block.
pub dao_fork_block: BlockNumber,
/// Whether the node supports or opposes the DAO hard-fork
pub dao_fork_support: bool,
/// EIP150 implements gas price changes.
pub eip_150_block: BlockNumber,
/// EIP155 hard-fork block (Spurious Dragon)
pub eip_155_block: BlockNumber,
/// EIP158 hard-fork block.
pub eip_158_block: BlockNumber,
/// Byzantium switch block.
pub byzantium_block: BlockNumber,
/// Constantinople switch block.
pub constantinople_block: BlockNumber,
/// Petersburg switch block.
pub petersburg_block: BlockNumber,
/// Istanbul switch block.
pub istanbul_block: BlockNumber,
/// EIP-2728 switch block.
pub berlin_block: BlockNumber,
/// EIP-1559 switch block.
pub london_block: BlockNumber,
/// The Merge/Paris hard-fork block number.
pub paris_block: BlockNumber,
/// Terminal total difficulty after the paris hard-fork to reach before The Merge is considered
/// activated.
#[cfg_attr(feature = "serde", serde(rename = "terminalTotalDifficulty"))]
pub merge_terminal_total_difficulty: u128,
}
impl Default for Config {
fn default() -> Self {
Self {
spurious_dragon_hard_fork_block: 2675000,
berlin_hard_fork_block: 12244000,
london_hard_fork_block: 12965000,
paris_hard_fork_block: 15537394,
merge_terminal_total_difficulty: 58750000000000000000000,
chain_id: 1,
homestead_block: 1150000,
dao_fork_block: 1920000,
dao_fork_support: true,
eip_150_block: 2463000,
eip_155_block: 2675000,
eip_158_block: 2675000,
byzantium_block: 4370000,
constantinople_block: 7280000,
petersburg_block: 7280000,
istanbul_block: 9069000,
berlin_block: 12244000,
london_block: 12965000,
paris_block: 15537394,
merge_terminal_total_difficulty: 58750000000000000000000,
}
}
}

View File

@ -44,7 +44,7 @@ impl Consensus for EthConsensus {
verification::validate_header_standalone(header, &self.config)?;
verification::validate_header_regarding_parent(parent, header, &self.config)?;
if header.number < self.config.paris_hard_fork_block {
if header.number < self.config.paris_block {
// TODO Consensus checks for old blocks:
// * difficulty, mix_hash & nonce aka PoW stuff
// low priority as syncing is done in reverse order
@ -57,6 +57,6 @@ impl Consensus for EthConsensus {
}
fn has_block_reward(&self, block_num: BlockNumber) -> bool {
block_num <= self.config.paris_hard_fork_block
block_num <= self.config.paris_block
}
}

View File

@ -4,8 +4,11 @@
no_crate_inject,
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
))]
//! Reth consensus.
//! Consensus algorithms for Ethereum.
//!
//! # Features
//!
//! - `serde`: Enable serde support for configuration types.
pub mod config;
pub mod consensus;
pub mod verification;

View File

@ -38,13 +38,13 @@ pub fn validate_header_standalone(
}
// Check if base fee is set.
if header.number >= config.london_hard_fork_block && header.base_fee_per_gas.is_none() {
if header.number >= config.london_block && header.base_fee_per_gas.is_none() {
return Err(Error::BaseFeeMissing)
}
// EIP-3675: Upgrade consensus to Proof-of-Stake:
// https://eips.ethereum.org/EIPS/eip-3675#replacing-difficulty-with-0
if header.number >= config.paris_hard_fork_block {
if header.number >= config.paris_block {
if header.difficulty != U256::zero() {
return Err(Error::TheMergeDifficultyIsNotZero)
}
@ -77,14 +77,14 @@ pub fn validate_transaction_regarding_header(
let chain_id = match transaction {
Transaction::Legacy(TxLegacy { chain_id, .. }) => {
// EIP-155: Simple replay attack protection: https://eips.ethereum.org/EIPS/eip-155
if config.spurious_dragon_hard_fork_block <= at_block_number && chain_id.is_some() {
if config.eip_155_block <= at_block_number && chain_id.is_some() {
return Err(Error::TransactionOldLegacyChainId)
}
*chain_id
}
Transaction::Eip2930(TxEip2930 { chain_id, .. }) => {
// EIP-2930: Optional access lists: https://eips.ethereum.org/EIPS/eip-2930 (New transaction type)
if config.berlin_hard_fork_block > at_block_number {
if config.berlin_block > at_block_number {
return Err(Error::TransactionEip2930Disabled)
}
Some(*chain_id)
@ -96,7 +96,7 @@ pub fn validate_transaction_regarding_header(
..
}) => {
// EIP-1559: Fee market change for ETH 1.0 chain https://eips.ethereum.org/EIPS/eip-1559
if config.berlin_hard_fork_block > at_block_number {
if config.berlin_block > at_block_number {
return Err(Error::TransactionEip1559Disabled)
}
@ -256,7 +256,7 @@ pub fn validate_header_regarding_parent(
}
// difficulty check is done by consensus.
if config.paris_hard_fork_block > child.number {
if config.paris_block > child.number {
// TODO how this needs to be checked? As ice age did increment it by some formula
}
@ -264,7 +264,7 @@ pub fn validate_header_regarding_parent(
// By consensus, gas_limit is multiplied by elasticity (*2) on
// on exact block that hardfork happens.
if config.london_hard_fork_block == child.number {
if config.london_block == child.number {
parent_gas_limit = parent.gas_limit * config::EIP1559_ELASTICITY_MULTIPLIER;
}
@ -284,10 +284,10 @@ pub fn validate_header_regarding_parent(
}
// EIP-1559 check base fee
if child.number >= config.london_hard_fork_block {
if child.number >= config.london_block {
let base_fee = child.base_fee_per_gas.ok_or(Error::BaseFeeMissing)?;
let expected_base_fee = if config.london_hard_fork_block == child.number {
let expected_base_fee = if config.london_block == child.number {
config::EIP1559_INITIAL_BASE_FEE
} else {
// This BaseFeeMissing will not happen as previous blocks are checked to have them.

View File

@ -182,6 +182,12 @@ impl<C> NetworkConfigBuilder<C> {
self
}
/// Sets the chain ID.
pub fn chain_id<Id: Into<Chain>>(mut self, chain_id: Id) -> Self {
self.chain = chain_id.into();
self
}
/// Sets the `HelloMessage` to send when connecting to peers.
///
/// ```

View File

@ -52,7 +52,7 @@ pub struct HeaderStage<D: HeaderDownloader, C: Consensus, H: HeadersClient, S: S
/// Network handle for updating status
pub network_handle: S,
/// The number of block headers to commit at once
pub commit_threshold: usize,
pub commit_threshold: u64,
}
#[async_trait::async_trait]
@ -84,7 +84,8 @@ impl<DB: Database, D: HeaderDownloader, C: Consensus, H: HeadersClient, S: Statu
);
let mut current_progress = stage_progress;
let mut stream = self.downloader.stream(head.clone(), tip).chunks(self.commit_threshold);
let mut stream =
self.downloader.stream(head.clone(), tip).chunks(self.commit_threshold as usize);
// The stage relies on the downloader to return the headers
// in descending order starting from the tip down to
@ -102,7 +103,6 @@ impl<DB: Database, D: HeaderDownloader, C: Consensus, H: HeadersClient, S: Statu
self.validate_header_response(&res)?;
let write_progress =
self.write_headers::<DB>(tx, res).await?.unwrap_or_default();
tx.commit()?;
current_progress = current_progress.max(write_progress);
}
Err(e) => match e {

View File

@ -62,8 +62,8 @@ impl<E: EnvironmentKind> Env<E> {
inner: Environment::new()
.set_max_dbs(TABLES.len())
.set_geometry(Geometry {
size: Some(0..0x10000000), // TODO: reevaluate
growth_step: Some(0x100000), // TODO: reevaluate
size: Some(0..(1024 * 1024 * 1024 * 1024 * 4)), // TODO: reevaluate (4 tb)
growth_step: Some(1024 * 1024 * 256), // TODO: reevaluate (256 mb)
shrink_threshold: None,
page_size: Some(PageSize::Set(default_page_size())),
})

View File

@ -28,9 +28,9 @@ impl Default for PoolConfig {
/// Size limits for a sub-pool.
#[derive(Debug, Clone)]
pub struct SubPoolLimit {
/// Max. amount of transaction in the pool.
/// Maximum amount of transaction in the pool.
pub max_txs: usize,
/// Max. combined size of transactions in the pool.
/// Maximum combined size (in bytes) of transactions in the pool.
pub max_size: usize,
}