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 43 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
dc0613b
Initial commit
cecton Aug 7, 2020
01b809e
WIP
cecton Aug 12, 2020
4206762
WIP
cecton Aug 12, 2020
b08c820
WIP
cecton Aug 12, 2020
f2a852b
CLEANUP
cecton Aug 13, 2020
d90db5c
CLEANUP
cecton Aug 13, 2020
0649a09
Merge commit 1fcd05503a3439edc86127832d4d37a41d87a91d (no conflict)
cecton Aug 13, 2020
172c4ed
Merge commit 9603b2fe5f2ea2955a4a8a34742c58e8a4f9bc54 (conflicts)
cecton Aug 13, 2020
4c2a768
Merge commit 96da14c14fb785e106bb89a18c9dedaf2f789d2c (no conflict)
cecton Aug 13, 2020
f1b4b74
Merge commit 2c63ccb9eb7d065038e53231c379a82a509acf37 (conflicts)
cecton Aug 13, 2020
d856433
Merge commit 326da935bb0fa0e082df4a6cc7a4e19b4dede3e3 (no conflict)
cecton Aug 13, 2020
a9e99e2
WIP
cecton Aug 13, 2020
9d1f24f
Pushed branch for polkadot & substrate
cecton Aug 13, 2020
8a02521
WIP
cecton Aug 14, 2020
d81db92
using rococo and tick
cecton Aug 14, 2020
45ec2be
Revert "using rococo and tick"
cecton Aug 14, 2020
8b6cc69
debug
cecton Aug 18, 2020
41ba862
WIP
cecton Aug 20, 2020
8d1a3b8
Revert "Revert "using rococo and tick""
cecton Aug 20, 2020
84fc0a1
WIP
cecton Aug 20, 2020
c001859
Update rococo-parachains/src/service.rs
cecton Aug 13, 2020
162e773
WIP
cecton Aug 20, 2020
28b980b
WIP
cecton Aug 21, 2020
d3f63ed
WIP
cecton Aug 21, 2020
22d1cf5
Revert "WIP"
cecton Aug 21, 2020
1c63c71
WIP
cecton Aug 21, 2020
6e1e4ac
CLEANUP
cecton Aug 21, 2020
f6c7704
CLEANUP
cecton Aug 21, 2020
e7817b8
CLEANUP
cecton Sep 3, 2020
9785cd3
Use inprocess validation
cecton Sep 3, 2020
c612087
CLEANUP
cecton Sep 3, 2020
9f30e21
CLEANUP
cecton Sep 3, 2020
1017e70
Fix failing test
cecton Sep 4, 2020
21ced02
CLEANUP
cecton Sep 4, 2020
487fc54
CLEANUP
cecton Sep 4, 2020
72a50f4
increase logs
cecton Sep 9, 2020
b416160
Removed a bit of logs
cecton Sep 9, 2020
20d498e
Merge commit 3da343b926eeb189ec3a89a359d927a83f987127 (no conflict)
cecton Sep 9, 2020
5bd3f76
Revert branch change
cecton Sep 9, 2020
d550391
CLEANUP
cecton Sep 9, 2020
8bfe00c
Test without STDIN close detection
cecton Sep 9, 2020
958ce30
Bypass validation pool
cecton Sep 10, 2020
a59bde1
Switch to rococo-branch
cecton Sep 11, 2020
25f4017
Move start_test_collator to rococo-collator
cecton Sep 16, 2020
9323d4f
CLEANUP
cecton Sep 16, 2020
28d906e
CLEANUP
cecton Sep 16, 2020
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,192 changes: 685 additions & 507 deletions Cargo.lock

Large diffs are not rendered by default.

113 changes: 26 additions & 87 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ use cumulus_primitives::{
};
use cumulus_runtime::ParachainBlockData;

