Skip to content

fix: cherry-pick 1515 to release/0.9: Error backfilling in case of same tx have multiples bridges#1525

Merged
joanestebanr merged 2 commits intorelease/0.9from
cherry-pick/pr-1515-to-0.9
Mar 5, 2026
Merged

fix: cherry-pick 1515 to release/0.9: Error backfilling in case of same tx have multiples bridges#1525
joanestebanr merged 2 commits intorelease/0.9from
cherry-pick/pr-1515-to-0.9

Conversation

@joanestebanr
Copy link
Collaborator

@joanestebanr joanestebanr commented Mar 5, 2026

cherry-pick from v0.8.x #1515

🔄 Changes Summary

  • 💎 In case of filling a row that to_address is NULL is also updated
  • 🐞backfill process is reading wrongly field DestinationAddress and OriginAddress of bridge table that produce an error extracting from_address, txn_sender and to_address

🛡️Security

  • Bump github.com/ethereum/go-ethereum to fix vulnerability GO-2026-4511:
- Vulnerability #1: GO-2026-4511
    Go Ethereum Improperly Validates the ECIES Public Key in RLPx Handshake in
    github.com/ethereum/go-ethereum
  More info: https://pkg.go.dev/vuln/GO-2026-4511
  Module: github.com/ethereum/go-ethereum
    Found in: github.com/ethereum/go-ethereum@v1.16.7
    Fixed in: github.com/ethereum/go-ethereum@v1.16.9

Adaptations

  • Fix bridgesync/backfill_tx_sender_test.go that insert DestinationAddress and OriginAddress as string

@joanestebanr joanestebanr self-assigned this Mar 5, 2026
@joanestebanr joanestebanr added this to the AggKit - v0.9.0 milestone Mar 5, 2026
@joanestebanr joanestebanr changed the title fix: cherry-pick #1515 Error backfilling in case of same tx have mult… fix: cherry-pick 1515 to release/0.9: Error backfilling in case of same tx have multiples bridges Mar 5, 2026
@joanestebanr joanestebanr force-pushed the cherry-pick/pr-1515-to-0.9 branch from 8a8c497 to cb1ace3 Compare March 5, 2026 15:19
@joanestebanr joanestebanr enabled auto-merge (squash) March 5, 2026 15:21
@joanestebanr
Copy link
Collaborator Author

@claude

@joanestebanr joanestebanr disabled auto-merge March 5, 2026 15:22
@claude
Copy link

claude bot commented Mar 5, 2026

Claude finished @joanestebanr's task in 1m 32s —— View job


Code Review Complete ✅

Todo List

  • Read changed files to understand the modifications
  • Analyze backfill logic changes in backfill_tx_sender.go
  • Review test changes in backfill_tx_sender_test.go
  • Verify go-ethereum security update
  • Check for potential bugs and security issues
  • Assess code quality and best practices
  • Provide structured feedback with priority levels

🚀 What's New

This PR cherry-picks critical fixes from #1515 to the release/0.9 branch, addressing backfill process errors when reading bridge table fields and updating the to_address field. Additionally, it bumps go-ethereum to fix a security vulnerability.

🐛 Bug Fixes

  • Fixed backfill process incorrectly reading DestinationAddress and OriginAddress fields from the bridge table (removed incorrect ,address meddler tags)
  • Fixed backfill to update to_address field when it's NULL
  • Fixed RecordUpdate struct to include ToAddr field for proper 3-field updates

📋 Config Updates

None

⚠️ Breaking Changes

None


Review Feedback

🟢 Code Quality - Good Overall

The changes successfully address the stated issues. The core fixes are:

  1. Meddler Tag Fix (bridgesync/backfill_tx_sender.go:127,129): Removed incorrect ,address tags from OriginAddress and DestinationAddress fields. These were causing the backfill process to read wrong data from the database.

  2. Three-Field Update (bridgesync/backfill_tx_sender.go:142,321,340,348,384): Added ToAddr field to RecordUpdate struct and updated the bulk update SQL to handle to_address using COALESCE pattern, ensuring NULL values are filled.

  3. Comprehensive Test Coverage (bridgesync/backfill_tx_sender_test.go): The test file has been significantly expanded with better edge case coverage, including tests for NULL handling, empty string handling, and various failure scenarios.

