Skip to content

Commit 0efd15c

Browse files
authored
Update substrate and polkadot (#50)
* Update Cargo.lock * Fix for substrate update * Update Cargo.lock * Fix for substrate update * Fix for substrate update * Fix for substrate update * Fix for substrate update * Update Cargo.lock * Fix for substrate update * Fix for substrate update * Fix for substrate update * Fix for substrate update * Fix for substrate update * WIP * Temporary fix until polkadot is fixed * WIP * WIP
1 parent 539f83e commit 0efd15c

File tree

13 files changed

+756
-620
lines changed

13 files changed

+756
-620
lines changed

Cargo.lock

+545-393
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

collator/src/lib.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use sp_consensus::{
2424
};
2525
use sp_inherents::InherentDataProviders;
2626
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
27+
use sc_cli;
2728

2829
use polkadot_collator::{
2930
BuildParachainContext, InvalidHead, Network as CollatorNetwork, ParachainContext,
@@ -43,7 +44,9 @@ use log::{error, trace};
4344

4445
use futures::{task::Spawn, Future, future};
4546

46-
use std::{fmt::Debug, marker::PhantomData, sync::Arc, time::Duration, pin::Pin};
47+
use std::{
48+
fmt::Debug, marker::PhantomData, sync::Arc, time::Duration, pin::Pin, collections::HashMap,
49+
};
4750

4851
use parking_lot::Mutex;
4952

@@ -207,11 +210,12 @@ where
207210
post_digests: vec![],
208211
body: Some(b.extrinsics().to_vec()),
209212
finalized: false,
213+
intermediates: HashMap::new(),
210214
auxiliary: vec![], // block-weight is written in block import.
211215
// TODO: block-import handles fork choice and this shouldn't even have the
212216
// option to specify one.
213217
// https://github.com/paritytech/substrate/issues/3623
214-
fork_choice: ForkChoiceStrategy::LongestChain,
218+
fork_choice: Some(ForkChoiceStrategy::LongestChain),
215219
allow_missing_state: false,
216220
import_existing: false,
217221
storage_changes: Some(storage_changes),
@@ -342,20 +346,19 @@ pub trait SetupParachain<Block: BlockT>: Send {
342346
}
343347

344348
/// Run a collator with the given proposer factory.
345-
pub fn run_collator<Block, SP, E>(
349+
pub fn run_collator<Block, SP>(
346350
setup_parachain: SP,
347351
para_id: ParaId,
348-
exit: E,
349352
key: Arc<CollatorPair>,
350353
configuration: polkadot_collator::Configuration,
351354
) -> Result<(), sc_cli::error::Error>
352355
where
353356
Block: BlockT,
354357
SP: SetupParachain<Block> + Send + 'static,
355358
<<SP as SetupParachain<Block>>::ProposerFactory as Environment<Block>>::Proposer: Send,
356-
E: Future<Output = ()> + Unpin + Send + Clone + Sync + 'static,
357359
{
358360
let builder = CollatorBuilder::new(setup_parachain);
361+
let exit = future::pending(); // TODO to delete
359362
polkadot_collator::run_collator(builder, para_id, exit, key, configuration)
360363
}
361364

@@ -518,7 +521,7 @@ mod tests {
518521
let context = builder
519522
.build::<_, _, polkadot_service::polkadot_runtime::RuntimeApi, _, _>(
520523
Arc::new(
521-
substrate_test_client::TestClientBuilder::<_, _, ()>::default()
524+
substrate_test_client::TestClientBuilder::<_, _, _, ()>::default()
522525
.build_with_native_executor(Some(NativeExecutor::<
523526
polkadot_service::PolkadotExecutor,
524527
>::new(Interpreted, None)))

consensus/src/import_queue.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use std::sync::Arc;
18+
use std::collections::HashMap;
1819

1920
use sc_client::Client;
2021
use sc_client_api::{Backend, CallExecutor, TransactionFor};
@@ -95,9 +96,10 @@ where
9596
post_digests: Vec::new(),
9697
body,
9798
finalized: false,
99+
intermediates: HashMap::new(),
98100
justification,
99101
auxiliary: Vec::new(),
100-
fork_choice: ForkChoiceStrategy::LongestChain,
102+
fork_choice: Some(ForkChoiceStrategy::LongestChain),
101103
allow_missing_state: false,
102104
import_existing: false,
103105
storage_changes: None,

runtime/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2018"
99
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = [ "derive" ] }
1010
memory-db = { version = "0.18.0", default-features = false }
1111
hash-db = { version = "0.15.2", default-features = false }
12-
trie-db = { version = "0.18.0", default-features = false }
12+
trie-db = { version = "0.19.2", default-features = false }
1313
hashbrown = "0.6.1"
1414

1515
# Substrate dependencies

runtime/src/validate_block/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ fn call_validate_block(
4747
.encode();
4848

4949
call_in_wasm::<
50-
_,
5150
(
5251
sp_io::SubstrateHostFunctions,
5352
sc_executor::deprecated_host_interface::SubstrateExternals,

test/client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulu
1111
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
1212
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
1313
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = [ "derive" ] }
14-
14+
sp-test-primitives = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }

test/client/src/lib.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use runtime::{
2121
genesismap::{additional_storage_with_genesis, GenesisConfig},
2222
Block,
2323
};
24-
use sp_core::{sr25519, storage::Storage};
24+
use sp_core::{sr25519, storage::Storage, ChangesTrieConfiguration};
2525
use sp_keyring::{AccountKeyring, Sr25519Keyring};
2626
use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT};
2727
pub use test_client::*;
@@ -46,7 +46,7 @@ pub type Executor =
4646
sc_client::LocalCallExecutor<Backend, sc_executor::NativeExecutor<LocalExecutor>>;
4747

4848
/// Test client builder for Cumulus
49-
pub type TestClientBuilder = test_client::TestClientBuilder<Executor, Backend, GenesisParameters>;
49+
pub type TestClientBuilder = test_client::TestClientBuilder<Block, Executor, Backend, GenesisParameters>;
5050

5151
/// LongestChain type for the test runtime/client.
5252
pub type LongestChain = test_client::sc_client::LongestChain<Backend, Block>;
@@ -64,7 +64,12 @@ impl test_client::GenesisInit for GenesisParameters {
6464
fn genesis_storage(&self) -> Storage {
6565
use codec::Encode;
6666

67-
let mut storage = genesis_config(self.support_changes_trie).genesis_map();
67+
let changes_trie_config: Option<ChangesTrieConfiguration> = if self.support_changes_trie {
68+
Some(sp_test_primitives::changes_trie_config())
69+
} else {
70+
None
71+
};
72+
let mut storage = genesis_config(changes_trie_config).genesis_map();
6873

6974
let child_roots = storage.children.iter().map(|(sk, child_content)| {
7075
let state_root =
@@ -121,9 +126,9 @@ impl DefaultTestClientBuilderExt for TestClientBuilder {
121126
}
122127
}
123128

124-
fn genesis_config(support_changes_trie: bool) -> GenesisConfig {
129+
fn genesis_config(changes_trie_config: Option<ChangesTrieConfiguration>) -> GenesisConfig {
125130
GenesisConfig::new(
126-
support_changes_trie,
131+
changes_trie_config,
127132
vec![
128133
sr25519::Public::from(Sr25519Keyring::Alice).into(),
129134
sr25519::Public::from(Sr25519Keyring::Bob).into(),

test/parachain/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch
3838
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
3939
sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
4040
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
41-
sc-basic-authority = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
41+
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
4242
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
4343

4444
# Cumulus dependencies
@@ -49,6 +49,7 @@ cumulus-collator = { path = "../../collator" }
4949
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
5050
polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
5151
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
52+
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
5253

5354
[build-dependencies]
5455
vergen = '3.0.4'

test/parachain/runtime/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ impl_runtime_apis! {
338338
}
339339

340340
impl sp_session::SessionKeys<Block> for Runtime {
341+
fn decode_session_keys(
342+
encoded: Vec<u8>,
343+
) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
344+
opaque::SessionKeys::decode_into_raw_public_keys(&encoded)
345+
}
346+
341347
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
342348
opaque::SessionKeys::generate(seed)
343349
}

0 commit comments

Comments
 (0)