Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Load sync states from the chain spec on the light client #7329

Closed
wants to merge 33 commits into from

Conversation

expenses
Copy link
Contributor

A follow-up to #7225 and part of #6804.

Some questions about the PR that we should:

  1. Is there a better way of getting a sync state header to load correctly without all the hacky allow_missing_parent code?
  2. Is there a better way to debug problems in the code other than replacing errors with panics?
  3. How can we best prune the EpochChanges tree? See Add missing fields to the light sync state #7225 (comment).

expenses and others added 30 commits September 23, 2020 17:06
@expenses expenses added A0-please_review Pull request needs code review. A3-in_progress Pull request is in progress. No review needed at this stage. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Oct 15, 2020
@github-actions github-actions bot removed the A0-please_review Pull request needs code review. label Oct 15, 2020
@expenses
Copy link
Contributor Author

* https://github.com/paritytech/substrate/blob/a9b22d4e901c2633f92fefc6cbfbf1d3a9971ecc/bin/node/cli/res/flaming-fir.json managed to sync to the head of the chain.

* https://github.com/paritytech/substrate/blob/e1180c25423dfe45b8027e331bcf99676424f1a5/bin/node/cli/res/flaming-fir.json does not.

We should probably try and find out what the difference between the two is 🤔

@expenses
Copy link
Contributor Author

* https://github.com/paritytech/substrate/blob/a9b22d4e901c2633f92fefc6cbfbf1d3a9971ecc/bin/node/cli/res/flaming-fir.json managed to sync to the head of the chain.

* https://github.com/paritytech/substrate/blob/e1180c25423dfe45b8027e331bcf99676424f1a5/bin/node/cli/res/flaming-fir.json does not.

We should probably try and find out what the difference between the two is thinking

  • The first chain spec for commit a9b22d4e901c2633f92fefc6cbfbf1d3a9971ecc is for block 118347 which contains a new session and new grandpa authorities.
    The second for commit e1180c25423dfe45b8027e331bcf99676424f1a5 is for block 198161 which seems to be a more regular block.

Copy link
Contributor

@cheme cheme left a 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>(
Copy link
Contributor

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 = || {
/*
Copy link
Contributor

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 {
Copy link
Contributor

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.

@gnunicorn gnunicorn added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Nov 2, 2020
@gnunicorn
Copy link
Contributor

Closing due to the PR being stale for a while.

@gnunicorn gnunicorn closed this Nov 25, 2020
@expenses expenses deleted the ashley-load-sync-state branch August 23, 2021 11:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A3-in_progress Pull request is in progress. No review needed at this stage. A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants