Skip to content

feat(consensus): add RPC endpoint to query signing tx count by epoch#2223

Open
benjamin202410 wants to merge 6 commits intodev-upgradefrom
feat(consensus)-add-RPC-endpoint-to-query-signing-tx-count-by-epoch
Open

feat(consensus): add RPC endpoint to query signing tx count by epoch#2223
benjamin202410 wants to merge 6 commits intodev-upgradefrom
feat(consensus)-add-RPC-endpoint-to-query-signing-tx-count-by-epoch

Conversation

@benjamin202410
Copy link
Collaborator

@benjamin202410 benjamin202410 commented Mar 23, 2026

Proposed changes

Add new GetSigningTxCountByEpoch API method that returns signing transaction
counts for all masternodes (including non-active ones) within a specified epoch.
The method validates that the provided block number is an epoch-switch block,
then walks backwards through the epoch collecting signing transactions at
MergeSignRange boundaries.

Also reduces log verbosity by changing two timeout-related log statements from
Info to Debug level in the v2 consensus engine.

Output:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "0x14f375e18a878abb4b713328e392abce98f07bfd": 7,
        "0x311bdf9066246e68559816e7f636435867f824ef": 60,
        "0x442a44a6fc20f5b8dfa8b304d7137581f7e6bef3": 60,
        "0x47318441696e9ae962633c16e04d53935272639d": 60,
        "0x537fc89618edae86950e12687a612e15c4786b84": 60,
        "0x73898cc3c5beca5841306b26fdb4e30411392a6a": 60,
        "0x74826141342a4dc33a1045cefa4182b6212ec031": 60,
        "0x7bc30fbeb7208192d1474b5f87ffbc056de43c11": 60
    }
}
        

Changes:

  • Add GetSigningTxCountByEpoch API method to consensus/XDPoS/api.go
  • Expose method via web3 RPC extension in internal/web3ext/web3ext.go
  • Demote getTCEpochInfo logs from Info to Debug level

Types of changes

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

  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Changes that don't change source code or tests
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Revert something
  • style: Changes that do not affect the meaning of the code
  • test: Adding missing tests or correcting existing tests

Impacted Components

Which parts of the codebase does this PR touch?
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
  • Tested on a private network from the genesis block and monitored the chain operating correctly for multiple epochs.
  • 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

@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 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.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 077e15a8-4348-4d64-864a-c9c5f63e6fd4

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat(consensus)-add-RPC-endpoint-to-query-signing-tx-count-by-epoch

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

Adds a new XDPoS RPC API for querying signing-transaction counts per masternode for a given epoch boundary, and reduces verbosity of some v2 timeout logs.

Changes:

  • Add GetSigningTxCountByEpoch to the XDPoS consensus RPC API.
  • Expose the new method via internal/web3ext as XDPoS_getSigningTxCountByEpoch.
  • Demote two getTCEpochInfo logs from Info to Debug in the v2 engine.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
consensus/XDPoS/api.go Implements the new RPC method to compute signing-tx counts by scanning blocks in an epoch.
internal/web3ext/web3ext.go Adds the Web3 extension method wiring for the new RPC call.
consensus/XDPoS/engines/engine_v2/timeout.go Lowers log level for timeout/epoch-info messages to reduce noise.

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

benjamin202410 and others added 4 commits March 23, 2026 23:38
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

6 participants