-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Allow to disable gap creation during block import #5343
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
Changes from 9 commits
d793877
714f587
72787ef
ec3ba21
299a8a0
4e87e24
4c23ba7
d70bfb1
f88dc13
5d7d2f3
dad8b83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| title: Allow to disable gap creation during block import | ||
|
|
||
| doc: | ||
| - audience: Node Dev | ||
| description: | | ||
| New property `BlockImportParams::create_gap` allows to change whether to create block gap in case block | ||
| has no parent (defaults to `true` keeping existing behavior), which is helpful for sync protocols that do not need | ||
| to sync the gap after this happens. `BlockImportOperation::create_gap()` method was also introduced, though in | ||
| most cases `BlockImportParams::create_gap` will be used. | ||
|
|
||
| crates: | ||
| - name: sc-client-api | ||
| bump: major | ||
| - name: sc-consensus | ||
| bump: minor | ||
| - name: sc-client-db | ||
| bump: minor | ||
| - name: sc-service | ||
| bump: minor |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -841,6 +841,7 @@ pub struct BlockImportOperation<Block: BlockT> { | |
| finalized_blocks: Vec<(Block::Hash, Option<Justification>)>, | ||
| set_head: Option<Block::Hash>, | ||
| commit_state: bool, | ||
| create_gap: bool, | ||
| index_ops: Vec<IndexOperation>, | ||
| } | ||
|
|
||
|
|
@@ -995,6 +996,10 @@ impl<Block: BlockT> sc_client_api::backend::BlockImportOperation<Block> | |
| self.index_ops = index_ops; | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn create_gap(&mut self, create_gap: bool) { | ||
| self.create_gap = create_gap; | ||
| } | ||
| } | ||
|
|
||
| struct StorageDb<Block: BlockT> { | ||
|
|
@@ -1707,8 +1712,9 @@ impl<Block: BlockT> Backend<Block> { | |
| &(start, end).encode(), | ||
| ); | ||
| } | ||
| } else if number > best_num + One::one() && | ||
| number > One::one() && self.blockchain.header(parent_hash)?.is_none() | ||
| } else if operation.create_gap && | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc #4984
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not exactly sure how it is related necessarily, it still had to pass through consensus successfully before ending up here IIUC. I do see those "block has an unknown parent" in some cases though and subscribed to linked issue a while ago. |
||
| number > best_num + One::one() && | ||
nazar-pc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| self.blockchain.header(parent_hash)?.is_none() | ||
| { | ||
| let gap = (best_num + One::one(), number - One::one()); | ||
| transaction.set(columns::META, meta_keys::BLOCK_GAP, &gap.encode()); | ||
|
|
@@ -2060,6 +2066,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> { | |
| finalized_blocks: Vec::new(), | ||
| set_head: None, | ||
| commit_state: false, | ||
| create_gap: true, | ||
| index_ops: Default::default(), | ||
| }) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.