Skip to content

Commit

Permalink
Separate lib from bin
Browse files Browse the repository at this point in the history
  • Loading branch information
serban300 committed Aug 8, 2024
1 parent 5061e06 commit 650f007
Show file tree
Hide file tree
Showing 31 changed files with 269 additions and 187 deletions.
8 changes: 4 additions & 4 deletions .gitlab/pipeline/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ build-linux-stable-cumulus:
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
script:
- echo "___Building a binary, please refrain from using it in production since it goes with the debug assertions.___"
- time cargo build --release --locked -p polkadot-parachain-bin --bin polkadot-parachain
- time cargo build --release --locked -p polkadot-parachain-bin --bin polkadot-parachain --features binary
- echo "___Packing the artifacts___"
- mkdir -p ./artifacts
- mv ./target/release/polkadot-parachain ./artifacts/.
Expand Down Expand Up @@ -288,7 +288,7 @@ build-short-benchmark-cumulus:
- .run-immediately
- .collect-artifacts
script:
- cargo build --profile release --locked --features=runtime-benchmarks,on-chain-release-build -p polkadot-parachain-bin --bin polkadot-parachain --workspace
- cargo build --profile release --locked --features=binary,runtime-benchmarks,on-chain-release-build -p polkadot-parachain-bin --bin polkadot-parachain --workspace
- mkdir -p artifacts
- target/release/polkadot-parachain --version
- cp ./target/release/polkadot-parachain ./artifacts/
Expand All @@ -313,7 +313,7 @@ build-linux-substrate:
# tldr: we need to checkout the branch HEAD explicitly because of our dynamic versioning approach while building the substrate binary
# see https://github.com/paritytech/ci_cd/issues/682#issuecomment-1340953589
- git checkout -B "$CI_COMMIT_REF_NAME" "$CI_COMMIT_SHA"
- !reference [.forklift-cache, before_script]
- !reference [ .forklift-cache, before_script ]
script:
- time WASM_BUILD_NO_COLOR=1 cargo build --locked --release -p staging-node-cli
- mv $CARGO_TARGET_DIR/release/substrate-node ./artifacts/substrate/substrate
Expand Down Expand Up @@ -353,7 +353,7 @@ build-runtimes-polkavm:
CARGO_TARGET_DIR: "$CI_PROJECT_DIR/target"
before_script:
- mkdir -p ./artifacts/subkey
- !reference [.forklift-cache, before_script]
- !reference [ .forklift-cache, before_script ]
script:
- cd ./substrate/bin/utils/subkey
- time SKIP_WASM_BUILD=1 cargo build --locked --release
Expand Down
1 change: 1 addition & 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 @@ -536,6 +536,7 @@ members = [
]

