Reverts RPC Disabling (#2435)

* make changes

* more changes
This commit is contained in:
Nishant Das 2019-04-29 21:23:24 +08:00 committed by Raul Jordan
parent 4a3b2f6d15
commit e16f1e1533
4 changed files with 11 additions and 43 deletions

View File

@ -348,11 +348,6 @@ func (b *BeaconNode) registerRPCService(ctx *cli.Context) error {
return err
}
var syncService *rbcsync.Service
if err := b.services.FetchService(&syncService); err != nil {
return err
}
port := ctx.GlobalString(utils.RPCPort.Name)
cert := ctx.GlobalString(utils.CertFlag.Name)
key := ctx.GlobalString(utils.KeyFlag.Name)
@ -364,7 +359,6 @@ func (b *BeaconNode) registerRPCService(ctx *cli.Context) error {
ChainService: chainService,
OperationService: operationService,
POWChainService: web3Service,
SyncService: syncService,
})
return b.services.RegisterService(rpcService)

View File

@ -55,10 +55,6 @@ type powChainService interface {
ChainStartDeposits() [][]byte
}
type syncService interface {
Status() error
}
// Service defining an RPC server for a beacon node.
type Service struct {
ctx context.Context
@ -67,7 +63,6 @@ type Service struct {
chainService chainService
powChainService powChainService
operationService operationService
syncService syncService
port string
listener net.Listener
withCert string
@ -87,7 +82,6 @@ type Config struct {
ChainService chainService
POWChainService powChainService
OperationService operationService
SyncService syncService
}
// NewRPCService creates a new instance of a struct implementing the BeaconServiceServer
@ -101,7 +95,6 @@ func NewRPCService(ctx context.Context, cfg *Config) *Service {
chainService: cfg.ChainService,
powChainService: cfg.POWChainService,
operationService: cfg.OperationService,
syncService: cfg.SyncService,
port: cfg.Port,
withCert: cfg.CertFlag,
withKey: cfg.KeyFlag,
@ -181,9 +174,6 @@ func (s *Service) Start() {
reflection.Register(s.grpcServer)
go func() {
for s.syncService.Status() != nil {
time.Sleep(time.Second * params.BeaconConfig().RPCSyncCheck)
}
if s.listener != nil {
if err := s.grpcServer.Serve(s.listener); err != nil {
log.Errorf("Could not serve gRPC: %v", err)

View File

@ -121,20 +121,12 @@ func newMockChainService() *mockChainService {
}
}
type mockSyncService struct {
}
func (ms *mockSyncService) Status() error {
return nil
}
func TestLifecycle_OK(t *testing.T) {
hook := logTest.NewGlobal()
rpcService := NewRPCService(context.Background(), &Config{
Port: "7348",
CertFlag: "alice.crt",
KeyFlag: "alice.key",
SyncService: &mockSyncService{},
Port: "7348",
CertFlag: "alice.crt",
KeyFlag: "alice.key",
})
rpcService.Start()
@ -158,8 +150,7 @@ func TestRPC_BadEndpoint(t *testing.T) {
hook := logTest.NewLocal(fl.Logger)
rpcService := NewRPCService(context.Background(), &Config{
Port: "ralph merkle!!!",
SyncService: &mockSyncService{},
Port: "ralph merkle!!!",
})
if val, ok := log.(*TestLogger).testMap["error"]; ok {
@ -188,8 +179,7 @@ func TestStatus_CredentialError(t *testing.T) {
func TestRPC_InsecureEndpoint(t *testing.T) {
hook := logTest.NewGlobal()
rpcService := NewRPCService(context.Background(), &Config{
Port: "7777",
SyncService: &mockSyncService{},
Port: "7777",
})
rpcService.Start()

View File

@ -17,10 +17,9 @@ var slog = logrus.WithField("prefix", "sync")
// Service defines the main routines used in the sync service.
type Service struct {
RegularSync *RegularSync
InitialSync *initialsync.InitialSync
Querier *Querier
querierFinished bool
RegularSync *RegularSync
InitialSync *initialsync.InitialSync
Querier *Querier
}
// Config defines the configured services required for sync to work.
@ -62,10 +61,9 @@ func NewSyncService(ctx context.Context, cfg *Config) *Service {
is := initialsync.NewInitialSyncService(ctx, isCfg)
return &Service{
RegularSync: rs,
InitialSync: is,
Querier: sq,
querierFinished: false,
RegularSync: rs,
InitialSync: is,
Querier: sq,
}
}
@ -94,9 +92,6 @@ func (ss *Service) Stop() error {
// Status checks the status of the node. It returns nil if it's synced
// with the rest of the network and no errors occurred. Otherwise, it returns an error.
func (ss *Service) Status() error {
if !ss.querierFinished {
return errors.New("querier is still running")
}
if !ss.Querier.chainStarted {
return nil
@ -125,7 +120,6 @@ func (ss *Service) run() {
if err != nil {
slog.Fatalf("Unable to retrieve result from sync querier %v", err)
}
ss.querierFinished = true
// Sets the highest observed slot from querier.
ss.InitialSync.InitializeObservedSlot(ss.Querier.currentHeadSlot)