🔴 Security - go-ethereum Bump (REQUIRED)

Properly Addressed: The PR correctly bumps github.com/ethereum/go-ethereum from v1.16.7 to v1.16.9 to fix vulnerability GO-2026-4511 (ECIES public key validation issue in RLPx handshake). This is a critical security fix.

🟡 Observations & Minor Suggestions

  1. SQL UPDATE Pattern (bridgesync/backfill_tx_sender.go:382-384):

    UPDATE %s
    SET
        txn_sender = COALESCE(NULLIF(txn_sender, ''), ?),
        from_address = COALESCE(NULLIF(from_address, ''), ?),
        to_address = COALESCE(NULLIF(to_address, ''), ?)
    WHERE block_num = ? AND block_pos = ?;

    The COALESCE(NULLIF(field, ''), ?) pattern is clever - it only updates fields that are NULL or empty string, preserving existing non-empty values. This is the correct approach for backfilling missing data.

  2. Test Quality Improvement: The test refactoring is excellent. New helper functions (newTestBridge, setup, insertBlock, insertBridge) make tests much more readable and maintainable. The comprehensive test cases in TestBackfillTxnSender_getRecordsNeedingBackfill_Cases thoroughly cover edge cases.

  3. Meddler Tag Consistency: After the fix, OriginAddress and DestinationAddress now use the default meddler address codec (just meddler:"origin_address") instead of the explicit ,address tag. This is consistent with other address fields in the codebase like FromAddress and TxnSender.

🟢 Code Style & Best Practices

  • ✅ Follows Go naming conventions
  • ✅ Proper error wrapping with context
  • ✅ Good use of testify require (not assert) as per CLAUDE.md guidelines
  • ✅ Comprehensive test coverage including edge cases, context cancellation, and large batches
  • ✅ Comments updated to reflect the new 3-field extraction

No Security Concerns Beyond the Fixed Vulnerability

The backfill logic properly handles:

  • Context cancellation throughout the worker pool
  • Transaction rollback on errors
  • No SQL injection (uses parameterized queries)
  • Proper resource cleanup with deferred closes

Summary

This is a solid cherry-pick that addresses real bugs in the backfill process:

  1. Root cause: The ,address meddler tags on OriginAddress and DestinationAddress were causing incorrect data extraction
  2. Impact: Backfill process couldn't properly extract from_address, txn_sender, and to_address
  3. Fix: Remove incorrect meddler tags + add ToAddr to the update flow + comprehensive tests

The security bump for go-ethereum is critical and properly implemented. The test improvements significantly enhance code reliability. I recommend approval for merge to release/0.9.


@joanestebanr joanestebanr enabled auto-merge (squash) March 5, 2026 16:14
joanestebanr and others added 2 commits March 5, 2026 21:27
- 💎 In case of filling a row that `to_address` is NULL is also updated
- 🐞backfill process is reading wrongly field `DestinationAddress` and
`OriginAddress` of `bridge` table that produce an error extracting
`from_address`, `txn_sender` and `to_address`

- Bump `github.com/ethereum/go-ethereum` to fix vulnerability
**GO-2026-4511**:
```
- Vulnerability #1: GO-2026-4511
    Go Ethereum Improperly Validates the ECIES Public Key in RLPx Handshake in
    github.com/ethereum/go-ethereum
  More info: https://pkg.go.dev/vuln/GO-2026-4511
  Module: github.com/ethereum/go-ethereum
    Found in: github.com/ethereum/go-ethereum@v1.16.7
    Fixed in: github.com/ethereum/go-ethereum@v1.16.9
```
- 🖱️ **Manual**: Synchronizing mainnet bridges

- Closes #1515

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@joanestebanr joanestebanr force-pushed the cherry-pick/pr-1515-to-0.9 branch from d6bb954 to 6db55aa Compare March 5, 2026 20:28
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 5, 2026

@joanestebanr joanestebanr merged commit 9e1ab6b into release/0.9 Mar 5, 2026
24 of 25 checks passed
@joanestebanr joanestebanr deleted the cherry-pick/pr-1515-to-0.9 branch March 5, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants