diff --git a/api/client/builder/client_test.go b/api/client/builder/client_test.go index fd4b898f98..7c82433f30 100644 --- a/api/client/builder/client_test.go +++ b/api/client/builder/client_test.go @@ -876,7 +876,7 @@ func testSignedBlindedBeaconBlockAndBlobsDeneb(t *testing.T) *eth.SignedBlindedB }, SyncAggregate: ð.SyncAggregate{ SyncCommitteeSignature: make([]byte, 96), - SyncCommitteeBits: bitfield.Bitvector512(ezDecode(t, "0x6451e9f951ebf05edc01de67e593484b672877054f055903ff0df1a1a945cf30ca26bb4d4b154f94a1bc776bcf5d0efb3603e1f9b8ee2499ccdcfe2a18cef458")), + SyncCommitteeBits: ezDecode(t, "0x6451e9f951ebf05edc01de67e593484b672877054f055903ff0df1a1a945cf30ca26bb4d4b154f94a1bc776bcf5d0efb3603e1f9b8ee2499ccdcfe2a18cef458"), }, ExecutionPayloadHeader: &v1.ExecutionPayloadHeaderDeneb{ ParentHash: ezDecode(t, "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"), diff --git a/beacon-chain/blockchain/lightclient.go b/beacon-chain/blockchain/lightclient.go index cac672d294..a4c6291de0 100644 --- a/beacon-chain/blockchain/lightclient.go +++ b/beacon-chain/blockchain/lightclient.go @@ -8,7 +8,6 @@ import ( "github.com/prysmaticlabs/prysm/v4/beacon-chain/state" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/interfaces" - types "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" ethpbv1 "github.com/prysmaticlabs/prysm/v4/proto/eth/v1" ethpbv2 "github.com/prysmaticlabs/prysm/v4/proto/eth/v2" @@ -63,7 +62,7 @@ func NewLightClientOptimisticUpdateFromBeaconState( attestedState state.BeaconState) (*ethpbv2.LightClientUpdate, error) { // assert compute_epoch_at_slot(attested_state.slot) >= ALTAIR_FORK_EPOCH attestedEpoch := slots.ToEpoch(attestedState.Slot()) - if attestedEpoch < types.Epoch(params.BeaconConfig().AltairForkEpoch) { + if attestedEpoch < params.BeaconConfig().AltairForkEpoch { return nil, fmt.Errorf("invalid attested epoch %d", attestedEpoch) } diff --git a/beacon-chain/db/kv/blob_test.go b/beacon-chain/db/kv/blob_test.go index a6705b09b2..4f8f846497 100644 --- a/beacon-chain/db/kv/blob_test.go +++ b/beacon-chain/db/kv/blob_test.go @@ -91,7 +91,7 @@ func TestStore_BlobSidecars(t *testing.T) { db := setupDB(t) scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock) require.NoError(t, db.SaveBlobSidecar(ctx, scs)) - require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs)) + require.Equal(t, fieldparams.MaxBlobsPerBlock, len(scs)) // we'll request indices 0 and 3, so make a slice with those indices for comparison expect := make([]*ethpb.BlobSidecar, 2) @@ -108,7 +108,7 @@ func TestStore_BlobSidecars(t *testing.T) { db := setupDB(t) scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock) require.NoError(t, db.SaveBlobSidecar(ctx, scs)) - require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs)) + require.Equal(t, fieldparams.MaxBlobsPerBlock, len(scs)) got, err := db.BlobSidecarsByRoot(ctx, bytesutil.ToBytes32(scs[0].BlockRoot), uint64(len(scs))) require.ErrorIs(t, err, ErrNotFound) @@ -127,7 +127,7 @@ func TestStore_BlobSidecars(t *testing.T) { db := setupDB(t) scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock) require.NoError(t, db.SaveBlobSidecar(ctx, scs)) - require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs)) + require.Equal(t, fieldparams.MaxBlobsPerBlock, len(scs)) got, err := db.BlobSidecarsBySlot(ctx, scs[0].Slot) require.NoError(t, err) require.NoError(t, equalBlobSlices(scs, got)) @@ -147,7 +147,7 @@ func TestStore_BlobSidecars(t *testing.T) { db := setupDB(t) scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock) require.NoError(t, db.SaveBlobSidecar(ctx, scs)) - require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs)) + require.Equal(t, fieldparams.MaxBlobsPerBlock, len(scs)) // we'll request indices 0 and 3, so make a slice with those indices for comparison expect := make([]*ethpb.BlobSidecar, 2) @@ -165,7 +165,7 @@ func TestStore_BlobSidecars(t *testing.T) { db := setupDB(t) scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock) require.NoError(t, db.SaveBlobSidecar(ctx, scs)) - require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs)) + require.Equal(t, fieldparams.MaxBlobsPerBlock, len(scs)) got, err := db.BlobSidecarsBySlot(ctx, scs[0].Slot, uint64(len(scs))) require.ErrorIs(t, err, ErrNotFound) @@ -175,7 +175,7 @@ func TestStore_BlobSidecars(t *testing.T) { db := setupDB(t) scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock) require.NoError(t, db.SaveBlobSidecar(ctx, scs)) - require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs)) + require.Equal(t, fieldparams.MaxBlobsPerBlock, len(scs)) got, err := db.BlobSidecarsByRoot(ctx, bytesutil.ToBytes32(scs[0].BlockRoot)) require.NoError(t, err) require.NoError(t, equalBlobSlices(scs, got)) diff --git a/beacon-chain/rpc/eth/events/events.go b/beacon-chain/rpc/eth/events/events.go index d47d317ea8..4ff128e80a 100644 --- a/beacon-chain/rpc/eth/events/events.go +++ b/beacon-chain/rpc/eth/events/events.go @@ -291,7 +291,7 @@ func (s *Server) streamPayloadAttributes(stream ethpbservice.Events_StreamEvents return err } - t, err := slots.ToTime(uint64(headState.GenesisTime()), headState.Slot()) + t, err := slots.ToTime(headState.GenesisTime(), headState.Slot()) if err != nil { return err } diff --git a/beacon-chain/rpc/eth/shared/structs_blocks_conversions.go b/beacon-chain/rpc/eth/shared/structs_blocks_conversions.go index 45239595cd..63ecaba69d 100644 --- a/beacon-chain/rpc/eth/shared/structs_blocks_conversions.go +++ b/beacon-chain/rpc/eth/shared/structs_blocks_conversions.go @@ -3260,5 +3260,5 @@ func sszBytesToUint256String(b []byte) (string, error) { if !math.IsValidUint256(bi) { return "", fmt.Errorf("%s is not a valid Uint256", bi.String()) } - return string([]byte(bi.String())), nil + return string(bi.String()), nil } diff --git a/beacon-chain/rpc/eth/validator/handlers.go b/beacon-chain/rpc/eth/validator/handlers.go index 6efc8b27d4..c999072f9d 100644 --- a/beacon-chain/rpc/eth/validator/handlers.go +++ b/beacon-chain/rpc/eth/validator/handlers.go @@ -466,7 +466,7 @@ func (s *Server) ProduceSyncCommitteeContribution(w http.ResponseWriter, r *http http2.HandleError(w, "Invalid Beacon Block Root: "+err.Error(), http.StatusBadRequest) return } - contribution, ok := s.produceSyncCommitteeContribution(ctx, w, primitives.Slot(slot), index, []byte(blockRoot)) + contribution, ok := s.produceSyncCommitteeContribution(ctx, w, primitives.Slot(slot), index, blockRoot) if !ok { return } diff --git a/beacon-chain/state/state-native/setters_attestation.go b/beacon-chain/state/state-native/setters_attestation.go index 1a070623ed..187ffdae00 100644 --- a/beacon-chain/state/state-native/setters_attestation.go +++ b/beacon-chain/state/state-native/setters_attestation.go @@ -54,7 +54,7 @@ func (b *BeaconState) AppendCurrentEpochAttestations(val *ethpb.PendingAttestati } atts := b.currentEpochAttestations - max := uint64(params.BeaconConfig().CurrentEpochAttestationsLength()) + max := params.BeaconConfig().CurrentEpochAttestationsLength() if uint64(len(atts)) >= max { return fmt.Errorf("current pending attestation exceeds max length %d", max) } @@ -84,7 +84,7 @@ func (b *BeaconState) AppendPreviousEpochAttestations(val *ethpb.PendingAttestat } atts := b.previousEpochAttestations - max := uint64(params.BeaconConfig().PreviousEpochAttestationsLength()) + max := params.BeaconConfig().PreviousEpochAttestationsLength() if uint64(len(atts)) >= max { return fmt.Errorf("previous pending attestation exceeds max length %d", max) } diff --git a/beacon-chain/state/state-native/setters_attestation_test.go b/beacon-chain/state/state-native/setters_attestation_test.go index 19576dab20..75613fc3dd 100644 --- a/beacon-chain/state/state-native/setters_attestation_test.go +++ b/beacon-chain/state/state-native/setters_attestation_test.go @@ -79,7 +79,7 @@ func BenchmarkAppendPreviousEpochAttestations(b *testing.B) { st, err := InitializeFromProtoPhase0(ðpb.BeaconState{}) require.NoError(b, err) - max := uint64(params.BeaconConfig().PreviousEpochAttestationsLength()) + max := params.BeaconConfig().PreviousEpochAttestationsLength() if max < 2 { b.Fatalf("previous epoch attestations length is less than 2: %d", max) } diff --git a/beacon-chain/state/stateutil/field_root_attestation.go b/beacon-chain/state/stateutil/field_root_attestation.go index 4a2e636b8b..2ac08cc2df 100644 --- a/beacon-chain/state/stateutil/field_root_attestation.go +++ b/beacon-chain/state/stateutil/field_root_attestation.go @@ -18,7 +18,7 @@ func RootsArrayHashTreeRoot(vals [][]byte, length uint64) ([32]byte, error) { } func EpochAttestationsRoot(atts []*ethpb.PendingAttestation) ([32]byte, error) { - max := uint64(params.BeaconConfig().CurrentEpochAttestationsLength()) + max := params.BeaconConfig().CurrentEpochAttestationsLength() if uint64(len(atts)) > max { return [32]byte{}, fmt.Errorf("epoch attestation exceeds max length %d", max) } diff --git a/beacon-chain/sync/rpc_handler_test.go b/beacon-chain/sync/rpc_handler_test.go index 2ce2715c7d..5e29577a07 100644 --- a/beacon-chain/sync/rpc_handler_test.go +++ b/beacon-chain/sync/rpc_handler_test.go @@ -41,8 +41,8 @@ func (rt *rpcHandlerTest) testHandler(nh network.StreamHandler, rh rpcHandler, r defer w.Done() nh(stream) } - server.BHost.SetStreamHandler(protocol.ID(rt.topic), h) - stream, err := client.BHost.NewStream(ctx, server.BHost.ID(), protocol.ID(rt.topic)) + server.BHost.SetStreamHandler(rt.topic, h) + stream, err := client.BHost.NewStream(ctx, server.BHost.ID(), rt.topic) require.NoError(rt.t, err) err = rh(ctx, rhi, stream) diff --git a/beacon-chain/sync/service.go b/beacon-chain/sync/service.go index b299f92315..48ed16785a 100644 --- a/beacon-chain/sync/service.go +++ b/beacon-chain/sync/service.go @@ -13,7 +13,6 @@ import ( pubsub "github.com/libp2p/go-libp2p-pubsub" libp2pcore "github.com/libp2p/go-libp2p/core" "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/core/protocol" gcache "github.com/patrickmn/go-cache" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v4/async" @@ -208,7 +207,7 @@ func (s *Service) Stop() error { }() // Removing RPC Stream handlers. for _, p := range s.cfg.p2p.Host().Mux().Protocols() { - s.cfg.p2p.Host().RemoveStreamHandler(protocol.ID(p)) + s.cfg.p2p.Host().RemoveStreamHandler(p) } // Deregister Topic Subscribers. for _, t := range s.cfg.p2p.PubSub().GetTopics() { diff --git a/crypto/bls/signature_batch_test.go b/crypto/bls/signature_batch_test.go index 6c9df38363..bf54aa216a 100644 --- a/crypto/bls/signature_batch_test.go +++ b/crypto/bls/signature_batch_test.go @@ -704,7 +704,7 @@ func NewInvalidSignatureSet(t *testing.T, msgBody string, num int, throwErr bool func messageBytes(message string) [32]byte { var bytes [32]byte - copy(bytes[:], []byte(message)) + copy(bytes[:], message) return bytes } diff --git a/proto/eth/v2/custom.go b/proto/eth/v2/custom.go index 86132bd84e..9e7d97493f 100644 --- a/proto/eth/v2/custom.go +++ b/proto/eth/v2/custom.go @@ -23,7 +23,7 @@ func (x *SyncCommittee) Equals(other *SyncCommittee) bool { } func FloorLog2(x uint64) int { - return bits.Len64(uint64(x - 1)) + return bits.Len64(x - 1) } func isEmptyWithLength(bb [][]byte, length uint64) bool { diff --git a/testing/middleware/builder/builder.go b/testing/middleware/builder/builder.go index e9cc943986..0c827d4ca6 100644 --- a/testing/middleware/builder/builder.go +++ b/testing/middleware/builder/builder.go @@ -255,7 +255,7 @@ func (p *Builder) registerValidators(w http.ResponseWriter, req *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - p.validatorMap[string(r.Message.Pubkey)] = msg + p.validatorMap[r.Message.Pubkey] = msg } // TODO: Verify Signatures from validators w.WriteHeader(http.StatusOK)