diff --git a/crates/storage/provider/src/providers/state/overlay.rs b/crates/storage/provider/src/providers/state/overlay.rs index b233d621b7..97baab150e 100644 --- a/crates/storage/provider/src/providers/state/overlay.rs +++ b/crates/storage/provider/src/providers/state/overlay.rs @@ -129,6 +129,8 @@ impl OverlayStateProviderFactory { /// This overlay will be applied on top of any reverts applied via `with_block_hash`. pub fn with_overlay_source(mut self, source: Option) -> Self { self.overlay_source = source; + // Clear the overlay cache since we've updated the source. + self.overlay_cache = Default::default(); self } @@ -137,6 +139,8 @@ impl OverlayStateProviderFactory { /// Convenience method that wraps the lazy overlay in `OverlaySource::Lazy`. pub fn with_lazy_overlay(mut self, lazy_overlay: Option) -> Self { self.overlay_source = lazy_overlay.map(OverlaySource::Lazy); + // Clear the overlay cache since we've updated the source. + self.overlay_cache = Default::default(); self } @@ -152,6 +156,8 @@ impl OverlayStateProviderFactory { trie: Arc::new(TrieUpdatesSorted::default()), state, }); + // Clear the overlay cache since we've updated the source. + self.overlay_cache = Default::default(); } self } @@ -178,6 +184,8 @@ impl OverlayStateProviderFactory { }); } } + // Clear the overlay cache since we've updated the source. + self.overlay_cache = Default::default(); self } }