mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 00:57:57 +00:00
[testnet] AssetHubRococo nits (#1954)
This PR addresses several minor issues: - Fixes the symlink for `asset-hub-rococo.json` chainspec. - Corrects the `asset-hub-rococo-genesis` invulnerables setup. - Relocates common bash functions for bridge testing to a separate file `bridges_common.sh`.
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
../../parachains/chain-specs/asset-hub-rococo.json
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
../../parachains/chain-specs/asset-hub-wococo.json
|
||||
@@ -796,39 +796,49 @@ fn asset_hub_rococo_like_local_config(
|
||||
)
|
||||
}
|
||||
|
||||
pub fn asset_hub_rococo_config() -> AssetHubRococoChainSpec {
|
||||
pub fn asset_hub_rococo_genesis_config() -> AssetHubRococoChainSpec {
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "ROC".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
asset_hub_rococo_like_local_config(properties, "Rococo Asset Hub", "asset-hub-rococo", 1000)
|
||||
}
|
||||
|
||||
pub fn asset_hub_wococo_config() -> AssetHubWococoChainSpec {
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "WOC".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
asset_hub_rococo_like_config(properties, "Wococo Asset Hub", "asset-hub-wococo", 1000)
|
||||
}
|
||||
|
||||
fn asset_hub_rococo_like_config(
|
||||
properties: sc_chain_spec::Properties,
|
||||
name: &str,
|
||||
chain_id: &str,
|
||||
para_id: u32,
|
||||
) -> AssetHubRococoChainSpec {
|
||||
let para_id = 1000;
|
||||
AssetHubRococoChainSpec::from_genesis(
|
||||
// Name
|
||||
name,
|
||||
"Rococo Asset Hub",
|
||||
// ID
|
||||
chain_id,
|
||||
"asset-hub-rococo",
|
||||
ChainType::Live,
|
||||
move || {
|
||||
asset_hub_rococo_genesis(
|
||||
// initial collators.
|
||||
vec![
|
||||
// TODO: add invulnerables? from Rockmine?
|
||||
// E8XC6rTJRsioKCp6KMy6zd24ykj4gWsusZ3AkSeyavpVBAG
|
||||
(
|
||||
hex!("44cb62d1d6cdd2fff2a5ef3bb7ef827be5b3e117a394ecaa634d8dd9809d5608")
|
||||
.into(),
|
||||
hex!("44cb62d1d6cdd2fff2a5ef3bb7ef827be5b3e117a394ecaa634d8dd9809d5608")
|
||||
.unchecked_into(),
|
||||
),
|
||||
// G28iWEybndgGRbhfx83t7Q42YhMPByHpyqWDUgeyoGF94ri
|
||||
(
|
||||
hex!("9864b85e23aa4506643db9879c3dbbeabaa94d269693a4447f537dd6b5893944")
|
||||
.into(),
|
||||
hex!("9864b85e23aa4506643db9879c3dbbeabaa94d269693a4447f537dd6b5893944")
|
||||
.unchecked_into(),
|
||||
),
|
||||
// G839e2eMiq7UXbConsY6DS1XDAYG2XnQxAmLuRLGGQ3Px9c
|
||||
(
|
||||
hex!("9ce5741ee2f1ac3bdedbde9f3339048f4da2cb88ddf33a0977fa0b4cf86e2948")
|
||||
.into(),
|
||||
hex!("9ce5741ee2f1ac3bdedbde9f3339048f4da2cb88ddf33a0977fa0b4cf86e2948")
|
||||
.unchecked_into(),
|
||||
),
|
||||
// GLao4ukFUW6qhexuZowdFrKa2NLCfnEjZMftSXXfvGv1vvt
|
||||
(
|
||||
hex!("a676ed15f5a325eab49ed8d5f8c00f3f814b19bb58cda14ad10894c078dd337f")
|
||||
.into(),
|
||||
hex!("a676ed15f5a325eab49ed8d5f8c00f3f814b19bb58cda14ad10894c078dd337f")
|
||||
.unchecked_into(),
|
||||
),
|
||||
],
|
||||
Vec::new(),
|
||||
para_id.into(),
|
||||
@@ -843,6 +853,64 @@ fn asset_hub_rococo_like_config(
|
||||
)
|
||||
}
|
||||
|
||||
pub fn asset_hub_wococo_genesis_config() -> AssetHubWococoChainSpec {
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "WOC".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
let para_id = 1000;
|
||||
AssetHubWococoChainSpec::from_genesis(
|
||||
// Name
|
||||
"Wococo Asset Hub",
|
||||
// ID
|
||||
"asset-hub-wococo",
|
||||
ChainType::Live,
|
||||
move || {
|
||||
asset_hub_rococo_genesis(
|
||||
// initial collators.
|
||||
vec![
|
||||
// 5C8RGkS8t5K93fB2hkgKbvSYs5iG6AknJMuQmbBDeazon9Lj
|
||||
(
|
||||
hex!("02d526f43cf27e94f478f9db785dc86052a77c695e7c855211839d3fde3ce534")
|
||||
.into(),
|
||||
hex!("02d526f43cf27e94f478f9db785dc86052a77c695e7c855211839d3fde3ce534")
|
||||
.unchecked_into(),
|
||||
),
|
||||
// 5GePeDZQeBagXH7kH5QPKnQKi39Z5hoYFB5FmUtEvc4yxKej
|
||||
(
|
||||
hex!("caa1f623ca183296c4521b56cc29c484ca017830f8cb538f30f2d4664d631814")
|
||||
.into(),
|
||||
hex!("caa1f623ca183296c4521b56cc29c484ca017830f8cb538f30f2d4664d631814")
|
||||
.unchecked_into(),
|
||||
),
|
||||
// 5CfnTTb9NMJDNKDntA83mHKoedZ7wjDC8ypLCTDd4NwUx3zv
|
||||
(
|
||||
hex!("1ac112d635db2bd34e79ae2b99486cf7c0b71a928668e4feb3dc4633d368f965")
|
||||
.into(),
|
||||
hex!("1ac112d635db2bd34e79ae2b99486cf7c0b71a928668e4feb3dc4633d368f965")
|
||||
.unchecked_into(),
|
||||
),
|
||||
// 5EqheiwiG22gvGpN7cvrbeaQzhg7rzsYYVkYK4yj5vRrTQRQ
|
||||
(
|
||||
hex!("7ac9d11be07334cd27e9eb849f5fc7677a10ad36b6ab38b377d3c8b2c0b08b66")
|
||||
.into(),
|
||||
hex!("7ac9d11be07334cd27e9eb849f5fc7677a10ad36b6ab38b377d3c8b2c0b08b66")
|
||||
.unchecked_into(),
|
||||
),
|
||||
],
|
||||
Vec::new(),
|
||||
para_id.into(),
|
||||
)
|
||||
},
|
||||
Vec::new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(properties),
|
||||
Extensions { relay_chain: "wococo".into(), para_id },
|
||||
)
|
||||
}
|
||||
|
||||
fn asset_hub_rococo_genesis(
|
||||
invulnerables: Vec<(AccountId, AuraId)>,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
|
||||
@@ -176,8 +176,8 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||
"asset-hub-rococo-local" =>
|
||||
Box::new(chain_spec::asset_hubs::asset_hub_rococo_local_config()),
|
||||
// the chain spec as used for generating the upgrade genesis values
|
||||
"asset-hub-rococo-genesis" => Box::new(chain_spec::asset_hubs::asset_hub_rococo_config()),
|
||||
// the shell-based chain spec as used for syncing
|
||||
"asset-hub-rococo-genesis" =>
|
||||
Box::new(chain_spec::asset_hubs::asset_hub_rococo_genesis_config()),
|
||||
"asset-hub-rococo" =>
|
||||
Box::new(chain_spec::asset_hubs::AssetHubRococoChainSpec::from_json_bytes(
|
||||
&include_bytes!("../chain-specs/asset-hub-rococo.json")[..],
|
||||
@@ -189,7 +189,8 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||
"asset-hub-wococo-local" =>
|
||||
Box::new(chain_spec::asset_hubs::asset_hub_wococo_local_config()),
|
||||
// the chain spec as used for generating the upgrade genesis values
|
||||
"asset-hub-wococo-genesis" => Box::new(chain_spec::asset_hubs::asset_hub_wococo_config()),
|
||||
"asset-hub-wococo-genesis" =>
|
||||
Box::new(chain_spec::asset_hubs::asset_hub_wococo_genesis_config()),
|
||||
"asset-hub-wococo" =>
|
||||
Box::new(chain_spec::asset_hubs::AssetHubWococoChainSpec::from_json_bytes(
|
||||
&include_bytes!("../chain-specs/asset-hub-wococo.json")[..],
|
||||
|
||||
Executable
+305
@@ -0,0 +1,305 @@
|
||||
#!/bin/bash
|
||||
|
||||
function ensure_binaries() {
|
||||
if [[ ! -f ~/local_bridge_testing/bin/polkadot ]]; then
|
||||
echo " Required polkadot binary '~/local_bridge_testing/bin/polkadot' does not exist!"
|
||||
echo " You need to build it and copy to this location!"
|
||||
echo " Please, check ./parachains/runtimes/bridge-hubs/README.md (Prepare/Build/Deploy)"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f ~/local_bridge_testing/bin/polkadot-parachain ]]; then
|
||||
echo " Required polkadot-parachain binary '~/local_bridge_testing/bin/polkadot-parachain' does not exist!"
|
||||
echo " You need to build it and copy to this location!"
|
||||
echo " Please, check ./parachains/runtimes/bridge-hubs/README.md (Prepare/Build/Deploy)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function ensure_relayer() {
|
||||
if [[ ! -f ~/local_bridge_testing/bin/substrate-relay ]]; then
|
||||
echo " Required substrate-relay binary '~/local_bridge_testing/bin/substrate-relay' does not exist!"
|
||||
echo " You need to build it and copy to this location!"
|
||||
echo " Please, check ./parachains/runtimes/bridge-hubs/README.md (Prepare/Build/Deploy)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function ensure_polkadot_js_api() {
|
||||
if ! which polkadot-js-api &> /dev/null; then
|
||||
echo ''
|
||||
echo 'Required command `polkadot-js-api` not in PATH, please, install, e.g.:'
|
||||
echo "npm install -g @polkadot/api-cli@beta"
|
||||
echo " or"
|
||||
echo "yarn global add @polkadot/api-cli"
|
||||
echo ''
|
||||
exit 1
|
||||
fi
|
||||
if ! which jq &> /dev/null; then
|
||||
echo ''
|
||||
echo 'Required command `jq` not in PATH, please, install, e.g.:'
|
||||
echo "apt install -y jq"
|
||||
echo ''
|
||||
exit 1
|
||||
fi
|
||||
generate_hex_encoded_call_data "check" "--"
|
||||
local retVal=$?
|
||||
if [ $retVal -ne 0 ]; then
|
||||
echo ""
|
||||
echo ""
|
||||
echo "-------------------"
|
||||
echo "Installing (nodejs) sub module: $(dirname "$0")/generate_hex_encoded_call"
|
||||
pushd $(dirname "$0")/generate_hex_encoded_call
|
||||
npm install
|
||||
popd
|
||||
fi
|
||||
}
|
||||
|
||||
function generate_hex_encoded_call_data() {
|
||||
local type=$1
|
||||
local endpoint=$2
|
||||
local output=$3
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
echo "Input params: $@"
|
||||
|
||||
node $(dirname "$0")/generate_hex_encoded_call "$type" "$endpoint" "$output" "$@"
|
||||
local retVal=$?
|
||||
|
||||
if [ $type != "check" ]; then
|
||||
local hex_encoded_data=$(cat $output)
|
||||
echo "Generated hex-encoded bytes to file '$output': $hex_encoded_data"
|
||||
fi
|
||||
|
||||
return $retVal
|
||||
}
|
||||
|
||||
function transfer_balance() {
|
||||
local runtime_para_endpoint=$1
|
||||
local seed=$2
|
||||
local target_account=$3
|
||||
local amount=$4
|
||||
echo " calling transfer_balance:"
|
||||
echo " runtime_para_endpoint: ${runtime_para_endpoint}"
|
||||
echo " seed: ${seed}"
|
||||
echo " target_account: ${target_account}"
|
||||
echo " amount: ${amount}"
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
polkadot-js-api \
|
||||
--ws "${runtime_para_endpoint}" \
|
||||
--seed "${seed?}" \
|
||||
tx.balances.transferAllowDeath \
|
||||
"${target_account}" \
|
||||
"${amount}"
|
||||
}
|
||||
|
||||
function send_governance_transact() {
|
||||
local relay_url=$1
|
||||
local relay_chain_seed=$2
|
||||
local para_id=$3
|
||||
local hex_encoded_data=$4
|
||||
local require_weight_at_most_ref_time=$5
|
||||
local require_weight_at_most_proof_size=$6
|
||||
echo " calling send_governance_transact:"
|
||||
echo " relay_url: ${relay_url}"
|
||||
echo " relay_chain_seed: ${relay_chain_seed}"
|
||||
echo " para_id: ${para_id}"
|
||||
echo " hex_encoded_data: ${hex_encoded_data}"
|
||||
echo " require_weight_at_most_ref_time: ${require_weight_at_most_ref_time}"
|
||||
echo " require_weight_at_most_proof_size: ${require_weight_at_most_proof_size}"
|
||||
echo " params:"
|
||||
|
||||
local dest=$(jq --null-input \
|
||||
--arg para_id "$para_id" \
|
||||
'{ "V3": { "parents": 0, "interior": { "X1": { "Parachain": $para_id } } } }')
|
||||
|
||||
local message=$(jq --null-input \
|
||||
--argjson hex_encoded_data $hex_encoded_data \
|
||||
--arg require_weight_at_most_ref_time "$require_weight_at_most_ref_time" \
|
||||
--arg require_weight_at_most_proof_size "$require_weight_at_most_proof_size" \
|
||||
'
|
||||
{
|
||||
"V3": [
|
||||
{
|
||||
"UnpaidExecution": {
|
||||
"weight_limit": "Unlimited"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Transact": {
|
||||
"origin_kind": "Superuser",
|
||||
"require_weight_at_most": {
|
||||
"ref_time": $require_weight_at_most_ref_time,
|
||||
"proof_size": $require_weight_at_most_proof_size,
|
||||
},
|
||||
"call": {
|
||||
"encoded": $hex_encoded_data
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
')
|
||||
|
||||
echo ""
|
||||
echo " dest:"
|
||||
echo "${dest}"
|
||||
echo ""
|
||||
echo " message:"
|
||||
echo "${message}"
|
||||
echo ""
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
polkadot-js-api \
|
||||
--ws "${relay_url?}" \
|
||||
--seed "${relay_chain_seed?}" \
|
||||
--sudo \
|
||||
tx.xcmPallet.send \
|
||||
"${dest}" \
|
||||
"${message}"
|
||||
}
|
||||
|
||||
function open_hrmp_channels() {
|
||||
local relay_url=$1
|
||||
local relay_chain_seed=$2
|
||||
local sender_para_id=$3
|
||||
local recipient_para_id=$4
|
||||
local max_capacity=$5
|
||||
local max_message_size=$6
|
||||
echo " calling open_hrmp_channels:"
|
||||
echo " relay_url: ${relay_url}"
|
||||
echo " relay_chain_seed: ${relay_chain_seed}"
|
||||
echo " sender_para_id: ${sender_para_id}"
|
||||
echo " recipient_para_id: ${recipient_para_id}"
|
||||
echo " max_capacity: ${max_capacity}"
|
||||
echo " max_message_size: ${max_message_size}"
|
||||
echo " params:"
|
||||
echo "--------------------------------------------------"
|
||||
polkadot-js-api \
|
||||
--ws "${relay_url?}" \
|
||||
--seed "${relay_chain_seed?}" \
|
||||
--sudo \
|
||||
tx.hrmp.forceOpenHrmpChannel \
|
||||
${sender_para_id} \
|
||||
${recipient_para_id} \
|
||||
${max_capacity} \
|
||||
${max_message_size}
|
||||
}
|
||||
|
||||
function set_storage() {
|
||||
local relay_url=$1
|
||||
local relay_chain_seed=$2
|
||||
local runtime_para_id=$3
|
||||
local runtime_para_endpoint=$4
|
||||
local items=$5
|
||||
echo " calling set_storage:"
|
||||
echo " relay_url: ${relay_url}"
|
||||
echo " relay_chain_seed: ${relay_chain_seed}"
|
||||
echo " runtime_para_id: ${runtime_para_id}"
|
||||
echo " runtime_para_endpoint: ${runtime_para_endpoint}"
|
||||
echo " items: ${items}"
|
||||
echo " params:"
|
||||
|
||||
# 1. generate data for Transact (System::set_storage)
|
||||
local tmp_output_file=$(mktemp)
|
||||
generate_hex_encoded_call_data "set-storage" "${runtime_para_endpoint}" "${tmp_output_file}" "$items"
|
||||
local hex_encoded_data=$(cat $tmp_output_file)
|
||||
|
||||
# 2. trigger governance call
|
||||
send_governance_transact "${relay_url}" "${relay_chain_seed}" "${runtime_para_id}" "${hex_encoded_data}" 200000000 12000
|
||||
}
|
||||
|
||||
function force_create_foreign_asset() {
|
||||
local relay_url=$1
|
||||
local relay_chain_seed=$2
|
||||
local runtime_para_id=$3
|
||||
local runtime_para_endpoint=$4
|
||||
local asset_multilocation=$5
|
||||
local asset_owner_account_id=$6
|
||||
local min_balance=$7
|
||||
local is_sufficient=$8
|
||||
echo " calling force_create_foreign_asset:"
|
||||
echo " relay_url: ${relay_url}"
|
||||
echo " relay_chain_seed: ${relay_chain_seed}"
|
||||
echo " runtime_para_id: ${runtime_para_id}"
|
||||
echo " runtime_para_endpoint: ${runtime_para_endpoint}"
|
||||
echo " asset_multilocation: ${asset_multilocation}"
|
||||
echo " asset_owner_account_id: ${asset_owner_account_id}"
|
||||
echo " min_balance: ${min_balance}"
|
||||
echo " is_sufficient: ${is_sufficient}"
|
||||
echo " params:"
|
||||
|
||||
# 1. generate data for Transact (ForeignAssets::force_create)
|
||||
local tmp_output_file=$(mktemp)
|
||||
generate_hex_encoded_call_data "force-create-asset" "${runtime_para_endpoint}" "${tmp_output_file}" "$asset_multilocation" "$asset_owner_account_id" $is_sufficient $min_balance
|
||||
local hex_encoded_data=$(cat $tmp_output_file)
|
||||
|
||||
# 2. trigger governance call
|
||||
send_governance_transact "${relay_url}" "${relay_chain_seed}" "${runtime_para_id}" "${hex_encoded_data}" 200000000 12000
|
||||
}
|
||||
|
||||
function limited_reserve_transfer_assets() {
|
||||
local url=$1
|
||||
local seed=$2
|
||||
local destination=$3
|
||||
local beneficiary=$4
|
||||
local assets=$5
|
||||
local fee_asset_item=$6
|
||||
local weight_limit=$7
|
||||
echo " calling limited_reserve_transfer_assets:"
|
||||
echo " url: ${url}"
|
||||
echo " seed: ${seed}"
|
||||
echo " destination: ${destination}"
|
||||
echo " beneficiary: ${beneficiary}"
|
||||
echo " assets: ${assets}"
|
||||
echo " fee_asset_item: ${fee_asset_item}"
|
||||
echo " weight_limit: ${weight_limit}"
|
||||
echo ""
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
polkadot-js-api \
|
||||
--ws "${url?}" \
|
||||
--seed "${seed?}" \
|
||||
tx.polkadotXcm.limitedReserveTransferAssets \
|
||||
"${destination}" \
|
||||
"${beneficiary}" \
|
||||
"${assets}" \
|
||||
"${fee_asset_item}" \
|
||||
"${weight_limit}"
|
||||
}
|
||||
|
||||
function claim_rewards() {
|
||||
local runtime_para_endpoint=$1
|
||||
local seed=$2
|
||||
local lane_id=$3
|
||||
local bridged_chain_id=$4
|
||||
local owner=$5
|
||||
echo " calling claim_rewards:"
|
||||
echo " runtime_para_endpoint: ${runtime_para_endpoint}"
|
||||
echo " seed: ${seed}"
|
||||
echo " lane_id: ${lane_id}"
|
||||
echo " bridged_chain_id: ${bridged_chain_id}"
|
||||
echo " owner: ${owner}"
|
||||
echo ""
|
||||
|
||||
local rewards_account_params=$(jq --null-input \
|
||||
--arg lane_id "$lane_id" \
|
||||
--arg bridged_chain_id "$bridged_chain_id" \
|
||||
--arg owner "$owner" \
|
||||
'{
|
||||
"laneId": $lane_id,
|
||||
"bridgedChainId": $bridged_chain_id,
|
||||
"owner": $owner
|
||||
}')
|
||||
|
||||
echo " rewards_account_params:"
|
||||
echo "${rewards_account_params}"
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
polkadot-js-api \
|
||||
--ws "${runtime_para_endpoint}" \
|
||||
--seed "${seed?}" \
|
||||
tx.bridgeRelayers.claimRewards \
|
||||
"${rewards_account_params}"
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# import common functions
|
||||
source "$(dirname "$0")"/bridges_common.sh
|
||||
|
||||
# Expected sovereign accounts.
|
||||
#
|
||||
# Generated by:
|
||||
@@ -125,310 +128,6 @@ ON_BRIDGE_HUB_WOCOCO_SOVEREIGN_ACCOUNT_FOR_LANE_00000001_bhro_BridgedChain="5EHn
|
||||
|
||||
LANE_ID="00000001"
|
||||
|
||||
function ensure_binaries() {
|
||||
if [[ ! -f ~/local_bridge_testing/bin/polkadot ]]; then
|
||||
echo " Required polkadot binary '~/local_bridge_testing/bin/polkadot' does not exist!"
|
||||
echo " You need to build it and copy to this location!"
|
||||
echo " Please, check ./parachains/runtimes/bridge-hubs/README.md (Prepare/Build/Deploy)"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f ~/local_bridge_testing/bin/polkadot-parachain ]]; then
|
||||
echo " Required polkadot-parachain binary '~/local_bridge_testing/bin/polkadot-parachain' does not exist!"
|
||||
echo " You need to build it and copy to this location!"
|
||||
echo " Please, check ./parachains/runtimes/bridge-hubs/README.md (Prepare/Build/Deploy)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function ensure_relayer() {
|
||||
if [[ ! -f ~/local_bridge_testing/bin/substrate-relay ]]; then
|
||||
echo " Required substrate-relay binary '~/local_bridge_testing/bin/substrate-relay' does not exist!"
|
||||
echo " You need to build it and copy to this location!"
|
||||
echo " Please, check ./parachains/runtimes/bridge-hubs/README.md (Prepare/Build/Deploy)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function ensure_polkadot_js_api() {
|
||||
if ! which polkadot-js-api &> /dev/null; then
|
||||
echo ''
|
||||
echo 'Required command `polkadot-js-api` not in PATH, please, install, e.g.:'
|
||||
echo "npm install -g @polkadot/api-cli@beta"
|
||||
echo " or"
|
||||
echo "yarn global add @polkadot/api-cli"
|
||||
echo ''
|
||||
exit 1
|
||||
fi
|
||||
if ! which jq &> /dev/null; then
|
||||
echo ''
|
||||
echo 'Required command `jq` not in PATH, please, install, e.g.:'
|
||||
echo "apt install -y jq"
|
||||
echo ''
|
||||
exit 1
|
||||
fi
|
||||
generate_hex_encoded_call_data "check" "--"
|
||||
local retVal=$?
|
||||
if [ $retVal -ne 0 ]; then
|
||||
echo ""
|
||||
echo ""
|
||||
echo "-------------------"
|
||||
echo "Installing (nodejs) sub module: $(dirname "$0")/generate_hex_encoded_call"
|
||||
pushd $(dirname "$0")/generate_hex_encoded_call
|
||||
npm install
|
||||
popd
|
||||
fi
|
||||
}
|
||||
|
||||
function generate_hex_encoded_call_data() {
|
||||
local type=$1
|
||||
local endpoint=$2
|
||||
local output=$3
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
echo "Input params: $@"
|
||||
|
||||
node $(dirname "$0")/generate_hex_encoded_call "$type" "$endpoint" "$output" "$@"
|
||||
local retVal=$?
|
||||
|
||||
if [ $type != "check" ]; then
|
||||
local hex_encoded_data=$(cat $output)
|
||||
echo "Generated hex-encoded bytes to file '$output': $hex_encoded_data"
|
||||
fi
|
||||
|
||||
return $retVal
|
||||
}
|
||||
|
||||
function transfer_balance() {
|
||||
local runtime_para_endpoint=$1
|
||||
local seed=$2
|
||||
local target_account=$3
|
||||
local amount=$4
|
||||
echo " calling transfer_balance:"
|
||||
echo " runtime_para_endpoint: ${runtime_para_endpoint}"
|
||||
echo " seed: ${seed}"
|
||||
echo " target_account: ${target_account}"
|
||||
echo " amount: ${amount}"
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
polkadot-js-api \
|
||||
--ws "${runtime_para_endpoint}" \
|
||||
--seed "${seed?}" \
|
||||
tx.balances.transferAllowDeath \
|
||||
"${target_account}" \
|
||||
"${amount}"
|
||||
}
|
||||
|
||||
function send_governance_transact() {
|
||||
local relay_url=$1
|
||||
local relay_chain_seed=$2
|
||||
local para_id=$3
|
||||
local hex_encoded_data=$4
|
||||
local require_weight_at_most_ref_time=$5
|
||||
local require_weight_at_most_proof_size=$6
|
||||
echo " calling send_governance_transact:"
|
||||
echo " relay_url: ${relay_url}"
|
||||
echo " relay_chain_seed: ${relay_chain_seed}"
|
||||
echo " para_id: ${para_id}"
|
||||
echo " hex_encoded_data: ${hex_encoded_data}"
|
||||
echo " require_weight_at_most_ref_time: ${require_weight_at_most_ref_time}"
|
||||
echo " require_weight_at_most_proof_size: ${require_weight_at_most_proof_size}"
|
||||
echo " params:"
|
||||
|
||||
local dest=$(jq --null-input \
|
||||
--arg para_id "$para_id" \
|
||||
'{ "V3": { "parents": 0, "interior": { "X1": { "Parachain": $para_id } } } }')
|
||||
|
||||
local message=$(jq --null-input \
|
||||
--argjson hex_encoded_data $hex_encoded_data \
|
||||
--arg require_weight_at_most_ref_time "$require_weight_at_most_ref_time" \
|
||||
--arg require_weight_at_most_proof_size "$require_weight_at_most_proof_size" \
|
||||
'
|
||||
{
|
||||
"V3": [
|
||||
{
|
||||
"UnpaidExecution": {
|
||||
"weight_limit": "Unlimited"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Transact": {
|
||||
"origin_kind": "Superuser",
|
||||
"require_weight_at_most": {
|
||||
"ref_time": $require_weight_at_most_ref_time,
|
||||
"proof_size": $require_weight_at_most_proof_size,
|
||||
},
|
||||
"call": {
|
||||
"encoded": $hex_encoded_data
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
')
|
||||
|
||||
echo ""
|
||||
echo " dest:"
|
||||
echo "${dest}"
|
||||
echo ""
|
||||
echo " message:"
|
||||
echo "${message}"
|
||||
echo ""
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
polkadot-js-api \
|
||||
--ws "${relay_url?}" \
|
||||
--seed "${relay_chain_seed?}" \
|
||||
--sudo \
|
||||
tx.xcmPallet.send \
|
||||
"${dest}" \
|
||||
"${message}"
|
||||
}
|
||||
|
||||
function open_hrmp_channels() {
|
||||
local relay_url=$1
|
||||
local relay_chain_seed=$2
|
||||
local sender_para_id=$3
|
||||
local recipient_para_id=$4
|
||||
local max_capacity=$5
|
||||
local max_message_size=$6
|
||||
echo " calling open_hrmp_channels:"
|
||||
echo " relay_url: ${relay_url}"
|
||||
echo " relay_chain_seed: ${relay_chain_seed}"
|
||||
echo " sender_para_id: ${sender_para_id}"
|
||||
echo " recipient_para_id: ${recipient_para_id}"
|
||||
echo " max_capacity: ${max_capacity}"
|
||||
echo " max_message_size: ${max_message_size}"
|
||||
echo " params:"
|
||||
echo "--------------------------------------------------"
|
||||
polkadot-js-api \
|
||||
--ws "${relay_url?}" \
|
||||
--seed "${relay_chain_seed?}" \
|
||||
--sudo \
|
||||
tx.hrmp.forceOpenHrmpChannel \
|
||||
${sender_para_id} \
|
||||
${recipient_para_id} \
|
||||
${max_capacity} \
|
||||
${max_message_size}
|
||||
}
|
||||
|
||||
function set_storage() {
|
||||
local relay_url=$1
|
||||
local relay_chain_seed=$2
|
||||
local runtime_para_id=$3
|
||||
local runtime_para_endpoint=$4
|
||||
local items=$5
|
||||
echo " calling set_storage:"
|
||||
echo " relay_url: ${relay_url}"
|
||||
echo " relay_chain_seed: ${relay_chain_seed}"
|
||||
echo " runtime_para_id: ${runtime_para_id}"
|
||||
echo " runtime_para_endpoint: ${runtime_para_endpoint}"
|
||||
echo " items: ${items}"
|
||||
echo " params:"
|
||||
|
||||
# 1. generate data for Transact (System::set_storage)
|
||||
local tmp_output_file=$(mktemp)
|
||||
generate_hex_encoded_call_data "set-storage" "${runtime_para_endpoint}" "${tmp_output_file}" "$items"
|
||||
local hex_encoded_data=$(cat $tmp_output_file)
|
||||
|
||||
# 2. trigger governance call
|
||||
send_governance_transact "${relay_url}" "${relay_chain_seed}" "${runtime_para_id}" "${hex_encoded_data}" 200000000 12000
|
||||
}
|
||||
|
||||
function force_create_foreign_asset() {
|
||||
local relay_url=$1
|
||||
local relay_chain_seed=$2
|
||||
local runtime_para_id=$3
|
||||
local runtime_para_endpoint=$4
|
||||
local asset_multilocation=$5
|
||||
local asset_owner_account_id=$6
|
||||
local min_balance=$7
|
||||
local is_sufficient=$8
|
||||
echo " calling force_create_foreign_asset:"
|
||||
echo " relay_url: ${relay_url}"
|
||||
echo " relay_chain_seed: ${relay_chain_seed}"
|
||||
echo " runtime_para_id: ${runtime_para_id}"
|
||||
echo " runtime_para_endpoint: ${runtime_para_endpoint}"
|
||||
echo " asset_multilocation: ${asset_multilocation}"
|
||||
echo " asset_owner_account_id: ${asset_owner_account_id}"
|
||||
echo " min_balance: ${min_balance}"
|
||||
echo " is_sufficient: ${is_sufficient}"
|
||||
echo " params:"
|
||||
|
||||
# 1. generate data for Transact (ForeignAssets::force_create)
|
||||
local tmp_output_file=$(mktemp)
|
||||
generate_hex_encoded_call_data "force-create-asset" "${runtime_para_endpoint}" "${tmp_output_file}" "$asset_multilocation" "$asset_owner_account_id" $is_sufficient $min_balance
|
||||
local hex_encoded_data=$(cat $tmp_output_file)
|
||||
|
||||
# 2. trigger governance call
|
||||
send_governance_transact "${relay_url}" "${relay_chain_seed}" "${runtime_para_id}" "${hex_encoded_data}" 200000000 12000
|
||||
}
|
||||
|
||||
function limited_reserve_transfer_assets() {
|
||||
local url=$1
|
||||
local seed=$2
|
||||
local destination=$3
|
||||
local beneficiary=$4
|
||||
local assets=$5
|
||||
local fee_asset_item=$6
|
||||
local weight_limit=$7
|
||||
echo " calling limited_reserve_transfer_assets:"
|
||||
echo " url: ${url}"
|
||||
echo " seed: ${seed}"
|
||||
echo " destination: ${destination}"
|
||||
echo " beneficiary: ${beneficiary}"
|
||||
echo " assets: ${assets}"
|
||||
echo " fee_asset_item: ${fee_asset_item}"
|
||||
echo " weight_limit: ${weight_limit}"
|
||||
echo ""
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
polkadot-js-api \
|
||||
--ws "${url?}" \
|
||||
--seed "${seed?}" \
|
||||
tx.polkadotXcm.limitedReserveTransferAssets \
|
||||
"${destination}" \
|
||||
"${beneficiary}" \
|
||||
"${assets}" \
|
||||
"${fee_asset_item}" \
|
||||
"${weight_limit}"
|
||||
}
|
||||
|
||||
function claim_rewards() {
|
||||
local runtime_para_endpoint=$1
|
||||
local seed=$2
|
||||
local lane_id=$3
|
||||
local bridged_chain_id=$4
|
||||
local owner=$5
|
||||
echo " calling claim_rewards:"
|
||||
echo " runtime_para_endpoint: ${runtime_para_endpoint}"
|
||||
echo " seed: ${seed}"
|
||||
echo " lane_id: ${lane_id}"
|
||||
echo " bridged_chain_id: ${bridged_chain_id}"
|
||||
echo " owner: ${owner}"
|
||||
echo ""
|
||||
|
||||
local rewards_account_params=$(jq --null-input \
|
||||
--arg lane_id "$lane_id" \
|
||||
--arg bridged_chain_id "$bridged_chain_id" \
|
||||
--arg owner "$owner" \
|
||||
'{
|
||||
"laneId": $lane_id,
|
||||
"bridgedChainId": $bridged_chain_id,
|
||||
"owner": $owner
|
||||
}')
|
||||
|
||||
echo " rewards_account_params:"
|
||||
echo "${rewards_account_params}"
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
polkadot-js-api \
|
||||
--ws "${runtime_para_endpoint}" \
|
||||
--seed "${seed?}" \
|
||||
tx.bridgeRelayers.claimRewards \
|
||||
"${rewards_account_params}"
|
||||
}
|
||||
|
||||
function init_ro_wo() {
|
||||
ensure_relayer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user