Skip to content

Commit

Permalink
chore(script): add workerpool eval analyzer with concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
atticusofsparta committed Sep 30, 2024
1 parent af574c9 commit 33da87e
Show file tree
Hide file tree
Showing 13 changed files with 3,414 additions and 3,060 deletions.
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@
"description": "This repository contains the IO contract implementation on AO.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"analyze-ants": "node --experimental-wasm-memory64 tools/analyze-ant-source-codes.mjs"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@ar.io/sdk": "^2.2.5",
"@iwsio/json-csv-node": "^6.1.7",
"@permaweb/ao-loader": "^0.0.37",
"@permaweb/aoconnect": "^0.0.59",
"arweave-graphql": "^0.0.5",
"fetch-retry": "^6.0.0",
"loglevel": "^1.9.2",
"plimit-lit": "^3.0.1",
"prettier": "^3.3.3"
"prettier": "^3.3.3",
"workerpool": "^9.1.3"
}
}
431 changes: 202 additions & 229 deletions affected-domains.csv → tools/affected-domains.csv

Large diffs are not rendered by default.

4,152 changes: 1,912 additions & 2,240 deletions affected-domains.json → tools/affected-domains.json

Large diffs are not rendered by default.

37 changes: 22 additions & 15 deletions tools/analyze-ant-source-codes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import { connect } from '@permaweb/aoconnect';
import { pLimit } from 'plimit-lit';
import { toCsvSync } from '@iwsio/json-csv-node';
import arweaveGraphql from 'arweave-graphql';
import path from 'path';

const cleanSourceCodeId = 'RuoUVJOCJOvSfvvi_tn0UPirQxlYdC4_odqmORASP8g';
const __dirname = path.dirname(new URL(import.meta.url).pathname);

const cleanSourceCodeIds = [
'RuoUVJOCJOvSfvvi_tn0UPirQxlYdC4_odqmORASP8g',
'vS1Sj5mHyVPhSGW3AkvzMhctsOStAjBIKWyO_1eWxVM',
];

function createDomainLink(domain) {
return `https://${domain}.arweave.net`;
Expand All @@ -16,10 +22,15 @@ function createEntityLink(processId) {

async function getProcessEvalMessageIDsNotFromArIO(processId) {
// Dcd4bnUAxJ
const abortSignal = new AbortController();
setTimeout(() => {
abortSignal.abort();
}, 120000);
const messages = await fetch(
`https://su-router.ao-testnet.xyz/${processId}?limit=100000`,
{
method: 'GET',
signal: abortSignal.signal,
},
).then((res) => res.json());
const evalMessages = messages.edges.reduce((acc, edge) => {
Expand Down Expand Up @@ -127,7 +138,7 @@ async function main() {
return [];
});

if (owner && sourceCodeId && sourceCodeId !== cleanSourceCodeId) {
if (owner && sourceCodeId && !cleanSourceCodeIds.includes(sourceCodeId)) {
affectedDomains.push({
['ArNS Domain']: domain,
['Process ID']: antId,
Expand All @@ -145,17 +156,6 @@ async function main() {
scannedCount++;
} catch (error) {
console.error('Error processing domain:', domain, error);
affectedDomains.push({
['ArNS Domain']: domain,
['Process ID']: antId,
['Owner ID']: 'unknown',
['Custom Eval Message Count']: 'unknown',
['ArNS Domain Link']: createDomainLink(domain),
['Process ID Link']: createEntityLink(antId),
['Owner Link']: 'unknown',
['Error']: 'Not reachable',
relatedManifestIds: [],
});
}
}
await Promise.all(
Expand Down Expand Up @@ -190,7 +190,7 @@ async function main() {
);
// write json file
fs.writeFileSync(
'affected-domains.json',
path.join(__dirname, 'affected-domains.json'),
JSON.stringify(affectedDomains, null, 2),
);
// create csv
Expand Down Expand Up @@ -233,7 +233,14 @@ async function main() {
ignoreHeader: false,
});

fs.writeFileSync('affected-domains.csv', csv);
fs.writeFileSync(path.join(__dirname, 'affected-domains.csv'), csv);
const domainsToProvision = affectedDomains.map(
(domain) => domain['ArNS Domain'],
);
fs.writeFileSync(
path.join(__dirname, 'domains-to-provision.json'),
JSON.stringify(domainsToProvision, null, 2),
);
}

main();
Loading

0 comments on commit 33da87e

Please sign in to comment.