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

New parachain runtime skeleton #1158

Merged
merged 42 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
05caf14
file structure and initializer skeleton
rphmeier May 26, 2020
0703ffd
ensure session changes happen before initialization
rphmeier May 26, 2020
11da041
add a couple tests for initializer flow
rphmeier May 26, 2020
00d4d60
integrate with session handling
rphmeier May 26, 2020
e07e656
configuration update logic
rphmeier May 26, 2020
af66290
configuration methods
rphmeier May 26, 2020
48ddd60
move test mock to its own module
rphmeier May 26, 2020
33dcdb1
integrate configuration into initializer
rphmeier May 26, 2020
0b228e9
add note about initialization order
rphmeier May 26, 2020
f8a8916
integrate configuration module into mock
rphmeier May 26, 2020
2d0c60a
add some tests for config module
rphmeier May 26, 2020
c1d854f
paras module storage
rphmeier May 27, 2020
b346d47
implement paras session change operation
rphmeier May 27, 2020
3c2dd39
amend past code pruning to fully cover acceptance period
rphmeier May 27, 2020
8183638
update guide again
rphmeier May 27, 2020
26b8870
do pruning of historical validation code
rphmeier May 27, 2020
c32759b
add weight to initialization
rphmeier May 27, 2020
ec0a15d
integrate into mock & leave notes for next session
rphmeier May 27, 2020
182fbf4
clean up un-ended sentence
rphmeier May 27, 2020
a3b89f7
alter test to account for double index in past code meta
rphmeier May 27, 2020
3b82a87
port over code-at logic test
rphmeier May 27, 2020
1a585a6
clarify checking for conflicting code upgrades
rphmeier May 27, 2020
10fe902
add genesis for paras, include in mock, ensure incoming paras are pro…
rphmeier May 27, 2020
a05a4b9
note on return value of `validation_code_at`
rphmeier May 27, 2020
f77326f
implement paras routines from implementor's guide
rphmeier May 28, 2020
fdc3631
bring over some existing tests and begin porting
rphmeier May 28, 2020
a58b349
port over code upgrade tests
rphmeier May 28, 2020
e671590
test parachain registration
rphmeier May 28, 2020
11c8c3c
test code_at with intermediate block
rphmeier May 28, 2020
0116cc4
fix warnings
rphmeier May 28, 2020
b608d34
Merge branch 'master' into rh-para-runtime-skeleton
rphmeier May 28, 2020
e0f1a71
clean up docs and extract to separate struct
rphmeier May 28, 2020
4fce5b5
adjust implementor's guide to include replacementtimes
rphmeier May 29, 2020
1297674
kill stray println
rphmeier May 29, 2020
e486ce3
rename expected_at to applied_after
rphmeier May 30, 2020
b50e6d2
rewrite ParaPastCodeMeta to avoid reversal
rphmeier May 30, 2020
ffe66b1
clarify and test interface of validation_code_at
rphmeier May 30, 2020
829dc2e
make FutureCode optional
rphmeier May 30, 2020
5a8efc8
Merge branch 'master' into rh-para-runtime-skeleton
rphmeier Jun 1, 2020
a01bafd
rename do_old_code_pruning
rphmeier Jun 1, 2020
2a079cc
add comment on Option<()> to answer FAQ
rphmeier Jun 1, 2020
4adc554
address some more grumbles
rphmeier Jun 1, 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
42 changes: 42 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ members = [
"network/test",
"primitives",
"runtime/common",
"runtime/parachains",
"runtime/polkadot",
"runtime/kusama",
"runtime/westend",
Expand Down
7 changes: 4 additions & 3 deletions roadmap/implementors-guide/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ It's also responsible for managing parachain validation code upgrades as well as
Utility structs:
```rust
// the two key times necessary to track for every code replacement.
struct ReplacementTimes {
pub struct ReplacementTimes {
/// The relay-chain block number that the code upgrade was expected to be activated.
/// This is when the code change occurs from the para's perspective - after the
/// first parablock included with a relay-parent with number >= this value.
Expand Down Expand Up @@ -564,7 +564,7 @@ PastCodePruning: Vec<(ParaId, BlockNumber)>;
/// in the context of a relay chain block with a number >= `expected_at`.
FutureCodeUpgrades: map ParaId => Option<BlockNumber>;
/// The actual future code of a para.
FutureCode: map ParaId => ValidationCode;
FutureCode: map ParaId => Option<ValidationCode>;

/// Upcoming paras (chains and threads). These are only updated on session change. Corresponds to an
/// entry in the upcoming-genesis map.
Expand All @@ -590,7 +590,7 @@ OutgoingParas: Vec<ParaId>;
* `schedule_para_cleanup(ParaId)`: schedule a para to be cleaned up at the next session.
* `schedule_code_upgrade(ParaId, ValidationCode, expected_at: BlockNumber)`: Schedule a future code upgrade of the given parachain, to be applied after inclusion of a block of the same parachain executed in the context of a relay-chain block with number >= `expected_at`.
* `note_new_head(ParaId, HeadData, BlockNumber)`: note that a para has progressed to a new head, where the new head was executed in the context of a relay-chain block with given number. This will apply pending code upgrades based on the block number provided.
* `validation_code_at(ParaId, at: BlockNumber, assume_intermediate: Option<BlockNumber>)`: Fetches the validation code to be used when validating a block in the context of the given relay-chain height. A second block number parameter may be used to tell the lookup to proceed as if an intermediate parablock has been included at the given relay-chain height. This may return past, current, or (with certain choices of `assume_intermediate`) future code. `assume_intermediate`, if provided, must be before `at`. If `at` is not within `config.acceptance_period` of the current block number, this will return `None`.
* `validation_code_at(ParaId, at: BlockNumber, assume_intermediate: Option<BlockNumber>)`: Fetches the validation code to be used when validating a block in the context of the given relay-chain height. A second block number parameter may be used to tell the lookup to proceed as if an intermediate parablock has been included at the given relay-chain height. This may return past, current, or (with certain choices of `assume_intermediate`) future code. `assume_intermediate`, if provided, must be before `at`. If the validation code has been pruned, this will return `None`.

#### Finalization

Expand Down Expand Up @@ -838,6 +838,7 @@ All failed checks should lead to an unrecoverable error making the block invalid
1. Return a list of freed cores consisting of the cores where candidates have become available.
* `process_candidates(BackedCandidates, scheduled: Vec<CoreAssignment>)`:
1. check that each candidate corresponds to a scheduled core and that they are ordered in ascending order by `ParaId`.
1. Ensure that any code upgrade scheduled by the candidate does not happen within `config.validation_upgrade_frequency` of the currently scheduled upgrade, if any, comparing against the value of `Paras::FutureCodeUpgrades` for the given para ID.
1. check the backing of the candidate using the signatures and the bitfields.
1. create an entry in the `PendingAvailability` map for each backed candidate with a blank `availability_votes` bitfield.
1. Return a `Vec<CoreIndex>` of all scheduled cores of the list of passed assignments that a candidate was successfully backed for, sorted ascending by CoreIndex.
Expand Down
84 changes: 84 additions & 0 deletions runtime/parachains/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
[package]
name = "polkadot-runtime-parachains"
version = "0.8.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

[dependencies]
bitvec = { version = "0.17.4", default-features = false, features = ["alloc"] }
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
log = { version = "0.3.9", optional = true }
rustc-hex = { version = "2.0.1", default-features = false }
serde = { version = "1.0.102", default-features = false }
serde_derive = { version = "1.0.102", optional = true }

sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

authorship = { package = "pallet-authorship", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
balances = { package = "pallet-balances", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
session = { package = "pallet-session", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
staking = { package = "pallet-staking", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
system = { package = "frame-system", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offences = { package = "pallet-offences", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }

primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
libsecp256k1 = { version = "0.3.2", default-features = false, optional = true }

[dev-dependencies]
hex-literal = "0.2.1"
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master" }
randomness-collective-flip = { package = "pallet-randomness-collective-flip", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "master" }
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "master" }
trie-db = "0.20.0"
serde_json = "1.0.41"
libsecp256k1 = "0.3.2"

[features]
default = ["std"]
no_std = []
std = [
"bitvec/std",
"codec/std",
"log",
"rustc-hex/std",
"serde_derive",
"serde/std",
"primitives/std",
"inherents/std",
"sp-core/std",
"sp-api/std",
"sp-std/std",
"sp-io/std",
"frame-support/std",
"authorship/std",
"balances/std",
"sp-runtime/std",
"sp-session/std",
"sp-staking/std",
"session/std",
"staking/std",
"system/std",
"timestamp/std",
"vesting/std",
]
runtime-benchmarks = [
"libsecp256k1/hmac",
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"system/runtime-benchmarks",
]
Loading