From f5560eb3ff59e809f087a6722420b266ffd1620d Mon Sep 17 00:00:00 2001 From: Leopold Schabel Date: Tue, 23 Mar 2021 14:07:47 +0100 Subject: [PATCH] Fix guardian set initialization race condition (#191) Fixes #184 --- bridge/pkg/processor/observation.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bridge/pkg/processor/observation.go b/bridge/pkg/processor/observation.go index fdedbdc83..3bdd95d91 100644 --- a/bridge/pkg/processor/observation.go +++ b/bridge/pkg/processor/observation.go @@ -129,6 +129,17 @@ func (p *Processor) handleObservation(ctx context.Context, m *gossipv1.SignedObs gs = p.gs } + // We haven't yet observed the trusted guardian set on Ethereum, and therefore, it's impossible to verify it. + // May as well not have received it/been offline - drop it and wait for the guardian set. + if gs == nil { + p.logger.Warn("dropping observations since we haven't initialized our guardian set yet", + zap.String("digest", their_addr.Hex()), + zap.String("their_addr", their_addr.Hex()), + ) + observationsFailedTotal.WithLabelValues("uninitialized_guardian_set").Inc() + return + } + // Verify that m.Addr is included in the guardian set. If it's not, drop the message. In case it's us // who have the outdated guardian set, we'll just wait for the message to be retransmitted eventually. _, ok := gs.KeyIndex(their_addr)