Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

FM-357: Notify the snapshot manager about new commits #389

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions fendermint/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fendermint_vm_interpreter = { path = "../vm/interpreter", features = ["bundle"]
fendermint_vm_message = { path = "../vm/message" }
fendermint_vm_resolver = { path = "../vm/resolver" }
fendermint_vm_topdown = { path = "../vm/topdown" }
fendermint_vm_snapshot = { path = "../vm/snapshot" }

fvm = { workspace = true }
fvm_ipld_blockstore = { workspace = true }
Expand Down
12 changes: 11 additions & 1 deletion fendermint/app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use fendermint_vm_interpreter::{
CheckInterpreter, ExecInterpreter, GenesisInterpreter, ProposalInterpreter, QueryInterpreter,
};
use fendermint_vm_message::query::FvmQueryHeight;
use fendermint_vm_snapshot::manager::SnapshotClient;
use fvm::engine::MultiEngine;
use fvm_ipld_blockstore::Blockstore;
use fvm_shared::chainid::ChainID;
Expand Down Expand Up @@ -169,6 +170,8 @@ where
resolve_pool: CheckpointPool,
/// The parent finality provider for top down checkpoint
parent_finality_provider: TopDownFinalityProvider,
/// Interface to the snapshotter, if enabled.
snapshots: Option<SnapshotClient>,
/// State accumulating changes during block execution.
exec_state: Arc<tokio::sync::Mutex<Option<FvmExecState<SS>>>>,
/// Projected (partial) state accumulating during transaction checks.
Expand Down Expand Up @@ -196,6 +199,7 @@ where
interpreter: I,
resolve_pool: CheckpointPool,
parent_finality_provider: TopDownFinalityProvider,
snapshots: Option<SnapshotClient>,
) -> Result<Self> {
let app = Self {
db: Arc::new(db),
Expand All @@ -208,6 +212,7 @@ where
interpreter: Arc::new(interpreter),
resolve_pool,
parent_finality_provider,
snapshots,
exec_state: Arc::new(tokio::sync::Mutex::new(None)),
check_state: Arc::new(tokio::sync::Mutex::new(None)),
};
Expand Down Expand Up @@ -803,6 +808,8 @@ where
state.state_params.circ_supply = circ_supply;

let app_hash = state.app_hash();
let block_height = state.block_height;
let state_params = state.state_params.clone();

tracing::debug!(
height = state.block_height,
Expand Down Expand Up @@ -834,7 +841,10 @@ where
let mut guard = self.check_state.lock().await;
*guard = None;

tracing::debug!("committed state");
// Notify the snapshotter.
if let Some(ref snapshots) = self.snapshots {
snapshots.on_commit(block_height, state_params).await;
}

let response = response::Commit {
data: app_hash.into(),
Expand Down
1 change: 1 addition & 0 deletions fendermint/app/src/cmd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ async fn run(settings: Settings) -> anyhow::Result<()> {
interpreter,
resolve_pool,
parent_finality_provider.clone(),
None,
)?;

if let Some((agent_proxy, config)) = ipc_tuple {
Expand Down
Loading