-
Notifications
You must be signed in to change notification settings - Fork 176
test(l1): add FCU test for StateNotReachable case #5628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
f8834de
d84d392
abd937a
1cd1ad2
e390687
c73718e
63fe25b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2463,6 +2463,23 @@ impl Store { | |
| let last_computed_flatkeyvalue = self.last_written()?; | ||
| Ok(&last_computed_flatkeyvalue[0..64] > account_nibbles.as_ref()) | ||
| } | ||
|
|
||
| /// Clears the in-memory trie layer cache. | ||
| /// | ||
| /// # Warning | ||
| /// This is a test helper that simulates state pruning. **Do not use in production.** | ||
| /// | ||
| /// In production, state older than 128 blocks is pruned from the diff layers and | ||
| /// may not be available on disk if using InMemory backend (which has a 10000 block | ||
| /// threshold for disk commits). | ||
| /// | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Option 3 is fine for now, but worth considering for the rebase. |
||
| /// Use this to test scenarios where a reorg's common ancestor state is unavailable. | ||
| pub fn clear_trie_cache_for_testing(&self) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Silently ignoring lock poisoning: if another thread panicked while holding |
||
| use crate::layering::TrieLayerCache; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider |
||
| if let Ok(mut cache) = self.trie_cache.lock() { | ||
| *cache = Arc::new(TrieLayerCache::default()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| type TrieNodesUpdate = Vec<(Nibbles, Vec<u8>)>; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop builds 129 blocks, each calling
new_block(which creates aBlockchain, builds a payload) +add_block+apply_fork_choice. This is likely slow — consider reducingCHAIN_LENGTHand using a smaller threshold, or documenting that this test is intentionally slow.Alternatively, since
clear_trie_cache_for_testingnukes all cached state regardless of how many blocks were built, the 128-block threshold is only conceptually relevant (it motivates why state would be pruned). You could use a much smaller chain (e.g., 5 blocks) and the test would still verify the same code path.