Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
1,006 changes: 643 additions & 363 deletions Cargo.lock

Large diffs are not rendered by default.

95 changes: 52 additions & 43 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ use cumulus_network::{
DelayedBlockAnnounceValidator, JustifiedBlockAnnounceValidator, WaitToAnnounce,
};
use cumulus_primitives::{
inherents::{VALIDATION_FUNCTION_PARAMS_IDENTIFIER as VFP_IDENT, DOWNWARD_MESSAGES_IDENTIFIER, DownwardMessagesType},
validation_function_params::ValidationFunctionParams, HeadData,
inherents::{
DownwardMessagesType, DOWNWARD_MESSAGES_IDENTIFIER,
VALIDATION_FUNCTION_PARAMS_IDENTIFIER as VFP_IDENT,
},
validation_function_params::ValidationFunctionParams,
HeadData,
};
use cumulus_runtime::ParachainBlockData;

Expand All @@ -37,8 +41,7 @@ use sp_inherents::{InherentData, InherentDataProviders};
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};

use polkadot_collator::{
BuildParachainContext, InvalidHead, Network as CollatorNetwork, ParachainContext,
RuntimeApiCollection,
BuildParachainContext, Network as CollatorNetwork, ParachainContext, RuntimeApiCollection,
};
use polkadot_primitives::{
parachain::{self, BlockData, GlobalValidationSchedule, Id as ParaId, LocalValidationData},
Expand Down Expand Up @@ -99,15 +102,17 @@ impl<Block: BlockT, PF, BI> Collator<Block, PF, BI> {
global_validation: GlobalValidationSchedule,
local_validation: LocalValidationData,
downward_messages: DownwardMessagesType,
) -> Result<InherentData, InvalidHead> {
let mut inherent_data = inherent_providers.create_inherent_data().map_err(|e| {
error!(
target: "cumulus-collator",
"Failed to create inherent data: {:?}",
e,
);
InvalidHead
})?;
) -> Option<InherentData> {
let mut inherent_data = inherent_providers
.create_inherent_data()
.map_err(|e| {
error!(
target: "cumulus-collator",
"Failed to create inherent data: {:?}",
e,
);
})
.ok()?;

inherent_data
.put_data(
Expand All @@ -120,24 +125,21 @@ impl<Block: BlockT, PF, BI> Collator<Block, PF, BI> {
"Failed to put validation function params into inherent data: {:?}",
e,
);
InvalidHead
})?;
})
.ok()?;

inherent_data
.put_data(
DOWNWARD_MESSAGES_IDENTIFIER,
&downward_messages,
)
.put_data(DOWNWARD_MESSAGES_IDENTIFIER, &downward_messages)
.map_err(|e| {
error!(
target: "cumulus-collator",
"Failed to put downward messages into inherent data: {:?}",
e,
);
InvalidHead
})?;
})
.ok()?;

Ok(inherent_data)
Some(inherent_data)
}
}

Expand Down Expand Up @@ -168,7 +170,7 @@ where
+ 'static,
{
type ProduceCandidate =
Pin<Box<dyn Future<Output = Result<(BlockData, parachain::HeadData), InvalidHead>> + Send>>;
Pin<Box<dyn Future<Output = Option<(BlockData, parachain::HeadData)>> + Send>>;

fn produce_candidate(
&mut self,
Expand All @@ -187,7 +189,7 @@ where
Ok(x) => x,
Err(e) => {
error!(target: "cumulus-collator", "Could not decode the head data: {:?}", e);
return Box::pin(future::ready(Err(InvalidHead)));
return Box::pin(future::ready(None));
}
};

Expand All @@ -196,14 +198,16 @@ where
let wait_to_announce = self.wait_to_announce.clone();

Box::pin(async move {
let proposer = proposer_future.await.map_err(|e| {
error!(
target: "cumulus-collator",
"Could not create proposer: {:?}",
e,
);
InvalidHead
})?;
let proposer = proposer_future
.await
.map_err(|e| {
error!(
target: "cumulus-collator",
"Could not create proposer: {:?}",
e,
);
})
.ok()?;

let inherent_data = Self::inherent_data(
inherent_providers,
Expand Down Expand Up @@ -231,16 +235,20 @@ where
"Proposing failed: {:?}",
e,
);
InvalidHead
})?;
})
.ok()?;

