Skip to content

Commit 7431075

Browse files
authored
Update polkadot & substrate (#76)
1 parent 461b971 commit 7431075

14 files changed

+750
-602
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@ charset=utf-8
88
trim_trailing_whitespace=true
99
max_line_length=100
1010
insert_final_newline=true
11+
12+
[*.yml]
13+
indent_style=space
14+
indent_size=2
15+
tab_width=8
16+
end_of_line=lf
17+
18+
[*.sh]
19+
indent_style=space
20+
indent_size=4
21+
tab_width=8
22+
end_of_line=lf

Cargo.lock

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

collator/src/lib.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ use polkadot_collator::{
3131
PolkadotClient,
3232
};
3333
use polkadot_primitives::{
34-
parachain::{self, BlockData, LocalValidationData, Id as ParaId}, Block as PBlock,
35-
Hash as PHash,
34+
parachain::{self, BlockData, GlobalValidationSchedule, LocalValidationData, Id as ParaId},
35+
Block as PBlock, Hash as PHash,
3636
};
3737

3838
use codec::{Decode, Encode};
@@ -111,15 +111,16 @@ where
111111
fn produce_candidate(
112112
&mut self,
113113
_relay_chain_parent: PHash,
114-
status: LocalValidationData,
114+
_global_validation: GlobalValidationSchedule,
115+
local_validation: LocalValidationData,
115116
) -> Self::ProduceCandidate {
116117
let factory = self.proposer_factory.clone();
117118
let inherent_providers = self.inherent_data_providers.clone();
118119
let block_import = self.block_import.clone();
119120

120121
trace!(target: "cumulus-collator", "Producing candidate");
121122

122-
let last_head = match HeadData::<Block>::decode(&mut &status.parent_head.0[..]) {
123+
let last_head = match HeadData::<Block>::decode(&mut &local_validation.parent_head.0[..]) {
123124
Ok(x) => x,
124125
Err(e) => {
125126
error!(target: "cumulus-collator", "Could not decode the head data: {:?}", e);
@@ -479,9 +480,15 @@ mod tests {
479480
let collation = collate(
480481
Default::default(),
481482
id,
483+
GlobalValidationSchedule {
484+
block_number: 0,
485+
max_code_size: 0,
486+
max_head_data_size: 0,
487+
},
482488
LocalValidationData {
483489
parent_head: HeadData(header.encode()),
484490
balance: 10,
491+
code_upgrade_allowed: None,
485492
},
486493
context,
487494
Arc::new(Sr25519Keyring::Alice.pair().into()),

runtime/src/validate_block/implementation.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use hash_db::{HashDB, EMPTY_PREFIX};
2828

2929
use trie_db::{Trie, TrieDB};
3030

31-
use parachain::{ValidationParams, ValidationResult};
31+
use parachain::primitives::{HeadData, ValidationParams, ValidationResult};
3232

3333
use codec::{Decode, Encode};
3434

@@ -73,12 +73,12 @@ trait Storage {
7373
/// Validate a given parachain block on a validator.
7474
#[doc(hidden)]
7575
pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(params: ValidationParams) -> ValidationResult {
76-
let block_data = crate::ParachainBlockData::<B>::decode(&mut &params.block_data[..])
76+
let block_data = crate::ParachainBlockData::<B>::decode(&mut &params.block_data.0[..])
7777
.expect("Invalid parachain block data");
7878

79-
let parent_head = B::Header::decode(&mut &params.parent_head[..]).expect("Invalid parent head");
79+
let parent_head = B::Header::decode(&mut &params.parent_head.0[..]).expect("Invalid parent head");
8080
// TODO: Use correct head data
81-
let head_data = block_data.header.encode();
81+
let head_data = HeadData(block_data.header.encode());
8282

8383
// TODO: Add `PolkadotInherent`.
8484
let block = B::new(block_data.header, block_data.extrinsics);
@@ -110,7 +110,10 @@ pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(params: ValidationParams) -
110110

111111
E::execute_block(block);
112112

113-
ValidationResult { head_data }
113+
ValidationResult {
114+
head_data,
115+
new_validation_code: None,
116+
}
114117
}
115118

116119
/// The storage implementation used when validating a block that is using the

runtime/src/validate_block/tests.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
use crate::{ParachainBlockData, WitnessData};
1818

19-
use parachain::{ValidationParams, ValidationResult};
19+
use parachain::primitives::{BlockData, HeadData, ValidationParams, ValidationResult};
2020
use sc_executor::{
2121
error::Result, WasmExecutionMethod, WasmExecutor, sp_wasm_interface::HostFunctions,
2222
};
@@ -44,8 +44,12 @@ fn call_validate_block(
4444
let mut ext = TestExternalities::default();
4545
let mut ext_ext = ext.ext();
4646
let params = ValidationParams {
47-
block_data: block_data.encode(),
48-
parent_head: parent_head.encode(),
47+
block_data: BlockData(block_data.encode()),
48+
parent_head: HeadData(parent_head.encode()),
49+
code_upgrade_allowed: None,
50+
max_code_size: 1024,
51+
max_head_data_size: 1024,
52+
relay_chain_height: 1,
4953
}
5054
.encode();
5155

@@ -65,7 +69,7 @@ fn call_validate_block(
6569
&mut ext_ext,
6670
)
6771
.map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`."))
68-
.map(|v| Header::decode(&mut &v.head_data[..]).expect("Decode `Header`."))
72+
.map(|v| Header::decode(&mut &v.head_data.0[..]).expect("Decode `Header`."))
6973
.map_err(|err| err.into())
7074
}
7175

test/parachain/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "c
5050
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
5151

5252
[build-dependencies]
53-
vergen = '3.0.4'
53+
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
5454

5555
[dev-dependencies]
5656
assert_cmd = "0.12"

test/parachain/build.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616

1717
use std::{env, path::PathBuf};
1818

19-
use vergen::{generate_cargo_keys, ConstantsFlags};
20-
21-
const ERROR_MSG: &str = "Failed to generate metadata files";
19+
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
2220

2321
fn main() {
24-
generate_cargo_keys(ConstantsFlags::SHA_SHORT).expect(ERROR_MSG);
22+
generate_cargo_keys();
23+
rerun_if_git_head_changed();
2524

2625
let mut manifest_dir = PathBuf::from(
2726
env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is always set by cargo."),

test/parachain/res/polkadot_chainspec.json

+63-62
Large diffs are not rendered by default.

test/parachain/src/chain_spec.rs

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub fn get_chain_spec() -> ChainSpec {
4343
ChainSpec::from_genesis(
4444
"Local Testnet",
4545
"parachain_local_testnet",
46+
sc_service::ChainType::Local,
4647
|| {
4748
testnet_genesis(
4849
vec![

test/parachain/src/cli.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use std::path::PathBuf;
1818

1919
use sc_cli;
20-
pub use polkadot_cli::Cli as PolkadotCli;
2120
use structopt::StructOpt;
2221

2322
/// Sub-commands supported by the collator.
@@ -55,3 +54,12 @@ pub struct Cli {
5554
#[structopt(raw = true)]
5655
pub relaychain_args: Vec<String>,
5756
}
57+
58+
#[derive(Debug, StructOpt, Clone)]
59+
pub struct PolkadotCli {
60+
#[structopt(flatten)]
61+
pub base: polkadot_cli::RunCmd,
62+
63+
#[structopt(skip)]
64+
pub base_path: Option<PathBuf>,
65+
}

0 commit comments

Comments
 (0)