Skip to content

Conversation

@gzliudan
Copy link
Collaborator

@gzliudan gzliudan commented Jan 29, 2026

This change removes support for subscribing to pending logs.

"Pending logs" were always an odd feature, because it can never be fully reliable. When support for it was added many years ago, the intention was for this to be used by wallet apps to show the 'potential future token balance' of accounts, i.e. as a way of notifying the user of incoming transfers before they were mined. In order to generate the pending logs, the node must pick a subset of all public mempool transactions, execute them in the EVM, and then dispatch the resulting logs to API consumers.

Ref:

Proposed changes

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

Summary by CodeRabbit

Release Notes

  • Refactor
    • Pending logs filtering is no longer available in filter queries
    • Simplified filter API interface; reduced parameters required for filter initialization
    • Streamlined event subscription system by removing light mode features and consolidating subscription types

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

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 and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes support for pending logs subscriptions from the Ethereum filters system. The functionality was deemed unreliable since nodes must speculatively execute mempool transactions to generate pending logs, which can never be fully accurate. The PR simplifies the filter system by removing the pending logs feature and the light mode parameter.

Changes:

  • Removed PendingBlockAndReceipts() and SubscribePendingLogsEvent() from the filters Backend interface
  • Removed lightMode parameter from NewEventSystem() and NewFilterAPI() functions
  • Added errPendingLogsUnsupported error for pending logs queries
  • Removed pending logs subscription types (PendingLogsSubscription, MinedAndPendingLogsSubscription)
  • Removed light client-specific filtering logic
  • Updated all tests to reflect the removal of pending logs functionality

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
eth/filters/api.go Added new error for unsupported pending logs, removed lightMode parameter from NewFilterAPI
eth/filters/filter.go Removed pendingLogs() method, simplified block range validation to reject pending block numbers
eth/filters/filter_system.go Removed pending logs subscription types, event handling, light mode filtering logic, and associated helper methods
eth/filters/filter_test.go Updated tests to expect errors for pending log queries instead of returning results
eth/filters/filter_system_test.go Removed TestPendingLogsSubscription and TestLightFilterLogs tests, updated test setup to remove lightMode parameter
eth/backend.go Updated NewFilterAPI call to remove lightMode parameter
cmd/utils/flags.go Updated NewFilterAPI call to remove lightMode parameter
accounts/abi/bind/backends/simulated.go Updated NewEventSystem calls to remove lightMode parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@eth/filters/filter.go`:
- Around line 147-169: Add an explicit validation in the filter range
resolution: after calling resolveSpecial for f.begin and f.end (before assigning
f.begin/f.end and before any arithmetic or rangeLimit checks in the function
that calls rangeLogsAsync), check if end < begin and return a clear
invalid-range error (consistent with SubscribeLogs) instead of proceeding;
update the code paths around resolveSpecial, the rangeLimit check, and the call
sites (e.g., where f.begin/f.end are set and rangeLogsAsync is invoked) to
ensure the new validation prevents silent empty results and underflowed
subtraction when computing (end - begin).

Comment on lines 147 to +169
// range query need to resolve the special begin/end block number
if f.begin, err = resolveSpecial(f.begin); err != nil {
begin, err := resolveSpecial(f.begin)
if err != nil {
return nil, err
}
if f.end, err = resolveSpecial(f.end); err != nil {
end, err := resolveSpecial(f.end)
if err != nil {
return nil, err
}
if f.rangeLimit != 0 && (uint64(f.end)-uint64(f.begin)) > f.rangeLimit {
if f.rangeLimit != 0 && (end-begin) > f.rangeLimit {
return nil, fmt.Errorf("exceed maximum block range: %d", f.rangeLimit)
}

f.begin = int64(begin)
f.end = int64(end)
logChan, errChan := f.rangeLogsAsync(ctx)
var logs []*types.Log
for {
select {
case log := <-logChan:
logs = append(logs, log)
case err := <-errChan:
if err != nil {
// if an error occurs during extraction, we do return the extracted data
return logs, err
}
// Append the pending ones
if endPending {
pendingLogs := f.pendingLogs()
logs = append(logs, pendingLogs...)
}
return logs, nil
return logs, err
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add explicit end ≥ begin validation before range arithmetic.

Right now, if end < begin and rangeLimit == 0, the filter silently returns empty results; when rangeLimit != 0, (end-begin) underflows and yields a misleading “exceed maximum block range” error. Consider returning an invalid-range error up front (consistent with SubscribeLogs).

💡 Suggested fix
  end, err := resolveSpecial(f.end)
  if err != nil {
      return nil, err
  }
+ if end < begin {
+     return nil, errInvalidBlockRange
+ }
  if f.rangeLimit != 0 && (end-begin) > f.rangeLimit {
      return nil, fmt.Errorf("exceed maximum block range: %d", f.rangeLimit)
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// range query need to resolve the special begin/end block number
if f.begin, err = resolveSpecial(f.begin); err != nil {
begin, err := resolveSpecial(f.begin)
if err != nil {
return nil, err
}
if f.end, err = resolveSpecial(f.end); err != nil {
end, err := resolveSpecial(f.end)
if err != nil {
return nil, err
}
if f.rangeLimit != 0 && (uint64(f.end)-uint64(f.begin)) > f.rangeLimit {
if f.rangeLimit != 0 && (end-begin) > f.rangeLimit {
return nil, fmt.Errorf("exceed maximum block range: %d", f.rangeLimit)
}
f.begin = int64(begin)
f.end = int64(end)
logChan, errChan := f.rangeLogsAsync(ctx)
var logs []*types.Log
for {
select {
case log := <-logChan:
logs = append(logs, log)
case err := <-errChan:
if err != nil {
// if an error occurs during extraction, we do return the extracted data
return logs, err
}
// Append the pending ones
if endPending {
pendingLogs := f.pendingLogs()
logs = append(logs, pendingLogs...)
}
return logs, nil
return logs, err
// range query need to resolve the special begin/end block number
begin, err := resolveSpecial(f.begin)
if err != nil {
return nil, err
}
end, err := resolveSpecial(f.end)
if err != nil {
return nil, err
}
if end < begin {
return nil, errInvalidBlockRange
}
if f.rangeLimit != 0 && (end-begin) > f.rangeLimit {
return nil, fmt.Errorf("exceed maximum block range: %d", f.rangeLimit)
}
f.begin = int64(begin)
f.end = int64(end)
logChan, errChan := f.rangeLogsAsync(ctx)
var logs []*types.Log
for {
select {
case log := <-logChan:
logs = append(logs, log)
case err := <-errChan:
return logs, err
🤖 Prompt for AI Agents
In `@eth/filters/filter.go` around lines 147 - 169, Add an explicit validation in
the filter range resolution: after calling resolveSpecial for f.begin and f.end
(before assigning f.begin/f.end and before any arithmetic or rangeLimit checks
in the function that calls rangeLogsAsync), check if end < begin and return a
clear invalid-range error (consistent with SubscribeLogs) instead of proceeding;
update the code paths around resolveSpecial, the rangeLimit check, and the call
sites (e.g., where f.begin/f.end are set and rangeLogsAsync is invoked) to
ensure the new validation prevents silent empty results and underflowed
subtraction when computing (end - begin).

This change removes support for subscribing to pending logs.

"Pending logs" were always an odd feature, because it can never be fully reliable. When support for it was added many years ago, the intention was for this to be used by wallet apps to show the 'potential future token balance' of accounts, i.e. as a way of notifying the  user of incoming transfers before they were mined. In order to generate the pending logs, the node must pick a subset of all public mempool transactions, execute them in the EVM, and then dispatch the resulting logs to API consumers.
@gzliudan gzliudan force-pushed the disable-pending-logs branch from ca41258 to 96816b2 Compare January 29, 2026 10:02
@gzliudan gzliudan changed the title eth/filters: remove support for pending logs #28623 #29574 [WIP] eth/filters: remove support for pending logs #28623 #29574 Feb 5, 2026
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.

3 participants