forked from polkadot-fellows/runtimes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
3,205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Bridges Tests for Local Polkadot <> Kusama Bridge | ||
|
||
This folder contains [zombienet](https://github.com/paritytech/zombienet/) based integration tests for both | ||
onchain and offchain bridges code. Due to some | ||
[technical diffuculties](https://github.com/paritytech/parity-bridges-common/pull/2649#issue-1965339051), we | ||
are using native zombienet provider, which means that you need to build some binaries locally. | ||
|
||
To start those tests, you need to: | ||
|
||
- download latest [zombienet release](https://github.com/paritytech/zombienet/releases); | ||
|
||
- build Polkadot binary by running `cargo build -p polkadot --release` command in the | ||
[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone. Also | ||
`cargo build -p polkadot-prepare-worker --release` | ||
`cargo build -p polkadot-execute-worker --release`; | ||
|
||
- build Polkadot Parachain binary by running `cargo build -p polkadot-parachain-bin --release` command in the | ||
[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone; | ||
|
||
- ensure that you have [`node`](https://nodejs.org/en) installed. Additionally, we'll need globally installed | ||
`polkadot/api-cli` package (use `npm install -g @polkadot/api-cli@beta` to install it); | ||
|
||
- build Substrate relay by running `cargo build -p substrate-relay --release` command in the | ||
[`parity-bridges-common`](https://github.com/paritytech/parity-bridges-common) repository clone; | ||
|
||
|
||
??? | ||
|
||
# zombienet: v1.3.70 (v1.3.78 not working) | ||
# TODO: add branch and or fix | ||
# polkadot-sdk (polkadot + polkadot-parachain): v1.3.0-rc1 | ||
# polkadot-sdk (Kusama and Polkadot chain specs): 122086d3d5 | ||
# polkadot-sdk (chain-spec-builder): cargo build --release -p staging-chain-spec-builder | ||
|
||
sudofi | ||
|
||
|
||
cd polkadot-sdk | ||
git checkout 122086d3d5 | ||
cd polkadot | ||
cd polkadot-sdk | ||
cargo run -p polkadot -- build-spec --chain=polkadot-local >../runtimes/system-parachains/bridge-hubs/zombienet/networks/polkadot-local.json | ||
cargo run -p polkadot -- build-spec --chain=kusama-local >../runtimes/system-parachains/bridge-hubs/zombienet/networks/kusama-local.json | ||
|
||
cargo run -p polkadot build-spec --chain=westend-local >../runtimes/system-parachains/bridge-hubs/zombienet/networks/westend-local.json | ||
|
||
|
||
|
||
- build all involved runtimes from this repo: | ||
`srtool build -p staging-kusama-runtime -r relay/kusama --root --build-opts=--features=fast-runtime --verbose` | ||
`srtool build -p polkadot-runtime -r relay/polkadot --root --build-opts=--features=fast-runtime --verbose` | ||
`srtool build -p asset-hub-kusama-runtime -r system-parachains/asset-hubs/asset-hub-kusama --root` | ||
`srtool build -p asset-hub-polkadot-runtime -r system-parachains/asset-hubs/asset-hub-polkadot --root` | ||
`srtool build -p bridge-hub-kusama-runtime -r system-parachains/bridge-hubs/bridge-hub-kusama --root` | ||
`srtool build -p bridge-hub-polkadot-runtime -r system-parachains/bridge-hubs/bridge-hub-polkadot --root` | ||
|
||
- copy fresh `substrate-relay` binary, built in previous point, to the `~/local_bridge_testing/bin/substrate-relay`; | ||
|
||
- change the `POLKADOT_SDK_FOLDER` and `ZOMBIENET_BINARY_PATH` (and ensure that the nearby variables | ||
have correct values) in the `./run-tests.sh`. | ||
|
||
After that, you could run tests with the `./run-tests.sh` command. Hopefully, it'll show the | ||
"All tests have completed successfully" message in the end. Otherwise, it'll print paths to zombienet | ||
process logs, which, in turn, may be used to track locations of all spinned relay and parachain nodes. |
25 changes: 25 additions & 0 deletions
25
system-parachains/bridge-hubs/zombienet/helpers/best-finalized-header-at-bridged-chain.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
async function run(nodeName, networkInfo, args) { | ||
const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName]; | ||
const api = await zombie.connect(wsUri, userDefinedTypes); | ||
|
||
// TODO: could be replaced with https://github.com/polkadot-js/api/issues/4930 (depends on metadata v15) later | ||
const bridgedChainName = args[0]; | ||
const expectedBridgedChainHeaderNumber = Number(args[1]); | ||
const runtimeApiMethod = bridgedChainName + "FinalityApi_best_finalized"; | ||
|
||
while (true) { | ||
const encodedBestFinalizedHeaderId = await api.rpc.state.call(runtimeApiMethod, []); | ||
const bestFinalizedHeaderId = api.createType("Option<BpRuntimeHeaderId>", encodedBestFinalizedHeaderId); | ||
if (bestFinalizedHeaderId.isSome) { | ||
const bestFinalizedHeaderNumber = Number(bestFinalizedHeaderId.unwrap().toHuman()[0]); | ||
if (bestFinalizedHeaderNumber > expectedBridgedChainHeaderNumber) { | ||
return bestFinalizedHeaderNumber; | ||
} | ||
} | ||
|
||
// else sleep and retry | ||
await new Promise((resolve) => setTimeout(resolve, 12000)); | ||
} | ||
} | ||
|
||
module.exports = { run } |
28 changes: 28 additions & 0 deletions
28
system-parachains/bridge-hubs/zombienet/helpers/relayer-rewards.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
async function run(nodeName, networkInfo, args) { | ||
const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName]; | ||
const api = await zombie.connect(wsUri, userDefinedTypes); | ||
|
||
// TODO: could be replaced with https://github.com/polkadot-js/api/issues/4930 (depends on metadata v15) later | ||
const relayerAccountAddress = args[0]; | ||
const laneId = args[1]; | ||
const bridgedChainId = args[2]; | ||
const relayerFundOwner = args[3]; | ||
const expectedRelayerReward = BigInt(args[4]); | ||
while (true) { | ||
const relayerReward = await api.query.bridgeRelayers.relayerRewards( | ||
relayerAccountAddress, | ||
{ laneId: laneId, bridgedChainId: bridgedChainId, owner: relayerFundOwner } | ||
); | ||
if (relayerReward.isSome) { | ||
const relayerRewardBalance = relayerReward.unwrap().toBigInt(); | ||
if (relayerRewardBalance > expectedRelayerReward) { | ||
return relayerRewardBalance; | ||
} | ||
} | ||
|
||
// else sleep and retry | ||
await new Promise((resolve) => setTimeout(resolve, 12000)); | ||
} | ||
} | ||
|
||
module.exports = { run } |
23 changes: 23 additions & 0 deletions
23
system-parachains/bridge-hubs/zombienet/helpers/wait-hrmp-channel-opened.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
async function run(nodeName, networkInfo, args) { | ||
const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName]; | ||
const api = await zombie.connect(wsUri, userDefinedTypes); | ||
|
||
// TODO: could be replaced with https://github.com/polkadot-js/api/issues/4930 (depends on metadata v15) later | ||
const sibling = args[0]; | ||
|
||
while (true) { | ||
const messagingStateAsObj = await api.query.parachainSystem.relevantMessagingState(); | ||
const messagingState = api.createType("Option<CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot>", messagingStateAsObj); | ||
if (messagingState.isSome) { | ||
const egressChannels = messagingState.unwrap().egressChannels; | ||
if (egressChannels.find(x => x[0] == sibling)) { | ||
return; | ||
} | ||
} | ||
|
||
// else sleep and retry | ||
await new Promise((resolve) => setTimeout(resolve, 12000)); | ||
} | ||
} | ||
|
||
module.exports = { run } |
26 changes: 26 additions & 0 deletions
26
system-parachains/bridge-hubs/zombienet/helpers/wrapped-assets-balance.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
async function run(nodeName, networkInfo, args) { | ||
const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName]; | ||
const api = await zombie.connect(wsUri, userDefinedTypes); | ||
|
||
// TODO: could be replaced with https://github.com/polkadot-js/api/issues/4930 (depends on metadata v15) later | ||
const accountAddress = args[0]; | ||
const expectedForeignAssetBalance = BigInt(args[1]); | ||
const bridgedNetworkName = args[2]; | ||
while (true) { | ||
const foreignAssetAccount = await api.query.foreignAssets.account( | ||
{ parents: 2, interior: { X1: { GlobalConsensus: bridgedNetworkName } } }, | ||
accountAddress | ||
); | ||
if (foreignAssetAccount.isSome) { | ||
const foreignAssetAccountBalance = foreignAssetAccount.unwrap().balance.toBigInt(); | ||
if (foreignAssetAccountBalance > expectedForeignAssetBalance) { | ||
return foreignAssetAccountBalance; | ||
} | ||
} | ||
|
||
// else sleep and retry | ||
await new Promise((resolve) => setTimeout(resolve, 12000)); | ||
} | ||
} | ||
|
||
module.exports = { run } |
89 changes: 89 additions & 0 deletions
89
system-parachains/bridge-hubs/zombienet/networks/asset-hub-kusama-local.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
"name": "Kusama Asset Hub Local Testnet", | ||
"id": "asset-hub-kusama-local", | ||
"chainType": "Local", | ||
"relay_chain": "kusama-local", | ||
"para_id": 1000, | ||
"consensusEngine": null, | ||
"bootNodes": [], | ||
"telemetryEndpoints": null, | ||
"protocolId": "dot", | ||
"properties": { | ||
"ss58Format": 2 | ||
}, | ||
"genesis": { | ||
"runtime": { | ||
"aura": { | ||
"authorities": [] | ||
}, | ||
"session": { | ||
"keys": [] | ||
}, | ||
"collatorSelection": { | ||
"invulnerables": [], | ||
"desiredCandidates": 0, | ||
"candidacyBond": 0 | ||
}, | ||
"system": {}, | ||
"parachainInfo": { | ||
"parachainId": 1000 | ||
}, | ||
"parachainSystem": {}, | ||
"polkadotXcm": { | ||
"safeXcmVersion": 3 | ||
}, | ||
"balances": { | ||
"balances": [ | ||
[ | ||
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
99000000000000 | ||
], | ||
[ | ||
"5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", | ||
99000000000000 | ||
], | ||
[ | ||
"5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y", | ||
99000000000000 | ||
], | ||
[ | ||
"5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy", | ||
99000000000000 | ||
], | ||
[ | ||
"5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", | ||
99000000000000 | ||
], | ||
[ | ||
"5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL", | ||
99000000000000 | ||
], | ||
[ | ||
"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", | ||
99000000000000 | ||
], | ||
[ | ||
"5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc", | ||
99000000000000 | ||
], | ||
[ | ||
"5Ck5SLSHYac6WFt5UZRSsdJjwmpSZq85fd5TRNAdZQVzEAPT", | ||
99000000000000 | ||
], | ||
[ | ||
"5HKPmK9GYtE1PSLsS1qiYU9xQ9Si1NcEhdeCq9sw5bqu4ns8", | ||
99000000000000 | ||
], | ||
[ | ||
"5FCfAonRZgTFrTd9HREEyeJjDpT397KMzizE6T3DvebLFE7n", | ||
99000000000000 | ||
], | ||
[ | ||
"5CRmqmsiNFExV6VbdmPJViVxrWmkaXXvBrSX8oqBT8R9vmWk", | ||
99000000000000 | ||
] | ||
] | ||
} | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
system-parachains/bridge-hubs/zombienet/networks/asset-hub-polkadot-local.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"name": "Polkadot Asset Hub Local Testnet", | ||
"id": "asset-hub-polkadot-local", | ||
"chainType": "Local", | ||
"relay_chain": "polkadot-local", | ||
"para_id": 1000, | ||
"consensusEngine": null, | ||
"bootNodes": [], | ||
"telemetryEndpoints": null, | ||
"protocolId": "dot", | ||
"properties": { | ||
"ss58Format": 0, | ||
"tokenDecimals": 10 | ||
}, | ||
"genesis": { | ||
"runtime": { | ||
"aura": { | ||
"authorities": [] | ||
}, | ||
"session": { | ||
"keys": [] | ||
}, | ||
"collatorSelection": { | ||
"invulnerables": [], | ||
"desiredCandidates": 0, | ||
"candidacyBond": 0 | ||
}, | ||
"system": {}, | ||
"parachainInfo": { | ||
"parachainId": 1000 | ||
}, | ||
"parachainSystem": {}, | ||
"polkadotXcm": { | ||
"safeXcmVersion": 3 | ||
}, | ||
"balances": { | ||
"balances": [ | ||
[ | ||
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
99000000000000 | ||
], | ||
[ | ||
"5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", | ||
99000000000000 | ||
], | ||
[ | ||
"5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y", | ||
99000000000000 | ||
], | ||
[ | ||
"5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy", | ||
99000000000000 | ||
], | ||
[ | ||
"5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", | ||
99000000000000 | ||
], | ||
[ | ||
"5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL", | ||
99000000000000 | ||
], | ||
[ | ||
"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", | ||
99000000000000 | ||
], | ||
[ | ||
"5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc", | ||
99000000000000 | ||
], | ||
[ | ||
"5Ck5SLSHYac6WFt5UZRSsdJjwmpSZq85fd5TRNAdZQVzEAPT", | ||
99000000000000 | ||
], | ||
[ | ||
"5HKPmK9GYtE1PSLsS1qiYU9xQ9Si1NcEhdeCq9sw5bqu4ns8", | ||
99000000000000 | ||
], | ||
[ | ||
"5FCfAonRZgTFrTd9HREEyeJjDpT397KMzizE6T3DvebLFE7n", | ||
99000000000000 | ||
], | ||
[ | ||
"5CRmqmsiNFExV6VbdmPJViVxrWmkaXXvBrSX8oqBT8R9vmWk", | ||
99000000000000 | ||
] | ||
] | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.