Skip to content

Commit

Permalink
Ignore corrupt database entries in pushToVera script
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelwedler committed May 27, 2024
1 parent f1f1235 commit 96d93dd
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions pushToVera.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,37 @@ async function upsertAndGetId(

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)
SELECT count(vc.*) FROM sourcify_matches sm
JOIN verified_contracts vc ON vc.id = sm.verified_contract_id
JOIN contract_deployments cd on vc.deployment_id = cd.id
JOIN contracts c on cd.contract_id = c.id
JOIN code on code.code_hash = c.creation_code_hash
WHERE 1=1
and sm.creation_match is not null
and sm.runtime_match is not null
and cd.transaction_hash is not null
and code.code is not null
and vc.id >= $1;
`,
[CURRENT_VERIFIED_CONTRACT]
);
console.log("Number of contracts left: ", countLeft[0].count);

const { rows: verifiedContracts, rowCount } = await sourceClient.query(
`
SELECT * FROM verified_contracts
WHERE id >= $1
AND compilation_id in (select id from compiled_contracts where creation_code_hash is not null)
ORDER BY id ASC
LIMIT $2
SELECT vc.* FROM sourcify_matches sm
JOIN verified_contracts vc ON vc.id = sm.verified_contract_id
JOIN contract_deployments cd on vc.deployment_id = cd.id
JOIN contracts c on cd.contract_id = c.id
JOIN code on code.code_hash = c.creation_code_hash
WHERE 1=1
and sm.creation_match is not null
and sm.runtime_match is not null
and cd.transaction_hash is not null
and code.code is not null
and vc.id >= $1
ORDER BY vc.id ASC
LIMIT $2;
`,
[CURRENT_VERIFIED_CONTRACT, N]
);
Expand Down

0 comments on commit 96d93dd

Please sign in to comment.