From 57e0b754809009dc79bde4e3f3ff6dd72328bb87 Mon Sep 17 00:00:00 2001 From: Andreas Bigger Date: Tue, 13 Jan 2026 12:10:50 -0500 Subject: [PATCH] feat(bin): kona consensus node rollup boost args base prefixes fixes --- Cargo.lock | 148 ++++++++++++---------- Cargo.toml | 55 ++++---- bin/consensus/Cargo.toml | 17 +++ bin/consensus/src/cli.rs | 169 +++++++++++++++++++++++-- bin/consensus/src/main.rs | 3 + bin/consensus/src/metrics.rs | 106 ++++++++++++++++ crates/client/cli/README.md | 8 +- crates/client/cli/src/p2p.rs | 64 ++++++++++ crates/shared/cli-utils/src/metrics.rs | 6 +- 9 files changed, 473 insertions(+), 103 deletions(-) create mode 100644 bin/consensus/src/metrics.rs diff --git a/Cargo.lock b/Cargo.lock index 75a4db9a..d10bdba0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12870ab65b131f609257436935047eec3cfabee8809732f6bf5a69fe2a18cf2e" +checksum = "5c3a590d13de3944675987394715f37537b50b856e3b23a0e66e97d963edbf38" dependencies = [ "alloy-eips", "alloy-primitives", @@ -129,9 +129,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47c66b14d2187de0c4efe4ef678aaa57a6a34cccdbea3a0773627fac9bd128f4" +checksum = "0f28f769d5ea999f0d8a105e434f483456a15b4e1fcb08edbbbe1650a497ff6d" dependencies = [ "alloy-consensus", "alloy-eips", @@ -144,9 +144,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9bf6afe8c25b63c98927c6f76d90cf8dc443cc4980a7d824151c84a6e568934" +checksum = "990fa65cd132a99d3c3795a82b9f93ec82b81c7de3bab0bf26ca5c73286f7186" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -241,9 +241,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f076d25ddfcd2f1cbcc234e072baf97567d1df0e3fccdc1f8af8cc8b18dc6299" +checksum = "09535cbc646b0e0c6fcc12b7597eaed12cf86dff4c4fba9507a61e71b94f30eb" dependencies = [ "alloy-eip2124", "alloy-eip2930", @@ -290,9 +290,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d424ac007b5f89d65eecb4ed6cc5ca74cbaf231f471789a8158fdf4cc5f446" +checksum = "1005520ccf89fa3d755e46c1d992a9e795466c2e7921be2145ef1f749c5727de" dependencies = [ "alloy-eips", "alloy-primitives", @@ -331,9 +331,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "250dbd8496f04eabe997e6e4c5186a0630b8bc3dbe7552e1fd917d491ef811e9" +checksum = "72b626409c98ba43aaaa558361bca21440c88fd30df7542c7484b9c7a1489cdb" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -346,9 +346,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd45cdac957d1fa1d0c18f54f262350eb72f1adc38dd1f8b15f33f0747c6a60c" +checksum = "89924fdcfeee0e0fa42b1f10af42f92802b5d16be614a70897382565663bf7cf" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -372,9 +372,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fba5c43e055effb5bd33dbc74b1ab7fe0f367d8801a25af9e7c716b3ef5e440b" +checksum = "0f0dbe56ff50065713ff8635d8712a0895db3ad7f209db9793ad8fcb6b1734aa" dependencies = [ "alloy-consensus", "alloy-eips", @@ -447,9 +447,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e87a90cacc27dffd91fa6440145934a782227d31b9876444c5924d3607084ea" +checksum = "8b56f7a77513308a21a2ba0e9d57785a9d9d2d609e77f4e71a78a1192b83ff2d" dependencies = [ "alloy-chains", "alloy-consensus", @@ -491,9 +491,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c24a102935aa9d5a8b8fc8c47f39a0823672c33f0b27b5806292cb80988e6345" +checksum = "94813abbd7baa30c700ea02e7f92319dbcb03bff77aeea92a3a9af7ba19c5c70" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -535,9 +535,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a65bb9060e43e9738bbd7c30d742ed962d609f2123a665bbdab7e6e0f13fd3" +checksum = "ff01723afc25ec4c5b04de399155bef7b6a96dfde2475492b1b7b4e7a4f46445" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -561,9 +561,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98bfd40f4e36cb29015ec744bc764629edbe823ec6b95aceef2684090c142976" +checksum = "f91bf006bb06b7d812591b6ac33395cb92f46c6a65cda11ee30b348338214f0f" dependencies = [ "alloy-primitives", "alloy-rpc-types-engine", @@ -574,9 +574,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-admin" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89123971b8e640d2841150680fba6cdeedbee483ae15d4b0bc3f1507f4715eb1" +checksum = "b934c3bcdc6617563b45deb36a40881c8230b94d0546ea739dff7edb3aa2f6fd" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -586,9 +586,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac7d0dbb62e807028554e34c2b5724a1f57132792684107c32009e84fcf4044" +checksum = "7e82145856df8abb1fefabef58cdec0f7d9abf337d4abd50c1ed7e581634acdd" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -598,9 +598,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8faa6f22068857f58579271b15e042f4725ad35cdce2ed4778ba32ffd3102b92" +checksum = "212ca1c1dab27f531d3858f8b1a2d6bfb2da664be0c1083971078eb7b71abe4b" dependencies = [ "alloy-consensus-any", "alloy-rpc-types-eth", @@ -609,9 +609,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-beacon" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ff8cc4b56836a9ffb4b19c3a221bba64e497199bf3900c302aee493a50dadb8" +checksum = "6d92a9b4b268fac505ef7fb1dac9bb129d4fd7de7753f22a5b6e9f666f7f7de6" dependencies = [ "alloy-eips", "alloy-primitives", @@ -629,9 +629,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-debug" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb37a9eee8e7a19bb07b5cd55d33457884e44b212588b7429c5d318d2b90295" +checksum = "bab1ebed118b701c497e6541d2d11dfa6f3c6ae31a3c52999daa802fcdcc16b7" dependencies = [ "alloy-primitives", "derive_more", @@ -641,9 +641,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95157286826aa7bb5463a5f4188266bbf2555db1fd53bb814a4b35c106f2a498" +checksum = "232f00fcbcd3ee3b9399b96223a8fc884d17742a70a44f9d7cef275f93e6e872" dependencies = [ "alloy-consensus", "alloy-eips", @@ -661,9 +661,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec734cce11f7fe889950b36b51589397528b26beb6f890834a2131ee9f174d7" +checksum = "5715d0bf7efbd360873518bd9f6595762136b5327a9b759a8c42ccd9b5e44945" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -683,9 +683,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-mev" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ddbe530062af75ec960fae36dcd1e5596615b730c83c535ecd9d3ec113ef3d7" +checksum = "c7b61941d2add2ee64646612d3eda92cbbde8e6c933489760b6222c8898c79be" dependencies = [ "alloy-consensus", "alloy-eips", @@ -698,9 +698,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe64cd4af2e68b2154ac02a7908249a448fbd3d1d05890786a5af93686083cc" +checksum = "9763cc931a28682bd4b9a68af90057b0fbe80e2538a82251afd69d7ae00bbebf" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -712,9 +712,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9504c0f00a72883e640abc4681a5691a57dec693bc28d4aa80257c8e1e9e6e1f" +checksum = "359a8caaa98cb49eed62d03f5bc511dd6dd5dee292238e8627a6e5690156df0f" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -724,9 +724,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27f076bfd74fccc63d50546e1765359736357a953de2eb778b7b6191571735e6" +checksum = "5ed8531cae8d21ee1c6571d0995f8c9f0652a6ef6452fde369283edea6ab7138" dependencies = [ "alloy-primitives", "arbitrary", @@ -736,9 +736,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d80748c209a68421ab6f737828ce6ede7543569a5cad099c1ec16fc1baa05620" +checksum = "fb10ccd49d0248df51063fce6b716f68a315dd912d55b32178c883fd48b4021d" dependencies = [ "alloy-primitives", "async-trait", @@ -751,9 +751,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17eb1eb39351b4bf20bb0710d8d3a91eb7918d3f3de2f3835f556842e33865cb" +checksum = "f4d992d44e6c414ece580294abbadb50e74cfd4eaa69787350a4dfd4b20eaa1b" dependencies = [ "alloy-consensus", "alloy-network", @@ -843,9 +843,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0c1a0288cdff6ee2b2c2c98ab42889d221ca8a9ee4120ede59b5449e0dcb20" +checksum = "3f50a9516736d22dd834cc2240e5bf264f338667cc1d9e514b55ec5a78b987ca" dependencies = [ "alloy-json-rpc", "auto_impl", @@ -866,9 +866,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36dfa207caf6b528b9466c714626f5b2dfd5e8d4595a74631d5670672dac102b" +checksum = "0a18b541a6197cf9a084481498a766fdf32fefda0c35ea6096df7d511025e9f1" dependencies = [ "alloy-json-rpc", "alloy-rpc-types-engine", @@ -890,9 +890,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf45686199d20b395d5912163f8fe497853b7f13de110bd552e50a0447bb4f48" +checksum = "8075911680ebc537578cacf9453464fd394822a0f68614884a9c63f9fbaf5e89" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -910,9 +910,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91620efb46f8d011e37f74fac53a643e830a7bb24982143094b887003cbfb6be" +checksum = "921d37a57e2975e5215f7dd0f28873ed5407c7af630d4831a4b5c737de4b0b8b" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -947,9 +947,9 @@ dependencies = [ [[package]] name = "alloy-tx-macros" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d567f4830dea921868c7680004ae0c7f221b05e6477db6c077c7953698f56" +checksum = "b2289a842d02fe63f8c466db964168bb2c7a9fdfb7b24816dbb17d45520575fb" dependencies = [ "darling 0.21.3", "proc-macro2", @@ -1893,9 +1893,20 @@ name = "base-consensus" version = "0.0.0" dependencies = [ "base-cli-utils", + "base-client-cli", "clap", "eyre", + "kona-derive", + "kona-disc", + "kona-engine", + "kona-genesis", + "kona-gossip", + "kona-node-service", + "kona-providers-alloy", "metrics", + "strum 0.27.2", + "tracing", + "tracing-subscriber 0.3.22", "vergen", "vergen-git2", ] @@ -2625,9 +2636,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" +checksum = "fac4744fb15ae8337dc853fee7fb3f4e48c0fbaa23d0afe49c447b4fab126118" dependencies = [ "iana-time-zone", "js-sys", @@ -5556,6 +5567,7 @@ dependencies = [ "kona-hardforks", "kona-macros", "kona-protocol", + "metrics", "op-alloy-consensus", "op-alloy-rpc-types-engine", "thiserror 2.0.17", @@ -5575,6 +5587,7 @@ dependencies = [ "kona-macros", "kona-peers", "libp2p", + "metrics", "rand 0.9.2", "thiserror 2.0.17", "tokio", @@ -5605,6 +5618,7 @@ dependencies = [ "kona-genesis", "kona-macros", "kona-protocol", + "metrics", "op-alloy-consensus", "op-alloy-network", "op-alloy-provider", @@ -5662,6 +5676,7 @@ dependencies = [ "libp2p", "libp2p-identity", "libp2p-stream", + "metrics", "op-alloy-consensus", "op-alloy-rpc-types-engine", "openssl", @@ -5726,6 +5741,7 @@ dependencies = [ "kona-sources", "libp2p", "libp2p-stream", + "metrics", "op-alloy-network", "op-alloy-provider", "op-alloy-rpc-types-engine", @@ -5816,6 +5832,7 @@ dependencies = [ "kona-macros", "kona-protocol", "lru 0.16.3", + "metrics", "op-alloy-consensus", "op-alloy-network", "reqwest", @@ -5862,6 +5879,7 @@ dependencies = [ "kona-macros", "kona-protocol", "libp2p", + "metrics", "op-alloy-consensus", "op-alloy-rpc-jsonrpsee", "op-alloy-rpc-types", @@ -6504,13 +6522,13 @@ dependencies = [ [[package]] name = "match-lookup" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1265724d8cb29dbbc2b0f06fffb8bf1a8c0cf73a78eede9ba73a4a66c52a981e" +checksum = "757aee279b8bdbb9f9e676796fd459e4207a1f986e87886700abf589f5abf771" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.114", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 6063e8a8..7dd484f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,11 +53,11 @@ codegen-units = 1 [workspace.dependencies] # Shared -base-access-lists = { path = "crates/shared/access-lists" } base-bundles = { path = "crates/shared/bundles" } base-cli-utils = { path = "crates/shared/cli-utils" } base-flashtypes = { path = "crates/shared/flashtypes" } base-primitives = { path = "crates/shared/primitives" } +base-access-lists = { path = "crates/shared/access-lists" } base-reth-rpc-types = { path = "crates/shared/reth-rpc-types" } base-jwt = { path = "crates/shared/jwt" } @@ -72,6 +72,20 @@ base-flashblocks = { path = "crates/client/flashblocks" } # Builder op-rbuilder = { path = "crates/builder/op-rbuilder" } +# Kona +kona-rpc = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } +kona-disc = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } +kona-engine = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } +kona-derive = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } +kona-gossip = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } +kona-genesis = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } +kona-registry = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } +kona-node-service = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } +kona-providers-alloy = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } +kona-cli = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d", default-features = false, features = ["secrets"] } +kona-peers = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } +kona-sources = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } + # reth reth-ipc = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" } reth-evm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" } @@ -201,39 +215,22 @@ alloy-rpc-types-beacon = { version = "1.0.41", features = ["ssz"] } # op-alloy op-alloy-flz = { version = "0.13.1", default-features = false } op-alloy-network = { version = "0.22.0", default-features = false } +op-alloy-provider = { version = "0.22.0", default-features = false } op-alloy-rpc-types = { version = "0.22.0", default-features = false } op-alloy-consensus = { version = "0.22.0", default-features = false } op-alloy-rpc-jsonrpsee = { version = "0.22.0", default-features = false } op-alloy-rpc-types-engine = { version = "0.22.0", default-features = false } -op-alloy-provider = { version = "0.22.0", default-features = false } alloy-op-evm = { version = "0.23.3", default-features = false } alloy-op-hardforks = "0.4.4" -# op-revm -op-revm = { version = "12.0.2", default-features = false } - -# kona -kona-cli = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d", default-features = false, features = ["secrets"] } -kona-derive = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } -kona-disc = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } -kona-engine = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } -kona-genesis = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } -kona-gossip = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } -kona-node-service = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } -kona-peers = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } -kona-providers-alloy = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } -kona-registry = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } -kona-rpc = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } -kona-sources = { git = "https://github.com/op-rs/kona", rev = "24e7e2658e09ac00c8e6cbb48bebe6d10f8fb69d" } - # rollup-boost rollup-boost = { git = "https://github.com/flashbots/rollup-boost", tag = "v0.7.11" } # rollup-boost version that matches kona's dependency (used for consensus binary) rollup-boost-kona = { package = "rollup-boost", git = "https://github.com/flashbots/rollup-boost.git", rev = "7fda98f" } -# libp2p -libp2p = { version = "0.56.0", default-features = false } -discv5 = "0.10.1" + +# op-revm +op-revm = { version = "12.0.2", default-features = false } # tokio tokio = "1.48.0" @@ -244,7 +241,6 @@ tokio-tungstenite = { version = "0.28.0", features = ["native-tls"] } futures = "0.3.31" reqwest = "0.12.25" futures-util = "0.3.31" -backon = "1.5" # rpc jsonrpsee = "0.26.0" @@ -255,6 +251,11 @@ vergen = "9.0.6" vergen-git2 = "1.0.7" clap = { version = "4.5.53", features = ["derive", "env", "string"] } +# Tracing +tracing = "0.1.43" +tracing-appender = "0.2.4" +tracing-subscriber = "0.3.22" + # Metrics metrics = { version = "0.24.3", default-features = false } prometheus = { version = "0.14.0", default-features = false } @@ -265,6 +266,8 @@ metrics-exporter-prometheus = { version = "0.18.1", default-features = false } url = "2.5.7" lru = "0.16.3" rand = "0.9.2" +strum = "0.27.2" +backon = "1.6.0" uuid = "1.19.0" time = { version = "0.3.44", features = ["macros", "formatting", "parsing"] } rayon = "1.11" @@ -277,21 +280,21 @@ rstest = "0.26.1" serde = "1.0.228" rustls = "0.23.35" httpmock = "0.8.2" -tracing = "0.1.43" arc-swap = "1.7.1" once_cell = "1.21.3" itertools = "0.14.0" derive_more = "2.1.0" serde_json = "1.0.145" metrics-derive = "0.1.0" -tracing-subscriber = "0.3.22" -tracing-appender = "0.2" thiserror = "2.0" async-trait = "0.1.83" parking_lot = "0.12.3" auto_impl = "1.2.0" serde_with = "3.8.1" secp256k1 = "0.30" +libp2p = "0.56.0" +libp2p-identity = "0.2.12" +discv5 = "0.10" either = { version = "1.15.0", default-features = false } tokio-util = { version = "0.7.4", features = ["codec"] } warp = "0.3.7" diff --git a/bin/consensus/Cargo.toml b/bin/consensus/Cargo.toml index abbd4b96..7c56d6da 100644 --- a/bin/consensus/Cargo.toml +++ b/bin/consensus/Cargo.toml @@ -15,10 +15,27 @@ workspace = true [dependencies] # Workspace base-cli-utils.workspace = true +base-client-cli.workspace = true + +# Kona +kona-disc = { workspace = true, features = ["metrics"] } +kona-derive = { workspace = true, features = ["metrics"] } +kona-engine = { workspace = true, features = ["metrics"] } +kona-genesis.workspace = true +kona-gossip = { workspace = true, features = ["metrics"] } +kona-node-service = { workspace = true, features = ["metrics"] } +kona-providers-alloy = { workspace = true, features = ["metrics"] } # CLI clap.workspace = true eyre.workspace = true +strum.workspace = true + +# Tracing +tracing.workspace = true +tracing-subscriber = { workspace = true, features = ["fmt", "env-filter"] } + +# Metrics metrics.workspace = true [build-dependencies] diff --git a/bin/consensus/src/cli.rs b/bin/consensus/src/cli.rs index 02ed5116..0a962407 100644 --- a/bin/consensus/src/cli.rs +++ b/bin/consensus/src/cli.rs @@ -1,9 +1,18 @@ //! Contains the CLI entry point for the Base consensus binary. -use base_cli_utils::GlobalArgs; +use std::{sync::Arc, time::Duration}; + +use base_cli_utils::{CliStyles, GlobalArgs, LogConfig, RuntimeManager}; +use base_client_cli::{ + BuilderClientArgs, L1ClientArgs, L1ConfigFile, L2ClientArgs, L2ConfigFile, P2PArgs, + RollupBoostFlags, RpcArgs, SequencerArgs, +}; use clap::Parser; +use kona_node_service::{EngineConfig, L1ConfigBuilder, NodeMode, RollupNodeBuilder}; +use strum::IntoEnumIterator; +use tracing::{error, info}; -use crate::version; +use crate::{metrics::init_rollup_config_metrics, version}; /// The Base Consensus CLI. #[derive(Parser, Clone, Debug)] @@ -11,6 +20,7 @@ use crate::version; author, version = version::SHORT_VERSION, long_version = version::LONG_VERSION, + styles = CliStyles::init(), about, long_about = None )] @@ -18,17 +28,160 @@ pub struct Cli { /// Global arguments for the Base Consensus CLI. #[command(flatten)] pub global: GlobalArgs, + /// The mode to run the node in. + #[arg( + long = "mode", + default_value_t = NodeMode::Validator, + env = "BASE_NODE_MODE", + help = format!( + "The mode to run the node in. Supported modes are: {}", + NodeMode::iter() + .map(|mode| format!("\"{}\"", mode.to_string())) + .collect::>() + .join(", ") + ) + )] + pub node_mode: NodeMode, + + /// L1 RPC CLI arguments. + #[clap(flatten)] + pub l1_rpc_args: L1ClientArgs, + + /// L2 engine CLI arguments. + #[clap(flatten)] + pub l2_client_args: L2ClientArgs, + + /// Optional block builder client. + #[clap(flatten)] + pub builder_client_args: BuilderClientArgs, + + /// L1 configuration file. + #[clap(flatten)] + pub l1_config: L1ConfigFile, + /// L2 configuration file. + #[clap(flatten)] + pub l2_config: L2ConfigFile, + + /// P2P CLI arguments. + #[command(flatten)] + pub p2p_flags: P2PArgs, + /// RPC CLI arguments. + #[command(flatten)] + pub rpc_flags: RpcArgs, + /// SEQUENCER CLI arguments. + #[command(flatten)] + pub sequencer_flags: SequencerArgs, + /// Rollup Boost CLI arguments. + #[command(flatten)] + pub rollup_boost_flags: RollupBoostFlags, } impl Cli { - /// Parse the CLI arguments. - pub fn parse() -> Self { - ::parse() + /// Runs the CLI. + pub fn run(self) -> eyre::Result<()> { + // Initialize telemetry - allow subcommands to customize the filter. + Self::init_logs(&self.global)?; + + // Initialize unified metrics + self.global.metrics.init_with(|| { + kona_gossip::Metrics::init(); + kona_disc::Metrics::init(); + kona_engine::Metrics::init(); + kona_node_service::Metrics::init(); + kona_derive::Metrics::init(); + kona_providers_alloy::Metrics::init(); + version::VersionInfo::from_build().register_version_metrics(); + })?; + + // Run the subcommand. + RuntimeManager::run_until_ctrl_c(self.exec(&self.global)) } - /// Run the CLI. - pub fn run(self) -> eyre::Result<()> { - // TODO: Implement the CLI logic + /// Run the Node subcommand. + pub async fn exec(&self, args: &GlobalArgs) -> eyre::Result<()> { + let cfg = self.l2_config.load(&args.l2_chain_id).map_err(|e| eyre::eyre!("{e}"))?; + + info!( + target: "rollup_node", + chain_id = cfg.l2_chain_id.id(), + "Starting rollup node services" + ); + for hf in cfg.hardforks.to_string().lines() { + info!(target: "rollup_node", "{hf}"); + } + + let l1_chain_config = + self.l1_config.load(cfg.l1_chain_id).map_err(|e| eyre::eyre!("{e}"))?; + let l1_config = L1ConfigBuilder { + chain_config: l1_chain_config, + trust_rpc: self.l1_rpc_args.l1_trust_rpc, + beacon: self.l1_rpc_args.l1_beacon.clone(), + rpc_url: self.l1_rpc_args.l1_eth_rpc.clone(), + slot_duration_override: self.l1_rpc_args.l1_slot_duration_override, + }; + + // If metrics are enabled, initialize the global cli metrics. + args.metrics.enabled.then(|| init_rollup_config_metrics(&cfg)); + + let jwt_secret = self.l2_client_args.validate_jwt().await?; + + self.p2p_flags.check_ports()?; + let genesis_signer = args.genesis_signer().ok(); + let p2p_config = self + .p2p_flags + .clone() + .config( + &cfg, + args.l2_chain_id.into(), + Some(self.l1_rpc_args.l1_eth_rpc.clone()), + genesis_signer, + ) + .await?; + let rpc_config = self.rpc_flags.clone().into(); + + let engine_config = EngineConfig { + config: Arc::new(cfg.clone()), + builder_url: self.builder_client_args.l2_builder_rpc.clone(), + builder_jwt_secret: self + .builder_client_args + .jwt_secret() + .map_err(|e| eyre::eyre!(e))?, + builder_timeout: Duration::from_millis(self.builder_client_args.builder_timeout), + l2_url: self.l2_client_args.l2_engine_rpc.clone(), + l2_jwt_secret: jwt_secret, + l2_timeout: Duration::from_millis(self.l2_client_args.l2_engine_timeout), + l1_url: self.l1_rpc_args.l1_eth_rpc.clone(), + mode: self.node_mode, + rollup_boost: self.rollup_boost_flags.clone().as_rollup_boost_args(), + }; + + RollupNodeBuilder::new( + cfg, + l1_config, + self.l2_client_args.l2_trust_rpc, + engine_config, + p2p_config, + rpc_config, + ) + .with_sequencer_config(self.sequencer_flags.config()) + .build() + .start() + .await + .map_err(|e| { + error!(target: "rollup_node", "Failed to start rollup node service: {e}"); + eyre::eyre!("{e}") + })?; + Ok(()) } + + /// Initializes the logging system based on global arguments. + pub fn init_logs(args: &GlobalArgs) -> eyre::Result<()> { + // Filter out discovery warnings since they're very very noisy. + let filter = tracing_subscriber::EnvFilter::from_default_env() + .add_directive("discv5=error".parse()?); + + let config: LogConfig = args.logging.clone().into(); + config.init_tracing_subscriber_with_filter(filter) + } } diff --git a/bin/consensus/src/main.rs b/bin/consensus/src/main.rs index ab12147b..854be4c8 100644 --- a/bin/consensus/src/main.rs +++ b/bin/consensus/src/main.rs @@ -4,9 +4,12 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] pub mod cli; +pub mod metrics; pub mod version; fn main() { + use clap::Parser; + base_cli_utils::Backtracing::enable(); base_cli_utils::SigsegvHandler::install(); diff --git a/bin/consensus/src/metrics.rs b/bin/consensus/src/metrics.rs new file mode 100644 index 00000000..de27b612 --- /dev/null +++ b/bin/consensus/src/metrics.rs @@ -0,0 +1,106 @@ +//! CLI Options Metrics + +use kona_genesis::RollupConfig; + +/// Metrics to record various CLI options. +#[derive(Debug, Clone, PartialEq)] +pub struct CliMetrics; + +impl CliMetrics { + /// The identifier for the cli metrics gauge. + pub const IDENTIFIER: &'static str = "base_cli_opts"; + + /// The P2P Scoring level (disabled if "off"). + pub const P2P_PEER_SCORING_LEVEL: &'static str = "base_node_peer_scoring_level"; + + /// Whether P2P Topic Scoring is enabled. + pub const P2P_TOPIC_SCORING_ENABLED: &'static str = "base_node_topic_scoring_enabled"; + + /// Whether P2P banning is enabled. + pub const P2P_BANNING_ENABLED: &'static str = "base_node_banning_enabled"; + + /// The value for peer redialing. + pub const P2P_PEER_REDIALING: &'static str = "base_node_peer_redialing"; + + /// Whether flood publishing is enabled. + pub const P2P_FLOOD_PUBLISH: &'static str = "base_node_flood_publish"; + + /// The interval to send FINDNODE requests through discv5. + pub const P2P_DISCOVERY_INTERVAL: &'static str = "base_node_discovery_interval"; + + /// The IP to advertise via P2P. + pub const P2P_ADVERTISE_IP: &'static str = "base_node_advertise_ip"; + + /// The advertised tcp port via P2P. + pub const P2P_ADVERTISE_TCP_PORT: &'static str = "base_node_advertise_tcp"; + + /// The advertised udp port via P2P. + pub const P2P_ADVERTISE_UDP_PORT: &'static str = "base_node_advertise_udp"; + + /// The low-tide peer count. + pub const P2P_PEERS_LO: &'static str = "base_node_peers_lo"; + + /// The high-tide peer count. + pub const P2P_PEERS_HI: &'static str = "base_node_peers_hi"; + + /// The gossip mesh d option. + pub const P2P_GOSSIP_MESH_D: &'static str = "base_node_gossip_mesh_d"; + + /// The gossip mesh d lo option. + pub const P2P_GOSSIP_MESH_D_LO: &'static str = "base_node_gossip_mesh_d_lo"; + + /// The gossip mesh d hi option. + pub const P2P_GOSSIP_MESH_D_HI: &'static str = "base_node_gossip_mesh_d_hi"; + + /// The gossip mesh d lazy option. + pub const P2P_GOSSIP_MESH_D_LAZY: &'static str = "base_node_gossip_mesh_d_lazy"; + + /// The duration to ban peers. + pub const P2P_BAN_DURATION: &'static str = "base_node_ban_duration"; + + /// Hardfork activation times. + pub const HARDFORK_ACTIVATION_TIMES: &'static str = "base_node_hardforks"; + + /// Top-level rollup config settings. + pub const ROLLUP_CONFIG: &'static str = "base_node_rollup_config"; +} + +/// Initializes metrics for the rollup config. +pub fn init_rollup_config_metrics(config: &RollupConfig) { + metrics::describe_gauge!( + CliMetrics::ROLLUP_CONFIG, + "Rollup configuration settings for the OP Stack" + ); + metrics::describe_gauge!( + CliMetrics::HARDFORK_ACTIVATION_TIMES, + "Activation times for hardforks in the OP Stack" + ); + + metrics::gauge!( + CliMetrics::ROLLUP_CONFIG, + &[ + ("l1_genesis_block_num", config.genesis.l1.number.to_string()), + ("l2_genesis_block_num", config.genesis.l2.number.to_string()), + ("genesis_l2_time", config.genesis.l2_time.to_string()), + ("l1_chain_id", config.l1_chain_id.to_string()), + ("l2_chain_id", config.l2_chain_id.to_string()), + ("block_time", config.block_time.to_string()), + ("max_sequencer_drift", config.max_sequencer_drift.to_string()), + ("sequencer_window_size", config.seq_window_size.to_string()), + ("channel_timeout", config.channel_timeout.to_string()), + ("granite_channel_timeout", config.granite_channel_timeout.to_string()), + ("batch_inbox_address", config.batch_inbox_address.to_string()), + ("deposit_contract_address", config.deposit_contract_address.to_string()), + ("l1_system_config_address", config.l1_system_config_address.to_string()), + ("protocol_versions_address", config.protocol_versions_address.to_string()), + ] + ) + .set(1); + + for (fork_name, activation_time) in config.hardforks.iter() { + // Set the value of the metric for the given hardfork, using `-1` as a signal that the + // fork is not scheduled. + let time: f64 = activation_time.map(|t| t as f64).unwrap_or(-1f64); + metrics::gauge!(CliMetrics::HARDFORK_ACTIVATION_TIMES, "fork" => fork_name).set(time); + } +} diff --git a/crates/client/cli/README.md b/crates/client/cli/README.md index 6c318034..7000493c 100644 --- a/crates/client/cli/README.md +++ b/crates/client/cli/README.md @@ -8,6 +8,10 @@ This crate provides reusable CLI argument types for configuring Base node consen - **`L1ClientArgs`**: L1 execution client RPC configuration - **`L2ClientArgs`**: L2 engine API configuration with JWT handling +- **`BuilderClientArgs`**: Block builder client configuration with JWT handling +- **`RpcArgs`**: JSON-RPC server configuration +- **`SequencerArgs`**: Sequencer mode configuration +- **`RollupBoostFlags`**: Rollup boost block builder configuration ## Usage @@ -17,7 +21,7 @@ base-client-cli = { workspace = true } ``` ```rust -use base_client_cli::{L1ClientArgs, L2ClientArgs}; +use base_client_cli::{L1ClientArgs, L2ClientArgs, BuilderClientArgs}; use clap::Parser; #[derive(Parser)] @@ -26,6 +30,8 @@ struct Cli { l1_args: L1ClientArgs, #[clap(flatten)] l2_args: L2ClientArgs, + #[clap(flatten)] + builder_args: BuilderClientArgs, } ``` diff --git a/crates/client/cli/src/p2p.rs b/crates/client/cli/src/p2p.rs index aad6a15c..3be74b0c 100644 --- a/crates/client/cli/src/p2p.rs +++ b/crates/client/cli/src/p2p.rs @@ -687,4 +687,68 @@ mod tests { ] ); } + + #[test] + fn test_p2p_args_bootnode_enr() { + let args = MockCommand::parse_from([ + "test", + "--p2p.bootnodes", + "enr:-J64QBbwPjPLZ6IOOToOLsSjtFUjjzN66qmBZdUexpO32Klrc458Q24kbty2PdRaLacHM5z-cZQr8mjeQu3pik6jPSOGAYYFIqBfgmlkgnY0gmlwhDaRWFWHb3BzdGFja4SzlAUAiXNlY3AyNTZrMaECmeSnJh7zjKrDSPoNMGXoopeDF4hhpj5I0OsQUUt4u8uDdGNwgiQGg3VkcIIkBg", + ]); + assert_eq!( + args.p2p.bootnodes, + vec![ + "enr:-J64QBbwPjPLZ6IOOToOLsSjtFUjjzN66qmBZdUexpO32Klrc458Q24kbty2PdRaLacHM5z-cZQr8mjeQu3pik6jPSOGAYYFIqBfgmlkgnY0gmlwhDaRWFWHb3BzdGFja4SzlAUAiXNlY3AyNTZrMaECmeSnJh7zjKrDSPoNMGXoopeDF4hhpj5I0OsQUUt4u8uDdGNwgiQGg3VkcIIkBg", + ] + ); + } + + #[test] + fn test_p2p_args_listen_ip_dns_resolution() { + // Test that DNS hostnames are resolved to IP addresses + // Using localhost which should resolve reliably + let args = MockCommand::parse_from(["test", "--p2p.listen.ip", "localhost"]); + // localhost typically resolves to 127.0.0.1 or ::1 + assert!( + args.p2p.listen_ip == "127.0.0.1".parse::().unwrap() + || args.p2p.listen_ip == "::1".parse::().unwrap() + ); + } + + #[test] + fn test_p2p_args_advertise_ip_dns_resolution() { + // Test that DNS hostnames are resolved to IP addresses for advertise_ip + let args = MockCommand::parse_from(["test", "--p2p.advertise.ip", "localhost"]); + // localhost typically resolves to 127.0.0.1 or ::1 + let ip = args.p2p.advertise_ip.unwrap(); + assert!( + ip == "127.0.0.1".parse::().unwrap() || ip == "::1".parse::().unwrap() + ); + } + + #[test] + fn test_resolve_host_with_ip() { + // Test that IP addresses are passed through directly + let ip = resolve_host("192.168.1.1").unwrap(); + assert_eq!(ip, "192.168.1.1".parse::().unwrap()); + + let ipv6 = resolve_host("::1").unwrap(); + assert_eq!(ipv6, "::1".parse::().unwrap()); + } + + #[test] + fn test_resolve_host_with_dns() { + // Test DNS resolution with localhost + let ip = resolve_host("localhost").unwrap(); + assert!( + ip == "127.0.0.1".parse::().unwrap() || ip == "::1".parse::().unwrap() + ); + } + + #[test] + fn test_resolve_host_invalid() { + // Test that invalid hostnames return an error + let result = resolve_host("this-hostname-definitely-does-not-exist.invalid"); + assert!(result.is_err()); + } } diff --git a/crates/shared/cli-utils/src/metrics.rs b/crates/shared/cli-utils/src/metrics.rs index b0f38fb5..359d43e7 100644 --- a/crates/shared/cli-utils/src/metrics.rs +++ b/crates/shared/cli-utils/src/metrics.rs @@ -16,12 +16,12 @@ pub struct MetricsArgs { long = "metrics.enabled", global = true, default_value_t = false, - env = "KONA_METRICS_ENABLED" + env = "BASE_METRICS_ENABLED" )] pub enabled: bool, /// The port to serve Prometheus metrics on. - #[arg(long = "metrics.port", global = true, default_value = "9090", env = "KONA_METRICS_PORT")] + #[arg(long = "metrics.port", global = true, default_value = "9090", env = "BASE_METRICS_PORT")] pub port: u16, /// The IP address to use for Prometheus metrics. @@ -29,7 +29,7 @@ pub struct MetricsArgs { long = "metrics.addr", global = true, default_value = "0.0.0.0", - env = "KONA_METRICS_ADDR" + env = "BASE_METRICS_ADDR" )] pub addr: IpAddr, }