Skip to content

fix: restore unpatched SDK, read hash from RPC response - #1824

Merged
Thegaram merged 1 commit into
developfrom
fix-l1-hash-from-rpc
Oct 22, 2026
Merged

Thegaram merged 1 commit into
developfrom
fix-l1-hash-from-rpc

Conversation

@Thegaram

@Thegaram Thegaram commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Purpose or design rationale of this PR

The gl2geth SDK computes wrong hashes for L1 blocks from Shanghai on. Its Header struct follows Scroll L2 rules: it lacks newer L1 fields (e.g. EIP-7685 requestsHash) and encodes Scroll-only fields after baseFee. bridge-history-api worked around this with a replace to an unmerged fork (scroll-tech/go-ethereum#1133). The rollup L1 watcher had no workaround, so it stored wrong hashes in l1_block.

This PR:

  • Reads the block hash from the eth_getBlockByNumber response in the bridge-history-api fetchers and the rollup L1 watcher.
  • Validates the response like ethclient did: required fields, a non-zero hash, and a transaction list that matches transactionsRoot.
  • Removes the replace. All modules now use the same SDK version.
  • Adds a forbidigo lint rule that forbids types.Header.Hash and types.Block.Hash. L2-only files are exempt, because the SDK hash is correct for L2.

This unblocks the go-ethereum and Go version bumps.

PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • fix: A bug fix

Deployment tag versioning

Has tag in common/version.go been updated or have you added bump-version label to this PR?

  • No, this PR doesn't involve a new deployment, git tag, docker image tag
  • Yes

Breaking change label

Does this PR have the breaking-change label?

  • No, this PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • Bug Fixes
    • Improved L1 and L2 block tracking to use hashes reported by the network, helping keep bridge history, watcher data, and reorganization recovery consistent with on-chain block information.
    • Block retrieval now reports errors for incomplete or inconsistent responses, including missing fields, zero hashes, and mismatched transaction data.
    • L1 block metadata, including base-fee and blob-gas information, is now read directly from the network response.
  • Maintenance
    • Updated the application version to v4.8.4.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3837974a-b660-4771-85ff-bca17ac6e416
📥 Commits

Reviewing files that changed from the base of the PR and between 398e90b and d47f1e3.

⛔ Files ignored due to path filters: 1
  • bridge-history-api/go.sum is excluded by !**/*.sum
📒 Files selected for processing: 13
  • bridge-history-api/cmd/fetcher/app/app.go
  • bridge-history-api/go.mod
  • bridge-history-api/internal/controller/fetcher/l1_fetcher.go
  • bridge-history-api/internal/controller/fetcher/l2_fetcher.go
  • bridge-history-api/internal/logic/l1_fetcher.go
  • bridge-history-api/internal/logic/l2_fetcher.go
  • bridge-history-api/internal/utils/utils.go
  • bridge-history-api/internal/utils/utils_test.go
  • build/.golangci.yml
  • common/version/version.go
  • rollup/internal/controller/watcher/l1_watcher.go
  • rollup/internal/controller/watcher/l1_watcher_test.go
  • rollup/internal/utils/utils.go
💤 Files with no reviewable changes: 1
  • bridge-history-api/go.mod

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

Bridge history fetchers and the rollup L1 watcher now use raw RPC responses to read block data, including the RPC-reported hash. The bridge API adds block-response validation. Lint configuration flags selected SDK hash calls, and the version tag changes to v4.8.4.

Changes: RPC block data flow

Layer / File(s) Summary
RPC block decoding and validation
bridge-history-api/internal/utils/utils.go, bridge-history-api/internal/utils/utils_test.go
A new block representation and RPC fetch functions decode block responses and validate required fields. Tests cover valid blocks and malformed or inconsistent responses.
Bridge fetcher RPC wiring
bridge-history-api/cmd/fetcher/app/app.go, bridge-history-api/internal/controller/fetcher/*
The app creates RPC clients and passes them to the L1 and L2 fetchers. Fetcher startup obtains resume and sync block hashes through RPC.
Bridge block processing and reorg handling
bridge-history-api/internal/logic/l1_fetcher.go, bridge-history-api/internal/logic/l2_fetcher.go
L1 and L2 logic fetches block ranges through RPC, reads transaction and timestamp fields from decoded blocks, and retrieves resync block hashes during reorg handling.
Rollup L1 watcher RPC header ingestion
rollup/internal/controller/watcher/l1_watcher.go, rollup/internal/controller/watcher/l1_watcher_test.go, rollup/internal/utils/utils.go, build/.golangci.yml
The watcher reads block header fields and the reported hash from RPC responses. Tests mock RPC calls. Lint rules flag selected SDK hash methods, with exclusions and a suppression for the validium commitment.

Module and version metadata

Layer / File(s) Summary
Module and version metadata
bridge-history-api/go.mod, common/version/version.go
The module replacement directive for go-ethereum is removed. The version tag changes from v4.8.3 to v4.8.4.

Priority: ⬆️ High

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant L1FetcherLogic
  participant GetBlocksInRange
  participant GetBlockByNumber
  participant RPCClient
  participant L1RPCEndpoint
  L1FetcherLogic->>GetBlocksInRange: Fetch a block range
  GetBlocksInRange->>GetBlockByNumber: Fetch each block by number
  GetBlockByNumber->>RPCClient: Request block with transactions
  RPCClient->>L1RPCEndpoint: eth_getBlockByNumber
  L1RPCEndpoint-->>RPCClient: RPC block response
  RPCClient-->>GetBlockByNumber: Decoded response
  GetBlockByNumber-->>GetBlocksInRange: Validated Block
  GetBlocksInRange-->>L1FetcherLogic: Block range
Loading

Suggested reviewers: colinlyguo, georgehao

Merge Risk: ⚪ Minimal · up to d47f1

No confirmed issue blocks merging after normal validation.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 11 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title is concise, uses the required conventional commit type, and accurately summarizes restoring the unpatched SDK and reading block hashes from RPC responses.
Description check Passed The description explains what the PR changes, why the change is needed, and how it works. It includes the required title, deployment versioning, and breaking-change sections with consistent selections…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains what the PR changes, why the change is needed, and how it works. It includes the required title, deployment versioning, and breaking-change sections with consistent selections.

Full details: Docstring Coverage

Explanation

Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 11 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

codecov-commenter commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 34.04255% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.58%. Comparing base (398e90b) to head (d47f1e3).

Files with missing lines Patch % Lines
bridge-history-api/internal/logic/l1_fetcher.go 0.00% 16 Missing ⚠️
bridge-history-api/internal/logic/l2_fetcher.go 0.00% 16 Missing ⚠️
bridge-history-api/internal/utils/utils.go 75.00% 6 Missing and 1 partial ⚠️
bridge-history-api/cmd/fetcher/app/app.go 0.00% 6 Missing ⚠️
...tory-api/internal/controller/fetcher/l1_fetcher.go 0.00% 6 Missing ⚠️
...tory-api/internal/controller/fetcher/l2_fetcher.go 0.00% 6 Missing ⚠️
rollup/internal/controller/watcher/l1_watcher.go 73.33% 3 Missing and 1 partial ⚠️
rollup/internal/utils/utils.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1824      +/-   ##
===========================================
+ Coverage    35.53%   35.58%   +0.05%     
===========================================
  Files          263      263              
  Lines        22763    22805      +42     
===========================================
+ Hits          8089     8116      +27     
- Misses       13824    13837      +13     
- Partials       850      852       +2     
Flag Coverage Δ
bridge-history-api 8.54% <26.92%> (+0.55%) ⬆️
rollup 35.62% <68.75%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Thegaram
Thegaram merged commit 585b170 into develop Oct 22, 2026
9 checks passed
@Thegaram
Thegaram deleted the fix-l1-hash-from-rpc branch October 22, 2026 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants