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

Introduce basic slot-based collator #4097

Merged
merged 85 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
9248cd1
Refactor block building and import in collator service
skunert Apr 3, 2024
70afa25
Remove unused SyncOracle, light reformat
skunert Apr 3, 2024
7e01dca
Add slot-based collator
skunert Apr 3, 2024
08ec3e7
Prepare cumulus test node & runtime
skunert Apr 3, 2024
3848239
Prepare cumulus test node & runtime
skunert Apr 3, 2024
7a057ed
Add zombienet test
skunert Apr 3, 2024
3f4a260
Misc
skunert Apr 3, 2024
c049f50
Nits
skunert Apr 3, 2024
c1c96bc
Remove unused dep, add issues to todos
skunert Apr 3, 2024
7af20a6
Remove unused dep, add issues to todos
skunert Apr 3, 2024
245a11a
Enable "elastic-scaling-experimental" for cumulus test node
skunert Apr 3, 2024
560a907
Adjust parent search to allow for pending blocks with depth > 1
skunert Apr 5, 2024
734bdcb
Merge fixes
skunert Apr 9, 2024
c439d21
Modernize zombienet test:
skunert Apr 11, 2024
fb9f383
Unify core schedule fetching methods
skunert Apr 11, 2024
06f8fc7
Remove overseer_handle from parameters
skunert Apr 11, 2024
cf64247
Improve logging
skunert Apr 11, 2024
aa7fba9
Merge branch 'master' into slot-based-mvp
skunert Apr 12, 2024
44b489f
Do not return potential_parents that are not available locally
skunert Apr 12, 2024
8df558f
Use commong async backing params fetching methods
skunert Apr 16, 2024
7705314
Assign cores during block building
skunert Apr 16, 2024
1553d40
Merge branch 'master' into slot-based-mvp
skunert Apr 16, 2024
f84a6f3
Add more comments, cleanup
skunert Apr 16, 2024
e1a5879
Refactor `find_potential_parent`
skunert Apr 16, 2024
576605b
Merge branch 'master' into slot-based-mvp
skunert Apr 17, 2024
1b184da
Make expected cores work when para slot duration > relay slot duration
skunert Apr 17, 2024
e95e5df
Review comments
skunert Apr 23, 2024
e4edbe4
Extract parent search into module
skunert Apr 23, 2024
53869a0
More code reuse between lookahead and slot-based
skunert Apr 23, 2024
4240cc1
Merge branch 'master' into slot-based-mvp
skunert Apr 23, 2024
c790fb8
fmt
skunert Apr 23, 2024
61be48b
Merge branch 'master' into slot-based-mvp
skunert Apr 25, 2024
a06bf79
Merge branch 'master' into slot-based-mvp
skunert Apr 29, 2024
169479a
Add slot drift for testing
skunert Apr 30, 2024
ac3e9ed
Merge branch 'master' into slot-based-mvp
skunert Apr 30, 2024
6a9955d
Remove duplicate comment
skunert May 6, 2024
9760e81
Expose slot_drift parameter
skunert May 7, 2024
42c0135
Do not assumed fixed slot_duration
skunert May 7, 2024
44bc8e7
Apply suggestions from code review
skunert May 29, 2024
a23d5a9
Address comments
skunert May 29, 2024
07478dc
Remove unused parameters from zombienet
skunert May 29, 2024
15c36a9
Introduce experimental CLI option
skunert May 29, 2024
2c8cc0d
Merge branch 'master' into slot-based-mvp
skunert May 29, 2024
65cdc01
fmt
skunert May 29, 2024
5dcea6c
Adjust zombienet parameter
skunert May 29, 2024
46bd385
Merge branch 'master' into slot-based-mvp
skunert May 31, 2024
27eb643
Remove +1 on velocity
skunert May 31, 2024
99e5741
Reduce number of relay chain fetches
skunert May 31, 2024
944044d
Add comments to `RelayChainCachingFetcher`
skunert Jun 4, 2024
41dba02
More comment adjustments
skunert Jun 4, 2024
33243a2
Merge branch 'master' into slot-based-mvp
skunert Jun 4, 2024
0b061f6
Fix template build
skunert Jun 4, 2024
8be5db4
Apply suggestions from code review
skunert Jun 13, 2024
8e4320d
Merge branch 'master' into slot-based-mvp
skunert Jun 13, 2024
6c97bd1
Merge option in relay chain fetcher
skunert Jun 13, 2024
0ae68d3
Spawn futures inside collator
skunert Jun 13, 2024
767430e
Do not build if pending parent is not in db
skunert Jun 13, 2024
1021ee3
Remove slot based experimental from common cli options
skunert Jun 17, 2024
c109088
Fix lookahead collator filling the pipeline
skunert Jun 18, 2024
8c364e8
Add PoV-recovery test, make sure no inherent errors are thrown
skunert Jun 18, 2024
8e30d38
Move collator to futures again
skunert Jun 19, 2024
f3233db
Move lost comment
skunert Jun 19, 2024
da96123
Improve pov-recovery test
skunert Jun 19, 2024
05c3812
Increase velocity to 4
skunert Jun 19, 2024
938a736
Add test to pipeline
skunert Jun 19, 2024
fa3f070
Add prdoc
skunert Jun 19, 2024
edfe474
Abort block builder task if we can not send to collation task
skunert Jun 19, 2024
b1490eb
Fixes
skunert Jun 19, 2024
17fd978
Merge branch 'master' into slot-based-mvp
skunert Jun 19, 2024
9d14989
Comment adjustments
skunert Jun 19, 2024
96d885a
Fix pov-recovery test
skunert Jun 20, 2024
eb61449
Fix prdoc semver
skunert Jun 20, 2024
cb16053
Add slot based collator for default runtimes or chainspecs
skunert Jun 20, 2024
48267c2
PRDoc one more time
skunert Jun 20, 2024
d595c7b
Fix collator image
skunert Jun 21, 2024
b1edd47
Merge branch 'master' into slot-based-mvp
skunert Jun 25, 2024
764fcd5
Merge branch 'master' into slot-based-mvp
skunert Jul 4, 2024
62d5b9d
post-merge adjustments
skunert Jul 4, 2024
7bc28ff
Review comments
skunert Jul 1, 2024
d986ee7
Apply suggestions from code review
skunert Jul 4, 2024
dd36c44
Remove unnecessary pending condition in parent search
skunert Jul 4, 2024
91c6539
Adjust comments and tracing log
skunert Jul 4, 2024
8e0b80d
".git/.scripts/commands/fmt/fmt.sh"
Jul 4, 2024
09222f7
make semver happy
skunert Jul 5, 2024
938d6e6
Reviewer comment: Remove duplicate check for pending
skunert Jul 5, 2024
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
24 changes: 24 additions & 0 deletions .gitlab/pipeline/zombienet/cumulus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,27 @@ zombienet-cumulus-0007-full_node_warp_sync:
--local-dir="${LOCAL_DIR}"
--concurrency=1
--test="0007-full_node_warp_sync.zndsl"

