Skip to content

Commit

Permalink
Only active validator signs stats (#1508) (#1510)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Or Neeman authored Apr 14, 2021
1 parent 2a42214 commit 3f01cef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 11 additions & 8 deletions ethstats/ethstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit 3f01cef

Please sign in to comment.