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

Aura: Fix warp syncing #13221

Merged
merged 2 commits into from
Jan 26, 2023
Merged
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
13 changes: 6 additions & 7 deletions client/consensus/aura/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,15 @@ where
&mut self,
mut block: BlockImportParams<B, ()>,
) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
// When importing whole state we don't verify the seal as the state is not available.
if block.with_state() {
return Ok((block, Default::default()))
}

// Skip checks that include execution, if being told so.
// Skip checks that include execution, if being told so or when importing only state.
//
// This is done for example when gap syncing and it is expected that the block after the gap
// was checked/chosen properly, e.g. by warp syncing to this block using a finality proof.
if block.state_action.skip_execution_checks() {
// Or when we are importing state only and can not verify the seal.
if block.with_state() || block.state_action.skip_execution_checks() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that:
A) state_action.skip_execution_checks() returns true iff state_action == StateAction::Skip
... AND that ...
B) block.state_action is set to Skip by the import queue here if imported block has no state and block.skip_execution == true
... AND that 😃 ...
C) block.skip_execution is true under one of the following conditions:
1. peer sync state is DownloadingGap here
2. is a block announcement here
3. in all the other cases if skip_execution() returns true here

All this boombastic introduction to ask: do you thing that we can replace this check in babe with the same check? (i.e. replace the s <= num <= e part with state_action.skip_execution_checks())
Intuitively it can, but I'm not super familiar with the sync crate and not 100% sure that the two conditions are (in practice for this use case) equivalent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are correct.

// When we are importing only the state of a block, it will be the best block.
block.fork_choice = Some(ForkChoiceStrategy::Custom(block.with_state()));
Copy link
Member

@davxy davxy Jan 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another observation.
Probably this requirement to modify the fork_choice is common to other protocols as well (for sure Babe).

Babe currently perform this a bit later here. In the import_state.

And as per @skunert comment on cumulus here

Can't we refactor all this assignment to where the block params is constucted in the import queue? (i.e. close to this) Maybe we can then catch them all in one single place
Or there is something I'm overlooking?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the cumulus one needs to stay anyway, as it is unrelated to all the state-business.

Copy link
Member

@davxy davxy Jan 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I was just trying to find out if there is a way to have these less scattered around.
That is, probably babe and aura are similar WRT this aspect. But aura is setting it in the verifier while babe in import_block ~> import_state


return Ok((block, Default::default()))
}

Expand Down