Skip to content

Commit

Permalink
Stagenet endpoint is pointing to a relay node (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
noandrea authored Apr 13, 2024
1 parent 0474cae commit bd49129
Show file tree
Hide file tree
Showing 78 changed files with 628 additions and 610 deletions.
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"p-map": "^4.0.0",
"p-queue": "^6.6.2",
"pg": "^8.8.0",
"prettier": "^2.7.1",
"prettier": "3.2.5",
"pretty-bytes": "^5.6.0",
"rollup-plugin-esbuild": "^4.6.0",
"rollup-plugin-preserve-shebangs": "^0.2.0",
Expand Down
22 changes: 11 additions & 11 deletions src/hotfixes/runtime-1300-fix-force-unreserve-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const main = async () => {
const runtimeVersion = upgradeInfo.specVersion.toNumber();

console.log(
`Using data from block #${atBlockNumber} (${api.runtimeVersion.specName.toString()}-${runtimeVersion})`
`Using data from block #${atBlockNumber} (${api.runtimeVersion.specName.toString()}-${runtimeVersion})`,
);

const keyring = new Keyring({ type: "ethereum" });
Expand Down Expand Up @@ -139,7 +139,7 @@ const main = async () => {
depositOf[1].unwrap()[0].map((deposit) => ({
accountId: deposit.toHex(),
reserved: depositOf[1].unwrap()[1].toBigInt(),
}))
})),
)
.flat()
.reduce(
Expand All @@ -158,8 +158,8 @@ const main = async () => {
},
{} as {
[accountId: string]: { accountId: string; reserved: { [key: string]: bigint } };
}
)
},
),
),
preimages
.filter((preimage) => preimage[1].unwrap().isAvailable)
Expand Down Expand Up @@ -236,10 +236,10 @@ const main = async () => {
if (expectedReserve != reserved) {
console.log(
`${accountId}: reserved ${reserved} vs expected ${expectedReserve} (${Object.keys(
expectedReserveByAccount[accountId]?.reserved || {}
expectedReserveByAccount[accountId]?.reserved || {},
)
.map((key) => `${key}: ${expectedReserveByAccount[accountId].reserved[key]}`)
.join(` - `)})`
.join(` - `)})`,
);
expectedReserveByAccount[accountId];
if (reserved < expectedReserve) {
Expand All @@ -264,21 +264,21 @@ const main = async () => {
.reduce((p, v) => p + v.reserve, 0n)
.toString()
.padStart(25)} - ${accountsToAddReserve.length} accounts:\n${accountsToAddReserve
.map(({ accountId, reserve }) => ` - ${accountId}: ${printTokens(api, reserve)}`)
.join("\n")}
.map(({ accountId, reserve }) => ` - ${accountId}: ${printTokens(api, reserve)}`)
.join("\n")}
- extra: ${accountsToRemoveReserve
.reduce((p, v) => p + v.reserve, 0n)
.toString()
.padStart(25)} - ${accountsToRemoveReserve.length} accounts:\n${accountsToRemoveReserve
.map(({ accountId, reserve }) => ` - ${accountId}: ${printTokens(api, reserve)}`)
.join("\n")}`
.map(({ accountId, reserve }) => ` - ${accountId}: ${printTokens(api, reserve)}`)
.join("\n")}`,
);

if (argv["send-preimage-hash"]) {
const collectiveThreshold = argv["collective-threshold"] || 1;
const account = await keyring.addFromUri(argv["account-priv-key"], null, "ethereum");
const { nonce: rawNonce, data: balance } = (await api.query.system.account(
account.address
account.address,
)) as any;
let nonce = BigInt(rawNonce.toString());
const BATCH_SIZE = 500;
Expand Down
10 changes: 5 additions & 5 deletions src/hotfixes/runtime-1300-fix-orphan-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const main = async () => {
const runtimeVersion = upgradeInfo.specVersion.toNumber();

console.log(
`Using data from block #${atBlockNumber} (${api.runtimeVersion.specName.toString()}-${runtimeVersion})`
`Using data from block #${atBlockNumber} (${api.runtimeVersion.specName.toString()}-${runtimeVersion})`,
);

