kaiax/staking,reward: Introduce consensus liquidity #176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
This PR introduces consensus liquidity to staking, reward modules.
The consensus liquidity will be activated for network activating Prague hardfork and
istanbul.policy == 2 && reward.deferredtxfee = true
.Staking module
When
GetStakingInfo
, if condition met, it reads CLInfos fromCLRegistry
defined in KIP-226. IfRegistry
hasn't been installed (by any reason), it skips CL and don't panic. IfCLRegistry
hasn't been registered, it will return empty arrays.Reward module
When
ConsolidatedNodes()
, if condition met, it consolidates CLInfos byCLNodeId
, notCLRewardAddr
.Let's assume we have following entries in AddressBook and CLRegistry.
Then, the
clr1
isn't neitherr1
norr2
. But it will be consolidated into[n1, n2]
since it hasCLNodeId == n2
. The result consolidated nodes are:If
CLNodeId
doesn't belong to any of node, then it'll be ignored. Note thatCLNodeId
can be any ofNodeId
, not firstNodeId
.Reward distribution
If validator has CL, then the staking in CL also summed up to total staking amount if
staking in AB >= minStaking
.The excess staking amount will be calculated by:
Both the proposer and staking rewards will be proportionally distributed to
RewardAddr
andCLRewardAddr
. For proposer, please see#specWithProposerAndFunds
.API
The
kaia.GetStakingInfo
will be affected andCLStakingInfos
field will be null before prague HF or empty CLRegistry entries.Testing
The unit tests are included in this PR. I'll start testing in private network once this PR stabilized.
Types of changes
Please put an x in the boxes related to your change.
Checklist
Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
I have read the CLA Document and I hereby sign the CLA
in first time contribute$ make test
)Related issues
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...