From 0b1536bc2fa59850753bfe8da2233a84f4ac4521 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Fri, 3 May 2019 15:21:14 -0500 Subject: [PATCH 1/3] no err throw --- beacon-chain/db/deposits.go | 8 ++++---- beacon-chain/rpc/validator_server.go | 15 +++------------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/beacon-chain/db/deposits.go b/beacon-chain/db/deposits.go index 2e429c337a08..d3bdade45769 100644 --- a/beacon-chain/db/deposits.go +++ b/beacon-chain/db/deposits.go @@ -3,7 +3,6 @@ package db import ( "bytes" "context" - "fmt" "math/big" "sort" @@ -86,7 +85,7 @@ func (db *BeaconDB) AllDeposits(ctx context.Context, beforeBlk *big.Int) []*pb.D // DepositByPubkey looks through historical deposits and finds one which contains // a certain public key within its deposit data. -func (db *BeaconDB) DepositByPubkey(ctx context.Context, pubKey []byte) (*pb.Deposit, *big.Int, error) { +func (db *BeaconDB) DepositByPubkey(ctx context.Context, pubKey []byte) (*pb.Deposit, *big.Int) { ctx, span := trace.StartSpan(ctx, "BeaconDB.DepositByPubkey") defer span.End() db.depositsLock.RLock() @@ -97,7 +96,8 @@ func (db *BeaconDB) DepositByPubkey(ctx context.Context, pubKey []byte) (*pb.Dep for _, ctnr := range db.deposits { depositInput, err := helpers.DecodeDepositInput(ctnr.deposit.DepositData) if err != nil { - return nil, nil, fmt.Errorf("could not decode deposit input: %v", err) + log.Debugf("Could not decode deposit input: %v", err) + continue } if bytes.Equal(depositInput.Pubkey, pubKey) { deposit = ctnr.deposit @@ -105,5 +105,5 @@ func (db *BeaconDB) DepositByPubkey(ctx context.Context, pubKey []byte) (*pb.Dep break } } - return deposit, blockNum, nil + return deposit, blockNum } diff --git a/beacon-chain/rpc/validator_server.go b/beacon-chain/rpc/validator_server.go index ab59e153871e..aee3063bbacc 100644 --- a/beacon-chain/rpc/validator_server.go +++ b/beacon-chain/rpc/validator_server.go @@ -216,10 +216,7 @@ func (vs *ValidatorServer) ValidatorStatus( return nil, fmt.Errorf("could not fetch beacon state: %v", err) } - _, eth1BlockNumBigInt, err := vs.beaconDB.DepositByPubkey(ctx, req.PublicKey) - if err != nil { - return nil, err - } + _, eth1BlockNumBigInt := vs.beaconDB.DepositByPubkey(ctx, req.PublicKey) if eth1BlockNumBigInt == nil { return &pb.ValidatorStatusResponse{ Status: pb.ValidatorStatus_UNKNOWN_STATUS, @@ -300,10 +297,7 @@ func (vs *ValidatorServer) MultipleValidatorStatus( PublicKey: key, Status: &pb.ValidatorStatusResponse{}, } - dep, eth1BlockNumBigInt, err := vs.beaconDB.DepositByPubkey(ctx, key) - if err != nil { - return activeValidatorExists, nil, err - } + dep, eth1BlockNumBigInt := vs.beaconDB.DepositByPubkey(ctx, key) if eth1BlockNumBigInt == nil { statusResponses[i].Status = &pb.ValidatorStatusResponse{ Status: pb.ValidatorStatus_UNKNOWN_STATUS, @@ -352,10 +346,7 @@ func (vs *ValidatorServer) MultipleValidatorStatus( } lastValidator := beaconState.ValidatorRegistry[lastValidatorIndex] - lastValidatorDeposit, _, err := vs.beaconDB.DepositByPubkey(ctx, lastValidator.Pubkey) - if err != nil { - return activeValidatorExists, nil, err - } + lastValidatorDeposit, _ := vs.beaconDB.DepositByPubkey(ctx, lastValidator.Pubkey) var positionInQueue uint64 if dep.MerkleTreeIndex > lastValidatorDeposit.MerkleTreeIndex { From 419ff895506845bb14e889c5ecde349a2f386198 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Fri, 3 May 2019 16:48:55 -0500 Subject: [PATCH 2/3] nil errors --- beacon-chain/rpc/validator_server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/beacon-chain/rpc/validator_server.go b/beacon-chain/rpc/validator_server.go index aee3063bbacc..227a726fcdf5 100644 --- a/beacon-chain/rpc/validator_server.go +++ b/beacon-chain/rpc/validator_server.go @@ -218,10 +218,11 @@ func (vs *ValidatorServer) ValidatorStatus( _, eth1BlockNumBigInt := vs.beaconDB.DepositByPubkey(ctx, req.PublicKey) if eth1BlockNumBigInt == nil { + status := vs.validatorStatus(req.PublicKey, beaconState) return &pb.ValidatorStatusResponse{ - Status: pb.ValidatorStatus_UNKNOWN_STATUS, + Status: status, ActivationEpoch: params.BeaconConfig().FarFutureEpoch - params.BeaconConfig().GenesisEpoch, - Eth1DepositBlockNumber: eth1BlockNumBigInt.Uint64(), + Eth1DepositBlockNumber: 0, }, nil } From 9629f5b6646b3a7e8dcfe8c7562fdb2b9593f7b5 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Fri, 3 May 2019 20:56:17 -0500 Subject: [PATCH 3/3] better error on init sync --- beacon-chain/sync/initial-sync/service.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/beacon-chain/sync/initial-sync/service.go b/beacon-chain/sync/initial-sync/service.go index c27f1b4cc818..3cb4888ebcff 100644 --- a/beacon-chain/sync/initial-sync/service.go +++ b/beacon-chain/sync/initial-sync/service.go @@ -222,6 +222,7 @@ func (s *InitialSync) exitInitialSync(ctx context.Context, block *pb.BeaconBlock } state, err = s.chainService.ApplyBlockStateTransition(ctx, block, state) if err != nil { + log.Error("OH NO - looks like you synced with a bad peer, try restarting your node!") switch err.(type) { case *blockchain.BlockFailedProcessingErr: // If the block fails processing, we delete it from our DB. @@ -244,6 +245,7 @@ func (s *InitialSync) exitInitialSync(ctx context.Context, block *pb.BeaconBlock if stateRoot != s.highestObservedRoot { // TODO(#2155): Instead of a fatal call, drop the peer and restart the initial sync service. + log.Error("OH NO - looks like you synced with a bad peer, try restarting your node!") log.Fatalf( "Canonical state root %#x does not match highest observed root from peer %#x", stateRoot,