Skip to content

feat: switch metadata reads to compiled_contracts_metadata - #2942

Draft
marcocastignoli wants to merge 2 commits into
feat/2924-compiled-contracts-metadatafrom
feat/2924-metadata-read-switch
Draft

feat: switch metadata reads to compiled_contracts_metadata#2942
marcocastignoli wants to merge 2 commits into
feat/2924-compiled-contracts-metadatafrom
feat/2924-metadata-read-switch

Conversation

@marcocastignoli

Copy link
Copy Markdown
Member

Important

Do not merge until all three are checked — this PR removes the only fallback to sourcify_matches.metadata:

  • Production backfill finished (backfill-compiled-contracts-metadata.mjs)
  • --verify reports missingRows=0
  • compiled_contracts_metadata added to the Datastream mirror (sourcify-matches stream)

Summary

Release 2 of 2 for #2924, stacked on #2941. Reads switch to the side table, writes to the old column stop:

  • STORED_PROPERTIES_TO_SELECTORS (metadata, std_json_output) now read compiled_contracts_metadata; the table is LEFT JOINed only when one of those fields is requested, and grouped by its PK where a GROUP BY exists (PK grouping is what makes the json column selectable).
  • getSourcifyMatchByChainAddress selects metadata via the same join.
  • getCompilationsByIds (similarity search) joins the side table directly on the compilation PK — the LATERAL detour through sourcify_matches that The same metadata is stored 8.5 times over: ~139 GB of a 182 GB table #2924 called out is gone, along with its stale-compilation quirk.
  • insertSourcifyMatch / updateSourcifyMatch no longer take or write metadata; the column stays in place (nullable, unread) until the drop.
  • Tests read metadata from the side table; assertContractSaved's duplicate check collapses back into one query.

After this deploys, the remaining ops task is dropping sourcify_matches.metadata and reclaiming the ~139 GB with pg_repack.

Notes

🤖 Generated with Claude Code

@marcocastignoli marcocastignoli moved this from Triage to Sprint - Up Next in Sourcify Public Aug 27, 2026
marcocastignoli and others added 2 commits August 28, 2026 07:40
Switches all metadata reads to the side table and stops writing
sourcify_matches.metadata, which can then be dropped:

- STORED_PROPERTIES_TO_SELECTORS metadata/std_json_output selectors
  read compiled_contracts_metadata, joined only when those fields are
  requested (grouping on the side table's PK keeps json selectable)
- getCompilationsByIds joins the side table directly instead of the
  LATERAL detour through sourcify_matches
- insertSourcifyMatch/updateSourcifyMatch no longer write metadata

Requires the backfill of compiled_contracts_metadata to be complete in
production before deployment. See #2924.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kuzdogan
kuzdogan force-pushed the feat/2924-metadata-read-switch branch from c7abc62 to c83d189 Compare August 28, 2026 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Sprint - Up Next

Development

Successfully merging this pull request may close these issues.

1 participant