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

Check for validator logout in slashing is off #75

Closed
djrtwo opened this Issue Apr 6, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@djrtwo
Contributor

djrtwo commented Apr 6, 2018

Issue

The following code found here in slash is incorrect

self.dynasty_wei_delta[self.dynasty + 1] -= deposit

if self.validators[validator_index_1].end_dynasty < self.default_end_dynasty:
    self.dynasty_wei_delta[self.validators[validator_index_1].end_dynasty] += deposit

This modifies self.dynasty_wei_delta for the validator's end_dynasty even after that dynasty has begun/occurred, and more importantly, it modifies the next dynasty regardless of whether the validator is already logged out. This will result in a doubly subtracted deposit total from the total deposits.

Proposed Implementation

  • Change the conditional statement to:
end_dynasty: int128 = self.validators[validator_index_1].end_dynasty

# if validator not logged out yet, remove total from next dynasty
if self.dynasty < end_dynasty:
    self.dynasty_wei_delta[self.dynasty + 1] -= deposit

    # if validator was already staged for logout at end_dynasty,
    # ensure that we don't doubly remove from total
    if end_dynasty < self.default_end_dynasty:
         self.dynasty_wei_delta[end_dynasty] += deposit
  • add relevant tests
@djrtwo

This comment has been minimized.

Contributor

djrtwo commented Apr 13, 2018

addressed in #81

@djrtwo djrtwo closed this Apr 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment