diff --git a/beacon-chain/core/helpers/shuffle.go b/beacon-chain/core/helpers/shuffle.go index 99377fe527..a7fe0dbb93 100644 --- a/beacon-chain/core/helpers/shuffle.go +++ b/beacon-chain/core/helpers/shuffle.go @@ -83,8 +83,8 @@ func ComputeShuffledIndex(index uint64, indexCount uint64, seed [32]byte, shuffl // effectively un-shuffling the list. round = rounds - 1 } - buf := make([]byte, totalSize, totalSize) - posBuffer := make([]byte, 8, 8) + buf := make([]byte, totalSize) + posBuffer := make([]byte, 8) hashfunc := hashutil.CustomSHA256Hasher() // Seed is always the first 32 bytes of the hash input, we never have to change this part of the buffer. @@ -168,7 +168,7 @@ func innerShuffleList(input []uint64, seed [32]byte, shuffle bool) ([]uint64, er return input, nil } listSize := uint64(len(input)) - buf := make([]byte, totalSize, totalSize) + buf := make([]byte, totalSize) r := uint8(0) if !shuffle { r = rounds - 1 diff --git a/beacon-chain/core/helpers/shuffle_test.go b/beacon-chain/core/helpers/shuffle_test.go index 236189d2a4..193c9f30a1 100644 --- a/beacon-chain/core/helpers/shuffle_test.go +++ b/beacon-chain/core/helpers/shuffle_test.go @@ -110,7 +110,7 @@ func BenchmarkShuffleList(b *testing.B) { listSizes := []uint64{400000, 40000, 400} seed := [32]byte{123, 42} for _, listSize := range listSizes { - testIndices := make([]uint64, listSize, listSize) + testIndices := make([]uint64, listSize) for i := uint64(0); i < listSize; i++ { testIndices[i] = i } diff --git a/beacon-chain/core/helpers/spectest/shuffle_yaml_test.go b/beacon-chain/core/helpers/spectest/shuffle_yaml_test.go index 761e8ec86b..cf71b097fb 100644 --- a/beacon-chain/core/helpers/spectest/shuffle_yaml_test.go +++ b/beacon-chain/core/helpers/spectest/shuffle_yaml_test.go @@ -50,7 +50,7 @@ func runShuffleTest(testCase *ShuffleTestCase) error { } seed := common.BytesToHash(baseSeed) - testIndices := make([]uint64, testCase.Count, testCase.Count) + testIndices := make([]uint64, testCase.Count) for i := uint64(0); i < testCase.Count; i++ { testIndices[i] = i } diff --git a/beacon-chain/rpc/beacon/attestations_test.go b/beacon-chain/rpc/beacon/attestations_test.go index b5adc10332..312397fb17 100644 --- a/beacon-chain/rpc/beacon/attestations_test.go +++ b/beacon-chain/rpc/beacon/attestations_test.go @@ -521,7 +521,7 @@ func TestServer_ListAttestations_Pagination_DefaultPageSize(t *testing.T) { func TestServer_mapAttestationToTargetRoot(t *testing.T) { count := uint64(100) - atts := make([]*ethpb.Attestation, count, count) + atts := make([]*ethpb.Attestation, count) targetRoot1 := bytesutil.ToBytes32([]byte("root1")) targetRoot2 := bytesutil.ToBytes32([]byte("root2")) @@ -606,7 +606,7 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) { state, _ := testutil.DeterministicGenesisState(t, numValidators) // Next up we convert the test attestations to indexed form: - indexedAtts := make([]*ethpb.IndexedAttestation, len(atts)+len(atts2), len(atts)+len(atts2)) + indexedAtts := make([]*ethpb.IndexedAttestation, len(atts)+len(atts2)) for i := 0; i < len(atts); i++ { att := atts[i] committee, err := helpers.BeaconCommitteeFromState(state, att.Data.Slot, att.Data.CommitteeIndex) @@ -707,7 +707,7 @@ func TestServer_ListIndexedAttestations_OldEpoch(t *testing.T) { require.NoError(t, state.SetSlot(startSlot)) // Next up we convert the test attestations to indexed form: - indexedAtts := make([]*ethpb.IndexedAttestation, len(atts), len(atts)) + indexedAtts := make([]*ethpb.IndexedAttestation, len(atts)) for i := 0; i < len(atts); i++ { att := atts[i] committee, err := helpers.BeaconCommitteeFromState(state, att.Data.Slot, att.Data.CommitteeIndex) diff --git a/beacon-chain/state/stateutil/arrays.go b/beacon-chain/state/stateutil/arrays.go index d0bafb235f..2e0bd66b37 100644 --- a/beacon-chain/state/stateutil/arrays.go +++ b/beacon-chain/state/stateutil/arrays.go @@ -122,7 +122,7 @@ func merkleizeTrieLeaves(layers [][][32]byte, hashLayer [][32]byte, chunkBuffer := bytes.NewBuffer([]byte{}) chunkBuffer.Grow(64) for len(hashLayer) > 1 && i < len(layers) { - layer := make([][32]byte, len(hashLayer)/2, len(hashLayer)/2) + layer := make([][32]byte, len(hashLayer)/2) for j := 0; j < len(hashLayer); j += 2 { chunkBuffer.Write(hashLayer[j][:]) chunkBuffer.Write(hashLayer[j+1][:]) diff --git a/shared/htrutils/hashers.go b/shared/htrutils/hashers.go index b5b6f337a5..3b50fee0e5 100644 --- a/shared/htrutils/hashers.go +++ b/shared/htrutils/hashers.go @@ -46,7 +46,7 @@ func (h *HasherFunc) Combi(a [32]byte, b [32]byte) [32]byte { // MixIn works like Combi, but using an integer as the second input. func (h *HasherFunc) MixIn(a [32]byte, i uint64) [32]byte { copy(h.b[:32], a[:]) - copy(h.b[32:], make([]byte, 32, 32)) + copy(h.b[32:], make([]byte, 32)) binary.LittleEndian.PutUint64(h.b[32:], i) return h.Hash(h.b[:]) } diff --git a/shared/htrutils/merkleize.go b/shared/htrutils/merkleize.go index b1e6b895e1..e3286c3ede 100644 --- a/shared/htrutils/merkleize.go +++ b/shared/htrutils/merkleize.go @@ -83,7 +83,7 @@ func Merkleize(hasher Hasher, count uint64, limit uint64, leaf func(i uint64) [] } depth := GetDepth(count) limitDepth := GetDepth(limit) - tmp := make([][32]byte, limitDepth+1, limitDepth+1) + tmp := make([][32]byte, limitDepth+1) j := uint8(0) hArr := [32]byte{} @@ -148,7 +148,7 @@ func ConstructProof(hasher Hasher, count uint64, limit uint64, leaf func(i uint6 limitDepth := GetDepth(limit) branch = append(branch, trieutil.ZeroHashes[:limitDepth]...) - tmp := make([][32]byte, limitDepth+1, limitDepth+1) + tmp := make([][32]byte, limitDepth+1) j := uint8(0) hArr := [32]byte{} diff --git a/shared/trieutil/sparse_merkle.go b/shared/trieutil/sparse_merkle.go index 831760ae15..76951386c0 100644 --- a/shared/trieutil/sparse_merkle.go +++ b/shared/trieutil/sparse_merkle.go @@ -58,7 +58,7 @@ func GenerateTrieFromItems(items [][]byte, depth int) (*SparseMerkleTrie, error) if len(layers[i])%2 == 1 { layers[i] = append(layers[i], ZeroHashes[i][:]) } - updatedValues := make([][]byte, 0, 0) + updatedValues := make([][]byte, 0) for j := 0; j < len(layers[i]); j += 2 { concat := hashutil.Hash(append(layers[i][j], layers[i][j+1]...)) updatedValues = append(updatedValues, concat[:]) diff --git a/slasher/detection/attestations/mock_spanner.go b/slasher/detection/attestations/mock_spanner.go index 922ee9271a..ca52d3b466 100644 --- a/slasher/detection/attestations/mock_spanner.go +++ b/slasher/detection/attestations/mock_spanner.go @@ -64,7 +64,7 @@ func (s *MockSpanDetector) SpanForEpochByValidator(ctx context.Context, valIdx u // ValidatorSpansByEpoch returns a list of all validator spans in a given epoch. func (s *MockSpanDetector) ValidatorSpansByEpoch(ctx context.Context, epoch uint64) map[uint64]types.Span { - return make(map[uint64]types.Span, 0) + return make(map[uint64]types.Span) } // DeleteValidatorSpansByEpoch mocks the delete spans by epoch function.