feat: add param SyncFromInBridges to bridgesyncer#1485
feat: add param SyncFromInBridges to bridgesyncer#1485joanestebanr wants to merge 24 commits intodevelopfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a configurable SyncFromInBridges parameter to the bridge syncer that controls whether the FromAddress field is extracted for bridge Asset events. The feature enables nodes without archive capability to sync bridge events by optionally skipping the expensive debug_traceTransaction call.
Changes:
- Introduces
SyncFromInBridgesModeconfiguration with three modes: "true" (always extract), "false" (never extract), and "auto" (extract if BRIDGE component is active) - Changes
Bridge.FromAddressfromcommon.Addressto*common.Addressto support NULL values in the database - Updates the compatibility check system to allow
IsCompatibleimplementations to return updated data for DB storage - Implements parameterized SQL queries for bridge filtering to prevent SQL injection
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| bridgesync/config.go | Adds SyncFromInBridgesMode type with validation and resolve logic |
| bridgesync/processor.go | Changes FromAddress to pointer type, adds compatibility validation for SyncFromInBridges, implements parameterized queries |
| bridgesync/downloader.go | Updates ExtractTxnAddresses to conditionally skip FromAddress extraction based on config |
| bridgesync/bridgesync.go | Passes syncFromInBridges parameter through to processor initialization |
| bridgesync/backfill_tx_sender.go | Updates backfill logic to respect syncFromInBridges flag |
| db/compatibility/types/comparer.go | Updates IsCompatible interface to return optional update data |
| db/compatibility/compatibility_db_contents.go | Adds logic to update DB when IsCompatible returns non-nil data |
| bridgeservice/types/types.go | Changes BridgeResponse.FromAddress to nullable pointer with documentation |
| bridgeservice/utils.go | Updates response conversion to handle nullable FromAddress |
| config/default.go | Sets default value of SyncFromInBridges = "auto" for both L1 and L2 configs |
| cmd/run.go | Resolves SyncFromInBridges mode based on active components and passes to bridge sync constructors |
| test/helpers/e2e.go | Updates test helpers to pass syncFromInBridges parameter |
| Multiple test files | Updates tests to use pointer-based FromAddress and adds syncFromInBridges parameter |
| bridgesync/migrations/migrations_test.go | Updates migration tests to reflect pointer-based field types |
| sync/evmdriver.go | Updates RuntimeData.IsCompatible signature to match new interface |
| multidownloader/storage/compatibility_runtime.go | Updates DBRuntimeData.IsCompatible to match new interface |
| aggsender/db/aggsender_db_storage.go | Updates RuntimeData.IsCompatible to match new interface |
Comments suppressed due to low confidence (1)
bridgesync/processor_test.go:2193
- Missing test coverage for SyncFromInBridges compatibility logic: The TestBridgeSyncRuntimeData_IsCompatible test doesn't include any test cases for the new SyncFromInBridges field. Consider adding test cases for:
- Storage has nil SyncFromInBridges (old DB) and runtime has false - should update DB
- Storage has nil SyncFromInBridges (old DB) and runtime has true - should update DB
- Storage has false and runtime has true - should return error (incompatible)
- Storage has true and runtime has false - should log warning but succeed
- Storage has true and runtime has true - should succeed
- Storage has false and runtime has false - should succeed
These cases test the compatibility validation logic in processor.go lines 639-665.
func TestBridgeSyncRuntimeData_IsCompatible(t *testing.T) {
tests := []struct {
name string
current BridgeSyncRuntimeData
storage BridgeSyncRuntimeData
expectError bool
errorMsg string
}{
{
name: "compatible versions",
current: BridgeSyncRuntimeData{
ChainID: 1,
Addresses: []common.Address{common.HexToAddress("0x123")},
DBVersion: intPtr(1),
},
storage: BridgeSyncRuntimeData{
ChainID: 1,
Addresses: []common.Address{common.HexToAddress("0x123")},
DBVersion: intPtr(1),
},
expectError: false,
},
{
name: "incompatible versions - different DB versions",
current: BridgeSyncRuntimeData{
ChainID: 1,
Addresses: []common.Address{common.HexToAddress("0x123")},
DBVersion: intPtr(2),
},
storage: BridgeSyncRuntimeData{
ChainID: 1,
Addresses: []common.Address{common.HexToAddress("0x123")},
DBVersion: intPtr(1),
},
expectError: true,
errorMsg: "database schema version mismatch",
},
{
name: "incompatible versions - different chain IDs",
current: BridgeSyncRuntimeData{
ChainID: 1,
Addresses: []common.Address{common.HexToAddress("0x123")},
DBVersion: intPtr(1),
},
storage: BridgeSyncRuntimeData{
ChainID: 2,
Addresses: []common.Address{common.HexToAddress("0x123")},
DBVersion: intPtr(1),
},
expectError: true,
errorMsg: "chain ID mismatch: 1 != 2",
},
{
name: "incompatible versions - different addresses",
current: BridgeSyncRuntimeData{
ChainID: 1,
Addresses: []common.Address{common.HexToAddress("0x123")},
DBVersion: intPtr(1),
},
storage: BridgeSyncRuntimeData{
ChainID: 1,
Addresses: []common.Address{common.HexToAddress("0x456")},
DBVersion: intPtr(1),
},
expectError: true,
errorMsg: "addresses[0] mismatch: 0x0000000000000000000000000000000000000123 != 0x0000000000000000000000000000000000000456",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := tt.current.IsCompatible(tt.storage)
if tt.expectError {
require.Error(t, err)
require.Contains(t, err.Error(), tt.errorMsg)
} else {
require.NoError(t, err)
}
})
}
}
7613d98 to
bb3599f
Compare
630c081 to
5ab9317
Compare
|
Claude finished @joanestebanr's task in 2m 2s —— View job Code Review Complete ✅I've completed a comprehensive review of this PR. Here's my analysis: 🚀 What's NewThis PR introduces a configurable 🐛 Bug Fixes
📋 Config UpdatesNew configuration parameter added to both BridgeL1Sync and BridgeL2Sync: [BridgeL1Sync]
SyncFromInBridges = "auto" # Options: "true", "false", "auto" (default: "auto")
[BridgeL2Sync]
SyncFromInBridges = "auto"
|
…e syncFromInBridges=true
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…afe here go:S2077
…afe here go:S2077
8c8a5b6 to
74821ba
Compare
|



🔄 Changes Summary
This PR adds a new configuration parameter SyncFromInBridges to the bridge syncer that controls whether to extract the FromAddress field for bridge Asset events using
debug_traceTransaction.The parameter supports three modes: "true" (always extract using debug_traceTransaction), "false" (never extract), and "auto" (decide based on BRIDGE component activation).
This allows nodes without archive capability to sync bridge events without the expensive debug tracing operation, while maintaining backward compatibility.
Also improve the case
SyncFromInBridges==true(bridgeService) using txReceipt in case of direct call to bridge SCINTERNAL CHANGE: The compatibility store checker (that validate that contents of DB is compatible with current execution) can update data on DB
None
📋 Config Updates
New configuration parameter added to both BridgeL1Sync and BridgeL2Sync
"true": Always extracts FromAddress (requires archive node with debug_traceTransaction)"false": Never extracts FromAddress (stores NULL, no archive node needed)"auto": Automatically decides based on whether BRIDGE component is active✅ Testing
🐞 Issues
🔗 Related PRs
📝 Notes