mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
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:
parent
480ddb7c3d
commit
c2daf8d82e
@ -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)
|
||||
|
@ -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 := ðpb.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 := ðpb.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 := ðpb.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 := ðpb.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())
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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: ðpb.ValidatorActivationResponse_Status{
|
||||
PublicKey: pubKeys[0],
|
||||
Status: ðpb.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: ðpb.ValidatorActivationResponse_Status{
|
||||
PublicKey: pubKeys[0],
|
||||
Status: ðpb.ValidatorStatusResponse{
|
||||
|
Loading…
Reference in New Issue
Block a user