diff --git a/beacon-chain/BUILD.bazel b/beacon-chain/BUILD.bazel deleted file mode 100644 index 2602cb314b..0000000000 --- a/beacon-chain/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -load("//tools:target_migration.bzl", "moved_targets") - -moved_targets( - [ - ":push_images_debug", - ":push_images_alpine", - ":push_images", - ":image_bundle_debug", - ":image_debug", - ":image_bundle_alpine", - ":image_bundle", - ":image_with_creation_time", - ":image_alpine", - ":image", - ":go_default_test", - ":beacon-chain", - ], - "//cmd/beacon-chain", -) diff --git a/beacon-chain/blockchain/service_test.go b/beacon-chain/blockchain/service_test.go index c2dbcfdb7c..99b6498177 100644 --- a/beacon-chain/blockchain/service_test.go +++ b/beacon-chain/blockchain/service_test.go @@ -446,11 +446,10 @@ func BenchmarkHasBlockForkChoiceStore_DoublyLinkedTree(b *testing.B) { s := &Service{ cfg: &config{ForkChoiceStore: doublylinkedtree.New(), BeaconDB: beaconDB}, } - blk := ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{}}} + blk := util.NewBeaconBlock() r, err := blk.Block.HashTreeRoot() require.NoError(b, err) - bs := ðpb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, CurrentJustifiedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}} - beaconState, err := state_native.InitializeFromProtoPhase0(bs) + beaconState, err := util.NewBeaconState() require.NoError(b, err) require.NoError(b, s.cfg.ForkChoiceStore.InsertNode(ctx, beaconState, r)) diff --git a/beacon-chain/db/kv/BUILD.bazel b/beacon-chain/db/kv/BUILD.bazel index c70608999e..c53653b05c 100644 --- a/beacon-chain/db/kv/BUILD.bazel +++ b/beacon-chain/db/kv/BUILD.bazel @@ -124,6 +124,7 @@ go_test( "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_golang_snappy//:go_default_library", "@com_github_pkg_errors//:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", "@com_github_urfave_cli_v2//:go_default_library", "@io_bazel_rules_go//go/tools/bazel:go_default_library", "@io_etcd_go_bbolt//:go_default_library", diff --git a/beacon-chain/db/kv/init_test.go b/beacon-chain/db/kv/init_test.go index c45e351fc0..7a3983513f 100644 --- a/beacon-chain/db/kv/init_test.go +++ b/beacon-chain/db/kv/init_test.go @@ -1,7 +1,12 @@ package kv import ( + "io" + "os" + "testing" + "github.com/prysmaticlabs/prysm/v4/config/params" + "github.com/sirupsen/logrus" ) func init() { @@ -10,3 +15,9 @@ func init() { panic(err) } } + +func TestMain(m *testing.M) { + logrus.SetLevel(logrus.DebugLevel) + logrus.SetOutput(io.Discard) + os.Exit(m.Run()) +} diff --git a/beacon-chain/operations/attestations/kv/BUILD.bazel b/beacon-chain/operations/attestations/kv/BUILD.bazel index a3ab84a720..a787ebd6c7 100644 --- a/beacon-chain/operations/attestations/kv/BUILD.bazel +++ b/beacon-chain/operations/attestations/kv/BUILD.bazel @@ -32,7 +32,6 @@ go_test( name = "go_default_test", srcs = [ "aggregated_test.go", - "benchmark_test.go", "block_test.go", "forkchoice_test.go", "seen_bits_test.go", diff --git a/beacon-chain/operations/attestations/kv/benchmark_test.go b/beacon-chain/operations/attestations/kv/benchmark_test.go deleted file mode 100644 index 3518d293ab..0000000000 --- a/beacon-chain/operations/attestations/kv/benchmark_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package kv_test - -import ( - "testing" - - "github.com/prysmaticlabs/prysm/v4/beacon-chain/operations/attestations/kv" - ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/v4/testing/assert" -) - -func BenchmarkAttCaches(b *testing.B) { - ac := kv.NewAttCaches() - - att := ðpb.Attestation{} - - for i := 0; i < b.N; i++ { - assert.NoError(b, ac.SaveUnaggregatedAttestation(att)) - assert.NoError(b, ac.DeleteAggregatedAttestation(att)) - } -} diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go index 3b3754d597..a4c6a50d88 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go @@ -2239,28 +2239,6 @@ func TestGetValidatorPerformanceCapella_OK(t *testing.T) { } } -func BenchmarkListValidatorBalances(b *testing.B) { - b.StopTimer() - beaconDB := dbTest.SetupDB(b) - ctx := context.Background() - - count := 1000 - _, _, headState := setupValidators(b, beaconDB, count) - bs := &Server{ - HeadFetcher: &mock.ChainService{ - State: headState, - }, - } - addDefaultReplayerBuilder(bs, beaconDB) - - req := ðpb.ListValidatorBalancesRequest{PageSize: 100} - b.StartTimer() - for i := 0; i < b.N; i++ { - _, err := bs.ListValidatorBalances(ctx, req) - require.NoError(b, err) - } -} - func setupValidators(t testing.TB, _ db.Database, count int) ([]*ethpb.Validator, []uint64, state.BeaconState) { balances := make([]uint64, count) validators := make([]*ethpb.Validator, 0, count) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel index 52955b46d7..8b68eba323 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel @@ -214,9 +214,12 @@ go_test( timeout = "moderate", srcs = [ "attester_mainnet_test.go", + "proposer_utils_bench_test.go", "server_mainnet_test.go", "status_mainnet_test.go", ], embed = [":go_default_library"], - deps = common_deps, + deps = common_deps + [ + "//proto/prysm/v1alpha1/attestation/aggregation/testing:go_default_library", + ], ) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/assignments_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/assignments_test.go index fecb516a52..7de63141ae 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/assignments_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/assignments_test.go @@ -639,9 +639,12 @@ func BenchmarkCommitteeAssignment(b *testing.B) { indices[i] = uint64(i) } + chain := &mockChain.ChainService{State: bs, Root: genesisRoot[:]} vs := &Server{ - HeadFetcher: &mockChain.ChainService{State: bs, Root: genesisRoot[:]}, - SyncChecker: &mockSync.Sync{IsSyncing: false}, + HeadFetcher: chain, + TimeFetcher: chain, + SyncChecker: &mockSync.Sync{IsSyncing: false}, + ProposerSlotIndexCache: cache.NewProposerPayloadIDsCache(), } // Create request for all validators in the system. diff --git a/cmd/beacon-chain/BUILD.bazel b/cmd/beacon-chain/BUILD.bazel index 63fdc2c675..ad2e075797 100644 --- a/cmd/beacon-chain/BUILD.bazel +++ b/cmd/beacon-chain/BUILD.bazel @@ -110,6 +110,7 @@ docker_push( go_binary( name = "beacon-chain", embed = [":go_default_library"], + pgoprofile = "pprof.beacon-chain.samples.cpu.pb.gz", visibility = [ "//beacon-chain:__subpackages__", "//testing/endtoend:__pkg__", diff --git a/cmd/beacon-chain/pprof.beacon-chain.samples.cpu.pb.gz b/cmd/beacon-chain/pprof.beacon-chain.samples.cpu.pb.gz new file mode 100644 index 0000000000..553015b136 Binary files /dev/null and b/cmd/beacon-chain/pprof.beacon-chain.samples.cpu.pb.gz differ diff --git a/proto/prysm/v1alpha1/attestation/attestation_utils_test.go b/proto/prysm/v1alpha1/attestation/attestation_utils_test.go index 411f36e4d5..f3ee551a1f 100644 --- a/proto/prysm/v1alpha1/attestation/attestation_utils_test.go +++ b/proto/prysm/v1alpha1/attestation/attestation_utils_test.go @@ -157,7 +157,7 @@ func TestIsValidAttestationIndices(t *testing.T) { func BenchmarkAttestingIndices_PartialCommittee(b *testing.B) { bf := bitfield.Bitlist{0b11111111, 0b11111111, 0b10000111, 0b11111111, 0b100} - committee := []primitives.ValidatorIndex{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34} + committee := []primitives.ValidatorIndex{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33} b.ResetTimer() for i := 0; i < b.N; i++ { diff --git a/testing/benchmark/README.md b/testing/benchmark/README.md index 844c9cf28e..64a70d92d8 100644 --- a/testing/benchmark/README.md +++ b/testing/benchmark/README.md @@ -10,6 +10,7 @@ The following configs are in `config.go`: Due to the sheer size of the benchmarking configurations (16384 validators), the files used for benchmarking are pregenerated so there's no wasted computations on generating a genesis state with 16384 validators. This should only be needed if there is a breaking spec change and the tests fail from SSZ issues. To generate new files to use for benchmarking, run the below command in the root of Prysm. + ``` bazel run //tools/benchmark-files-gen -- --output-dir $PRYSMPATH/testing/benchmark/benchmark_files/ --overwrite ``` diff --git a/testing/benchmark/benchmark_files/bState1Epoch-128Atts-16384Vals.ssz b/testing/benchmark/benchmark_files/bState1Epoch-128Atts-16384Vals.ssz index b1e8bdd41f..19ebebe2fd 100644 Binary files a/testing/benchmark/benchmark_files/bState1Epoch-128Atts-16384Vals.ssz and b/testing/benchmark/benchmark_files/bState1Epoch-128Atts-16384Vals.ssz differ diff --git a/testing/benchmark/benchmark_files/bState2Epochs-128Atts-16384Vals.ssz b/testing/benchmark/benchmark_files/bState2Epochs-128Atts-16384Vals.ssz index d1a6ee0289..f79b4be818 100644 Binary files a/testing/benchmark/benchmark_files/bState2Epochs-128Atts-16384Vals.ssz and b/testing/benchmark/benchmark_files/bState2Epochs-128Atts-16384Vals.ssz differ diff --git a/testing/benchmark/benchmark_files/fullBlock-128Atts-16384Vals.ssz b/testing/benchmark/benchmark_files/fullBlock-128Atts-16384Vals.ssz index ff810e9e8b..b258fcd9e9 100644 Binary files a/testing/benchmark/benchmark_files/fullBlock-128Atts-16384Vals.ssz and b/testing/benchmark/benchmark_files/fullBlock-128Atts-16384Vals.ssz differ diff --git a/testing/benchmark/pregen.go b/testing/benchmark/pregen.go index 4b21c6a7c5..8517f19a70 100644 --- a/testing/benchmark/pregen.go +++ b/testing/benchmark/pregen.go @@ -30,7 +30,7 @@ var GenesisFileName = fmt.Sprintf("bStateGenesis-%dAtts-%dVals.ssz", Attestation var BState1EpochFileName = fmt.Sprintf("bState1Epoch-%dAtts-%dVals.ssz", AttestationsPerEpoch, ValidatorCount) // BstateEpochFileName is the generated beacon state after 2 full epochs file name. -var BstateEpochFileName = fmt.Sprintf("bstateEpochs-%dAtts-%dVals.ssz", AttestationsPerEpoch, ValidatorCount) +var BstateEpochFileName = fmt.Sprintf("bState2Epochs-%dAtts-%dVals.ssz", AttestationsPerEpoch, ValidatorCount) // FullBlockFileName is the generated full block file name. var FullBlockFileName = fmt.Sprintf("fullBlock-%dAtts-%dVals.ssz", AttestationsPerEpoch, ValidatorCount) diff --git a/testing/benchmark/pregen_test.go b/testing/benchmark/pregen_test.go index 1dd2ffb273..acd7e75022 100644 --- a/testing/benchmark/pregen_test.go +++ b/testing/benchmark/pregen_test.go @@ -12,11 +12,11 @@ func TestPreGenFullBlock(t *testing.T) { } func TestPreGenState1Epoch(t *testing.T) { - _, err := PreGenFullBlock() + _, err := PreGenState1Epoch() require.NoError(t, err) } func TestPreGenstateFullEpochs(t *testing.T) { - _, err := PreGenFullBlock() + _, err := PreGenstateFullEpochs() require.NoError(t, err) } diff --git a/tools/target_migration.bzl b/tools/target_migration.bzl deleted file mode 100644 index 1df8c88e91..0000000000 --- a/tools/target_migration.bzl +++ /dev/null @@ -1,8 +0,0 @@ -def moved_targets(targets, new_package): - for target in targets: - native.alias( - name = target[1:], - actual = new_package + target, - deprecation = "This target has moved to %s%s" % (new_package, target), - tags = ["manual"], - ) diff --git a/validator/BUILD.bazel b/validator/BUILD.bazel deleted file mode 100644 index a41f51aef8..0000000000 --- a/validator/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -load("//tools:target_migration.bzl", "moved_targets") - -moved_targets( - [ - ":push_images_debug", - ":push_images_alpine", - ":push_images", - ":image_bundle_debug", - ":image_debug", - ":image_bundle_alpine", - ":image_bundle", - ":image_with_creation_time", - ":image_alpine", - ":image", - ":go_default_test", - ":validator", - ], - "//cmd/validator", -)