Skip to content

Commit

Permalink
build and tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
fgamundi committed Jan 26, 2024
1 parent 8406e80 commit 066e1cc
Show file tree
Hide file tree
Showing 30 changed files with 1,829 additions and 2,013 deletions.
3,021 changes: 1,411 additions & 1,610 deletions Cargo.lock

Large diffs are not rendered by default.

268 changes: 136 additions & 132 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions client/consensus/nimbus-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ sp-core = { workspace = true }
sp-inherents = { workspace = true }
sp-keystore = { workspace = true }
sp-runtime = { workspace = true }
sp-version = { workspace = true }
substrate-prometheus-endpoint = { workspace = true }

# Cumulus dependencies
cumulus-client-collator = { workspace = true }
cumulus-client-consensus-common = { workspace = true }
cumulus-client-consensus-proposer = { workspace = true }
cumulus-client-parachain-inherent = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }
Expand Down
22 changes: 15 additions & 7 deletions client/consensus/nimbus-consensus/src/collators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ pub(crate) async fn collate<ADP, Block, BI, CS, Proposer>(
inherent_data: (ParachainInherentData, InherentData),
proposal_duration: Duration,
max_pov_size: usize,
) -> Result<(Collation, ParachainBlockData<Block>, Block::Hash), Box<dyn Error + Send + 'static>>
) -> Result<
Option<(Collation, ParachainBlockData<Block>, Block::Hash)>,
Box<dyn Error + Send + 'static>,
>
where
ADP: DigestsProvider<NimbusId, <Block as BlockT>::Hash> + 'static,
Block: BlockT,
Expand All @@ -79,11 +82,7 @@ where
additional_digests_provider.provide_digests(author_id.clone(), parent_header.hash()),
);

let Proposal {
block,
storage_changes,
proof,
} = proposer
let maybe_proposal = proposer
.propose(
&parent_header,
&inherent_data.0,
Expand All @@ -95,6 +94,15 @@ where
.await
.map_err(|e| Box::new(e) as Box<dyn Error + Send>)?;

let Proposal {
block,
storage_changes,
proof,
} = match maybe_proposal {
None => return Ok(None),
Some(p) => p,
};

let (header, extrinsics) = block.clone().deconstruct();

let sig_digest = seal_header::<Block>(
Expand Down Expand Up @@ -155,7 +163,7 @@ where
);
}

