Skip to content

Commit

Permalink
Merge branch 'main' into region-pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
cuteolaf committed Apr 17, 2024
2 parents 7affd21 + d6313a1 commit 92b13f4
Show file tree
Hide file tree
Showing 21 changed files with 250 additions and 115 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export POLKADOT_IMAGE=paritypr/polkadot-debug:v1.6.0
export REGIONX_IMAGE=szegoo/regionx-node:latest
1 change: 1 addition & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ runs:
rustup component add clippy --toolchain nightly-x86_64-unknown-linux-gnu
rustup component add rustfmt --toolchain nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup component add rust-src
rustup show
shell: bash
6 changes: 5 additions & 1 deletion .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
fmt:
Expand Down Expand Up @@ -50,7 +54,7 @@ jobs:
run: echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" >> $GITHUB_ENV

- name: Cargo clippy
run: cargo +nightly clippy -- -D warnings
run: cargo clippy -- -D warnings

- name: Check Code
run: cargo check
4 changes: 4 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Benchmarks
on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
benchmark:
runs-on: ubuntu-22.04
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test coverage

on:
# Triggers the workflow on push or pull request events but only for the main branch
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
TARPAULIN_VERSION: 0.27.3

jobs:
coverage:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup

- name: Setup SSH
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.GH_TOKEN }}

- name: Use Git CLI for Cargo
run: echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" >> $GITHUB_ENV

