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

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dm-get-rid-of-peers…
Browse files Browse the repository at this point in the history
…et-stub
  • Loading branch information
dmitry-markin committed Jul 26, 2023
2 parents 3ce1576 + 6fb5756 commit cba34e7
Show file tree
Hide file tree
Showing 23 changed files with 809 additions and 1,720 deletions.
2,345 changes: 694 additions & 1,651 deletions Cargo.lock

Large diffs are not rendered by default.

39 changes: 6 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
This repository contains both the Cumulus SDK and also specific chains implemented
on top of this SDK.

If you only want to run a **Polkadot Parachain Node**, check out our [container section](./docs/container.md).

## Cumulus SDK

A set of tools for writing [Substrate](https://substrate.io/)-based
Expand Down Expand Up @@ -37,6 +39,8 @@ and treat as best.
A Polkadot [collator](https://wiki.polkadot.network/docs/en/learn-collator) for the parachain is
implemented by the `polkadot-parachain` binary (previously called `polkadot-collator`).

You may run `polkadot-parachain` locally after building it or using one of the container option described [here](./docs/container.md).

### Relay Chain Interaction
To operate a parachain node, a connection to the corresponding relay chain is necessary. This can be
achieved in one of two ways:
Expand Down Expand Up @@ -220,26 +224,15 @@ To run a Rococo collator you will need to compile the following binary:
cargo build --release --locked --bin polkadot-parachain
```

Otherwise you can compile it with
[Parity CI docker image](https://github.com/paritytech/scripts/tree/master/dockerfiles/ci-linux):

```bash
docker run --rm -it -w /shellhere/cumulus \
-v $(pwd):/shellhere/cumulus \
paritytech/ci-linux:production cargo build --release --locked --bin polkadot-parachain
sudo chown -R $(id -u):$(id -g) target/
```

If you want to reproduce other steps of CI process you can use the following
[guide](https://github.com/paritytech/scripts#gitlab-ci-for-building-docker-images).

Once the executable is built, launch collators for each parachain (repeat once each for chain
`tick`, `trick`, `track`):

```bash
./target/release/polkadot-parachain --chain $CHAIN --validator
```

You can also build [using a container](./docs/container.md).

### Parachains

* [Asset Hub](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-statemint-rpc.polkadot.io#/explorer)
Expand All @@ -249,23 +242,3 @@ Once the executable is built, launch collators for each parachain (repeat once e
The network uses horizontal message passing (HRMP) to enable communication between parachains and
the relay chain and, in turn, between parachains. This means that every message is sent to the relay
chain, and from the relay chain to its destination parachain.

### Containerize

After building `polkadot-parachain` with cargo or with Parity CI image as documented in [this chapter](#build--launch-rococo-collators),
the following will allow producing a new docker image where the compiled binary is injected:

```bash
./docker/scripts/build-injected-image.sh
```

Alternatively, you can build an image with a builder pattern:

```bash
docker build --tag $OWNER/$IMAGE_NAME --file ./docker/polkadot-parachain_builder.Containerfile .

You may then run your new container:

```bash
docker run --rm -it $OWNER/$IMAGE_NAME --collator --tmp --chain /specs/westmint.json
```
2 changes: 1 addition & 1 deletion client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"

[dependencies]
clap = { version = "4.3.17", features = ["derive"] }
clap = { version = "4.3.19", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0.0" }
url = "2.4.0"

Expand Down
4 changes: 2 additions & 2 deletions client/collator/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use sc_client_api::BlockBackend;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_consensus::BlockStatus;
use sp_core::traits::SpawnNamed;
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT, Zero};
use sp_runtime::traits::{Block as BlockT, HashingFor, Header as HeaderT, Zero};

use cumulus_client_consensus_common::ParachainCandidate;
use polkadot_node_primitives::{
Expand Down Expand Up @@ -222,7 +222,7 @@ where

let compact_proof = match candidate
.proof
.into_compact_proof::<HashFor<Block>>(*parent_header.state_root())
.into_compact_proof::<HashingFor<Block>>(*parent_header.state_root())
{
Ok(proof) => proof,
Err(e) => {
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async-trait = "0.1.72"
codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ] }
futures = "0.3.28"
tracing = "0.1.37"
lru = "0.10.0"
lru = "0.11.0"

# Substrate
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
4 changes: 2 additions & 2 deletions client/consensus/aura/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvid
use sp_keystore::KeystorePtr;
use sp_runtime::{
generic::Digest,
traits::{Block as BlockT, HashFor, Header as HeaderT, Member},
traits::{Block as BlockT, HashingFor, Header as HeaderT, Member},
};
use sp_state_machine::StorageChanges;
use sp_timestamp::Timestamp;
Expand Down Expand Up @@ -324,7 +324,7 @@ where
/// Seal a block with a signature in the header.
pub fn seal<B: BlockT, T, P>(
pre_sealed: B,
storage_changes: StorageChanges<T, HashFor<B>>,
storage_changes: StorageChanges<T, HashingFor<B>>,
author_pub: &P::Public,
keystore: &KeystorePtr,
) -> Result<BlockImportParams<B, T>, Box<dyn Error>>
Expand Down
2 changes: 1 addition & 1 deletion client/relay-chain-minimal-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ cumulus-relay-chain-rpc-interface = { path = "../relay-chain-rpc-interface" }
cumulus-primitives-core = { path = "../../primitives/core" }

array-bytes = "6.1"
lru = "0.9"
lru = "0.11"
tracing = "0.1.37"
async-trait = "0.1.72"
futures = "0.3.28"
Expand Down
4 changes: 2 additions & 2 deletions client/relay-chain-rpc-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ tracing = "0.1.37"
async-trait = "0.1.72"
url = "2.4.0"
serde_json = "1.0.103"
serde = "1.0.171"
lru = "0.9.0"
serde = "1.0.175"
lru = "0.11.0"
60 changes: 60 additions & 0 deletions docs/container.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Using Containers

Using containers via **Podman** or **Docker** brings benefit, whether it is to build a container image or
run a node while keeping a minimum footprint on your local system.

This document mentions using `podman` or `docker`. Those are usually interchangeable and it is encouraged using preferably **Podman**. If you have podman installed and want to use all the commands mentioned below, you can simply create an alias with `alias docker=podman`.

There are a few options to build a node within a container and inject a binary inside an image.

### Parity built container image

Parity builds and publishes a container image that can be found as `docker.io/parity/polkadot-parachain`.

### Parity CI image

Parity maintains and uses internally a generic "CI" image that can be used as a base to build binaries: [Parity CI container image](https://github.com/paritytech/scripts/tree/master/dockerfiles/ci-linux):

The command below allows building a Linux binary without having to even install Rust or any dependency locally:

```bash
docker run --rm -it \
-w /shellhere/cumulus \
-v $(pwd):/shellhere/cumulus \
paritytech/ci-linux:production
cargo build --release --locked --bin polkadot-parachain
sudo chown -R $(id -u):$(id -g) target/
```

If you want to reproduce other steps of CI process you can use the following
[guide](https://github.com/paritytech/scripts#gitlab-ci-for-building-docker-images).

### Injected image

Injecting a binary inside a base image is the quickest option to get a working container image. This only works if you were able to build a Linux binary, either locally, or using a container as described above.

After building a Linux binary ()`polkadot-parachain`) with cargo or with Parity CI image as documented above, the following command allows producing a new container image where the compiled binary is injected:

```bash
./docker/scripts/build-injected-image.sh
```

### Container build

Alternatively, you can build an image with a builder pattern. This options takes a while but offers a simple method for anyone to get a working container image without requiring any of the Rust toolchain installed locally.

```bash
docker build \
--tag $OWNER/$IMAGE_NAME \
--file ./docker/polkadot-parachain_builder.Containerfile .
```

You may then run your new container:

```bash
docker run --rm -it \
$OWNER/$IMAGE_NAME \
--collator --tmp \
--execution wasm \
--chain /specs/westmint.json
```
2 changes: 1 addition & 1 deletion pallets/parachain-system/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Proc macros provided by the parachain-system pallet"
proc-macro = true

[dependencies]
syn = "2.0.26"
syn = "2.0.27"
proc-macro2 = "1.0.64"
quote = "1.0.31"
proc-macro-crate = "1.3.1"
Expand Down
11 changes: 6 additions & 5 deletions pallets/parachain-system/src/relay_state_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use cumulus_primitives_core::{
relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId,
};
use scale_info::TypeInfo;
use sp_runtime::traits::HashFor;
use sp_runtime::traits::HashingFor;
use sp_state_machine::{Backend, TrieBackend, TrieBackendBuilder};
use sp_std::vec::Vec;
use sp_trie::{HashDBT, MemoryDB, StorageProof, EMPTY_PREFIX};
Expand Down Expand Up @@ -114,7 +114,7 @@ pub enum ReadEntryErr {
fn read_entry<T, B>(backend: &B, key: &[u8], fallback: Option<T>) -> Result<T, ReadEntryErr>
where
T: Decode,
B: Backend<HashFor<relay_chain::Block>>,
B: Backend<HashingFor<relay_chain::Block>>,
{
backend
.storage(key)
Expand All @@ -133,7 +133,7 @@ where
fn read_optional_entry<T, B>(backend: &B, key: &[u8]) -> Result<Option<T>, ReadEntryErr>
where
T: Decode,
B: Backend<HashFor<relay_chain::Block>>,
B: Backend<HashingFor<relay_chain::Block>>,
{
match read_entry(backend, key, None) {
Ok(v) => Ok(Some(v)),
Expand All @@ -147,7 +147,8 @@ where
/// This state proof is extracted from the relay chain block we are building on top of.
pub struct RelayChainStateProof {
para_id: ParaId,
trie_backend: TrieBackend<MemoryDB<HashFor<relay_chain::Block>>, HashFor<relay_chain::Block>>,
trie_backend:
TrieBackend<MemoryDB<HashingFor<relay_chain::Block>>, HashingFor<relay_chain::Block>>,
}

impl RelayChainStateProof {
Expand All @@ -160,7 +161,7 @@ impl RelayChainStateProof {
relay_parent_storage_root: relay_chain::Hash,
proof: StorageProof,
) -> Result<Self, Error> {
let db = proof.into_memory_db::<HashFor<relay_chain::Block>>();
let db = proof.into_memory_db::<HashingFor<relay_chain::Block>>();
if !db.contains(&relay_parent_storage_root, EMPTY_PREFIX) {
return Err(Error::RootMismatch)
}
Expand Down
10 changes: 5 additions & 5 deletions pallets/parachain-system/src/validate_block/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ use frame_support::traits::{ExecuteBlock, ExtrinsicCall, Get, IsSubType};
use sp_core::storage::{ChildInfo, StateVersion};
use sp_externalities::{set_and_run_with_externalities, Externalities};
use sp_io::KillStorageResult;
use sp_runtime::traits::{Block as BlockT, Extrinsic, HashFor, Header as HeaderT};
use sp_runtime::traits::{Block as BlockT, Extrinsic, HashingFor, Header as HeaderT};
use sp_std::prelude::*;
use sp_trie::MemoryDB;

type TrieBackend<B> = sp_state_machine::TrieBackend<
MemoryDB<HashFor<B>>,
HashFor<B>,
trie_cache::CacheProvider<HashFor<B>>,
MemoryDB<HashingFor<B>>,
HashingFor<B>,
trie_cache::CacheProvider<HashingFor<B>>,
>;

type Ext<'a, B> = sp_state_machine::Ext<'a, HashFor<B>, TrieBackend<B>>;
type Ext<'a, B> = sp_state_machine::Ext<'a, HashingFor<B>, TrieBackend<B>>;

fn with_externalities<F: FnOnce(&mut dyn Externalities) -> R, R>(f: F) -> R {
sp_externalities::with_externalities(f).expect("Environmental externalities not set.")
Expand Down
4 changes: 2 additions & 2 deletions parachain-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ edition = "2021"
build = "build.rs"

[dependencies]
clap = { version = "4.3.17", features = ["derive"] }
clap = { version = "4.3.19", features = ["derive"] }
log = "0.4.19"
codec = { package = "parity-scale-codec", version = "3.0.0" }
serde = { version = "1.0.171", features = ["derive"] }
serde = { version = "1.0.175", features = ["derive"] }
jsonrpsee = { version = "0.16.2", features = ["server"] }
futures = "0.3.28"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
hex-literal = { version = "0.4.1" }
log = { version = "0.4.19", default-features = false }
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.171", optional = true, features = ["derive"] }
serde = { version = "1.0.175", optional = true, features = ["derive"] }
smallvec = "1.11.0"

# Substrate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
hex-literal = { version = "0.4.1" }
log = { version = "0.4.19", default-features = false }
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.171", optional = true, features = ["derive"] }
serde = { version = "1.0.175", optional = true, features = ["derive"] }
smallvec = "1.11.0"

# Substrate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
hex-literal = { version = "0.4.1" }
log = { version = "0.4.19", default-features = false }
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.171", optional = true, features = ["derive"] }
serde = { version = "1.0.175", optional = true, features = ["derive"] }
smallvec = "1.11.0"

# Substrate
Expand Down
4 changes: 2 additions & 2 deletions polkadot-parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ path = "src/main.rs"

[dependencies]
async-trait = "0.1.72"
clap = { version = "4.3.17", features = ["derive"] }
clap = { version = "4.3.19", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0.0" }
futures = "0.3.28"
hex-literal = "0.4.1"
log = "0.4.19"
serde = { version = "1.0.171", features = ["derive"] }
serde = { version = "1.0.175", features = ["derive"] }
serde_json = "1.0.103"

# Local
Expand Down
2 changes: 1 addition & 1 deletion polkadot-parachain/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ where
C::Api: BlockBuilder<Block>,
P: TransactionPool + Sync + Send + 'static,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashingFor<Block>>,
{
use frame_rpc_system::{System, SystemApiServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/gitlab/pipeline/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ build-short-benchmark:
- job: check-rustdoc
artifacts: false
script:
- cargo build --profile release --locked --features=runtime-benchmarks
- cargo build --profile release --locked --features=runtime-benchmarks --bin polkadot-parachain
- mkdir -p ./artifacts
- cp ./target/release/polkadot-parachain ./artifacts/
4 changes: 2 additions & 2 deletions test/relay-sproof-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use cumulus_primitives_core::{
relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId,
};
use polkadot_primitives::UpgradeGoAhead;
use sp_runtime::traits::HashFor;
use sp_runtime::traits::HashingFor;
use sp_state_machine::MemoryDB;
use sp_std::collections::btree_map::BTreeMap;

Expand Down Expand Up @@ -104,7 +104,7 @@ impl RelayStateSproofBuilder {
pub fn into_state_root_and_proof(
self,
) -> (polkadot_primitives::Hash, sp_state_machine::StorageProof) {
let (db, root) = MemoryDB::<HashFor<polkadot_primitives::Block>>::default_with_root();
let (db, root) = MemoryDB::<HashingFor<polkadot_primitives::Block>>::default_with_root();
let state_version = Default::default(); // for test using default.
let mut backend = sp_state_machine::TrieBackendBuilder::new(db, root).build();

Expand Down
4 changes: 2 additions & 2 deletions test/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ path = "src/main.rs"

[dependencies]
async-trait = "0.1.72"
clap = { version = "4.3.17", features = ["derive"] }
clap = { version = "4.3.19", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0.0" }
criterion = { version = "0.5.1", features = [ "async_tokio" ] }
jsonrpsee = { version = "0.16.2", features = ["server"] }
rand = "0.8.5"
serde = { version = "1.0.171", features = ["derive"] }
serde = { version = "1.0.175", features = ["derive"] }
tokio = { version = "1.29.1", features = ["macros"] }
tracing = "0.1.37"
url = "2.4.0"
Expand Down
Loading

0 comments on commit cba34e7

Please sign in to comment.