Ok((collation, block_data, post_hash))
Ok(Some((collation, block_data, post_hash)))
} else {
Err(
Box::<dyn Error + Send + Sync>::from("Unable to produce collation")
Expand Down
17 changes: 11 additions & 6 deletions client/consensus/nimbus-consensus/src/collators/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ where
.await
);

let (collation, _, post_hash) = try_request!(
let maybe_collation = try_request!(
super::collate::<ADP, Block, BI, CS, Proposer>(
&additional_digests_provider,
nimbus_id,
Expand All @@ -195,11 +195,16 @@ where
.await
);

let result_sender = Some(collator_service.announce_with_barrier(post_hash));
request.complete(Some(CollationResult {
collation,
result_sender,
}));
if let Some((collation, _, post_hash)) = maybe_collation {
let result_sender = Some(collator_service.announce_with_barrier(post_hash));
request.complete(Some(CollationResult {
collation,
result_sender,
}));
} else {
request.complete(None);
tracing::debug!(target: crate::LOG_TARGET, "No block proposal");
}
}
}
}
6 changes: 5 additions & 1 deletion client/consensus/nimbus-consensus/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ where
)
.await
{
Ok((collation, block_data, new_block_hash)) => {
Ok(Some((collation, block_data, new_block_hash))) => {
// Here we are assuming that the import logic protects against equivocations
// and provides sybil-resistance, as it should.
params.collator_service.announce_block(new_block_hash, None);
Expand Down Expand Up @@ -377,6 +377,10 @@ where
parent_hash = new_block_hash;
parent_header = block_data.into_header();
}
Ok(None) => {
tracing::debug!(target: crate::LOG_TARGET, "No block proposal");
break;
}
Err(err) => {
tracing::error!(target: crate::LOG_TARGET, ?err);
break;
Expand Down
17 changes: 11 additions & 6 deletions client/consensus/nimbus-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mod manual_seal;
pub use import_queue::import_queue;
pub use manual_seal::NimbusManualSealConsensusDataProvider;

use cumulus_client_parachain_inherent::ParachainInherentDataProvider;
use cumulus_primitives_core::{
relay_chain::{Hash as PHash, Header as PHeader},
ParaId, PersistedValidationData,
Expand Down Expand Up @@ -78,11 +79,11 @@ where
// Determine if runtime change
let runtime_upgraded = if *parent.number() > sp_runtime::traits::Zero::zero() {
use sp_api::Core as _;
let previous_runtime_version: sp_api::RuntimeVersion = para_client
let previous_runtime_version: sp_version::RuntimeVersion = para_client
.runtime_api()
.version(parent.hash())
.map_err(Box::new)?;
let runtime_version: sp_api::RuntimeVersion = para_client
let runtime_version: sp_version::RuntimeVersion = para_client
.runtime_api()
.version(parent.hash())
.map_err(Box::new)?;
Expand All @@ -96,7 +97,7 @@ where
first_available_key(&*keystore)
} else {
first_eligible_key::<Block, Client>(
para_client.clone(),
para_client,
&*keystore,
parent,
*relay_parent_header.number(),
Expand Down Expand Up @@ -127,9 +128,13 @@ where
CIDP: CreateInherentDataProviders<Block, (PHash, PersistedValidationData, NimbusId)> + 'static,
RClient: RelayChainInterface + Send + Clone + 'static,
{
let paras_inherent_data =
ParachainInherentData::create_at(relay_parent, relay_client, validation_data, para_id)
.await;
let paras_inherent_data = ParachainInherentDataProvider::create_at(
relay_parent,
relay_client,
validation_data,
para_id,
)
.await;

let paras_inherent_data = match paras_inherent_data {
Some(p) => p,
Expand Down
7 changes: 5 additions & 2 deletions client/consensus/nimbus-consensus/src/manual_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ use nimbus_primitives::{
};
use sc_consensus::BlockImportParams;
use sc_consensus_manual_seal::{ConsensusDataProvider, Error};
use sp_api::{BlockT, HeaderT, ProvideRuntimeApi};
use sp_api::ProvideRuntimeApi;
use sp_application_crypto::ByteArray;
use sp_core::sr25519;
use sp_inherents::InherentData;
use sp_keystore::KeystorePtr;
use sp_runtime::{Digest, DigestItem};
use sp_runtime::{
traits::{Block as BlockT, Header as HeaderT},
Digest, DigestItem,
};
use std::{marker::PhantomData, sync::Arc};

/// Provides nimbus-compatible pre-runtime digests for use with manual seal consensus
Expand Down
1 change: 1 addition & 0 deletions pallets/async-backing/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = ();
}

impl pallet_timestamp::Config for Test {
Expand Down
7 changes: 5 additions & 2 deletions pallets/author-inherent/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
//! with the nimubs consensus family.

use frame_support::traits::ExecuteBlock;
use sp_api::{BlockT, HeaderT};
// For some reason I can't get these logs to actually print
use log::debug;
use nimbus_primitives::{digests::CompatibleDigestItem, NimbusId, NIMBUS_ENGINE_ID};
use sp_application_crypto::ByteArray;
use sp_runtime::{generic::DigestItem, RuntimeAppPublic};
use sp_runtime::{
generic::DigestItem,
traits::{Block as BlockT, Header},
RuntimeAppPublic,
};

/// Block executive to be used by relay chain validators when validating parachain blocks built
/// with the nimubs consensus family.
Expand Down
1 change: 1 addition & 0 deletions pallets/author-inherent/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = ();
}

pub struct DummyBeacon {}
Expand Down
1 change: 1 addition & 0 deletions pallets/author-mapping/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ impl frame_system::Config for Runtime {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
}
parameter_types! {
pub const ExistentialDeposit: u128 = 1;
Expand Down
1 change: 1 addition & 0 deletions pallets/author-slot-filter/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = ();
}

impl pallet_testing::Config for Test {
Expand Down
1 change: 1 addition & 0 deletions pallets/foreign-asset-creator/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions pallets/maintenance-mode/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl frame_system::Config for Test {
type SS58Prefix = SS58Prefix;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
}

/// During maintenance mode we will not allow any calls.
Expand Down
1 change: 1 addition & 0 deletions pallets/migrations/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl frame_system::Config for Runtime {
type SS58Prefix = SS58Prefix;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions pallets/randomness/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl frame_system::Config for Test {
type SS58Prefix = SS58Prefix;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions pallets/relay-storage-roots/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl frame_system::Config for Test {
type SS58Prefix = SS58Prefix;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
}

parameter_types! {
Expand Down
4 changes: 2 additions & 2 deletions primitives/session-keys/src/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
//! VRF pre digest object and conversion to DigestItem
use crate::vrf::{VrfSignature, VRF_ENGINE_ID};
use parity_scale_codec::{Decode, Encode};
use sp_core::sr25519::vrf::{VrfOutput, VrfProof};
use sp_core::sr25519::vrf::{VrfPreOutput, VrfProof};
use sp_runtime::{generic::DigestItem, RuntimeDebug};

/// Raw VRF pre-digest.
#[derive(Clone, RuntimeDebug, Encode, Decode)]
pub struct PreDigest {
/// VRF output
pub vrf_output: VrfOutput,
pub vrf_output: VrfPreOutput,
/// VRF proof
pub vrf_proof: VrfProof,
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.70.0"
channel = "1.75.0"
components = [ "rustfmt", "clippy" ]
targets = [ "wasm32-unknown-unknown" ]
profile = "minimal"
3 changes: 2 additions & 1 deletion template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ flume = { workspace = true }
hex-literal = { workspace = true }
log = { workspace = true }
serde = { workspace = true, features = [ "derive" ] }
serde_json = { workspace = true }
jsonrpsee = { workspace = true, features = [ "macros", "server" ] }
futures = { workspace = true }

Expand Down Expand Up @@ -81,8 +82,8 @@ cumulus-client-consensus-common = { workspace = true }
cumulus-client-consensus-proposer = { workspace = true }
cumulus-client-network = { workspace = true }
cumulus-client-service = { workspace = true }
cumulus-client-parachain-inherent = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-relay-chain-inprocess-interface = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }
cumulus-relay-chain-rpc-interface = { workspace = true }
Expand Down
Loading

0 comments on commit 066e1cc

Please sign in to comment.