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

Adapt stake to new definitions #1300

Merged
merged 1 commit into from
Feb 17, 2022
Merged

Adapt stake to new definitions #1300

merged 1 commit into from
Feb 17, 2022

Conversation

t00ts
Copy link
Contributor

@t00ts t00ts commented Feb 16, 2022

Resolves: #1299

@@ -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 {
Copy link
Contributor Author

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

Copy link
Member

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)
Copy link
Member

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 {
Copy link
Member

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?

@t00ts t00ts marked this pull request as ready for review February 17, 2022 08:49
@t00ts t00ts changed the title wip: adapt stake to new definitions Adapt stake to new definitions Feb 17, 2022
member.Stakes[0].Amount = 500
member.Stakes[0].EndHeight = 10000
member.Stakes[0].Value = 500
member.Stakes[0].Eligibility = 10000
Copy link
Member

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

Copy link
Member

@herr-seppia herr-seppia left a comment

Choose a reason for hiding this comment

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

LGTM

@t00ts t00ts merged commit 7baab69 into master Feb 17, 2022
@t00ts t00ts deleted the fix-1299 branch February 17, 2022 09:58
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.

Adapt the stake.proto to the latest specification and layout of the Rusk contract
4 participants