Skip to content

[Sidechain] Integration of the peer sync mechanism#627

Merged
murerfel merged 32 commits intomasterfrom
feature/fm-peer-block-sync-integration
Feb 9, 2022
Merged

[Sidechain] Integration of the peer sync mechanism#627
murerfel merged 32 commits intomasterfrom
feature/fm-peer-block-sync-integration

Conversation

@murerfel
Copy link
Contributor

@murerfel murerfel commented Jan 24, 2022

Description

Part of #567 - integrating all parts in order to have a working setup where blocks are peer fetched on a worker that joins later, and then continues to synchronize using block gossiping.

Important workflow changes

  • When importing a sidechain block, we peek the parentchain block from the queue, then verify the sidechain block and only then import the parentchain block.
    • Split verification and state update when importing a sidechain block
  • Sidechain blocks are now imported as a first step in the sidechain block production loop. Instead of importing them when they are gossiped.
    • Gossiping sidechain blocks happens asynchronously and only fills an import queue
    • Importing sidechain blocks potentially also imports parentchain blocks. The latest imported parentchain header is communicated back to aura
    • When the import fails because of a header ancestry, or invalid first block error, we attempt to fetch and import the sidechain block
  • Sidechain block verifier specifically checks if a block was already imported

Closes #567

Workflow documentation (activity diagrams)

This is an updated version of the activity diagrams in #567 and document the current workflow activity for:

  • Sidechain production loop. Contains the block import loop action as well, but in a compact form. All the details are found in the dedicated diagram for the import (below).
  • Sidechain block import loop

Sidechain block production

Sidechain block production loop

Sidechain block import

Process sidechain import queue

Copy link
Contributor Author

@murerfel murerfel left a comment

Choose a reason for hiding this comment

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

This is a far larger PR than originally intended. The integration of the whole sidechain synchronization required quite a few more changes than anticipated. So I added a couple of comments to hopefully help our reviewers 😄

Copy link
Contributor Author

@murerfel murerfel left a comment

Choose a reason for hiding this comment

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

More explanations on the changes I've made.

@murerfel murerfel marked this pull request as ready for review January 26, 2022 06:33
@murerfel murerfel requested review from clangenb and haerdib January 26, 2022 06:33
@murerfel
Copy link
Contributor Author

Currently working on the activity diagrams for the block production loop and sidechain block import loop. Will add them to the description here.

Copy link
Contributor

@haerdib haerdib left a comment

Choose a reason for hiding this comment

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

Some remarks, but veery good job on making this work!

PS: Could you add this PR link to the README? https://github.com/integritee-network/worker/blob/master/docs/README.md

@murerfel murerfel force-pushed the feature/fm-peer-block-sync-integration branch from 026eb65 to 4ede153 Compare February 7, 2022 07:05
Copy link
Contributor

@clangenb clangenb left a comment

Choose a reason for hiding this comment

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

Looks very good to me!

}

/// Trait to peek the queue, without mutating it.
pub trait PeekParentchainBlockImportQueue<SignedBlockType> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I second that question

@murerfel murerfel mentioned this pull request Feb 8, 2022
1 task
Copy link
Contributor

@haerdib haerdib left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the effort !

}

/// Trait to peek the queue, without mutating it.
pub trait PeekParentchainBlockImportQueue<SignedBlockType> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, then that's fine. Thanks for the explanation :)

- Sidechain functionality: https://polkadot.polkassembly.io/post/111
- Sidechain flow: https://github.com/integritee-network/worker/issues/567
- Peer sync and block production suspension for sidechain: https://github.com/integritee-network/worker/pull/618
- Sidechain flow: https://github.com/integritee-network/worker/pull/627
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks 👍

@murerfel murerfel force-pushed the feature/fm-peer-block-sync-integration branch from 3d2be2a to 0e674cb Compare February 9, 2022 06:26
@murerfel murerfel merged commit 1af78af into master Feb 9, 2022
@murerfel murerfel deleted the feature/fm-peer-block-sync-integration branch February 9, 2022 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sync state by retrieving sidechain blocks from storage of a different, given worker

3 participants