From 113172d8aa5f8b1d5b13eda7a35e42f2c1a960b7 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Wed, 26 Jul 2023 08:38:25 +0800 Subject: [PATCH] Exit Initial Sync Early (#12659) * add check * fix test --- beacon-chain/sync/initial-sync/service.go | 6 ++++++ beacon-chain/sync/initial-sync/service_test.go | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/beacon-chain/sync/initial-sync/service.go b/beacon-chain/sync/initial-sync/service.go index 9ff9d2c27..0cc94edf6 100644 --- a/beacon-chain/sync/initial-sync/service.go +++ b/beacon-chain/sync/initial-sync/service.go @@ -89,6 +89,12 @@ func (s *Service) Start() { log.Debug("Exiting Initial Sync Service") return } + // Exit entering round-robin sync if we require 0 peers to sync. + if flags.Get().MinimumSyncPeers == 0 { + s.markSynced() + log.WithField("genesisTime", gt).Info("Due to number of peers required for sync being set at 0, entering regular sync immediately.") + return + } if gt.After(prysmTime.Now()) { s.markSynced() log.WithField("genesisTime", gt).Info("Genesis time has not arrived - not syncing") diff --git a/beacon-chain/sync/initial-sync/service_test.go b/beacon-chain/sync/initial-sync/service_test.go index 4659a99eb..a61a00b73 100644 --- a/beacon-chain/sync/initial-sync/service_test.go +++ b/beacon-chain/sync/initial-sync/service_test.go @@ -31,6 +31,14 @@ func TestService_Constants(t *testing.T) { func TestService_InitStartStop(t *testing.T) { hook := logTest.NewGlobal() + resetFlags := flags.Get() + flags.Init(&flags.GlobalFlags{ + MinimumSyncPeers: 1, + }) + defer func() { + flags.Init(resetFlags) + }() + tests := []struct { name string assert func()