Skip to content
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

Return Nil Error if Pre-Genesis in P2P Service Healthz Check #5355

Merged
merged 6 commits into from
Apr 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions beacon-chain/p2p/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,25 @@ const maxBadResponses = 3

// Service for managing peer to peer (p2p) networking.
type Service struct {
beaconDB db.Database
ctx context.Context
cancel context.CancelFunc
started bool
isPreGenesis bool
pingMethod func(ctx context.Context, id peer.ID) error
cancel context.CancelFunc
cfg *Config
startupErr error
peers *peers.Status
dht *kaddht.IpfsDHT
privKey *ecdsa.PrivateKey
exclusionList *ristretto.Cache
metaData *pb.MetaData
pubsub *pubsub.PubSub
beaconDB db.Database
dv5Listener Listener
startupErr error
stateNotifier statefeed.Notifier
ctx context.Context
host host.Host
pubsub *pubsub.PubSub
exclusionList *ristretto.Cache
privKey *ecdsa.PrivateKey
dht *kaddht.IpfsDHT
peers *peers.Status
genesisTime time.Time
genesisValidatorsRoot []byte
metaData *pb.MetaData
stateNotifier statefeed.Notifier
pingMethod func(ctx context.Context, id peer.ID) error
}

// NewService initializes a new p2p service compatible with shared.Service interface. No
Expand All @@ -98,6 +99,7 @@ func NewService(cfg *Config) (*Service, error) {
cancel: cancel,
cfg: cfg,
exclusionList: cache,
isPreGenesis: true,
}

dv5Nodes, kadDHTNodes := parseBootStrapAddrs(s.cfg.BootstrapNodeAddr)
Expand Down Expand Up @@ -184,6 +186,7 @@ func (s *Service) Start() {
} else {
s.awaitStateInitialized()
}
s.isPreGenesis = false

var peersToWatch []string
if s.cfg.RelayNodeAddr != "" {
Expand Down Expand Up @@ -295,9 +298,15 @@ func (s *Service) Stop() error {
// Status of the p2p service. Will return an error if the service is considered unhealthy to
// indicate that this node should not serve traffic until the issue has been resolved.
func (s *Service) Status() error {
if s.isPreGenesis {
return nil
}
if !s.started {
return errors.New("not running")
}
rauljordan marked this conversation as resolved.
Show resolved Hide resolved
if s.startupErr != nil {
return s.startupErr
}
return nil
}

Expand Down