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

Make updateMembershipHistory in Validators.sol correct if epoch number is 0 #8060

Merged
merged 5 commits into from
Jun 11, 2021

Conversation

oneeman
Copy link
Contributor

@oneeman oneeman commented Jun 8, 2021

Description

Celo-blockchain has a tool called mycelo which applies the core contract migrations as part of genesis generation. This means that the epoch number when they are run is zero. However, the updateMembershipHistory() method in Validators.sol did not expect that to be possible. As a result, when mycelo adds a validator to a validator group, the method does not add a new entry to the member's history (specifically, it does not increase numEntries from 0 to 1 as it should). This commit fixes that by adding a condition to the check for whether to replace an existing entry, namely that the number of entries isn't zero.

This will allow the e2e slashing tests to use mycelo instead of running the migrations against the live network.

Other changes

  • Updated the contract to use InitializableV2 as required by CI.

Tested

  • Verified that, before this fix, validators' membership history is empty when they are added to the group using mycelo
  • Verified that, after this fix, validators' membership history is correct when they are added to the group using mycelo
  • Protocol package's automated tests pass
  • Logically speaking, the change makes sense

Backwards compatibility

Backwards compatible, as this only fixes a bug in an edge case the contract wasn't originally designed to handle.

Or Neeman added 4 commits June 8, 2021 08:36
…r is 0.

Celo-blockchain has a tool called mycelo which applies the core contract migrations as part of genesis generation. This means that the epoch number when they are run is zero. However, the updateMembershipHistory() method in Validators.sol did not expect that to be possible. As a result, when mycelo adds a validator to a validator group, the method does not add a new entry to the member's history (specifically, it does not increase numEntries from 0 to 1 as it should). This commit fixes that by adding a condition to the check for whether to replace an existing entry, namely that the number of entries isn't zero.
@oneeman oneeman added the automerge Have PR merge automatically when checks pass label Jun 9, 2021
@oneeman oneeman marked this pull request as ready for review June 9, 2021 14:52
@oneeman oneeman requested review from a team and yorhodes June 9, 2021 14:52
oneeman pushed a commit that referenced this pull request Jun 10, 2021
@oneeman oneeman requested a review from codyborn June 11, 2021 17:31
Copy link
Contributor

@codyborn codyborn left a comment

Choose a reason for hiding this comment

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

LGTM!

@mergify mergify bot merged commit 01a82de into master Jun 11, 2021
@mergify mergify bot deleted the oneeman/validators-contract-tweak branch June 11, 2021 19:33
eelanagaraj pushed a commit that referenced this pull request Jun 17, 2021
…r is 0 (#8060)

### Description

Celo-blockchain has a tool called mycelo which applies the core contract migrations as part of genesis generation. This means that the epoch number when they are run is zero. However, the updateMembershipHistory() method in Validators.sol did not expect that to be possible. As a result, when mycelo adds a validator to a validator group, the method does not add a new entry to the member's history (specifically, it does not increase numEntries from 0 to 1 as it should). This commit fixes that by adding a condition to the check for whether to replace an existing entry, namely that the number of entries isn't zero.

This will allow the e2e slashing tests to use mycelo instead of running the migrations against the live network.

### Other changes

* Updated the contract to use `InitializableV2` as required by CI.

### Tested

* Verified that, before this fix, validators' membership history is empty when they are added to the group using mycelo
* Verified that, after this fix, validators' membership history is correct when they are added to the group using mycelo
* Protocol package's automated tests pass
* Logically speaking, the change makes sense

### Backwards compatibility

Backwards compatible, as this only fixes a bug in an edge case the contract wasn't originally designed to handle.
tkporter pushed a commit that referenced this pull request Jul 8, 2021
…r is 0 (#8060)

### Description

Celo-blockchain has a tool called mycelo which applies the core contract migrations as part of genesis generation. This means that the epoch number when they are run is zero. However, the updateMembershipHistory() method in Validators.sol did not expect that to be possible. As a result, when mycelo adds a validator to a validator group, the method does not add a new entry to the member's history (specifically, it does not increase numEntries from 0 to 1 as it should). This commit fixes that by adding a condition to the check for whether to replace an existing entry, namely that the number of entries isn't zero.

This will allow the e2e slashing tests to use mycelo instead of running the migrations against the live network.

### Other changes

* Updated the contract to use `InitializableV2` as required by CI.

### Tested

* Verified that, before this fix, validators' membership history is empty when they are added to the group using mycelo
* Verified that, after this fix, validators' membership history is correct when they are added to the group using mycelo
* Protocol package's automated tests pass
* Logically speaking, the change makes sense

### Backwards compatibility

Backwards compatible, as this only fixes a bug in an edge case the contract wasn't originally designed to handle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants