Skip to content

fix(jsonrpc): post log/block filters for reorg-applied blocks#6819

Merged
kuny0707 merged 3 commits into
tronprotocol:release_v4.8.2from
0xbigapple:fix/reorg-jsonrpc-logsfilter
Jun 11, 2026
Merged

fix(jsonrpc): post log/block filters for reorg-applied blocks#6819
kuny0707 merged 3 commits into
tronprotocol:release_v4.8.2from
0xbigapple:fix/reorg-jsonrpc-logsfilter

Conversation

@0xbigapple

@0xbigapple 0xbigapple commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds reApplyLogsFilter(List<KhaosBlock>), invoked after switchFork has fully applied the new branch (oldest-first), mirroring blockTrigger's jsonrpc FULL handling so reorg'd blocks reach the FULL stream like the normal extend path.

Why are these changes required?

On a reorg, pushBlock calls switchFork() and returns early, never reaching blockTrigger() — the only place that posts the "added" FULL filters (postBlockFilter / postLogsFilter(block, false, false)). The rollback side withdraws the orphaned branch's logs (reOrgLogsFilter, removed=true), but nothing re-posts the new branch's logs: withdraw old, never add new, violating reorg semantics.

So dApps using eth_newFilter + eth_getFilterChanges miss every log in blocks applied via switchFork.

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

  • Failed-rollback (switch-back) path — new branch's logs not re-posted; out of scope, known limitations
  • Event-plugin block/transaction triggers — not posted on the reorg path; out of scope, known limitations

Extra details

@github-actions github-actions Bot requested a review from bladehan1 June 4, 2026 06:20
@lvs0075 lvs0075 added this to the GreatVoyage-v4.8.2 milestone Jun 4, 2026
@halibobo1205 halibobo1205 added topic:json-rpc topic:event subscribe transaction trigger, block trigger, contract event, contract log labels Jun 4, 2026
Comment thread framework/src/main/java/org/tron/core/db/Manager.java
Comment thread framework/src/test/java/org/tron/core/db/ManagerTest.java
…er elements

 - Restore topicToByteArray for LogFilter topics, guard with (0x)?[0-9a-fA-F]{63,64}$ so the stripped zero is padded back by ByteArray.fromHexString, while non-hex or wrong-length input still gets a clean -32602.
 - LogFilter: validate element types before the (String) cast in the address array and nested topic array loops.

@bladehan1 bladehan1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kuny0707 kuny0707 merged commit c3263dc into tronprotocol:release_v4.8.2 Jun 11, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:event subscribe transaction trigger, block trigger, contract event, contract log topic:json-rpc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants