Skip to content

Commit

Permalink
Merge pull request #2 from logion-network/feature/prepare-rochefort
Browse files Browse the repository at this point in the history
Handle review feedback and change root for logion net
  • Loading branch information
gdethier authored Sep 29, 2023
2 parents bf02287 + 41fe6cb commit a0d84bd
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/target/
.cargo
bin/
debian-bin/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@

# Logion
/bin
/debian-bin
4 changes: 4 additions & 0 deletions Dockerfile.build-debian11
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM logionnetwork/debian-rust:latest
WORKDIR /logion-collator
COPY . .
ENTRYPOINT . ~/.cargo/env && cargo build --release && mv target/release/logion /target/logion
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ and did not clean-up the data, you can just start the nodes (steps 3, 4 and 10).
6. (optional if you did not change the runtime) Generate plain chainspec:

```
./target/release/logion build-spec --disable-default-bootnode > ./res/rococo-local-logion-plain.json
./target/release/logion build-spec --chain local --disable-default-bootnode > ./res/local.json
```

7. (optional if you did not change the runtime) Generate raw chainspec

```
./target/release/logion build-spec --chain ./res/rococo-local-logion-plain.json --raw --disable-default-bootnode > ./res/rococo-local-logion-raw.json
./target/release/logion build-spec --chain ./res/local.json --raw --disable-default-bootnode > ./res/local.raw.json
```

8. Generate WASM and genesis state

```
./target/release/logion export-genesis-wasm --chain ./res/rococo-local-logion-raw.json > ./bin/local-logion-wasm
./target/release/logion export-genesis-wasm --chain ./res/local.raw.json > ./bin/local-wasm
```

```
./target/release/logion export-genesis-state --chain ./res/rococo-local-logion-raw.json > ./bin/local-logion-genesis
./target/release/logion export-genesis-state --chain ./res/local.raw.json > ./bin/local-genesis
```

9. Register parachain
Expand All @@ -78,8 +78,8 @@ and did not clean-up the data, you can just start the nodes (steps 3, 4 and 10).
- Go to Developer > Sudo
- Select extrinsic `paraSudoWrapper.sudoScheduleParaInitialize` and set the following parameters:
- id: 2000
- genesisHead: set file `./bin/local-logion-genesis` generated above
- validationCode: set file `./bin/local-logion-wasm` generated above
- genesisHead: set file `./bin/local-genesis` generated above
- validationCode: set file `./bin/local-wasm` generated above
- parachain: Yes
- Submit the extrinsic

