From 268162e13757bb542927144953a522e54009365d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 6 Dec 2025 13:47:05 +0100 Subject: [PATCH 1/2] fix: make inserted blocks part of fcu canonical --- Cargo.lock | 120 ++++++++++++++--------------- Cargo.toml | 54 ++++++------- crates/engine/tree/src/tree/mod.rs | 27 +++++-- 3 files changed, 109 insertions(+), 92 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7460cfc0513..2b135437352 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6440213a22df93a87ed512d2f668e7dc1d62a05642d107f82d61edc9e12370" +checksum = "2e318e25fb719e747a7e8db1654170fc185024f3ed5b10f86c08d448a912f6e2" dependencies = [ "alloy-eips", "alloy-primitives", @@ -140,9 +140,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d0bea09287942405c4f9d2a4f22d1e07611c2dbd9d5bf94b75366340f9e6e0" +checksum = "364380a845193a317bcb7a5398fc86cdb66c47ebe010771dde05f6869bf9e64a" dependencies = [ "alloy-consensus", "alloy-eips", @@ -155,9 +155,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d69af404f1d00ddb42f2419788fa87746a4cd13bab271916d7726fda6c792d94" +checksum = "08d39c80ffc806f27a76ed42f3351a455f3dc4f81d6ff92c8aad2cf36b7d3a34" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -240,9 +240,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd2c7ae05abcab4483ce821f12f285e01c0b33804e6883dd9ca1569a87ee2be" +checksum = "a4c4d7c5839d9f3a467900c625416b24328450c65702eb3d8caff8813e4d1d33" dependencies = [ "alloy-eip2124", "alloy-eip2930", @@ -288,9 +288,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc47eaae86488b07ea8e20236184944072a78784a1f4993f8ec17b3aa5d08c21" +checksum = "1ba4b1be0988c11f0095a2380aa596e35533276b8fa6c9e06961bbfe0aebcac5" dependencies = [ "alloy-eips", "alloy-primitives", @@ -329,9 +329,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003f46c54f22854a32b9cc7972660a476968008ad505427eabab49225309ec40" +checksum = "f72cf87cda808e593381fb9f005ffa4d2475552b7a6c5ac33d087bf77d82abd0" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -344,9 +344,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4029954d9406a40979f3a3b46950928a0fdcfe3ea8a9b0c17490d57e8aa0e3" +checksum = "12aeb37b6f2e61b93b1c3d34d01ee720207c76fe447e2a2c217e433ac75b17f5" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -370,9 +370,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7805124ad69e57bbae7731c9c344571700b2a18d351bda9e0eba521c991d1bcb" +checksum = "abd29ace62872083e30929cd9b282d82723196d196db589f3ceda67edcc05552" dependencies = [ "alloy-consensus", "alloy-eips", @@ -444,9 +444,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d369e12c92870d069e0c9dc5350377067af8a056e29e3badf8446099d7e00889" +checksum = "9b710636d7126e08003b8217e24c09f0cca0b46d62f650a841736891b1ed1fc1" dependencies = [ "alloy-chains", "alloy-consensus", @@ -489,9 +489,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f77d20cdbb68a614c7a86b3ffef607b37d087bb47a03c58f4c3f8f99bc3ace3b" +checksum = "cdd4c64eb250a18101d22ae622357c6b505e158e9165d4c7974d59082a600c5e" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -533,9 +533,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c89883fe6b7381744cbe80fef638ac488ead4f1956a4278956a1362c71cd2e" +checksum = "d0882e72d2c1c0c79dcf4ab60a67472d3f009a949f774d4c17d0bdb669cfde05" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -559,9 +559,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e279e6d40ee40fe8f76753b678d8d5d260cb276dc6c8a8026099b16d2b43f4" +checksum = "39cf1398cb33aacb139a960fa3d8cf8b1202079f320e77e952a0b95967bf7a9f" dependencies = [ "alloy-primitives", "alloy-rpc-types-engine", @@ -572,9 +572,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-admin" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bcf50ccb65d29b8599f8f5e23dcac685f1d79459654c830cba381345760e901" +checksum = "65a583d2029b171301f5dcf122aa2ef443a65a373778ec76540d999691ae867d" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -584,9 +584,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e176c26fdd87893b6afeb5d92099d8f7e7a1fe11d6f4fe0883d6e33ac5f31ba" +checksum = "c3ce4c24e416bd0f17fceeb2f26cd8668df08fe19e1dc02f9d41c3b8ed1e93e0" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -596,9 +596,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b43c1622aac2508d528743fd4cfdac1dea92d5a8fa894038488ff7edd0af0b32" +checksum = "6a63fb40ed24e4c92505f488f9dd256e2afaed17faa1b7a221086ebba74f4122" dependencies = [ "alloy-consensus-any", "alloy-rpc-types-eth", @@ -607,9 +607,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-beacon" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1786681640d4c60f22b6b8376b0f3fa200360bf1c3c2cb913e6c97f51928eb1b" +checksum = "16633087e23d8d75161c3a59aa183203637b817a5a8d2f662f612ccb6d129af0" dependencies = [ "alloy-eips", "alloy-primitives", @@ -627,9 +627,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-debug" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b2ca3a434a6d49910a7e8e51797eb25db42ef8a5578c52d877fcb26d0afe7bc" +checksum = "4936f579d9d10eae01772b2ab3497f9d568684f05f26f8175e12f9a1a2babc33" dependencies = [ "alloy-primitives", "derive_more", @@ -639,9 +639,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4c53a8b0905d931e7921774a1830609713bd3e8222347963172b03a3ecc68" +checksum = "4c60bdce3be295924122732b7ecd0b2495ce4790bedc5370ca7019c08ad3f26e" dependencies = [ "alloy-consensus", "alloy-eips", @@ -660,9 +660,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed5fafb741c19b3cca4cdd04fa215c89413491f9695a3e928dee2ae5657f607e" +checksum = "9eae0c7c40da20684548cbc8577b6b7447f7bf4ddbac363df95e3da220e41e72" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -682,9 +682,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-mev" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a97bfc6d9b411c85bb08e1174ddd3e5d61b10d3bd13f529d6609f733cb2f6f" +checksum = "81c0dd81c24944cfbf45b5df7cd149d9cd3e354db81ccf08aa47e0e05be8ab97" dependencies = [ "alloy-consensus", "alloy-eips", @@ -697,9 +697,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55324323aa634b01bdecb2d47462a8dce05f5505b14a6e5db361eef16eda476" +checksum = "ef206a4b8d436fbb7cf2e6a61c692d11df78f9382becc3c9a283bd58e64f0583" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -711,9 +711,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b1aa28effb6854be356ce92ed64cea3b323acd04c3f8bfb5126e2839698043" +checksum = "ecb5a795264a02222f9534435b8f40dcbd88de8e9d586647884aae24f389ebf2" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -723,9 +723,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f180c399ca7c1e2fe17ea58343910cad0090878a696ff5a50241aee12fc529" +checksum = "c0df1987ed0ff2d0159d76b52e7ddfc4e4fbddacc54d2fbee765e0d14d7c01b5" dependencies = [ "alloy-primitives", "arbitrary", @@ -735,9 +735,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc39ad2c0a3d2da8891f4081565780703a593f090f768f884049aa3aa929cbc" +checksum = "6ff69deedee7232d7ce5330259025b868c5e6a52fa8dffda2c861fb3a5889b24" dependencies = [ "alloy-primitives", "async-trait", @@ -750,9 +750,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "930e17cb1e46446a193a593a3bfff8d0ecee4e510b802575ebe300ae2e43ef75" +checksum = "72cfe0be3ec5a8c1a46b2e5a7047ed41121d360d97f4405bb7c1c784880c86cb" dependencies = [ "alloy-consensus", "alloy-network", @@ -839,9 +839,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cae82426d98f8bc18f53c5223862907cac30ab8fc5e4cd2bb50808e6d3ab43d8" +checksum = "be98b07210d24acf5b793c99b759e9a696e4a2e67593aec0487ae3b3e1a2478c" dependencies = [ "alloy-json-rpc", "auto_impl", @@ -862,9 +862,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90aa6825760905898c106aba9c804b131816a15041523e80b6d4fe7af6380ada" +checksum = "4198a1ee82e562cab85e7f3d5921aab725d9bd154b6ad5017f82df1695877c97" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -877,9 +877,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ace83a4a6bb896e5894c3479042e6ba78aa5271dde599aa8c36a021d49cc8cc" +checksum = "d8db249779ebc20dc265920c7e706ed0d31dbde8627818d1cbde60919b875bb0" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -897,9 +897,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86c9ab4c199e3a8f3520b60ba81aa67bb21fed9ed0d8304e0569094d0758a56f" +checksum = "5ad2344a12398d7105e3722c9b7a7044ea837128e11d453604dec6e3731a86e2" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -935,9 +935,9 @@ dependencies = [ [[package]] name = "alloy-tx-macros" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae109e33814b49fc0a62f2528993aa8a2dd346c26959b151f05441dc0b9da292" +checksum = "333544408503f42d7d3792bfc0f7218b643d968a03d2c0ed383ae558fb4a76d0" dependencies = [ "darling 0.21.3", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 0294a059f8e..8533bbf7f37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -495,33 +495,33 @@ alloy-trie = { version = "0.9.1", default-features = false } alloy-hardforks = "0.4.5" -alloy-consensus = { version = "1.1.2", default-features = false } -alloy-contract = { version = "1.1.2", default-features = false } -alloy-eips = { version = "1.1.2", default-features = false } -alloy-genesis = { version = "1.1.2", default-features = false } -alloy-json-rpc = { version = "1.1.2", default-features = false } -alloy-network = { version = "1.1.2", default-features = false } -alloy-network-primitives = { version = "1.1.2", default-features = false } -alloy-provider = { version = "1.1.2", features = ["reqwest", "debug-api"], default-features = false } -alloy-pubsub = { version = "1.1.2", default-features = false } -alloy-rpc-client = { version = "1.1.2", default-features = false } -alloy-rpc-types = { version = "1.1.2", features = ["eth"], default-features = false } -alloy-rpc-types-admin = { version = "1.1.2", default-features = false } -alloy-rpc-types-anvil = { version = "1.1.2", default-features = false } -alloy-rpc-types-beacon = { version = "1.1.2", default-features = false } -alloy-rpc-types-debug = { version = "1.1.2", default-features = false } -alloy-rpc-types-engine = { version = "1.1.2", default-features = false } -alloy-rpc-types-eth = { version = "1.1.2", default-features = false } -alloy-rpc-types-mev = { version = "1.1.2", default-features = false } -alloy-rpc-types-trace = { version = "1.1.2", default-features = false } -alloy-rpc-types-txpool = { version = "1.1.2", default-features = false } -alloy-serde = { version = "1.1.2", default-features = false } -alloy-signer = { version = "1.1.2", default-features = false } -alloy-signer-local = { version = "1.1.2", default-features = false } -alloy-transport = { version = "1.1.2" } -alloy-transport-http = { version = "1.1.2", features = ["reqwest-rustls-tls"], default-features = false } -alloy-transport-ipc = { version = "1.1.2", default-features = false } -alloy-transport-ws = { version = "1.1.2", default-features = false } +alloy-consensus = { version = "1.1.3", default-features = false } +alloy-contract = { version = "1.1.3", default-features = false } +alloy-eips = { version = "1.1.3", default-features = false } +alloy-genesis = { version = "1.1.3", default-features = false } +alloy-json-rpc = { version = "1.1.3", default-features = false } +alloy-network = { version = "1.1.3", default-features = false } +alloy-network-primitives = { version = "1.1.3", default-features = false } +alloy-provider = { version = "1.1.3", features = ["reqwest", "debug-api"], default-features = false } +alloy-pubsub = { version = "1.1.3", default-features = false } +alloy-rpc-client = { version = "1.1.3", default-features = false } +alloy-rpc-types = { version = "1.1.3", features = ["eth"], default-features = false } +alloy-rpc-types-admin = { version = "1.1.3", default-features = false } +alloy-rpc-types-anvil = { version = "1.1.3", default-features = false } +alloy-rpc-types-beacon = { version = "1.1.3", default-features = false } +alloy-rpc-types-debug = { version = "1.1.3", default-features = false } +alloy-rpc-types-engine = { version = "1.1.3", default-features = false } +alloy-rpc-types-eth = { version = "1.1.3", default-features = false } +alloy-rpc-types-mev = { version = "1.1.3", default-features = false } +alloy-rpc-types-trace = { version = "1.1.3", default-features = false } +alloy-rpc-types-txpool = { version = "1.1.3", default-features = false } +alloy-serde = { version = "1.1.3", default-features = false } +alloy-signer = { version = "1.1.3", default-features = false } +alloy-signer-local = { version = "1.1.3", default-features = false } +alloy-transport = { version = "1.1.3" } +alloy-transport-http = { version = "1.1.3", features = ["reqwest-rustls-tls"], default-features = false } +alloy-transport-ipc = { version = "1.1.3", default-features = false } +alloy-transport-ws = { version = "1.1.3", default-features = false } # op alloy-op-evm = { version = "0.24.1", default-features = false } diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index 2e39ecd919f..451a55538ee 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -1901,6 +1901,16 @@ where false } + /// Returns true if the given hash is part of the last received sync target fork choice update. + /// + /// See [`ForkchoiceStateTracker::sync_target_state`] + fn is_any_sync_target(&self, block_hash: B256) -> bool { + if let Some(target) = self.state.forkchoice_state_tracker.sync_target_state() { + return target.contains(block_hash) + } + false + } + /// Checks if the given `check` hash points to an invalid header, inserting the given `head` /// block into the invalid header cache if the `check` hash has a known invalid ancestor. /// @@ -2040,9 +2050,12 @@ where match self.insert_block(child) { Ok(res) => { debug!(target: "engine::tree", child =?child_num_hash, ?res, "connected buffered block"); - if self.is_sync_target_head(child_num_hash.hash) && + if self.is_any_sync_target(child_num_hash.hash) && matches!(res, InsertPayloadOk::Inserted(BlockStatus::Valid)) { + debug!(target: "engine::tree", child =?child_num_hash, "connected sync target block"); + // we just inserted a block that we know is part of the canonical chain, so + // we can make it canonical self.make_canonical(child_num_hash.hash)?; } } @@ -2348,11 +2361,15 @@ where // try to append the block match self.insert_block(block) { Ok(InsertPayloadOk::Inserted(BlockStatus::Valid)) => { - if self.is_sync_target_head(block_num_hash.hash) { - trace!(target: "engine::tree", "appended downloaded sync target block"); + // check if we just inserted a block that's part of sync targets, + // head,safe,finalized + if let Some(sync_target) = self.state.forkchoice_state_tracker.sync_target_state() && + sync_target.contains(block_num_hash.hash) + { + debug!(target: "engine::tree", ?sync_target, "appended downloaded sync target block"); - // we just inserted the current sync target block, we can try to make it - // canonical + // we just inserted a block that we know is part of the canonical chain, so we + // can make it canonical return Ok(Some(TreeEvent::TreeAction(TreeAction::MakeCanonical { sync_target_head: block_num_hash.hash, }))) From 5cb08969cfab8477d68ed859749165e010d4cdda Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 8 Dec 2025 11:55:03 +0100 Subject: [PATCH 2/2] Update crates/engine/tree/src/tree/mod.rs Co-authored-by: Alexey Shekhirin <5773434+shekhirin@users.noreply.github.com> --- crates/engine/tree/src/tree/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index 451a55538ee..7bc9811495d 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -2362,7 +2362,7 @@ where match self.insert_block(block) { Ok(InsertPayloadOk::Inserted(BlockStatus::Valid)) => { // check if we just inserted a block that's part of sync targets, - // head,safe,finalized + // i.e. head, safe, or finalized if let Some(sync_target) = self.state.forkchoice_state_tracker.sync_target_state() && sync_target.contains(block_num_hash.hash) {