mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
prevent validator exit reentrance (#2443)
This commit is contained in:
parent
3f742d79c0
commit
7a7b4e55c9
@ -206,11 +206,10 @@ func InitiateValidatorExit(state *pb.BeaconState, idx uint64) *pb.BeaconState {
|
||||
func ExitValidator(state *pb.BeaconState, idx uint64) *pb.BeaconState {
|
||||
validator := state.ValidatorRegistry[idx]
|
||||
|
||||
exitEpoch := entryExitEffectEpoch(helpers.CurrentEpoch(state))
|
||||
if validator.ExitEpoch <= exitEpoch {
|
||||
if validator.ExitEpoch != params.BeaconConfig().FarFutureEpoch {
|
||||
return state
|
||||
}
|
||||
validator.ExitEpoch = exitEpoch
|
||||
validator.ExitEpoch = entryExitEffectEpoch(helpers.CurrentEpoch(state))
|
||||
return state
|
||||
}
|
||||
|
||||
|
@ -430,14 +430,14 @@ func TestExitValidator_OK(t *testing.T) {
|
||||
|
||||
func TestExitValidator_AlreadyExited(t *testing.T) {
|
||||
state := &pb.BeaconState{
|
||||
Slot: 1,
|
||||
Slot: params.BeaconConfig().GenesisEpoch + 1000,
|
||||
ValidatorRegistry: []*pb.Validator{
|
||||
{ExitEpoch: params.BeaconConfig().ActivationExitDelay},
|
||||
},
|
||||
}
|
||||
state = ExitValidator(state, 0)
|
||||
if len(state.ValidatorRegistry) != 1 {
|
||||
t.Error("Expected validator to have failed exiting")
|
||||
if state.ValidatorRegistry[0].ExitEpoch != params.BeaconConfig().ActivationExitDelay {
|
||||
t.Error("Expected exited validator to stay exited")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user