Skip to content

feat(api/xdpos): upgrade GetMasternodesByNumber to support TipUpgradeReward#2422

Open
wanwiset25 wants to merge 3 commits into
dev-upgradefrom
upgrade-getMasterNodesByNumber
Open

feat(api/xdpos): upgrade GetMasternodesByNumber to support TipUpgradeReward#2422
wanwiset25 wants to merge 3 commits into
dev-upgradefrom
upgrade-getMasterNodesByNumber

Conversation

@wanwiset25

Copy link
Copy Markdown
Collaborator

Proposed changes

Extend the XDPoS_getMasternodesByNumber RPC so its response reflects the node tiers introduced by the TIPUpgradeReward fork.

For blocks before TIPUpgradeReward, behavior is unchanged

For blocks from TIPUpgradeReward onward, the standby pool is split into the reward tiers: the top MaxProtectorNodes become Protector, the next MaxObverserNodes become Observer, and the remainder stays in Standbynodes.

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

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

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: df3a03d3-da87-4ac2-9424-f5105373baaf

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 upgrade-getMasterNodesByNumber

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.

Comment thread consensus/XDPoS/api.go Outdated
Epoch uint64
Number uint64
Round types.Round
TipUpgradeReward bool // whether the protector/observer tiers are active at this block

@benjamin202410 benjamin202410 Jun 29, 2026

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.

we don't need this flag at json response, you can make it lowercase tipUpgradeReward

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

do you mean we can infer from the returned Protectornodes or Standbynodes ?

Comment thread consensus/XDPoS/api.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

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 extends the XDPoS_getMasternodesByNumber RPC response to reflect the node reward tiers introduced by the TIPUpgradeReward fork by partitioning the standby pool into Protector, Observer, and remaining Standbynodes for post-fork blocks.

Changes:

  • Extends MasternodesStatus with TipUpgradeReward, Protector*, and Observer* fields.
  • Updates GetMasternodesByNumber to split the standby slice into tiered segments when TIPUpgradeReward is active.
  • Adds clarifying comments about tier semantics (snapshot-consistent vs reward-hook live state).

Comment thread consensus/XDPoS/api.go
Comment thread consensus/XDPoS/api.go Outdated
- rename Protector/Observer fields to Protectornodes/Observernodes
- omit empty outputs
- rename standbynodes > standbyPool to prevent confusion
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