let proof = proof.ok_or_else(|| {
error!(
target: "cumulus-collator",
"Proposer did not return the requested proof.",
);
InvalidHead
})?;
let proof = match proof {
Some(proof) => proof,
None => {
error!(
target: "cumulus-collator",
"Proposer did not return the requested proof.",
);

return None;
}
};

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

Expand All @@ -266,7 +274,8 @@ where
b.header().parent_hash(),
err,
);
return Err(InvalidHead);

return None;
}

let block_data = BlockData(b.encode());
Expand All @@ -283,7 +292,7 @@ where

trace!(target: "cumulus-collator", "Produced candidate: {:?}", candidate);

Ok(candidate)
Some(candidate)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn import_queue<Client, Block: BlockT, I>(
client: Arc<Client>,
block_import: I,
inherent_data_providers: InherentDataProviders,
spawner: &impl sp_core::traits::SpawnBlocking,
spawner: &impl sp_core::traits::SpawnNamed,
registry: Option<&substrate_prometheus_endpoint::Registry>,
) -> ClientResult<BasicQueue<Block, I::Transaction>>
where
Expand Down
4 changes: 2 additions & 2 deletions network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ where

Validation::Failure
} else {
Validation::Success
Validation::Success { is_new_best: false }
});
}

Expand Down Expand Up @@ -202,7 +202,7 @@ where
)) as Box<_>);
}

Ok(Validation::Success)
Ok(Validation::Success { is_new_best: false })
}
}

Expand Down
2 changes: 1 addition & 1 deletion network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn valid_if_no_data_and_less_than_best_known_number() {

assert_eq!(
res.unwrap(),
Validation::Success,
Validation::Success { is_new_best: false },
"validating without data with block number < best known number is always a success",
);
}
Expand Down
9 changes: 6 additions & 3 deletions parachain-upgrade/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,16 @@ mod tests {

use codec::Encode;
use frame_support::{
assert_ok, impl_outer_event, impl_outer_origin, parameter_types,
assert_ok,
dispatch::UnfilteredDispatchable,
impl_outer_event, impl_outer_origin, parameter_types,
traits::{OnFinalize, OnInitialize},
weights::Weight,
};
use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, Dispatchable, IdentityLookup},
traits::{BlakeTwo256, IdentityLookup},
Perbill,
};
use sp_version::RuntimeVersion;
Expand Down Expand Up @@ -305,6 +307,7 @@ mod tests {
type DbWeight = ();
type BlockExecutionWeight = ();
type ExtrinsicBaseWeight = ();
type BaseCallFilter = ();
}
impl Trait for Test {
type Event = TestEvent;
Expand Down Expand Up @@ -472,7 +475,7 @@ mod tests {
ParachainUpgrade::on_initialize(*n);
ParachainUpgrade::create_inherent(&inherent_data)
.expect("got an inherent")
.dispatch(RawOrigin::None.into())
.dispatch_bypass_filter(RawOrigin::None.into())
.expect("dispatch succeeded");
within_block();
ParachainUpgrade::on_finalize(*n);
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = [ "derive" ] }
memory-db = { version = "0.18.0", default-features = false }
hash-db = { version = "0.15.2", default-features = false }
trie-db = { version = "0.20.1", default-features = false }
trie-db = { version = "0.21.0", default-features = false }
hashbrown = "0.6.1"

# Cumulus dependencies
Expand Down
1 change: 1 addition & 0 deletions test/parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulu
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "0.8.0-alpha.5" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-informant = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }

# Cumulus dependencies
cumulus-consensus = { path = "../../consensus" }
Expand Down
1 change: 1 addition & 0 deletions test/parachain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ impl frame_system::Trait for Runtime {
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
type BlockExecutionWeight = ();
type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
type BaseCallFilter = ();
}

parameter_types! {
Expand Down
Loading