Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update node weight #272

Closed
wants to merge 4 commits into from
Closed

Update node weight #272

wants to merge 4 commits into from

Conversation

Neeharika-Sompalli
Copy link
Member

@Neeharika-Sompalli Neeharika-Sompalli commented Apr 21, 2023

Fixes #271

Related to hashgraph/hedera-services#6204

Adds Consensus Weight to NodeStake to update mirror nodes with the staking info updated midnight UTC

/**
* The consensus weight of this node in the network. This is computed based on the stake of this node
* at midnight UTC of the current day. If the stake of this node is less than minStake, then the
* weight is 0. Sum of all weights of nodes in the network should be less than 500.
Copy link
Contributor

@tinker-michaelj tinker-michaelj Apr 21, 2023

Choose a reason for hiding this comment

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

I might tweak this to give a little more context,

The network normalizes the weights of nodes above minStake so that the total sum of
weight is approximately 500. Specifically, the weight of a node A with stake > minStake
is computed using integer arithmetic as,

A_weight = Math.max((# of whole hbars staked by A) * 500 / (total # of whole hbars staked), 1)

so that every node above minStake has weight at least 1; but any node that has staked
at least 1 out of every 250 whole hbars staked will have weight >= 2. 

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @tinker-michaelj . Updated

Copy link
Contributor

@tinker-michaelj tinker-michaelj left a comment

Choose a reason for hiding this comment

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

One suggestion on comment, otherwise LGTM!

@@ -112,7 +112,7 @@ message NodeStake {
int64 reward_rate = 4;

/**
* Consensus weight of this node for the new staking period.
* Total stake (rewarded and not rewarded) of this node at the beginning of the new staking period.
Copy link
Contributor

Choose a reason for hiding this comment

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

it's true only when min_stake <= stake_rewarded + stake_not_rewarded <= max_stake I believe. i.e. if the sum is less than min_stake, stake is 0; if the sum is more than max_stake, stake = max_stake

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah just discussed with Nick and the same field can be used as the consensus weight .

@Neeharika-Sompalli
Copy link
Member Author

NodeStake.stake field will be used as the consensus weight to export value to mirror node. No need for a new field. Closing this PR.

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.

Add consensus weight to NodeStake
3 participants