Skip to content
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

Add fast-sync. #2657

Closed
wants to merge 9 commits into from
Closed

Add fast-sync. #2657

wants to merge 9 commits into from

Conversation

shamil-gadelshin
Copy link
Member

@shamil-gadelshin shamil-gadelshin commented Apr 1, 2024

This PR introduces fast-sync to subspace-node complementing the existing sync mechanisms: DSN-sync and Substrate sync.

Fast-sync algorithm aims to improve the speed of the synchronization to the latest block by skipping the majority of the blocks and downloading only the minimum of required blocks and state.

Algorithm highlight:

  • download the two last segments from DSN
  • import the last block from the second last segment without execution bypassing regular checks and initialize the node's archiver
  • download state for the first block of the last segment
  • import and execute all the remaining blocks from the last segment
  • pass the control to the next sync algorithm (DSN-sync or Substrate sync)

The initial state of the PR is draft because several block importing checks are disabled.

Currently disabled checks:

  • PoT verification in runtime
  • InherentData check

Remaining work:

  • restore disabled checks (UPD: all checks restored)
  • test all combinations of the state and sync-algorithms involved
  • advanced peer management can be added (similar to the original sync-engine)
  • handle XDM and Domains data dependency (requires research)
  • debug flaky "Unable to pin block for import notification. Error: UnknownBlock" error

Here is the draft PR for polkadot-sdk: autonomys/polkadot-sdk#13

Code contributor checklist:

@shamil-gadelshin shamil-gadelshin added networking Subspace networking (DSN) node Node (service library/node app) labels Apr 1, 2024
@shamil-gadelshin shamil-gadelshin self-assigned this Apr 1, 2024
@@ -795,7 +801,8 @@ where
}
};

let import_queue_service = import_queue.service();
let import_queue_service1 = import_queue.service();
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: Remove the copy by using Arc

@@ -700,6 +700,12 @@ where
mut telemetry,
} = other;

// Clear block gap on reruns
if client.info().finalized_state.is_some() {
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: Add fast-sync flag condition.

@@ -917,7 +945,7 @@ async fn send_archived_segment_notification(
archived_segment_notification_sender.notify(move || archived_segment_notification);

while acknowledgement_receiver.next().await.is_some() {
debug!(
info!(
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: return to debug

@@ -800,7 +828,7 @@ where
let parent_block_hash = *block.block.header().parent_hash();
let block_hash_to_archive = block.block.hash();

debug!(
info!(
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: return to debug

@@ -783,6 +810,7 @@ where
};

if best_archived_block_number >= block_number_to_archive {
info!(%block_number, "Skipped archiving imported block: already archived.");
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: set to debug

skip_proofs: true,
storage_chain_mode: false,
},
// sync_mode: SyncMode::Full, // TODO: add configurable default sync-state
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove the comment

@dariolina
Copy link
Member

@nazar-pc the goal of this PR was primarily to provide visibility to you into the development progress, please take a look when you're back.

@nazar-pc
Copy link
Member

nazar-pc commented Apr 8, 2024

There were too many things missing and too many various small things to even comment on last time I checked, wasn't sure what to do with it.

I'd rather see a series of logical PRs that prepare various parts of the codebase to fast sync with explanation of the situation and why the changes are needed. Kind of like I did with PoT and many consensus upgrades prior and how I started doing with farming cluster too. I am very bad at looking at large dumps of WIP code that is not ready for review.

@shamil-gadelshin
Copy link
Member Author

shamil-gadelshin commented Apr 14, 2024

Superseded by #2678

@nazar-pc nazar-pc deleted the fast-sync-v2-5 branch September 26, 2024 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
networking Subspace networking (DSN) node Node (service library/node app)
Projects
Development

Successfully merging this pull request may close these issues.

3 participants