From c205084f9c2b86eb5d6b7a9bb0b2c3aec0dd39c2 Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Thu, 21 Dec 2023 10:03:49 +0200 Subject: [PATCH 1/8] Revert "chore: remove unused import" This reverts commit 8bae7b4d6b639503e391d91e14ad4891f2a26ef7. --- scripts/interlay-chopsticks-test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/interlay-chopsticks-test.ts b/scripts/interlay-chopsticks-test.ts index f4e96c7..9b53ae3 100644 --- a/scripts/interlay-chopsticks-test.ts +++ b/scripts/interlay-chopsticks-test.ts @@ -4,6 +4,7 @@ import { PolkadotAdapter } from "../src/adapters/polkadot"; import { InterlayAdapter } from "../src/adapters/interlay"; import { StatemintAdapter } from "../src/adapters/statemint"; +import { HydraAdapter } from "../src/adapters/hydradx"; import { AcalaAdapter } from "../src/adapters/acala"; import { ParallelAdapter } from "../src/adapters/parallel"; import { BifrostPolkadotAdapter } from "../src/adapters/bifrost"; From 82d64584c55f19da49d4212d7a4550fa151254c5 Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Thu, 21 Dec 2023 10:03:54 +0200 Subject: [PATCH 2/8] Revert "test: disable hydra tests - rpc too flaky" This reverts commit ed137e0d06dd73c17c39b2fb37d18935bf340802. --- .github/workflows/xcm-tests.yml | 1 + scripts/interlay-chopsticks-test.ts | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/xcm-tests.yml b/.github/workflows/xcm-tests.yml index eedeb0c..3194195 100644 --- a/.github/workflows/xcm-tests.yml +++ b/.github/workflows/xcm-tests.yml @@ -69,6 +69,7 @@ jobs: -r scripts/configs/polkadot.yml \ -p scripts/configs/interlay.yml \ -p scripts/configs/statemint.yml \ + -p scripts/configs/hydradx.yml \ -p scripts/configs/acala.yml \ -p scripts/configs/parallel.yml \ -p scripts/configs/bifrost-polkadot.yml \ diff --git a/scripts/interlay-chopsticks-test.ts b/scripts/interlay-chopsticks-test.ts index 9b53ae3..e40f9a2 100644 --- a/scripts/interlay-chopsticks-test.ts +++ b/scripts/interlay-chopsticks-test.ts @@ -25,21 +25,18 @@ async function main(): Promise { // relaychain gets its port last after all parachains. interlay: { adapter: new InterlayAdapter(), endpoints: ['ws://127.0.0.1:8000'] }, statemint: { adapter: new StatemintAdapter(), endpoints: ['ws://127.0.0.1:8001'] }, - // disable hydra - rpc too flaky to use in regular test runs - // hydra: { adapter: new HydraAdapter(), endpoints: ['ws://127.0.0.1:8002'] }, - acala: { adapter: new AcalaAdapter(), endpoints: ['ws://127.0.0.1:8002'] }, + hydra: { adapter: new HydraAdapter(), endpoints: ['ws://127.0.0.1:8002'] }, + acala: { adapter: new AcalaAdapter(), endpoints: ['ws://127.0.0.1:8003'] }, // disable astar - rpc currently is too fragile for use in recurring tests // astar: { adapter: new AstarAdapter(), endpoints: ['ws://127.0.0.1:8004'] }, - parallel: { adapter: new ParallelAdapter(), endpoints: ['ws://127.0.0.1:8003'] }, - bifrost_polkadot: { adapter: new BifrostPolkadotAdapter(), endpoints: ['ws://127.0.0.1:8004']}, - polkadot: { adapter: new PolkadotAdapter(), endpoints: ['ws://127.0.0.1:8005'] }, + parallel: { adapter: new ParallelAdapter(), endpoints: ['ws://127.0.0.1:8004'] }, + bifrost_polkadot: { adapter: new BifrostPolkadotAdapter(), endpoints: ['ws://127.0.0.1:8005']}, + polkadot: { adapter: new PolkadotAdapter(), endpoints: ['ws://127.0.0.1:8006'] }, }; const filterCases: Partial[] = [ {from: "astar"}, {to: "astar"}, - {from: "hydra"}, - {to: "hydra"}, ]; await runTestCasesAndExit(adaptersEndpoints, filterCases); From 0ca8a0c234278037ccbc6681680fe9e50b33c830 Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Thu, 21 Dec 2023 10:19:43 +0200 Subject: [PATCH 3/8] test: use modified amount to check ED for hydra --- scripts/chopsticks-test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/chopsticks-test.ts b/scripts/chopsticks-test.ts index 5c8ed53..c00537e 100644 --- a/scripts/chopsticks-test.ts +++ b/scripts/chopsticks-test.ts @@ -137,6 +137,17 @@ async function checkTransfer(fromChain: ChainName, toChain: ChainName, token: st // check existential deposit by sending exactly `actualFee + ed + [1 planck]`. The function // will throw an error if the ed is set too low. let amountToSend = actualFee.add(expectedEd).add(FN.fromInner("1", actualFee.getPrecision())); + + if (toChain === "hydra") { + // bump amount to send by a few percent for XCM to HydraDX + // token/HDX price pair changes can make this fail due to change from previous tx + const bumpRate = 0.1; + amountToSend = amountToSend.mul(FN.fromInner(1 + bumpRate)); + ret = { + message: `Modified ED check for ${token} to ${toChain} - price changes in ${token}/HDX can cause false negatives. Bumped test amount by ${bumpRate * 100}%`, + result: ResultCode.WARN + }; + } await sendTx(fromChain, toChain, token, bridge, amountToSend, TestCase.ExistentialDeposit); return ret; From 1e212c2adafab49c3cc9fee6e40c49434ceabda0 Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Thu, 21 Dec 2023 10:40:38 +0200 Subject: [PATCH 4/8] chore: only apply multiplier to fee, not entire amount --- scripts/chopsticks-test.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/chopsticks-test.ts b/scripts/chopsticks-test.ts index c00537e..d71cd27 100644 --- a/scripts/chopsticks-test.ts +++ b/scripts/chopsticks-test.ts @@ -136,15 +136,17 @@ async function checkTransfer(fromChain: ChainName, toChain: ChainName, token: st // check existential deposit by sending exactly `actualFee + ed + [1 planck]`. The function // will throw an error if the ed is set too low. - let amountToSend = actualFee.add(expectedEd).add(FN.fromInner("1", actualFee.getPrecision())); + const dust = FN.fromInner("1", actualFee.getPrecision()); + let amountToSend = actualFee.add(expectedEd).add(dust); if (toChain === "hydra") { - // bump amount to send by a few percent for XCM to HydraDX - // token/HDX price pair changes can make this fail due to change from previous tx + // bump fees in amount to send by a few percent for XCM to HydraDX + // token/HDX price pair changes can make this fail due to pair changes from previous tx increasing fee required const bumpRate = 0.1; - amountToSend = amountToSend.mul(FN.fromInner(1 + bumpRate)); + const bumpedFee = actualFee.mul(FN.fromInner(1 + bumpRate)); + amountToSend = bumpedFee.add(expectedEd).add(dust); ret = { - message: `Modified ED check for ${token} to ${toChain} - price changes in ${token}/HDX can cause false negatives. Bumped test amount by ${bumpRate * 100}%`, + message: `Modified ED check for ${token} to ${toChain} - price changes in ${token}/HDX can cause false negatives. Bumped assumed fees by ${bumpRate * 100}%`, result: ResultCode.WARN }; } From f8acf44bf9a3e8b08403aa9df3926b7c642ddc8b Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Thu, 21 Dec 2023 11:09:52 +0200 Subject: [PATCH 5/8] fix: incorrect use of FN.fromInner, accept WARN results without triggering a retry --- scripts/chopsticks-test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/chopsticks-test.ts b/scripts/chopsticks-test.ts index d71cd27..ce8e9be 100644 --- a/scripts/chopsticks-test.ts +++ b/scripts/chopsticks-test.ts @@ -142,11 +142,11 @@ async function checkTransfer(fromChain: ChainName, toChain: ChainName, token: st if (toChain === "hydra") { // bump fees in amount to send by a few percent for XCM to HydraDX // token/HDX price pair changes can make this fail due to pair changes from previous tx increasing fee required - const bumpRate = 0.1; - const bumpedFee = actualFee.mul(FN.fromInner(1 + bumpRate)); + const bumpRate = new FN(1.1); + const bumpedFee = actualFee.mul(bumpRate); amountToSend = bumpedFee.add(expectedEd).add(dust); ret = { - message: `Modified ED check for ${token} to ${toChain} - price changes in ${token}/HDX can cause false negatives. Bumped assumed fees by ${bumpRate * 100}%`, + message: `Modified ED check for ${token} to ${toChain} - price changes in ${token}/HDX can cause false negatives. Bumped assumed fees by ${bumpRate.minus(FN.ONE).toNumber() * 100}%`, result: ResultCode.WARN }; } @@ -171,7 +171,8 @@ async function retryCheckTransfer( ): Promise>> { const result = await checkTransfer(fromChain, toChain, token, bridge); - if (result.result === ResultCode.OK) { + // OK or WARN are fine, only retry on failures + if (result.result === ResultCode.OK || result.result === ResultCode.WARN) { return result; } From e564662ccc570b2a0e62320a148187f3d2d57b83 Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Thu, 21 Dec 2023 11:35:30 +0200 Subject: [PATCH 6/8] test: undo WARN/OK handling, instead log test result message if it exists regardless of status --- scripts/chopsticks-test.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/chopsticks-test.ts b/scripts/chopsticks-test.ts index ce8e9be..696e2d6 100644 --- a/scripts/chopsticks-test.ts +++ b/scripts/chopsticks-test.ts @@ -147,7 +147,7 @@ async function checkTransfer(fromChain: ChainName, toChain: ChainName, token: st amountToSend = bumpedFee.add(expectedEd).add(dust); ret = { message: `Modified ED check for ${token} to ${toChain} - price changes in ${token}/HDX can cause false negatives. Bumped assumed fees by ${bumpRate.minus(FN.ONE).toNumber() * 100}%`, - result: ResultCode.WARN + result: ResultCode.OK }; } await sendTx(fromChain, toChain, token, bridge, amountToSend, TestCase.ExistentialDeposit); @@ -171,8 +171,7 @@ async function retryCheckTransfer( ): Promise>> { const result = await checkTransfer(fromChain, toChain, token, bridge); - // OK or WARN are fine, only retry on failures - if (result.result === ResultCode.OK || result.result === ResultCode.WARN) { + if (result.result === ResultCode.OK) { return result; } @@ -274,8 +273,11 @@ export async function runTestCasesAndExit( process.stdout.write(`Testing ${token} transfer from ${from} to ${to}... `); const result = await retryCheckTransfer(from, to, token, bridge, 2); console.log(ResultCode[result.result]); - if (result.result != ResultCode.OK) { + if (result.message?.length > 0) { console.log(iconOf(result.result), result.message); + } + + if (result.result != ResultCode.OK) { problematicTestCases.push({from: from as ChainName, to: to as ChainName, token, icon: iconOf(result.result), message: result.message}); if (aggregateTestResult == ResultCode.OK || (aggregateTestResult == ResultCode.WARN && result.result == ResultCode.FAIL)) { // only 'increase' the aggregate error From 7eb0ad862d14154126246eb7c46f965ad28eb9e0 Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Thu, 21 Dec 2023 12:00:32 +0200 Subject: [PATCH 7/8] chore: add multiple wss endpoints to kusama config --- scripts/configs/kusama.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/configs/kusama.yml b/scripts/configs/kusama.yml index be92115..7a8e2b2 100644 --- a/scripts/configs/kusama.yml +++ b/scripts/configs/kusama.yml @@ -1,5 +1,6 @@ -# endpoint: wss://kusama-rpc.dwellir.com -endpoint: wss://kusama-rpc.polkadot.io +endpoint: + - wss://kusama-rpc.dwellir.com + - wss://kusama-rpc.dwellir.com mock-signature-host: true block: ${env.KUSAMA_BLOCK_NUMBER} db: ./db.sqlite From 3a2f5c5e2e54ef1d6e9314c975f522a65b0917ee Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Thu, 21 Dec 2023 12:27:22 +0200 Subject: [PATCH 8/8] testing: switch order of polkadot wss endpoints in config --- scripts/configs/polkadot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/configs/polkadot.yml b/scripts/configs/polkadot.yml index 19b9055..466357f 100644 --- a/scripts/configs/polkadot.yml +++ b/scripts/configs/polkadot.yml @@ -1,6 +1,6 @@ endpoint: - - wss://rpc.polkadot.io - wss://polkadot-rpc.dwellir.com + - wss://rpc.polkadot.io mock-signature-host: true block: ${env.POLKADOT_BLOCK_NUMBER} db: ./db.sqlite