feat: migrate bridgesync claim data into claimsync DB on startup#1554
Conversation
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>
|
Claude finished @joanestebanr's task in 1m 41s —— View job PR Review Complete ✅🚀 What's NewThis PR adds functionality to migrate bridgesync claim data into the claimsync DB on startup. The implementation includes:
🐛 Bug FixesNone 📋 Config UpdatesNone - uses existing
|
|


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 activeTest plan
TestImportDataFromBridgesyncer_NoTables– bridge DB with no tables: no-op, no claimDB createdTestImportDataFromBridgesyncer_EmptyTables– tables present but empty: no-op, no claimDB createdTestImportDataFromBridgesyncer_Success– verifies row counts per tableTestImportDataFromBridgesyncer_Idempotent– second call does not duplicate rowsTestImportDataFromBridgesyncer_MissingRequiredMigration– error whenbridgesync0012absentTestImportDataFromBridgesyncer_OldSchemaNoHash– old schema without optional columns,block.hashdefaults to''TestImportKeyValueFromBridgesyncer_NoTable,_EmptyTable,_Success,_Idempotent🤖 Generated with Claude Code