-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conversation
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.
Minor comments
* @return new state, result of applied transition to the latest input state | ||
*/ | ||
private BeaconStateEx applySlotTransitionsWithoutEpoch( | ||
private BeaconStateEx applySlotTransitions( |
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.
Could we move this helper somewhere in public? I see 2 places where you use it, plus I have another, 3rd, in tests.
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.
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) { |
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.
what does it mean?
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.
It's a reference to saturation arithmetic. Maybe you can come with a better naming to this method?
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.
Just add javadoc comment to plusSat
and minSat
like in UInt64
blsVerify: false | ||
blsVerifyProofOfPosession: false | ||
blsSign: false | ||
blsVerify: true |
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.
why?
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.
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)) { |
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.
condition is always true and looks erroneous
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.
another good catch!
} else { | ||
// Dequeue if the minimum amount of time has passed | ||
return get_current_epoch(state).greaterEqual( | ||
validator.getExitEpoch().plus(getConstants().getMinValidatorWithdrawabilityDelay())); |
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.
we are getting overflow here.FAR_FUTURE
which is usually exit epoch is highest possible number and we are adding MinValidatorWithdrawabilityDelay
to it
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.
Gonna fix it within the others overflows/underflows 👍
@zilm13 ready for the next 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.
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()))); |
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.
Can't get what's the difference between fixed and original version?
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.
BTW still wondering...
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.
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.
👍
@@ -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; | |||
} |
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.
M.b. Arrays.fill()
would more laconic?
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.
Definitely 👍
ObjectHasher<Hash32> sszHasher = SSZObjectHasher.create(hashFunction); | ||
return new SpecHelpers(constants, hashFunction, sszHasher); | ||
} | ||
public class CachingBeaconChainSpec extends DelegatingBeaconChainSpec { |
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.
Delegating wouldn't work for polymorphic invocations. E.g. CachingSpecHelpers.get_permuted_list
would never be called
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.
That's true. Once call reaches delegate it never goes back to a class originated this call. Let me think around a little bit.
What was done?
This PR mainly updates consensus to v0.5.1 version.
Alongside this there are few other changes and fixes:
signed_root
.signed_root
as a block id all over the code.chainSpec
section.SpecHelpers
down to several sub-interfaces.get_shuffling2
fixed in order to pass shuffling tests.Spec issues fixed in this PR
process_exit_queue
, Fix epoch overflow in process_exit_queue ethereum/consensus-specs#875.