From 427712cfbaea2e46e36b2e35b28d3a894522e322 Mon Sep 17 00:00:00 2001 From: Gregory Hill Date: Thu, 23 Feb 2023 14:15:50 +0000 Subject: [PATCH 1/3] chore: set all versions in runtime-upgrade script Signed-off-by: Gregory Hill --- scripts/runtime-upgrade.ts | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/scripts/runtime-upgrade.ts b/scripts/runtime-upgrade.ts index 07af4777d..3156fe091 100644 --- a/scripts/runtime-upgrade.ts +++ b/scripts/runtime-upgrade.ts @@ -73,6 +73,33 @@ async function printDiscordProposal( console.log(""); } +async function setAllClientReleases(api: ApiPromise, baseUrl: String, runtimeName: String) { + const checksumFile = await fetch(baseUrl + 'sha256sums.txt') + .then(res => { + if (res.status >= 400) { + throw new Error("Bad response from server"); + } + return res.text(); + }); + + const regex = new RegExp("([a-f0-9]+)\\\s*[.]\/(([a-z]+)-parachain-metadata-" + runtimeName + ")", "g"); + let matches = [] + let match; + while ((match = regex.exec(checksumFile)) !== null) { + matches.push([match[1], match[2], match[3]]); + } + + return matches.map(([checksum, fullFileName, clientName]) => { + return api.tx.clientsInfo.setCurrentClientRelease( + clientName, + { + uri: baseUrl + fullFileName, + checksum: "0x" + checksum, + } + ) + }); +} + async function main(): Promise { await cryptoWaitReady(); @@ -112,20 +139,13 @@ async function main(): Promise { const clientsRepo = "https://github.com/interlay/interbtc-clients"; const clientsVersion = args['clients-version']; - console.log(`Downloading vault binary (${clientsVersion})...`); - const vaultFileName = `vault-parachain-metadata-${args['runtime-name']}`; - const vaultBinaryUri = `${clientsRepo}/releases/download/${clientsVersion}/${vaultFileName}`; - const vaultBinary = await fetch(vaultBinaryUri); - const vaultBinaryRaw = await vaultBinary.arrayBuffer(); - const vaultChecksum = sha256AsU8a(Buffer.from(vaultBinaryRaw)); - const vaultRelease = { uri: vaultBinaryUri, checksum: vaultChecksum }; + const clientsBaseUrl = `${clientsRepo}/releases/download/${clientsVersion}/`; const paraApi = await createSubstrateAPI(args['parachain-endpoint']); const batched = paraApi.tx.utility.batchAll([ paraApi.tx.parachainSystem.authorizeUpgrade(codeHash), - paraApi.tx.clientsInfo.setPendingClientRelease("vault", vaultRelease), - ]); + ].concat(await setAllClientReleases(paraApi, clientsBaseUrl, args['runtime-name']))); const title = `Runtime Upgrade ${parachainVersion}`; printDiscordProposal(title, batched, args["parachain-endpoint"], paraApi); From 2c8d532d09818f7060f3c192fb5930e6e23963e9 Mon Sep 17 00:00:00 2001 From: Gregory Hill Date: Thu, 23 Feb 2023 14:44:23 +0000 Subject: [PATCH 2/3] fix: only match oracle or vault in regex and newline Signed-off-by: Gregory Hill --- scripts/runtime-upgrade.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/runtime-upgrade.ts b/scripts/runtime-upgrade.ts index 3156fe091..4a4addea5 100644 --- a/scripts/runtime-upgrade.ts +++ b/scripts/runtime-upgrade.ts @@ -82,8 +82,8 @@ async function setAllClientReleases(api: ApiPromise, baseUrl: String, runtimeNam return res.text(); }); - const regex = new RegExp("([a-f0-9]+)\\\s*[.]\/(([a-z]+)-parachain-metadata-" + runtimeName + ")", "g"); - let matches = [] + const regex = new RegExp("([a-f0-9]+)\\\s*[.]\/((oracle|vault)-parachain-metadata-" + runtimeName + ")\n", "g"); + let matches = []; let match; while ((match = regex.exec(checksumFile)) !== null) { matches.push([match[1], match[2], match[3]]); From 14690604929effdec366a0296e2a79e380f973ea Mon Sep 17 00:00:00 2001 From: Gregory Hill Date: Thu, 23 Feb 2023 14:52:02 +0000 Subject: [PATCH 3/3] fix: set pending client release in upgrade script Signed-off-by: Gregory Hill --- scripts/runtime-upgrade.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/runtime-upgrade.ts b/scripts/runtime-upgrade.ts index 4a4addea5..e18636b58 100644 --- a/scripts/runtime-upgrade.ts +++ b/scripts/runtime-upgrade.ts @@ -90,7 +90,7 @@ async function setAllClientReleases(api: ApiPromise, baseUrl: String, runtimeNam } return matches.map(([checksum, fullFileName, clientName]) => { - return api.tx.clientsInfo.setCurrentClientRelease( + return api.tx.clientsInfo.setPendingClientRelease( clientName, { uri: baseUrl + fullFileName,