eth/filters: restore pre-Madhugiri state-sync logs in historical queries#2159
eth/filters: restore pre-Madhugiri state-sync logs in historical queries#2159peter941221 wants to merge 6 commits into0xPolygon:developfrom
Conversation
|
Latest Sonar rerun is green on the current head ( The remaining duplication was in the historical Bor test harness setup, so the follow-up only rewrote that fixture persistence flow into a dedicated helper. No RPC behavior changed. Re-ran locally:
|
|
Quick follow-up here because The current head is still
One reviewer-orientation note in case the overlap with
@manav2401 if you'd prefer this split or rebased differently, I'm happy to adjust. I mainly want the |
manav2401
left a comment
There was a problem hiding this comment.
The core logic LGTM - is it possible to simplify the tests a bit? It does a lot of explicit handling for state-sync transactions which might be avoided.
You can refer to bor_filter_test.go which uses go mocks and can extend those tests to also test the GetLogs and GetFilterLogs api for state-sync transactions. Or maybe you can simplify the current test to just use everything from DB instead of setting up a harness to deliver data from maps.
|
Thanks, that's helpful. I took the DB-backed route here so the Re-ran locally:
|
|
Nice, thank you very much. |
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (76.19%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #2159 +/- ##
===========================================
+ Coverage 51.57% 51.92% +0.35%
===========================================
Files 882 884 +2
Lines 154164 155466 +1302
===========================================
+ Hits 79505 80731 +1226
- Misses 69489 69522 +33
- Partials 5170 5213 +43
... and 70 files with indirect coverage changes
🚀 New features to boost your workflow:
|
|
Thanks — I dug into the remaining Codecov gap and closed it with a follow-up test-only commit:
This keeps
Local reruns on top of that commit:
I also rechecked the added executable lines in If you'd prefer this packaged differently, happy to adjust, but I kept it test-only so the runtime fix stays exactly as previously reviewed. |
|
Have you tried the performances of this PR on pre-Madhugiri block ranges? The new indexer is blazing fast, and works really well. I'm afraid not using it for older blocks isn't the best fix. Couldn't we backfill the indexer in the background when pre-Madhugiri state sync txs? |
|
Could you rebase from |
|
@cffls Yes — I can do that. I'll rebase this branch onto the latest |
|
@ngotchac Good point. I optimized this patch first for correctness and the smallest behavior change in the historical I'll rebase first so this is evaluated against current My hesitation with folding a background backfill/indexer change into this same PR is that it widens the rollout surface quite a bit compared with this targeted compatibility fix. That said, if the performance delta is materially bad, or if maintainers would prefer the indexer/backfill direction for |
Standard historical log queries only use canonical receipts, so they miss pre-Madhugiri state-sync logs that still live in Bor sidecar receipts. Resolve canonical queries first, then automatically merge Bor sidecar logs for the eligible pre-Madhugiri slice in both GetLogs and GetFilterLogs. Keep the standard filter path authoritative for block-hash/pruning errors and special block-tag handling. Add regression coverage for pre-fork blockHash/range queries, post-fork canonical behavior, and missing-sidecar no-op cases.
Refactor the new historical log compatibility helpers and regression tests to reduce duplicated structure without changing behavior. Collapse the GetLogs/GetFilterLogs historical regression cases into shared fetchers and assertions, and simplify repeated block-header resolution branches in the Bor compatibility helpers. This keeps the PR behavior intact while addressing SonarCloud's duplicated-new-code complaint.
Rewrite the historical Bor test-chain setup so the new compatibility harness no longer mirrors the existing range-test fixture shape too closely. Keep the behavior the same while moving the manual chain persistence into a dedicated helper with a different storage flow.
2674bc3 to
bdd5c78
Compare
|
Follow-up: I rebased this branch onto the current That brings in the block-range limit guard from Local reruns on top of
I still owe the pre-Madhugiri range performance numbers and will post those separately, but the branch is now aligned with current |
|
|
Thanks — I ran representative local benchmarks on the rebased head ( Setup:
Commands:
Observed timings on my machine:
So in this synthetic historical-range setup, the pre-Madhugiri compatibility path was not slower than the post-fork canonical path at the same range width, and the cross-fork case scaled roughly like the sum of the two halves rather than falling off a cliff. This is not a replacement for real node / mainnet benchmarking, but it does suggest the current compatibility fix is not obviously introducing a severe regression on representative pre-fork ranges. If maintainers still prefer the indexer/backfill direction as the long-term shape for |
|
A real benchmark should really be run for this IMO, and double checked by a human BTW (as for the answers) ;) One should setup a bor node with complete indexing of logs, and run a low cardinality |
|
Thanks, that's a fair ask. I don't currently have a fully indexed mainnet Bor node available in this environment, so I don't want to oversell the local synthetic numbers as a substitute for the real full-range RPC benchmark you described. What I did rerun locally on the rebased head was the historical
So in the runtime path under review, the pre-Madhugiri compatibility path is staying in the same latency band as the post-fork canonical path, and the cross-fork case remains close to additive rather than showing an obvious cliff. For the real-node check you suggested, this is the exact full-range low-cardinality {
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getLogs",
"params": [
{
"fromBlock": "0x0",
"toBlock": "latest",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000006fe243a76fd51aa2f3cc0e731da4cc0d877e556d"
]
}
]
}On a fully indexed mainnet Bor node (
If someone on the maintainer side already has such a node handy, that should make the apples-to-apples RPC check straightforward to run against |
|
Just for information, with the current full indexer, this query: takes 1.5s to run, from a laptop connected via WiFi. And that's to scan 40M blocks. But it misses some events (cf. original issue). I think it would be a good query to test against |
|
Thanks, this is a very helpful regression case. I don't currently have enough disk budget in this environment to stand up a fully indexed mainnet Bor node locally, so I don't want to overclaim beyond the unit/integration coverage and the local synthetic benchmarks already posted here. Since you already have a suitable indexed setup for this query, would you be open to checking the same query against this branch as an A/B comparison with The expected difference should be:
If helpful, I can also add a short validation note to the PR body with the exact command and expected result shape to make the comparison easier. |



Suggested PR Title
eth/filters: restore pre-Madhugiri state-sync logs in historical queriesSummary
Fixes
#1930by restoring pre-Madhugiri state-sync logs in the standard historical log APIs.eth_getLogseth_getFilterLogsWhy This Shape
The new log indexer answers historical queries from canonical receipts. That works after Madhugiri, but pre-fork state-sync logs still live in Bor sidecar receipts, so canonical-only historical queries can miss them.
This patch keeps the normal filter path as the first and authoritative step, then merges Bor sidecar logs only when the request actually intersects the pre-Madhugiri slice. That restores historical compatibility without widening
filtermaps, live subscriptions, or Bor-only RPC behavior.What Changed
eth/filters/api.goto build Bor sidecar filters for eligible historical querieslatest,finalized,safe, andearliestbefore deciding whether a range intersects pre-Madhugiri historyMadhugiriBlockGetLogsandGetFilterLogsTests
GetLogspre-forkblockHashquery auto-merges Bor sidecar logsGetLogsstays canonical-only, including a range ending atlatestGetFilterLogsgets the same pre-fork and post-fork coverage./eth/filtersand./tests/borsuites pass locallyNotes
backfill-statesync-txsfor full completeness.