Change Validator Status for visible deposit back to DEPOSITED (#5563)

* Change valstatus for visible deposit back to DEPOSITED
* Rename logs
* Merge branch 'master' into val-status
* Fix tests
* Merge branch 'val-status' of https://github.com/prysmaticlabs/prysm into val-status
* Fix tests
* Change test
* Merge branch 'master' into val-status
* Text changes
* Merge branch 'master' of https://github.com/prysmaticlabs/prysm into val-status
* Merge branch 'val-status' of https://github.com/prysmaticlabs/prysm into val-status
* Update validator/client/validator.go

Co-Authored-By: Preston Van Loon <preston@prysmaticlabs.com>
* Update validator/client/validator.go

Co-Authored-By: Preston Van Loon <preston@prysmaticlabs.com>
* Merge branch 'val-status' of https://github.com/prysmaticlabs/prysm into val-status
* Merge branch 'master' into val-status
This commit is contained in:
Ivan Martinez 2020-04-21 15:11:27 -04:00 committed by GitHub
parent 480ddb7c3d
commit c2daf8d82e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 25 deletions

View File

@ -102,12 +102,14 @@ func (vs *Server) validatorStatus(ctx context.Context, pubKey []byte, headState
log.Warn("Not connected to ETH1. Cannot determine validator ETH1 deposit block number")
return resp
}
_, eth1BlockNumBigInt := vs.DepositFetcher.DepositByPubkey(ctx, pubKey)
if eth1BlockNumBigInt == nil { // No deposit found in ETH1.
return resp
}
// Mark a validator as DEPOSITED if their deposit is visible.
resp.Status = ethpb.ValidatorStatus_DEPOSITED
resp.Eth1DepositBlockNumber = eth1BlockNumBigInt.Uint64()
depositBlockSlot, err := vs.depositBlockSlot(ctx, eth1BlockNumBigInt, headState)

View File

@ -22,14 +22,14 @@ import (
"github.com/prysmaticlabs/prysm/shared/trieutil"
)
func TestValidatorStatus_Unknown(t *testing.T) {
func TestValidatorStatus_DepositedEth1(t *testing.T) {
db := dbutil.SetupDB(t)
defer dbutil.TeardownDB(t, db)
ctx := context.Background()
pubKey := pubKey(1)
pubKey1 := pubKey(1)
depData := &ethpb.Deposit_Data{
PublicKey: pubKey,
PublicKey: pubKey1,
Signature: []byte("hi"),
WithdrawalCredentials: []byte("hey"),
}
@ -62,17 +62,14 @@ func TestValidatorStatus_Unknown(t *testing.T) {
Eth1InfoFetcher: p,
}
req := &ethpb.ValidatorStatusRequest{
PublicKey: pubKey,
PublicKey: pubKey1,
}
resp, err := vs.ValidatorStatus(context.Background(), req)
if err != nil {
t.Fatalf("Could not get validator status %v", err)
}
if resp.Status != ethpb.ValidatorStatus_UNKNOWN_STATUS {
t.Errorf("Wanted %v, got %v", ethpb.ValidatorStatus_UNKNOWN_STATUS, resp.Status)
}
if resp.DepositInclusionSlot == 0 {
t.Errorf("Wanted 0, got %d", resp.DepositInclusionSlot)
if resp.Status != ethpb.ValidatorStatus_DEPOSITED {
t.Errorf("Wanted %v, got %v", ethpb.ValidatorStatus_DEPOSITED, resp.Status)
}
}
@ -82,7 +79,6 @@ func TestValidatorStatus_Deposited(t *testing.T) {
ctx := context.Background()
pubKey1 := pubKey(1)
pubKey2 := pubKey(2)
depData := &ethpb.Deposit_Data{
PublicKey: pubKey1,
Signature: []byte("hi"),
@ -106,7 +102,7 @@ func TestValidatorStatus_Deposited(t *testing.T) {
stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
Validators: []*ethpb.Validator{
{
PublicKey: pubKey2,
PublicKey: pubKey1,
ActivationEligibilityEpoch: 1,
},
},
@ -124,7 +120,7 @@ func TestValidatorStatus_Deposited(t *testing.T) {
Eth1InfoFetcher: p,
}
req := &ethpb.ValidatorStatusRequest{
PublicKey: pubKey2,
PublicKey: pubKey1,
}
resp, err := vs.ValidatorStatus(context.Background(), req)
if err != nil {
@ -638,7 +634,7 @@ func TestMultipleValidatorStatus_OK(t *testing.T) {
response[1].PublicKey)
}
if response[2].Status.Status != ethpb.ValidatorStatus_UNKNOWN_STATUS {
if response[2].Status.Status != ethpb.ValidatorStatus_DEPOSITED {
t.Errorf("Validator with pubkey %#x is not unknown and instead has this status: %s",
response[2].PublicKey, response[2].Status.Status.String())
}

View File

@ -239,18 +239,18 @@ func (v *validator) checkAndLogValidatorStatus(validatorStatuses []*ethpb.Valida
}
switch status.Status.Status {
case ethpb.ValidatorStatus_UNKNOWN_STATUS:
log.Info("Waiting for deposit to be observed by beacon node")
case ethpb.ValidatorStatus_DEPOSITED:
if status.Status.DepositInclusionSlot != 0 {
log.WithFields(logrus.Fields{
"expectedInclusionSlot": status.Status.DepositInclusionSlot,
"eth1DepositBlockNumber": status.Status.Eth1DepositBlockNumber,
}).Info("Waiting for deposit to be processed by the beacon chain")
}).Info("Deposit for validator received but not processed into the beacon state")
} else {
log.Info("Waiting for a deposit to be put into an eth1 block")
log.WithField(
"positionInActivationQueue", status.Status.PositionInActivationQueue,
).Info("Deposit processed, entering activation queue after finalization")
}
case ethpb.ValidatorStatus_DEPOSITED:
log.WithField(
"positionInActivationQueue", status.Status.PositionInActivationQueue,
).Info("Deposit processed, entering activation queue after finalization")
case ethpb.ValidatorStatus_PENDING:
log.WithFields(logrus.Fields{
"positionInActivationQueue": status.Status.PositionInActivationQueue,

View File

@ -834,22 +834,22 @@ func TestCheckAndLogValidatorStatus_OK(t *testing.T) {
Status: ethpb.ValidatorStatus_UNKNOWN_STATUS,
},
},
log: "Waiting for a deposit to be put into an eth1 block",
log: "Waiting for deposit to be observed by beacon node",
},
{
name: "UNKNOWN_STATUS, but deposit found",
name: "DEPOSITED, deposit found",
status: &ethpb.ValidatorActivationResponse_Status{
PublicKey: pubKeys[0],
Status: &ethpb.ValidatorStatusResponse{
Status: ethpb.ValidatorStatus_UNKNOWN_STATUS,
Status: ethpb.ValidatorStatus_DEPOSITED,
DepositInclusionSlot: 50,
Eth1DepositBlockNumber: 400,
},
},
log: "Waiting for deposit to be processed by the beacon chain\" eth1DepositBlockNumber=400 expectedInclusionSlot=50",
log: "Deposit for validator received but not processed into the beacon state\" eth1DepositBlockNumber=400 expectedInclusionSlot=50",
},
{
name: "DEPOSITED",
name: "DEPOSITED into state",
status: &ethpb.ValidatorActivationResponse_Status{
PublicKey: pubKeys[0],
Status: &ethpb.ValidatorStatusResponse{