From 2ba29a3cfc88ce98bb28c2eea32c937e7e9c69ab Mon Sep 17 00:00:00 2001 From: terence tsao Date: Mon, 20 Sep 2021 09:17:03 -0700 Subject: [PATCH] Move block and attestation to proto v1alpha1 folder (#9618) * Add block and attestation to container pkg * Move aggregation into attestation * Update attestation_test.go * Move them to proto * Gazelle * fix cycle Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Raul Jordan --- beacon-chain/blockchain/BUILD.bazel | 2 +- .../blockchain/process_attestation.go | 6 ++--- beacon-chain/blockchain/process_block.go | 4 +-- .../blockchain/process_block_helpers.go | 4 +-- beacon-chain/blockchain/process_block_test.go | 4 +-- beacon-chain/core/BUILD.bazel | 2 ++ beacon-chain/core/altair/BUILD.bazel | 4 +-- beacon-chain/core/altair/attestation.go | 6 ++--- beacon-chain/core/altair/attestation_test.go | 6 ++--- beacon-chain/core/altair/upgrade.go | 4 +-- beacon-chain/core/altair/upgrade_test.go | 4 +-- beacon-chain/core/blocks/BUILD.bazel | 8 +++--- beacon-chain/core/blocks/attestation.go | 12 ++++----- beacon-chain/core/blocks/attestation_test.go | 22 +++++++-------- beacon-chain/core/blocks/attester_slashing.go | 4 +-- beacon-chain/core/blocks/signature.go | 6 ++--- beacon-chain/core/epoch/BUILD.bazel | 2 +- beacon-chain/core/epoch/epoch_processing.go | 4 +-- .../core/epoch/precompute/BUILD.bazel | 4 +-- .../core/epoch/precompute/attestation.go | 4 +-- .../core/epoch/precompute/attestation_test.go | 6 ++--- beacon-chain/core/helpers/BUILD.bazel | 2 ++ beacon-chain/core/transition/BUILD.bazel | 2 +- .../core/transition/transition_test.go | 4 +-- .../operations/attestations/BUILD.bazel | 4 +-- .../operations/attestations/kv/BUILD.bazel | 2 +- .../operations/attestations/kv/aggregated.go | 2 +- .../attestations/prepare_forkchoice.go | 2 +- .../attestations/prepare_forkchoice_test.go | 2 +- .../rpc/prysm/v1alpha1/beacon/BUILD.bazel | 8 +++--- .../rpc/prysm/v1alpha1/beacon/attestations.go | 8 +++--- .../v1alpha1/beacon/attestations_test.go | 12 ++++----- .../rpc/prysm/v1alpha1/debug/BUILD.bazel | 2 +- .../rpc/prysm/v1alpha1/debug/block.go | 4 +-- .../rpc/prysm/v1alpha1/validator/BUILD.bazel | 10 +++---- .../v1alpha1/validator/aggregator_test.go | 8 +++--- .../rpc/prysm/v1alpha1/validator/proposer.go | 4 +-- .../validator/proposer_attestations.go | 2 +- .../prysm/v1alpha1/validator/proposer_test.go | 6 ++--- .../validator/proposer_utils_bench_test.go | 2 +- beacon-chain/sync/BUILD.bazel | 2 +- .../sync/pending_attestations_queue_test.go | 8 +++--- .../sync/validate_aggregate_proof_test.go | 12 ++++----- .../prysm/v1alpha1/attestation}/BUILD.bazel | 2 +- .../attestation}/aggregation/BUILD.bazel | 4 +-- .../attestation}/aggregation/aggregation.go | 0 .../aggregation/attestations/BUILD.bazel | 8 +++--- .../aggregation/attestations/attestations.go | 2 +- .../attestations/attestations_bench_test.go | 2 +- .../attestations/attestations_test.go | 4 +-- .../aggregation/attestations/maxcover.go | 2 +- .../aggregation/attestations/maxcover_test.go | 2 +- .../aggregation/attestations/naive.go | 0 .../attestation}/aggregation/maxcover.go | 0 .../aggregation/maxcover_bench_test.go | 2 +- .../attestation}/aggregation/maxcover_test.go | 2 +- .../aggregation/sync_contribution/BUILD.bazel | 8 +++--- .../sync_contribution/contribution.go | 2 +- .../aggregation/sync_contribution/naive.go | 2 +- .../sync_contribution/naive_test.go | 4 +-- .../aggregation/testing/BUILD.bazel | 2 +- .../aggregation/testing/bitlistutils.go | 0 .../attestation}/attestation_utils.go | 2 +- .../attestation}/attestation_utils_test.go | 20 +++++++------- proto/prysm/v1alpha1/block/BUILD.bazel | 22 +++++++++++++-- .../prysm/v1alpha1/block}/block_utils.go | 7 +++-- .../prysm/v1alpha1/block}/block_utils_test.go | 15 ++++++----- shared/blockutil/BUILD.bazel | 27 ------------------- validator/client/BUILD.bazel | 1 - validator/client/propose_protect.go | 17 ++++++------ 70 files changed, 189 insertions(+), 196 deletions(-) rename {shared/attestationutil => proto/prysm/v1alpha1/attestation}/BUILD.bazel (93%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/BUILD.bazel (81%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/aggregation.go (100%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/attestations/BUILD.bazel (78%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/attestations/attestations.go (97%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/attestations/attestations_bench_test.go (96%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/attestations/attestations_test.go (98%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/attestations/maxcover.go (99%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/attestations/maxcover_test.go (99%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/attestations/naive.go (100%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/maxcover.go (100%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/maxcover_bench_test.go (95%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/maxcover_test.go (99%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/sync_contribution/BUILD.bazel (71%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/sync_contribution/contribution.go (95%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/sync_contribution/naive.go (97%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/sync_contribution/naive_test.go (96%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/testing/BUILD.bazel (81%) rename {shared => proto/prysm/v1alpha1/attestation}/aggregation/testing/bitlistutils.go (100%) rename {shared/attestationutil => proto/prysm/v1alpha1/attestation}/attestation_utils.go (99%) rename {shared/attestationutil => proto/prysm/v1alpha1/attestation}/attestation_utils_test.go (92%) rename {shared/blockutil => proto/prysm/v1alpha1/block}/block_utils.go (88%) rename {shared/blockutil => proto/prysm/v1alpha1/block}/block_utils_test.go (93%) delete mode 100644 shared/blockutil/BUILD.bazel diff --git a/beacon-chain/blockchain/BUILD.bazel b/beacon-chain/blockchain/BUILD.bazel index 0b4b56f7c..acc29957d 100644 --- a/beacon-chain/blockchain/BUILD.bazel +++ b/beacon-chain/blockchain/BUILD.bazel @@ -52,9 +52,9 @@ go_library( "//monitoring/tracing:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", "//runtime/version:go_default_library", - "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "//time:go_default_library", diff --git a/beacon-chain/blockchain/process_attestation.go b/beacon-chain/blockchain/process_attestation.go index 747abe1ee..80744bf82 100644 --- a/beacon-chain/blockchain/process_attestation.go +++ b/beacon-chain/blockchain/process_attestation.go @@ -7,7 +7,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/attestationutil" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/time" @@ -84,11 +84,11 @@ func (s *Service) onAttestation(ctx context.Context, a *ethpb.Attestation) error if err != nil { return err } - indexedAtt, err := attestationutil.ConvertToIndexed(ctx, a, committee) + indexedAtt, err := attestation.ConvertToIndexed(ctx, a, committee) if err != nil { return err } - if err := attestationutil.IsValidAttestationIndices(ctx, indexedAtt); err != nil { + if err := attestation.IsValidAttestationIndices(ctx, indexedAtt); err != nil { return err } diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index 9a1616065..14804e160 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -16,8 +16,8 @@ import ( "github.com/prysmaticlabs/prysm/crypto/bls" ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" @@ -376,7 +376,7 @@ func (s *Service) insertBlockAndAttestationsToForkChoiceStore(ctx context.Contex if err != nil { return err } - indices, err := attestationutil.AttestingIndices(a.AggregationBits, committee) + indices, err := attestation.AttestingIndices(a.AggregationBits, committee) if err != nil { return err } diff --git a/beacon-chain/blockchain/process_block_helpers.go b/beacon-chain/blockchain/process_block_helpers.go index a59568c41..874f5ce6e 100644 --- a/beacon-chain/blockchain/process_block_helpers.go +++ b/beacon-chain/blockchain/process_block_helpers.go @@ -13,8 +13,8 @@ import ( "github.com/prysmaticlabs/prysm/config/features" "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" @@ -346,7 +346,7 @@ func (s *Service) ancestorByDB(ctx context.Context, r [32]byte, slot types.Slot) // store.justified_checkpoint = state.current_justified_checkpoint func (s *Service) finalizedImpliesNewJustified(ctx context.Context, state state.BeaconState) error { // Update justified if it's different than the one cached in the store. - if !attestationutil.CheckPointIsEqual(s.justifiedCheckpt, state.CurrentJustifiedCheckpoint()) { + if !attestation.CheckPointIsEqual(s.justifiedCheckpt, state.CurrentJustifiedCheckpoint()) { if state.CurrentJustifiedCheckpoint().Epoch > s.justifiedCheckpt.Epoch { s.justifiedCheckpt = state.CurrentJustifiedCheckpoint() return s.cacheJustifiedStateBalances(ctx, bytesutil.ToBytes32(s.justifiedCheckpt.Root)) diff --git a/beacon-chain/blockchain/process_block_test.go b/beacon-chain/blockchain/process_block_test.go index fbd954e02..0dd9924be 100644 --- a/beacon-chain/blockchain/process_block_test.go +++ b/beacon-chain/blockchain/process_block_test.go @@ -22,9 +22,9 @@ import ( v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" "github.com/prysmaticlabs/prysm/config/features" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -790,7 +790,7 @@ func TestFinalizedImpliesNewJustified(t *testing.T) { } require.NoError(t, service.finalizedImpliesNewJustified(ctx, beaconState)) - assert.Equal(t, true, attestationutil.CheckPointIsEqual(test.want, service.justifiedCheckpt), "Did not get wanted check point") + assert.Equal(t, true, attestation.CheckPointIsEqual(test.want, service.justifiedCheckpt), "Did not get wanted check point") } } diff --git a/beacon-chain/core/BUILD.bazel b/beacon-chain/core/BUILD.bazel index 27e00fdf6..83e266ff5 100644 --- a/beacon-chain/core/BUILD.bazel +++ b/beacon-chain/core/BUILD.bazel @@ -6,7 +6,9 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/core", visibility = [ "//beacon-chain:__subpackages__", + "//fuzz:__pkg__", "//network/forks:__pkg__", + "//proto/prysm/v1alpha1/attestation:__pkg__", "//shared/attestationutil:__pkg__", "//shared/depositutil:__pkg__", "//shared/interop:__pkg__", diff --git a/beacon-chain/core/altair/BUILD.bazel b/beacon-chain/core/altair/BUILD.bazel index 751e7d6c1..fde3f94f4 100644 --- a/beacon-chain/core/altair/BUILD.bazel +++ b/beacon-chain/core/altair/BUILD.bazel @@ -33,8 +33,8 @@ go_library( "//crypto/hash:go_default_library", "//math:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", - "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "@com_github_pkg_errors//:go_default_library", @@ -70,8 +70,8 @@ go_test( "//crypto/bls:go_default_library", "//math:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", - "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", diff --git a/beacon-chain/core/altair/attestation.go b/beacon-chain/core/altair/attestation.go index 1e6797336..405001a99 100644 --- a/beacon-chain/core/altair/attestation.go +++ b/beacon-chain/core/altair/attestation.go @@ -12,8 +12,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" ) @@ -69,7 +69,7 @@ func ProcessAttestationNoVerifySignature( if err != nil { return nil, err } - indices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + indices, err := attestation.AttestingIndices(att.AggregationBits, committee) if err != nil { return nil, err } @@ -283,7 +283,7 @@ func AttestationParticipationFlagIndices(beaconState state.BeaconStateAltair, da // is_matching_target = is_matching_source and data.target.root == get_block_root(state, data.target.epoch) // is_matching_head = is_matching_target and data.beacon_block_root == get_block_root_at_slot(state, data.slot) func MatchingStatus(beaconState state.BeaconState, data *ethpb.AttestationData, cp *ethpb.Checkpoint) (matchedSrc, matchedTgt, matchedHead bool, err error) { - matchedSrc = attestationutil.CheckPointIsEqual(data.Source, cp) + matchedSrc = attestation.CheckPointIsEqual(data.Source, cp) r, err := helpers.BlockRoot(beaconState, data.Target.Epoch) if err != nil { diff --git a/beacon-chain/core/altair/attestation_test.go b/beacon-chain/core/altair/attestation_test.go index 600670c71..3f2223cb2 100644 --- a/beacon-chain/core/altair/attestation_test.go +++ b/beacon-chain/core/altair/attestation_test.go @@ -16,8 +16,8 @@ import ( "github.com/prysmaticlabs/prysm/crypto/bls" "github.com/prysmaticlabs/prysm/math" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -213,7 +213,7 @@ func TestProcessAttestations_OK(t *testing.T) { committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex) require.NoError(t, err) - attestingIndices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(att.AggregationBits, committee) require.NoError(t, err) sigs := make([]bls.Signature, len(attestingIndices)) for i, indice := range attestingIndices { @@ -271,7 +271,7 @@ func TestProcessAttestationNoVerify_SourceTargetHead(t *testing.T) { committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex) require.NoError(t, err) - indices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + indices, err := attestation.AttestingIndices(att.AggregationBits, committee) require.NoError(t, err) for _, index := range indices { require.Equal(t, true, altair.HasValidatorFlag(p[index], params.BeaconConfig().TimelyHeadFlagIndex)) diff --git a/beacon-chain/core/altair/upgrade.go b/beacon-chain/core/altair/upgrade.go index d105cc7a0..268ffe6f6 100644 --- a/beacon-chain/core/altair/upgrade.go +++ b/beacon-chain/core/altair/upgrade.go @@ -8,7 +8,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" statealtair "github.com/prysmaticlabs/prysm/beacon-chain/state/v2" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/attestationutil" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -152,7 +152,7 @@ func TranslateParticipation(state *statealtair.BeaconState, atts []*ethpb.Pendin if err != nil { return nil, err } - indices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + indices, err := attestation.AttestingIndices(att.AggregationBits, committee) if err != nil { return nil, err } diff --git a/beacon-chain/core/altair/upgrade_test.go b/beacon-chain/core/altair/upgrade_test.go index 922720708..570b8ca6d 100644 --- a/beacon-chain/core/altair/upgrade_test.go +++ b/beacon-chain/core/altair/upgrade_test.go @@ -12,7 +12,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" stateAltair "github.com/prysmaticlabs/prysm/beacon-chain/state/v2" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/attestationutil" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -58,7 +58,7 @@ func TestTranslateParticipation(t *testing.T) { committee, err := helpers.BeaconCommitteeFromState(st, pendingAtts[0].Data.Slot, pendingAtts[0].Data.CommitteeIndex) require.NoError(t, err) - indices, err := attestationutil.AttestingIndices(pendingAtts[0].AggregationBits, committee) + indices, err := attestation.AttestingIndices(pendingAtts[0].AggregationBits, committee) require.NoError(t, err) for _, index := range indices { require.Equal(t, true, altair.HasValidatorFlag(participation[index], params.BeaconConfig().TimelyHeadFlagIndex)) diff --git a/beacon-chain/core/blocks/BUILD.bazel b/beacon-chain/core/blocks/BUILD.bazel index c5083fbed..da1896a0f 100644 --- a/beacon-chain/core/blocks/BUILD.bazel +++ b/beacon-chain/core/blocks/BUILD.bazel @@ -35,9 +35,9 @@ go_library( "//math:go_default_library", "//network/forks:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", "//runtime/version:go_default_library", - "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/depositutil:go_default_library", "//shared/params:go_default_library", @@ -82,10 +82,10 @@ go_test( "//container/trie:go_default_library", "//crypto/bls:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/attestations:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", - "//shared/aggregation:go_default_library", - "//shared/aggregation/attestations:go_default_library", - "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", diff --git a/beacon-chain/core/blocks/attestation.go b/beacon-chain/core/blocks/attestation.go index d51eefcaa..bc83cb664 100644 --- a/beacon-chain/core/blocks/attestation.go +++ b/beacon-chain/core/blocks/attestation.go @@ -11,8 +11,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" ) @@ -114,12 +114,12 @@ func VerifyAttestationNoVerifySignature( if err != nil { return err } - indexedAtt, err := attestationutil.ConvertToIndexed(ctx, att, committee) + indexedAtt, err := attestation.ConvertToIndexed(ctx, att, committee) if err != nil { return err } - return attestationutil.IsValidAttestationIndices(ctx, indexedAtt) + return attestation.IsValidAttestationIndices(ctx, indexedAtt) } // ProcessAttestationNoVerifySignature processes the attestation without verifying the attestation signature. This @@ -173,7 +173,7 @@ func VerifyAttestationSignature(ctx context.Context, beaconState state.ReadOnlyB if err != nil { return err } - indexedAtt, err := attestationutil.ConvertToIndexed(ctx, att, committee) + indexedAtt, err := attestation.ConvertToIndexed(ctx, att, committee) if err != nil { return err } @@ -200,7 +200,7 @@ func VerifyIndexedAttestation(ctx context.Context, beaconState state.ReadOnlyBea ctx, span := trace.StartSpan(ctx, "core.VerifyIndexedAttestation") defer span.End() - if err := attestationutil.IsValidAttestationIndices(ctx, indexedAtt); err != nil { + if err := attestation.IsValidAttestationIndices(ctx, indexedAtt); err != nil { return err } domain, err := helpers.Domain( @@ -222,5 +222,5 @@ func VerifyIndexedAttestation(ctx context.Context, beaconState state.ReadOnlyBea } pubkeys = append(pubkeys, pk) } - return attestationutil.VerifyIndexedAttestationSig(ctx, indexedAtt, pubkeys, domain) + return attestation.VerifyIndexedAttestationSig(ctx, indexedAtt, pubkeys, domain) } diff --git a/beacon-chain/core/blocks/attestation_test.go b/beacon-chain/core/blocks/attestation_test.go index baee0977b..2d2a6a0fe 100644 --- a/beacon-chain/core/blocks/attestation_test.go +++ b/beacon-chain/core/blocks/attestation_test.go @@ -11,9 +11,9 @@ import ( v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/aggregation" - attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" - "github.com/prysmaticlabs/prysm/shared/attestationutil" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation" + attaggregation "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -42,7 +42,7 @@ func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) { committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex) require.NoError(t, err) - attestingIndices1, err := attestationutil.AttestingIndices(att1.AggregationBits, committee) + attestingIndices1, err := attestation.AttestingIndices(att1.AggregationBits, committee) require.NoError(t, err) sigs := make([]bls.Signature, len(attestingIndices1)) for i, indice := range attestingIndices1 { @@ -64,7 +64,7 @@ func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) { committee, err = helpers.BeaconCommitteeFromState(beaconState, att2.Data.Slot, att2.Data.CommitteeIndex) require.NoError(t, err) - attestingIndices2, err := attestationutil.AttestingIndices(att2.AggregationBits, committee) + attestingIndices2, err := attestation.AttestingIndices(att2.AggregationBits, committee) require.NoError(t, err) sigs = make([]bls.Signature, len(attestingIndices2)) for i, indice := range attestingIndices2 { @@ -216,20 +216,20 @@ func TestConvertToIndexed_OK(t *testing.T) { var sig [96]byte copy(sig[:], "signed") - attestation := testutil.HydrateAttestation(ðpb.Attestation{ + att := testutil.HydrateAttestation(ðpb.Attestation{ Signature: sig[:], }) for _, tt := range tests { - attestation.AggregationBits = tt.aggregationBitfield + att.AggregationBits = tt.aggregationBitfield wanted := ðpb.IndexedAttestation{ AttestingIndices: tt.wantedAttestingIndices, - Data: attestation.Data, - Signature: attestation.Signature, + Data: att.Data, + Signature: att.Signature, } - committee, err := helpers.BeaconCommitteeFromState(state, attestation.Data.Slot, attestation.Data.CommitteeIndex) + committee, err := helpers.BeaconCommitteeFromState(state, att.Data.Slot, att.Data.CommitteeIndex) require.NoError(t, err) - ia, err := attestationutil.ConvertToIndexed(context.Background(), attestation, committee) + ia, err := attestation.ConvertToIndexed(context.Background(), att, committee) require.NoError(t, err) assert.DeepEqual(t, wanted, ia, "Convert attestation to indexed attestation didn't result as wanted") } diff --git a/beacon-chain/core/blocks/attester_slashing.go b/beacon-chain/core/blocks/attester_slashing.go index c35b7f5ee..25f7b7380 100644 --- a/beacon-chain/core/blocks/attester_slashing.go +++ b/beacon-chain/core/blocks/attester_slashing.go @@ -11,8 +11,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/container/slice" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/runtime/version" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/slashutil" ) @@ -124,7 +124,7 @@ func IsSlashableAttestationData(data1, data2 *ethpb.AttestationData) bool { if data1 == nil || data2 == nil || data1.Target == nil || data2.Target == nil || data1.Source == nil || data2.Source == nil { return false } - isDoubleVote := !attestationutil.AttDataIsEqual(data1, data2) && data1.Target.Epoch == data2.Target.Epoch + isDoubleVote := !attestation.AttDataIsEqual(data1, data2) && data1.Target.Epoch == data2.Target.Epoch att1 := ðpb.IndexedAttestation{Data: data1} att2 := ðpb.IndexedAttestation{Data: data2} // Check if att1 is surrounding att2. diff --git a/beacon-chain/core/blocks/signature.go b/beacon-chain/core/blocks/signature.go index 5cb6d1114..e277765cb 100644 --- a/beacon-chain/core/blocks/signature.go +++ b/beacon-chain/core/blocks/signature.go @@ -12,8 +12,8 @@ import ( "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/attestation" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -173,11 +173,11 @@ func createAttestationSignatureSet( if err != nil { return nil, err } - ia, err := attestationutil.ConvertToIndexed(ctx, a, c) + ia, err := attestation.ConvertToIndexed(ctx, a, c) if err != nil { return nil, err } - if err := attestationutil.IsValidAttestationIndices(ctx, ia); err != nil { + if err := attestation.IsValidAttestationIndices(ctx, ia); err != nil { return nil, err } indices := ia.AttestingIndices diff --git a/beacon-chain/core/epoch/BUILD.bazel b/beacon-chain/core/epoch/BUILD.bazel index b22308453..65f365c50 100644 --- a/beacon-chain/core/epoch/BUILD.bazel +++ b/beacon-chain/core/epoch/BUILD.bazel @@ -16,7 +16,7 @@ go_library( "//config/features:go_default_library", "//math:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/attestationutil:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", "//shared/params:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", diff --git a/beacon-chain/core/epoch/epoch_processing.go b/beacon-chain/core/epoch/epoch_processing.go index c086b0088..6d674010b 100644 --- a/beacon-chain/core/epoch/epoch_processing.go +++ b/beacon-chain/core/epoch/epoch_processing.go @@ -17,7 +17,7 @@ import ( "github.com/prysmaticlabs/prysm/config/features" "github.com/prysmaticlabs/prysm/math" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/attestationutil" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -469,7 +469,7 @@ func UnslashedAttestingIndices(state state.ReadOnlyBeaconState, atts []*ethpb.Pe if err != nil { return nil, err } - attestingIndices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(att.AggregationBits, committee) if err != nil { return nil, err } diff --git a/beacon-chain/core/epoch/precompute/BUILD.bazel b/beacon-chain/core/epoch/precompute/BUILD.bazel index 972d21f2e..540c1b7fc 100644 --- a/beacon-chain/core/epoch/precompute/BUILD.bazel +++ b/beacon-chain/core/epoch/precompute/BUILD.bazel @@ -22,7 +22,7 @@ go_library( "//math:go_default_library", "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/attestationutil:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", "//shared/params:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", @@ -48,7 +48,7 @@ go_test( "//beacon-chain/state/v1:go_default_library", "//math:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/attestationutil:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/core/epoch/precompute/attestation.go b/beacon-chain/core/epoch/precompute/attestation.go index 9dbb247c0..8bd24d3bb 100644 --- a/beacon-chain/core/epoch/precompute/attestation.go +++ b/beacon-chain/core/epoch/precompute/attestation.go @@ -11,7 +11,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/attestationutil" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" ) @@ -57,7 +57,7 @@ func ProcessAttestations( if err != nil { return nil, nil, err } - indices, err := attestationutil.AttestingIndices(a.AggregationBits, committee) + indices, err := attestation.AttestingIndices(a.AggregationBits, committee) if err != nil { return nil, nil, err } diff --git a/beacon-chain/core/epoch/precompute/attestation_test.go b/beacon-chain/core/epoch/precompute/attestation_test.go index 6eb29d431..946f583c2 100644 --- a/beacon-chain/core/epoch/precompute/attestation_test.go +++ b/beacon-chain/core/epoch/precompute/attestation_test.go @@ -8,7 +8,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/attestationutil" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -183,7 +183,7 @@ func TestProcessAttestations(t *testing.T) { committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex) require.NoError(t, err) - indices, err := attestationutil.AttestingIndices(att1.AggregationBits, committee) + indices, err := attestation.AttestingIndices(att1.AggregationBits, committee) require.NoError(t, err) for _, i := range indices { if !pVals[i].IsPrevEpochAttester { @@ -192,7 +192,7 @@ func TestProcessAttestations(t *testing.T) { } committee, err = helpers.BeaconCommitteeFromState(beaconState, att2.Data.Slot, att2.Data.CommitteeIndex) require.NoError(t, err) - indices, err = attestationutil.AttestingIndices(att2.AggregationBits, committee) + indices, err = attestation.AttestingIndices(att2.AggregationBits, committee) require.NoError(t, err) for _, i := range indices { assert.Equal(t, true, pVals[i].IsPrevEpochAttester, "Not a prev epoch attester") diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index 5807388d7..b69b0d2ee 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -18,7 +18,9 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers", visibility = [ "//beacon-chain:__subpackages__", + "//fuzz:__pkg__", "//network/forks:__pkg__", + "//proto/prysm/v1alpha1/attestation:__pkg__", "//shared/attestationutil:__pkg__", "//shared/depositutil:__pkg__", "//shared/interop:__pkg__", diff --git a/beacon-chain/core/transition/BUILD.bazel b/beacon-chain/core/transition/BUILD.bazel index 05c5ace3b..9be18e2a4 100644 --- a/beacon-chain/core/transition/BUILD.bazel +++ b/beacon-chain/core/transition/BUILD.bazel @@ -85,9 +85,9 @@ go_test( "//crypto/bls:go_default_library", "//crypto/hash:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//runtime/version:go_default_library", - "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", diff --git a/beacon-chain/core/transition/transition_test.go b/beacon-chain/core/transition/transition_test.go index 5458ba080..eb278783d 100644 --- a/beacon-chain/core/transition/transition_test.go +++ b/beacon-chain/core/transition/transition_test.go @@ -15,9 +15,9 @@ import ( v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/runtime/version" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -301,7 +301,7 @@ func createFullBlockWithOperations(t *testing.T) (state.BeaconState, committee, err := helpers.BeaconCommitteeFromState(beaconState, blockAtt.Data.Slot, blockAtt.Data.CommitteeIndex) assert.NoError(t, err) - attestingIndices, err := attestationutil.AttestingIndices(blockAtt.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(blockAtt.AggregationBits, committee) require.NoError(t, err) assert.NoError(t, err) hashTreeRoot, err = helpers.ComputeSigningRoot(blockAtt.Data, domain) diff --git a/beacon-chain/operations/attestations/BUILD.bazel b/beacon-chain/operations/attestations/BUILD.bazel index 6c7314348..026291131 100644 --- a/beacon-chain/operations/attestations/BUILD.bazel +++ b/beacon-chain/operations/attestations/BUILD.bazel @@ -21,7 +21,7 @@ go_library( "//cache/lru:go_default_library", "//crypto/hash:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/aggregation/attestations:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/attestations:go_default_library", "//shared/params:go_default_library", "//time:go_default_library", "//time/slots:go_default_library", @@ -49,7 +49,7 @@ go_test( "//beacon-chain/operations/attestations/kv:go_default_library", "//crypto/bls:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/aggregation/attestations:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/attestations:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/operations/attestations/kv/BUILD.bazel b/beacon-chain/operations/attestations/kv/BUILD.bazel index 5a5055cf9..358b4422c 100644 --- a/beacon-chain/operations/attestations/kv/BUILD.bazel +++ b/beacon-chain/operations/attestations/kv/BUILD.bazel @@ -16,7 +16,7 @@ go_library( "//beacon-chain/core/helpers:go_default_library", "//crypto/hash:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/aggregation/attestations:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/attestations:go_default_library", "//shared/params:go_default_library", "@com_github_patrickmn_go_cache//:go_default_library", "@com_github_pkg_errors//:go_default_library", diff --git a/beacon-chain/operations/attestations/kv/aggregated.go b/beacon-chain/operations/attestations/kv/aggregated.go index fe9e8b316..2ce580ec7 100644 --- a/beacon-chain/operations/attestations/kv/aggregated.go +++ b/beacon-chain/operations/attestations/kv/aggregated.go @@ -7,7 +7,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" + attaggregation "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/attestations" log "github.com/sirupsen/logrus" "go.opencensus.io/trace" ) diff --git a/beacon-chain/operations/attestations/prepare_forkchoice.go b/beacon-chain/operations/attestations/prepare_forkchoice.go index 1d57d7b79..8b4e71eab 100644 --- a/beacon-chain/operations/attestations/prepare_forkchoice.go +++ b/beacon-chain/operations/attestations/prepare_forkchoice.go @@ -9,7 +9,7 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/crypto/hash" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" + attaggregation "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/attestations" "github.com/prysmaticlabs/prysm/time/slots" "go.opencensus.io/trace" ) diff --git a/beacon-chain/operations/attestations/prepare_forkchoice_test.go b/beacon-chain/operations/attestations/prepare_forkchoice_test.go index e9f298172..0d330734e 100644 --- a/beacon-chain/operations/attestations/prepare_forkchoice_test.go +++ b/beacon-chain/operations/attestations/prepare_forkchoice_test.go @@ -9,7 +9,7 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" + attaggregation "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel index 29ebde619..17721f88c 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel @@ -44,10 +44,10 @@ go_library( "//config/features:go_default_library", "//container/slice:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/attestations:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", "//runtime/version:go_default_library", - "//shared/aggregation/attestations:go_default_library", - "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/cmd:go_default_library", "//shared/params:go_default_library", @@ -100,10 +100,10 @@ go_test( "//cmd/beacon-chain/flags:go_default_library", "//config/features:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/attestations:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", - "//shared/aggregation/attestations:go_default_library", - "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/cmd:go_default_library", "//shared/params:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go index 31ffd5e7d..6debf624b 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go @@ -13,9 +13,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" + attaggregation "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/attestations" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" - attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/params" @@ -180,7 +180,7 @@ func (bs *Server) ListIndexedAttestations( err, ) } - idxAtt, err := attestationutil.ConvertToIndexed(ctx, att, committee) + idxAtt, err := attestation.ConvertToIndexed(ctx, att, committee) if err != nil { return nil, err } @@ -321,7 +321,7 @@ func (bs *Server) StreamIndexedAttestations( continue } committee := committeesForSlot.Committees[att.Data.CommitteeIndex] - idxAtt, err := attestationutil.ConvertToIndexed(stream.Context(), att, committee.ValidatorIndices) + idxAtt, err := attestation.ConvertToIndexed(stream.Context(), att, committee.ValidatorIndices) if err != nil { continue } diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go index f0a0580b9..a642452ef 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go @@ -21,10 +21,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" + attaggregation "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/attestations" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" - attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/params" @@ -545,7 +545,7 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) { att := atts[i] committee, err := helpers.BeaconCommitteeFromState(state, att.Data.Slot, att.Data.CommitteeIndex) require.NoError(t, err) - idxAtt, err := attestationutil.ConvertToIndexed(ctx, atts[i], committee) + idxAtt, err := attestation.ConvertToIndexed(ctx, atts[i], committee) require.NoError(t, err, "Could not convert attestation to indexed") indexedAtts[i] = idxAtt } @@ -553,7 +553,7 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) { att := atts2[i] committee, err := helpers.BeaconCommitteeFromState(state, att.Data.Slot, att.Data.CommitteeIndex) require.NoError(t, err) - idxAtt, err := attestationutil.ConvertToIndexed(ctx, atts2[i], committee) + idxAtt, err := attestation.ConvertToIndexed(ctx, atts2[i], committee) require.NoError(t, err, "Could not convert attestation to indexed") indexedAtts[i+len(atts)] = idxAtt } @@ -652,7 +652,7 @@ func TestServer_ListIndexedAttestations_OldEpoch(t *testing.T) { att := atts[i] committee, err := helpers.BeaconCommitteeFromState(state, att.Data.Slot, att.Data.CommitteeIndex) require.NoError(t, err) - idxAtt, err := attestationutil.ConvertToIndexed(ctx, atts[i], committee) + idxAtt, err := attestation.ConvertToIndexed(ctx, atts[i], committee) require.NoError(t, err, "Could not convert attestation to indexed") indexedAtts[i] = idxAtt } @@ -955,7 +955,7 @@ func TestServer_StreamIndexedAttestations_OK(t *testing.T) { allAtts = append(allAtts, aggAtts...) for _, att := range aggAtts { committee := committees[att.Data.Slot].Committees[att.Data.CommitteeIndex] - idxAtt, err := attestationutil.ConvertToIndexed(ctx, att, committee.ValidatorIndices) + idxAtt, err := attestation.ConvertToIndexed(ctx, att, committee.ValidatorIndices) require.NoError(t, err) indexedAtts[dataRoot] = append(indexedAtts[dataRoot], idxAtt) } diff --git a/beacon-chain/rpc/prysm/v1alpha1/debug/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/debug/BUILD.bazel index b068706b1..11003118c 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/debug/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/debug/BUILD.bazel @@ -20,7 +20,7 @@ go_library( "//beacon-chain/state:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/attestationutil:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "@com_github_ethereum_go_ethereum//log:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/debug/block.go b/beacon-chain/rpc/prysm/v1alpha1/debug/block.go index 5b30d481d..7857d366d 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/debug/block.go +++ b/beacon-chain/rpc/prysm/v1alpha1/debug/block.go @@ -9,7 +9,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" "github.com/prysmaticlabs/prysm/beacon-chain/state" pbrpc "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/attestationutil" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "google.golang.org/grpc/codes" @@ -78,7 +78,7 @@ func (ds *Server) GetInclusionSlot(ctx context.Context, req *pbrpc.InclusionSlot if err != nil { return nil, status.Errorf(codes.Internal, "Could not get committee: %v", err) } - indices, err := attestationutil.AttestingIndices(a.AggregationBits, c) + indices, err := attestation.AttestingIndices(a.AggregationBits, c) if err != nil { return nil, err } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel index 270cbb851..667f1b201 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel @@ -51,12 +51,12 @@ go_library( "//network/forks:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/attestations:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/sync_contribution:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//runtime/version:go_default_library", - "//shared/aggregation:go_default_library", - "//shared/aggregation/attestations:go_default_library", - "//shared/aggregation/sync_contribution:go_default_library", "//shared/bytesutil:go_default_library", "//shared/depositutil:go_default_library", "//shared/params:go_default_library", @@ -124,9 +124,9 @@ go_test( "//crypto/bls:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/attestations:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", - "//shared/aggregation/attestations:go_default_library", - "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go index be5f975e2..27f0d8b90 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go @@ -16,8 +16,8 @@ import ( mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" - "github.com/prysmaticlabs/prysm/shared/attestationutil" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" + attaggregation "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -217,7 +217,7 @@ func generateAtt(state state.ReadOnlyBeaconState, index uint64, privKeys []bls.S if err != nil { return nil, err } - attestingIndices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(att.AggregationBits, committee) if err != nil { return nil, err } @@ -256,7 +256,7 @@ func generateUnaggregatedAtt(state state.ReadOnlyBeaconState, index uint64, priv if err != nil { return nil, err } - attestingIndices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(att.AggregationBits, committee) if err != nil { return nil, err } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go index 44e854b71..e03d06260 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go @@ -27,10 +27,10 @@ import ( "github.com/prysmaticlabs/prysm/crypto/rand" dbpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + attaggregation "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/attestations" + synccontribution "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/sync_contribution" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" - attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" - synccontribution "github.com/prysmaticlabs/prysm/shared/aggregation/sync_contribution" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/sirupsen/logrus" diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_attestations.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_attestations.go index ad54d0d4a..731efe736 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_attestations.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_attestations.go @@ -12,8 +12,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/config/features" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation" "github.com/prysmaticlabs/prysm/runtime/version" - "github.com/prysmaticlabs/prysm/shared/aggregation" "github.com/prysmaticlabs/prysm/shared/params" ) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go index f1e515fbf..81203149f 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go @@ -27,9 +27,9 @@ import ( dbpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" + attaggregation "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/attestations" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" - attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -1910,7 +1910,7 @@ func TestProposer_FilterAttestation(t *testing.T) { }) committee, err := helpers.BeaconCommitteeFromState(state, atts[i].Data.Slot, atts[i].Data.CommitteeIndex) assert.NoError(t, err) - attestingIndices, err := attestationutil.AttestingIndices(atts[i].AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(atts[i].AggregationBits, committee) require.NoError(t, err) assert.NoError(t, err) domain, err := helpers.Domain(state.Fork(), 0, params.BeaconConfig().DomainBeaconAttester, params.BeaconConfig().ZeroHash[:]) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_utils_bench_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_utils_bench_test.go index 711b993cb..81bb16bc2 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_utils_bench_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_utils_bench_test.go @@ -7,7 +7,7 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/config/features" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - aggtesting "github.com/prysmaticlabs/prysm/shared/aggregation/testing" + aggtesting "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/testing" "github.com/prysmaticlabs/prysm/shared/params" ) diff --git a/beacon-chain/sync/BUILD.bazel b/beacon-chain/sync/BUILD.bazel index 9af45320c..e30d63311 100644 --- a/beacon-chain/sync/BUILD.bazel +++ b/beacon-chain/sync/BUILD.bazel @@ -188,10 +188,10 @@ go_test( "//crypto/rand:go_default_library", "//network/forks:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/attestation:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", "//proto/prysm/v1alpha1/metadata:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", - "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "//shared/sszutil:go_default_library", diff --git a/beacon-chain/sync/pending_attestations_queue_test.go b/beacon-chain/sync/pending_attestations_queue_test.go index 52fd32070..b2004183c 100644 --- a/beacon-chain/sync/pending_attestations_queue_test.go +++ b/beacon-chain/sync/pending_attestations_queue_test.go @@ -20,8 +20,8 @@ import ( "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -80,7 +80,7 @@ func TestProcessPendingAtts_HasBlockSaveUnAggregatedAtt(t *testing.T) { committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex) assert.NoError(t, err) - attestingIndices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(att.AggregationBits, committee) require.NoError(t, err) assert.NoError(t, err) attesterDomain, err := helpers.Domain(beaconState.Fork(), 0, params.BeaconConfig().DomainBeaconAttester, beaconState.GenesisValidatorRoot()) @@ -196,7 +196,7 @@ func TestProcessPendingAtts_NoBroadcastWithBadSignature(t *testing.T) { } committee, err := helpers.BeaconCommitteeFromState(s, att.Data.Slot, att.Data.CommitteeIndex) assert.NoError(t, err) - attestingIndices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(att.AggregationBits, committee) require.NoError(t, err) assert.NoError(t, err) attesterDomain, err := helpers.Domain(s.Fork(), 0, params.BeaconConfig().DomainBeaconAttester, s.GenesisValidatorRoot()) @@ -270,7 +270,7 @@ func TestProcessPendingAtts_HasBlockSaveAggregatedAtt(t *testing.T) { committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex) assert.NoError(t, err) - attestingIndices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(att.AggregationBits, committee) require.NoError(t, err) assert.NoError(t, err) attesterDomain, err := helpers.Domain(beaconState.Fork(), 0, params.BeaconConfig().DomainBeaconAttester, beaconState.GenesisValidatorRoot()) diff --git a/beacon-chain/sync/validate_aggregate_proof_test.go b/beacon-chain/sync/validate_aggregate_proof_test.go index 27ac23b05..6c9b08752 100644 --- a/beacon-chain/sync/validate_aggregate_proof_test.go +++ b/beacon-chain/sync/validate_aggregate_proof_test.go @@ -21,8 +21,8 @@ import ( lruwrpr "github.com/prysmaticlabs/prysm/cache/lru" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -47,7 +47,7 @@ func TestVerifyIndexInCommittee_CanVerify(t *testing.T) { committee, err := helpers.BeaconCommitteeFromState(s, att.Data.Slot, att.Data.CommitteeIndex) assert.NoError(t, err) - indices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + indices, err := attestation.AttestingIndices(att.AggregationBits, committee) require.NoError(t, err) require.NoError(t, validateIndexInCommittee(ctx, s, att, types.ValidatorIndex(indices[0]))) @@ -320,7 +320,7 @@ func TestValidateAggregateAndProof_CanValidate(t *testing.T) { committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex) assert.NoError(t, err) - attestingIndices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(att.AggregationBits, committee) require.NoError(t, err) assert.NoError(t, err) attesterDomain, err := helpers.Domain(beaconState.Fork(), 0, params.BeaconConfig().DomainBeaconAttester, beaconState.GenesisValidatorRoot()) @@ -413,7 +413,7 @@ func TestVerifyIndexInCommittee_SeenAggregatorEpoch(t *testing.T) { committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex) require.NoError(t, err) - attestingIndices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(att.AggregationBits, committee) require.NoError(t, err) attesterDomain, err := helpers.Domain(beaconState.Fork(), 0, params.BeaconConfig().DomainBeaconAttester, beaconState.GenesisValidatorRoot()) require.NoError(t, err) @@ -523,7 +523,7 @@ func TestValidateAggregateAndProof_BadBlock(t *testing.T) { committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex) assert.NoError(t, err) - attestingIndices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(att.AggregationBits, committee) require.NoError(t, err) assert.NoError(t, err) attesterDomain, err := helpers.Domain(beaconState.Fork(), 0, params.BeaconConfig().DomainBeaconAttester, beaconState.GenesisValidatorRoot()) @@ -613,7 +613,7 @@ func TestValidateAggregateAndProof_RejectWhenAttEpochDoesntEqualTargetEpoch(t *t committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex) assert.NoError(t, err) - attestingIndices, err := attestationutil.AttestingIndices(att.AggregationBits, committee) + attestingIndices, err := attestation.AttestingIndices(att.AggregationBits, committee) require.NoError(t, err) assert.NoError(t, err) attesterDomain, err := helpers.Domain(beaconState.Fork(), 0, params.BeaconConfig().DomainBeaconAttester, beaconState.GenesisValidatorRoot()) diff --git a/shared/attestationutil/BUILD.bazel b/proto/prysm/v1alpha1/attestation/BUILD.bazel similarity index 93% rename from shared/attestationutil/BUILD.bazel rename to proto/prysm/v1alpha1/attestation/BUILD.bazel index 6462dc443..2efde8dcb 100644 --- a/shared/attestationutil/BUILD.bazel +++ b/proto/prysm/v1alpha1/attestation/BUILD.bazel @@ -3,7 +3,7 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", srcs = ["attestation_utils.go"], - importpath = "github.com/prysmaticlabs/prysm/shared/attestationutil", + importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation", visibility = ["//visibility:public"], deps = [ "//beacon-chain/core/helpers:go_default_library", diff --git a/shared/aggregation/BUILD.bazel b/proto/prysm/v1alpha1/attestation/aggregation/BUILD.bazel similarity index 81% rename from shared/aggregation/BUILD.bazel rename to proto/prysm/v1alpha1/attestation/aggregation/BUILD.bazel index adc15a240..811c0fa14 100644 --- a/shared/aggregation/BUILD.bazel +++ b/proto/prysm/v1alpha1/attestation/aggregation/BUILD.bazel @@ -6,7 +6,7 @@ go_library( "aggregation.go", "maxcover.go", ], - importpath = "github.com/prysmaticlabs/prysm/shared/aggregation", + importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation", visibility = ["//visibility:public"], deps = [ "@com_github_pkg_errors//:go_default_library", @@ -23,7 +23,7 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//shared/aggregation/testing:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/testing:go_default_library", "//shared/params:go_default_library", "//shared/testutil/assert:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", diff --git a/shared/aggregation/aggregation.go b/proto/prysm/v1alpha1/attestation/aggregation/aggregation.go similarity index 100% rename from shared/aggregation/aggregation.go rename to proto/prysm/v1alpha1/attestation/aggregation/aggregation.go diff --git a/shared/aggregation/attestations/BUILD.bazel b/proto/prysm/v1alpha1/attestation/aggregation/attestations/BUILD.bazel similarity index 78% rename from shared/aggregation/attestations/BUILD.bazel rename to proto/prysm/v1alpha1/attestation/aggregation/attestations/BUILD.bazel index 9393545b1..d6de39943 100644 --- a/shared/aggregation/attestations/BUILD.bazel +++ b/proto/prysm/v1alpha1/attestation/aggregation/attestations/BUILD.bazel @@ -7,13 +7,13 @@ go_library( "maxcover.go", "naive.go", ], - importpath = "github.com/prysmaticlabs/prysm/shared/aggregation/attestations", + importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/attestations", visibility = ["//visibility:public"], deps = [ "//config/features:go_default_library", "//crypto/bls:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/aggregation:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", @@ -32,8 +32,8 @@ go_test( "//config/features:go_default_library", "//crypto/bls:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/aggregation:go_default_library", - "//shared/aggregation/testing:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/testing:go_default_library", "//shared/params:go_default_library", "//shared/sszutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/shared/aggregation/attestations/attestations.go b/proto/prysm/v1alpha1/attestation/aggregation/attestations/attestations.go similarity index 97% rename from shared/aggregation/attestations/attestations.go rename to proto/prysm/v1alpha1/attestation/aggregation/attestations/attestations.go index 5357f169f..0b74c4e7c 100644 --- a/shared/aggregation/attestations/attestations.go +++ b/proto/prysm/v1alpha1/attestation/aggregation/attestations/attestations.go @@ -5,7 +5,7 @@ import ( "github.com/prysmaticlabs/prysm/config/features" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/aggregation" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation" "github.com/sirupsen/logrus" ) diff --git a/shared/aggregation/attestations/attestations_bench_test.go b/proto/prysm/v1alpha1/attestation/aggregation/attestations/attestations_bench_test.go similarity index 96% rename from shared/aggregation/attestations/attestations_bench_test.go rename to proto/prysm/v1alpha1/attestation/aggregation/attestations/attestations_bench_test.go index be16deeec..2df8ac97f 100644 --- a/shared/aggregation/attestations/attestations_bench_test.go +++ b/proto/prysm/v1alpha1/attestation/aggregation/attestations/attestations_bench_test.go @@ -8,7 +8,7 @@ import ( "github.com/prysmaticlabs/prysm/config/features" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - aggtesting "github.com/prysmaticlabs/prysm/shared/aggregation/testing" + aggtesting "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/testing" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) diff --git a/shared/aggregation/attestations/attestations_test.go b/proto/prysm/v1alpha1/attestation/aggregation/attestations/attestations_test.go similarity index 98% rename from shared/aggregation/attestations/attestations_test.go rename to proto/prysm/v1alpha1/attestation/aggregation/attestations/attestations_test.go index 936563f20..d90e3f072 100644 --- a/shared/aggregation/attestations/attestations_test.go +++ b/proto/prysm/v1alpha1/attestation/aggregation/attestations/attestations_test.go @@ -10,8 +10,8 @@ import ( "github.com/prysmaticlabs/prysm/config/features" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/aggregation" - aggtesting "github.com/prysmaticlabs/prysm/shared/aggregation/testing" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation" + aggtesting "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/testing" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sszutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" diff --git a/shared/aggregation/attestations/maxcover.go b/proto/prysm/v1alpha1/attestation/aggregation/attestations/maxcover.go similarity index 99% rename from shared/aggregation/attestations/maxcover.go rename to proto/prysm/v1alpha1/attestation/aggregation/attestations/maxcover.go index 7ed8712de..3a6c729d6 100644 --- a/shared/aggregation/attestations/maxcover.go +++ b/proto/prysm/v1alpha1/attestation/aggregation/attestations/maxcover.go @@ -7,7 +7,7 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/aggregation" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation" ) // MaxCoverAttestationAggregation relies on Maximum Coverage greedy algorithm for aggregation. diff --git a/shared/aggregation/attestations/maxcover_test.go b/proto/prysm/v1alpha1/attestation/aggregation/attestations/maxcover_test.go similarity index 99% rename from shared/aggregation/attestations/maxcover_test.go rename to proto/prysm/v1alpha1/attestation/aggregation/attestations/maxcover_test.go index e68fd0a90..f26eae6cd 100644 --- a/shared/aggregation/attestations/maxcover_test.go +++ b/proto/prysm/v1alpha1/attestation/aggregation/attestations/maxcover_test.go @@ -6,7 +6,7 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/aggregation" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation" "github.com/prysmaticlabs/prysm/shared/testutil/assert" ) diff --git a/shared/aggregation/attestations/naive.go b/proto/prysm/v1alpha1/attestation/aggregation/attestations/naive.go similarity index 100% rename from shared/aggregation/attestations/naive.go rename to proto/prysm/v1alpha1/attestation/aggregation/attestations/naive.go diff --git a/shared/aggregation/maxcover.go b/proto/prysm/v1alpha1/attestation/aggregation/maxcover.go similarity index 100% rename from shared/aggregation/maxcover.go rename to proto/prysm/v1alpha1/attestation/aggregation/maxcover.go diff --git a/shared/aggregation/maxcover_bench_test.go b/proto/prysm/v1alpha1/attestation/aggregation/maxcover_bench_test.go similarity index 95% rename from shared/aggregation/maxcover_bench_test.go rename to proto/prysm/v1alpha1/attestation/aggregation/maxcover_bench_test.go index 229f94c16..533484f97 100644 --- a/shared/aggregation/maxcover_bench_test.go +++ b/proto/prysm/v1alpha1/attestation/aggregation/maxcover_bench_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/prysmaticlabs/go-bitfield" - aggtesting "github.com/prysmaticlabs/prysm/shared/aggregation/testing" + aggtesting "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/testing" "github.com/prysmaticlabs/prysm/shared/params" ) diff --git a/shared/aggregation/maxcover_test.go b/proto/prysm/v1alpha1/attestation/aggregation/maxcover_test.go similarity index 99% rename from shared/aggregation/maxcover_test.go rename to proto/prysm/v1alpha1/attestation/aggregation/maxcover_test.go index 5e6abc27d..b869a69aa 100644 --- a/shared/aggregation/maxcover_test.go +++ b/proto/prysm/v1alpha1/attestation/aggregation/maxcover_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/prysmaticlabs/go-bitfield" - aggtesting "github.com/prysmaticlabs/prysm/shared/aggregation/testing" + aggtesting "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/testing" "github.com/prysmaticlabs/prysm/shared/testutil/assert" ) diff --git a/shared/aggregation/sync_contribution/BUILD.bazel b/proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/BUILD.bazel similarity index 71% rename from shared/aggregation/sync_contribution/BUILD.bazel rename to proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/BUILD.bazel index 8ec466612..be1afd35d 100644 --- a/shared/aggregation/sync_contribution/BUILD.bazel +++ b/proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/BUILD.bazel @@ -6,12 +6,12 @@ go_library( "contribution.go", "naive.go", ], - importpath = "github.com/prysmaticlabs/prysm/shared/aggregation/sync_contribution", + importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/sync_contribution", visibility = ["//visibility:public"], deps = [ "//crypto/bls:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/aggregation:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", ], @@ -25,8 +25,8 @@ go_test( "//config/features:go_default_library", "//crypto/bls:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/aggregation:go_default_library", - "//shared/aggregation/testing:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation:go_default_library", + "//proto/prysm/v1alpha1/attestation/aggregation/testing:go_default_library", "//shared/testutil/assert:go_default_library", "//shared/testutil/require:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", diff --git a/shared/aggregation/sync_contribution/contribution.go b/proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/contribution.go similarity index 95% rename from shared/aggregation/sync_contribution/contribution.go rename to proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/contribution.go index 63ee219f2..ce1c81909 100644 --- a/shared/aggregation/sync_contribution/contribution.go +++ b/proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/contribution.go @@ -3,7 +3,7 @@ package sync_contribution import ( "github.com/pkg/errors" v2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/aggregation" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation" "github.com/sirupsen/logrus" ) diff --git a/shared/aggregation/sync_contribution/naive.go b/proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/naive.go similarity index 97% rename from shared/aggregation/sync_contribution/naive.go rename to proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/naive.go index 302ef898f..4e8dc3152 100644 --- a/shared/aggregation/sync_contribution/naive.go +++ b/proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/naive.go @@ -3,7 +3,7 @@ package sync_contribution import ( "github.com/prysmaticlabs/prysm/crypto/bls" v2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/aggregation" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation" ) // naiveSyncContributionAggregation aggregates naively, without any complex algorithms or optimizations. diff --git a/shared/aggregation/sync_contribution/naive_test.go b/proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/naive_test.go similarity index 96% rename from shared/aggregation/sync_contribution/naive_test.go rename to proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/naive_test.go index 417761af0..8a926f6cf 100644 --- a/shared/aggregation/sync_contribution/naive_test.go +++ b/proto/prysm/v1alpha1/attestation/aggregation/sync_contribution/naive_test.go @@ -9,8 +9,8 @@ import ( "github.com/prysmaticlabs/prysm/config/features" "github.com/prysmaticlabs/prysm/crypto/bls" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/aggregation" - aggtesting "github.com/prysmaticlabs/prysm/shared/aggregation/testing" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation" + aggtesting "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/testing" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) diff --git a/shared/aggregation/testing/BUILD.bazel b/proto/prysm/v1alpha1/attestation/aggregation/testing/BUILD.bazel similarity index 81% rename from shared/aggregation/testing/BUILD.bazel rename to proto/prysm/v1alpha1/attestation/aggregation/testing/BUILD.bazel index 3fb566c19..97536c51c 100644 --- a/shared/aggregation/testing/BUILD.bazel +++ b/proto/prysm/v1alpha1/attestation/aggregation/testing/BUILD.bazel @@ -3,7 +3,7 @@ load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = ["bitlistutils.go"], - importpath = "github.com/prysmaticlabs/prysm/shared/aggregation/testing", + importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation/aggregation/testing", visibility = ["//visibility:public"], deps = [ "//crypto/bls:go_default_library", diff --git a/shared/aggregation/testing/bitlistutils.go b/proto/prysm/v1alpha1/attestation/aggregation/testing/bitlistutils.go similarity index 100% rename from shared/aggregation/testing/bitlistutils.go rename to proto/prysm/v1alpha1/attestation/aggregation/testing/bitlistutils.go diff --git a/shared/attestationutil/attestation_utils.go b/proto/prysm/v1alpha1/attestation/attestation_utils.go similarity index 99% rename from shared/attestationutil/attestation_utils.go rename to proto/prysm/v1alpha1/attestation/attestation_utils.go index fab3191fe..7abcc51a3 100644 --- a/shared/attestationutil/attestation_utils.go +++ b/proto/prysm/v1alpha1/attestation/attestation_utils.go @@ -1,6 +1,6 @@ // Package attestationutil contains useful helpers for converting // attestations into indexed form. -package attestationutil +package attestation import ( "bytes" diff --git a/shared/attestationutil/attestation_utils_test.go b/proto/prysm/v1alpha1/attestation/attestation_utils_test.go similarity index 92% rename from shared/attestationutil/attestation_utils_test.go rename to proto/prysm/v1alpha1/attestation/attestation_utils_test.go index 136ad4f1b..57e38b47b 100644 --- a/shared/attestationutil/attestation_utils_test.go +++ b/proto/prysm/v1alpha1/attestation/attestation_utils_test.go @@ -1,4 +1,4 @@ -package attestationutil_test +package attestation_test import ( "context" @@ -7,7 +7,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/go-bitfield" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/attestationutil" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/attestation" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -51,7 +51,7 @@ func TestAttestingIndices(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := attestationutil.AttestingIndices(tt.args.bf, tt.args.committee) + got, err := attestation.AttestingIndices(tt.args.bf, tt.args.committee) if tt.err == "" { require.NoError(t, err) assert.DeepEqual(t, tt.want, got) @@ -144,7 +144,7 @@ func TestIsValidAttestationIndices(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := attestationutil.IsValidAttestationIndices(context.Background(), tt.att) + err := attestation.IsValidAttestationIndices(context.Background(), tt.att) if tt.wantedErr != "" { assert.ErrorContains(t, tt.wantedErr, err) } else { @@ -160,7 +160,7 @@ func BenchmarkAttestingIndices_PartialCommittee(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { - _, err := attestationutil.AttestingIndices(bf, committee) + _, err := attestation.AttestingIndices(bf, committee) require.NoError(b, err) } } @@ -179,7 +179,7 @@ func BenchmarkIsValidAttestationIndices(b *testing.B) { } b.ResetTimer() for i := 0; i < b.N; i++ { - if err := attestationutil.IsValidAttestationIndices(context.Background(), att); err != nil { + if err := attestation.IsValidAttestationIndices(context.Background(), att); err != nil { require.NoError(b, err) } } @@ -313,7 +313,7 @@ func TestAttDataIsEqual(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - assert.Equal(t, tt.equal, attestationutil.AttDataIsEqual(tt.attData1, tt.attData2)) + assert.Equal(t, tt.equal, attestation.AttDataIsEqual(tt.attData1, tt.attData2)) }) } } @@ -365,7 +365,7 @@ func TestCheckPtIsEqual(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - assert.Equal(t, tt.equal, attestationutil.CheckPointIsEqual(tt.checkPt1, tt.checkPt2)) + assert.Equal(t, tt.equal, attestation.CheckPointIsEqual(tt.checkPt1, tt.checkPt2)) }) } } @@ -401,14 +401,14 @@ func BenchmarkAttDataIsEqual(b *testing.B) { b.Run("fast", func(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - assert.Equal(b, true, attestationutil.AttDataIsEqual(attData1, attData2)) + assert.Equal(b, true, attestation.AttDataIsEqual(attData1, attData2)) } }) b.Run("proto.Equal", func(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - assert.Equal(b, true, attestationutil.AttDataIsEqual(attData1, attData2)) + assert.Equal(b, true, attestation.AttDataIsEqual(attData1, attData2)) } }) } diff --git a/proto/prysm/v1alpha1/block/BUILD.bazel b/proto/prysm/v1alpha1/block/BUILD.bazel index 2ea35748b..082884ca9 100644 --- a/proto/prysm/v1alpha1/block/BUILD.bazel +++ b/proto/prysm/v1alpha1/block/BUILD.bazel @@ -1,14 +1,32 @@ -load("@prysm//tools/go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = ["block_interfaces.go"], + srcs = [ + "block_interfaces.go", + "block_utils.go", + ], importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block", visibility = ["//visibility:public"], deps = [ "//proto/prysm/v1alpha1:go_default_library", "@com_github_ferranbt_fastssz//:go_default_library", + "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], ) + +go_test( + name = "go_default_test", + srcs = ["block_utils_test.go"], + deps = [ + ":go_default_library", + "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//shared/bytesutil:go_default_library", + "//shared/params:go_default_library", + "//shared/testutil/assert:go_default_library", + "//shared/testutil/require:go_default_library", + ], +) diff --git a/shared/blockutil/block_utils.go b/proto/prysm/v1alpha1/block/block_utils.go similarity index 88% rename from shared/blockutil/block_utils.go rename to proto/prysm/v1alpha1/block/block_utils.go index 3429d2c22..7c9691515 100644 --- a/shared/blockutil/block_utils.go +++ b/proto/prysm/v1alpha1/block/block_utils.go @@ -1,9 +1,8 @@ -package blockutil +package block import ( "github.com/pkg/errors" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" ) // SignedBeaconBlockHeaderFromBlock function to retrieve signed block header from block. @@ -29,7 +28,7 @@ func SignedBeaconBlockHeaderFromBlock(block *ethpb.SignedBeaconBlock) (*ethpb.Si } // SignedBeaconBlockHeaderFromBlockInterface function to retrieve signed block header from block. -func SignedBeaconBlockHeaderFromBlockInterface(sb block.SignedBeaconBlock) (*ethpb.SignedBeaconBlockHeader, error) { +func SignedBeaconBlockHeaderFromBlockInterface(sb SignedBeaconBlock) (*ethpb.SignedBeaconBlockHeader, error) { b := sb.Block() if b.IsNil() || b.Body().IsNil() { return nil, errors.New("nil block") @@ -65,7 +64,7 @@ func BeaconBlockHeaderFromBlock(block *ethpb.BeaconBlock) (*ethpb.BeaconBlockHea } // BeaconBlockHeaderFromBlockInterface function to retrieve block header from block. -func BeaconBlockHeaderFromBlockInterface(block block.BeaconBlock) (*ethpb.BeaconBlockHeader, error) { +func BeaconBlockHeaderFromBlockInterface(block BeaconBlock) (*ethpb.BeaconBlockHeader, error) { if block.Body().IsNil() { return nil, errors.New("nil block body") } diff --git a/shared/blockutil/block_utils_test.go b/proto/prysm/v1alpha1/block/block_utils_test.go similarity index 93% rename from shared/blockutil/block_utils_test.go rename to proto/prysm/v1alpha1/block/block_utils_test.go index caacd30d3..838e9ccf2 100644 --- a/shared/blockutil/block_utils_test.go +++ b/proto/prysm/v1alpha1/block/block_utils_test.go @@ -1,9 +1,10 @@ -package blockutil +package block_test import ( "testing" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -43,7 +44,7 @@ func TestBeaconBlockHeaderFromBlock(t *testing.T) { BodyRoot: bodyRoot[:], } - bh, err := BeaconBlockHeaderFromBlock(blk) + bh, err := block.BeaconBlockHeaderFromBlock(blk) require.NoError(t, err) assert.DeepEqual(t, want, bh) } @@ -80,7 +81,7 @@ func TestBeaconBlockHeaderFromBlockInterface(t *testing.T) { BodyRoot: bodyRoot[:], } - bh, err := BeaconBlockHeaderFromBlockInterface(wrapper.WrappedPhase0BeaconBlock(blk)) + bh, err := block.BeaconBlockHeaderFromBlockInterface(wrapper.WrappedPhase0BeaconBlock(blk)) require.NoError(t, err) assert.DeepEqual(t, want, bh) } @@ -93,7 +94,7 @@ func TestBeaconBlockHeaderFromBlock_NilBlockBody(t *testing.T) { ParentRoot: bytesutil.PadTo([]byte("parent root"), hashLen), StateRoot: bytesutil.PadTo([]byte("state root"), hashLen), } - _, err := BeaconBlockHeaderFromBlock(blk) + _, err := block.BeaconBlockHeaderFromBlock(blk) require.ErrorContains(t, "nil block body", err) } @@ -133,7 +134,7 @@ func TestSignedBeaconBlockHeaderFromBlock(t *testing.T) { Signature: blk.Signature, } - bh, err := SignedBeaconBlockHeaderFromBlock(blk) + bh, err := block.SignedBeaconBlockHeaderFromBlock(blk) require.NoError(t, err) assert.DeepEqual(t, want, bh) } @@ -174,7 +175,7 @@ func TestSignedBeaconBlockHeaderFromBlockInterface(t *testing.T) { Signature: blk.Signature, } - bh, err := SignedBeaconBlockHeaderFromBlockInterface(wrapper.WrappedPhase0SignedBeaconBlock(blk)) + bh, err := block.SignedBeaconBlockHeaderFromBlockInterface(wrapper.WrappedPhase0SignedBeaconBlock(blk)) require.NoError(t, err) assert.DeepEqual(t, want, bh) } @@ -189,6 +190,6 @@ func TestSignedBeaconBlockHeaderFromBlock_NilBlockBody(t *testing.T) { }, Signature: bytesutil.PadTo([]byte("signature"), params.BeaconConfig().BLSSignatureLength), } - _, err := SignedBeaconBlockHeaderFromBlock(blk) + _, err := block.SignedBeaconBlockHeaderFromBlock(blk) require.ErrorContains(t, "nil block", err) } diff --git a/shared/blockutil/BUILD.bazel b/shared/blockutil/BUILD.bazel deleted file mode 100644 index 3de8861de..000000000 --- a/shared/blockutil/BUILD.bazel +++ /dev/null @@ -1,27 +0,0 @@ -load("@prysm//tools/go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = ["block_utils.go"], - importpath = "github.com/prysmaticlabs/prysm/shared/blockutil", - visibility = ["//visibility:public"], - deps = [ - "//proto/prysm/v1alpha1:go_default_library", - "//proto/prysm/v1alpha1/block:go_default_library", - "@com_github_pkg_errors//:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = ["block_utils_test.go"], - embed = [":go_default_library"], - deps = [ - "//proto/prysm/v1alpha1:go_default_library", - "//proto/prysm/v1alpha1/wrapper:go_default_library", - "//shared/bytesutil:go_default_library", - "//shared/params:go_default_library", - "//shared/testutil/assert:go_default_library", - "//shared/testutil/require:go_default_library", - ], -) diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 96d858bee..9c78f221c 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -39,7 +39,6 @@ go_library( "//proto/prysm/v1alpha1/validator-client:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//runtime/version:go_default_library", - "//shared/blockutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "//shared/slashutil:go_default_library", diff --git a/validator/client/propose_protect.go b/validator/client/propose_protect.go index 18ce82729..ea8cffcb2 100644 --- a/validator/client/propose_protect.go +++ b/validator/client/propose_protect.go @@ -7,7 +7,6 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/config/features" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" - "github.com/prysmaticlabs/prysm/shared/blockutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/sirupsen/logrus" ) @@ -17,11 +16,11 @@ var failedPreBlockSignExternalErr = "attempted a double proposal, block rejected var failedPostBlockSignErr = "made a double proposal, considered slashable by remote slashing protection" func (v *validator) preBlockSignValidations( - ctx context.Context, pubKey [48]byte, block block.BeaconBlock, signingRoot [32]byte, + ctx context.Context, pubKey [48]byte, blk block.BeaconBlock, signingRoot [32]byte, ) error { fmtKey := fmt.Sprintf("%#x", pubKey[:]) - prevSigningRoot, proposalAtSlotExists, err := v.db.ProposalHistoryForSlot(ctx, pubKey, block.Slot()) + prevSigningRoot, proposalAtSlotExists, err := v.db.ProposalHistoryForSlot(ctx, pubKey, blk.Slot()) if err != nil { if v.emitAccountMetrics { ValidatorProposeFailVec.WithLabelValues(fmtKey).Inc() @@ -50,16 +49,16 @@ func (v *validator) preBlockSignValidations( // than or equal to the minimum signed proposal present in the DB for that public key. // In the case the slot of the incoming block is equal to the minimum signed proposal, we // then also check the signing root is different. - if lowestProposalExists && signingRootIsDifferent && lowestSignedProposalSlot >= block.Slot() { + if lowestProposalExists && signingRootIsDifferent && lowestSignedProposalSlot >= blk.Slot() { return fmt.Errorf( "could not sign block with slot <= lowest signed slot in db, lowest signed slot: %d >= block slot: %d", lowestSignedProposalSlot, - block.Slot(), + blk.Slot(), ) } if features.Get().SlasherProtection && v.protector != nil { - blockHdr, err := blockutil.BeaconBlockHeaderFromBlockInterface(block) + blockHdr, err := block.BeaconBlockHeaderFromBlockInterface(blk) if err != nil { return errors.Wrap(err, "failed to get block header from block") } @@ -77,12 +76,12 @@ func (v *validator) preBlockSignValidations( func (v *validator) postBlockSignUpdate( ctx context.Context, pubKey [48]byte, - block block.SignedBeaconBlock, + blk block.SignedBeaconBlock, signingRoot [32]byte, ) error { fmtKey := fmt.Sprintf("%#x", pubKey[:]) if features.Get().SlasherProtection && v.protector != nil { - sbh, err := blockutil.SignedBeaconBlockHeaderFromBlockInterface(block) + sbh, err := block.SignedBeaconBlockHeaderFromBlockInterface(blk) if err != nil { return errors.Wrap(err, "failed to get block header from block") } @@ -97,7 +96,7 @@ func (v *validator) postBlockSignUpdate( return fmt.Errorf(failedPostBlockSignErr) } } - if err := v.db.SaveProposalHistoryForSlot(ctx, pubKey, block.Block().Slot(), signingRoot[:]); err != nil { + if err := v.db.SaveProposalHistoryForSlot(ctx, pubKey, blk.Block().Slot(), signingRoot[:]); err != nil { if v.emitAccountMetrics { ValidatorProposeFailVec.WithLabelValues(fmtKey).Inc() }