From 506ab806e4007770c74b61cfaf4872a2a7d40247 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Thu, 19 Feb 2026 03:52:43 +0100 Subject: [PATCH] fix: propagate trie update diff result to trigger debug recorder writes (#22331) Co-authored-by: Amp --- .changelog/odd-donkeys-chirp.md | 5 +++++ .../engine/tree/src/tree/payload_validator.rs | 17 ++++++++++------- crates/engine/tree/src/tree/trie_updates.rs | 7 +++++-- 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 .changelog/odd-donkeys-chirp.md diff --git a/.changelog/odd-donkeys-chirp.md b/.changelog/odd-donkeys-chirp.md new file mode 100644 index 0000000000..22629f46d3 --- /dev/null +++ b/.changelog/odd-donkeys-chirp.md @@ -0,0 +1,5 @@ +--- +reth-engine-tree: patch +--- + +Fixed `compare_trie_updates` to return `bool` indicating whether differences were found, and updated the caller to properly use the return value instead of treating all successful comparisons as having no differences. diff --git a/crates/engine/tree/src/tree/payload_validator.rs b/crates/engine/tree/src/tree/payload_validator.rs index a18e72712c..da18967c18 100644 --- a/crates/engine/tree/src/tree/payload_validator.rs +++ b/crates/engine/tree/src/tree/payload_validator.rs @@ -1104,17 +1104,20 @@ where // Get a database provider to use as trie cursor factory match overlay_factory.database_provider_ro() { Ok(provider) => { - if let Err(err) = super::trie_updates::compare_trie_updates( + match super::trie_updates::compare_trie_updates( &provider, task_trie_updates, serial_trie_updates, ) { - warn!( - target: "engine::tree::payload_validator", - %err, - "Error comparing trie updates" - ); - return true; + Ok(has_diff) => return has_diff, + Err(err) => { + warn!( + target: "engine::tree::payload_validator", + %err, + "Error comparing trie updates" + ); + return true; + } } } Err(err) => { diff --git a/crates/engine/tree/src/tree/trie_updates.rs b/crates/engine/tree/src/tree/trie_updates.rs index 332aec24bd..a757d55571 100644 --- a/crates/engine/tree/src/tree/trie_updates.rs +++ b/crates/engine/tree/src/tree/trie_updates.rs @@ -101,11 +101,13 @@ impl StorageTrieUpdatesDiff { /// Compares the trie updates from state root task, regular state root calculation and database, /// and logs the differences if there's any. +/// +/// Returns `true` if there are differences. pub(crate) fn compare_trie_updates( trie_cursor_factory: impl TrieCursorFactory, task: TrieUpdates, regular: TrieUpdates, -) -> Result<(), DatabaseError> { +) -> Result { let mut task = adjust_trie_updates(task); let mut regular = adjust_trie_updates(regular); @@ -179,9 +181,10 @@ pub(crate) fn compare_trie_updates( } // log differences + let has_differences = diff.has_differences(); diff.log_differences(); - Ok(()) + Ok(has_differences) } fn compare_storage_trie_updates(