Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3,968 changes: 1,536 additions & 2,432 deletions Cargo.lock

Large diffs are not rendered by default.

285 changes: 143 additions & 142 deletions Cargo.toml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/consensus/nimbus-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ version = "0.9.0"
sc-client-api = { workspace = true }
sc-consensus = { workspace = true }
sc-consensus-manual-seal = { workspace = true }
sc-network-types = { workspace = true }
sp-consensus-slots = { workspace = true }
sp-api = { workspace = true }
sp-application-crypto = { workspace = true }
Expand Down
7 changes: 6 additions & 1 deletion client/consensus/nimbus-consensus/src/collators/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use nimbus_primitives::{DigestsProvider, NimbusApi, NimbusId};
use polkadot_node_primitives::CollationResult;
use polkadot_primitives::CollatorPair;
use sc_client_api::{AuxStore, BlockBackend, BlockOf, StateBackend};
use sc_network_types::PeerId;
use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_consensus_slots::{Slot, SlotDuration};
Expand Down Expand Up @@ -62,6 +63,8 @@ pub struct Params<Proposer, BI, ParaClient, RClient, CIDP, CS, ADP = ()> {
pub keystore: KeystorePtr,
/// The collator key used to sign collations before submitting to validators.
pub collator_key: CollatorPair,
/// The collator network peer id.
pub collator_peer_id: PeerId,
Comment thread
arturgontijo marked this conversation as resolved.
/// Force production of the block even if the collator is not eligible
pub force_authoring: bool,
/// Maximum percentage of POV size to use (0-85)
Expand Down Expand Up @@ -111,6 +114,7 @@ pub async fn run<Block, BI, CIDP, Backend, Client, RClient, Proposer, CS, ADP>(
collator_service,
create_inherent_data_providers,
keystore,
collator_peer_id,
para_id,
mut proposer,
para_client,
Expand Down Expand Up @@ -252,7 +256,8 @@ pub async fn run<Block, BI, CIDP, Backend, Client, RClient, Proposer, CS, ADP>(
&relay_client,
*request.relay_parent(),
nimbus_id.clone(),
Some(timestamp)
Some(timestamp),
Comment thread
arturgontijo marked this conversation as resolved.
collator_peer_id,
)
.await
);
Expand Down
7 changes: 5 additions & 2 deletions client/consensus/nimbus-consensus/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use cumulus_client_consensus_common::{
};
use cumulus_client_consensus_proposer::ProposerInterface;
use cumulus_primitives_core::{
relay_chain::{vstaging::CoreState, AsyncBackingParams, CoreIndex, Hash as PHash},
relay_chain::{AsyncBackingParams, CoreIndex, Hash as PHash},
CollectCollationInfo, ParaId,
};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
Expand All @@ -33,7 +33,7 @@ use polkadot_node_primitives::SubmitCollationParams;
use polkadot_node_subsystem::messages::{
CollationGenerationMessage, RuntimeApiMessage, RuntimeApiRequest,
};
use polkadot_primitives::{CollatorPair, OccupiedCoreAssumption};
use polkadot_primitives::{CollatorPair, CoreState, OccupiedCoreAssumption};
use sc_client_api::{BlockBackend, BlockOf};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
Expand All @@ -57,6 +57,8 @@ pub struct Params<BI, CIDP, Client, Backend, RClient, CHP, SO, Proposer, CS, DP
pub code_hash_provider: CHP,
/// The collator key used to sign collations before submitting to validators.
pub collator_key: CollatorPair,
/// The collator network peer id.
pub collator_peer_id: PeerId,
/// The generic collator service used to plug into this consensus engine.
pub collator_service: CS,
/// Inherent data providers. Only non-consensus inherent data should be provided, i.e.
Expand Down Expand Up @@ -344,6 +346,7 @@ where
relay_parent,
author_id.clone(),
Some(timestamp),
params.collator_peer_id,
)
.await
{
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/nimbus-consensus/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ where
.runtime_api()
.check_inherents(
*block_params.header.parent_hash(),
block.clone(),
block.clone().into(),
inherent_data,
)
.map_err(|e| format!("{:?}", e))?;
Expand Down
4 changes: 4 additions & 0 deletions client/consensus/nimbus-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use futures::prelude::*;
use log::{info, warn};
use nimbus_primitives::{NimbusApi, NimbusId, NIMBUS_KEY_ID};
use sc_consensus::BlockImport;
use sc_network_types::PeerId;
use sp_api::ProvideRuntimeApi;
use sp_application_crypto::ByteArray;
use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider};
Expand Down Expand Up @@ -109,6 +110,7 @@ pub(crate) async fn create_inherent_data<Block, CIDP, RClient>(
relay_parent: PHash,
author_id: NimbusId,
timestamp: impl Into<Option<sp_timestamp::Timestamp>>,
collator_peer_id: PeerId,
Comment thread
arturgontijo marked this conversation as resolved.
) -> Result<(ParachainInherentData, InherentData), Box<dyn Error + Send + Sync + 'static>>
where
Block: BlockT,
Expand All @@ -121,6 +123,8 @@ where
validation_data,
para_id,
vec![],
vec![],
Comment thread
arturgontijo marked this conversation as resolved.
Outdated
collator_peer_id,
)
.await;