zombienet-cumulus-0008-elastic_authoring:
extends:
- .zombienet-cumulus-common
- .zombienet-refs
- .zombienet-before-script
- .zombienet-after-script
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--local-dir="${LOCAL_DIR}"
--concurrency=1
--test="0008-elastic_authoring.zndsl"

zombienet-cumulus-0009-elastic_pov_recovery:
extends:
- .zombienet-cumulus-common
- .zombienet-refs
- .zombienet-before-script
- .zombienet-after-script
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--local-dir="${LOCAL_DIR}"
--concurrency=1
--test="0009-elastic_pov_recovery.zndsl"
12 changes: 2 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cumulus/client/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ codec = { features = ["derive"], workspace = true, default-features = true }
futures = { workspace = true }
tracing = { workspace = true, default-features = true }
schnellru = { workspace = true }
tokio = { workspace = true, features = ["macros"] }

# Substrate
sc-client-api = { workspace = true, default-features = true }
sc-consensus = { workspace = true, default-features = true }
sc-consensus-aura = { workspace = true, default-features = true }
sc-consensus-babe = { workspace = true, default-features = true }
sc-consensus-slots = { workspace = true, default-features = true }
sc-utils = { workspace = true, default-features = true }
sc-telemetry = { workspace = true, default-features = true }
sp-api = { workspace = true, default-features = true }
sp-application-crypto = { workspace = true, default-features = true }
Expand Down
64 changes: 44 additions & 20 deletions cumulus/client/consensus/aura/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,26 +156,16 @@ where
Ok((paras_inherent_data, other_inherent_data))
}

/// Propose, seal, and import a block, packaging it into a collation.
///
/// Provide the slot to build at as well as any other necessary pre-digest logs,
/// the inherent data, and the proposal duration and PoV size limits.
///
/// The Aura pre-digest should not be explicitly provided and is set internally.
///
/// This does not announce the collation to the parachain network or the relay chain.
pub async fn collate(
/// Build and import a parachain block on the given parent header, using the given slot claim.
pub async fn build_block_and_import(
&mut self,
parent_header: &Block::Header,
slot_claim: &SlotClaim<P::Public>,
additional_pre_digest: impl Into<Option<Vec<DigestItem>>>,
inherent_data: (ParachainInherentData, InherentData),
proposal_duration: Duration,
max_pov_size: usize,
) -> Result<
Option<(Collation, ParachainBlockData<Block>, Block::Hash)>,
Box<dyn Error + Send + 'static>,
> {
) -> Result<Option<ParachainCandidate<Block>>, Box<dyn Error + Send + 'static>> {
let mut digest = additional_pre_digest.into().unwrap_or_default();
digest.push(slot_claim.pre_digest.clone());

Expand Down Expand Up @@ -205,7 +195,6 @@ where
)
.map_err(|e| e as Box<dyn Error + Send>)?;

