From 275e6b8b7f353ce1e26d26d7630f1c28cb49212f Mon Sep 17 00:00:00 2001 From: Derek Croote Date: Sun, 22 Sep 2024 13:30:22 -0700 Subject: [PATCH 1/5] feat: add script to validate chain-support.json --- .github/workflows/validate-verify.yml | 3 ++ package.json | 1 + scripts/validate-chain-support.ts | 51 +++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 scripts/validate-chain-support.ts diff --git a/.github/workflows/validate-verify.yml b/.github/workflows/validate-verify.yml index d898990..ce5a787 100644 --- a/.github/workflows/validate-verify.yml +++ b/.github/workflows/validate-verify.yml @@ -32,6 +32,9 @@ jobs: - name: Validate deployment config run: pnpm validate-deployment-config + - name: Validate chain support + run: pnpm validate-chain-support + - name: Validate deployments run: pnpm validate-deployments if: always() diff --git a/package.json b/package.json index 356c98d..f286456 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "test:coverage": "hardhat coverage", "test:extended": "EXTENDED_TEST=TRUE hardhat test --parallel", "test:gas": "REPORT_GAS=TRUE hardhat test", + "validate-chain-support": "ts-node scripts/validate-chain-support.ts", "validate-deployment-config": "hardhat run scripts/validate-deployment-config.ts", "validate-deployments": "hardhat run scripts/validate-deployments.ts", "verify-deployments": "hardhat run scripts/verify-deployments.ts", diff --git a/scripts/validate-chain-support.ts b/scripts/validate-chain-support.ts new file mode 100644 index 0000000..5e35d74 --- /dev/null +++ b/scripts/validate-chain-support.ts @@ -0,0 +1,51 @@ +import chainSupport from '../data/chain-support.json'; + +async function checkSortedList(list: string[]): Promise { + const sortedList = [...list].sort(); + if (JSON.stringify(list) !== JSON.stringify(sortedList)) { + throw new Error(`List unsorted`); + } +} + +async function checkDuplicates(list: string[]): Promise { + const hasDuplicates = new Set(list).size !== list.length; + if (hasDuplicates) { + throw new Error(`Duplicates found`); + } +} + +async function main(fieldLists: Record): Promise { + const errors: Error[] = []; + for (const field in fieldLists) { + const list = fieldLists[field]; + if (!list || list.length === 0) { + errors.push(new Error(`Empty list found for field: ${field}`)); + continue; + } + + const validations = [checkDuplicates, checkSortedList]; + await Promise.all( + validations.map(async (validation) => { + try { + await validation(list); + } catch (error) { + errors.push(new Error(String((error as Error).message) + ` in field: ${field}`)); + } + }) + ); + } + if (errors.length > 0) { + // eslint-disable-next-line no-console + console.error('Validation failed with the following error(s):\n' + errors.join('\n')); + // eslint-disable-next-line unicorn/no-process-exit + process.exit(1); + } +} + +/* eslint-disable */ +main(chainSupport) + .then(() => process.exit(0)) + .catch((error) => { + console.log(error); + process.exit(1); + }); From ba38f427261422be7a3692797df75caadfc0b646 Mon Sep 17 00:00:00 2001 From: Derek Croote Date: Sun, 22 Sep 2024 13:30:46 -0700 Subject: [PATCH 2/5] fix: errors in chain-support.json revealed by script --- data/chain-support.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/data/chain-support.json b/data/chain-support.json index 2a8b182..7f6ad92 100644 --- a/data/chain-support.json +++ b/data/chain-support.json @@ -19,7 +19,6 @@ "bsc", "bsc-testnet", "bsquared", - "blast-sepolia-testnet", "camp-sepolia-testnet", "conflux", "conflux-testnet", @@ -77,10 +76,10 @@ "rari", "rari-arbitrum-sepolia-testnet", "rsk", - "sei", - "sei-testnet", "scroll", "scroll-sepolia-testnet", + "sei", + "sei-testnet", "soneium-sepolia-testnet", "sonic-testnet", "taiko", @@ -166,10 +165,10 @@ "polygon-zkevm-sepolia-testnet", "rari", "rari-arbitrum-sepolia-testnet", - "sei", - "sei-testnet", "scroll", "scroll-sepolia-testnet", + "sei", + "sei-testnet", "soneium-sepolia-testnet", "sonic-testnet", "taiko", From 862eb7c8e44981ea39f6f8c3e6fabc3a11794ac9 Mon Sep 17 00:00:00 2001 From: Derek Croote Date: Sun, 22 Sep 2024 13:43:59 -0700 Subject: [PATCH 3/5] fix: lints --- scripts/validate-chain-support.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/validate-chain-support.ts b/scripts/validate-chain-support.ts index 5e35d74..0cc428e 100644 --- a/scripts/validate-chain-support.ts +++ b/scripts/validate-chain-support.ts @@ -29,14 +29,14 @@ async function main(fieldLists: Record): Promise { try { await validation(list); } catch (error) { - errors.push(new Error(String((error as Error).message) + ` in field: ${field}`)); + errors.push(new Error(`${(error as Error).message} in field: ${field}`)); } }) ); } if (errors.length > 0) { // eslint-disable-next-line no-console - console.error('Validation failed with the following error(s):\n' + errors.join('\n')); + console.error(`Validation failed with the following error(s):\n${errors.join('\n')}`); // eslint-disable-next-line unicorn/no-process-exit process.exit(1); } From 250f3f06f90d1d87638b2b48f3f01868be7cd101 Mon Sep 17 00:00:00 2001 From: Derek Croote Date: Mon, 23 Sep 2024 23:50:42 -0700 Subject: [PATCH 4/5] Move duplicate and sort checking to validate-deployment-config.ts --- .github/workflows/validate-verify.yml | 3 -- package.json | 1 - scripts/validate-chain-support.ts | 51 --------------------------- scripts/validate-deployment-config.ts | 20 ++++++++--- 4 files changed, 15 insertions(+), 60 deletions(-) delete mode 100644 scripts/validate-chain-support.ts diff --git a/.github/workflows/validate-verify.yml b/.github/workflows/validate-verify.yml index ce5a787..d898990 100644 --- a/.github/workflows/validate-verify.yml +++ b/.github/workflows/validate-verify.yml @@ -32,9 +32,6 @@ jobs: - name: Validate deployment config run: pnpm validate-deployment-config - - name: Validate chain support - run: pnpm validate-chain-support - - name: Validate deployments run: pnpm validate-deployments if: always() diff --git a/package.json b/package.json index f286456..356c98d 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "test:coverage": "hardhat coverage", "test:extended": "EXTENDED_TEST=TRUE hardhat test --parallel", "test:gas": "REPORT_GAS=TRUE hardhat test", - "validate-chain-support": "ts-node scripts/validate-chain-support.ts", "validate-deployment-config": "hardhat run scripts/validate-deployment-config.ts", "validate-deployments": "hardhat run scripts/validate-deployments.ts", "verify-deployments": "hardhat run scripts/verify-deployments.ts", diff --git a/scripts/validate-chain-support.ts b/scripts/validate-chain-support.ts deleted file mode 100644 index 0cc428e..0000000 --- a/scripts/validate-chain-support.ts +++ /dev/null @@ -1,51 +0,0 @@ -import chainSupport from '../data/chain-support.json'; - -async function checkSortedList(list: string[]): Promise { - const sortedList = [...list].sort(); - if (JSON.stringify(list) !== JSON.stringify(sortedList)) { - throw new Error(`List unsorted`); - } -} - -async function checkDuplicates(list: string[]): Promise { - const hasDuplicates = new Set(list).size !== list.length; - if (hasDuplicates) { - throw new Error(`Duplicates found`); - } -} - -async function main(fieldLists: Record): Promise { - const errors: Error[] = []; - for (const field in fieldLists) { - const list = fieldLists[field]; - if (!list || list.length === 0) { - errors.push(new Error(`Empty list found for field: ${field}`)); - continue; - } - - const validations = [checkDuplicates, checkSortedList]; - await Promise.all( - validations.map(async (validation) => { - try { - await validation(list); - } catch (error) { - errors.push(new Error(`${(error as Error).message} in field: ${field}`)); - } - }) - ); - } - if (errors.length > 0) { - // eslint-disable-next-line no-console - console.error(`Validation failed with the following error(s):\n${errors.join('\n')}`); - // eslint-disable-next-line unicorn/no-process-exit - process.exit(1); - } -} - -/* eslint-disable */ -main(chainSupport) - .then(() => process.exit(0)) - .catch((error) => { - console.log(error); - process.exit(1); - }); diff --git a/scripts/validate-deployment-config.ts b/scripts/validate-deployment-config.ts index ff5bcad..2ab4b61 100644 --- a/scripts/validate-deployment-config.ts +++ b/scripts/validate-deployment-config.ts @@ -10,18 +10,28 @@ import managerMultisigAddresses from '../data/manager-multisig.json'; function main() { const chainAliases = new Set(CHAINS.map((chain) => chain.alias)); - [ - Object.keys(managerMultisigAddresses), + const records: Record = { + managerMultisigAddresses: Object.keys(managerMultisigAddresses), chainsSupportedByDapis, chainsSupportedByMarket, chainsSupportedByOevAuctions, - ].map((supportedChainAliases) => { - supportedChainAliases.map((supportedChainAlias) => { + }; + + Object.entries(records).forEach(([fieldName, supportedChainAliases]) => { + supportedChainAliases.forEach((supportedChainAlias) => { if (!chainAliases.has(supportedChainAlias)) { - throw new Error(`Supported chain with alias ${supportedChainAlias} does not exist`); + throw new Error(`Supported chain in ${fieldName} with alias ${supportedChainAlias} does not exist`); } }); + if (new Set(supportedChainAliases).size !== supportedChainAliases.length) { + throw new Error(`Duplicates found in ${fieldName}`); + } + const sortedSupportedChainAliases = [...supportedChainAliases].sort(); + if (JSON.stringify(supportedChainAliases) !== JSON.stringify(sortedSupportedChainAliases)) { + throw new Error(`${fieldName} is not sorted`); + } }); + Object.entries(managerMultisigAddresses).map(([alias, address]) => { if (!ethers.isAddress(address)) { throw new Error(`Manager multisig address of ${alias}, ${address as string}, is not valid`); From 0a84ae6ed42a178e1095249afd209d598f50e7c1 Mon Sep 17 00:00:00 2001 From: Derek Croote Date: Mon, 23 Sep 2024 23:51:16 -0700 Subject: [PATCH 5/5] Fix unsorted manager-multisig.json --- data/manager-multisig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/manager-multisig.json b/data/manager-multisig.json index a6b7cbb..ee89e6f 100644 --- a/data/manager-multisig.json +++ b/data/manager-multisig.json @@ -41,14 +41,14 @@ "kroma-sepolia-testnet": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26", "lightlink": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26", "lightlink-sepolia-testnet": "0x5aB00E30453EEAd35025A761ED65d51d74574C24", - "manta": "0x0D4136b033807C5298a77E2ad7ebE8ce05207D2d", - "manta-sepolia-testnet": "0x29AbCeDfa34a229536962b3061913842F103A916", "linea": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26", "linea-sepolia-testnet": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26", "lukso": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26", "lukso-testnet": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26", "lumia": "0x026A473DAB17ef658Ca09d726c70b4570A76188b", "lumia-sepolia-testnet": "0x026A473DAB17ef658Ca09d726c70b4570A76188b", + "manta": "0x0D4136b033807C5298a77E2ad7ebE8ce05207D2d", + "manta-sepolia-testnet": "0x29AbCeDfa34a229536962b3061913842F103A916", "mantle": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26", "mantle-sepolia-testnet": "0x25C6f371Cf8d4200B89dF84f9dE69d011013B086", "merlin": "0x14A9E40FcAdA95A273ce3c8d4ccF7EA3280BDd26",