-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Load sync states from the chain spec on the light client #7329
Conversation
…-state-WIP-loading
…-state-WIP-loading
…-state-WIP-loading
…rove-sync-state-WIP-loading
This reverts commit a8f0966.
We should probably try and find out what the difference between the two is 🤔 |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know if 'allow_missing_parent' can be avoided, if it can't, it could also think of naming it 'snapshot_syncing' or something that refer to the actual action it is used for.
Still 'allow_missing_parent' is similar to existing 'allow_missing_state' (probably for light client), so maybe that is not a good idea at all place.
Generally loading from a snapshot do not use the same trust assumption, so I do not find this that surprising it is needed (maybe some specific api or trait could make it looks less hacky, I think making code generic may help here but that should be next steps).
@@ -110,7 +110,7 @@ pub(crate) fn write_epoch_changes<Block: BlockT, F, R>( | |||
} | |||
|
|||
/// Write the cumulative chain-weight of a block ot aux storage. | |||
pub(crate) fn write_block_weight<H: Encode, F, R>( | |||
pub fn write_block_weight<H: Encode, F, R>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not have a specific 'load_snapshot_state' method that is also public but makes it clear that in should not be use lighty?
Could be part of a trait.
@@ -1275,10 +1275,12 @@ impl<Block, Client, Inner> BlockImport<Block> for BabeBlockImport<Block, Client, | |||
// used by pruning may not know about the block that is being | |||
// imported. | |||
let prune_and_import = || { | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if light pruning method from https://github.com/paritytech/substrate/pull/6851/files would work here, really just a wild guess.
let hash = header.hash(); | ||
let number = header.number(); | ||
|
||
// Note: this may lock storage, so it must happen before obtaining storage | ||
// write lock. | ||
let best_tree_route = { | ||
let best_hash = self.storage.read().best_hash; | ||
if &best_hash == header.parent_hash() { | ||
if &best_hash == header.parent_hash() || allow_missing_parent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if modifying tree_route to not fail on missing parent may be better, or if it could break some assumption and make existing code unsecure.
Closing due to the PR being stale for a while. |
A follow-up to #7225 and part of #6804.
Some questions about the PR that we should:
allow_missing_parent
code?EpochChanges
tree? See Add missing fields to the light sync state #7225 (comment).