feat: migrate bridgesync claim data into claimsync DB on startup#1554
feat: migrate bridgesync claim data into claimsync DB on startup#1554joanestebanr merged 15 commits intodevelopfrom
Conversation
1fc6a0f to
4ab19d5
Compare
Introduce `runImportFromBridgeSyncerIfNeeded` which copies block, claim, set_claim, unset_claim and key_value rows from an existing bridgesync SQLite database into the claimsync database before the syncers start. The migration is triggered at the call site in `start()`: - for L1 when BRIDGE or L1BRIDGESYNC are active - for L2 when any of BRIDGE, L2BRIDGESYNC, L2CLAIMSYNC, AGGSENDER, AGGSENDERVALIDATOR or AGGCHAINPROOFGEN are active It delegates to `claimsyncstorage.ImportDataFromBridgesyncer` and `claimsyncstorage.ImportKeyValueFromBridgesyncer`, both of which are idempotent and no-ops when the source DB has no relevant data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c22a339 to
36c4725
Compare
|
Claude finished @joanestebanr's task in 1m 27s —— View job Code Review Complete ✓🚀 What's NewThis PR adds automatic migration of claim-related data from the legacy bridgesync SQLite database into the new claimsync database on startup. The migration handles schema evolution gracefully (supporting old bridgesync schemas missing optional columns like 🐛 Bug FixesNone - this is a new feature to handle data migration during the bridgesync → claimsync transition. 📋 Config UpdatesNone - migration is triggered automatically based on which components are running.
|
There was a problem hiding this comment.
Pull request overview
Adds a startup-time migration to preserve historical claim indexing data by copying claim-related tables out of the legacy bridgesync SQLite DB into the claimsync DB, and then removing the legacy tables from bridgesync via a new migration.
Changes:
- Wire a startup hook in
cmd/run.goto inspect bridgesync/claimsync DBs and run the import when appropriate (L1/L2). - Add claimsync storage helpers to inspect bridgesync DB state and import
block/claim/set_claim/unset_claimplus akey_valueentry. - Add bridgesync migration
bridgesync0015to drop legacy claim tables, with a test validating tables are removed.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/run.go | Calls the bridgesync → claimsync import before starting syncers based on active components. |
| claimsync/storage/import_data_from_bridgesyncer.go | Implements DB inspection and the actual data/key_value import logic. |
| claimsync/storage/import_data_from_bridgesyncer_test.go | Adds unit tests for the inspection and import helpers. |
| bridgesync/migrations/migrations_test.go | Adds coverage verifying the new bridgesync migration drops claim tables. |
| bridgesync/migrations/bridgesync0015.sql | Drops legacy claim tables from bridgesync (and recreates them on Down). |
| // - block.hash - present since bridgesync migration 0003; defaults to ". | ||
| // - claim.tx_hash - present since bridgesync migration 0002; defaults to ". | ||
| // - claim.block_timestamp - present since bridgesync migration 0002; defaults to 0. | ||
| // - claim.type - present since bridgesync migration 0012; defaults to ". |
There was a problem hiding this comment.
The doc comment lists defaults as "." for several optional columns, but the implementation defaults to empty string ('') and 0 for timestamps. Please fix the comment so it reflects the real fallback values.
| // - block.hash - present since bridgesync migration 0003; defaults to ". | |
| // - claim.tx_hash - present since bridgesync migration 0002; defaults to ". | |
| // - claim.block_timestamp - present since bridgesync migration 0002; defaults to 0. | |
| // - claim.type - present since bridgesync migration 0012; defaults to ". | |
| // - block.hash - present since bridgesync migration 0003; defaults to ''. | |
| // - claim.tx_hash - present since bridgesync migration 0002; defaults to ''. | |
| // - claim.block_timestamp - present since bridgesync migration 0002; defaults to 0. | |
| // - claim.type - present since bridgesync migration 0012; defaults to ''. |
|



🔄 Changes Summary
ImportDataFromBridgesyncerwhich copiesblock,claim,set_claimandunset_claimrows from a bridgesync SQLite DB into the claimsync DB. Handles old schema versions (missingblock.hash,claim.tx_hash,claim.block_timestamp,claim.type) gracefully via column detection.ImportKeyValueFromBridgesyncerwhich copies the singlekey_valuerow, replacing theownerfield with the claimsync syncer ID.INSERT OR IGNORE) and no-ops when the source DB has no relevant data (claimDB is not created unless data exists).bridgesync0012(the last migration touching the imported tables) has been applied before proceeding.cmd/run.go, wire the migration viarunImportFromBridgeSyncerIfNeededat the call site, before both the bridge and claim syncers start:BRIDGEorL1BRIDGESYNCare activeBRIDGE,L2BRIDGESYNC,L2CLAIMSYNC,AGGSENDER,AGGSENDERVALIDATORorAGGCHAINPROOFGENare activeCases:
bridgesync0012None
📋 Config Updates
None
✅ Testing
🐞 Issues