Remove CanonicalStateChan (#10093)

(cherry picked from commit 69a2ffd7c9)
This commit is contained in:
Radosław Kapka
2022-01-18 15:24:47 +01:00
committed by GitHub
parent 64c02c405b
commit 68ef8ae99a
5 changed files with 34 additions and 46 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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 := &ethpb.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 := &ethpb.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 := &ethpb.ValidatorActivationRequest{
PublicKeys: [][]byte{pubKey1, pubKey2, pubKey3},

View File

@@ -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{

View File

@@ -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,