Expand All @@ -100,26 +100,28 @@ you can run the following command:
rm -rf /tmp/relay /tmp/parachain/
```

## Mainnet JSON chainspec generation
## JSON chainspec generation

Below, `$CHAIN` equals `logion` or `local`. It is recommanded to define the variable before running the commands (`export CHAIN=...`).

1. Generate plain chainspec:

```
./target/release/logion build-spec --chain main --disable-default-bootnode > ./res/main-plain.json
./target/release/logion build-spec --chain $CHAIN --disable-default-bootnode > ./res/$CHAIN.json
```

2. Generate raw chainspec

```
./target/release/logion build-spec --chain ./res/main-plain.json --raw --disable-default-bootnode > ./res/main-raw.json
./target/release/logion build-spec --chain ./res/$CHAIN.json --raw --disable-default-bootnode > ./res/$CHAIN.raw.json
```

3. Generate WASM and genesis state

```
./target/release/logion export-genesis-wasm --chain ./res/main-raw.json > ./bin/main-wasm
./target/release/logion export-genesis-wasm --chain ./res/$CHAIN.raw.json > ./bin/$CHAIN-wasm
```

```
./target/release/logion export-genesis-state --chain ./res/main-raw.json > ./bin/main-genesis
./target/release/logion export-genesis-state --chain ./res/$CHAIN.raw.json > ./bin/$CHAIN-genesis
```
9 changes: 9 additions & 0 deletions docker/rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM debian:11

RUN apt-get update && apt-get install curl build-essential libclang-dev protobuf-compiler -y
RUN curl https://sh.rustup.rs -sSf > ~/install_rust.sh
RUN bash ~/install_rust.sh -y
RUN . ~/.cargo/env && rustup default stable
RUN . ~/.cargo/env && rustup update
RUN . ~/.cargo/env && rustup update nightly
RUN . ~/.cargo/env && rustup target add wasm32-unknown-unknown --toolchain nightly
9 changes: 5 additions & 4 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cumulus_primitives_core::ParaId;
use logion_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT, Balance, LGNT};
use logion_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT, Balance, LGNT, SS58Prefix};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -62,8 +62,8 @@ pub fn template_session_keys(keys: AuraId) -> logion_runtime::SessionKeys {
logion_runtime::SessionKeys { aura: keys }
}

pub fn main_config() -> ChainSpec {
const ROOT_PUBLIC_SR25519: &str = "5FUg3QWfipPf8yKv5hMK6wQf8nn6og9BbRNcr3Y8CwUJwTh9";
pub fn logion_config() -> ChainSpec {
const ROOT_PUBLIC_SR25519: &str = "5GzrECvUzFng58zzFvqVJvpE2MRnjU9vgh4iJMhqrLBSRRAv";

const NODE01_PUBLIC_SR25519: &str = "5DjzFDhFidvGCuuy6i8Lsi4XyruYjxTTkJKb1o7XzVdMNPVb";
const NODE02_PUBLIC_SR25519: &str = "5DoD9n61SssFiWQDTD7bz1eX3KCxZJ6trVj2GsDwMi2PqP85";
Expand Down Expand Up @@ -168,7 +168,7 @@ fn main_para_id() -> u32 {

const DEFAULT_TEST_BALANCE: Balance = 1 << 60;

pub fn local_testnet_config() -> ChainSpec {
pub fn local_config() -> ChainSpec {
ChainSpec::from_genesis(
// Name
"Local Logion",
Expand Down Expand Up @@ -314,6 +314,7 @@ fn default_properties(symbol: &str) -> sc_service::Properties {
let mut props : sc_service::Properties = sc_service::Properties::new();
props.insert("tokenSymbol".into(), symbol.into());
props.insert("tokenDecimals".into(), 18.into());
props.insert("ss58Format".into(), SS58Prefix::get().into());
return props;
}

Expand Down
4 changes: 2 additions & 2 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use crate::{

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Ok(match id {
"main" => Box::new(chain_spec::main_config()),
"" | "local" => Box::new(chain_spec::local_testnet_config()),
"logion" => Box::new(chain_spec::logion_config()),
"" | "local" => Box::new(chain_spec::local_config()),
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
}
Expand Down
1 change: 1 addition & 0 deletions res/rococo-local-logion.json → res/local.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"telemetryEndpoints": null,
"protocolId": "logion",
"properties": {
"ss58Format": 2021,
"tokenDecimals": 18,
"tokenSymbol": "LGNT"
},
Expand Down
1 change: 1 addition & 0 deletions res/rococo-local-logion.raw.json → res/local.raw.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"telemetryEndpoints": null,
"protocolId": "logion",
"properties": {
"ss58Format": 2021,
"tokenDecimals": 18,
"tokenSymbol": "LGNT"
},
Expand Down
5 changes: 3 additions & 2 deletions res/logion.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"telemetryEndpoints": null,
"protocolId": "logion",
"properties": {
"ss58Format": 2021,
"tokenDecimals": 18,
"tokenSymbol": "LGNT"
},
Expand All @@ -24,7 +25,7 @@
"balances": {
"balances": [
[
"5FUg3QWfipPf8yKv5hMK6wQf8nn6og9BbRNcr3Y8CwUJwTh9",
"5GzrECvUzFng58zzFvqVJvpE2MRnjU9vgh4iJMhqrLBSRRAv",
1000000000000000000000000000
]
]
Expand All @@ -33,7 +34,7 @@
"multiplier": "1000000000000000000"
},
"sudo": {
"key": "5FUg3QWfipPf8yKv5hMK6wQf8nn6og9BbRNcr3Y8CwUJwTh9"
"key": "5GzrECvUzFng58zzFvqVJvpE2MRnjU9vgh4iJMhqrLBSRRAv"
},
"collatorSelection": {
"invulnerables": [
Expand Down
5 changes: 3 additions & 2 deletions res/logion.raw.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions scripts/build_debian_collator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

BUILDER_IMAGE=logionnetwork/logion-collator-debian-builder:latest

docker build . -f ./Dockerfile.build-debian11 -t $BUILDER_IMAGE
docker run --rm -it -v $(pwd)/debian-bin:/target/logion $BUILDER_IMAGE
6 changes: 6 additions & 0 deletions scripts/build_debian_rust.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Builds the debian-based rust environment for building
# a logion collator binary that will run on a debian system.

docker build docker/rust/ -t logionnetwork/debian-rust:latest
4 changes: 2 additions & 2 deletions scripts/run_collator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ set -e
--alice \
--collator \
--force-authoring \
--chain ./res/rococo-local-logion-raw.json \
--chain ./res/local.raw.json \
--base-path /tmp/parachain/alice \
--port 40333 \
--rpc-port 8844 \
-- \
--chain ./res/raw-local-chainspec.json \
--chain ./res/local-chainspec.raw.json \
--port 30343 \
--rpc-port 9977 \
--bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWBmAwcd4PJNJvfV89HwE48nwkRmAgo8Vy3uQEyNNHBox2
2 changes: 1 addition & 1 deletion scripts/run_validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fi
../polkadot/target/release/polkadot \
--$1 \
--base-path /tmp/relay/$1 \
--chain ./res/raw-local-chainspec.json \
--chain ./res/local-chainspec.raw.json \
--port $P2P_PORT \
--rpc-port $RPC_PORT \
$OTHER_OPTIONS

0 comments on commit a0d84bd

Please sign in to comment.