Skip to content

Commit

Permalink
build fast-runtime helper script
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkucharczyk committed Sep 13, 2023
1 parent a98cd78 commit f84cd5d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions polkadot/scripts/build-fast-rococo-and-update-chain-spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash -eux

CURRENT_DIR=$(pwd)

#directory were polkadot-sdk is checked out
POLKADOT_SDK_DIR=/home/miszka/parity/10-genesis-config/polkadot-sdk-rococo

# required epoch duration:
EPOCH_DURATION_IN_BLOCK=6

# polkadot command:
DOCKER_IMAGE=paritypr/polkadot-debug:1539-2085d3f0
POLKADOT_CMD="docker run --rm -v $CURRENT_DIR:/dir -w /dir $DOCKER_IMAGE"
# POLKADOT_CMD=$POLKADOT_SDK_DIR/target/release/polkadot

# path to built rococo runtime:
WASM_RUNTIME_BLOB_PATH=$POLKADOT_SDK_DIR/target/release/wbuild/rococo-runtime/rococo_runtime.compact.compressed.wasm

# build rococo runtime with adjusted epoch diration
pushd $POLKADOT_SDK_DIR
ROCOCO_EPOCH_DURATION=$EPOCH_DURATION_IN_BLOCK cargo build --features fast-runtime --release -p rococo-runtime
popd

# do hexdump of runtime:
hexdump -v -e '/1 "%02x"' $WASM_RUNTIME_BLOB_PATH > ./runtime.hex

# get westend spec:
$POLKADOT_CMD build-spec --chain westend-staging > $CURRENT_DIR/wococo-source.json

# replace runtime in chainspec with newly built runtime with overwritten epoch duration:
jq --rawfile code runtime.hex '.genesis.runtime.system.code = "0x" + $code' > $CURRENT_DIR/chainspec-nonraw.json < $CURRENT_DIR/wococo-source.json

# jq will write numbers in compact way with 1e+18, substrtate json parser dont support it.
sed 's/1e+18/1000000000000000000/' -i $CURRENT_DIR/chainspec-nonraw.json

# generate raw
$POLKADOT_CMD build-spec --chain ./chainspec-nonraw.json --raw > $CURRENT_DIR/chainspec-raw.json


0 comments on commit f84cd5d

Please sign in to comment.