diff --git a/api/gateway/BUILD.bazel b/api/gateway/BUILD.bazel index d91982df4..54cc81040 100644 --- a/api/gateway/BUILD.bazel +++ b/api/gateway/BUILD.bazel @@ -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", diff --git a/api/gateway/gateway.go b/api/gateway/gateway.go index 21846fda6..335de5b65 100644 --- a/api/gateway/gateway.go +++ b/api/gateway/gateway.go @@ -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 { diff --git a/beacon-chain/core/BUILD.bazel b/beacon-chain/core/BUILD.bazel index 84e56053c..27e00fdf6 100644 --- a/beacon-chain/core/BUILD.bazel +++ b/beacon-chain/core/BUILD.bazel @@ -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__", diff --git a/beacon-chain/core/blocks/BUILD.bazel b/beacon-chain/core/blocks/BUILD.bazel index 76772389f..cd7f5e7cf 100644 --- a/beacon-chain/core/blocks/BUILD.bazel +++ b/beacon-chain/core/blocks/BUILD.bazel @@ -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", diff --git a/beacon-chain/core/blocks/signature.go b/beacon-chain/core/blocks/signature.go index 1c8099005..5cb6d1114 100644 --- a/beacon-chain/core/blocks/signature.go +++ b/beacon-chain/core/blocks/signature.go @@ -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 } diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index 67ed92d22..1f2f6c98c 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -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__", diff --git a/beacon-chain/interop-cold-start/BUILD.bazel b/beacon-chain/interop-cold-start/BUILD.bazel index 2fed6776c..e86f05cdc 100644 --- a/beacon-chain/interop-cold-start/BUILD.bazel +++ b/beacon-chain/interop-cold-start/BUILD.bazel @@ -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", diff --git a/beacon-chain/interop-cold-start/service.go b/beacon-chain/interop-cold-start/service.go index 39d9715c0..2acdc5823 100644 --- a/beacon-chain/interop-cold-start/service.go +++ b/beacon-chain/interop-cold-start/service.go @@ -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) diff --git a/beacon-chain/node/BUILD.bazel b/beacon-chain/node/BUILD.bazel index e6412b1cf..4d2bfec05 100644 --- a/beacon-chain/node/BUILD.bazel +++ b/beacon-chain/node/BUILD.bazel @@ -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", diff --git a/beacon-chain/node/node.go b/beacon-chain/node/node.go index a87c6b897..3a9a0a7a2 100644 --- a/beacon-chain/node/node.go +++ b/beacon-chain/node/node.go @@ -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{ diff --git a/beacon-chain/p2p/BUILD.bazel b/beacon-chain/p2p/BUILD.bazel index d307548ff..c58ac7160 100644 --- a/beacon-chain/p2p/BUILD.bazel +++ b/beacon-chain/p2p/BUILD.bazel @@ -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", diff --git a/beacon-chain/p2p/fork.go b/beacon-chain/p2p/fork.go index 29d9884d0..eb34d8419 100644 --- a/beacon-chain/p2p/fork.go +++ b/beacon-chain/p2p/fork.go @@ -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 } diff --git a/beacon-chain/p2p/fork_test.go b/beacon-chain/p2p/fork_test.go index 76aa18a99..3d8331ff7 100644 --- a/beacon-chain/p2p/fork_test.go +++ b/beacon-chain/p2p/fork_test.go @@ -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[:], diff --git a/beacon-chain/p2p/message_id.go b/beacon-chain/p2p/message_id.go index c9054f876..b1b7dc680 100644 --- a/beacon-chain/p2p/message_id.go +++ b/beacon-chain/p2p/message_id.go @@ -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. diff --git a/beacon-chain/p2p/message_id_test.go b/beacon-chain/p2p/message_id_test.go index 0ccc87e69..c2c257583 100644 --- a/beacon-chain/p2p/message_id_test.go +++ b/beacon-chain/p2p/message_id_test.go @@ -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'} diff --git a/beacon-chain/p2p/pubsub_filter.go b/beacon-chain/p2p/pubsub_filter.go index ee932bb23..af430d3aa 100644 --- a/beacon-chain/p2p/pubsub_filter.go +++ b/beacon-chain/p2p/pubsub_filter.go @@ -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 diff --git a/beacon-chain/p2p/pubsub_filter_test.go b/beacon-chain/p2p/pubsub_filter_test.go index 4fce59e32..83a5ff6a6 100644 --- a/beacon-chain/p2p/pubsub_filter_test.go +++ b/beacon-chain/p2p/pubsub_filter_test.go @@ -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 diff --git a/beacon-chain/p2p/service.go b/beacon-chain/p2p/service.go index be3591b1e..55c46dda0 100644 --- a/beacon-chain/p2p/service.go +++ b/beacon-chain/p2p/service.go @@ -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 diff --git a/beacon-chain/p2p/service_test.go b/beacon-chain/p2p/service_test.go index a403fa0b0..bda1b53cd 100644 --- a/beacon-chain/p2p/service_test.go +++ b/beacon-chain/p2p/service_test.go @@ -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. diff --git a/beacon-chain/package/BUILD.bazel b/beacon-chain/package/BUILD.bazel index 41be0a710..7d2621b0c 100644 --- a/beacon-chain/package/BUILD.bazel +++ b/beacon-chain/package/BUILD.bazel @@ -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__"], ) diff --git a/beacon-chain/rpc/eth/beacon/BUILD.bazel b/beacon-chain/rpc/eth/beacon/BUILD.bazel index 8b388b458..1ac052740 100644 --- a/beacon-chain/rpc/eth/beacon/BUILD.bazel +++ b/beacon-chain/rpc/eth/beacon/BUILD.bazel @@ -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", diff --git a/beacon-chain/rpc/eth/beacon/config.go b/beacon-chain/rpc/eth/beacon/config.go index 0e5f80d65..7e7eeff07 100644 --- a/beacon-chain/rpc/eth/beacon/config.go +++ b/beacon-chain/rpc/eth/beacon/config.go @@ -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 { diff --git a/beacon-chain/rpc/eth/events/BUILD.bazel b/beacon-chain/rpc/eth/events/BUILD.bazel index a90dce2f4..13800c69f 100644 --- a/beacon-chain/rpc/eth/events/BUILD.bazel +++ b/beacon-chain/rpc/eth/events/BUILD.bazel @@ -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", diff --git a/beacon-chain/rpc/eth/events/events_test.go b/beacon-chain/rpc/eth/events/events_test.go index e09270f07..54fa2f014 100644 --- a/beacon-chain/rpc/eth/events/events_test.go +++ b/beacon-chain/rpc/eth/events/events_test.go @@ -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" ) diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel index ec1c59eb9..913ee2de1 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel @@ -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", diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go index 36ac0a0f7..f0a0580b9 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go @@ -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" ) diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go index 137d71a15..5f90f45f1 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go @@ -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" ) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel index c4f9c99a5..22cb6bccb 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel @@ -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", diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/assignments_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/assignments_test.go index f1f401fe3..952c1412f 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/assignments_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/assignments_test.go @@ -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. diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/blocks_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/blocks_test.go index 84d71b75c..f43b22117 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/blocks_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/blocks_test.go @@ -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) { diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server.go index 0da6c8ce6..75da38c8a 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server.go @@ -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 } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go index e87c0e648..d4af20d93 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go @@ -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" ) diff --git a/beacon-chain/sync/BUILD.bazel b/beacon-chain/sync/BUILD.bazel index da21e4a29..0897804d8 100644 --- a/beacon-chain/sync/BUILD.bazel +++ b/beacon-chain/sync/BUILD.bazel @@ -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", diff --git a/beacon-chain/sync/fork_watcher.go b/beacon-chain/sync/fork_watcher.go index 9c081df64..b7b10eb15 100644 --- a/beacon-chain/sync/fork_watcher.go +++ b/beacon-chain/sync/fork_watcher.go @@ -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") } diff --git a/beacon-chain/sync/fork_watcher_test.go b/beacon-chain/sync/fork_watcher_test.go index 5e4f0bef3..780bc7a87 100644 --- a/beacon-chain/sync/fork_watcher_test.go +++ b/beacon-chain/sync/fork_watcher_test.go @@ -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)) diff --git a/beacon-chain/sync/initial-sync/BUILD.bazel b/beacon-chain/sync/initial-sync/BUILD.bazel index 775751371..d2b94cb17 100644 --- a/beacon-chain/sync/initial-sync/BUILD.bazel +++ b/beacon-chain/sync/initial-sync/BUILD.bazel @@ -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", diff --git a/beacon-chain/sync/initial-sync/service.go b/beacon-chain/sync/initial-sync/service.go index ca385c808..711fc2c34 100644 --- a/beacon-chain/sync/initial-sync/service.go +++ b/beacon-chain/sync/initial-sync/service.go @@ -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 { diff --git a/beacon-chain/sync/rpc_chunked_response.go b/beacon-chain/sync/rpc_chunked_response.go index d61bcf508..ac9d51b86 100644 --- a/beacon-chain/sync/rpc_chunked_response.go +++ b/beacon-chain/sync/rpc_chunked_response.go @@ -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 } diff --git a/beacon-chain/sync/rpc_metadata.go b/beacon-chain/sync/rpc_metadata.go index 196dbcdb7..4ee3f794e 100644 --- a/beacon-chain/sync/rpc_metadata.go +++ b/beacon-chain/sync/rpc_metadata.go @@ -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 } diff --git a/beacon-chain/sync/service.go b/beacon-chain/sync/service.go index 0e961fa53..7143539d5 100644 --- a/beacon-chain/sync/service.go +++ b/beacon-chain/sync/service.go @@ -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 diff --git a/beacon-chain/sync/subscriber.go b/beacon-chain/sync/subscriber.go index c23d54c39..8b71c5396 100644 --- a/beacon-chain/sync/subscriber.go +++ b/beacon-chain/sync/subscriber.go @@ -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 } diff --git a/beacon-chain/sync/subscriber_test.go b/beacon-chain/sync/subscriber_test.go index 9ab8486d3..e0b99cff8 100644 --- a/beacon-chain/sync/subscriber_test.go +++ b/beacon-chain/sync/subscriber_test.go @@ -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 { diff --git a/beacon-chain/sync/subscription_topic_handler_test.go b/beacon-chain/sync/subscription_topic_handler_test.go index fa8b226a8..7d3f9aa34 100644 --- a/beacon-chain/sync/subscription_topic_handler_test.go +++ b/beacon-chain/sync/subscription_topic_handler_test.go @@ -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{} diff --git a/monitoring/prometheus/BUILD.bazel b/monitoring/prometheus/BUILD.bazel index f1cd502d7..180f32efe 100644 --- a/monitoring/prometheus/BUILD.bazel +++ b/monitoring/prometheus/BUILD.bazel @@ -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", diff --git a/monitoring/prometheus/service.go b/monitoring/prometheus/service.go index 529b5b897..3bd1e0827 100644 --- a/monitoring/prometheus/service.go +++ b/monitoring/prometheus/service.go @@ -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() diff --git a/monitoring/prometheus/service_test.go b/monitoring/prometheus/service_test.go index 69ac1f31b..e7d6baa08 100644 --- a/monitoring/prometheus/service_test.go +++ b/monitoring/prometheus/service_test.go @@ -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") diff --git a/shared/p2putils/BUILD.bazel b/network/forks/BUILD.bazel similarity index 93% rename from shared/p2putils/BUILD.bazel rename to network/forks/BUILD.bazel index 8e392e94c..a5b1d4910 100644 --- a/shared/p2putils/BUILD.bazel +++ b/network/forks/BUILD.bazel @@ -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", diff --git a/shared/p2putils/fork.go b/network/forks/fork.go similarity index 98% rename from shared/p2putils/fork.go rename to network/forks/fork.go index 38fe655ae..969037fe5 100644 --- a/shared/p2putils/fork.go +++ b/network/forks/fork.go @@ -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" diff --git a/shared/p2putils/fork_test.go b/network/forks/fork_test.go similarity index 99% rename from shared/p2putils/fork_test.go rename to network/forks/fork_test.go index a8428f9fe..57115de2e 100644 --- a/shared/p2putils/fork_test.go +++ b/network/forks/fork_test.go @@ -1,4 +1,4 @@ -package p2putils +package forks import ( "math" diff --git a/nogo_config.json b/nogo_config.json index 37b76c75a..1dbc8cdef 100644 --- a/nogo_config.json +++ b/nogo_config.json @@ -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" } }, diff --git a/shared/BUILD.bazel b/runtime/BUILD.bazel similarity index 90% rename from shared/BUILD.bazel rename to runtime/BUILD.bazel index 786e3babc..f0814742a 100644 --- a/shared/BUILD.bazel +++ b/runtime/BUILD.bazel @@ -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 = [ diff --git a/shared/messagehandler/BUILD.bazel b/runtime/messagehandler/BUILD.bazel similarity index 90% rename from shared/messagehandler/BUILD.bazel rename to runtime/messagehandler/BUILD.bazel index 64214fc79..945ac386d 100644 --- a/shared/messagehandler/BUILD.bazel +++ b/runtime/messagehandler/BUILD.bazel @@ -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", diff --git a/shared/messagehandler/messagehandler.go b/runtime/messagehandler/messagehandler.go similarity index 100% rename from shared/messagehandler/messagehandler.go rename to runtime/messagehandler/messagehandler.go diff --git a/shared/messagehandler/messagehandler_test.go b/runtime/messagehandler/messagehandler_test.go similarity index 94% rename from shared/messagehandler/messagehandler_test.go rename to runtime/messagehandler/messagehandler_test.go index c0675aaad..9733b20ad 100644 --- a/shared/messagehandler/messagehandler_test.go +++ b/runtime/messagehandler/messagehandler_test.go @@ -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" ) diff --git a/shared/service_registry.go b/runtime/service_registry.go similarity index 99% rename from shared/service_registry.go rename to runtime/service_registry.go index 66ddf8f91..5696d6060 100644 --- a/shared/service_registry.go +++ b/runtime/service_registry.go @@ -1,6 +1,6 @@ // Package shared includes useful utilities globally accessible in // the Prysm monorepo. -package shared +package runtime import ( "fmt" diff --git a/shared/service_registry_test.go b/runtime/service_registry_test.go similarity index 99% rename from shared/service_registry_test.go rename to runtime/service_registry_test.go index b7359a157..6e23ffec9 100644 --- a/shared/service_registry_test.go +++ b/runtime/service_registry_test.go @@ -1,4 +1,4 @@ -package shared +package runtime import ( "errors" diff --git a/shared/httputils/BUILD.bazel b/shared/httputils/BUILD.bazel deleted file mode 100644 index 45ca140bf..000000000 --- a/shared/httputils/BUILD.bazel +++ /dev/null @@ -1 +0,0 @@ -load("@prysm//tools/go:def.bzl", "go_library", "go_test") diff --git a/shared/iputils/BUILD.bazel b/shared/iputils/BUILD.bazel deleted file mode 100644 index 45ca140bf..000000000 --- a/shared/iputils/BUILD.bazel +++ /dev/null @@ -1 +0,0 @@ -load("@prysm//tools/go:def.bzl", "go_library", "go_test") diff --git a/testing/endtoend/evaluators/BUILD.bazel b/testing/endtoend/evaluators/BUILD.bazel index 9d3ed842e..509dbe4a5 100644 --- a/testing/endtoend/evaluators/BUILD.bazel +++ b/testing/endtoend/evaluators/BUILD.bazel @@ -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", diff --git a/testing/endtoend/evaluators/metrics.go b/testing/endtoend/evaluators/metrics.go index 95dedb30f..8cd274314 100644 --- a/testing/endtoend/evaluators/metrics.go +++ b/testing/endtoend/evaluators/metrics.go @@ -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 } diff --git a/shared/mock/BUILD.bazel b/testing/mock/BUILD.bazel similarity index 95% rename from shared/mock/BUILD.bazel rename to testing/mock/BUILD.bazel index e27f9ca6c..224159376 100644 --- a/shared/mock/BUILD.bazel +++ b/testing/mock/BUILD.bazel @@ -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", diff --git a/shared/mock/beacon_altair_validator_client_mock.go b/testing/mock/beacon_altair_validator_client_mock.go similarity index 100% rename from shared/mock/beacon_altair_validator_client_mock.go rename to testing/mock/beacon_altair_validator_client_mock.go diff --git a/shared/mock/beacon_altair_validator_server_mock.go b/testing/mock/beacon_altair_validator_server_mock.go similarity index 100% rename from shared/mock/beacon_altair_validator_server_mock.go rename to testing/mock/beacon_altair_validator_server_mock.go diff --git a/shared/mock/beacon_chain_altair_client_mock.go b/testing/mock/beacon_chain_altair_client_mock.go similarity index 100% rename from shared/mock/beacon_chain_altair_client_mock.go rename to testing/mock/beacon_chain_altair_client_mock.go diff --git a/shared/mock/beacon_chain_altair_service_mock.go b/testing/mock/beacon_chain_altair_service_mock.go similarity index 100% rename from shared/mock/beacon_chain_altair_service_mock.go rename to testing/mock/beacon_chain_altair_service_mock.go diff --git a/shared/mock/beacon_chain_service_mock.go b/testing/mock/beacon_chain_service_mock.go similarity index 100% rename from shared/mock/beacon_chain_service_mock.go rename to testing/mock/beacon_chain_service_mock.go diff --git a/shared/mock/beacon_service_mock.go b/testing/mock/beacon_service_mock.go similarity index 100% rename from shared/mock/beacon_service_mock.go rename to testing/mock/beacon_service_mock.go diff --git a/shared/mock/beacon_validator_client_mock.go b/testing/mock/beacon_validator_client_mock.go similarity index 100% rename from shared/mock/beacon_validator_client_mock.go rename to testing/mock/beacon_validator_client_mock.go diff --git a/shared/mock/beacon_validator_server_mock.go b/testing/mock/beacon_validator_server_mock.go similarity index 100% rename from shared/mock/beacon_validator_server_mock.go rename to testing/mock/beacon_validator_server_mock.go diff --git a/shared/mock/event_service_mock.go b/testing/mock/event_service_mock.go similarity index 100% rename from shared/mock/event_service_mock.go rename to testing/mock/event_service_mock.go diff --git a/shared/mock/keymanager_mock.go b/testing/mock/keymanager_mock.go similarity index 100% rename from shared/mock/keymanager_mock.go rename to testing/mock/keymanager_mock.go diff --git a/shared/mock/node_service_mock.go b/testing/mock/node_service_mock.go similarity index 100% rename from shared/mock/node_service_mock.go rename to testing/mock/node_service_mock.go diff --git a/validator/accounts/BUILD.bazel b/validator/accounts/BUILD.bazel index 1a6f44013..0d9338b91 100644 --- a/validator/accounts/BUILD.bazel +++ b/validator/accounts/BUILD.bazel @@ -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", diff --git a/validator/accounts/accounts_exit_test.go b/validator/accounts/accounts_exit_test.go index a3326e8fb..b321d8401 100644 --- a/validator/accounts/accounts_exit_test.go +++ b/validator/accounts/accounts_exit_test.go @@ -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()). diff --git a/validator/accounts/accounts_list_test.go b/validator/accounts/accounts_list_test.go index 5515689fd..e11d1567d 100644 --- a/validator/accounts/accounts_list_test.go +++ b/validator/accounts/accounts_list_test.go @@ -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" diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index d31ac9391..e43187e48 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -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", diff --git a/validator/client/key_reload_test.go b/validator/client/key_reload_test.go index 93c2ec1f5..c45396401 100644 --- a/validator/client/key_reload_test.go +++ b/validator/client/key_reload_test.go @@ -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" ) diff --git a/validator/client/propose_test.go b/validator/client/propose_test.go index 350d3364c..a344af819 100644 --- a/validator/client/propose_test.go +++ b/validator/client/propose_test.go @@ -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(), ðpb.ValidatorIndexRequest{PublicKey: pubKey[:]}). diff --git a/validator/client/service_test.go b/validator/client/service_test.go index 2ceb770c9..0a2822fd1 100644 --- a/validator/client/service_test.go +++ b/validator/client/service_test.go @@ -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) diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index 72396d4ef..95e0ae86a 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -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(), ðpb.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: ðpb.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()) diff --git a/validator/client/wait_for_activation_test.go b/validator/client/wait_for_activation_test.go index d08db8ae9..12e65feb6 100644 --- a/validator/client/wait_for_activation_test.go +++ b/validator/client/wait_for_activation_test.go @@ -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" diff --git a/validator/keymanager/remote/BUILD.bazel b/validator/keymanager/remote/BUILD.bazel index 042386761..bf9566c31 100644 --- a/validator/keymanager/remote/BUILD.bazel +++ b/validator/keymanager/remote/BUILD.bazel @@ -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", diff --git a/validator/keymanager/remote/keymanager_test.go b/validator/keymanager/remote/keymanager_test.go index 039f2f085..b7dba6a80 100644 --- a/validator/keymanager/remote/keymanager_test.go +++ b/validator/keymanager/remote/keymanager_test.go @@ -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" ) diff --git a/validator/node/BUILD.bazel b/validator/node/BUILD.bazel index 489e9d1a6..fd6b413f3 100644 --- a/validator/node/BUILD.bazel +++ b/validator/node/BUILD.bazel @@ -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", diff --git a/validator/node/node.go b/validator/node/node.go index 988c1249f..073d03383 100644 --- a/validator/node/node.go +++ b/validator/node/node.go @@ -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, diff --git a/validator/package/BUILD.bazel b/validator/package/BUILD.bazel index bded1a8ca..52e66cb60 100644 --- a/validator/package/BUILD.bazel +++ b/validator/package/BUILD.bazel @@ -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__"], ) diff --git a/validator/rpc/BUILD.bazel b/validator/rpc/BUILD.bazel index ae57444c0..5e362bc95 100644 --- a/validator/rpc/BUILD.bazel +++ b/validator/rpc/BUILD.bazel @@ -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", diff --git a/validator/rpc/accounts_test.go b/validator/rpc/accounts_test.go index 7b63bfc2d..f3f124583 100644 --- a/validator/rpc/accounts_test.go +++ b/validator/rpc/accounts_test.go @@ -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()). diff --git a/validator/rpc/beacon_test.go b/validator/rpc/beacon_test.go index 1d08a9651..5f0f0fda2 100644 --- a/validator/rpc/beacon_test.go +++ b/validator/rpc/beacon_test.go @@ -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(), diff --git a/validator/web/BUILD.bazel b/validator/web/BUILD.bazel index bcc58313e..3344f8067 100644 --- a/validator/web/BUILD.bazel +++ b/validator/web/BUILD.bazel @@ -17,7 +17,7 @@ go_library( "//validator:__subpackages__", ], deps = [ - "//shared:go_default_library", + "//runtime:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", ], )