Skip to content

Commit

Permalink
Use Penpal parachain for testing (#1027)
Browse files Browse the repository at this point in the history
* use penpal parachain instead of template parachain

* removes template node

* replaces template node with penpal

* update smoke tests

* updates polkadot-sdk

* updates polkadot-sdk

---------

Co-authored-by: claravanstaden <Cats 4 life!>
  • Loading branch information
claravanstaden authored Nov 28, 2023
1 parent 377f5c6 commit a222329
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 97 deletions.
2 changes: 1 addition & 1 deletion parachain/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion smoketest/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ src/parachains/assethub.rs
src/parachains/bridgehub.rs
src/parachains/penpal.rs
src/parachains/relaychain.rs
src/parachains/template.rs
src/contracts
3 changes: 1 addition & 2 deletions smoketest/make-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ fi
# Fetch metadata from BridgeHub and generate client
subxt codegen --url ws://localhost:11144 > src/parachains/bridgehub.rs
subxt codegen --url ws://localhost:12144 > src/parachains/assethub.rs
subxt codegen --url ws://localhost:13144 > src/parachains/template.rs
subxt codegen --url ws://localhost:14144 > src/parachains/penpal.rs
subxt codegen --url ws://localhost:13144 > src/parachains/penpal.rs
subxt codegen --url ws://localhost:9944 > src/parachains/relaychain.rs
6 changes: 3 additions & 3 deletions smoketest/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub const ETHEREUM_HTTP_API: &str = "http://localhost:8545";

pub const ASSET_HUB_WS_URL: &str = "ws://127.0.0.1:12144";
pub const BRIDGE_HUB_WS_URL: &str = "ws://127.0.0.1:11144";
pub const PENPAL_WS_URL: &str = "ws://127.0.0.1:14144";
pub const PENPAL_WS_URL: &str = "ws://127.0.0.1:13144";
pub const RELAY_CHAIN_WS_URL: &str = "ws://127.0.0.1:9944";
pub const TEMPLATE_NODE_WS_URL: &str = "ws://127.0.0.1:13144";

Expand All @@ -29,9 +29,9 @@ pub const BRIDGE_HUB_AGENT_ID: [u8; 32] =
// Agent for asset hub parachain 1000
pub const ASSET_HUB_AGENT_ID: [u8; 32] =
hex!("72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4");
// Agent for template parachain 1001
// Agent for penpal parachain 2000
pub const SIBLING_AGENT_ID: [u8; 32] =
hex!("e01018a3378502770faff44fbef3910d120a0353d18be653625b8daa88a86453");
hex!("5097ee1101e90c3aadb882858c59a22108668021ec81bce9f4930155e5c21e59");

pub const ASSET_HUB_SOVEREIGN: [u8; 32] =
hex!("7369626ce8030000000000000000000000000000000000000000000000000000");
Expand Down
43 changes: 12 additions & 31 deletions smoketest/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ use crate::{
VersionedXcm as RelaychainVersionedXcm,
},
},
template::{
api::runtime_types as templateTypes,
penpal::{
api::runtime_types as penpalTypes,
{self},
},
},
Expand All @@ -53,28 +53,16 @@ use subxt::{
tx::{PairSigner, TxPayload},
Config, OnlineClient, PolkadotConfig, SubstrateConfig,
};
use templateTypes::{
use penpalTypes::{
staging_xcm::v3::multilocation::MultiLocation,
xcm::{
v3::{junction::Junction, junctions::Junctions},
VersionedMultiLocation, VersionedXcm,
},
pallet_xcm::pallet::Call,
penpal_runtime::RuntimeCall
};

/// Custom config that works with TemplateParachain
pub enum TemplateConfig {}

impl Config for TemplateConfig {
type Index = <PolkadotConfig as Config>::Index;
type Hash = <PolkadotConfig as Config>::Hash;
type AccountId = <PolkadotConfig as Config>::AccountId;
type Address = <PolkadotConfig as Config>::Address;
type Signature = <PolkadotConfig as Config>::Signature;
type Hasher = <PolkadotConfig as Config>::Hasher;
type Header = <PolkadotConfig as Config>::Header;
type ExtrinsicParams = <PolkadotConfig as Config>::ExtrinsicParams;
}

/// Custom config that works with Penpal
pub enum PenpalConfig {}

Expand Down Expand Up @@ -106,7 +94,6 @@ impl Config for AssetHubConfig {
pub struct TestClients {
pub asset_hub_client: Box<OnlineClient<PolkadotConfig>>,
pub bridge_hub_client: Box<OnlineClient<PolkadotConfig>>,
pub template_client: Box<OnlineClient<TemplateConfig>>,
pub penpal_client: Box<OnlineClient<PenpalConfig>>,
pub relaychain_client: Box<OnlineClient<PolkadotConfig>>,
pub ethereum_client: Box<Arc<Provider<Ws>>>,
Expand All @@ -122,11 +109,6 @@ pub async fn initial_clients() -> Result<TestClients, Box<dyn std::error::Error>
.await
.expect("can not connect to bridgehub");

let template_client: OnlineClient<TemplateConfig> =
OnlineClient::from_url(TEMPLATE_NODE_WS_URL)
.await
.expect("can not connect to template parachain");

let penpal_client: OnlineClient<PenpalConfig> = OnlineClient::from_url(PENPAL_WS_URL)
.await
.expect("can not connect to penpal parachain");
Expand All @@ -148,7 +130,6 @@ pub async fn initial_clients() -> Result<TestClients, Box<dyn std::error::Error>
Ok(TestClients {
asset_hub_client: Box::new(asset_hub_client),
bridge_hub_client: Box::new(bridge_hub_client),
template_client: Box::new(template_client),
penpal_client: Box::new(penpal_client),
relaychain_client: Box::new(relaychain_client),
ethereum_client: Box::new(ethereum_client),
Expand Down Expand Up @@ -207,24 +188,24 @@ pub async fn wait_for_ethereum_event<Ev: EthEvent>(ethereum_client: &Box<Arc<Pro
assert!(ethereum_event_found);
}

pub async fn send_xcm_transact(
template_client: &Box<OnlineClient<TemplateConfig>>,
pub async fn send_sudo_xcm_transact(
penpal_client: &Box<OnlineClient<PenpalConfig>>,
message: Box<VersionedXcm>,
) -> Result<ExtrinsicEvents<TemplateConfig>, Box<dyn std::error::Error>> {
) -> Result<ExtrinsicEvents<PenpalConfig>, Box<dyn std::error::Error>> {
let dest = Box::new(VersionedMultiLocation::V3(MultiLocation {
parents: 1,
interior: Junctions::X1(Junction::Parachain(BRIDGE_HUB_PARA_ID)),
}));

let xcm_call = template::api::template_pallet::calls::TransactionApi.send_xcm(*dest, *message);
let sudo_call = penpal::api::sudo::calls::TransactionApi::sudo(&penpal::api::sudo::calls::TransactionApi,RuntimeCall::PolkadotXcm(Call::send { dest, message }));

let owner: Pair = Pair::from_string("//Alice", None).expect("cannot create keypair");

let signer: PairSigner<TemplateConfig, _> = PairSigner::new(owner);
let signer: PairSigner<PenpalConfig, _> = PairSigner::new(owner);

let result = template_client
let result = penpal_client
.tx()
.sign_and_submit_then_watch_default(&xcm_call, &signer)
.sign_and_submit_then_watch_default(&sudo_call, &signer)
.await
.expect("send through xcm call.")
.wait_for_finalized_success()
Expand Down
1 change: 0 additions & 1 deletion smoketest/src/parachains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ pub mod assethub;
pub mod bridgehub;
pub mod penpal;
pub mod relaychain;
pub mod template;
10 changes: 5 additions & 5 deletions smoketest/src/xcm.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::parachains::template::api::{
runtime_types as templateTypes, runtime_types::staging_xcm as templateXcm,
use crate::parachains::penpal::api::{
runtime_types as penpalTypes, runtime_types::staging_xcm as penpalXcm,
};
use templateTypes::sp_weights::weight_v2::Weight;
use templateXcm::v3::multilocation::MultiLocation;
use penpalTypes::sp_weights::weight_v2::Weight;
use penpalXcm::v3::multilocation::MultiLocation;

use templateTypes::xcm::{
use penpalTypes::xcm::{
double_encoded::DoubleEncoded,
v2::OriginKind,
v3::{
Expand Down
2 changes: 1 addition & 1 deletion smoketest/tests/create_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async fn create_agent() {

let message = construct_xcm_message_with_fee(encoded_call).await;

let result = send_xcm_transact(&test_clients.template_client, message)
let result = send_sudo_xcm_transact(&test_clients.penpal_client, message)
.await
.expect("failed to send xcm transact.");

Expand Down
4 changes: 2 additions & 2 deletions smoketest/tests/create_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ async fn create_channel() {

let encoded_call = construct_create_channel_call(&test_clients.bridge_hub_client)
.await
.expect("construct innner call.");
.expect("construct inner call.");

let message = construct_xcm_message_with_fee(encoded_call).await;

let result = send_xcm_transact(&test_clients.template_client, message)
let result = send_sudo_xcm_transact(&test_clients.penpal_client, message)
.await
.expect("failed to send xcm transact.");

Expand Down
2 changes: 1 addition & 1 deletion smoketest/tests/transfer_native_from_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn transfer_native_from_agent() {
)
.await;

let result = send_xcm_transact(&test_clients.template_client, message)
let result = send_sudo_xcm_transact(&test_clients.penpal_client, message)
.await
.expect("failed to send xcm transact.");

Expand Down
23 changes: 2 additions & 21 deletions web/packages/test/config/launch-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,6 @@ cumulus_based = true
"-lparachain=debug,xcm=trace,runtime::bridge-assets-transfer=trace,runtime::assets=trace,runtime::bridge-transfer=trace",
]


## Template node
[[parachains]]
id = 1001
chain = "template-rococo"
cumulus_based = true

# run alice as parachain collator
[[parachains.collators]]
name = "template01"
validator = true
command = "{{output_bin_dir}}/parachain-template-node"
rpc_port = 8083
ws_port = 13144
args = [
"--force-authoring",
"-lparachain=debug,xcm=trace,runtime::bridge-assets-transfer=trace,runtime::assets=trace,runtime::bridge-transfer=trace",
]

## Penpal
[[parachains]]
id = 2000
Expand All @@ -100,8 +81,8 @@ cumulus_based = true
validator = true
command = "{{output_bin_dir}}/polkadot-parachain"
rpc_port = 8084
ws_port = 14144
args = [
ws_port = 13144
args = [
"--force-authoring",
"-lxcm=trace,runtime::assets=trace",
]
5 changes: 2 additions & 3 deletions web/packages/test/scripts/build-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ build_binaries() {
features=--features beacon-spec-mainnet
fi

echo "Building polkadot binary and parachain template node"
cargo build --release --workspace --locked --bin polkadot --bin polkadot-execute-worker --bin polkadot-prepare-worker --bin parachain-template-node
echo "Building polkadot binary"
cargo build --release --workspace --locked --bin polkadot --bin polkadot-execute-worker --bin polkadot-prepare-worker
cp target/release/polkadot $output_bin_dir/polkadot
cp target/release/polkadot-execute-worker $output_bin_dir/polkadot-execute-worker
cp target/release/polkadot-prepare-worker $output_bin_dir/polkadot-prepare-worker
cp target/release/parachain-template-node $output_bin_dir/parachain-template-node

echo "Building polkadot-parachain binary"
cargo build --release --workspace --locked --bin polkadot-parachain $features
Expand Down
6 changes: 3 additions & 3 deletions web/packages/test/scripts/configure-bridgehub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ wait_beacon_chain_ready() {
fund_accounts() {
echo "Funding substrate accounts"
transfer_balance $relaychain_ws_url "//Charlie" 1013 1000000000000000 $assethub_sovereign_account
transfer_balance $relaychain_ws_url "//Charlie" 1013 1000000000000000 $template_sovereign_account
transfer_balance $relaychain_ws_url "//Charlie" 1013 1000000000000000 $penpal_sovereign_account
transfer_balance $relaychain_ws_url "//Charlie" 1013 1000000000000000 $beacon_relayer_pub_key
transfer_balance $relaychain_ws_url "//Charlie" 1013 1000000000000000 $execution_relayer_pub_key
}
Expand Down Expand Up @@ -63,8 +63,8 @@ open_hrmp_channels()
echo "Opening HRMP channels"
open_hrmp_channel "${relaychain_ws_url}" "${relaychain_sudo_seed}" 1000 1013 8 512 # Assethub -> BridgeHub
open_hrmp_channel "${relaychain_ws_url}" "${relaychain_sudo_seed}" 1013 1000 8 512 # BridgeHub -> Assethub
open_hrmp_channel "${relaychain_ws_url}" "${relaychain_sudo_seed}" 1001 1013 8 512 # TemplateNode -> BridgeHub
open_hrmp_channel "${relaychain_ws_url}" "${relaychain_sudo_seed}" 1013 1001 8 512 # BridgeHub -> TemplateNode
open_hrmp_channel "${relaychain_ws_url}" "${relaychain_sudo_seed}" 2000 1013 8 512 # Penpal -> BridgeHub
open_hrmp_channel "${relaychain_ws_url}" "${relaychain_sudo_seed}" 1013 2000 8 512 # BridgeHub -> Penpal
open_hrmp_channel "${relaychain_ws_url}" "${relaychain_sudo_seed}" 1000 2000 8 512 # Penpal -> AssetHub
open_hrmp_channel "${relaychain_ws_url}" "${relaychain_sudo_seed}" 2000 1000 8 512 # Assethub -> Penpal
}
Expand Down
9 changes: 4 additions & 5 deletions web/packages/test/scripts/set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ assethub_ws_url="${ASSET_HUB_WS_URL:-ws://127.0.0.1:12144}"
assethub_seed="${ASSET_HUB_SEED:-//Alice}"
export ASSET_HUB_PARAID="${ASSET_HUB_PARAID:-1000}"
export ASSET_HUB_AGENT_ID="${ASSET_HUB_AGENT_ID:-0x72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4}"
export TEMPLATE_PARA_ID="${TEMPLATE_PARA_ID:-1001}"
export TEMPLATE_AGENT_ID="${TEMPLATE_AGENT_ID:-0x2075b9f5bc236462eb1473c9a6236c3588e33ed19ead53aa3d9c62ed941cb793}"

export ASSET_HUB_CHANNEL_ID="0xc173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539"
export TEMPLATE_CHANNEL_ID="0x26c13363ad6499b895574b3ca482545dda41d657ffc5673b39a218cd34053e5b"
export PENPAL_CHANNEL_ID="0xa69fbbae90bb6096d59b1930bbcfc8a3ef23959d226b1861deb7ad8fb06c6fa3"
export PRIMARY_GOVERNANCE_CHANNEL_ID="0x0000000000000000000000000000000000000000000000000000000000000001"
export SECONDARY_GOVERNANCE_CHANNEL_ID="0x0000000000000000000000000000000000000000000000000000000000000002"

Expand All @@ -57,10 +55,11 @@ skip_relayer="${SKIP_RELAYER:-false}"

## Important accounts

# Useful tool to get these account values: https://www.shawntabrizi.com/substrate-js-utilities/
# Account for assethub (Sibling parachain 1000 5Eg2fntNprdN3FgH4sfEaaZhYtddZQSQUqvYJ1f2mLtinVhV in testnet)
assethub_sovereign_account="${ASSETHUB_SOVEREIGN_ACCOUNT:-0x7369626ce8030000000000000000000000000000000000000000000000000000}"
# Account for template (Sibling parachain 1001 5Eg2fntP2UgYZNc5tW8xmmCmeXJ3hmNXaZ9MvcpbMdvh1bBJ in testnet)
template_sovereign_account="${TEMPLATE_SOVEREIGN_ACCOUNT:-0x7369626ce9030000000000000000000000000000000000000000000000000000}"
# Account for penpal (Sibling parachain 2000 5Eg2fntJ27qsari4FGrGhrMqKFDRnkNSR6UshkZYBGXmSuC8 in testnet)
penpal_sovereign_account="${PENPAL_SOVEREIGN_ACCOUNT:-0x7369626cd0070000000000000000000000000000000000000000000000000000}"
# Beacon relay account (//BeaconRelay 5GWFwdZb6JyU46e6ZiLxjGxogAHe8SenX76btfq8vGNAaq8c in testnet)
beacon_relayer_pub_key="${BEACON_RELAYER_PUB_KEY:-0xc46e141b5083721ad5f5056ba1cded69dce4a65f027ed3362357605b1687986a}"
# Execution relay account (//ExecutionRelay 5CFNWKMFPsw5Cs2Teo6Pvg7rWyjKiFfqPZs8U4MZXzMYFwXL in testnet)
Expand Down
32 changes: 16 additions & 16 deletions web/packages/test/scripts/start-relayer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ config_relayer() {
' \
config/parachain-relay.json >$output_dir/parachain-relay-asset-hub.json

# Configure parachain relay (parachain template)
# Configure parachain relay (penpal)
jq \
--arg k1 "$(address_for GatewayProxy)" \
--arg k2 "$(address_for BeefyClient)" \
--arg eth_endpoint_ws $eth_endpoint_ws \
--arg channelID $TEMPLATE_CHANNEL_ID \
--arg channelID $PENPAL_CHANNEL_ID \
--arg eth_gas_limit $eth_gas_limit \
'
.source.contracts.Gateway = $k1
Expand All @@ -87,7 +87,7 @@ config_relayer() {
| .sink.ethereum."gas-limit" = $eth_gas_limit
| .source."channel-id" = $channelID
' \
config/parachain-relay.json >$output_dir/parachain-relay-template.json
config/parachain-relay.json >$output_dir/parachain-relay-penpal.json

# Configure beacon relay
jq \
Expand All @@ -111,17 +111,17 @@ config_relayer() {
' \
config/execution-relay.json >$output_dir/execution-relay-asset-hub.json

# Configure execution relay for template node
# Configure execution relay for penpal
jq \
--arg eth_endpoint_ws $eth_endpoint_ws \
--arg k1 "$(address_for GatewayProxy)" \
--arg channelID $TEMPLATE_CHANNEL_ID \
--arg channelID $PENPAL_CHANNEL_ID \
'
.source.ethereum.endpoint = $eth_endpoint_ws
| .source.contracts.Gateway = $k1
| .source."channel-id" = $channelID
' \
config/execution-relay.json >$output_dir/execution-relay-template.json
config/execution-relay.json >$output_dir/execution-relay-penpal.json
}

start_relayer() {
Expand Down Expand Up @@ -178,15 +178,15 @@ start_relayer() {
done
) &

# Launch parachain relay for parachain template
# Launch parachain relay for parachain penpal
(
: >"$output_dir"/parachain-relay-template.log
: >"$output_dir"/parachain-relay-penpal.log
while :; do
echo "Starting parachain-relay (parachain-template) at $(date)"
echo "Starting parachain-relay (penpal) at $(date)"
"${relay_bin}" run parachain \
--config "$output_dir/parachain-relay-template.json" \
--config "$output_dir/parachain-relay-penpal.json" \
--ethereum.private-key $parachain_relay_eth_key \
>>"$output_dir"/parachain-relay-template.log 2>&1 || true
>>"$output_dir"/parachain-relay-penpal.log 2>&1 || true
sleep 20
done
) &
Expand Down Expand Up @@ -217,15 +217,15 @@ start_relayer() {
done
) &

# Launch execution relay for template
# Launch execution relay for penpal
(
: >$output_dir/execution-relay-template.log
: >$output_dir/execution-relay-penpal.log
while :; do
echo "Starting execution relay (parachain-template) at $(date)"
echo "Starting execution relay (penpal) at $(date)"
"${relay_bin}" run execution \
--config $output_dir/execution-relay-template.json \
--config $output_dir/execution-relay-penpal.json \
--substrate.private-key "//ExecutionRelay" \
>>"$output_dir"/execution-relay-template.log 2>&1 || true
>>"$output_dir"/execution-relay-penpal.log 2>&1 || true
sleep 20
done
) &
Expand Down

0 comments on commit a222329

Please sign in to comment.