Skip to content

Commit

Permalink
Add logging to pushToVera script
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelwedler committed May 24, 2024
1 parent 9e32394 commit f1f1235
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pushToVera.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import dotenv from "dotenv";

dotenv.config();

console.log("Starting Push to Verifier Alliance DB");

const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename);

Expand Down Expand Up @@ -62,6 +64,21 @@ async function upsertAndGetId(
let verifiedContractCount = 1;

while (verifiedContractCount > 0) {
const startIterationTime = performance.now();

console.log(`Processing next ${N} contracts`);
console.log(`Current contract id: ${CURRENT_VERIFIED_CONTRACT}`);

const { rows: countLeft } = await sourceClient.query(
`
SELECT COUNT(*) FROM verified_contracts
WHERE id >= $1
AND compilation_id in (select id from compiled_contracts where creation_code_hash is not null)
`,
[CURRENT_VERIFIED_CONTRACT]
);
console.log("Number of contracts left: ", countLeft[0].count);

const { rows: verifiedContracts, rowCount } = await sourceClient.query(
`
SELECT * FROM verified_contracts
Expand Down Expand Up @@ -237,6 +254,15 @@ async function upsertAndGetId(
]
);
}

const endIterationTime = performance.now();
const iterationTimeTaken = endIterationTime - startIterationTime;
console.log(
`Rate: processing ${
N / (iterationTimeTaken / 1000)
} contracts per second`
);
console.log();
}
console.log("Contracts transferred successfully.");
} catch (error) {
Expand Down

0 comments on commit f1f1235

Please sign in to comment.