use sc_client_api::{BlockBackend, Finalizer, StateBackend, UsageProvider};
use sp_api::ApiExt;
use sc_client_api::{BlockBackend, Finalizer, StateBackend, UsageProvider, Backend as BackendT};
use sp_blockchain::HeaderBackend;
use sp_consensus::{
BlockImport, BlockImportParams, BlockOrigin, BlockStatus, Environment, Error as ConsensusError,
Expand Down Expand Up @@ -426,14 +425,19 @@ where
{
type ParachainContext = Collator<Block, PF, BI, BS>;

fn build<Spawner>(
fn build<Spawner, PClient, PBackend, PNetwork>(
self,
polkadot_client: polkadot_collator::Client,
polkadot_client: Arc<PClient>,
spawner: Spawner,
polkadot_network: impl CollatorNetwork + SyncOracle + Clone + 'static,
polkadot_network: PNetwork,
) -> Result<Self::ParachainContext, ()>
where
Spawner: SpawnNamed + Clone + Send + Sync + 'static,
PBackend: BackendT<PBlock>,
PBackend::State: StateBackend<BlakeTwo256>,
PClient: polkadot_service::AbstractClient<PBlock, PBackend> + 'static,
PClient::Api: RuntimeApiCollection<StateBackend = PBackend::State>,
PNetwork: CollatorNetwork + SyncOracle + Clone + 'static,
{
let CollatorBuilder {
proposer_factory,
Expand All @@ -446,101 +450,36 @@ where
delayed_block_announce_validator,
_marker,
} = self;
polkadot_client.execute_with(CollatorBuilderWithClient {
spawner,
polkadot_network,
proposer_factory,
inherent_data_providers,
block_import,
block_status,
para_id,
client,
announce_block,
delayed_block_announce_validator,
_marker,
})
}
}

pub struct CollatorBuilderWithClient<Block: BlockT, PF, BI, Backend, Client, BS, Spawner, Network> {
proposer_factory: PF,
inherent_data_providers: InherentDataProviders,
block_import: BI,
block_status: Arc<BS>,
para_id: ParaId,
client: Arc<Client>,
announce_block: Arc<dyn Fn(Block::Hash, Vec<u8>) + Send + Sync>,
delayed_block_announce_validator: DelayedBlockAnnounceValidator<Block>,
_marker: PhantomData<(Block, Backend)>,
spawner: Spawner,
polkadot_network: Network,
}

impl<Block: BlockT, PF, BI, Backend, Client, BS, Spawner, Network>
polkadot_service::ExecuteWithClient
for CollatorBuilderWithClient<Block, PF, BI, Backend, Client, BS, Spawner, Network>
where
PF: Environment<Block> + Send + 'static,
BI: BlockImport<Block, Error = sp_consensus::Error, Transaction = TransactionFor<PF, Block>>
+ Send
+ Sync
+ 'static,
Backend: sc_client_api::Backend<Block> + 'static,
Client: Finalizer<Block, Backend>
+ UsageProvider<Block>
+ HeaderBackend<Block>
+ Send
+ Sync
+ BlockBackend<Block>
+ 'static,
for<'a> &'a Client: BlockImport<Block>,
BS: BlockBackend<Block>,
Spawner: SpawnNamed + Clone + Send + Sync + 'static,
Network: CollatorNetwork + SyncOracle + Clone + 'static,
{
type Output = Result<Collator<Block, PF, BI, BS>, ()>;

fn execute_with_client<PClient, Api, PBackend>(
self,
polkadot_client: Arc<PClient>,
) -> Self::Output
where
<Api as ApiExt<PBlock>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
PBackend: sc_client_api::Backend<PBlock>,
PBackend::State: StateBackend<BlakeTwo256>,
Api: RuntimeApiCollection<StateBackend = PBackend::State>,
PClient: polkadot_service::AbstractClient<PBlock, PBackend, Api = Api> + 'static,
{
self.delayed_block_announce_validator
delayed_block_announce_validator
.set(Box::new(JustifiedBlockAnnounceValidator::new(
polkadot_client.clone(),
self.para_id,
Box::new(self.polkadot_network.clone()),
para_id,
Box::new(polkadot_network.clone()),
)));

let follow = match cumulus_consensus::follow_polkadot(
self.para_id,
self.client,
para_id,
client,
polkadot_client,
self.announce_block.clone(),
announce_block.clone(),
) {
Ok(follow) => follow,
Err(e) => {
return Err(error!("Could not start following polkadot: {:?}", e));
}
};

self.spawner
spawner
.spawn("cumulus-follow-polkadot", follow.map(|_| ()).boxed());

Ok(Collator::new(
self.proposer_factory,
self.inherent_data_providers,
self.polkadot_network,
self.block_import,
self.block_status,
Arc::new(self.spawner),
self.announce_block,
proposer_factory,
inherent_data_providers,
polkadot_network,
block_import,
block_status,
Arc::new(spawner),
announce_block,
))
}
}
Expand Down Expand Up @@ -685,8 +624,8 @@ mod tests {
block_announce_validator,
);
let context = builder
.build(
polkadot_service::Client::Polkadot(Arc::new(
.build::<_, _, polkadot_service::FullBackend, _>(
Arc::new(
substrate_test_client::TestClientBuilder::<_, _, _, ()>::default()
.build_with_native_executor::<polkadot_service::polkadot_runtime::RuntimeApi, _>(
Some(NativeExecutor::<polkadot_service::PolkadotExecutor>::new(
Expand All @@ -696,7 +635,7 @@ mod tests {
)),
)
.0,
)),
),
spawner,
DummyCollatorNetwork,
)
Expand Down
3 changes: 2 additions & 1 deletion rococo-parachains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ substrate-build-script-utils = { git = "https://github.com/paritytech/substrate"
assert_cmd = "0.12"
nix = "0.17"
rand = "0.7.3"
tokio = { version = "0.2.13", features = ["macros"] }
tokio = { version = "0.2.21", features = ["macros"] }

# Polkadot dependencies
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", branch = "rococo-branch" }
Expand All @@ -92,3 +92,4 @@ polkadot-test-service = { git = "https://github.com/paritytech/polkadot", branch
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
substrate-test-runtime-client = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
2 changes: 2 additions & 0 deletions rococo-parachains/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ pub fn run() -> Result<()> {
polkadot_config,
id,
cli.run.base.validator,
false,
)
} else {
crate::service::start_node(
Expand All @@ -300,6 +301,7 @@ pub fn run() -> Result<()> {
polkadot_config,
id,
cli.run.base.validator,
false,
)
.map(|r| r.0)
}
Expand Down
Loading