From d5777113786a6950fe50bc2355edfe0fb88df9d5 Mon Sep 17 00:00:00 2001 From: Matjaz Verbole Date: Tue, 10 Sep 2024 14:53:58 +0200 Subject: [PATCH 1/5] Validate configuration inside GitHub PR actions --- .github/workflows/pr.yaml | 6 +++++- package.json | 1 + scripts/validateConfig.ts | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 scripts/validateConfig.ts diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 9dde3245c..f937c90f0 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -30,4 +30,8 @@ jobs: echo "Running format is required" exit 1 fi - - run: yarn test + - name: Validate configuration + run: yarn validate-config + - name: Test + shell: bash + run: yarn test diff --git a/package.json b/package.json index 853257556..d9d3febf8 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "lint-fix": "yarn eslint --fix && yarn prettier --write", "format": "prettier --write '**/*'", "eslint": "eslint .", + "validate-config": "yarn ts-node ./scripts/validateConfig.ts", "test": "RELAYER_TEST=true hardhat test", "build": "tsc --build", "watch": "tsc --build --incremental --watch", diff --git a/scripts/validateConfig.ts b/scripts/validateConfig.ts new file mode 100644 index 000000000..a683f3145 --- /dev/null +++ b/scripts/validateConfig.ts @@ -0,0 +1,38 @@ +import { RelayerConfig } from "../src/relayer/RelayerConfig"; + +// Example run: +// ts-node ./scripts/validateConfig.ts + +export async function run(): Promise { + console.log("Validating config"); + + const env: NodeJS.ProcessEnv = { + MAX_RELAYER_DEPOSIT_LOOK_BACK: "1800", + RELAYER_TOKENS: + '["0x16B840bA01e2b05fc2268eAf6d18892a11EC29D6", "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0", "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"]', + MIN_DEPOSIT_CONFIRMATIONS: + '{ "1000000": { "919": 1, "4202": 1, "80002": 1, "84532": 1, "421614": 1, "11155111": 1, "11155420": 1 } }', + RELAYER_IGNORE_LIMITS: "true", + RELAYER_ORIGIN_CHAINS: JSON.stringify([11155111, 4202]), + RELAYER_DESTINATION_CHAINS: JSON.stringify([11155111, 4202]), + HUB_CHAIN_ID: "11155111", + SEND_REBALANCES: "true", + RELAYER_EXTERNAL_INVENTORY_CONFIG: "config/mainnet/relayerExternalInventory.json", + }; + new RelayerConfig(env); + + console.log("Config is valid"); +} + +if (require.main === module) { + run() + .then(async () => { + // eslint-disable-next-line no-process-exit + process.exit(0); + }) + .catch(async (error) => { + console.error("Process exited with", error); + // eslint-disable-next-line no-process-exit + process.exit(1); + }); +} From aadb96e344d12160807ee5ecd5bc8e886476efec Mon Sep 17 00:00:00 2001 From: Matjaz Verbole Date: Tue, 10 Sep 2024 16:31:01 +0200 Subject: [PATCH 2/5] Remove unneeded environment variables --- scripts/validateConfig.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/validateConfig.ts b/scripts/validateConfig.ts index a683f3145..0674920ad 100644 --- a/scripts/validateConfig.ts +++ b/scripts/validateConfig.ts @@ -7,16 +7,12 @@ export async function run(): Promise { console.log("Validating config"); const env: NodeJS.ProcessEnv = { - MAX_RELAYER_DEPOSIT_LOOK_BACK: "1800", RELAYER_TOKENS: - '["0x16B840bA01e2b05fc2268eAf6d18892a11EC29D6", "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0", "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"]', + '["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "0x6033F7f88332B8db6ad452B7C6D5bB643990aE3f", "0xdAC17F958D2ee523a2206206994597C13D831ec7"]', MIN_DEPOSIT_CONFIRMATIONS: - '{ "1000000": { "919": 1, "4202": 1, "80002": 1, "84532": 1, "421614": 1, "11155111": 1, "11155420": 1 } }', - RELAYER_IGNORE_LIMITS: "true", - RELAYER_ORIGIN_CHAINS: JSON.stringify([11155111, 4202]), - RELAYER_DESTINATION_CHAINS: JSON.stringify([11155111, 4202]), - HUB_CHAIN_ID: "11155111", - SEND_REBALANCES: "true", + '{"5000": { "1": 5, "1135": 10 }, "2000": { "1": 4, "1135": 10 }, "100": { "1": 3, "1135": 10 } }', + RELAYER_ORIGIN_CHAINS: JSON.stringify([1,1135]), + RELAYER_DESTINATION_CHAINS: JSON.stringify([1,1135]), RELAYER_EXTERNAL_INVENTORY_CONFIG: "config/mainnet/relayerExternalInventory.json", }; new RelayerConfig(env); From fc0118067a0ef52880a2a55d8022c2df2112fa2e Mon Sep 17 00:00:00 2001 From: Matjaz Verbole Date: Thu, 12 Sep 2024 13:10:15 +0200 Subject: [PATCH 3/5] Intentionally invalidate config to check if GH Action will fail --- config/mainnet/relayerExternalInventory.json | 1 - 1 file changed, 1 deletion(-) diff --git a/config/mainnet/relayerExternalInventory.json b/config/mainnet/relayerExternalInventory.json index 334e1481a..aa31521f0 100644 --- a/config/mainnet/relayerExternalInventory.json +++ b/config/mainnet/relayerExternalInventory.json @@ -33,7 +33,6 @@ "USDT": { "1135": { "targetPct": 30, - "thresholdPct": 10, "targetOverageBuffer": 1.5 } } From 6d4085bfd43519f7fed167eb9ddc70db6e0a3970 Mon Sep 17 00:00:00 2001 From: Matjaz Verbole Date: Thu, 12 Sep 2024 13:21:28 +0200 Subject: [PATCH 4/5] Fix formatting --- scripts/validateConfig.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/validateConfig.ts b/scripts/validateConfig.ts index 0674920ad..82b1d9743 100644 --- a/scripts/validateConfig.ts +++ b/scripts/validateConfig.ts @@ -11,8 +11,8 @@ export async function run(): Promise { '["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "0x6033F7f88332B8db6ad452B7C6D5bB643990aE3f", "0xdAC17F958D2ee523a2206206994597C13D831ec7"]', MIN_DEPOSIT_CONFIRMATIONS: '{"5000": { "1": 5, "1135": 10 }, "2000": { "1": 4, "1135": 10 }, "100": { "1": 3, "1135": 10 } }', - RELAYER_ORIGIN_CHAINS: JSON.stringify([1,1135]), - RELAYER_DESTINATION_CHAINS: JSON.stringify([1,1135]), + RELAYER_ORIGIN_CHAINS: JSON.stringify([1, 1135]), + RELAYER_DESTINATION_CHAINS: JSON.stringify([1, 1135]), RELAYER_EXTERNAL_INVENTORY_CONFIG: "config/mainnet/relayerExternalInventory.json", }; new RelayerConfig(env); From c23272c189a77ade4c32858ea301974e58e9a81e Mon Sep 17 00:00:00 2001 From: Matjaz Verbole Date: Thu, 12 Sep 2024 13:54:47 +0200 Subject: [PATCH 5/5] Revert "Intentionally invalidate config to check if GH Action will fail" This reverts commit fc0118067a0ef52880a2a55d8022c2df2112fa2e. --- config/mainnet/relayerExternalInventory.json | 1 + 1 file changed, 1 insertion(+) diff --git a/config/mainnet/relayerExternalInventory.json b/config/mainnet/relayerExternalInventory.json index aa31521f0..334e1481a 100644 --- a/config/mainnet/relayerExternalInventory.json +++ b/config/mainnet/relayerExternalInventory.json @@ -33,6 +33,7 @@ "USDT": { "1135": { "targetPct": 30, + "thresholdPct": 10, "targetOverageBuffer": 1.5 } }