From 43d7a9d5a95f44d188b5e8c8eba3053fd08fc8ae Mon Sep 17 00:00:00 2001 From: ZanCorDX <126988525+ZanCorDX@users.noreply.github.com> Date: Fri, 7 Mar 2025 11:56:47 -0300 Subject: [PATCH] better check on some errors (#476) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📝 Summary We had some obfuscating ERROR traces. ## 💡 Motivation and Context I don't like to be woken up in the middle of the night for a false alarm. ## ✅ I have completed the following steps: * [X] Run `make lint` * [X] Run `make test` * [ ] Added tests (if applicable) --- crates/eth-sparse-mpt/src/reth_sparse_trie/mod.rs | 11 +++++++++++ crates/rbuilder/src/roothash/mod.rs | 12 +++++++++--- crates/rbuilder/src/roothash/prefetcher.rs | 4 +++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/crates/eth-sparse-mpt/src/reth_sparse_trie/mod.rs b/crates/eth-sparse-mpt/src/reth_sparse_trie/mod.rs index 9c266e168..6fe27a082 100644 --- a/crates/eth-sparse-mpt/src/reth_sparse_trie/mod.rs +++ b/crates/eth-sparse-mpt/src/reth_sparse_trie/mod.rs @@ -46,6 +46,17 @@ pub enum SparseTrieError { FailedToFetchData, } +impl SparseTrieError { + /// When reth's block tip changes we generate an error which is not really critical. + /// We have this func so we can avoid logging it. + /// This could be unstable due to reth changes, DON'T use as a real error check. + pub fn is_db_consistency_error(&self) -> bool { + matches!( + self, + SparseTrieError::FailedToUpdateSharedCache(AddNodeError::InconsistentProofs) + ) + } +} #[derive(Debug)] pub struct ChangedAccountData { pub address: Address, diff --git a/crates/rbuilder/src/roothash/mod.rs b/crates/rbuilder/src/roothash/mod.rs index f626a3133..d8a226dcd 100644 --- a/crates/rbuilder/src/roothash/mod.rs +++ b/crates/rbuilder/src/roothash/mod.rs @@ -46,9 +46,15 @@ impl RootHashError { pub fn is_consistent_db_view_err(&self) -> bool { let provider_error = match self { RootHashError::AsyncStateRoot(ParallelStateRootError::Provider(p)) => p, - RootHashError::SparseStateRoot(SparseTrieError::FetchNode( - FetchNodeError::Provider(p), - )) => p, + RootHashError::SparseStateRoot(sparse_state_root_err) => { + if let SparseTrieError::FetchNode(FetchNodeError::Provider(p)) = + sparse_state_root_err + { + p + } else { + return sparse_state_root_err.is_db_consistency_error(); + } + } _ => return false, }; diff --git a/crates/rbuilder/src/roothash/prefetcher.rs b/crates/rbuilder/src/roothash/prefetcher.rs index cd666cd3d..a6912d683 100644 --- a/crates/rbuilder/src/roothash/prefetcher.rs +++ b/crates/rbuilder/src/roothash/prefetcher.rs @@ -156,7 +156,9 @@ pub fn run_trie_prefetcher

( return; } Err(err) => { - error!(?err, "Error while prefetching trie nodes"); + if !err.is_db_consistency_error() { + error!(?err, "Error while prefetching trie nodes"); + } } } trace!(