diff --git a/Cargo.lock b/Cargo.lock index 94e6353..c38fe9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,9 +55,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27d301f5bcfd37e3aac727c360d8b50c33ddff9169ce0370198dedda36a9927d" +checksum = "c2179ba839ac532f50279f5da2a6c5047f791f03f6f808b4dfab11327b97902f" dependencies = [ "alloy-eips", "alloy-primitives", @@ -66,7 +66,7 @@ dependencies = [ "alloy-trie", "auto_impl", "c-kzg", - "derive_more 2.0.1", + "derive_more", "either", "k256", "once_cell", @@ -78,9 +78,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f4f97a85a45965e0e4f9f5b94bbafaa3e4ee6868bdbcf2e4a9acb4b358038fe" +checksum = "aec6f67bdc62aa277e0ec13c1b1fb396c8a62b65c8e9bd8c1d3583cc6d1a8dd3" dependencies = [ "alloy-consensus", "alloy-eips", @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "alloy-eip2124" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "675264c957689f0fd75f5993a73123c2cc3b5c235a38f5b9037fe6c826bfb2c0" +checksum = "741bdd7499908b3aa0b159bba11e71c8cddd009a2c2eb7a06e825f1ec87900a5" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -105,9 +105,9 @@ dependencies = [ [[package]] name = "alloy-eip2930" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0069cf0642457f87a01a014f6dc29d5d893cd4fd8fddf0c3cdfad1bb3ebafc41" +checksum = "dbe3e16484669964c26ac48390245d84c410b1a5f968976076c17184725ef235" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "alloy-eip7702" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b15b13d38b366d01e818fe8e710d4d702ef7499eacd44926a06171dd9585d0c" +checksum = "804cefe429015b4244966c006d25bda5545fa9db5990e9c9079faf255052f50a" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -128,9 +128,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10b11c382ca8075128d1ae6822b60921cf484c911d9a5831797a01218f98125f" +checksum = "609515c1955b33af3d78d26357540f68c5551a90ef58fd53def04f2aa074ec43" dependencies = [ "alloy-eip2124", "alloy-eip2930", @@ -140,7 +140,7 @@ dependencies = [ "alloy-serde", "auto_impl", "c-kzg", - "derive_more 2.0.1", + "derive_more", "either", "ethereum_ssz", "ethereum_ssz_derive", @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.25" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6beff64ad0aa6ad1019a3db26fef565aefeb011736150ab73ed3366c3cfd1b" +checksum = "5189fa9a8797e92396bc4b4454c5f2073a4945f7c2b366af9af60f9536558f7a" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -162,9 +162,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f736e1d1eb1b770dbd32919bdf46d4dcd4617f2eed07947dfb32649962baba" +checksum = "498f2ee2eef38a6db0fc810c7bf7daebdf5f2fa8d04adb8bd53e54e91ddbdea3" dependencies = [ "alloy-consensus", "alloy-eips", @@ -175,17 +175,17 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.25" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c77490fe91a0ce933a1f219029521f20fc28c2c0ca95d53fa4da9c00b8d9d4e" +checksum = "70b98b99c1dcfbe74d7f0b31433ff215e7d1555e367d90e62db904f3c9d4ff53" dependencies = [ "alloy-rlp", "bytes", "cfg-if 1.0.0", "const-hex", - "derive_more 2.0.1", + "derive_more", "foldhash", - "getrandom 0.2.15", + "getrandom 0.3.2", "hashbrown 0.15.2", "indexmap 2.8.0", "itoa", @@ -193,7 +193,7 @@ dependencies = [ "keccak-asm", "paste", "proptest", - "rand 0.8.5", + "rand 0.9.0", "ruint", "rustc-hash 2.1.1", "serde", @@ -225,16 +225,16 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "689521777149dabe210ef122605fb00050e038f2e85b8c9897534739f1a904f8" +checksum = "4235d79af20fe5583ca26096258fe9307571a345745c433cfd8c91b41aa2611e" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-serde", - "derive_more 2.0.1", + "derive_more", "ethereum_ssz", "ethereum_ssz_derive", "jsonwebtoken", @@ -245,9 +245,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8b6d55bdaa0c4a08650d4b32f174494cbade56adf6f2fcfa2a4f3490cb5511" +checksum = "f2a9f64e0f69cfb6029e2a044519a1bdd44ce9fc334d5315a7b9837f7a6748e5" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -265,9 +265,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1824791912f468a481dedc1db50feef3e85a078f6d743a62db2ee9c2ca674882" +checksum = "d4dba6ff08916bc0a9cbba121ce21f67c0b554c39cf174bc7b9df6c651bd3c3b" dependencies = [ "alloy-primitives", "serde", @@ -276,9 +276,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.25" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10ae8e9a91d328ae954c22542415303919aabe976fe7a92eb06db1b68fd59f2" +checksum = "60fcfa26956bcb22f66ab13407115197f26ef23abca5b48d39a1946897382d74" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -290,9 +290,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.25" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83ad5da86c127751bc607c174d6c9fe9b85ef0889a9ca0c641735d77d4f98f26" +checksum = "72a9b402f0013f1ff8c24066eeafc2207a8e52810a2b18b77776ce7fead5af41" dependencies = [ "alloy-sol-macro-input", "const-hex", @@ -308,9 +308,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.25" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3d30f0d3f9ba3b7686f3ff1de9ee312647aac705604417a2f40c604f409a9e" +checksum = "d02d61741337bb6b3f4899c2e3173fe17ffa2810e143d3b28acd953197c8dd79" dependencies = [ "const-hex", "dunce", @@ -324,9 +324,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.25" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d162f8524adfdfb0e4bd0505c734c985f3e2474eb022af32eef0d52a4f3935c" +checksum = "d2b5f5f9f561c29f78ea521ebe2e5ac1633f1b1442dae582f68ecd57c6350042" dependencies = [ "serde", "winnow", @@ -334,9 +334,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.25" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d43d5e60466a440230c07761aa67671d4719d46f43be8ea6e7ed334d8db4a9ab" +checksum = "c02635bce18205ff8149fb752c753b0a91ea3f3c8ee04c58846448be4811a640" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -347,14 +347,14 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.7.9" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a94854e420f07e962f7807485856cde359ab99ab6413883e15235ad996e8b" +checksum = "983d99aa81f586cef9dae38443245e585840fcf0fc58b09aee0b1f27aed1d500" dependencies = [ "alloy-primitives", "alloy-rlp", "arrayvec", - "derive_more 1.0.0", + "derive_more", "nybbles", "serde", "smallvec", @@ -678,7 +678,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9f7720b74ed28ca77f90769a71fd8c637a0137f6fae4ae947e1050229cff57f" dependencies = [ - "bindgen", + "bindgen 0.69.5", "cc", "cmake", "dunce", @@ -788,6 +788,24 @@ dependencies = [ "which", ] +[[package]] +name = "bindgen" +version = "0.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" +dependencies = [ + "bitflags 2.9.0", + "cexpr", + "clang-sys", + "itertools 0.13.0", + "proc-macro2", + "quote", + "regex", + "rustc-hash 1.1.0", + "shlex", + "syn 2.0.100", +] + [[package]] name = "bit-set" version = "0.8.0" @@ -1299,33 +1317,13 @@ dependencies = [ "syn 2.0.100", ] -[[package]] -name = "derive_more" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" -dependencies = [ - "derive_more-impl 1.0.0", -] - [[package]] name = "derive_more" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" dependencies = [ - "derive_more-impl 2.0.1", -] - -[[package]] -name = "derive_more-impl" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.100", + "derive_more-impl", ] [[package]] @@ -1479,9 +1477,9 @@ dependencies = [ [[package]] name = "ethereum_serde_utils" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70cbccfccf81d67bff0ab36e591fa536c8a935b078a7b0e58c1d00d418332fc9" +checksum = "3dc1355dbb41fbbd34ec28d4fb2a57d9a70c67ac3c19f6a5ca4d4a176b9e997a" dependencies = [ "alloy-primitives", "hex", @@ -1492,9 +1490,9 @@ dependencies = [ [[package]] name = "ethereum_ssz" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86da3096d1304f5f28476ce383005385459afeaf0eea08592b65ddbc9b258d16" +checksum = "9ca8ba45b63c389c6e115b095ca16381534fdcc03cf58176a3f8554db2dbe19b" dependencies = [ "alloy-primitives", "ethereum_serde_utils", @@ -1507,9 +1505,9 @@ dependencies = [ [[package]] name = "ethereum_ssz_derive" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d832a5c38eba0e7ad92592f7a22d693954637fbb332b4f669590d66a5c3183e5" +checksum = "0dd55d08012b4e0dfcc92b8d6081234df65f2986ad34cc76eeed69c5e2ce7506" dependencies = [ "darling", "proc-macro2", @@ -2524,6 +2522,17 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" +[[package]] +name = "libproc" +version = "0.14.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78a09b56be5adbcad5aa1197371688dc6bb249a26da3bca2011ee2fb987ebfb" +dependencies = [ + "bindgen 0.70.1", + "errno", + "libc", +] + [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -2571,6 +2580,15 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + [[package]] name = "macro-string" version = "0.1.4" @@ -2634,6 +2652,22 @@ dependencies = [ "tracing", ] +[[package]] +name = "metrics-process" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a82c8add4382f29a122fa64fff1891453ed0f6b2867d971e7d60cb8dfa322ff" +dependencies = [ + "libc", + "libproc", + "mach2", + "metrics", + "once_cell", + "procfs", + "rlimit", + "windows", +] + [[package]] name = "metrics-util" version = "0.19.0" @@ -2678,9 +2712,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" +checksum = "29c72f6929239626840b28f919ce8981a317fc5dc63ce25c30d2ab372f94886f" dependencies = [ "adler2", ] @@ -2855,32 +2889,32 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "op-alloy-consensus" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91764ebe0eddf6e3cfff41650332ff4e01defe372386027703f2e7e334734a05" +checksum = "1a09198717ebb22b201442c12a306a62de4a5d9535993b975c6bc0e5a919e2b1" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-serde", - "derive_more 2.0.1", + "derive_more", "serde", "thiserror 2.0.12", ] [[package]] name = "op-alloy-rpc-types-engine" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc26f8288839926d0137d39d70628bb5ac00fca449bab24c54cebd66c71b9cf4" +checksum = "b8ec35c34f8b74f329b0a43ab462c65943cf894406126b613e65e0e4313eaadb" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-primitives", "alloy-rpc-types-engine", "alloy-serde", - "derive_more 2.0.1", + "derive_more", "ethereum_ssz", "op-alloy-consensus", "serde", @@ -3277,6 +3311,28 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "procfs" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc5b72d8145275d844d4b5f6d4e1eef00c8cd889edb6035c21675d1bb1f45c9f" +dependencies = [ + "bitflags 2.9.0", + "hex", + "procfs-core", + "rustix 0.38.44", +] + +[[package]] +name = "procfs-core" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "239df02d8349b06fc07398a3a1697b06418223b1c7725085e801e7c0fc6a12ec" +dependencies = [ + "bitflags 2.9.0", + "hex", +] + [[package]] name = "proptest" version = "1.6.0" @@ -3392,6 +3448,7 @@ checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.3", + "serde", "zerocopy 0.8.24", ] @@ -3431,6 +3488,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ "getrandom 0.3.2", + "serde", ] [[package]] @@ -3552,8 +3610,8 @@ dependencies = [ [[package]] name = "reth-rpc-layer" -version = "1.3.7" -source = "git+https://github.com/paradigmxyz/reth.git?rev=v1.3.7#ed7da87da4de340a437bf46f39a7e1397ac82065" +version = "1.3.9" +source = "git+https://github.com/paradigmxyz/reth.git?rev=v1.3.9#00e5b6e01e3cf4c86cb3625f7aff52b81960d724" dependencies = [ "alloy-rpc-types-engine", "http", @@ -3588,6 +3646,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rlimit" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7043b63bd0cd1aaa628e476b80e6d4023a3b50eb32789f2728908107bd0c793a" +dependencies = [ + "libc", +] + [[package]] name = "rlp" version = "0.5.2" @@ -3624,6 +3691,7 @@ dependencies = [ "lazy_static", "metrics", "metrics-exporter-prometheus", + "metrics-process", "metrics-util", "moka", "nix", @@ -4272,9 +4340,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.25" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4560533fbd6914b94a8fb5cc803ed6801c3455668db3b810702c57612bac9412" +checksum = "34c9c96de1f835488c1501092847b522be88c9ac6fb0d4c0fbea92992324c8f4" dependencies = [ "paste", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index a2a5fce..e981e02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,12 +4,12 @@ version = "0.1.0" edition = "2024" [dependencies] -op-alloy-rpc-types-engine = "0.12.0" -alloy-rpc-types-engine = "0.13.0" -alloy-rpc-types-eth = "0.13.0" -alloy-serde = "0.13.0" -alloy-eips = { version = "0.13.0", features = ["serde"], optional = true } -alloy-primitives = { version = "0.8.10", features = ["rand"] } +op-alloy-rpc-types-engine = "0.13.0" +alloy-rpc-types-engine = "0.14.0" +alloy-rpc-types-eth = "0.14.0" +alloy-serde = "0.14.0" +alloy-eips = { version = "0.14.0", features = ["serde"], optional = true } +alloy-primitives = { version = "1.0.0", features = ["rand"] } tokio = { version = "1", features = ["full"] } tracing = "0.1.4" tracing-subscriber = { version = "0.3.11", features = ["env-filter", "json"] } @@ -41,6 +41,7 @@ tracing-opentelemetry = "0.29.0" futures = "0.3.31" metrics = "0.24.0" metrics-exporter-prometheus = "0.16.0" +metrics-process = "2.3.1" tokio-tungstenite = { version = "0.26.2", features = ["native-tls"] } url = "2.5" metrics-util = "0.19.0" @@ -53,14 +54,14 @@ time = { version = "0.3.36", features = ["macros", "formatting", "parsing"], opt lazy_static = {version = "1.5.0", optional = true } [dev-dependencies] -op-alloy-consensus = "0.12.0" +op-alloy-consensus = "0.13.0" anyhow = "1.0" assert_cmd = "2.0.10" predicates = "3.1.2" tokio-util = { version = "0.7.13" } nix = "0.15.0" bytes = "1.2" -reth-rpc-layer = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.3.7" } +reth-rpc-layer = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.3.9" } ctor = "0.4.1" [features] diff --git a/src/client/rpc.rs b/src/client/rpc.rs index bdf863e..8320b7d 100644 --- a/src/client/rpc.rs +++ b/src/client/rpc.rs @@ -12,6 +12,7 @@ use http::Uri; use jsonrpsee::http_client::transport::HttpBackend; use jsonrpsee::http_client::{HttpClient, HttpClientBuilder}; use jsonrpsee::types::ErrorObjectOwned; +use metrics::counter; use op_alloy_rpc_types_engine::{ OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4, OpExecutionPayloadV4, OpPayloadAttributes, @@ -153,6 +154,8 @@ impl RpcClient { } if res.is_invalid() { + error!("Invalid payload: {:?}. Payload status: {}", res.payload_id, res.payload_status.status); + counter!(format!("rpc_fork_choice_updated_v3_invalid_payload_{}", self.payload_source)).increment(1); return Err(RpcClientError::InvalidPayload( res.payload_status.status.to_string(), )) @@ -213,6 +216,8 @@ impl RpcClient { .set_code()?; if res.is_invalid() { + error!("Invalid payload (latest hash): {:?}. Payload status: {}", res.latest_valid_hash, res.status); + counter!(format!("rpc_new_payload_v3_invalid_payload_{}", self.payload_source)).increment(1); return Err(RpcClientError::InvalidPayload(res.status.to_string()).set_code()); } @@ -291,6 +296,8 @@ impl RpcClient { .set_code()?; if res.is_invalid() { + error!("Invalid payload (latest hash): {:?}. Payload status: {}", res.latest_valid_hash, res.status); + counter!(format!("rpc_new_payload_v4_invalid_payload_{}", self.payload_source)).increment(1); return Err(RpcClientError::InvalidPayload(res.status.to_string()).set_code()); } diff --git a/src/flashblocks/service.rs b/src/flashblocks/service.rs index af7c416..278c2e8 100644 --- a/src/flashblocks/service.rs +++ b/src/flashblocks/service.rs @@ -12,7 +12,7 @@ use std::sync::Arc; use thiserror::Error; use tokio::sync::RwLock; use tokio::sync::mpsc; -use tracing::error; +use tracing::{debug, error}; #[derive(Debug, Error)] pub enum FlashblocksError { #[error("Missing base payload for initial flashblock")] @@ -162,9 +162,16 @@ impl FlashblocksService { ) -> Result, FlashblocksError> { // consume the best payload and reset the builder let payload = { + debug!( + message = + "Acquiring best payload write lock: get_best_payload() to use best_payload" + ); let mut builder = self.best_payload.write().await; std::mem::take(&mut *builder).into_envelope()? }; + debug!( + message = "Acquiring best payload write lock: get_best_payload() to reset best_payload" + ); *self.best_payload.write().await = FlashblockBuilder::new(); Ok(Some(payload)) @@ -172,6 +179,9 @@ impl FlashblocksService { pub async fn set_current_payload_id(&self, payload_id: PayloadId) { tracing::debug!(message = "Setting current payload ID", payload_id = %payload_id); + debug!( + message = "Acquiring current payload id write lock: set_current_payload_id() to use current_payload_id" + ); *self.current_payload_id.write().await = payload_id; } @@ -185,12 +195,19 @@ impl FlashblocksService { ); // make sure the payload id matches the current payload id + debug!( + message = "Acquiring current payload id read lock: on_event() to use current_payload_id" + ); let current_payload_id = *self.current_payload_id.read().await; if current_payload_id != payload.payload_id { error!(message = "Payload ID mismatch", current_payload_id = %current_payload_id, payload_id = %payload.payload_id); return; } + debug!( + message = + "Acquiring best payload write lock: on_event() to extend best_payload" + ); if let Err(e) = self.best_payload.write().await.extend(payload.clone()) { error!(message = "Failed to extend payload", error = %e); } else { diff --git a/src/server.rs b/src/server.rs index 6d36789..4e42006 100644 --- a/src/server.rs +++ b/src/server.rs @@ -2,6 +2,7 @@ use crate::client::rpc::RpcClient; use crate::debug_api::DebugServer; use crate::flashblocks::FlashblocksService; use alloy_primitives::{B256, Bytes}; +use metrics::{counter, histogram}; use moka::sync::Cache; use opentelemetry::trace::SpanKind; use parking_lot::Mutex; @@ -27,6 +28,7 @@ use jsonrpsee::proc_macros::rpc; const CACHE_SIZE: u64 = 100; +#[derive(Debug, Clone)] pub struct PayloadTraceContext { block_hash_to_payload_ids: Cache>, payload_id: Cache)>, @@ -424,6 +426,38 @@ impl OpExecutionPayloadEnvelope { OpExecutionPayloadEnvelope::V4(_) => Version::V4, } } + pub fn transactions(&self) -> &[Bytes] { + match self { + OpExecutionPayloadEnvelope::V3(v3) => { + &v3.execution_payload + .payload_inner + .payload_inner + .transactions + } + OpExecutionPayloadEnvelope::V4(v4) => { + &v4.execution_payload + .payload_inner + .payload_inner + .payload_inner + .transactions + } + } + } + + pub fn gas_used(&self) -> u64 { + match self { + OpExecutionPayloadEnvelope::V3(v3) => { + v3.execution_payload.payload_inner.payload_inner.gas_used + } + OpExecutionPayloadEnvelope::V4(v4) => { + v4.execution_payload + .payload_inner + .payload_inner + .payload_inner + .gas_used + } + } + } } impl From for ExecutionPayload { @@ -534,10 +568,20 @@ impl RollupBoostServer { let builder = self.builder_client.clone(); let new_payload_clone = new_payload.clone(); tokio::spawn(async move { - let _ = builder.new_payload(new_payload_clone).await; + let result = builder.new_payload(new_payload_clone).await; + if let Err(_) = &result { + error!("Invalid payload (builder): {:?}", result); + counter!("block_building_invalid_builder_payload").increment(1); + } }); } - Ok(self.l2_client.new_payload(new_payload).await?) + let result = self.l2_client.new_payload(new_payload).await; + if let Err(_) = &result { + error!("Invalid payload (l2): {:?}", result); + counter!("block_building_invalid_l2_payload").increment(1); + } + + Ok(result?) } async fn get_payload( @@ -545,6 +589,9 @@ impl RollupBoostServer { payload_id: PayloadId, version: Version, ) -> RpcResult { + debug!(message = format!("payload_id: {:?}", payload_id)); + debug!(message = format!("payload_trace_context: {:?}", self.payload_trace_context)); + let l2_client_future = self.l2_client.get_payload(payload_id, version); let builder_client_future = Box::pin(async move { let execution_mode = self.execution_mode(); @@ -584,28 +631,49 @@ impl RollupBoostServer { let builder = self.builder_client.clone(); - // Fallback to the get_payload_v3 from the builder if no flashblocks payload is available - let payload = if let Some(payload) = payload { - info!(message = "using flashblocks payload"); - OpExecutionPayloadEnvelope::V3(payload) - } else { - builder.get_payload(payload_id, version).await? - }; + // // Fallback to the get_payload_v3 from the builder if no flashblocks payload is available + // let payload = if let Some(payload) = payload { + // info!(message = "using flashblocks payload"); + // OpExecutionPayloadEnvelope::V3(payload) + // } else { + // builder.get_payload(payload_id, version).await? + // }; + + if let Some(_) = payload { + info!(message = "flashblocks paylod found, but not using it"); + } + + let payload = builder.get_payload(payload_id, version).await?; // Send the payload to the local execution engine with engine_newPayload to validate the block from the builder. // Otherwise, we do not want to risk the network to a halt since op-node will not be able to propose the block. // If validation fails, return the local block since that one has already been validated. - let _ = self + + let result = self .l2_client .new_payload(NewPayload::from(payload.clone())) - .await?; - + .await; + if let Err(_) = &result { + counter!("block_building_invalid_l2_payload").increment(1); + } Ok(Some(payload)) }); let (l2_payload, builder_payload) = tokio::join!(l2_client_future, builder_client_future); + let (payload, context) = match (builder_payload, l2_payload) { - (Ok(Some(builder)), _) => Ok((builder, PayloadSource::Builder)), + (Ok(Some(builder)), Ok(l2)) => { + histogram!("block_building_gas_difference") + .record((builder.transactions().len() - l2.transactions().len()) as f64); + histogram!("block_building_tx_count_difference") + .record((builder.gas_used() - l2.gas_used()) as f64); + counter!("block_building_builder_payloads_returned").increment(1); + Ok((builder, PayloadSource::Builder)) + } + (Ok(Some(builder)), _) => { + counter!("block_building_builder_payloads_returned").increment(1); + Ok((builder, PayloadSource::Builder)) + } (_, Ok(l2)) => Ok((l2, PayloadSource::L2)), (_, Err(e)) => Err(e), }?;