Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: set all versions in runtime-upgrade script #573

Merged
merged 3 commits into from
Feb 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions scripts/runtime-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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*[.]\/((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]]);
}

return matches.map(([checksum, fullFileName, clientName]) => {
return api.tx.clientsInfo.setPendingClientRelease(
clientName,
{
uri: baseUrl + fullFileName,
checksum: "0x" + checksum,
}
)
});
}

async function main(): Promise<void> {
await cryptoWaitReady();

Expand Down Expand Up @@ -112,20 +139,13 @@ async function main(): Promise<void> {

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);
Expand Down