Skip to content

Commit

Permalink
Add mmr.commit() to MMR sync.
Browse files Browse the repository at this point in the history
  • Loading branch information
shamil-gadelshin authored and nazar-pc committed Nov 5, 2024
1 parent 903173f commit f15e6d5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/subspace-service/src/mmr/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl mmr_lib::Merge for MmrHasher {

const SYNC_PAUSE: Duration = Duration::from_secs(5);

// TODO: Add support for MMR-sync reruns from non-zero starting point.
/// Synchronize MMR-leafs from remote offchain storage of the synced peer.
pub async fn mmr_sync<Block, Client, NR, OS>(
fork_id: Option<String>,
Expand Down Expand Up @@ -242,6 +243,14 @@ where

// Should we request a new portion of the data from the last peer?
if target_position <= starting_position.into() {
if let Err(err) = mmr.commit() {
error!(?err, "MMR commit failed.");

return Err(sp_blockchain::Error::Application(
"Failed to commit MMR data.".into(),
));
}

// Actual MMR-nodes may exceed this number, however, we will catch up with the rest
// when we sync the remaining data (consensus and domain chains).
debug!("Target position reached: {target_position}");
Expand Down

0 comments on commit f15e6d5

Please sign in to comment.