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

Gap Synced blocks are kept even though they are out of pruning window #5119

Open
skunert opened this issue Jul 23, 2024 · 4 comments
Open

Gap Synced blocks are kept even though they are out of pruning window #5119

skunert opened this issue Jul 23, 2024 · 4 comments

Comments

@skunert
Copy link
Contributor

skunert commented Jul 23, 2024

While reviewing #5103 I was wondering how we handle gap synced blocks together with a block pruning setting.

After warp sync reached the top and we have downloaded the state, the tip of the chain continues with normal sync operations. In the meantime, the gap between genesis and the warp target block is being downloaded from the other peers.
We issue the peer gap block requests here:

fn peer_gap_block_request<B: BlockT>(
id: &PeerId,

Attributes to fetch are defined here and show that we fetch bodies too:

fn required_block_attributes(&self) -> BlockAttributes {
match self.mode {
ChainSyncMode::Full =>
BlockAttributes::HEADER | BlockAttributes::JUSTIFICATION | BlockAttributes::BODY,
ChainSyncMode::LightState { storage_chain_mode: false, .. } =>
BlockAttributes::HEADER | BlockAttributes::JUSTIFICATION | BlockAttributes::BODY,
ChainSyncMode::LightState { storage_chain_mode: true, .. } =>
BlockAttributes::HEADER |
BlockAttributes::JUSTIFICATION |
BlockAttributes::INDEXED_BODY,
}
}

However the pruning of block bodies only happens by pruning the current finalized block - pruning window.

Ok(())
}

So my suspicion is that the gap blocks are currently all kept (but should be verified). Another question for me currently is why we even download block bodies for gap sync.

@tmpolaczyk
Copy link
Contributor

So my suspicion is that the gap blocks are currently all kept

That's correct.

Another question for me currently is why we even download block bodies for gap sync.

There is some related discussion in #2710, where I tried to add a flag to disable the block history download, but then I realized that simply enabling block prunning should already skip the block download. But that doesn't work.

I would be happy if this is fixed, warp sync would use much fewer resources if it didn't have to download the block history when it is not needed.

@lexnv
Copy link
Contributor

lexnv commented Jul 24, 2024

cc #2738

@skunert skunert added this to SDK Node Jul 24, 2024
@github-project-automation github-project-automation bot moved this to backlog in SDK Node Jul 24, 2024
@nazar-pc
Copy link
Contributor

I'd love to see gap sync decoupled somehow as in our blockchain we don't even attempt to sync the gap at all and had to prevent gap sync with a hack: autonomys@799ca7c

Ideally gap sync would not be initiated at all, but right now Substrate assumes gap means warp sync, which is not necessarily true for projects that do much deeper customizations than parachains typically do.

@bkchr
Copy link
Member

bkchr commented Jul 24, 2024

I'd love to see gap sync decoupled somehow as in our blockchain we don't even attempt to sync the gap

Yeah. We need to improve this. We probably need to keep the Gap in the db. However, we should be more smart when it comes to closing this Gap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: backlog
Development

No branches or pull requests

5 participants