-
Notifications
You must be signed in to change notification settings - Fork 47
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
Adapt stake to new definitions #1300
Conversation
pkg/core/consensus/user/sortition.go
Outdated
@@ -115,8 +115,8 @@ func (p Provisioners) CreateVotingCommittee(seed []byte, round uint64, step uint | |||
break | |||
} | |||
|
|||
if m.Stakes[i].StartHeight > round || m.Stakes[i].EndHeight < round { | |||
subtractFromTotalWeight(W, m.Stakes[i].Amount) | |||
if m.Stakes[i].CreatedAt > round || m.Stakes[i].Eligibility < round { |
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.
@autholykos I'm concerned about this, not sure if it's correct anymore with respect to what's now understood as "valid"
Would appreciate any insight on the matter...
cc/ @ureeves @goshawk-3
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.
Since expiration is now removed, the logic around it should be removed here as well.
eligibility
is the block at which a stake starts being valid. Assuming that round
is the current block (unsure about this), the logic should then be exceedingly simple:
if round >= m.Stakes[i].Eligibility {
// stake is valid here
}
@@ -358,6 +358,6 @@ func unmarshalStake(r *bytes.Buffer) (Stake, error) { | |||
|
|||
// Format implements fmt.Formatter interface. | |||
func (s Stake) Format(f fmt.State, c rune) { | |||
r := fmt.Sprintf("Amount: %d, From: %d, To: %d", s.Amount, s.StartHeight, s.EndHeight) | |||
r := fmt.Sprintf("Value: %d, From: %d, To: %d", s.Value, s.CreatedAt, s.Eligibility) |
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.
This should be changed according to the new fields meaning
@@ -163,7 +163,7 @@ func (p Provisioners) SubsetSizeAt(round uint64) int { | |||
|
|||
for _, member := range p.Members { | |||
for _, stake := range member.Stakes { | |||
if stake.StartHeight <= round && round <= stake.EndHeight { | |||
if stake.CreatedAt <= round && round <= stake.Eligibility { |
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.
IIUC the eligibility
is when the stake become effective (as the old startHeight)
Said that, should the round>=elegibility
be the only needed check?
pkg/core/consensus/fixtures.go
Outdated
member.Stakes[0].Amount = 500 | ||
member.Stakes[0].EndHeight = 10000 | ||
member.Stakes[0].Value = 500 | ||
member.Stakes[0].Eligibility = 10000 |
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 eligibility should be 1
, it replace the start_height at line 101
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.
LGTM
Resolves: #1299