Skip to content

Commit dac1458

Browse files
authored
Minor release and local relay running fixes (#2359)
# Goal The goal of this PR is to fix the issues with running Paseo-Local, and confirm that there are no issues with fatxpool Part of #2333 # Discussion - Updated the fee test to be a bit looser with the new benchmark runners - Adding missing `with_id` to the `frequnecy-paseo-local` spec generator - Bumped the Paseo-Local spec to the new v1.4.2 - Removed/Fixed the old generate_spec.sh script - Added notes about `setSchedulingLookahead` for the Paseo Local chain - Added a third tech council member for local to break ties # Checklist - [x] Updated Readme? - [x] Spec version incremented?
1 parent 758d951 commit dac1458

File tree

12 files changed

+118
-64
lines changed

12 files changed

+118
-64
lines changed

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ register:
9090
onboard:
9191
./scripts/init.sh onboard-frequency-paseo-local
9292

93+
.PHONY: onboard-res-local
94+
onboard-debug:
95+
./scripts/init.sh onboard-res-local
96+
9397
.PHONY: onboard-docker
9498
onboard-docker:
9599
env DOCKER_ONBOARD=true PARA_DOCKER_IMAGE=frequencychain/collator-node-local:latest ./scripts/init.sh onboard-frequency-paseo-local
@@ -98,12 +102,13 @@ onboard-docker:
98102
offboard:
99103
./scripts/init.sh offboard-frequency-paseo-local
100104

101-
.PHONY: specs-testnet-2000 specs-paseo-local
102-
specs-testnet-2000:
103-
./scripts/generate_specs.sh 2000 paseo-2000 release
105+
.PHONY: specs-frequency-paseo-local-debug specs-frequency-paseo-local-release
106+
107+
specs-frequency-paseo-local-debug:
108+
./scripts/generate_specs.sh 2000 frequency-paseo-local debug
104109

105-
specs-paseo-local:
106-
./scripts/generate_relay_specs.sh
110+
specs-frequency-paseo-local-release:
111+
./scripts/generate_specs.sh 2000 frequency-paseo-local release
107112

108113
.PHONY: format
109114
format:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ This option runs two collator nodes as local host processes and two relay chain
224224
make start-paseo-relay
225225
```
226226

227+
ALERT: You likely need to manually set the scheduling lookahead. `sudo(configuration.setSchedulingLookahead(3))` and wait for it to apply.
228+
227229
1. Register a new parachain slot (parachain id) for Frequency. _Note, if parachain was
228230
previously registered on a running relay chain and no new registration is required,
229231
then you can skip the above step._

node/service/src/chain_spec/frequency_paseo_local.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ pub type ChainSpec = sc_service::GenericChainSpec<Extensions>;
1212
// Generic chain spec, in case when we don't have the native runtime.
1313
pub type RelayChainSpec = sc_service::GenericChainSpec<RelayChainExtensions>;
1414

15-
// TODO: Remove once on a Polkadot-SDK with Paseo-Local
16-
#[allow(clippy::unwrap_used)]
1715
/// Generates the Paseo-Local Relay chain spec from the json
1816
pub fn load_paseo_local_spec() -> RelayChainSpec {
1917
RelayChainSpec::from_json_bytes(&include_bytes!("../../../../resources/paseo-local.json")[..])
@@ -34,6 +32,7 @@ pub fn local_paseo_testnet_config() -> ChainSpec {
3432
},
3533
)
3634
.with_name("Frequency Local Testnet")
35+
.with_id("frequency-local")
3736
.with_protocol_id("frequency-paseo-local")
3837
.with_properties(properties)
3938
.with_chain_type(ChainType::Local)

resources/paseo-local.json

Lines changed: 1 addition & 2 deletions
Large diffs are not rendered by default.

runtime/common/src/fee.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ mod test {
7777

7878
assert_eq!(p, 100_000);
7979

80-
assert!(q >= 50_000_000);
81-
assert!(q <= 110_000_000);
80+
assert!(q >= 75_000_000);
81+
assert!(q <= 130_000_000);
8282

8383
assert_eq!(p / q, Balance::from(0u128));
8484
}

runtime/frequency/src/genesis/helpers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,6 @@ pub fn default_technical_committee_members() -> Vec<AccountId> {
156156
vec![
157157
get_account_id_from_seed::<sr25519::Public>("Bob"),
158158
get_account_id_from_seed::<sr25519::Public>("Dave"),
159+
get_account_id_from_seed::<sr25519::Public>("Eve"),
159160
]
160161
}

runtime/frequency/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
435435
spec_name: Cow::Borrowed("frequency"),
436436
impl_name: Cow::Borrowed("frequency"),
437437
authoring_version: 1,
438-
spec_version: 152,
438+
spec_version: 153,
439439
impl_version: 0,
440440
apis: RUNTIME_API_VERSIONS,
441441
transaction_version: 1,
@@ -449,7 +449,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
449449
spec_name: Cow::Borrowed("frequency-testnet"),
450450
impl_name: Cow::Borrowed("frequency"),
451451
authoring_version: 1,
452-
spec_version: 152,
452+
spec_version: 153,
453453
impl_version: 0,
454454
apis: RUNTIME_API_VERSIONS,
455455
transaction_version: 1,

scripts/generate_relay_specs.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

scripts/generate_specs.sh

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
parachain_id=$1
6-
build_step=$2
6+
chain=$2
77
profile=$3
88
if [[ $parachain_id == "" ]]; then
99
echo "Chain Name or Parachain ID argument not provided"
@@ -15,23 +15,32 @@ if [ ! -x "$BUILT_TARGET" ]; then
1515
echo "FATAL: $BUILT_TARGET does not exist, or not executable, rebuild binary to continue"
1616
exit 1
1717
fi
18-
case $build_step in
19-
paseo-2000)
20-
mkdir -p ./res/genesis/local
21-
echo "Building Spec for frequency testnet paseo localnet paraid=2000"
22-
$PWD/target/$profile/frequency build-spec --disable-default-bootnode --chain=frequency-paseo-local > ./res/genesis/local/frequency-spec-paseo.json
23-
sed -i.bu "s/\"parachainId\": 2000/\"parachainId\": $parachain_id/g" ./res/genesis/local/frequency-spec-paseo.json
24-
sed -i.bu "s/\"para_id\": 2000/\"para_id\": $parachain_id/g" ./res/genesis/local/frequency-spec-paseo.json
25-
$PWD/target/$profile/frequency build-spec --raw --disable-default-bootnode --chain ./res/genesis/local/frequency-spec-paseo.json > ./res/genesis/local/paseo-local-frequency-2000-raw.json
26-
rm ./res/genesis/local/frequency-spec-paseo.json.bu
27-
28-
echo "Exporting state and wasm for frequency testnet paseo localnet paraid=2000"
29-
$PWD/target/$profile/frequency export-genesis-state --chain ./res/genesis/local/paseo-local-frequency-2000-raw.json > ./res/genesis/local/frequency-paseo-genesis-state
30-
$PWD/target/$profile/frequency export-genesis-wasm --chain ./res/genesis/local/paseo-local-frequency-2000-raw.json > ./res/genesis/local/frequency-paseo-genesis-wasm
31-
;;
32-
*)
33-
echo "Unknown build step: $build_step"
34-
exit 1
35-
;;
3618

37-
esac
19+
spec_file="./res/genesis/local/${chain}-${parachain_id}.json"
20+
uncompressed_wasm="./res/genesis/local/${chain}-${parachain_id}.wasm"
21+
compressed_wasm="./res/genesis/local/${chain}-${parachain_id}.compressed.wasm"
22+
genesis_state="./res/genesis/local/${chain}-${parachain_id}-genesis-state"
23+
hex_wasm_file="./res/genesis/local/${chain}-${parachain_id}-wasm-hex"
24+
25+
mkdir -p ./res/genesis/local
26+
echo "Building Spec for ${chain} paraid=${parachain_id}"
27+
./target/$profile/frequency build-spec --disable-default-bootnode --chain="${chain}" > "${spec_file}"
28+
29+
cp ./target/$profile/wbuild/frequency-runtime/frequency_runtime.wasm "${uncompressed_wasm}"
30+
31+
subwasm compress "${uncompressed_wasm}" "${compressed_wasm}"
32+
33+
# Update the spec with the compressed WASM
34+
hex_compressed_wasm=`xxd -ps -c 0 "${compressed_wasm}"`
35+
echo -n "0x${hex_compressed_wasm}" > "${hex_wasm_file}"
36+
37+
jq --rawfile code "${hex_wasm_file}" '.genesis.runtimeGenesis.code = $code' "${spec_file}" > "${spec_file}.tmp" && mv "${spec_file}.tmp" "${spec_file}"
38+
39+
echo "Exporting state and wasm for ${chain} paraid=${parachain_id}"
40+
./target/$profile/frequency export-genesis-state --chain="${spec_file}" > "${genesis_state}"
41+
42+
echo "Spec File: ${spec_file}"
43+
echo "Uncompressed wasm: ${uncompressed_wasm}"
44+
echo "Compressed wasm: ${compressed_wasm}"
45+
echo "Genesis State: ${genesis_state}"
46+
echo "Compressed wasm Hex: ${hex_wasm_file}"

scripts/init.sh

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ start-paseo-relay-chain)
3030
echo "Starting local relay chain with Alice and Bob..."
3131
cd docker
3232
docker compose up -d relay_paseo_alice relay_paseo_bob
33+
echo "ALERT: You likely need to manually set the scheduling lookahead. sudo(configuration.setSchedulingLookahead(3)) and wait for it to apply."
3334
;;
3435

3536
stop-paseo-relay-chain)
@@ -64,15 +65,18 @@ start-paseo-collator-alice)
6465

6566
"${Frequency_BINARY_PATH:-./target/release/frequency}" key generate-node-key --base-path=$parachain_dir_alice/data
6667

67-
./scripts/run_collator.sh \
68+
NODE_PARACHAIN_RPC_PORT=9943 ./scripts/run_collator.sh \
6869
--chain="frequency-paseo-local" --alice \
6970
--base-path=$parachain_dir_alice/data \
7071
--force-authoring \
72+
--discover-local \
7173
--port $((30333)) \
7274
--rpc-port $((9944)) \
7375
--rpc-external \
7476
--rpc-cors all \
7577
--rpc-methods=Unsafe \
78+
--no-prometheus \
79+
--no-hardware-benchmarks \
7680
$offchain_params \
7781
;;
7882

@@ -90,15 +94,18 @@ start-paseo-collator-bob)
9094

9195
"${Frequency_BINARY_PATH:-./target/release/frequency}" key generate-node-key --base-path=$parachain_dir_bob/data
9296

93-
./scripts/run_collator.sh \
97+
NODE_PARACHAIN_RPC_PORT=9944 ./scripts/run_collator.sh \
9498
--chain="frequency-paseo-local" --bob \
9599
--base-path=$parachain_dir_bob/data \
100+
--discover-local \
96101
--force-authoring \
97102
--port $((30332)) \
98103
--rpc-port $((9943)) \
99104
--rpc-external \
100105
--rpc-cors all \
101106
--rpc-methods=Unsafe \
107+
--no-prometheus \
108+
--no-hardware-benchmarks \
102109
$offchain_params \
103110
;;
104111

@@ -212,6 +219,7 @@ start-frequency-container)
212219

213220
./scripts/run_collator.sh \
214221
--chain="frequency-paseo-local" \
222+
--state-pruning archive \
215223
--alice \
216224
--unsafe-force-node-key-generation \
217225
--base-path=$parachain_dir/data \
@@ -234,22 +242,40 @@ register-frequency-paseo-local)
234242
onboard-frequency-paseo-local)
235243
echo "Onboarding parachain with runtime '$parachain' and id '$para_id'..."
236244

237-
onboard_dir="$base_dir/onboard"
238-
mkdir -p $onboard_dir
239-
wasm_location="$onboard_dir/${parachain}-${para_id}.wasm"
245+
onboard_dir="$base_dir/onboard"
246+
mkdir -p $onboard_dir
247+
wasm_location="$onboard_dir/${parachain}-${para_id}.wasm"
248+
249+
# THE `-r` is important for it to be binary instead of hex
250+
# Make sure the docker does NOT use -t as it breaks the binary output
251+
if [ "$docker_onboard" == "true" ]; then
252+
genesis=$(docker run --rm -e RUST_LOG=off -i ${frequency_docker_image} /frequency/target/release/frequency export-genesis-state --chain="frequency-paseo-local")
253+
docker run --rm -e RUST_LOG=off -i ${frequency_docker_image} /frequency/target/release/frequency export-genesis-wasm --raw --chain="frequency-paseo-local" > $wasm_location
254+
else
255+
genesis=$(RUST_LOG=off ./target/release/frequency export-genesis-state --chain=frequency-paseo-local)
256+
RUST_LOG=off ./target/release/frequency export-genesis-wasm --raw --chain=frequency-paseo-local > $wasm_location
257+
fi
258+
259+
cd scripts/js/onboard
260+
echo "WASM File md5: $(md5 "${wasm_location}")"
261+
wasm_hex=$(echo -n "0x"`xxd -ps -c 0 "${wasm_location}"`)
262+
echo "WASM Hex md5: $(echo -n "${wasm_hex}" | md5)"
263+
npm i && echo -n "${wasm_hex}" | npm run onboard "ws://0.0.0.0:9946" "//Alice" ${para_id} "${genesis}"
264+
;;
265+
266+
# Useful in combination with make specs-frequency-paseo-local-*
267+
onboard-res-local)
268+
echo "Onboarding parachain with runtime '$parachain' and id '$para_id'..."
269+
echo "Assuming that the files in res/genesis/local are correct..."
240270

241-
# THE `-r` is important for it to be binary instead of hex
242-
# Make sure the docker does NOT use -t as it breaks the binary output
243-
if [ "$docker_onboard" == "true" ]; then
244-
genesis=$(docker run --rm -e RUST_LOG=off -i ${frequency_docker_image} /frequency/target/release/frequency export-genesis-state --chain="frequency-paseo-local")
245-
docker run --rm -e RUST_LOG=off -i ${frequency_docker_image} /frequency/target/release/frequency export-genesis-wasm --chain="frequency-paseo-local" -r > $wasm_location
246-
else
247-
genesis=$(RUST_LOG=off ./target/release/frequency export-genesis-state --chain="frequency-paseo-local")
248-
RUST_LOG=off ./target/release/frequency export-genesis-wasm --chain="frequency-paseo-local" -r > $wasm_location
249-
fi
271+
wasm_location="../../../res/genesis/local/frequency-paseo-local-2000.compressed.wasm"
272+
genesis=$(cat res/genesis/local/frequency-paseo-local-2000-genesis-state)
250273

251274
cd scripts/js/onboard
252-
npm i && npm run onboard "ws://0.0.0.0:9946" "//Alice" ${para_id} "${genesis}" "${wasm_location}"
275+
echo "WASM File md5: $(md5 "${wasm_location}")"
276+
wasm_hex=$(echo -n "0x"`xxd -ps -c 0 "${wasm_location}"`)
277+
echo "WASM Hex md5: $(echo -n "${wasm_hex}" | md5)"
278+
npm i && echo -n "${wasm_hex}" | npm run onboard "ws://0.0.0.0:9946" "//Alice" ${para_id} "${genesis}"
253279
;;
254280

255281
offboard-frequency-paseo-local)

scripts/js/onboard/onboard.mjs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ApiPromise, WsProvider, Keyring } from "@polkadot/api";
2-
import { readFileSync } from "fs";
2+
import fs from 'node:fs';
33

44
const run = async () => {
55
try {
@@ -9,7 +9,10 @@ const run = async () => {
99
const seed = process.argv[3];
1010
const id = process.argv[4];
1111
const header = process.argv[5];
12-
const wasmFile = process.argv[6];
12+
13+
// Read wasmHex from stdin synchronously
14+
// 0 is the file descriptor for stdin
15+
const wasmHex = fs.readFileSync(0, 'utf-8').trim();
1316

1417
const wsProvider = new WsProvider(endpoint);
1518

@@ -20,17 +23,9 @@ const run = async () => {
2023
const keyring = new Keyring({ type: "sr25519" });
2124
const alice = keyring.addFromUri(seed);
2225

23-
let wasm;
24-
try {
25-
wasm = readFileSync(wasmFile).toString("hex");
26-
} catch (err) {
27-
console.error(err);
28-
throw err;
29-
}
30-
3126
let paraGenesisArgs = {
3227
genesis_head: header,
33-
validation_code: "0x" + wasm,
28+
validation_code: wasmHex,
3429
parachain: true,
3530
};
3631

scripts/run_collator.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ alice_rpc_port="${ALICE_RPC_PORT:-9946}"
2121
bob_rpc_port="${BOB_RPC_PORT:-9947}"
2222
chain="${RELAY_CHAIN_SPEC:-./resources/paseo-local.json}"
2323

24+
node_parachain="${NODE_PARACHAIN:-127.0.0.1}"
25+
node_parachain_rpc_port="${NODE_PARACHAIN_RPC_PORT:-9944}"
26+
2427
get_bootnode () {
2528
node="$1"
2629
port="$2"
@@ -34,6 +37,18 @@ get_bootnode () {
3437

3538
}
3639

40+
bootnode_para () {
41+
node="$1"
42+
rpc_port="$2"
43+
bootnode=$(get_bootnode "$node" "$rpc_port")
44+
>&2 echo "Parachain Bootnode: $bootnode"
45+
if [ ! -z "$bootnode" ]; then
46+
echo "$bootnode"
47+
else
48+
echo >&2 "failed to get id for $node"
49+
fi
50+
}
51+
3752
bootnode () {
3853
node="$1"
3954
rpc_port="$2"
@@ -50,6 +65,14 @@ bootnode () {
5065
echo "$bootnode"
5166
}
5267

68+
# Only add it if it's not empty
69+
parachain_bootnode="$(bootnode_para "$node_parachain" "$node_parachain_rpc_port")"
70+
if [ ! -z "$parachain_bootnode" ]; then
71+
args+=( "--bootnodes=$parachain_bootnode" )
72+
else
73+
echo "No parachain bootnode found. May not be needed..."
74+
fi
75+
5376
args+=( "--" "--chain=${chain}" "--bootnodes=$(bootnode "$alice" "$alice_rpc_port")" "--bootnodes=$(bootnode "$bob" "$bob_rpc_port")" )
5477

5578
set -x

0 commit comments

Comments
 (0)