- name: Run cargo-tarpaulin
run: |
wget https://github.com/xd009642/tarpaulin/releases/download/${{ env.TARPAULIN_VERSION }}/cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz
tar -zxvf cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz -C $HOME/.cargo/bin
cargo tarpaulin --workspace \
-e regionx-node regionx-runtime \
--exclude-files **/mock.rs **/weights/* \
--out xml
- uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: RegionX-Labs/RegionX-Node
29 changes: 29 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Dependency checks

on:
# Triggers the workflow on push or pull request events but only for the main branch
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup

- name: Install Rust
run: cargo install --git https://github.com/paritytech/psvm psvm
- name: Check Dependency Versions
run: |
chmod +x ./scripts/check-dependency-versions.sh
./scripts/check-dependency-versions.sh
42 changes: 42 additions & 0 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Smoke tests

# Controls when the action will run.
on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
smoke:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- uses: ./.github/actions/setup

- name: Zombienet setup
run: |
wget https://github.com/paritytech/zombienet/releases/download/v1.3.100/zombienet-linux-x64
chmod +x zombienet-linux-x64
yes 2>/dev/null | ./zombienet-linux-x64 setup polkadot || true
echo $GITHUB_WORKSPACE
echo "PATH=$GITHUB_WORKSPACE:$PATH" >> $GITHUB_ENV
echo $PATH
- name: Pull Docker Image
run: docker pull szegoo/regionx-node:latest

- name: Compile regionx-node
run: |
cargo build --release
cp ./target/release/regionx-node .
- name: Run smoke test 0001
run: ./zombienet-linux-x64 -p native test ./zombienet_tests/0001-smoke-test.zndsl
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Tests
on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-22.04
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/try_runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Try-runtime
on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
try-runtime:
runs-on: ubuntu-22.04
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# The cache for docker container dependency
/.cargo/config

bin/

.DS_Store
.idea
.vscode
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ sp-consensus-beefy = { version = "13.0.0", default-features = false }
sp-core = { version = "28.0.0", default-features = false }
sp-inherents = { version = "26.0.0", default-features = false }
sp-offchain = { version = "26.0.0", default-features = false }
sp-runtime = { version = "31.0.1", default-features = false }
sp-runtime = { version = "31.0.0", default-features = false }
sp-session = { version = "27.0.0", default-features = false }
sp-std = { version = "14.0.0", default-features = false }
sp-transaction-pool = { version = "26.0.0", default-features = false }
Expand All @@ -69,9 +69,9 @@ sp-genesis-builder = { version = "0.7.0", default-features = false }
pallet-xcm = { version = "7.0.0", default-features = false }
polkadot-parachain-primitives = { version = "6.0.0", default-features = false }
polkadot-runtime-common = { version = "7.0.0", default-features = false }
xcm = { package = "staging-xcm", version = "7.0.0", default-features = false }
xcm-builder = { package = "staging-xcm-builder", version = "7.0.0", default-features = false }
xcm-executor = { package = "staging-xcm-executor", version = "7.0.0", default-features = false }
xcm = { version = "7.0.0", package = "staging-xcm", default-features = false }
xcm-builder = { version = "7.0.3", package = "staging-xcm-builder", default-features = false }
xcm-executor = { version = "7.0.3", package = "staging-xcm-executor", default-features = false }
cumulus-primitives-aura = { version = "0.7.0", default-features = false }
cumulus-pallet-session-benchmarking = { version = "9.0.0", default-features = false }
cumulus-pallet-aura-ext = { version = "0.7.0", default-features = false }
Expand All @@ -81,14 +81,14 @@ cumulus-pallet-xcm = { version = "0.7.0", default-features = false }
cumulus-pallet-xcmp-queue = { version = "0.7.0", default-features = false }
cumulus-primitives-core = { version = "0.7.0", default-features = false }
cumulus-primitives-timestamp = { version = "0.7.0", default-features = false }
cumulus-primitives-utility = { version = "0.7.0", default-features = false }
cumulus-primitives-utility = { version = "0.7.3", default-features = false }
pallet-collator-selection = { version = "9.0.0", default-features = false }
parachain-info = { package = "staging-parachain-info", version = "0.7.0", default-features = false }
parachains-common = { version = "7.0.0", default-features = false }
parachain-info = { version = "0.7.0", package = "staging-parachain-info", default-features = false }
parachains-common = { version = "7.0.0", default-features = false }
sp-timestamp = { version = "26.0.0", default-features = false }
sp-keystore = { version = "0.34.0", default-features = false }
sp-mmr-primitives = { version = "26.0.0", default-features = false }
sp-storage = { version = "19.0.0", default-features = false }
sp-storage = { version = "19.0.0", default-features = false }
pallet-beefy-mmr = { version = "28.0.0", default-features = false }
pallet-mmr = { version = "27.0.0", default-features = false }

Expand Down
32 changes: 0 additions & 32 deletions Containerfile

This file was deleted.

23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:22.04

# show backtraces
ENV RUST_BACKTRACE 1

RUN useradd -m -u 1000 -U -s /bin/sh -d /regionx regionx && \
mkdir /data && \
chown -R regionx:regionx /data

ARG PROFILE=release

# copy the compiled binary to the container
COPY ./regionx-node /usr/bin/regionx-node

USER regionx

# check if executable works in this container
RUN /usr/bin/regionx-node --version

# ws_port
EXPOSE 9333 9944 30333 30334

CMD ["/usr/bin/regionx-node"]
21 changes: 10 additions & 11 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub type ChainSpec<T> = sc_service::GenericChainSpec<T, Extensions>;

/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
Expand Down Expand Up @@ -72,11 +72,11 @@ where
/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
pub fn template_session_keys(keys: AuraId) -> regionx_runtime::SessionKeys {
pub fn session_keys(keys: AuraId) -> regionx_runtime::SessionKeys {
regionx_runtime::SessionKeys { aura: keys }
}

pub fn development_config() -> ChainSpec {
pub fn development_config(id: u32) -> ChainSpec<regionx_runtime::RuntimeGenesisConfig> {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "REGX".into());
Expand Down Expand Up @@ -122,26 +122,25 @@ pub fn development_config() -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
2000.into(),
id.into(),
))
.build()
}

pub fn local_testnet_config() -> ChainSpec {
pub fn local_testnet_config(id: u32) -> ChainSpec<regionx_runtime::RuntimeGenesisConfig> {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "REGX".into());
properties.insert("tokenDecimals".into(), 12.into());
// TODO: chose an ss58Format
properties.insert("ss58Format".into(), 42.into());

#[allow(deprecated)]
ChainSpec::builder(
regionx_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "rococo-local".into(),
// You MUST set this to the correct network!
para_id: 2000,
para_id: id,
},
)
.with_name("RegionX Local")
Expand Down Expand Up @@ -174,7 +173,7 @@ pub fn local_testnet_config() -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
2000.into(),
id.into(),
))
.with_protocol_id("regionx-local")
.with_properties(properties)
Expand Down Expand Up @@ -203,9 +202,9 @@ fn testnet_genesis(
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
template_session_keys(aura), // session keys
acc.clone(), // account id
acc, // validator id
session_keys(aura), // session keys
)
})
.collect::<Vec<_>>(),
Expand Down
12 changes: 8 additions & 4 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ use crate::{

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(chain_spec::development_config()),
"regionx-rococo" => Box::new(chain_spec::local_testnet_config()),
"" | "local" => Box::new(chain_spec::local_testnet_config()),
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
"dev" => Box::new(chain_spec::development_config(2000)),
"regionx-rococo" => Box::new(chain_spec::local_testnet_config(2000)),
"" | "local" => Box::new(chain_spec::local_testnet_config(2000)),
path => Box::new(
chain_spec::ChainSpec::<regionx_runtime::RuntimeGenesisConfig>::from_json_file(
std::path::PathBuf::from(path),
)?,
),
})
}

Expand Down
Loading

0 comments on commit 92b13f4

Please sign in to comment.