From c16aff3f5f92a71d5618860c4b1f34d40a4c6037 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Wed, 24 May 2023 18:22:31 +0200 Subject: [PATCH 1/7] added script --- scripts/create_glutton_spec.sh | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 scripts/create_glutton_spec.sh diff --git a/scripts/create_glutton_spec.sh b/scripts/create_glutton_spec.sh new file mode 100755 index 00000000000..a64bac2bd93 --- /dev/null +++ b/scripts/create_glutton_spec.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR +usage() { + echo Usage: + echo "$0 " + exit 1 +} + +set -e + +binary_path=$1 +relay_chain=$2 +id="glutton_$2_$3" +protocol_id="glutton_$2_$3" +para_id=$3 +sudo=$4 + +[ -z "$binary_path" ] && usage +[ -z "$relay_chain" ] && usage +[ -z "$id" ] && usage +[ -z "$protocol_id" ] && usage +[ -z "$para_id" ] && usage +[ -z "$sudo" ] && usage + +# binary="./target/release/polkadot-parachain" + +# build the chain spec we'll manipulate +$binary_path build-spec --disable-default-bootnode --chain "glutton-kusama-genesis-$para_id" > "plain-glutton-$para_id-$relay_chain-spec.json" + +# convert runtime to hex +# cat $runtime_path | od -A n -v -t x1 | tr -d ' \n' > seedling-hex.txt + +# replace the runtime in the spec with the given runtime and set some values to production +cat "plain-glutton-$para_id-$relay_chain-spec.json" \ + | jq --arg id $id '.id = $id' \ + | jq --arg id $id '.protocolId = $id' \ + | jq --arg relay_chain $relay_chain '.relay_chain = $relay_chain' \ + | jq --argjson para_id $para_id '.para_id = $para_id' \ + | jq --arg sudo $sudo '.genesis.runtime.sudo.key = $sudo' \ + | jq --argjson para_id $para_id '.genesis.runtime.parachainInfo.parachainId = $para_id' \ + > glutton-$para_id-$relay_chain-spec.json + +# build a raw spec +$binary_path build-spec --disable-default-bootnode --chain "glutton-$para_id-$relay_chain-spec.json" --raw > "glutton-$para_id-$relay_chain-raw-spec.json" + +# build genesis data +$binary_path export-genesis-state --chain "glutton-$para_id-$relay_chain-raw-spec.json" > "glutton-$para_id-$relay_chain-head-data" + +# build genesis wasm +$binary_path export-genesis-wasm --chain "glutton-$para_id-$relay_chain-raw-spec.json" > "glutton-$para_id-$relay_chain-validation-code" From cdd1f68021811d2e71b18d9df0f87a4bdbef1185 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Thu, 25 May 2023 13:40:48 +0200 Subject: [PATCH 2/7] create_glutton_spec script done --- scripts/create_glutton_spec.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/create_glutton_spec.sh b/scripts/create_glutton_spec.sh index a64bac2bd93..186e830ad98 100755 --- a/scripts/create_glutton_spec.sh +++ b/scripts/create_glutton_spec.sh @@ -1,9 +1,10 @@ #!/usr/bin/env bash -# G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR +# Example for `compute` and `storage` at 50% and 5120 `trash_data_count` +# ./scripts/create_glutton_spec.sh ./target/release/polkadot-parachain rococo 1300 G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR 500000000 5500000000 5120 usage() { echo Usage: - echo "$0 " + echo "$0 " exit 1 } @@ -15,6 +16,9 @@ id="glutton_$2_$3" protocol_id="glutton_$2_$3" para_id=$3 sudo=$4 +compute=$5 +storage=$6 +trash_data_count=$7 [ -z "$binary_path" ] && usage [ -z "$relay_chain" ] && usage @@ -22,15 +26,13 @@ sudo=$4 [ -z "$protocol_id" ] && usage [ -z "$para_id" ] && usage [ -z "$sudo" ] && usage - -# binary="./target/release/polkadot-parachain" +[ -z "$compute" ] && usage +[ -z "$storage" ] && usage +[ -z "$trash_data_count" ] && usage # build the chain spec we'll manipulate $binary_path build-spec --disable-default-bootnode --chain "glutton-kusama-genesis-$para_id" > "plain-glutton-$para_id-$relay_chain-spec.json" -# convert runtime to hex -# cat $runtime_path | od -A n -v -t x1 | tr -d ' \n' > seedling-hex.txt - # replace the runtime in the spec with the given runtime and set some values to production cat "plain-glutton-$para_id-$relay_chain-spec.json" \ | jq --arg id $id '.id = $id' \ @@ -39,6 +41,9 @@ cat "plain-glutton-$para_id-$relay_chain-spec.json" \ | jq --argjson para_id $para_id '.para_id = $para_id' \ | jq --arg sudo $sudo '.genesis.runtime.sudo.key = $sudo' \ | jq --argjson para_id $para_id '.genesis.runtime.parachainInfo.parachainId = $para_id' \ + | jq --argjson compute $compute '.genesis.runtime.glutton.compute = $compute' \ + | jq --argjson storage $storage '.genesis.runtime.glutton.storage = $storage' \ + | jq --argjson trash_data_count $trash_data_count '.genesis.runtime.glutton.trashDataCount = $trash_data_count' \ > glutton-$para_id-$relay_chain-spec.json # build a raw spec @@ -49,3 +54,5 @@ $binary_path export-genesis-state --chain "glutton-$para_id-$relay_chain-raw-spe # build genesis wasm $binary_path export-genesis-wasm --chain "glutton-$para_id-$relay_chain-raw-spec.json" > "glutton-$para_id-$relay_chain-validation-code" + +rm "plain-glutton-$para_id-$relay_chain-spec.json" From 10013a6ad027dda7e3e1993f5853b2673d24e978 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Thu, 25 May 2023 14:34:26 +0200 Subject: [PATCH 3/7] made script for many paras --- polkadot-parachain/src/chain_spec/glutton.rs | 4 +- scripts/create_glutton_spec.sh | 80 ++++++++++++-------- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/polkadot-parachain/src/chain_spec/glutton.rs b/polkadot-parachain/src/chain_spec/glutton.rs index 1a5f60b3baf..d975a0d7d87 100644 --- a/polkadot-parachain/src/chain_spec/glutton.rs +++ b/polkadot-parachain/src/chain_spec/glutton.rs @@ -65,13 +65,13 @@ pub fn glutton_config(para_id: ParaId) -> GluttonChainSpec { // Name format!("Glutton {}", para_id).as_str(), // ID - format!("glutton_kusama_{}", para_id).as_str(), + format!("glutton-kusama-{}", para_id).as_str(), ChainType::Live, move || glutton_genesis(para_id), Vec::new(), None, // Protocol ID - Some(format!("glutton_kusama_{}", para_id).as_str()), + Some(format!("glutton-kusama-{}", para_id).as_str()), None, Some(properties), Extensions { relay_chain: "kusama".into(), para_id: para_id.into() }, diff --git a/scripts/create_glutton_spec.sh b/scripts/create_glutton_spec.sh index 186e830ad98..7e4c8cc0f50 100755 --- a/scripts/create_glutton_spec.sh +++ b/scripts/create_glutton_spec.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash # Example for `compute` and `storage` at 50% and 5120 `trash_data_count` -# ./scripts/create_glutton_spec.sh ./target/release/polkadot-parachain rococo 1300 G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR 500000000 5500000000 5120 +# ./scripts/create_glutton_spec.sh ./target/release/polkadot-parachain rococo 1300 1305 G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR 500000000 5500000000 5120 output-dir usage() { echo Usage: - echo "$0 " + echo "$0 " exit 1 } @@ -12,47 +12,61 @@ set -e binary_path=$1 relay_chain=$2 -id="glutton_$2_$3" -protocol_id="glutton_$2_$3" -para_id=$3 -sudo=$4 -compute=$5 -storage=$6 -trash_data_count=$7 +from_para_id=$3 +to_para_id=$4 +sudo=$5 +compute=$6 +storage=$7 +trash_data_count=$8 +output_dir=$9 [ -z "$binary_path" ] && usage [ -z "$relay_chain" ] && usage -[ -z "$id" ] && usage -[ -z "$protocol_id" ] && usage -[ -z "$para_id" ] && usage +[ -z "$from_para_id" ] && usage +[ -z "$to_para_id" ] && usage [ -z "$sudo" ] && usage [ -z "$compute" ] && usage [ -z "$storage" ] && usage [ -z "$trash_data_count" ] && usage +[ -z "$output_dir" ] && usage -# build the chain spec we'll manipulate -$binary_path build-spec --disable-default-bootnode --chain "glutton-kusama-genesis-$para_id" > "plain-glutton-$para_id-$relay_chain-spec.json" -# replace the runtime in the spec with the given runtime and set some values to production -cat "plain-glutton-$para_id-$relay_chain-spec.json" \ - | jq --arg id $id '.id = $id' \ - | jq --arg id $id '.protocolId = $id' \ - | jq --arg relay_chain $relay_chain '.relay_chain = $relay_chain' \ - | jq --argjson para_id $para_id '.para_id = $para_id' \ - | jq --arg sudo $sudo '.genesis.runtime.sudo.key = $sudo' \ - | jq --argjson para_id $para_id '.genesis.runtime.parachainInfo.parachainId = $para_id' \ - | jq --argjson compute $compute '.genesis.runtime.glutton.compute = $compute' \ - | jq --argjson storage $storage '.genesis.runtime.glutton.storage = $storage' \ - | jq --argjson trash_data_count $trash_data_count '.genesis.runtime.glutton.trashDataCount = $trash_data_count' \ - > glutton-$para_id-$relay_chain-spec.json +for (( para_id=$from_para_id; para_id<=$to_para_id; para_id++ )); do + echo "Building chain specs for parachain $para_id" -# build a raw spec -$binary_path build-spec --disable-default-bootnode --chain "glutton-$para_id-$relay_chain-spec.json" --raw > "glutton-$para_id-$relay_chain-raw-spec.json" + # create dir to store parachain generated files + output_para_dir="$output_dir/glutton-$relay_chain-$para_id" + if [ ! -d "$output_para_dir" ]; then + mkdir $output_para_dir + fi -# build genesis data -$binary_path export-genesis-state --chain "glutton-$para_id-$relay_chain-raw-spec.json" > "glutton-$para_id-$relay_chain-head-data" + # build the chain spec we'll manipulate + $binary_path build-spec --disable-default-bootnode --chain "glutton-kusama-genesis-$para_id" > "$output_para_dir/plain-glutton-$relay_chain-$para_id-spec.json" -# build genesis wasm -$binary_path export-genesis-wasm --chain "glutton-$para_id-$relay_chain-raw-spec.json" > "glutton-$para_id-$relay_chain-validation-code" + id="glutton-$relay_chain-$para_id" + protocol_id="glutton-$relay_chain-$para_id" -rm "plain-glutton-$para_id-$relay_chain-spec.json" + # replace the runtime in the spec with the given runtime and set some values to production + cat "$output_para_dir/plain-glutton-$relay_chain-$para_id-spec.json" \ + | jq --arg id $id '.id = $id' \ + | jq --arg protocol_id $protocol_id '.protocolId = $protocol_id' \ + | jq --arg relay_chain $relay_chain '.relay_chain = $relay_chain' \ + | jq --argjson para_id $para_id '.para_id = $para_id' \ + | jq --arg sudo $sudo '.genesis.runtime.sudo.key = $sudo' \ + | jq --argjson para_id $para_id '.genesis.runtime.parachainInfo.parachainId = $para_id' \ + | jq --argjson compute $compute '.genesis.runtime.glutton.compute = $compute' \ + | jq --argjson storage $storage '.genesis.runtime.glutton.storage = $storage' \ + | jq --argjson trash_data_count $trash_data_count '.genesis.runtime.glutton.trashDataCount = $trash_data_count' \ + > $output_para_dir/glutton-$relay_chain-$para_id-spec.json + + # build a raw spec + $binary_path build-spec --disable-default-bootnode --chain "$output_para_dir/glutton-$relay_chain-$para_id-spec.json" --raw > "$output_para_dir/glutton-$relay_chain-$para_id-raw-spec.json" + + # build genesis data + $binary_path export-genesis-state --chain "$output_para_dir/glutton-$relay_chain-$para_id-raw-spec.json" > "$output_para_dir/glutton-$relay_chain-$para_id-head-data" + + # build genesis wasm + $binary_path export-genesis-wasm --chain "$output_para_dir/glutton-$relay_chain-$para_id-raw-spec.json" > "$output_para_dir/glutton-$relay_chain-$para_id-validation-code" + + rm "$output_para_dir/plain-glutton-$relay_chain-$para_id-spec.json" +done From 0dba92385954528eb9006d81f37a4925c92e9141 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Thu, 25 May 2023 14:50:27 +0200 Subject: [PATCH 4/7] comment fix --- scripts/create_glutton_spec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_glutton_spec.sh b/scripts/create_glutton_spec.sh index 7e4c8cc0f50..8334ae7f6a0 100755 --- a/scripts/create_glutton_spec.sh +++ b/scripts/create_glutton_spec.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Example for `compute` and `storage` at 50% and 5120 `trash_data_count` -# ./scripts/create_glutton_spec.sh ./target/release/polkadot-parachain rococo 1300 1305 G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR 500000000 5500000000 5120 output-dir +# ./scripts/create_glutton_spec.sh ./target/release/polkadot-parachain rococo 1300 1305 G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR 500000000 500000000 5120 output-dir usage() { echo Usage: echo "$0 " From a24bb17280bffe114c956efdb09001b5d7af77a8 Mon Sep 17 00:00:00 2001 From: Ignacio Palacios Date: Thu, 25 May 2023 15:52:16 +0200 Subject: [PATCH 5/7] comment fix Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- scripts/create_glutton_spec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_glutton_spec.sh b/scripts/create_glutton_spec.sh index 8334ae7f6a0..edc738dbfa4 100755 --- a/scripts/create_glutton_spec.sh +++ b/scripts/create_glutton_spec.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Example for `compute` and `storage` at 50% and 5120 `trash_data_count` +# Example for `compute`, `storage`, and `trash_data_count` set to 50%, 50%, and 5,120, respectively. # ./scripts/create_glutton_spec.sh ./target/release/polkadot-parachain rococo 1300 1305 G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR 500000000 500000000 5120 output-dir usage() { echo Usage: From fc20ef6aa538a54d6f2bd3c68aa77925176639cf Mon Sep 17 00:00:00 2001 From: NachoPal Date: Fri, 26 May 2023 12:12:51 +0200 Subject: [PATCH 6/7] update docs --- scripts/create_glutton_spec.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/create_glutton_spec.sh b/scripts/create_glutton_spec.sh index 8334ae7f6a0..9f77328ad1c 100755 --- a/scripts/create_glutton_spec.sh +++ b/scripts/create_glutton_spec.sh @@ -1,7 +1,16 @@ #!/usr/bin/env bash -# Example for `compute` and `storage` at 50% and 5120 `trash_data_count` -# ./scripts/create_glutton_spec.sh ./target/release/polkadot-parachain rococo 1300 1305 G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR 500000000 500000000 5120 output-dir +# Example usage to: +# +# - Use the `polkadot-parachain` binary; +# - Use `rococo` as the parent Relay Chain; +# - Generate `ParaId`s from 1,300 to 1,370, inclusive; +# - Set the Sudo key to `G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR`; +# - Set `compute`, `storage`, and `trash_data_count` set to 50%, 50%, and 5,120, respectively; +# - And save the results in `output-dir`. +# +# ./scripts/create_glutton_spec.sh ./target/release/polkadot-parachain rococo 1300 1370 G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR 500000000 500000000 5120 output-dir + usage() { echo Usage: echo "$0 " From b1ea2a2a3bf33af83988dbcebf4f6aecf2710b4f Mon Sep 17 00:00:00 2001 From: NachoPal Date: Fri, 26 May 2023 16:18:20 +0200 Subject: [PATCH 7/7] check jq installed --- scripts/create_glutton_spec.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/create_glutton_spec.sh b/scripts/create_glutton_spec.sh index 9f77328ad1c..571a84b57a0 100755 --- a/scripts/create_glutton_spec.sh +++ b/scripts/create_glutton_spec.sh @@ -19,6 +19,11 @@ usage() { set -e +if ! command -v jq >/dev/null 2>&1; then + echo "'jq' is not installed, please install. Exiting..." + exit 1 +fi + binary_path=$1 relay_chain=$2 from_para_id=$3