From 3f01cef456d3ab121fad2ae2b2e6d3e5bbc61cc6 Mon Sep 17 00:00:00 2001 From: Or Neeman Date: Wed, 14 Apr 2021 11:21:10 -0600 Subject: [PATCH] Only active validator signs stats (#1508) (#1510) A proxy with two validators (one active) that send a stat to be signed by the validator, was receiving 2 signed messages for the same (one per validator) Only the active validator will sign those stats. --- cmd/geth/config.go | 2 +- ethstats/ethstats.go | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index a5f4cadc0e..10180daf1f 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -177,7 +177,7 @@ func makeFullNode(ctx *cli.Context) *node.Node { utils.RegisterGraphQLService(stack, cfg.Node.GraphQLEndpoint(), cfg.Node.GraphQLCors, cfg.Node.GraphQLVirtualHosts, cfg.Node.HTTPTimeouts) } // Add the Ethereum Stats daemon if requested. - if cfg.Ethstats.URL != "" || cfg.Eth.Istanbul.Proxied { + if cfg.Ethstats.URL != "" { utils.RegisterEthStatsService(stack, cfg.Ethstats.URL) } return stack diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 044bfc160e..4b0a6dd60b 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -286,9 +286,11 @@ func (s *Service) loop(ctx context.Context) { for { select { case delegateSignMsg := <-signCh: - s.fillWithValidatorInfo(&delegateSignMsg.Payload) - if err := s.handleDelegateSign(&delegateSignMsg.Payload, delegateSignMsg.PeerID); err != nil { - log.Warn("Delegate sign failed", "err", err) + if s.backend.IsValidating() { + s.fillWithValidatorInfo(&delegateSignMsg.Payload) + if err := s.handleDelegateSign(&delegateSignMsg.Payload, delegateSignMsg.PeerID); err != nil { + log.Warn("Delegate sign failed", "err", err) + } } case <-ctxGroup.Done(): return ctxGroup.Err() @@ -391,9 +393,10 @@ func (s *Service) loop(ctx context.Context) { log.Warn("Delegate send failed", "err", err) } } else { - errMessage := fmt.Sprintf("Signed message with action %s discarded", signedMessage.Action) + // As both discarded messages, if they were required should eventually close the connection + // we just warn the user to avoid possible unnecessary disconnections (for example, from + // another backup validator) log.Warn("Signed message discarded", "Action", signedMessage.Action) - err = errors.New(errMessage) } } } @@ -423,18 +426,18 @@ func (s *Service) login(conn *connWrapper, sendCh chan *StatsPayload) error { if info := infos.Protocols[istanbul.ProtocolName]; info != nil { ethInfo, ok := info.(*eth.NodeInfo) if !ok { - return errors.New("Could not resolve NodeInfo") + return errors.New("could not resolve NodeInfo") } network = fmt.Sprintf("%d", ethInfo.Network) protocol = fmt.Sprintf("%s/%d", istanbul.ProtocolName, istanbul.ProtocolVersions[0]) } else { lesProtocol, ok := infos.Protocols["les"] if !ok { - return errors.New("No less protocol found") + return errors.New("no LES protocol found") } lesInfo, ok := lesProtocol.(*les.NodeInfo) if !ok { - return errors.New("Could not resolve NodeInfo") + return errors.New("could not resolve NodeInfo") } network = fmt.Sprintf("%d", lesInfo.Network) protocol = fmt.Sprintf("les/%d", les.ClientProtocolVersions[0])