-
Notifications
You must be signed in to change notification settings - Fork 189
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
Updated minimum staking related logic #920
Updated minimum staking related logic #920
Conversation
@KimKyungup @jeongkyun-oh The third policy probably becomes a huddle for Service Chain or Private Chain operators. How about letting "Governing node in single mode" propose a block? |
80e11ec
to
1aac62b
Compare
@jeongkyun-oh @aidan-kwon |
1aac62b
to
077152e
Compare
governance/default.go
Outdated
if minimumStakingAmount, ok := new(big.Int).SetString(gov.MinimumStake(), 10); ok { | ||
params.SetMinimumStakingAmount(minimumStakingAmount) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as updateMinimumStakingAmount
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but updateMinimumStakingAmount
is a trigger function for voting. There is no proper key and value for this.
consensus/istanbul/backend/engine.go
Outdated
// they will not be in the committee as well as the proposer candidates list. | ||
pHeader := chain.GetHeaderByNumber(params.CalcStakingBlockNumber(snap.Number + 1)) | ||
if pHeader != nil { | ||
if err := snap.ValSet.TransitionValidators(pHeader.Hash(), pHeader.Number.Uint64()); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an error we can ignore and does not make any problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is updated and moved to into Refresh
function. Please take another look.
} | ||
|
||
if len(newWeightedValidators) <= 0 { | ||
return newWeightedDemoted, newDemotedStaking, []*weightedValidator{}, []float64{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we return demoted validators and their staking info in this place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no validator has enough KLAYs, the demoted validators can still propose blocks to prevent them from not creating blocks.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -607,17 +656,62 @@ func (valSet *weightedCouncil) Refresh(hash common.Hash, blockNum uint64) error | |||
return nil | |||
} | |||
|
|||
// updateValidators converts weighted validator slice to istanbul.Validators and sets them to the council. | |||
func (valSet *weightedCouncil) updateValidators(validators []*weightedValidator, demoted []*weightedValidator) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor comment, but I think set
would be more appropriate in this case.
set
-> does nothing or little inside the functionupdate
-> does something inside the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thanks!
63db488
to
2c8e809
Compare
@aidan-kwon As we talked f2f, I will update the following cases.
|
71ff89a
4ccdb5a
to
71ff89a
Compare
snap.ValSet, snap.Votes, snap.Tally = gov.HandleGovernanceVote(snap.ValSet, snap.Votes, snap.Tally, header, validator, addr) | ||
if policy == uint64(params.WeightedRandom) { | ||
// Snapshot of block N (Snapshot_N) should contain proposers for N+1 and following blocks. | ||
// And proposers for Block N+1 can be calculated from the nearest previous proposersUpdateInterval block. | ||
// Let's refresh proposers in Snapshot_N using previous proposersUpdateInterval block for N+1, if not updated yet. | ||
pHeader := chain.GetHeaderByNumber(params.CalcProposerBlockNumber(number + 1)) | ||
if pHeader != nil { | ||
if err := snap.ValSet.Refresh(pHeader.Hash(), pHeader.Number.Uint64(), chain.Config()); err != nil { | ||
// There are three error cases and they just don't refresh proposers | ||
// (1) no validator at all | ||
// (2) invalid formatted hash | ||
// (3) no staking info available | ||
logger.Trace("Skip refreshing proposers while creating snapshot", "snap.Number", snap.Number, "pHeader.Number", pHeader.Number.Uint64(), "err", err) | ||
} | ||
} else { | ||
logger.Trace("Can't refreshing proposers while creating snapshot due to lack of required header", "snap.Number", snap.Number) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a lock for atomicity of snap.ValSet
? @jeongkyun-oh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think no need to lock snap.ValSet
which is accessed synchronously.snap.ValSet
is an interface for weightedCouncil
. If you worry about the validators
and demotedValidators
, the validatorsMu
protects them in weightedCouncil
.
Proposed changes
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.
$ make test
)