Skip to content
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

feat(state-sync): drop old state parts at the end of epoch #12200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions chain/chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,15 @@ impl Chain {
};
let (apply_chunk_work, block_preprocess_info) = preprocess_res;

// Delete state sync files if needed.
if self.epoch_manager.is_next_block_epoch_start(block.header().prev_hash())? {
// This is the end of the epoch. Next epoch we will generate new state parts. We can drop the old ones.
let mut store_update = self.chain_store.store().store_update();
store_update.delete_all(DBCol::StateParts);
store_update.delete_all(DBCol::StateHeaders);
store_update.commit()?;
}

// 2) Start creating snapshot if needed.
if let Err(err) = self.process_snapshot() {
tracing::error!(target: "state_snapshot", ?err, "Failed to make a state snapshot");
Expand Down
Loading