Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Upgradeable validation functions #918

Merged
merged 33 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
58941e2
upgrade primitives to allow changing validation function
rphmeier Mar 15, 2020
753ea08
set up storage schema for old parachains code
rphmeier Mar 15, 2020
ddfa72f
fix compilation errors
rphmeier Mar 16, 2020
d66a544
fix test compilation
rphmeier Mar 16, 2020
ba6b392
add some tests for past code meta
rphmeier Mar 16, 2020
d87c034
most of the runtime logic for code upgrades
rphmeier Mar 16, 2020
fd07208
implement old-code pruning
rphmeier Mar 18, 2020
dcd2a22
add a couple tests
rphmeier Mar 19, 2020
f26c6d5
clean up remaining TODOs
rphmeier Mar 19, 2020
85adf9f
add a whole bunch of tests for runtime functionality
rphmeier Mar 20, 2020
a7cc5a8
remove unused function
rphmeier Mar 20, 2020
847bbbb
fix runtime compilation
rphmeier Mar 20, 2020
b265719
extract some primitives to parachain crate
rphmeier Mar 20, 2020
7008912
add validation-code upgrades to validation params and result
rphmeier Mar 20, 2020
b331fd1
extend validation params with code upgrade fields
rphmeier Mar 20, 2020
554ed89
provide maximums to validation params
rphmeier Mar 20, 2020
c9b324b
port test-parachains
rphmeier Mar 20, 2020
38d724c
add a code-upgrader test-parachain and tests
rphmeier Mar 20, 2020
43888e3
fix collator tests
rphmeier Mar 22, 2020
71d23d3
Merge branch 'master' into rh-upgradeable-validation-function
rphmeier Mar 22, 2020
e638aa5
move test-parachains to own folder to work around compilation errors
rphmeier Mar 22, 2020
87e0dcc
Merge branch 'master' into rh-upgradeable-validation-function
rphmeier Mar 22, 2020
87de26e
Merge branch 'master' into rh-upgradeable-validation-function
rphmeier Mar 22, 2020
a4b5b09
fix test compilation
rphmeier Mar 22, 2020
1442886
Merge branch 'master' into rh-upgradeable-validation-function
rphmeier Mar 30, 2020
8026746
Merge branch 'master' into rh-upgradeable-validation-function
rphmeier Apr 1, 2020
052de96
update the Cargo.lock
rphmeier Apr 1, 2020
fa80d0a
fix parachains tests
rphmeier Apr 2, 2020
ff534ce
remove dbg! invocation
rphmeier Apr 2, 2020
d43aeed
Merge branch 'master' into rh-upgradeable-validation-function
rphmeier Apr 4, 2020
25c0cd7
use new pool in code-upgrader
rphmeier Apr 3, 2020
c3fa7fe
bump lockfile
rphmeier Apr 4, 2020
342ad7f
link TODO to issue
rphmeier Apr 6, 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
98 changes: 59 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ members = [
"service",
"validation",

"test-parachains/adder",
"test-parachains/adder/collator",
"parachain/test-parachains",
"parachain/test-parachains/adder",
"parachain/test-parachains/adder/collator",
"parachain/test-parachains/code-upgrader",
]
exclude = [
"runtime/polkadot/wasm",
"runtime/kusama/wasm",
"test-parachains/adder/wasm",
"parachain/test-parachains/adder/wasm",
]

[badges]
Expand Down
10 changes: 8 additions & 2 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use polkadot_primitives::{
BlockId, Hash, Block,
parachain::{
self, BlockData, DutyRoster, HeadData, Id as ParaId,
PoVBlock, ValidatorId, CollatorPair, LocalValidationData
PoVBlock, ValidatorId, CollatorPair, LocalValidationData, GlobalValidationSchedule,
}
};
use polkadot_cli::{
Expand Down Expand Up @@ -154,14 +154,16 @@ pub trait ParachainContext: Clone {
fn produce_candidate(
&mut self,
relay_parent: Hash,
status: LocalValidationData,
global_validation: GlobalValidationSchedule,
local_validation: LocalValidationData,
) -> Self::ProduceCandidate;
}

/// Produce a candidate for the parachain, with given contexts, parent head, and signing key.
pub async fn collate<P>(
relay_parent: Hash,
local_id: ParaId,
global_validation: GlobalValidationSchedule,
local_validation_data: LocalValidationData,
mut para_context: P,
key: Arc<CollatorPair>,
Expand All @@ -173,6 +175,7 @@ pub async fn collate<P>(
{
let (block_data, head_data) = para_context.produce_candidate(
relay_parent,
global_validation,
local_validation_data,
).map_err(Error::Collator).await?;

Expand Down Expand Up @@ -281,6 +284,7 @@ fn build_collator_service<S, P, Extrinsic>(

let work = future::lazy(move |_| {
let api = client.runtime_api();
let global_validation = try_fr!(api.global_validation_schedule(&id));
let local_validation = match try_fr!(api.local_validation_data(&id, para_id)) {
Some(local_validation) => local_validation,
None => return future::Either::Left(future::ok(())),
Expand All @@ -297,6 +301,7 @@ fn build_collator_service<S, P, Extrinsic>(
let collation_work = collate(
relay_parent,
para_id,
global_validation,
local_validation,
parachain_context,
key,
Expand Down Expand Up @@ -427,6 +432,7 @@ mod tests {
fn produce_candidate(
&mut self,
_relay_parent: Hash,
_global: GlobalValidationSchedule,
_local_validation: LocalValidationData,
) -> Self::ProduceCandidate {
// send messages right back.
Expand Down
21 changes: 11 additions & 10 deletions parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ description = "Types and utilities for creating and working with parachains"
edition = "2018"

[dependencies]
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = [ "derive" ] }
derive_more = { version = "0.99.2", optional = true }
serde = { version = "1.0.102", default-features = false, features = [ "derive" ], optional = true }
# note: special care is taken to avoid inclusion of `sp-io` externals when compiling
# this crate for WASM. This is critical to avoid forcing all parachain WASM into implementing
# various unnecessary Substrate-specific endpoints.
codec = { package = "parity-scale-codec", version = "1.1.0", default-features = false, features = [ "derive" ] }
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime-interface = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-wasm-interface = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

# all optional crates.
derive_more = { version = "0.99.2", optional = true }
serde = { version = "1.0.102", default-features = false, features = [ "derive" ], optional = true }
sp-runtime-interface = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true, default-features = false }
sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
Expand All @@ -22,14 +27,9 @@ log = { version = "0.4.8", optional = true }
[target.'cfg(not(target_os = "unknown"))'.dependencies]
shared_memory = { version = "0.10.0", optional = true }

[dev-dependencies]
tiny-keccak = "1.5.0"
adder = { path = "../test-parachains/adder" }
halt = { path = "../test-parachains/halt" }

[features]
default = ["std"]
wasm-api = []
wasm-api = ["sp-runtime-interface"]
std = [
"codec/std",
"derive_more",
Expand All @@ -39,6 +39,7 @@ std = [
"sp-core/std",
"parking_lot",
"log",
"sp-runtime-interface",
"sp-runtime-interface/std",
"sp-externalities",
"sc-executor",
Expand Down
Loading