default-members = [
"cumulus/polkadot-parachain",
"polkadot",
"substrate/bin/node/cli",
]
Expand Down
13 changes: 7 additions & 6 deletions bridges/testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ To start those tests, you need to:
- download latest [zombienet release](https://github.com/paritytech/zombienet/releases);

- build Polkadot binary by running `cargo build -p polkadot --release --features fast-runtime` command in the
[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone;
[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone;

- build Polkadot Parachain binary by running `cargo build -p polkadot-parachain-bin --release` command in the
[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone;
- build Polkadot Parachain binary by running
`cargo build --release -p polkadot-parachain-bin --bin polkadot-parachain --features binary`
command in the [`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone;

- ensure that you have [`node`](https://nodejs.org/en) installed. Additionally, we'll need globally installed
`polkadot/api-cli` package (use `npm install -g @polkadot/api-cli@beta` to install it);
`polkadot/api-cli` package (use `npm install -g @polkadot/api-cli@beta` to install it);

- build Substrate relay by running `cargo build -p substrate-relay --release` command in the
[`parity-bridges-common`](https://github.com/paritytech/parity-bridges-common) repository clone.
[`parity-bridges-common`](https://github.com/paritytech/parity-bridges-common) repository clone.

- copy fresh `substrate-relay` binary, built in previous point, to the `~/local_bridge_testing/bin/substrate-relay`;

- change the `POLKADOT_SDK_PATH` and `ZOMBIENET_BINARY_PATH` (and ensure that the nearby variables
have correct values) in the `./run-tests.sh`.
have correct values) in the `./run-tests.sh`.

After that, you could run tests with the `./run-tests.sh` command. Hopefully, it'll show the
"All tests have completed successfully" message in the end. Otherwise, it'll print paths to zombienet
Expand Down
26 changes: 20 additions & 6 deletions cumulus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,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/contributor/container.md).
If you only want to run a **Polkadot Parachain Node**, check out
our [container section](./docs/contributor/container.md).

## Cumulus SDK

Expand All @@ -22,7 +23,8 @@ Cumulus clouds are shaped sort of like dots; together they form a system that is

### Consensus

[`parachain-consensus`](https://github.com/paritytech/polkadot-sdk/blob/master/cumulus/client/consensus/common/src/parachain_consensus.rs)
[
`parachain-consensus`](https://github.com/paritytech/polkadot-sdk/blob/master/cumulus/client/consensus/common/src/parachain_consensus.rs)
is a [consensus engine](https://docs.substrate.io/v3/advanced/consensus) for Substrate that follows a Polkadot [relay
chain](https://wiki.polkadot.network/docs/en/learn-architecture#relay-chain). This will run a Polkadot node internally,
and dictate to the client and synchronization algorithms which chain to follow,
Expand All @@ -37,20 +39,24 @@ You may run `polkadot-parachain` locally after building it or using one of the c
[here](./docs/contributor/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
three ways:

1. Run a full relay chain node within the parachain node (default)
2. Connect to an external relay chain node via WebSocket RPC
3. Run a light client for the relay chain

#### In-process Relay Chain Node

If an external relay chain node is not specified (default behavior), then a full relay chain node is spawned within the
same process.

This node has all of the typical components of a regular Polkadot node and will have to fully sync with the relay chain
to work.

##### Example command

```bash
polkadot-parachain \
--chain parachain-chainspec.json \
Expand All @@ -60,6 +66,7 @@ polkadot-parachain \
```

#### External Relay Chain Node

An external relay chain node is connected via WebsSocket RPC by using the `--relay-chain-rpc-urls` command line
argument. This option accepts one or more space-separated WebSocket URLs to a full relay chain node. By default, only
the first URL will be used, with the rest as a backup in case the connection to the first node is lost.
Expand All @@ -85,6 +92,7 @@ polkadot-parachain \
```

#### Relay Chain Light Client

An internal relay chain light client provides a fast and lightweight approach for connecting to the relay chain network.
It provides relay chain notifications and facilitates runtime calls.

Expand All @@ -95,8 +103,8 @@ relay chain arguments.
node in-process. Even though they lack the majority of normal Polkadot subsystems, they will still need to connect
directly to the relay chain network.


##### Example command

```bash
polkadot-parachain \
--chain parachain-chainspec.json \
Expand All @@ -107,26 +115,32 @@ polkadot-parachain \
```

## Installation and Setup

Before building Cumulus SDK based nodes / runtimes prepare your environment by following Substrate [installation
instructions](https://docs.substrate.io/main-docs/install/).

To launch a local network, you can use [zombienet](https://github.com/paritytech/zombienet) for quick setup and
experimentation or follow the [manual setup](#manual-setup).

### Zombienet

We use Zombienet to spin up networks for integration tests and local networks. Follow [these installation
steps](https://github.com/paritytech/zombienet#requirements-by-provider) to set it up on your machine. A simple network
specification with two relay chain nodes and one collator is located at
[zombienet/examples/small_network.toml](zombienet/examples/small_network.toml).

#### Which provider should I use?

Zombienet offers multiple providers to run networks. Choose the one that best fits your needs:

- **Podman:** Choose this if you want to spin up a network quick and easy.
- **Native:** Choose this if you want to develop and deploy your changes. Requires compilation of the binaries.
- **Kubernetes:** Choose this for advanced use-cases or running on cloud-infrastructure.

#### How to run

To run the example network, use the following commands:

```bash
# Podman provider
zombienet --provider podman spawn ./zombienet/examples/small_network.toml
Expand All @@ -136,6 +150,7 @@ zombienet --provider native spawn ./zombienet/examples/small_network.toml
```

### Manual Setup

#### Launch the Relay Chain

```bash
Expand All @@ -159,7 +174,7 @@ cargo build --release -p polkadot

```bash
# Compile
cargo build --release -p polkadot-parachain-bin
cargo build --release -p polkadot-parachain-bin --bin polkadot-parachain --features binary

# Export genesis state
./target/release/polkadot-parachain export-genesis-state > genesis-state
Expand All @@ -184,7 +199,6 @@ cargo build --release -p polkadot-parachain-bin

![image](https://user-images.githubusercontent.com/2915325/99548884-1be13580-2987-11eb-9a8b-20be658d34f9.png)


## Asset Hub 🪙

This repository also contains the Asset Hub runtimes. Asset Hub is a system parachain providing an asset store for the
Expand Down Expand Up @@ -216,6 +230,7 @@ See [the `contracts-rococo` readme](parachains/runtimes/contracts/contracts-roco
See [the `bridge-hubs` readme](parachains/runtimes/bridge-hubs/README.md) for details.

## Rococo 👑

[Rococo](https://polkadot.js.org/apps/?rpc=wss://rococo-rpc.polkadot.io) is becoming a [Community Parachain
Testbed](https://polkadot.network/blog/rococo-revamp-becoming-a-community-parachain-testbed/) for parachain teams in the
Polkadot ecosystem. It supports multiple parachains with the differentiation of long-term connections and recurring
Expand All @@ -231,7 +246,6 @@ the relay chain for a parachain.

To run a Rococo collator you will need to compile the following binary:


```bash
cargo build --release --locked --bin polkadot-parachain
```
Expand Down
67 changes: 43 additions & 24 deletions cumulus/parachains/runtimes/bridge-hubs/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
- [Bridge-hub Parachains](#bridge-hub-parachains)
- [Requirements for local run/testing](#requirements-for-local-runtesting)
- [How to test local Rococo <-> Westend bridge](#how-to-test-local-rococo---westend-bridge)
- [Run Rococo/Westend chains with zombienet](#run-rococowestend-chains-with-zombienet)
- [Init bridge and run relayer between BridgeHubRococo and
BridgeHubWestend](#init-bridge-and-run-relayer-between-bridgehubrococo-and-bridgehubwestend)
- [Initialize configuration for transfer asset over bridge
(ROCs/WNDs)](#initialize-configuration-for-transfer-asset-over-bridge-rocswnds)
- [Send messages - transfer asset over bridge (ROCs/WNDs)](#send-messages---transfer-asset-over-bridge-rocswnds)
- [Claim relayer's rewards on BridgeHubRococo and
BridgeHubWestend](#claim-relayers-rewards-on-bridgehubrococo-and-bridgehubwestend)
- [How to test local BridgeHubKusama/BridgeHubPolkadot](#how-to-test-local-bridgehubkusamabridgehubpolkadot)
- [Requirements for local run/testing](#requirements-for-local-runtesting)
- [How to test local Rococo <-> Westend bridge](#how-to-test-local-rococo---westend-bridge)
- [Run Rococo/Westend chains with zombienet](#run-rococowestend-chains-with-zombienet)
- [Init bridge and run relayer between BridgeHubRococo and
BridgeHubWestend](#init-bridge-and-run-relayer-between-bridgehubrococo-and-bridgehubwestend)
- [Initialize configuration for transfer asset over bridge
(ROCs/WNDs)](#initialize-configuration-for-transfer-asset-over-bridge-rocswnds)
- [Send messages - transfer asset over bridge (ROCs/WNDs)](#send-messages---transfer-asset-over-bridge-rocswnds)
- [Claim relayer's rewards on BridgeHubRococo and
BridgeHubWestend](#claim-relayers-rewards-on-bridgehubrococo-and-bridgehubwestend)
- [How to test local BridgeHubKusama/BridgeHubPolkadot](#how-to-test-local-bridgehubkusamabridgehubpolkadot)

# Bridge-hub Parachains

_BridgeHub(s)_ are **_system parachains_** that will house trustless bridges from the local ecosystem to others. The
current trustless bridges planned for the BridgeHub(s) are:

- `BridgeHubPolkadot` system parachain:
1. Polkadot <-> Kusama bridge
2. Polkadot <-> Ethereum bridge (Snowbridge)
1. Polkadot <-> Kusama bridge
2. Polkadot <-> Ethereum bridge (Snowbridge)
- `BridgeHubKusama` system parachain:
1. Kusama <-> Polkadot bridge
2. Kusama <-> Ethereum bridge The high-level
responsibilities of each bridge living on BridgeHub:
1. Kusama <-> Polkadot bridge
2. Kusama <-> Ethereum bridge The high-level
responsibilities of each bridge living on BridgeHub:
- sync finality proofs between relay chains (or equivalent)
- sync finality proofs between BridgeHub parachains
- pass (XCM) messages between different BridgeHub parachains
Expand Down Expand Up @@ -76,7 +77,7 @@ cp target/release/substrate-relay ~/local_bridge_testing/bin/substrate-relay
# 4. Build cumulus polkadot-parachain binary
cd <polkadot-sdk-git-repo-dir>
cargo build --release -p polkadot-parachain-bin
cargo build --release -p polkadot-parachain-bin --bin polkadot-parachain --features binary
cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain
cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain-asset-hub
```
Expand Down Expand Up @@ -106,22 +107,26 @@ POLKADOT_PARACHAIN_BINARY=~/local_bridge_testing/bin/polkadot-parachain \
### Init bridge and run relayer between BridgeHubRococo and BridgeHubWestend

**Accounts of BridgeHub parachains:**

- `Bob` is pallet owner of all bridge pallets

#### Run with script

```
cd <polkadot-sdk-git-repo-dir>
./bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh run-relay
```

**Check relay-chain headers relaying:**

- Rococo parachain: - https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A8943#/chainstate - Pallet:
**bridgeWestendGrandpa** - Keys: **bestFinalized()**
- Westend parachain: - https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A8945#/chainstate - Pallet:
**bridgeRococoGrandpa** - Keys: **bestFinalized()**

**Check parachain headers relaying:**

- Rococo parachain: - https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A8943#/chainstate - Pallet:
**bridgeWestendParachains** - Keys: **parasInfo(None)**
- Westend parachain: - https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A8945#/chainstate - Pallet:
Expand All @@ -130,8 +135,10 @@ cd <polkadot-sdk-git-repo-dir>
### Initialize configuration for transfer asset over bridge (ROCs/WNDs)

This initialization does several things:

- creates `ForeignAssets` for wrappedROCs/wrappedWNDs
- drips SA for AssetHubRococo on AssetHubWestend (and vice versa) which holds reserved assets on source chains

```
cd <polkadot-sdk-git-repo-dir>
Expand All @@ -144,12 +151,14 @@ cd <polkadot-sdk-git-repo-dir>
### Send messages - transfer asset over bridge (ROCs/WNDs)

Do reserve-backed transfers:

```
cd <polkadot-sdk-git-repo-dir>
# ROCs from Rococo's Asset Hub to Westend's.
./bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh reserve-transfer-assets-from-asset-hub-rococo-local
```

```
cd <polkadot-sdk-git-repo-dir>
Expand All @@ -158,19 +167,26 @@ cd <polkadot-sdk-git-repo-dir>
```

- open explorers: (see zombienets)
- AssetHubRococo (see events `xcmpQueue.XcmpMessageSent`, `polkadotXcm.Attempted`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9910#/explorer
- BridgeHubRococo (see `bridgeWestendMessages.MessageAccepted`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8943#/explorer
- BridgeHubWestend (see `bridgeRococoMessages.MessagesReceived`, `xcmpQueue.XcmpMessageSent`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8945#/explorer
- AssetHubWestend (see `foreignAssets.Issued`, `xcmpQueue.Success`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9010#/explorer
- BridgeHubRocococ (see `bridgeWestendMessages.MessagesDelivered`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8943#/explorer
- AssetHubRococo (see events `xcmpQueue.XcmpMessageSent`,
`polkadotXcm.Attempted`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9910#/explorer
- BridgeHubRococo (see
`bridgeWestendMessages.MessageAccepted`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8943#/explorer
- BridgeHubWestend (see `bridgeRococoMessages.MessagesReceived`,
`xcmpQueue.XcmpMessageSent`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8945#/explorer
- AssetHubWestend (see `foreignAssets.Issued`,
`xcmpQueue.Success`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9010#/explorer
- BridgeHubRocococ (see
`bridgeWestendMessages.MessagesDelivered`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8943#/explorer

Do reserve withdraw transfers: (when previous is finished)

```
cd <polkadot-sdk-git-repo-dir>
# wrappedWNDs from Rococo's Asset Hub to Westend's.
./bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh withdraw-reserve-assets-from-asset-hub-rococo-local
```

```
cd <polkadot-sdk-git-repo-dir>
Expand All @@ -181,6 +197,7 @@ cd <polkadot-sdk-git-repo-dir>
### Claim relayer's rewards on BridgeHubRococo and BridgeHubWestend

**Accounts of BridgeHub parachains:**

- `//Charlie` is relayer account on BridgeHubRococo
- `//Charlie` is relayer account on BridgeHubWestend

Expand All @@ -195,8 +212,10 @@ cd <polkadot-sdk-git-repo-dir>
```

- open explorers: (see zombienets)
- BridgeHubRococo (see 2x `bridgeRelayers.RewardPaid`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8943#/explorer
- BridgeHubWestend (see 2x `bridgeRelayers.RewardPaid`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8945#/explorer
- BridgeHubRococo (see 2x
`bridgeRelayers.RewardPaid`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8943#/explorer
- BridgeHubWestend (see 2x
`bridgeRelayers.RewardPaid`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8945#/explorer

## How to test local BridgeHubKusama/BridgeHubPolkadot

Expand Down
Loading

0 comments on commit 650f007

Please sign in to comment.