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

Update consensus to v0.5.1 #113

Merged
merged 50 commits into from
Apr 3, 2019
Merged

Update consensus to v0.5.1 #113

merged 50 commits into from
Apr 3, 2019

Conversation

mkalinin
Copy link
Contributor

@mkalinin mkalinin commented Apr 1, 2019

What was done?

This PR mainly updates consensus to v0.5.1 version.
Alongside this there are few other changes and fixes:

  • Get rid of field name in signed_root.
  • Use signed_root as a block id all over the code.
  • Fix simulator config with empty chainSpec section.
  • Break SpecHelpers down to several sub-interfaces.
  • get_shuffling2 fixed in order to pass shuffling tests.

Spec issues fixed in this PR

Copy link
Member

@zilm13 zilm13 left a comment

Choose a reason for hiding this comment

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

Minor comments

* @return new state, result of applied transition to the latest input state
*/
private BeaconStateEx applySlotTransitionsWithoutEpoch(
private BeaconStateEx applySlotTransitions(
Copy link
Member

Choose a reason for hiding this comment

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

Could we move this helper somewhere in public? I see 2 places where you use it, plus I have another, 3rd, in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was an idea to add a transition to handle this particular case. Will try to hash it out.

@@ -33,6 +33,23 @@ public Gwei minus(Gwei subtrahend) {
return new Gwei(super.minus(subtrahend));
}

public Gwei minusSat(Gwei subtrahend) {
Copy link
Member

Choose a reason for hiding this comment

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

what does it mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a reference to saturation arithmetic. Maybe you can come with a better naming to this method?

Copy link
Member

Choose a reason for hiding this comment

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

Just add javadoc comment to plusSat and minSat like in UInt64

blsVerify: false
blsVerifyProofOfPosession: false
blsSign: false
blsVerify: true
Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, committed by a mistake. nice catch! 👍


public Gwei plusSat(Gwei addend) {
Gwei res = this.plus(addend);
if (res.lessEqual(res) && addend.greater(Gwei.ZERO)) {
Copy link
Member

Choose a reason for hiding this comment

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

condition is always true and looks erroneous

Copy link
Contributor Author

Choose a reason for hiding this comment

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

another good catch!

} else {
// Dequeue if the minimum amount of time has passed
return get_current_epoch(state).greaterEqual(
validator.getExitEpoch().plus(getConstants().getMinValidatorWithdrawabilityDelay()));
Copy link
Member

Choose a reason for hiding this comment

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

we are getting overflow here.FAR_FUTURE which is usually exit epoch is highest possible number and we are adding MinValidatorWithdrawabilityDelay to it

Copy link
Contributor Author

@mkalinin mkalinin Apr 2, 2019

Choose a reason for hiding this comment

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

Gonna fix it within the others overflows/underflows 👍

@mkalinin
Copy link
Contributor Author

mkalinin commented Apr 2, 2019

@zilm13 ready for the next round

Copy link
Member

@zilm13 zilm13 left a comment

Choose a reason for hiding this comment

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

LGTM

get_current_epoch_committee_count(state), constants.getShardCount()));
state.setCurrentShufflingStartShard(ShardNumber.of(
state.getCurrentShufflingStartShard().plus(get_current_epoch_committee_count(state))
.modulo(constants.getShardCount())));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't get what's the difference between fixed and original version?

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW still wondering...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -2105,6 +2105,9 @@ private Gwei get_inactivity_penalty(BeaconState state, ValidatorIndex index, Epo
new Gwei[state.getValidatorRegistry().size().getIntValue()],
new Gwei[state.getValidatorRegistry().size().getIntValue()]
};
for (ValidatorIndex index : state.getValidatorRegistry().size()) {
deltas[0][index.getIntValue()] = deltas[1][index.getIntValue()] = Gwei.ZERO;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

M.b. Arrays.fill() would more laconic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely 👍

ObjectHasher<Hash32> sszHasher = SSZObjectHasher.create(hashFunction);
return new SpecHelpers(constants, hashFunction, sszHasher);
}
public class CachingBeaconChainSpec extends DelegatingBeaconChainSpec {
Copy link
Contributor

Choose a reason for hiding this comment

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

Delegating wouldn't work for polymorphic invocations. E.g. CachingSpecHelpers.get_permuted_list would never be called

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true. Once call reaches delegate it never goes back to a class originated this call. Let me think around a little bit.

@mkalinin mkalinin merged commit 427e00b into develop Apr 3, 2019
@mkalinin mkalinin deleted the spec/v0.5.1 branch June 3, 2019 09:42
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.

3 participants