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

Implement script to import contracts with creator-tx-hash.txt and re-verify them after #1589

Merged
merged 9 commits into from
Aug 26, 2024

Conversation

marcocastignoli
Copy link
Member

@marcocastignoli marcocastignoli commented Aug 22, 2024

See #1573

PR

This PR:

  • Implements the new sourcify:database import-creator-tx-hash, a script that goes through every creator-tx-hash.txt file in repository and store all related contract into a new table sourcify_transaction_hash.
  • Implements a new option for sourcify:database sync to allow specifying a custom sourcify_sync table
  • Refactors code so that import-creator-tx-hash and import-sync don't duplicate code

Process

  1. Create a dedicated sourcify_sync like table (sourcify_transaction_hash with additional transaction_hash field)
CREATE TABLE sourcify_transaction_hash (
    id BIGSERIAL NOT NULL,
    chain_id numeric NOT NULL,
    address bytea NOT NULL,
    match_type varchar NOT NULL,
    transaction_hash bytea NOT NULL,
    synced bool NOT NULL DEFAULT false,
    created_at timestamptz NOT NULL DEFAULT now(),
    CONSTRAINT sourcify_transaction_hash_pkey PRIMARY KEY (id),
    CONSTRAINT sourcify_transaction_hash_pseudo_pkey UNIQUE (chain_id, address)
);
  1. Run the new import-creator-tx-hash script, pushing all the contracts that have a creator-tx-hash.txt from the legacy Argo repo to sourcify_transaction_hash
npm run sourcify:database import-creator-tx-hash /tmp/sourcify/repository/contracts
  1. Create a new table from the comparison between contract_deployments.transaction_hash with sourcify_transaction_hash.transaction_hash finding all the contracts that don't have transaction_hash in contract_deployments but they have it in sourcify_transaction_hash
CREATE TABLE sourcify_sync_sourcify_transaction_hash AS
SELECT sth.*
FROM sourcify_transaction_hash sth
LEFT JOIN contract_deployments cd 
ON sth.chain_id = cd.chain_id 
   AND sth.address = cd.address 
   AND sth.transaction_hash = cd.transaction_hash
WHERE cd.transaction_hash IS NULL;
  1. Execute sync on the new sourcify_sync_sourcify_transaction_hash table
npm run sourcify:database sync https://staging.sourcify.dev/server /tmp/sourcify/repository/contracts --  -c 1 -st sourcify_sync_sourcify_transaction_hash

@marcocastignoli marcocastignoli changed the title Implement script to import contracts with creator-tx-hash.txtand sync them Implement script to import contracts with creator-tx-hash.txt and re-verify them after Aug 22, 2024
services/database/scripts.mjs Outdated Show resolved Hide resolved
services/database/scripts.mjs Outdated Show resolved Hide resolved
services/database/scripts.mjs Outdated Show resolved Hide resolved
services/database/scripts.mjs Outdated Show resolved Hide resolved
services/database/scripts.mjs Outdated Show resolved Hide resolved
services/database/scripts.mjs Outdated Show resolved Hide resolved
services/database/scripts.mjs Outdated Show resolved Hide resolved
@marcocastignoli marcocastignoli merged commit f585f87 into staging Aug 26, 2024
6 checks passed
@marcocastignoli marcocastignoli deleted the import-creator-tx-hash branch August 26, 2024 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

2 participants