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 20 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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,15 @@ charset=utf-8
trim_trailing_whitespace=true
max_line_length=100
insert_final_newline=true

[*.yml]
indent_style=space
indent_size=2
tab_width=8
end_of_line=lf

[*.sh]
indent_style=space
indent_size=4
tab_width=8
end_of_line=lf
2,974 changes: 1,448 additions & 1,526 deletions Cargo.lock

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ edition = "2018"

[dependencies]
# Substrate dependencies
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }

# Polkadot dependencies
polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }

# Cumulus dependencies
cumulus-consensus = { path = "../consensus" }
Expand All @@ -37,13 +37,13 @@ test-runtime = { package = "cumulus-test-runtime", path = "../test/runtime" }
test-client = { package = "cumulus-test-client", path = "../test/client" }

# Substrate dependencies
substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }

# Polkadot dependencies
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }

# Other dependencies
env_logger = "0.7.1"
15 changes: 11 additions & 4 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ use polkadot_collator::{
PolkadotClient,
};
use polkadot_primitives::{
parachain::{self, BlockData, LocalValidationData, Id as ParaId}, Block as PBlock,
Hash as PHash,
parachain::{self, BlockData, GlobalValidationSchedule, LocalValidationData, Id as ParaId},
Block as PBlock, Hash as PHash,
};

use codec::{Decode, Encode};
Expand Down Expand Up @@ -111,15 +111,16 @@ where
fn produce_candidate(
&mut self,
_relay_chain_parent: PHash,
status: LocalValidationData,
_global_validation: GlobalValidationSchedule,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used

local_validation: LocalValidationData,
) -> Self::ProduceCandidate {
let factory = self.proposer_factory.clone();
let inherent_providers = self.inherent_data_providers.clone();
let block_import = self.block_import.clone();

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

let last_head = match HeadData::<Block>::decode(&mut &status.parent_head.0[..]) {
let last_head = match HeadData::<Block>::decode(&mut &local_validation.parent_head.0[..]) {
Ok(x) => x,
Err(e) => {
error!(target: "cumulus-collator", "Could not decode the head data: {:?}", e);
Expand Down Expand Up @@ -479,9 +480,15 @@ mod tests {
let collation = collate(
Default::default(),
id,
GlobalValidationSchedule {
block_number: 0,
max_code_size: 0,
max_head_data_size: 0,
},
Comment on lines +483 to +487
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used anyway

LocalValidationData {
parent_head: HeadData(header.encode()),
balance: 10,
code_upgrade_allowed: None,
},
context,
Arc::new(Sr25519Keyring::Alice.pair().into()),
Expand Down
22 changes: 11 additions & 11 deletions consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ edition = "2018"

[dependencies]
# substrate deps
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }

# polkadot deps
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }

# other deps
futures = { version = "0.3.1", features = ["compat"] }
Expand Down
18 changes: 9 additions & 9 deletions network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ edition = "2018"

[dependencies]
# substrate deps
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }

# polkadot deps
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
polkadot-statement-table = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
polkadot-validation = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
polkadot-network = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-statement-table = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-validation = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-network = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }

# other deps
codec = { package = "parity-scale-codec", version = "1.0.5", features = [ "derive" ] }
24 changes: 12 additions & 12 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ trie-db = { version = "0.20.0", default-features = false }
hashbrown = "0.6.1"

# Substrate dependencies
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" }
frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" }
sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }

# Polkadot dependencies
parachain = { package = "polkadot-parachain", git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch", default-features = false, features = [ "wasm-api" ] }
parachain = { package = "polkadot-parachain", git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch", default-features = false, features = [ "wasm-api" ] }

[dev-dependencies]
sc-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
test-client = { package = "cumulus-test-client", path = "../test/client" }

[features]
Expand Down
13 changes: 8 additions & 5 deletions runtime/src/validate_block/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use hash_db::{HashDB, EMPTY_PREFIX};

use trie_db::{Trie, TrieDB};

use parachain::{ValidationParams, ValidationResult};
use parachain::primitives::{HeadData, ValidationParams, ValidationResult};

use codec::{Decode, Encode};

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

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

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

E::execute_block(block);

ValidationResult { head_data }
ValidationResult {
head_data,
new_validation_code: None,
}
}

/// The storage implementation used when validating a block that is using the
Expand Down
12 changes: 8 additions & 4 deletions runtime/src/validate_block/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use crate::{ParachainBlockData, WitnessData};

use parachain::{ValidationParams, ValidationResult};
use parachain::primitives::{BlockData, HeadData, ValidationParams, ValidationResult};
use sc_executor::{
error::Result, WasmExecutionMethod, WasmExecutor, sp_wasm_interface::HostFunctions,
};
Expand Down Expand Up @@ -44,8 +44,12 @@ fn call_validate_block(
let mut ext = TestExternalities::default();
let mut ext_ext = ext.ext();
let params = ValidationParams {
block_data: block_data.encode(),
parent_head: parent_head.encode(),
block_data: BlockData(block_data.encode()),
parent_head: HeadData(parent_head.encode()),
code_upgrade_allowed: None,
max_code_size: 1024,
max_head_data_size: 1024,
relay_chain_height: 1,
Comment on lines +49 to +52
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the defaults from what I found in substrate

}
.encode();

Expand All @@ -65,7 +69,7 @@ fn call_validate_block(
&mut ext_ext,
)
.map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`."))
.map(|v| Header::decode(&mut &v.head_data[..]).expect("Decode `Header`."))
.map(|v| Header::decode(&mut &v.head_data.0[..]).expect("Decode `Header`."))
.map_err(|err| err.into())
}

Expand Down
10 changes: 5 additions & 5 deletions test/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

[dependencies]
test-client = { package = "substrate-test-client", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
test-client = { package = "substrate-test-client", git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
runtime = { package = "cumulus-test-runtime", path = "../runtime" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = [ "derive" ] }
sp-test-primitives = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-test-primitives = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
Loading