let post_hash = sealed_importable.post_hash();
let block = Block::new(
sealed_importable.post_header(),
sealed_importable
Expand All @@ -220,11 +209,46 @@ where
.map_err(|e| Box::new(e) as Box<dyn Error + Send>)
.await?;

if let Some((collation, block_data)) = self.collator_service.build_collation(
parent_header,
post_hash,
ParachainCandidate { block, proof: proposal.proof },
) {
Ok(Some(ParachainCandidate { block, proof: proposal.proof }))
}

/// Propose, seal, import a block and packaging it into a collation.
///
/// Provide the slot to build at as well as any other necessary pre-digest logs,
/// the inherent data, and the proposal duration and PoV size limits.
///
/// The Aura pre-digest should not be explicitly provided and is set internally.
///
/// This does not announce the collation to the parachain network or the relay chain.
pub async fn collate(
&mut self,
parent_header: &Block::Header,
slot_claim: &SlotClaim<P::Public>,
additional_pre_digest: impl Into<Option<Vec<DigestItem>>>,
inherent_data: (ParachainInherentData, InherentData),
proposal_duration: Duration,
max_pov_size: usize,
) -> Result<
Option<(Collation, ParachainBlockData<Block>, Block::Hash)>,
skunert marked this conversation as resolved.
Show resolved Hide resolved
Box<dyn Error + Send + 'static>,
> {
let maybe_candidate = self
.build_block_and_import(
parent_header,
slot_claim,
additional_pre_digest,
inherent_data,
proposal_duration,
max_pov_size,
)
.await?;

let Some(candidate) = maybe_candidate else { return Ok(None) };

let hash = candidate.block.header().hash();
if let Some((collation, block_data)) =
self.collator_service.build_collation(parent_header, hash, candidate)
{
tracing::info!(
target: crate::LOG_TARGET,
"PoV size {{ header: {}kb, extrinsics: {}kb, storage_proof: {}kb }}",
Expand All @@ -241,7 +265,7 @@ where
);
}

Ok(Some((collation, block_data, post_hash)))
Ok(Some((collation, block_data, hash)))
} else {
Err(Box::<dyn Error + Send + Sync>::from("Unable to produce collation")
as Box<dyn Error + Send>)
Expand Down
10 changes: 3 additions & 7 deletions cumulus/client/consensus/aura/src/collators/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use sc_consensus::BlockImport;
use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_application_crypto::AppPublic;
use sp_blockchain::HeaderBackend;
use sp_consensus::SyncOracle;
use sp_consensus_aura::AuraApi;
use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders;
Expand All @@ -53,7 +52,7 @@ use std::{sync::Arc, time::Duration};
use crate::collator as collator_util;

/// Parameters for [`run`].
pub struct Params<BI, CIDP, Client, RClient, SO, Proposer, CS> {
pub struct Params<BI, CIDP, Client, RClient, Proposer, CS> {
/// Inherent data providers. Only non-consensus inherent data should be provided, i.e.
/// the timestamp, slot, and paras inherents should be omitted, as they are set by this
/// collator.
Expand All @@ -64,8 +63,6 @@ pub struct Params<BI, CIDP, Client, RClient, SO, Proposer, CS> {
pub para_client: Arc<Client>,
/// A handle to the relay-chain client.
pub relay_client: RClient,
/// A chain synchronization oracle.
pub sync_oracle: SO,
/// The underlying keystore, which should contain Aura consensus keys.
pub keystore: KeystorePtr,
/// The collator key used to sign collations before submitting to validators.
Expand All @@ -89,8 +86,8 @@ pub struct Params<BI, CIDP, Client, RClient, SO, Proposer, CS> {
}

/// Run bare Aura consensus as a relay-chain-driven collator.
pub fn run<Block, P, BI, CIDP, Client, RClient, SO, Proposer, CS>(
params: Params<BI, CIDP, Client, RClient, SO, Proposer, CS>,
pub fn run<Block, P, BI, CIDP, Client, RClient, Proposer, CS>(
params: Params<BI, CIDP, Client, RClient, Proposer, CS>,
) -> impl Future<Output = ()> + Send + 'static
where
Block: BlockT + Send,
Expand All @@ -108,7 +105,6 @@ where
CIDP: CreateInherentDataProviders<Block, ()> + Send + 'static,
CIDP::InherentDataProviders: Send,
BI: BlockImport<Block> + ParachainBlockImportMarker + Send + Sync + 'static,
SO: SyncOracle + Send + Sync + Clone + 'static,
Proposer: ProposerInterface<Block> + Send + Sync + 'static,
CS: CollatorServiceInterface<Block> + Send + Sync + 'static,
P: Pair,
Expand Down
Loading
Loading