Move Miscellaneous Shared/ Packages Into Semantic Groups (#9624)

* remove shared network and ip util

* forkutil

* gaz

* build

* gaz

* nogo

* genrule

* gaz

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Raul Jordan 2021-09-17 14:20:50 -05:00 committed by GitHub
parent 6308678a89
commit d2f74615ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
90 changed files with 190 additions and 193 deletions

View File

@ -17,7 +17,7 @@ go_library(
],
deps = [
"//api/grpc:go_default_library",
"//shared:go_default_library",
"//runtime:go_default_library",
"//shared/bytesutil:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_gorilla_mux//:go_default_library",

View File

@ -12,14 +12,14 @@ import (
gwruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/runtime"
"github.com/rs/cors"
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials"
)
var _ shared.Service = (*Gateway)(nil)
var _ runtime.Service = (*Gateway)(nil)
// PbMux serves grpc-gateway requests for selected patterns using registered protobuf handlers.
type PbMux struct {

View File

@ -6,11 +6,11 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/core",
visibility = [
"//beacon-chain:__subpackages__",
"//network/forks:__pkg__",
"//shared/attestationutil:__pkg__",
"//shared/depositutil:__pkg__",
"//shared/interop:__pkg__",
"//shared/keystore:__pkg__",
"//shared/p2putils:__pkg__",
"//shared/testutil:__pkg__",
"//shared/testutil/altair:__pkg__",
"//slasher:__subpackages__",

View File

@ -32,6 +32,7 @@ go_library(
"//container/trie:go_default_library",
"//crypto/bls:go_default_library",
"//crypto/hash:go_default_library",
"//network/forks:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/block:go_default_library",
"//runtime/version:go_default_library",
@ -39,7 +40,6 @@ go_library(
"//shared/bytesutil:go_default_library",
"//shared/depositutil:go_default_library",
"//shared/mathutil:go_default_library",
"//shared/p2putils:go_default_library",
"//shared/params:go_default_library",
"//shared/slashutil:go_default_library",
"@com_github_pkg_errors//:go_default_library",

View File

@ -10,10 +10,10 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
"github.com/prysmaticlabs/prysm/crypto/bls"
"github.com/prysmaticlabs/prysm/network/forks"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"github.com/prysmaticlabs/prysm/shared/attestationutil"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/params"
)
@ -84,7 +84,7 @@ func VerifyBlockSignature(beaconState state.ReadOnlyBeaconState,
// via the respective epoch.
func VerifyBlockSignatureUsingCurrentFork(beaconState state.ReadOnlyBeaconState, blk block.SignedBeaconBlock) error {
currentEpoch := core.SlotToEpoch(blk.Block().Slot())
fork, err := p2putils.Fork(currentEpoch)
fork, err := forks.Fork(currentEpoch)
if err != nil {
return err
}

View File

@ -18,11 +18,11 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers",
visibility = [
"//beacon-chain:__subpackages__",
"//network/forks:__pkg__",
"//shared/attestationutil:__pkg__",
"//shared/depositutil:__pkg__",
"//shared/interop:__pkg__",
"//shared/keystore:__pkg__",
"//shared/p2putils:__pkg__",
"//shared/testutil:__pkg__",
"//shared/testutil/altair:__pkg__",
"//slasher:__subpackages__",

View File

@ -15,7 +15,7 @@ go_library(
"//beacon-chain/state:go_default_library",
"//beacon-chain/state/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//shared:go_default_library",
"//runtime:go_default_library",
"//shared/interop:go_default_library",
"//time/slots:go_default_library",
"@com_github_prysmaticlabs_eth2_types//:go_default_library",

View File

@ -16,12 +16,12 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/runtime"
"github.com/prysmaticlabs/prysm/shared/interop"
"github.com/prysmaticlabs/prysm/time/slots"
)
var _ shared.Service = (*Service)(nil)
var _ runtime.Service = (*Service)(nil)
var _ depositcache.DepositFetcher = (*Service)(nil)
var _ powchain.ChainStartFetcher = (*Service)(nil)

View File

@ -42,10 +42,10 @@ go_library(
"//monitoring/backup:go_default_library",
"//monitoring/prometheus:go_default_library",
"//monitoring/tracing:go_default_library",
"//runtime:go_default_library",
"//runtime/debug:go_default_library",
"//runtime/prereqs:go_default_library",
"//runtime/version:go_default_library",
"//shared:go_default_library",
"//shared/cmd:go_default_library",
"//shared/event:go_default_library",
"//shared/params:go_default_library",

View File

@ -43,10 +43,10 @@ import (
"github.com/prysmaticlabs/prysm/container/slice"
"github.com/prysmaticlabs/prysm/monitoring/backup"
"github.com/prysmaticlabs/prysm/monitoring/prometheus"
"github.com/prysmaticlabs/prysm/runtime"
"github.com/prysmaticlabs/prysm/runtime/debug"
"github.com/prysmaticlabs/prysm/runtime/prereqs"
"github.com/prysmaticlabs/prysm/runtime/version"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/shared/cmd"
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/params"
@ -63,7 +63,7 @@ type BeaconNode struct {
cliCtx *cli.Context
ctx context.Context
cancel context.CancelFunc
services *shared.ServiceRegistry
services *runtime.ServiceRegistry
lock sync.RWMutex
stop chan struct{} // Channel to wait for termination notifications.
db db.Database
@ -100,7 +100,7 @@ func New(cliCtx *cli.Context) (*BeaconNode, error) {
// Initializes any forks here.
params.BeaconConfig().InitializeForkSchedule()
registry := shared.NewServiceRegistry()
registry := runtime.NewServiceRegistry()
ctx, cancel := context.WithCancel(cliCtx.Context)
beacon := &BeaconNode{

View File

@ -57,14 +57,14 @@ go_library(
"//crypto/hash:go_default_library",
"//monitoring/tracing:go_default_library",
"//network:go_default_library",
"//network/forks:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/metadata:go_default_library",
"//proto/prysm/v1alpha1/wrapper:go_default_library",
"//runtime:go_default_library",
"//runtime/version:go_default_library",
"//shared:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/fileutil:go_default_library",
"//shared/p2putils:go_default_library",
"//shared/params:go_default_library",
"//shared/runutil:go_default_library",
"//time:go_default_library",
@ -143,6 +143,7 @@ go_test(
"//beacon-chain/p2p/types:go_default_library",
"//crypto/hash:go_default_library",
"//network:go_default_library",
"//network/forks:go_default_library",
"//proto/eth/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/wrapper:go_default_library",
@ -150,7 +151,6 @@ go_test(
"//runtime/version:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/event:go_default_library",
"//shared/p2putils:go_default_library",
"//shared/params:go_default_library",
"//shared/testutil:go_default_library",
"//shared/testutil/assert:go_default_library",

View File

@ -9,8 +9,8 @@ import (
"github.com/ethereum/go-ethereum/p2p/enr"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/core"
"github.com/prysmaticlabs/prysm/network/forks"
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/params"
prysmTime "github.com/prysmaticlabs/prysm/time"
"github.com/sirupsen/logrus"
@ -25,7 +25,7 @@ func (s *Service) currentForkDigest() ([4]byte, error) {
if !s.isInitialized() {
return [4]byte{}, errors.New("state is not initialized")
}
return p2putils.CreateForkDigest(s.genesisTime, s.genesisValidatorsRoot)
return forks.CreateForkDigest(s.genesisTime, s.genesisValidatorsRoot)
}
// Compares fork ENRs between an incoming peer's record and our node's
@ -84,7 +84,7 @@ func addForkEntry(
genesisTime time.Time,
genesisValidatorsRoot []byte,
) (*enode.LocalNode, error) {
digest, err := p2putils.CreateForkDigest(genesisTime, genesisValidatorsRoot)
digest, err := forks.CreateForkDigest(genesisTime, genesisValidatorsRoot)
if err != nil {
return nil, err
}
@ -93,7 +93,7 @@ func addForkEntry(
if prysmTime.Now().Before(genesisTime) {
currentEpoch = 0
}
nextForkVersion, nextForkEpoch, err := p2putils.NextForkData(currentEpoch)
nextForkVersion, nextForkEpoch, err := forks.NextForkData(currentEpoch)
if err != nil {
return nil, err
}

View File

@ -16,9 +16,9 @@ import (
types "github.com/prysmaticlabs/eth2-types"
mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/network/forks"
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
@ -219,7 +219,7 @@ func TestDiscv5_AddRetrieveForkEntryENR(t *testing.T) {
genesisTime := time.Now()
genesisValidatorsRoot := make([]byte, 32)
digest, err := p2putils.CreateForkDigest(genesisTime, make([]byte, 32))
digest, err := forks.CreateForkDigest(genesisTime, make([]byte, 32))
require.NoError(t, err)
enrForkID := &pb.ENRForkID{
CurrentForkDigest: digest[:],

View File

@ -4,8 +4,8 @@ import (
pubsub_pb "github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
"github.com/prysmaticlabs/prysm/crypto/hash"
"github.com/prysmaticlabs/prysm/network/forks"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/params"
)
@ -36,7 +36,7 @@ func MsgID(genesisValidatorsRoot []byte, pmsg *pubsub_pb.Message) string {
copy(msg, "invalid")
return string(msg)
}
_, fEpoch, err := p2putils.RetrieveForkDataFromDigest(digest, genesisValidatorsRoot)
_, fEpoch, err := forks.RetrieveForkDataFromDigest(digest, genesisValidatorsRoot)
if err != nil {
// Impossible condition that should
// never be hit.

View File

@ -10,15 +10,15 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/crypto/hash"
"github.com/prysmaticlabs/prysm/network/forks"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
)
func TestMsgID_HashesCorrectly(t *testing.T) {
genesisValidatorsRoot := bytesutil.PadTo([]byte{'A'}, 32)
d, err := p2putils.CreateForkDigest(time.Now(), genesisValidatorsRoot)
d, err := forks.CreateForkDigest(time.Now(), genesisValidatorsRoot)
assert.NoError(t, err)
tpc := fmt.Sprintf(p2p.BlockSubnetTopicFormat, d)
invalidSnappy := [32]byte{'J', 'U', 'N', 'K'}

View File

@ -8,7 +8,7 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
pubsubpb "github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/network/forks"
"github.com/prysmaticlabs/prysm/shared/params"
)
@ -42,7 +42,7 @@ func (s *Service) CanSubscribe(topic string) bool {
log.WithError(err).Error("Could not determine fork digest")
return false
}
digest, err := p2putils.ForkDigestFromEpoch(params.BeaconConfig().AltairForkEpoch, s.genesisValidatorsRoot)
digest, err := forks.ForkDigestFromEpoch(params.BeaconConfig().AltairForkEpoch, s.genesisValidatorsRoot)
if err != nil {
log.WithError(err).Error("Could not determine next fork digest")
return false

View File

@ -13,8 +13,8 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed"
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
"github.com/prysmaticlabs/prysm/network/forks"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
prysmTime "github.com/prysmaticlabs/prysm/time"
"github.com/stretchr/testify/require"
@ -25,7 +25,7 @@ func TestService_CanSubscribe(t *testing.T) {
validProtocolSuffix := "/" + encoder.ProtocolSuffixSSZSnappy
genesisTime := time.Now()
valRoot := [32]byte{}
digest, err := p2putils.CreateForkDigest(genesisTime, valRoot[:])
digest, err := forks.CreateForkDigest(genesisTime, valRoot[:])
assert.NoError(t, err)
type test struct {
name string
@ -211,7 +211,7 @@ func TestService_FilterIncomingSubscriptions(t *testing.T) {
validProtocolSuffix := "/" + encoder.ProtocolSuffixSSZSnappy
genesisTime := time.Now()
valRoot := [32]byte{}
digest, err := p2putils.CreateForkDigest(genesisTime, valRoot[:])
digest, err := forks.CreateForkDigest(genesisTime, valRoot[:])
assert.NoError(t, err)
type args struct {
id peer.ID

View File

@ -29,7 +29,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/metadata"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/runtime"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/runutil"
"github.com/prysmaticlabs/prysm/time/slots"
@ -37,7 +37,7 @@ import (
"go.opencensus.io/trace"
)
var _ shared.Service = (*Service)(nil)
var _ runtime.Service = (*Service)(nil)
// In the event that we are at our peer limit, we
// stop looking for new peers and instead poll

View File

@ -21,9 +21,9 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
"github.com/prysmaticlabs/prysm/network/forks"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
prysmTime "github.com/prysmaticlabs/prysm/time"
@ -320,7 +320,7 @@ func initializeStateWithForkDigest(ctx context.Context, t *testing.T, ef *event.
})
}
fd, err := p2putils.CreateForkDigest(gt, gvr)
fd, err := forks.CreateForkDigest(gt, gvr)
require.NoError(t, err)
time.Sleep(50 * time.Millisecond) // wait for pubsub filter to initialize.

View File

@ -46,6 +46,6 @@ pkg_deb(
package = "prysm-beacon-chain",
postinst = "postinst.sh",
preinst = "preinst.sh",
version_file = "//shared:version_file",
version_file = "//runtime:version_file",
visibility = ["//beacon-chain:__pkg__"],
)

View File

@ -38,6 +38,7 @@ go_library(
"//beacon-chain/state/v1:go_default_library",
"//config/features:go_default_library",
"//crypto/bls:go_default_library",
"//network/forks:go_default_library",
"//proto/eth/v1:go_default_library",
"//proto/eth/v2:go_default_library",
"//proto/migration:go_default_library",
@ -45,7 +46,6 @@ go_library(
"//proto/prysm/v1alpha1/block:go_default_library",
"//proto/prysm/v1alpha1/wrapper:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/p2putils:go_default_library",
"//shared/params:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_pkg_errors//:go_default_library",

View File

@ -8,8 +8,8 @@ import (
"strings"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/prysmaticlabs/prysm/network/forks"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/params"
"go.opencensus.io/trace"
"google.golang.org/grpc/codes"
@ -29,7 +29,7 @@ func (bs *Server) GetForkSchedule(ctx context.Context, _ *emptypb.Empty) (*ethpb
}, nil
}
versions := p2putils.SortedForkVersions(schedule)
versions := forks.SortedForkVersions(schedule)
forks := make([]*ethpb.Fork, len(schedule))
var previous, current []byte
for i, v := range versions {

View File

@ -40,10 +40,10 @@ go_test(
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/wrapper:go_default_library",
"//shared/event:go_default_library",
"//shared/mock:go_default_library",
"//shared/testutil:go_default_library",
"//shared/testutil/assert:go_default_library",
"//shared/testutil/require:go_default_library",
"//testing/mock:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_grpc_ecosystem_grpc_gateway_v2//proto/gateway:go_default_library",
"@org_golang_google_protobuf//types/known/anypb:go_default_library",

View File

@ -16,10 +16,10 @@ import (
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/testing/mock"
"google.golang.org/protobuf/types/known/anypb"
)

View File

@ -106,11 +106,11 @@ go_test(
"//shared/attestationutil:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/cmd:go_default_library",
"//shared/mock:go_default_library",
"//shared/params:go_default_library",
"//shared/testutil:go_default_library",
"//shared/testutil/assert:go_default_library",
"//shared/testutil/require:go_default_library",
"//testing/mock:go_default_library",
"//time:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_prysmaticlabs_eth2_types//:go_default_library",

View File

@ -27,11 +27,11 @@ import (
"github.com/prysmaticlabs/prysm/shared/attestationutil"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/cmd"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/testing/mock"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/emptypb"
)

View File

@ -22,11 +22,11 @@ import (
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/cmd"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/testing/mock"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/emptypb"
)

View File

@ -47,6 +47,7 @@ go_library(
"//crypto/hash:go_default_library",
"//crypto/rand:go_default_library",
"//monitoring/tracing:go_default_library",
"//network/forks:go_default_library",
"//proto/eth/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/block:go_default_library",
@ -58,7 +59,6 @@ go_library(
"//shared/bytesutil:go_default_library",
"//shared/depositutil:go_default_library",
"//shared/event:go_default_library",
"//shared/p2putils:go_default_library",
"//shared/params:go_default_library",
"//time:go_default_library",
"//time/slots:go_default_library",
@ -128,11 +128,11 @@ go_test(
"//shared/attestationutil:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/event:go_default_library",
"//shared/mock:go_default_library",
"//shared/params:go_default_library",
"//shared/testutil:go_default_library",
"//shared/testutil/assert:go_default_library",
"//shared/testutil/require:go_default_library",
"//testing/mock:go_default_library",
"//time:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_prysmaticlabs_eth2_types//:go_default_library",

View File

@ -20,11 +20,11 @@ import (
ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/testing/mock"
)
// pubKey is a helper to generate a well-formed public key.

View File

@ -13,11 +13,11 @@ import (
dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/testing/mock"
)
func TestServer_StreamAltairBlocksVerified_ContextCanceled(t *testing.T) {

View File

@ -24,9 +24,9 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
"github.com/prysmaticlabs/prysm/beacon-chain/sync"
"github.com/prysmaticlabs/prysm/network/forks"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/params"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@ -124,7 +124,7 @@ func (vs *Server) ValidatorIndex(ctx context.Context, req *ethpb.ValidatorIndexR
// DomainData fetches the current domain version information from the beacon state.
func (vs *Server) DomainData(_ context.Context, request *ethpb.DomainRequest) (*ethpb.DomainResponse, error) {
fork, err := p2putils.Fork(request.Epoch)
fork, err := forks.Fork(request.Epoch)
if err != nil {
return nil, err
}

View File

@ -19,11 +19,11 @@ import (
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/testing/mock"
logTest "github.com/sirupsen/logrus/hooks/test"
"google.golang.org/protobuf/types/known/emptypb"
)

View File

@ -81,17 +81,17 @@ go_library(
"//crypto/bls:go_default_library",
"//crypto/rand:go_default_library",
"//monitoring/tracing:go_default_library",
"//network/forks:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/block:go_default_library",
"//proto/prysm/v1alpha1/metadata:go_default_library",
"//proto/prysm/v1alpha1/wrapper:go_default_library",
"//runtime:go_default_library",
"//runtime/messagehandler:go_default_library",
"//runtime/version:go_default_library",
"//shared:go_default_library",
"//shared/abool:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/messagehandler:go_default_library",
"//shared/mputil:go_default_library",
"//shared/p2putils:go_default_library",
"//shared/params:go_default_library",
"//shared/runutil:go_default_library",
"//shared/sszutil:go_default_library",
@ -186,6 +186,7 @@ go_test(
"//cmd/beacon-chain/flags:go_default_library",
"//crypto/bls:go_default_library",
"//crypto/rand:go_default_library",
"//network/forks:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/block:go_default_library",
"//proto/prysm/v1alpha1/metadata:go_default_library",
@ -193,7 +194,6 @@ go_test(
"//shared/abool:go_default_library",
"//shared/attestationutil:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/p2putils:go_default_library",
"//shared/params:go_default_library",
"//shared/sszutil:go_default_library",
"//shared/testutil:go_default_library",

View File

@ -5,7 +5,7 @@ import (
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/core"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/network/forks"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/time/slots"
)
@ -41,7 +41,7 @@ func (s *Service) forkWatcher() {
// it registers the appropriate gossip and rpc topics.
func (s *Service) registerForUpcomingFork(currEpoch types.Epoch) error {
genRoot := s.cfg.Chain.GenesisValidatorRoot()
isNextForkEpoch, err := p2putils.IsForkNextEpoch(s.cfg.Chain.GenesisTime(), genRoot[:])
isNextForkEpoch, err := forks.IsForkNextEpoch(s.cfg.Chain.GenesisTime(), genRoot[:])
if err != nil {
return errors.Wrap(err, "Could not retrieve next fork epoch")
}
@ -51,7 +51,7 @@ func (s *Service) registerForUpcomingFork(currEpoch types.Epoch) error {
if isNextForkEpoch {
nextEpoch := currEpoch + 1
if nextEpoch == params.BeaconConfig().AltairForkEpoch {
digest, err := p2putils.ForkDigestFromEpoch(nextEpoch, genRoot[:])
digest, err := forks.ForkDigestFromEpoch(nextEpoch, genRoot[:])
if err != nil {
return errors.Wrap(err, "Could not retrieve fork digest")
}
@ -72,7 +72,7 @@ func (s *Service) deregisterFromPastFork(currEpoch types.Epoch) error {
// This method takes care of the de-registration of
// old gossip pubsub handlers. Once we are at the epoch
// after the fork, we de-register from all the outdated topics.
currFork, err := p2putils.Fork(currEpoch)
currFork, err := forks.Fork(currEpoch)
if err != nil {
return err
}
@ -86,7 +86,7 @@ func (s *Service) deregisterFromPastFork(currEpoch types.Epoch) error {
if epochAfterFork == currEpoch {
// Look at the previous fork's digest.
epochBeforeFork := currFork.Epoch - 1
prevDigest, err := p2putils.ForkDigestFromEpoch(epochBeforeFork, genRoot[:])
prevDigest, err := forks.ForkDigestFromEpoch(epochBeforeFork, genRoot[:])
if err != nil {
return errors.Wrap(err, "Failed to determine previous epoch fork digest")
}

View File

@ -10,8 +10,8 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
"github.com/prysmaticlabs/prysm/network/forks"
"github.com/prysmaticlabs/prysm/shared/abool"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
)
@ -85,7 +85,7 @@ func TestService_CheckForNextEpochFork(t *testing.T) {
wantErr: false,
postSvcCheck: func(t *testing.T, s *Service) {
genRoot := s.cfg.Chain.GenesisValidatorRoot()
digest, err := p2putils.ForkDigestFromEpoch(5, genRoot[:])
digest, err := forks.ForkDigestFromEpoch(5, genRoot[:])
assert.NoError(t, err)
assert.Equal(t, true, s.subHandler.digestExists(digest))
rpcMap := make(map[string]bool)
@ -192,12 +192,12 @@ func TestService_CheckForPreviousEpochFork(t *testing.T) {
r.registerRPCHandlersAltair()
genRoot := r.cfg.Chain.GenesisValidatorRoot()
digest, err := p2putils.ForkDigestFromEpoch(0, genRoot[:])
digest, err := forks.ForkDigestFromEpoch(0, genRoot[:])
assert.NoError(t, err)
r.registerSubscribers(0, digest)
assert.Equal(t, true, r.subHandler.digestExists(digest))
digest, err = p2putils.ForkDigestFromEpoch(3, genRoot[:])
digest, err = forks.ForkDigestFromEpoch(3, genRoot[:])
assert.NoError(t, err)
r.registerSubscribers(3, digest)
assert.Equal(t, true, r.subHandler.digestExists(digest))
@ -208,10 +208,10 @@ func TestService_CheckForPreviousEpochFork(t *testing.T) {
wantErr: false,
postSvcCheck: func(t *testing.T, s *Service) {
genRoot := s.cfg.Chain.GenesisValidatorRoot()
digest, err := p2putils.ForkDigestFromEpoch(0, genRoot[:])
digest, err := forks.ForkDigestFromEpoch(0, genRoot[:])
assert.NoError(t, err)
assert.Equal(t, false, s.subHandler.digestExists(digest))
digest, err = p2putils.ForkDigestFromEpoch(3, genRoot[:])
digest, err = forks.ForkDigestFromEpoch(3, genRoot[:])
assert.NoError(t, err)
assert.Equal(t, true, s.subHandler.digestExists(digest))

View File

@ -31,7 +31,7 @@ go_library(
"//crypto/rand:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/block:go_default_library",
"//shared:go_default_library",
"//runtime:go_default_library",
"//shared/abool:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/mathutil:go_default_library",

View File

@ -17,14 +17,14 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/db"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/runtime"
"github.com/prysmaticlabs/prysm/shared/abool"
"github.com/prysmaticlabs/prysm/shared/params"
prysmTime "github.com/prysmaticlabs/prysm/time"
"github.com/sirupsen/logrus"
)
var _ shared.Service = (*Service)(nil)
var _ runtime.Service = (*Service)(nil)
// blockchainService defines the interface for interaction with block chain service.
type blockchainService interface {

View File

@ -8,10 +8,10 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
"github.com/prysmaticlabs/prysm/network/forks"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"github.com/prysmaticlabs/prysm/runtime/version"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/params"
)
@ -33,14 +33,14 @@ func WriteBlockChunk(stream libp2pcore.Stream, chain blockchain.ChainInfoFetcher
switch blk.Version() {
case version.Phase0:
valRoot := chain.GenesisValidatorRoot()
digest, err := p2putils.ForkDigestFromEpoch(params.BeaconConfig().GenesisEpoch, valRoot[:])
digest, err := forks.ForkDigestFromEpoch(params.BeaconConfig().GenesisEpoch, valRoot[:])
if err != nil {
return err
}
obtainedCtx = digest[:]
case version.Altair:
valRoot := chain.GenesisValidatorRoot()
digest, err := p2putils.ForkDigestFromEpoch(params.BeaconConfig().AltairForkEpoch, valRoot[:])
digest, err := forks.ForkDigestFromEpoch(params.BeaconConfig().AltairForkEpoch, valRoot[:])
if err != nil {
return err
}

View File

@ -12,12 +12,12 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
"github.com/prysmaticlabs/prysm/network/forks"
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/metadata"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/runtime/version"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/params"
)
@ -107,7 +107,7 @@ func (s *Service) sendMetaDataRequest(ctx context.Context, id peer.ID) (metadata
return nil, errors.New(errMsg)
}
valRoot := s.cfg.Chain.GenesisValidatorRoot()
rpcCtx, err := p2putils.ForkDigestFromEpoch(core.SlotToEpoch(s.cfg.Chain.CurrentSlot()), valRoot[:])
rpcCtx, err := forks.ForkDigestFromEpoch(core.SlotToEpoch(s.cfg.Chain.CurrentSlot()), valRoot[:])
if err != nil {
return nil, err
}

View File

@ -31,7 +31,7 @@ import (
lruwrpr "github.com/prysmaticlabs/prysm/cache/lru"
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/runtime"
"github.com/prysmaticlabs/prysm/shared/abool"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/runutil"
@ -39,7 +39,7 @@ import (
"github.com/prysmaticlabs/prysm/time/slots"
)
var _ shared.Service = (*Service)(nil)
var _ runtime.Service = (*Service)(nil)
const rangeLimit = 1024
const seenBlockSize = 1000

View File

@ -17,10 +17,10 @@ import (
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
"github.com/prysmaticlabs/prysm/container/slice"
"github.com/prysmaticlabs/prysm/monitoring/tracing"
"github.com/prysmaticlabs/prysm/network/forks"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/messagehandler"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/runtime/messagehandler"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/time/slots"
"go.opencensus.io/trace"
@ -120,7 +120,7 @@ func (s *Service) registerSubscribers(epoch types.Epoch, digest [4]byte) {
// The base protobuf message is used to initialize new messages for decoding.
func (s *Service) subscribe(topic string, validator pubsub.ValidatorEx, handle subHandler, digest [4]byte) *pubsub.Subscription {
genRoot := s.cfg.Chain.GenesisValidatorRoot()
_, e, err := p2putils.RetrieveForkDataFromDigest(digest, genRoot[:])
_, e, err := forks.RetrieveForkDataFromDigest(digest, genRoot[:])
if err != nil {
// Impossible condition as it would mean digest does not exist.
panic(err)
@ -266,7 +266,7 @@ func (s *Service) wrapAndReportValidation(topic string, v pubsub.ValidatorEx) (s
// used to handle messages from the subnet. The base protobuf message is used to initialize new messages for decoding.
func (s *Service) subscribeStaticWithSubnets(topic string, validator pubsub.ValidatorEx, handle subHandler, digest [4]byte) {
genRoot := s.cfg.Chain.GenesisValidatorRoot()
_, e, err := p2putils.RetrieveForkDataFromDigest(digest, genRoot[:])
_, e, err := forks.RetrieveForkDataFromDigest(digest, genRoot[:])
if err != nil {
// Impossible condition as it would mean digest does not exist.
panic(err)
@ -339,7 +339,7 @@ func (s *Service) subscribeDynamicWithSubnets(
digest [4]byte,
) {
genRoot := s.cfg.Chain.GenesisValidatorRoot()
_, e, err := p2putils.RetrieveForkDataFromDigest(digest, genRoot[:])
_, e, err := forks.RetrieveForkDataFromDigest(digest, genRoot[:])
if err != nil {
// Impossible condition as it would mean digest does not exist.
panic(err)
@ -468,7 +468,7 @@ func (s *Service) subscribeSyncSubnet(
// used to handle messages from the subnet. The base protobuf message is used to initialize new messages for decoding.
func (s *Service) subscribeStaticWithSyncSubnets(topic string, validator pubsub.ValidatorEx, handle subHandler, digest [4]byte) {
genRoot := s.cfg.Chain.GenesisValidatorRoot()
_, e, err := p2putils.RetrieveForkDataFromDigest(digest, genRoot[:])
_, e, err := forks.RetrieveForkDataFromDigest(digest, genRoot[:])
if err != nil {
panic(err)
}
@ -539,7 +539,7 @@ func (s *Service) subscribeDynamicWithSyncSubnets(
digest [4]byte,
) {
genRoot := s.cfg.Chain.GenesisValidatorRoot()
_, e, err := p2putils.RetrieveForkDataFromDigest(digest, genRoot[:])
_, e, err := forks.RetrieveForkDataFromDigest(digest, genRoot[:])
if err != nil {
panic(err)
}
@ -705,16 +705,16 @@ func (s *Service) addDigestAndIndexToTopic(topic string, digest [4]byte, idx uin
func (s *Service) currentForkDigest() ([4]byte, error) {
genRoot := s.cfg.Chain.GenesisValidatorRoot()
return p2putils.CreateForkDigest(s.cfg.Chain.GenesisTime(), genRoot[:])
return forks.CreateForkDigest(s.cfg.Chain.GenesisTime(), genRoot[:])
}
// Checks if the provided digest matches up with the current supposed digest.
func isDigestValid(digest [4]byte, genesis time.Time, genValRoot [32]byte) (bool, error) {
retDigest, err := p2putils.CreateForkDigest(genesis, genValRoot[:])
retDigest, err := forks.CreateForkDigest(genesis, genValRoot[:])
if err != nil {
return false, err
}
isNextEpoch, err := p2putils.IsForkNextEpoch(genesis, genValRoot[:])
isNextEpoch, err := forks.IsForkNextEpoch(genesis, genValRoot[:])
if err != nil {
return false, err
}

View File

@ -23,10 +23,10 @@ import (
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
lruwrpr "github.com/prysmaticlabs/prysm/cache/lru"
"github.com/prysmaticlabs/prysm/network/forks"
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/abool"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@ -324,7 +324,7 @@ func Test_wrapAndReportValidation(t *testing.T) {
Genesis: time.Now(),
ValidatorsRoot: [32]byte{0x01},
}
fd, err := p2putils.CreateForkDigest(mChain.GenesisTime(), mChain.ValidatorsRoot[:])
fd, err := forks.CreateForkDigest(mChain.GenesisTime(), mChain.ValidatorsRoot[:])
assert.NoError(t, err)
mockTopic := fmt.Sprintf(p2p.BlockSubnetTopicFormat, fd) + encoder.SszNetworkEncoder{}.ProtocolSuffix()
type args struct {

View File

@ -8,7 +8,7 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
"github.com/prysmaticlabs/prysm/shared/p2putils"
"github.com/prysmaticlabs/prysm/network/forks"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
)
@ -18,7 +18,7 @@ func TestSubTopicHandler_CRUD(t *testing.T) {
assert.Equal(t, false, h.topicExists("junk"))
assert.Equal(t, false, h.digestExists([4]byte{}))
digest, err := p2putils.CreateForkDigest(time.Now(), make([]byte, 32))
digest, err := forks.CreateForkDigest(time.Now(), make([]byte, 32))
assert.NoError(t, err)
enc := encoder.SszNetworkEncoder{}

View File

@ -11,7 +11,7 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/monitoring/prometheus",
visibility = ["//visibility:public"],
deps = [
"//shared:go_default_library",
"//runtime:go_default_library",
"@com_github_golang_gddo//httputil:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
@ -29,7 +29,7 @@ go_test(
],
embed = [":go_default_library"],
deps = [
"//shared:go_default_library",
"//runtime:go_default_library",
"//shared/testutil/assert:go_default_library",
"//shared/testutil/require:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",

View File

@ -14,7 +14,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/runtime"
"github.com/sirupsen/logrus"
)
@ -24,7 +24,7 @@ var log = logrus.WithField("prefix", "prometheus")
// show all the metrics registered with the Prometheus DefaultRegisterer.
type Service struct {
server *http.Server
svcRegistry *shared.ServiceRegistry
svcRegistry *runtime.ServiceRegistry
failStatus error
}
@ -36,7 +36,7 @@ type Handler struct {
// NewService sets up a new instance for a given address host:port.
// An empty host will match with any IP so an address like ":2121" is perfectly acceptable.
func NewService(addr string, svcRegistry *shared.ServiceRegistry, additionalHandlers ...Handler) *Service {
func NewService(addr string, svcRegistry *runtime.ServiceRegistry, additionalHandlers ...Handler) *Service {
s := &Service{svcRegistry: svcRegistry}
mux := http.NewServeMux()

View File

@ -9,7 +9,7 @@ import (
"testing"
"time"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/runtime"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/sirupsen/logrus"
@ -57,7 +57,7 @@ func (m *mockService) Status() error {
}
func TestHealthz(t *testing.T) {
registry := shared.NewServiceRegistry()
registry := runtime.NewServiceRegistry()
m := &mockService{}
require.NoError(t, registry.RegisterService(m), "Failed to register service")
s := NewService("" /*addr*/, registry)
@ -109,7 +109,7 @@ func TestStatus(t *testing.T) {
func TestContentNegotiation(t *testing.T) {
t.Run("/healthz all services are ok", func(t *testing.T) {
registry := shared.NewServiceRegistry()
registry := runtime.NewServiceRegistry()
m := &mockService{}
require.NoError(t, registry.RegisterService(m), "Failed to register service")
s := NewService("", registry)
@ -139,7 +139,7 @@ func TestContentNegotiation(t *testing.T) {
})
t.Run("/healthz failed service", func(t *testing.T) {
registry := shared.NewServiceRegistry()
registry := runtime.NewServiceRegistry()
m := &mockService{}
m.status = errors.New("something is wrong")
require.NoError(t, registry.RegisterService(m), "Failed to register service")

View File

@ -3,7 +3,7 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = ["fork.go"],
importpath = "github.com/prysmaticlabs/prysm/shared/p2putils",
importpath = "github.com/prysmaticlabs/prysm/network/forks",
visibility = ["//visibility:public"],
deps = [
"//beacon-chain/core:go_default_library",

View File

@ -1,5 +1,5 @@
// Package p2putils contains useful helpers for Ethereum consensus fork-related functionality.
package p2putils
// Package forks contains useful helpers for Ethereum consensus fork-related functionality.
package forks
import (
"math"

View File

@ -1,4 +1,4 @@
package p2putils
package forks
import (
"math"

View File

@ -7,7 +7,7 @@
},
"unreachable": {
"exclude_files": {
"shared/messagehandler/messagehandler_test.go": "Necessary panic before return for test",
"runtime/messagehandler/messagehandler_test.go": "Necessary panic before return for test",
"external/.*": "Unreachable third party code"
}
},

View File

@ -3,14 +3,13 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = ["service_registry.go"],
importpath = "github.com/prysmaticlabs/prysm/shared",
importpath = "github.com/prysmaticlabs/prysm/runtime",
visibility = ["//visibility:public"],
deps = ["@com_github_sirupsen_logrus//:go_default_library"],
)
go_test(
name = "go_default_test",
size = "small",
srcs = ["service_registry_test.go"],
embed = [":go_default_library"],
deps = [

View File

@ -3,7 +3,7 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = ["messagehandler.go"],
importpath = "github.com/prysmaticlabs/prysm/shared/messagehandler",
importpath = "github.com/prysmaticlabs/prysm/runtime/messagehandler",
visibility = ["//visibility:public"],
deps = [
"@com_github_libp2p_go_libp2p_pubsub//:go_default_library",

View File

@ -5,7 +5,7 @@ import (
"testing"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/prysmaticlabs/prysm/shared/messagehandler"
"github.com/prysmaticlabs/prysm/runtime/messagehandler"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
logTest "github.com/sirupsen/logrus/hooks/test"
)

View File

@ -1,6 +1,6 @@
// Package shared includes useful utilities globally accessible in
// the Prysm monorepo.
package shared
package runtime
import (
"fmt"

View File

@ -1,4 +1,4 @@
package shared
package runtime
import (
"errors"

View File

@ -1 +0,0 @@
load("@prysm//tools/go:def.bzl", "go_library", "go_test")

View File

@ -1 +0,0 @@
load("@prysm//tools/go:def.bzl", "go_library", "go_test")

View File

@ -22,11 +22,11 @@ go_library(
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/p2p:go_default_library",
"//container/slice:go_default_library",
"//network/forks:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/block:go_default_library",
"//proto/prysm/v1alpha1/wrapper:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/p2putils:go_default_library",
"//shared/params:go_default_library",
"//shared/testutil:go_default_library",
"//testing/endtoend/helpers:go_default_library",

View File

@ -12,8 +12,8 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/network/forks"
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/p2putils"
e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params"
"github.com/prysmaticlabs/prysm/testing/endtoend/policies"
"github.com/prysmaticlabs/prysm/testing/endtoend/types"
@ -90,7 +90,7 @@ func metricsTest(conns ...*grpc.ClientConn) error {
if err != nil {
return err
}
forkDigest, err := p2putils.CreateForkDigest(time.Unix(genesis.GenesisTime.Seconds, 0), genesis.GenesisValidatorsRoot)
forkDigest, err := forks.CreateForkDigest(time.Unix(genesis.GenesisTime.Seconds, 0), genesis.GenesisValidatorsRoot)
if err != nil {
return err
}

View File

@ -17,7 +17,7 @@ go_library(
"keymanager_mock.go",
"node_service_mock.go",
],
importpath = "github.com/prysmaticlabs/prysm/shared/mock",
importpath = "github.com/prysmaticlabs/prysm/testing/mock",
visibility = ["//visibility:public"],
deps = [
"//proto/eth/service:go_default_library",

View File

@ -77,11 +77,11 @@ go_test(
"//shared/bytesutil:go_default_library",
"//shared/event:go_default_library",
"//shared/fileutil:go_default_library",
"//shared/mock:go_default_library",
"//shared/params:go_default_library",
"//shared/petnames:go_default_library",
"//shared/testutil/assert:go_default_library",
"//shared/testutil/require:go_default_library",
"//testing/mock:go_default_library",
"//time:go_default_library",
"//validator/accounts/iface:go_default_library",
"//validator/accounts/wallet:go_default_library",

View File

@ -11,9 +11,9 @@ import (
"github.com/golang/mock/gomock"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
mock2 "github.com/prysmaticlabs/prysm/testing/mock"
"github.com/prysmaticlabs/prysm/validator/accounts/wallet"
"github.com/prysmaticlabs/prysm/validator/keymanager"
"github.com/prysmaticlabs/prysm/validator/keymanager/imported"
@ -25,8 +25,8 @@ import (
func TestExitAccountsCli_OK(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockValidatorClient := mock.NewMockBeaconNodeValidatorClient(ctrl)
mockNodeClient := mock.NewMockNodeClient(ctrl)
mockValidatorClient := mock2.NewMockBeaconNodeValidatorClient(ctrl)
mockNodeClient := mock2.NewMockNodeClient(ctrl)
mockValidatorClient.EXPECT().
ValidatorIndex(gomock.Any(), gomock.Any()).
@ -111,8 +111,8 @@ func TestExitAccountsCli_OK(t *testing.T) {
func TestExitAccountsCli_OK_AllPublicKeys(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockValidatorClient := mock.NewMockBeaconNodeValidatorClient(ctrl)
mockNodeClient := mock.NewMockNodeClient(ctrl)
mockValidatorClient := mock2.NewMockBeaconNodeValidatorClient(ctrl)
mockNodeClient := mock2.NewMockNodeClient(ctrl)
mockValidatorClient.EXPECT().
ValidatorIndex(gomock.Any(), gomock.Any()).

View File

@ -18,10 +18,10 @@ import (
validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/petnames"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/testing/mock"
"github.com/prysmaticlabs/prysm/validator/accounts/wallet"
"github.com/prysmaticlabs/prysm/validator/keymanager"
"github.com/prysmaticlabs/prysm/validator/keymanager/derived"

View File

@ -112,15 +112,15 @@ go_test(
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/validator-client:go_default_library",
"//proto/prysm/v1alpha1/wrapper:go_default_library",
"//shared:go_default_library",
"//runtime:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/event:go_default_library",
"//shared/fileutil:go_default_library",
"//shared/mock:go_default_library",
"//shared/params:go_default_library",
"//shared/testutil:go_default_library",
"//shared/testutil/assert:go_default_library",
"//shared/testutil/require:go_default_library",
"//testing/mock:go_default_library",
"//time:go_default_library",
"//time/slots:go_default_library",
"//time/slots/testing:go_default_library",

View File

@ -8,9 +8,9 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/crypto/bls"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/testing/mock"
"github.com/prysmaticlabs/prysm/validator/client/testutil"
logTest "github.com/sirupsen/logrus/hooks/test"
)

View File

@ -16,11 +16,11 @@ import (
validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
mock2 "github.com/prysmaticlabs/prysm/testing/mock"
testing2 "github.com/prysmaticlabs/prysm/validator/db/testing"
"github.com/prysmaticlabs/prysm/validator/graffiti"
logTest "github.com/sirupsen/logrus/hooks/test"
@ -29,8 +29,8 @@ import (
)
type mocks struct {
validatorClient *mock.MockBeaconNodeValidatorClient
nodeClient *mock.MockNodeClient
validatorClient *mock2.MockBeaconNodeValidatorClient
nodeClient *mock2.MockNodeClient
signExitFunc func(context.Context, *validatorpb.SignRequest) (bls.Signature, error)
}
@ -67,8 +67,8 @@ func setupWithKey(t *testing.T, validatorKey bls.SecretKey) (*validator, *mocks,
valDB := testing2.SetupDB(t, [][48]byte{pubKey})
ctrl := gomock.NewController(t)
m := &mocks{
validatorClient: mock.NewMockBeaconNodeValidatorClient(ctrl),
nodeClient: mock.NewMockNodeClient(ctrl),
validatorClient: mock2.NewMockBeaconNodeValidatorClient(ctrl),
nodeClient: mock2.NewMockNodeClient(ctrl),
signExitFunc: func(ctx context.Context, req *validatorpb.SignRequest) (bls.Signature, error) {
return mockSignature{}, nil
},
@ -875,7 +875,7 @@ func TestSignAltairBlock(t *testing.T) {
func TestGetGraffiti_Ok(t *testing.T) {
ctrl := gomock.NewController(t)
m := &mocks{
validatorClient: mock.NewMockBeaconNodeValidatorClient(ctrl),
validatorClient: mock2.NewMockBeaconNodeValidatorClient(ctrl),
}
pubKey := [48]byte{'a'}
tests := []struct {
@ -958,7 +958,7 @@ func TestGetGraffitiOrdered_Ok(t *testing.T) {
valDB := testing2.SetupDB(t, [][48]byte{pubKey})
ctrl := gomock.NewController(t)
m := &mocks{
validatorClient: mock.NewMockBeaconNodeValidatorClient(ctrl),
validatorClient: mock2.NewMockBeaconNodeValidatorClient(ctrl),
}
m.validatorClient.EXPECT().
ValidatorIndex(gomock.Any(), &ethpb.ValidatorIndexRequest{PublicKey: pubKey[:]}).

View File

@ -6,14 +6,14 @@ import (
"testing"
"time"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/runtime"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
logTest "github.com/sirupsen/logrus/hooks/test"
"google.golang.org/grpc/metadata"
)
var _ shared.Service = (*ValidatorService)(nil)
var _ runtime.Service = (*ValidatorService)(nil)
var _ GenesisFetcher = (*ValidatorService)(nil)
var _ SyncChecker = (*ValidatorService)(nil)

View File

@ -18,11 +18,11 @@ import (
validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
mock2 "github.com/prysmaticlabs/prysm/testing/mock"
"github.com/prysmaticlabs/prysm/validator/client/iface"
dbTest "github.com/prysmaticlabs/prysm/validator/db/testing"
"github.com/sirupsen/logrus"
@ -112,7 +112,7 @@ func generateMockStatusResponse(pubkeys [][]byte) *ethpb.ValidatorActivationResp
func TestWaitForChainStart_SetsGenesisInfo(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
db := dbTest.SetupDB(t, [][48]byte{})
v := validator{
@ -127,7 +127,7 @@ func TestWaitForChainStart_SetsGenesisInfo(t *testing.T) {
genesis := uint64(time.Unix(1, 0).Unix())
genesisValidatorsRoot := bytesutil.ToBytes32([]byte("validators"))
clientStream := mock.NewMockBeaconNodeValidator_WaitForChainStartClient(ctrl)
clientStream := mock2.NewMockBeaconNodeValidator_WaitForChainStartClient(ctrl)
client.EXPECT().WaitForChainStart(
gomock.Any(),
&emptypb.Empty{},
@ -167,7 +167,7 @@ func TestWaitForChainStart_SetsGenesisInfo(t *testing.T) {
func TestWaitForChainStart_SetsGenesisInfo_IncorrectSecondTry(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
db := dbTest.SetupDB(t, [][48]byte{})
v := validator{
@ -176,7 +176,7 @@ func TestWaitForChainStart_SetsGenesisInfo_IncorrectSecondTry(t *testing.T) {
}
genesis := uint64(time.Unix(1, 0).Unix())
genesisValidatorsRoot := bytesutil.ToBytes32([]byte("validators"))
clientStream := mock.NewMockBeaconNodeValidator_WaitForChainStartClient(ctrl)
clientStream := mock2.NewMockBeaconNodeValidator_WaitForChainStartClient(ctrl)
client.EXPECT().WaitForChainStart(
gomock.Any(),
&emptypb.Empty{},
@ -219,7 +219,7 @@ func TestWaitForChainStart_SetsGenesisInfo_IncorrectSecondTry(t *testing.T) {
func TestWaitForChainStart_ContextCanceled(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
v := validator{
//keyManager: testKeyManager,
@ -227,7 +227,7 @@ func TestWaitForChainStart_ContextCanceled(t *testing.T) {
}
genesis := uint64(time.Unix(0, 0).Unix())
genesisValidatorsRoot := bytesutil.PadTo([]byte("validators"), 32)
clientStream := mock.NewMockBeaconNodeValidator_WaitForChainStartClient(ctrl)
clientStream := mock2.NewMockBeaconNodeValidator_WaitForChainStartClient(ctrl)
client.EXPECT().WaitForChainStart(
gomock.Any(),
&emptypb.Empty{},
@ -248,7 +248,7 @@ func TestWaitForChainStart_ContextCanceled(t *testing.T) {
func TestWaitForChainStart_StreamSetupFails(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
privKey, err := bls.RandKey()
require.NoError(t, err)
@ -261,7 +261,7 @@ func TestWaitForChainStart_StreamSetupFails(t *testing.T) {
validatorClient: client,
keyManager: km,
}
clientStream := mock.NewMockBeaconNodeValidator_WaitForChainStartClient(ctrl)
clientStream := mock2.NewMockBeaconNodeValidator_WaitForChainStartClient(ctrl)
client.EXPECT().WaitForChainStart(
gomock.Any(),
&emptypb.Empty{},
@ -274,12 +274,12 @@ func TestWaitForChainStart_StreamSetupFails(t *testing.T) {
func TestWaitForChainStart_ReceiveErrorFromStream(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
v := validator{
validatorClient: client,
}
clientStream := mock.NewMockBeaconNodeValidator_WaitForChainStartClient(ctrl)
clientStream := mock2.NewMockBeaconNodeValidator_WaitForChainStartClient(ctrl)
client.EXPECT().WaitForChainStart(
gomock.Any(),
&emptypb.Empty{},
@ -296,7 +296,7 @@ func TestWaitForChainStart_ReceiveErrorFromStream(t *testing.T) {
func TestCanonicalHeadSlot_FailedRPC(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconChainClient(ctrl)
client := mock2.NewMockBeaconChainClient(ctrl)
v := validator{
beaconClient: client,
genesisTime: 1,
@ -312,7 +312,7 @@ func TestCanonicalHeadSlot_FailedRPC(t *testing.T) {
func TestCanonicalHeadSlot_OK(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconChainClient(ctrl)
client := mock2.NewMockBeaconChainClient(ctrl)
v := validator{
beaconClient: client,
}
@ -329,7 +329,7 @@ func TestWaitMultipleActivation_LogsActivationEpochOK(t *testing.T) {
hook := logTest.NewGlobal()
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
privKey, err := bls.RandKey()
require.NoError(t, err)
pubKey := [48]byte{}
@ -347,7 +347,7 @@ func TestWaitMultipleActivation_LogsActivationEpochOK(t *testing.T) {
resp := generateMockStatusResponse([][]byte{pubKey[:]})
resp.Statuses[0].Status.Status = ethpb.ValidatorStatus_ACTIVE
clientStream := mock.NewMockBeaconNodeValidator_WaitForActivationClient(ctrl)
clientStream := mock2.NewMockBeaconNodeValidator_WaitForActivationClient(ctrl)
client.EXPECT().WaitForActivation(
gomock.Any(),
&ethpb.ValidatorActivationRequest{
@ -365,7 +365,7 @@ func TestWaitMultipleActivation_LogsActivationEpochOK(t *testing.T) {
func TestWaitActivation_NotAllValidatorsActivatedOK(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
privKey, err := bls.RandKey()
require.NoError(t, err)
@ -383,7 +383,7 @@ func TestWaitActivation_NotAllValidatorsActivatedOK(t *testing.T) {
}
resp := generateMockStatusResponse([][]byte{pubKey[:]})
resp.Statuses[0].Status.Status = ethpb.ValidatorStatus_ACTIVE
clientStream := mock.NewMockBeaconNodeValidator_WaitForActivationClient(ctrl)
clientStream := mock2.NewMockBeaconNodeValidator_WaitForActivationClient(ctrl)
client.EXPECT().WaitForActivation(
gomock.Any(),
gomock.Any(),
@ -402,7 +402,7 @@ func TestWaitActivation_NotAllValidatorsActivatedOK(t *testing.T) {
func TestWaitSync_ContextCanceled(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
n := mock.NewMockNodeClient(ctrl)
n := mock2.NewMockNodeClient(ctrl)
v := validator{
node: n,
@ -422,7 +422,7 @@ func TestWaitSync_ContextCanceled(t *testing.T) {
func TestWaitSync_NotSyncing(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
n := mock.NewMockNodeClient(ctrl)
n := mock2.NewMockNodeClient(ctrl)
v := validator{
node: n,
@ -439,7 +439,7 @@ func TestWaitSync_NotSyncing(t *testing.T) {
func TestWaitSync_Syncing(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
n := mock.NewMockNodeClient(ctrl)
n := mock2.NewMockNodeClient(ctrl)
v := validator{
node: n,
@ -461,7 +461,7 @@ func TestWaitSync_Syncing(t *testing.T) {
func TestUpdateDuties_DoesNothingWhenNotEpochStart_AlreadyExistingAssignments(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
slot := types.Slot(1)
v := validator{
@ -487,7 +487,7 @@ func TestUpdateDuties_DoesNothingWhenNotEpochStart_AlreadyExistingAssignments(t
func TestUpdateDuties_ReturnsError(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
privKey, err := bls.RandKey()
require.NoError(t, err)
@ -524,7 +524,7 @@ func TestUpdateDuties_ReturnsError(t *testing.T) {
func TestUpdateDuties_OK(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
slot := params.BeaconConfig().SlotsPerEpoch
privKey, err := bls.RandKey()
@ -582,7 +582,7 @@ func TestUpdateDuties_OK_FilterBlacklistedPublicKeys(t *testing.T) {
hook := logTest.NewGlobal()
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
slot := params.BeaconConfig().SlotsPerEpoch
numValidators := 10
@ -836,7 +836,7 @@ func TestCheckAndLogValidatorStatus_OK(t *testing.T) {
hook := logTest.NewGlobal()
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
v := validator{
validatorClient: client,
duties: &ethpb.DutiesResponse{
@ -860,7 +860,7 @@ func TestCheckAndLogValidatorStatus_OK(t *testing.T) {
func TestAllValidatorsAreExited_AllExited(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
statuses := []*ethpb.ValidatorStatusResponse{
{Status: ethpb.ValidatorStatus_EXITED},
@ -881,7 +881,7 @@ func TestAllValidatorsAreExited_AllExited(t *testing.T) {
func TestAllValidatorsAreExited_NotAllExited(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
statuses := []*ethpb.ValidatorStatusResponse{
{Status: ethpb.ValidatorStatus_ACTIVE},
@ -902,7 +902,7 @@ func TestAllValidatorsAreExited_NotAllExited(t *testing.T) {
func TestAllValidatorsAreExited_PartialResult(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
statuses := []*ethpb.ValidatorStatusResponse{
{Status: ethpb.ValidatorStatus_EXITED},
@ -922,7 +922,7 @@ func TestAllValidatorsAreExited_PartialResult(t *testing.T) {
func TestAllValidatorsAreExited_NoKeys(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
v := validator{keyManager: genMockKeymanager(0), validatorClient: client}
exited, err := v.AllValidatorsAreExited(context.Background())
require.NoError(t, err)
@ -933,7 +933,7 @@ func TestAllValidatorsAreExited_NoKeys(t *testing.T) {
func TestAllValidatorsAreExited_CorrectRequest(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
// Create two different public keys
pubKey0 := [48]byte{1, 2, 3, 4}
@ -973,12 +973,12 @@ func TestAllValidatorsAreExited_CorrectRequest(t *testing.T) {
func TestService_ReceiveBlocks_NilBlock(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
valClient := mock.NewMockBeaconNodeValidatorClient(ctrl)
valClient := mock2.NewMockBeaconNodeValidatorClient(ctrl)
v := validator{
blockFeed: new(event.Feed),
validatorClient: valClient,
}
stream := mock.NewMockBeaconNodeValidatorAltair_StreamBlocksClient(ctrl)
stream := mock2.NewMockBeaconNodeValidatorAltair_StreamBlocksClient(ctrl)
ctx, cancel := context.WithCancel(context.Background())
valClient.EXPECT().StreamBlocksAltair(
gomock.Any(),
@ -1000,13 +1000,13 @@ func TestService_ReceiveBlocks_NilBlock(t *testing.T) {
func TestService_ReceiveBlocks_SetHighest(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
v := validator{
validatorClient: client,
blockFeed: new(event.Feed),
}
stream := mock.NewMockBeaconNodeValidatorAltair_StreamBlocksClient(ctrl)
stream := mock2.NewMockBeaconNodeValidatorAltair_StreamBlocksClient(ctrl)
ctx, cancel := context.WithCancel(context.Background())
client.EXPECT().StreamBlocksAltair(
gomock.Any(),
@ -1061,7 +1061,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
{
name: "no doppelganger",
validatorSetter: func(t *testing.T) *validator {
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
km := genMockKeymanager(10)
keys, err := km.FetchValidatingPublicKeys(context.Background())
assert.NoError(t, err)
@ -1093,7 +1093,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
{
name: "multiple doppelganger exists",
validatorSetter: func(t *testing.T) *validator {
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
km := genMockKeymanager(10)
keys, err := km.FetchValidatingPublicKeys(context.Background())
assert.NoError(t, err)
@ -1127,7 +1127,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
{
name: "single doppelganger exists",
validatorSetter: func(t *testing.T) *validator {
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
km := genMockKeymanager(10)
keys, err := km.FetchValidatingPublicKeys(context.Background())
assert.NoError(t, err)
@ -1161,7 +1161,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
{
name: "multiple attestations saved",
validatorSetter: func(t *testing.T) *validator {
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
km := genMockKeymanager(10)
keys, err := km.FetchValidatingPublicKeys(context.Background())
assert.NoError(t, err)
@ -1200,7 +1200,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
{
name: "no history exists",
validatorSetter: func(t *testing.T) *validator {
client := mock.NewMockBeaconNodeValidatorClient(ctrl)
client := mock2.NewMockBeaconNodeValidatorClient(ctrl)
// Use only 1 key for deterministic order.
km := genMockKeymanager(1)
keys, err := km.FetchValidatingPublicKeys(context.Background())

View File

@ -12,9 +12,9 @@ import (
"github.com/prysmaticlabs/prysm/crypto/bls"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/testing/mock"
slotutilmock "github.com/prysmaticlabs/prysm/time/slots/testing"
walletMock "github.com/prysmaticlabs/prysm/validator/accounts/testing"
"github.com/prysmaticlabs/prysm/validator/client/testutil"

View File

@ -37,10 +37,10 @@ go_test(
"//proto/prysm/v1alpha1/validator-client:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/event:go_default_library",
"//shared/mock:go_default_library",
"//shared/params:go_default_library",
"//shared/testutil/assert:go_default_library",
"//shared/testutil/require:go_default_library",
"//testing/mock:go_default_library",
"//validator/keymanager:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_sirupsen_logrus//hooks/test:go_default_library",

View File

@ -16,10 +16,10 @@ import (
validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/testing/mock"
"github.com/prysmaticlabs/prysm/validator/keymanager"
logTest "github.com/sirupsen/logrus/hooks/test"
)

View File

@ -36,10 +36,10 @@ go_library(
"//monitoring/tracing:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/validator-client:go_default_library",
"//runtime:go_default_library",
"//runtime/debug:go_default_library",
"//runtime/prereqs:go_default_library",
"//runtime/version:go_default_library",
"//shared:go_default_library",
"//shared/cmd:go_default_library",
"//shared/event:go_default_library",
"//shared/fileutil:go_default_library",

View File

@ -24,10 +24,10 @@ import (
tracing2 "github.com/prysmaticlabs/prysm/monitoring/tracing"
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
"github.com/prysmaticlabs/prysm/runtime"
"github.com/prysmaticlabs/prysm/runtime/debug"
"github.com/prysmaticlabs/prysm/runtime/prereqs"
"github.com/prysmaticlabs/prysm/runtime/version"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/shared/cmd"
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/fileutil"
@ -55,7 +55,7 @@ type ValidatorClient struct {
ctx context.Context
cancel context.CancelFunc
db *kv.Store
services *shared.ServiceRegistry // Lifecycle and service store.
services *runtime.ServiceRegistry // Lifecycle and service store.
lock sync.RWMutex
wallet *wallet.Wallet
walletInitialized *event.Feed
@ -84,7 +84,7 @@ func NewValidatorClient(cliCtx *cli.Context) (*ValidatorClient, error) {
// Warn if user's platform is not supported
prereqs.WarnIfPlatformNotSupported(cliCtx.Context)
registry := shared.NewServiceRegistry()
registry := runtime.NewServiceRegistry()
ctx, cancel := context.WithCancel(cliCtx.Context)
validatorClient := &ValidatorClient{
cliCtx: cliCtx,

View File

@ -46,6 +46,6 @@ pkg_deb(
package = "prysm-validator",
postinst = "postinst.sh",
preinst = "preinst.sh",
version_file = "//shared:version_file",
version_file = "//runtime:version_file",
visibility = ["//validator:__pkg__"],
)

View File

@ -86,9 +86,9 @@ go_test(
"//shared/bytesutil:go_default_library",
"//shared/event:go_default_library",
"//shared/fileutil:go_default_library",
"//shared/mock:go_default_library",
"//shared/testutil/assert:go_default_library",
"//shared/testutil/require:go_default_library",
"//testing/mock:go_default_library",
"//time:go_default_library",
"//validator/accounts:go_default_library",
"//validator/accounts/iface:go_default_library",

View File

@ -16,9 +16,9 @@ import (
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
mock2 "github.com/prysmaticlabs/prysm/testing/mock"
"github.com/prysmaticlabs/prysm/validator/accounts"
"github.com/prysmaticlabs/prysm/validator/accounts/iface"
"github.com/prysmaticlabs/prysm/validator/accounts/wallet"
@ -243,8 +243,8 @@ func TestServer_VoluntaryExit(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
ctx := context.Background()
mockValidatorClient := mock.NewMockBeaconNodeValidatorClient(ctrl)
mockNodeClient := mock.NewMockNodeClient(ctrl)
mockValidatorClient := mock2.NewMockBeaconNodeValidatorClient(ctrl)
mockNodeClient := mock2.NewMockNodeClient(ctrl)
mockValidatorClient.EXPECT().
ValidatorIndex(gomock.Any(), gomock.Any()).

View File

@ -10,16 +10,16 @@ import (
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
"github.com/prysmaticlabs/prysm/shared/mock"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
mock2 "github.com/prysmaticlabs/prysm/testing/mock"
"google.golang.org/grpc/metadata"
"google.golang.org/protobuf/types/known/timestamppb"
)
func TestGetBeaconStatus_NotConnected(t *testing.T) {
ctrl := gomock.NewController(t)
nodeClient := mock.NewMockNodeClient(ctrl)
nodeClient := mock2.NewMockNodeClient(ctrl)
nodeClient.EXPECT().GetSyncStatus(
gomock.Any(), // ctx
gomock.Any(),
@ -40,8 +40,8 @@ func TestGetBeaconStatus_NotConnected(t *testing.T) {
func TestGetBeaconStatus_OK(t *testing.T) {
ctrl := gomock.NewController(t)
nodeClient := mock.NewMockNodeClient(ctrl)
beaconChainClient := mock.NewMockBeaconChainClient(ctrl)
nodeClient := mock2.NewMockNodeClient(ctrl)
beaconChainClient := mock2.NewMockBeaconChainClient(ctrl)
nodeClient.EXPECT().GetSyncStatus(
gomock.Any(), // ctx
gomock.Any(),

View File

@ -17,7 +17,7 @@ go_library(
"//validator:__subpackages__",
],
deps = [
"//shared:go_default_library",
"//runtime:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
],
)