Restructure RPC packages to be future compatible (#9136)

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
terence tsao 2021-07-02 08:54:52 -07:00 committed by GitHub
parent 877cb9f6e6
commit 1edf1f4c87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
89 changed files with 67 additions and 67 deletions

View File

@ -21,15 +21,15 @@ go_library(
"//beacon-chain/operations/voluntaryexits:go_default_library",
"//beacon-chain/p2p:go_default_library",
"//beacon-chain/powchain:go_default_library",
"//beacon-chain/rpc/beacon:go_default_library",
"//beacon-chain/rpc/beaconv1:go_default_library",
"//beacon-chain/rpc/debug:go_default_library",
"//beacon-chain/rpc/debugv1:go_default_library",
"//beacon-chain/rpc/eventsv1:go_default_library",
"//beacon-chain/rpc/node:go_default_library",
"//beacon-chain/rpc/nodev1:go_default_library",
"//beacon-chain/rpc/eth/v1/beacon:go_default_library",
"//beacon-chain/rpc/eth/v1/debug:go_default_library",
"//beacon-chain/rpc/eth/v1/events:go_default_library",
"//beacon-chain/rpc/eth/v1/node:go_default_library",
"//beacon-chain/rpc/prysm/v1alpha1/beacon:go_default_library",
"//beacon-chain/rpc/prysm/v1alpha1/debug:go_default_library",
"//beacon-chain/rpc/prysm/v1alpha1/node:go_default_library",
"//beacon-chain/rpc/prysm/v1alpha1/validator:go_default_library",
"//beacon-chain/rpc/statefetcher:go_default_library",
"//beacon-chain/rpc/validator:go_default_library",
"//beacon-chain/state/stategen:go_default_library",
"//beacon-chain/sync:go_default_library",
"//proto/beacon/p2p/v1:go_default_library",

View File

@ -11,7 +11,7 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/apimiddleware",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/rpc/eventsv1:go_default_library",
"//beacon-chain/rpc/eth/v1/events:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/gateway:go_default_library",
"//shared/grpcutils:go_default_library",
@ -29,7 +29,7 @@ go_test(
],
embed = [":go_default_library"],
deps = [
"//beacon-chain/rpc/eventsv1:go_default_library",
"//beacon-chain/rpc/eth/v1/events:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/gateway:go_default_library",
"//shared/grpcutils:go_default_library",

View File

@ -11,7 +11,7 @@ import (
"strconv"
"strings"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/eventsv1"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/v1/events"
"github.com/prysmaticlabs/prysm/shared/gateway"
"github.com/prysmaticlabs/prysm/shared/grpcutils"
"github.com/r3labs/sse"
@ -187,11 +187,11 @@ func receiveEvents(eventChan <-chan *sse.Event, w http.ResponseWriter, req *http
var data interface{}
switch strings.TrimSpace(string(msg.Event)) {
case eventsv1.HeadTopic:
case events.HeadTopic:
data = &eventHeadJson{}
case eventsv1.BlockTopic:
case events.BlockTopic:
data = &receivedBlockDataJson{}
case eventsv1.AttestationTopic:
case events.AttestationTopic:
data = &attestationJson{}
// Data received in the event does not fit the expected event stream output.
@ -206,11 +206,11 @@ func receiveEvents(eventChan <-chan *sse.Event, w http.ResponseWriter, req *http
return gateway.InternalServerError(err)
}
msg.Data = attData
case eventsv1.VoluntaryExitTopic:
case events.VoluntaryExitTopic:
data = &signedVoluntaryExitJson{}
case eventsv1.FinalizedCheckpointTopic:
case events.FinalizedCheckpointTopic:
data = &eventFinalizedCheckpointJson{}
case eventsv1.ChainReorgTopic:
case events.ChainReorgTopic:
data = &eventChainReorgJson{}
case "error":
data = &eventErrorJson{}

View File

@ -10,7 +10,7 @@ import (
"testing"
"time"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/eventsv1"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/v1/events"
"github.com/prysmaticlabs/prysm/shared/gateway"
"github.com/prysmaticlabs/prysm/shared/grpcutils"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@ -161,7 +161,7 @@ func TestReceiveEvents(t *testing.T) {
require.NoError(t, err)
msg := &sse.Event{
Data: bData,
Event: []byte(eventsv1.FinalizedCheckpointTopic),
Event: []byte(events.FinalizedCheckpointTopic),
}
ch <- msg
time.Sleep(time.Second)

View File

@ -11,7 +11,7 @@ go_library(
"state.go",
"validator.go",
],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/beaconv1",
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/v1/beacon",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/blockchain:go_default_library",

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import (
"context"

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import (
"context"

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import (
"context"

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import (
"context"

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import "github.com/sirupsen/logrus"

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import (
"context"

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import (
"context"

View File

@ -1,7 +1,7 @@
// Package beaconv1 defines a gRPC beacon service implementation,
// following the official API standards https://ethereum.github.io/eth2.0-APIs/#/.
// This package includes the beacon and config endpoints.
package beaconv1
package beacon
import (
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain"

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1"

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import (
"bytes"

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import (
"context"

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import (
"context"

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import (
"bytes"

View File

@ -6,7 +6,7 @@ go_library(
"debug.go",
"server.go",
],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/debugv1",
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/v1/debug",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/blockchain:go_default_library",

View File

@ -1,4 +1,4 @@
package debugv1
package debug
import (
"context"

View File

@ -1,4 +1,4 @@
package debugv1
package debug
import (
"context"

View File

@ -1,7 +1,7 @@
// Package debugv1 defines a gRPC beacon service implementation,
// following the official API standards https://ethereum.github.io/eth2.0-APIs/#/.
// This package includes the beacon and config endpoints.
package debugv1
package debug
import (
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain"

View File

@ -6,7 +6,7 @@ go_library(
"events.go",
"server.go",
],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/eventsv1",
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/v1/events",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/core/feed:go_default_library",

View File

@ -1,4 +1,4 @@
package eventsv1
package events
import (
gwpb "github.com/grpc-ecosystem/grpc-gateway/v2/proto/gateway"

View File

@ -1,4 +1,4 @@
package eventsv1
package events
import (
"context"

View File

@ -1,7 +1,7 @@
// Package eventsv1 defines a gRPC events service implementation,
// following the official API standards https://ethereum.github.io/eth2.0-APIs/#/.
// This package includes the events endpoint.
package eventsv1
package events
import (
"context"

View File

@ -6,7 +6,7 @@ go_library(
"node.go",
"server.go",
],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/nodev1",
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/v1/node",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/blockchain:go_default_library",

View File

@ -1,4 +1,4 @@
package nodev1
package node
import (
"context"

View File

@ -1,4 +1,4 @@
package nodev1
package node
import (
"context"

View File

@ -1,7 +1,7 @@
// Package nodev1 defines a gRPC node service implementation, providing
// useful endpoints for checking a node's sync status, peer info,
// genesis data, and version information.
package nodev1
package node
import (
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain"

View File

@ -1,4 +1,4 @@
package nodev1
package node
import (
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1"

View File

@ -14,7 +14,7 @@ go_library(
"validators.go",
"validators_stream.go",
],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/beacon",
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/prysm/v1alpha1/beacon",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/blockchain:go_default_library",

View File

@ -1,4 +1,4 @@
package beaconv1
package beacon
import (
"github.com/prysmaticlabs/prysm/shared/params"

View File

@ -9,7 +9,7 @@ go_library(
"server.go",
"state.go",
],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/debug",
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/prysm/v1alpha1/debug",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/blockchain:go_default_library",

View File

@ -3,7 +3,7 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = ["server.go"],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/node",
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/prysm/v1alpha1/node",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/blockchain:go_default_library",

View File

@ -14,7 +14,7 @@ go_library(
"server.go",
"status.go",
],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator",
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/prysm/v1alpha1/validator",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/blockchain:go_default_library",

View File

@ -25,15 +25,15 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/operations/voluntaryexits"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/beacon"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/beaconv1"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/debug"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/debugv1"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/eventsv1"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/node"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/nodev1"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/v1/beacon"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/v1/debug"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/v1/events"
node "github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/v1/node"
beacon2 "github.com/prysmaticlabs/prysm/beacon-chain/rpc/prysm/v1alpha1/beacon"
debug2 "github.com/prysmaticlabs/prysm/beacon-chain/rpc/prysm/v1alpha1/debug"
node2 "github.com/prysmaticlabs/prysm/beacon-chain/rpc/prysm/v1alpha1/node"
validator2 "github.com/prysmaticlabs/prysm/beacon-chain/rpc/prysm/v1alpha1/validator"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/statefetcher"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
chainSync "github.com/prysmaticlabs/prysm/beacon-chain/sync"
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
@ -165,7 +165,7 @@ func (s *Service) Start() {
}
s.grpcServer = grpc.NewServer(opts...)
validatorServer := &validator.Server{
validatorServer := &validator2.Server{
Ctx: s.ctx,
BeaconDB: s.cfg.BeaconDB,
AttestationCache: cache.NewAttestationCache(),
@ -192,7 +192,7 @@ func (s *Service) Start() {
SlashingsPool: s.cfg.SlashingsPool,
StateGen: s.cfg.StateGen,
}
nodeServer := &node.Server{
nodeServer := &node2.Server{
LogsStreamer: logutil.NewStreamServer(),
StreamLogsBufferSize: 1000, // Enough to handle bursts of beacon node logs for gRPC streaming.
BeaconDB: s.cfg.BeaconDB,
@ -205,7 +205,7 @@ func (s *Service) Start() {
BeaconMonitoringHost: s.cfg.BeaconMonitoringHost,
BeaconMonitoringPort: s.cfg.BeaconMonitoringPort,
}
nodeServerV1 := &nodev1.Server{
nodeServerV1 := &node.Server{
BeaconDB: s.cfg.BeaconDB,
Server: s.grpcServer,
SyncChecker: s.cfg.SyncService,
@ -216,7 +216,7 @@ func (s *Service) Start() {
HeadFetcher: s.cfg.HeadFetcher,
}
beaconChainServer := &beacon.Server{
beaconChainServer := &beacon2.Server{
Ctx: s.ctx,
BeaconDB: s.cfg.BeaconDB,
AttestationsPool: s.cfg.AttestationsPool,
@ -238,7 +238,7 @@ func (s *Service) Start() {
ReceivedAttestationsBuffer: make(chan *ethpb.Attestation, attestationBufferSize),
CollectedAttestationsBuffer: make(chan []*ethpb.Attestation, attestationBufferSize),
}
beaconChainServerV1 := &beaconv1.Server{
beaconChainServerV1 := &beacon.Server{
BeaconDB: s.cfg.BeaconDB,
AttestationsPool: s.cfg.AttestationsPool,
SlashingsPool: s.cfg.SlashingsPool,
@ -261,7 +261,7 @@ func (s *Service) Start() {
pbrpc.RegisterHealthServer(s.grpcServer, nodeServer)
ethpb.RegisterBeaconChainServer(s.grpcServer, beaconChainServer)
ethpbv1.RegisterBeaconChainServer(s.grpcServer, beaconChainServerV1)
ethpbv1.RegisterEventsServer(s.grpcServer, &eventsv1.Server{
ethpbv1.RegisterEventsServer(s.grpcServer, &events.Server{
Ctx: s.ctx,
StateNotifier: s.cfg.StateNotifier,
BlockNotifier: s.cfg.BlockNotifier,
@ -269,7 +269,7 @@ func (s *Service) Start() {
})
if s.cfg.EnableDebugRPCEndpoints {
log.Info("Enabled debug gRPC endpoints")
debugServer := &debug.Server{
debugServer := &debug2.Server{
GenesisTimeFetcher: s.cfg.GenesisTimeFetcher,
BeaconDB: s.cfg.BeaconDB,
StateGen: s.cfg.StateGen,
@ -277,7 +277,7 @@ func (s *Service) Start() {
PeerManager: s.cfg.PeerManager,
PeersFetcher: s.cfg.PeersFetcher,
}
debugServerV1 := &debugv1.Server{
debugServerV1 := &debug.Server{
BeaconDB: s.cfg.BeaconDB,
HeadFetcher: s.cfg.HeadFetcher,
StateFetcher: &statefetcher.StateProvider{