const delegatorsToFix = [];
Expand All @@ -75,7 +75,7 @@ const main = async () => {
requestData.forEach((request, collator) => {
totalRequests++;
const delegation = stateData.delegations.find(
({ owner }) => owner.toString() == collator.toString()
({ owner }) => owner.toString() == collator.toString(),
);
if (
!delegation ||
Expand All @@ -84,8 +84,8 @@ const main = async () => {
console.log(
`${stateData.id}: ${request.whenExecutable} - ${printTokens(
api,
delegation.amount.toBigInt()
)} vs requested ${printTokens(api, request.amount.toBigInt())}`
delegation.amount.toBigInt(),
)} vs requested ${printTokens(api, request.amount.toBigInt())}`,
);
delegatorsToFix.push(stateData.id);
}
Expand All @@ -100,7 +100,7 @@ const main = async () => {
const collectiveThreshold = argv["collective-threshold"] || 1;
const account = await keyring.addFromUri(argv["account-priv-key"], null, "ethereum");
const { nonce: rawNonce, data: balance } = (await api.query.system.account(
account.address
account.address,
)) as any;
let nonce = BigInt(rawNonce.toString());

Expand Down
10 changes: 5 additions & 5 deletions src/hotfixes/runtime-1500-find-non-sufficient-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const main = async () => {
const runtimeVersion = upgradeInfo.specVersion.toNumber();

console.log(
`Using data from block #${atBlockNumber} (${api.runtimeVersion.specName.toString()}-${runtimeVersion})`
`Using data from block #${atBlockNumber} (${api.runtimeVersion.specName.toString()}-${runtimeVersion})`,
);

const [accountCodeKeys] = await Promise.all([apiAt.query.evm.accountCodes.keys()]);
Expand All @@ -42,7 +42,7 @@ const main = async () => {
for (let i = 0; i < accountCodeKeys.length; i += BATCH_SIZE) {
const chunkKeys = accountCodeKeys.slice(i, i + BATCH_SIZE);
const multiAccount = await apiAt.query.system.account.multi(
chunkKeys.map((k) => `0x${k.toHex().slice(-40)}`)
chunkKeys.map((k) => `0x${k.toHex().slice(-40)}`),
);
for (const index in chunkKeys) {
accounts[chunkKeys[index].toHex()] = multiAccount[index];
Expand All @@ -68,14 +68,14 @@ const main = async () => {
console.log(
`Found ${sortedAccountsToFix.length} / ${
accountCodeKeys.length
} on ${upgradeInfo.specName.toString()}[${upgradeInfo.specVersion.toNumber()}]`
} on ${upgradeInfo.specName.toString()}[${upgradeInfo.specVersion.toNumber()}]`,
);

if (argv["account-priv-key"]) {
const keyring = new Keyring({ type: "ethereum" });
const account = await keyring.addFromUri(argv["account-priv-key"], null, "ethereum");
const { nonce: rawNonce, data: balance } = (await api.query.system.account(
account.address
account.address,
)) as any;
let nonce = BigInt(rawNonce.toString());

Expand All @@ -90,7 +90,7 @@ const main = async () => {
}
fs.writeFileSync(
`${upgradeInfo.specName.toString()}-accounts-to-fix.json`,
JSON.stringify(sortedAccountsToFix, null, 2)
JSON.stringify(sortedAccountsToFix, null, 2),
);

await api.disconnect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ async function main() {
try {
const scheduledRequestAccounts = new Set(
(await apiAt.query.parachainStaking.delegationScheduledRequests.keys()).map(
({ args: [accountId] }) => accountId.toString()
)
({ args: [accountId] }) => accountId.toString(),
),
);
const collators = new Set(
(await apiAt.query.parachainStaking.candidateInfo.keys()).map(({ args: [accountId] }) =>
accountId.toString()
)
accountId.toString(),
),
);

// verify empty delegation requests
const accountsToFix = [...scheduledRequestAccounts].filter(
(accountId) => !collators.has(accountId)
(accountId) => !collators.has(accountId),
);
for (const account of accountsToFix) {
const requests = await apiAt.query.parachainStaking.delegationScheduledRequests(account);
Expand Down Expand Up @@ -84,7 +84,7 @@ async function main() {
async function waitTxDone(
api: ApiPromise,
tx: SubmittableExtrinsic,
timeoutMs = 120000
timeoutMs = 120000,
): Promise<string> {
return new Promise(async (resolve, reject) => {
let unsub = () => {};
Expand Down
Loading

0 comments on commit bd49129

Please sign in to comment.