Expand Down
12 changes: 8 additions & 4 deletions pallets/author-inherent/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use nimbus_primitives::{digests::CompatibleDigestItem, NimbusId, NIMBUS_ENGINE_I
use sp_application_crypto::ByteArray;
use sp_runtime::{
generic::DigestItem,
traits::{Block as BlockT, Header},
traits::{Block as BlockT, Header, LazyBlock},
RuntimeAppPublic,
};

Expand All @@ -46,8 +46,12 @@ where
Block: BlockT,
I: ExecuteBlock<Block>,
{
fn execute_block(block: Block) {
let (mut header, extrinsics) = block.deconstruct();
fn execute_block(block: <Block as BlockT>::LazyBlock) {
let mut header = block.header().clone();
let extrinsics = block
.extrinsics()
.map(|r| r.expect("Expected extrinsic to be valid"))
.collect();

debug!(target: "executive", "In hacked Executive. Initial digests are {:?}", header.digest());

Expand Down Expand Up @@ -97,6 +101,6 @@ where

// Now that we've verified the signature, hand execution off to the inner executor
// which is probably the normal frame executive.
I::execute_block(Block::new(header, extrinsics));
I::execute_block(Block::new(header, extrinsics).into());
Comment thread
arturgontijo marked this conversation as resolved.
Outdated
}
}
14 changes: 9 additions & 5 deletions template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use nimbus_consensus::NimbusManualSealConsensusDataProvider;
use cumulus_client_cli::CollatorOptions;
use cumulus_client_collator::service::CollatorService;
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
use cumulus_client_consensus_proposer::Proposer;
use cumulus_client_network::RequireSecondedInBlockAnnounce;
use cumulus_client_parachain_inherent::{MockValidationDataInherentDataProvider, MockXcmConfig};
#[allow(deprecated)]
Expand All @@ -42,7 +41,7 @@ use sc_executor::{
};
use sc_network::{
config::FullNetworkConfiguration, request_responses::IncomingRequest as GenericIncomingRequest,
service::traits::NetworkService, NetworkBlock,
service::traits::NetworkService, NetworkBlock, PeerId,
};
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
Expand Down Expand Up @@ -283,6 +282,8 @@ where
metrics,
})?;

let peer_id = network.local_peer_id();

let rpc_extensions_builder = {
let client = client.clone();
let transaction_pool = transaction_pool.clone();
Expand Down Expand Up @@ -312,6 +313,7 @@ where
system_rpc_tx,
tx_handler_controller,
telemetry: telemetry.as_mut(),
tracing_execute_block: None,
Comment thread
librelois marked this conversation as resolved.
Outdated
})?;

let announce_block = {
Expand Down Expand Up @@ -354,6 +356,7 @@ where
params.keystore_container.keystore(),
para_id,
collator_key.expect("Command line arguments do not allow this. qed"),
peer_id,
overseer_handle,
announce_block,
force_authoring,
Expand All @@ -375,21 +378,20 @@ fn start_consensus(
keystore: KeystorePtr,
para_id: ParaId,
collator_key: CollatorPair,
collator_peer_id: PeerId,
overseer_handle: OverseerHandle,
announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
force_authoring: bool,
max_pov_percentage: u8,
) -> Result<(), sc_service::Error> {
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
let proposer = sc_basic_authorship::ProposerFactory::with_proof_recording(
task_manager.spawn_handle(),
client.clone(),
transaction_pool,
prometheus_registry,
telemetry.clone(),
);

let proposer = Proposer::new(proposer_factory);

let collator_service = CollatorService::new(
client.clone(),
Arc::new(task_manager.spawn_handle()),
Expand All @@ -411,6 +413,7 @@ fn start_consensus(
max_pov_percentage,
additional_digests_provider: (),
collator_key,
collator_peer_id,
authoring_duration: Duration::from_millis(500),
relay_chain_slot_duration: Duration::from_millis(6_000),
slot_duration: Some(SlotDuration::from_millis(6_000)),
Expand Down Expand Up @@ -541,6 +544,7 @@ where
config,
tx_handler_controller,
telemetry: telemetry.as_mut(),
tracing_execute_block: None,
Comment thread
librelois marked this conversation as resolved.
Outdated
})?;

if is_authority {
Expand Down
5 changes: 2 additions & 3 deletions template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type CheckAssociatedRelayNumber =
cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
type ConsensusHook = ConsensusHook;
type SelectCore = cumulus_pallet_parachain_system::DefaultCoreSelector<Runtime>;
type RelayParentOffset = ConstU32<0>;
}

Expand Down Expand Up @@ -727,7 +726,7 @@ impl_runtime_apis! {
VERSION
}

fn execute_block(block: Block) {
fn execute_block(block: <Block as BlockT>::LazyBlock) {
Executive::execute_block(block)
}

Expand Down Expand Up @@ -764,7 +763,7 @@ impl_runtime_apis! {
}

fn check_inherents(
block: Block,
block: <Block as BlockT>::LazyBlock,
data: sp_inherents::InherentData,
) -> sp_inherents::CheckInherentsResult {
data.check_extrinsics(&block)
Expand Down
Loading