From 68ef8ae99a2176e44b2ea3b074cf56c36b32c265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kapka?= Date: Tue, 18 Jan 2022 15:24:47 +0100 Subject: [PATCH] Remove `CanonicalStateChan` (#10093) (cherry picked from commit 69a2ffd7c9f8ca1c67b4ea5aba71154ebc7713c2) --- .../rpc/prysm/v1alpha1/beacon/server.go | 1 - .../rpc/prysm/v1alpha1/validator/server.go | 1 - .../prysm/v1alpha1/validator/server_test.go | 33 +++++++-------- .../prysm/v1alpha1/validator/status_test.go | 41 +++++++++---------- beacon-chain/rpc/service.go | 4 -- 5 files changed, 34 insertions(+), 46 deletions(-) diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/server.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/server.go index c7aaa4b722..47672dde12 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/server.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/server.go @@ -40,7 +40,6 @@ type Server struct { Broadcaster p2p.Broadcaster AttestationsPool attestations.Pool SlashingsPool slashings.PoolManager - CanonicalStateChan chan *ethpb.BeaconState ChainStartChan chan time.Time ReceivedAttestationsBuffer chan *ethpb.Attestation CollectedAttestationsBuffer chan []*ethpb.Attestation diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server.go index bad7395b10..5263d4de6b 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server.go @@ -44,7 +44,6 @@ type Server struct { ForkFetcher blockchain.ForkFetcher FinalizationFetcher blockchain.FinalizationFetcher TimeFetcher blockchain.TimeFetcher - CanonicalStateChan chan *ethpb.BeaconState BlockFetcher powchain.POWBlockFetcher DepositFetcher depositcache.DepositFetcher ChainStartFetcher powchain.ChainStartFetcher diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go index bc13a1930e..c6491c0fad 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go @@ -63,13 +63,12 @@ func TestWaitForActivation_ContextClosed(t *testing.T) { require.NoError(t, err) vs := &Server{ - Ctx: ctx, - ChainStartFetcher: &mockPOW.POWChain{}, - BlockFetcher: &mockPOW.POWChain{}, - Eth1InfoFetcher: &mockPOW.POWChain{}, - CanonicalStateChan: make(chan *ethpb.BeaconState, 1), - DepositFetcher: depositCache, - HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, + Ctx: ctx, + ChainStartFetcher: &mockPOW.POWChain{}, + BlockFetcher: &mockPOW.POWChain{}, + Eth1InfoFetcher: &mockPOW.POWChain{}, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, } req := ðpb.ValidatorActivationRequest{ PublicKeys: [][]byte{pubKey(1)}, @@ -142,13 +141,12 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { trie, err := v1.InitializeFromProtoUnsafe(beaconState) require.NoError(t, err) vs := &Server{ - Ctx: context.Background(), - CanonicalStateChan: make(chan *ethpb.BeaconState, 1), - ChainStartFetcher: &mockPOW.POWChain{}, - BlockFetcher: &mockPOW.POWChain{}, - Eth1InfoFetcher: &mockPOW.POWChain{}, - DepositFetcher: depositCache, - HeadFetcher: &mockChain.ChainService{State: trie, Root: genesisRoot[:]}, + Ctx: context.Background(), + ChainStartFetcher: &mockPOW.POWChain{}, + BlockFetcher: &mockPOW.POWChain{}, + Eth1InfoFetcher: &mockPOW.POWChain{}, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: trie, Root: genesisRoot[:]}, } req := ðpb.ValidatorActivationRequest{ PublicKeys: [][]byte{pubKey1, pubKey2}, @@ -222,10 +220,9 @@ func TestWaitForActivation_MultipleStatuses(t *testing.T) { trie, err := v1.InitializeFromProtoUnsafe(beaconState) require.NoError(t, err) vs := &Server{ - Ctx: context.Background(), - CanonicalStateChan: make(chan *ethpb.BeaconState, 1), - ChainStartFetcher: &mockPOW.POWChain{}, - HeadFetcher: &mockChain.ChainService{State: trie, Root: genesisRoot[:]}, + Ctx: context.Background(), + ChainStartFetcher: &mockPOW.POWChain{}, + HeadFetcher: &mockChain.ChainService{State: trie, Root: genesisRoot[:]}, } req := ðpb.ValidatorActivationRequest{ PublicKeys: [][]byte{pubKey1, pubKey2, pubKey3}, diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go index 945934aa6e..4a397d825f 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go @@ -539,13 +539,12 @@ func TestActivationStatus_OK(t *testing.T) { assert.NoError(t, depositCache.InsertDeposit(context.Background(), dep, 0, 1, depositTrie.HashTreeRoot())) vs := &Server{ - Ctx: context.Background(), - CanonicalStateChan: make(chan *ethpb.BeaconState, 1), - ChainStartFetcher: &mockPOW.POWChain{}, - BlockFetcher: &mockPOW.POWChain{}, - Eth1InfoFetcher: &mockPOW.POWChain{}, - DepositFetcher: depositCache, - HeadFetcher: &mockChain.ChainService{State: stateObj, Root: genesisRoot[:]}, + Ctx: context.Background(), + ChainStartFetcher: &mockPOW.POWChain{}, + BlockFetcher: &mockPOW.POWChain{}, + Eth1InfoFetcher: &mockPOW.POWChain{}, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: stateObj, Root: genesisRoot[:]}, } activeExists, response, err := vs.activationStatus(context.Background(), pubKeys) require.NoError(t, err) @@ -743,14 +742,13 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) { assert.NoError(t, depositCache.InsertDeposit(context.Background(), dep, 0, 1, depositTrie.HashTreeRoot())) vs := &Server{ - Ctx: context.Background(), - CanonicalStateChan: make(chan *ethpb.BeaconState, 1), - ChainStartFetcher: &mockPOW.POWChain{}, - BlockFetcher: &mockPOW.POWChain{}, - Eth1InfoFetcher: &mockPOW.POWChain{}, - DepositFetcher: depositCache, - HeadFetcher: &mockChain.ChainService{State: stateObj, Root: genesisRoot[:]}, - SyncChecker: &mockSync.Sync{IsSyncing: false}, + Ctx: context.Background(), + ChainStartFetcher: &mockPOW.POWChain{}, + BlockFetcher: &mockPOW.POWChain{}, + Eth1InfoFetcher: &mockPOW.POWChain{}, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: stateObj, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, } want := []*ethpb.ValidatorStatusResponse{ @@ -839,13 +837,12 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) { require.NoError(t, err, "Could not get signing root") vs := &Server{ - Ctx: context.Background(), - CanonicalStateChan: make(chan *ethpb.BeaconState, 1), - ChainStartFetcher: &mockPOW.POWChain{}, - BlockFetcher: &mockPOW.POWChain{}, - Eth1InfoFetcher: &mockPOW.POWChain{}, - HeadFetcher: &mockChain.ChainService{State: stateObj, Root: genesisRoot[:]}, - SyncChecker: &mockSync.Sync{IsSyncing: false}, + Ctx: context.Background(), + ChainStartFetcher: &mockPOW.POWChain{}, + BlockFetcher: &mockPOW.POWChain{}, + Eth1InfoFetcher: &mockPOW.POWChain{}, + HeadFetcher: &mockChain.ChainService{State: stateObj, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, } want := []*ethpb.ValidatorStatusResponse{ diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index 37868f8ff9..27ebd7f48c 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -62,7 +62,6 @@ type Service struct { cancel context.CancelFunc listener net.Listener grpcServer *grpc.Server - canonicalStateChan chan *ethpbv1alpha1.BeaconState incomingAttestation chan *ethpbv1alpha1.Attestation credentialError error connectedRPCClients map[net.Addr]bool @@ -119,7 +118,6 @@ func NewService(ctx context.Context, cfg *Config) *Service { cfg: cfg, ctx: ctx, cancel: cancel, - canonicalStateChan: make(chan *ethpbv1alpha1.BeaconState, params.BeaconConfig().DefaultBufferSize), incomingAttestation: make(chan *ethpbv1alpha1.Attestation, params.BeaconConfig().DefaultBufferSize), connectedRPCClients: make(map[net.Addr]bool), } @@ -178,7 +176,6 @@ func (s *Service) Start() { ForkFetcher: s.cfg.ForkFetcher, FinalizationFetcher: s.cfg.FinalizationFetcher, TimeFetcher: s.cfg.GenesisTimeFetcher, - CanonicalStateChan: s.canonicalStateChan, BlockFetcher: s.cfg.POWChainService, DepositFetcher: s.cfg.DepositFetcher, ChainStartFetcher: s.cfg.ChainStartFetcher, @@ -249,7 +246,6 @@ func (s *Service) Start() { ChainStartFetcher: s.cfg.ChainStartFetcher, DepositFetcher: s.cfg.DepositFetcher, BlockFetcher: s.cfg.POWChainService, - CanonicalStateChan: s.canonicalStateChan, GenesisTimeFetcher: s.cfg.GenesisTimeFetcher, StateNotifier: s.cfg.StateNotifier, BlockNotifier: s.cfg.BlockNotifier,