Skip to content

Commit 3bbb56e

Browse files
authored
feat(l1): show healing in progress message at set intervals (#2462)
**Motivation** We are not able to perform estimations on when healing will end, but we should also not stay completely silent while healing takes place, as this is not very user-friendly. This PR aims to add messages to inform wether state and storage healing are taking place, at the same pace as we show state sync and rebuild progress. For state sync, pending paths will be shown. These can give an insight on the progress, as the amount of paths will continuously increase as we progress through the trie, but will start gradually decreasing as we near the end of healing. For storages it is a slightly different story as we don't have the full number of pending storages available for showing so we only show the storages currently in the queue. <!-- Why does this pull request exist? What are its goals? --> **Description** * Periodically show amount of paths left during State Healing * Periodically show storages in queue during Storage Healing <!-- A clear and concise general description of the changes this PR introduces --> <!-- Link to issues: Resolves #111, Resolves #222 -->
1 parent 9e9ca0b commit 3bbb56e

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

crates/networking/p2p/sync/state_healing.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! This process will stop once it has fixed all trie inconsistencies or when the pivot becomes stale, in which case it can be resumed on the next cycle
99
//! All healed accounts will also have their bytecodes and storages healed by the corresponding processes
1010
11-
use std::cmp::min;
11+
use std::{cmp::min, time::Instant};
1212

1313
use ethrex_common::{
1414
types::{AccountState, EMPTY_KECCACK_HASH},
@@ -18,13 +18,13 @@ use ethrex_rlp::decode::RLPDecode;
1818
use ethrex_storage::Store;
1919
use ethrex_trie::{Nibbles, Node, EMPTY_TRIE_HASH};
2020
use tokio::sync::mpsc::{channel, Sender};
21-
use tracing::debug;
21+
use tracing::{debug, info};
2222

2323
use crate::{
2424
peer_handler::PeerHandler,
2525
sync::{
2626
bytecode_fetcher, node_missing_children, MAX_CHANNEL_MESSAGES, MAX_PARALLEL_FETCHES,
27-
NODE_BATCH_SIZE,
27+
NODE_BATCH_SIZE, SHOW_PROGRESS_INTERVAL_DURATION,
2828
},
2929
};
3030

@@ -47,7 +47,12 @@ pub(crate) async fn heal_state_trie(
4747
));
4848
// Add the current state trie root to the pending paths
4949
paths.push(Nibbles::default());
50+
let mut last_update = Instant::now();
5051
while !paths.is_empty() {
52+
if last_update.elapsed() >= SHOW_PROGRESS_INTERVAL_DURATION {
53+
last_update = Instant::now();
54+
info!("State Healing in Progress, pending paths: {}", paths.len());
55+
}
5156
// Spawn multiple parallel requests
5257
let mut state_tasks = tokio::task::JoinSet::new();
5358
for _ in 0..MAX_PARALLEL_FETCHES {

crates/networking/p2p/sync/storage_healing.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ use std::{
1616
use ethrex_common::H256;
1717
use ethrex_storage::Store;
1818
use ethrex_trie::{Nibbles, EMPTY_TRIE_HASH};
19+
use tokio::time::Instant;
1920
use tokio_util::sync::CancellationToken;
20-
use tracing::debug;
21+
use tracing::{debug, info};
2122

2223
use crate::{peer_handler::PeerHandler, sync::node_missing_children};
2324

2425
/// Minumum amount of storages to keep in the storage healer queue
2526
/// More paths will be read from the Store if the amount goes below this value
2627
const MINUMUM_STORAGES_IN_QUEUE: usize = 400;
2728

28-
use super::{SyncError, MAX_PARALLEL_FETCHES, NODE_BATCH_SIZE};
29+
use super::{SyncError, MAX_PARALLEL_FETCHES, NODE_BATCH_SIZE, SHOW_PROGRESS_INTERVAL_DURATION};
2930

3031
/// Waits for incoming hashed addresses from the receiver channel endpoint and queues the associated root nodes for state retrieval
3132
/// Also retrieves their children nodes until we have the full storage trie stored
@@ -41,7 +42,15 @@ pub(crate) async fn storage_healer(
4142
// List of paths in need of healing, grouped by hashed address
4243
let mut pending_paths = BTreeMap::<H256, Vec<Nibbles>>::new();
4344
let mut stale = false;
45+
let mut last_update = Instant::now();
4446
while !(stale || cancel_token.is_cancelled()) {
47+
if last_update.elapsed() >= SHOW_PROGRESS_INTERVAL_DURATION {
48+
last_update = Instant::now();
49+
info!(
50+
"Storage Healing in Progress, storages queued: {}",
51+
pending_paths.len()
52+
);
53+
}
4554
// If we have few storages in queue, fetch more from the store
4655
// We won't be retrieving all of them as the read can become quite long and we may not end up using all of the paths in this cycle
4756
if pending_paths.len() < MINUMUM_STORAGES_IN_QUEUE {

0 commit comments

Comments
 (0)