From 398f44bb53c4034bacea7cc15377e0a49c18a3c8 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Mon, 18 Sep 2023 22:30:34 +0800 Subject: [PATCH] fix it (#12917) --- beacon-chain/sync/fork_watcher.go | 3 ++ beacon-chain/sync/fork_watcher_test.go | 44 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/beacon-chain/sync/fork_watcher.go b/beacon-chain/sync/fork_watcher.go index 756954fcf..49a8cf05a 100644 --- a/beacon-chain/sync/fork_watcher.go +++ b/beacon-chain/sync/fork_watcher.go @@ -63,6 +63,9 @@ func (s *Service) registerForUpcomingFork(currEpoch primitives.Epoch) error { if nextEpoch == params.BeaconConfig().AltairForkEpoch { s.registerRPCHandlersAltair() } + if nextEpoch == params.BeaconConfig().DenebForkEpoch { + s.registerRPCHandlersDeneb() + } } return nil } diff --git a/beacon-chain/sync/fork_watcher_test.go b/beacon-chain/sync/fork_watcher_test.go index f0441ac9e..33bcd1994 100644 --- a/beacon-chain/sync/fork_watcher_test.go +++ b/beacon-chain/sync/fork_watcher_test.go @@ -143,6 +143,50 @@ func TestService_CheckForNextEpochFork(t *testing.T) { } }, }, + { + name: "deneb fork in the next epoch", + svcCreator: func(t *testing.T) *Service { + peer2peer := p2ptest.NewTestP2P(t) + gt := time.Now().Add(-4 * oneEpoch()) + vr := [32]byte{'A'} + chainService := &mockChain.ChainService{ + Genesis: gt, + ValidatorsRoot: vr, + } + bCfg := params.BeaconConfig().Copy() + bCfg.DenebForkEpoch = 5 + params.OverrideBeaconConfig(bCfg) + params.BeaconConfig().InitializeForkSchedule() + ctx, cancel := context.WithCancel(context.Background()) + r := &Service{ + ctx: ctx, + cancel: cancel, + cfg: &config{ + p2p: peer2peer, + chain: chainService, + clock: startup.NewClock(gt, vr), + initialSync: &mockSync.Sync{IsSyncing: false}, + }, + chainStarted: abool.New(), + subHandler: newSubTopicHandler(), + } + return r + }, + currEpoch: 4, + wantErr: false, + postSvcCheck: func(t *testing.T, s *Service) { + genRoot := s.cfg.clock.GenesisValidatorsRoot() + digest, err := forks.ForkDigestFromEpoch(5, genRoot[:]) + assert.NoError(t, err) + assert.Equal(t, true, s.subHandler.digestExists(digest)) + rpcMap := make(map[string]bool) + for _, p := range s.cfg.p2p.Host().Mux().Protocols() { + rpcMap[string(p)] = true + } + assert.Equal(t, true, rpcMap[p2p.RPCBlobSidecarsByRangeTopicV1+s.cfg.p2p.Encoding().ProtocolSuffix()], "topic doesn't exist") + assert.Equal(t, true, rpcMap[p2p.RPCBlobSidecarsByRootTopicV1+s.cfg.p2p.Encoding().ProtocolSuffix()], "topic doesn't exist") + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {