diff --git a/beacon-chain/blockchain/head.go b/beacon-chain/blockchain/head.go index 6a478c61a3e..459ae20f8ad 100644 --- a/beacon-chain/blockchain/head.go +++ b/beacon-chain/blockchain/head.go @@ -244,7 +244,7 @@ func (s *Service) headBlock() block.SignedBeaconBlock { // It does a full copy on head state for immutability. // This is a lock free version. func (s *Service) headState(ctx context.Context) state.BeaconState { - ctx, span := trace.StartSpan(ctx, "blockChain.headState") + _, span := trace.StartSpan(ctx, "blockChain.headState") defer span.End() return s.head.state.Copy() diff --git a/beacon-chain/blockchain/process_attestation.go b/beacon-chain/blockchain/process_attestation.go index 992a4ca60ea..03b81926b3f 100644 --- a/beacon-chain/blockchain/process_attestation.go +++ b/beacon-chain/blockchain/process_attestation.go @@ -62,7 +62,7 @@ func (s *Service) onAttestation(ctx context.Context, a *ethpb.Attestation) error genesisTime := baseState.GenesisTime() // Verify attestation target is from current epoch or previous epoch. - if err := s.verifyAttTargetEpoch(ctx, genesisTime, uint64(time.Now().Unix()), tgt); err != nil { + if err := verifyAttTargetEpoch(ctx, genesisTime, uint64(time.Now().Unix()), tgt); err != nil { return err } diff --git a/beacon-chain/blockchain/process_attestation_helpers.go b/beacon-chain/blockchain/process_attestation_helpers.go index f892fcc02fd..20f81d2c316 100644 --- a/beacon-chain/blockchain/process_attestation_helpers.go +++ b/beacon-chain/blockchain/process_attestation_helpers.go @@ -61,7 +61,7 @@ func (s *Service) getAttPreState(ctx context.Context, c *ethpb.Checkpoint) (stat } // verifyAttTargetEpoch validates attestation is from the current or previous epoch. -func (s *Service) verifyAttTargetEpoch(_ context.Context, genesisTime, nowTime uint64, c *ethpb.Checkpoint) error { +func verifyAttTargetEpoch(_ context.Context, genesisTime, nowTime uint64, c *ethpb.Checkpoint) error { currentSlot := types.Slot((nowTime - genesisTime) / params.BeaconConfig().SecondsPerSlot) currentEpoch := slots.ToEpoch(currentSlot) var prevEpoch types.Epoch diff --git a/beacon-chain/blockchain/process_attestation_test.go b/beacon-chain/blockchain/process_attestation_test.go index 34c4db20d44..216f3188a23 100644 --- a/beacon-chain/blockchain/process_attestation_test.go +++ b/beacon-chain/blockchain/process_attestation_test.go @@ -266,34 +266,22 @@ func TestStore_UpdateCheckpointState(t *testing.T) { func TestAttEpoch_MatchPrevEpoch(t *testing.T) { ctx := context.Background() - opts := testServiceOptsNoDB() - service, err := NewService(ctx, opts...) - require.NoError(t, err) - nowTime := uint64(params.BeaconConfig().SlotsPerEpoch) * params.BeaconConfig().SecondsPerSlot - require.NoError(t, service.verifyAttTargetEpoch(ctx, 0, nowTime, ðpb.Checkpoint{Root: make([]byte, 32)})) + require.NoError(t, verifyAttTargetEpoch(ctx, 0, nowTime, ðpb.Checkpoint{Root: make([]byte, 32)})) } func TestAttEpoch_MatchCurrentEpoch(t *testing.T) { ctx := context.Background() - opts := testServiceOptsNoDB() - service, err := NewService(ctx, opts...) - require.NoError(t, err) - nowTime := uint64(params.BeaconConfig().SlotsPerEpoch) * params.BeaconConfig().SecondsPerSlot - require.NoError(t, service.verifyAttTargetEpoch(ctx, 0, nowTime, ðpb.Checkpoint{Epoch: 1})) + require.NoError(t, verifyAttTargetEpoch(ctx, 0, nowTime, ðpb.Checkpoint{Epoch: 1})) } func TestAttEpoch_NotMatch(t *testing.T) { ctx := context.Background() - opts := testServiceOptsNoDB() - service, err := NewService(ctx, opts...) - require.NoError(t, err) - nowTime := 2 * uint64(params.BeaconConfig().SlotsPerEpoch) * params.BeaconConfig().SecondsPerSlot - err = service.verifyAttTargetEpoch(ctx, 0, nowTime, ðpb.Checkpoint{Root: make([]byte, 32)}) + err := verifyAttTargetEpoch(ctx, 0, nowTime, ðpb.Checkpoint{Root: make([]byte, 32)}) assert.ErrorContains(t, "target epoch 0 does not match current epoch 2 or prev epoch 1", err) } diff --git a/beacon-chain/blockchain/state_balance_cache.go b/beacon-chain/blockchain/state_balance_cache.go index 1bbec57ad0f..700c0cc66ce 100644 --- a/beacon-chain/blockchain/state_balance_cache.go +++ b/beacon-chain/blockchain/state_balance_cache.go @@ -28,7 +28,7 @@ type stateByRooter interface { // to avoid nil pointer bugs when updating the cache in the read path (get()) func newStateBalanceCache(sg *stategen.State) (*stateBalanceCache, error) { if sg == nil { - return nil, errors.New("Can't initialize state balance cache without stategen") + return nil, errors.New("can't initialize state balance cache without stategen") } return &stateBalanceCache{stateGen: sg}, nil } diff --git a/beacon-chain/blockchain/testing/mock.go b/beacon-chain/blockchain/testing/mock.go index eff126d9696..f7bfbf308db 100644 --- a/beacon-chain/blockchain/testing/mock.go +++ b/beacon-chain/blockchain/testing/mock.go @@ -285,12 +285,12 @@ func (s *ChainService) PreviousJustifiedCheckpt() *ethpb.Checkpoint { } // ReceiveAttestation mocks ReceiveAttestation method in chain service. -func (s *ChainService) ReceiveAttestation(_ context.Context, _ *ethpb.Attestation) error { +func (_ *ChainService) ReceiveAttestation(_ context.Context, _ *ethpb.Attestation) error { return nil } // ReceiveAttestationNoPubsub mocks ReceiveAttestationNoPubsub method in chain service. -func (s *ChainService) ReceiveAttestationNoPubsub(context.Context, *ethpb.Attestation) error { +func (_ *ChainService) ReceiveAttestationNoPubsub(context.Context, *ethpb.Attestation) error { return nil } @@ -369,7 +369,7 @@ func (s *ChainService) HasInitSyncBlock(rt [32]byte) bool { } // HeadGenesisValidatorRoot mocks HeadGenesisValidatorRoot method in chain service. -func (s *ChainService) HeadGenesisValidatorRoot() [32]byte { +func (_ *ChainService) HeadGenesisValidatorRoot() [32]byte { return [32]byte{} } @@ -379,7 +379,7 @@ func (s *ChainService) VerifyBlkDescendant(_ context.Context, _ [32]byte) error } // VerifyLmdFfgConsistency mocks VerifyLmdFfgConsistency and always returns nil. -func (s *ChainService) VerifyLmdFfgConsistency(_ context.Context, a *ethpb.Attestation) error { +func (_ *ChainService) VerifyLmdFfgConsistency(_ context.Context, a *ethpb.Attestation) error { if !bytes.Equal(a.Data.BeaconBlockRoot, a.Data.Target.Root) { return errors.New("LMD and FFG miss matched") } @@ -395,7 +395,7 @@ func (s *ChainService) VerifyFinalizedConsistency(_ context.Context, r []byte) e } // ChainHeads mocks ChainHeads and always return nil. -func (s *ChainService) ChainHeads() ([][32]byte, []types.Slot) { +func (_ *ChainService) ChainHeads() ([][32]byte, []types.Slot) { return [][32]byte{ bytesutil.ToBytes32(bytesutil.PadTo([]byte("foo"), 32)), bytesutil.ToBytes32(bytesutil.PadTo([]byte("bar"), 32)), @@ -404,7 +404,7 @@ func (s *ChainService) ChainHeads() ([][32]byte, []types.Slot) { } // HeadPublicKeyToValidatorIndex mocks HeadPublicKeyToValidatorIndex and always return 0 and true. -func (s *ChainService) HeadPublicKeyToValidatorIndex(_ context.Context, _ [48]byte) (types.ValidatorIndex, bool) { +func (_ *ChainService) HeadPublicKeyToValidatorIndex(_ context.Context, _ [48]byte) (types.ValidatorIndex, bool) { return 0, true } diff --git a/beacon-chain/cache/depositcache/deposits_cache.go b/beacon-chain/cache/depositcache/deposits_cache.go index 31a078c788b..86668cdd265 100644 --- a/beacon-chain/cache/depositcache/deposits_cache.go +++ b/beacon-chain/cache/depositcache/deposits_cache.go @@ -17,7 +17,6 @@ import ( "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/container/trie" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - dbpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/sirupsen/logrus" "go.opencensus.io/trace" @@ -50,10 +49,10 @@ type FinalizedDeposits struct { // stores all the deposit related data that is required by the beacon-node. type DepositCache struct { // Beacon chain deposits in memory. - pendingDeposits []*dbpb.DepositContainer - deposits []*dbpb.DepositContainer + pendingDeposits []*ethpb.DepositContainer + deposits []*ethpb.DepositContainer finalizedDeposits *FinalizedDeposits - depositsByKey map[[48]byte][]*dbpb.DepositContainer + depositsByKey map[[48]byte][]*ethpb.DepositContainer depositsLock sync.RWMutex } @@ -67,8 +66,8 @@ func New() (*DepositCache, error) { // finalizedDeposits.MerkleTrieIndex is initialized to -1 because it represents the index of the last trie item. // Inserting the first item into the trie will set the value of the index to 0. return &DepositCache{ - pendingDeposits: []*dbpb.DepositContainer{}, - deposits: []*dbpb.DepositContainer{}, + pendingDeposits: []*ethpb.DepositContainer{}, + deposits: []*ethpb.DepositContainer{}, depositsByKey: map[[48]byte][]*ethpb.DepositContainer{}, finalizedDeposits: &FinalizedDeposits{Deposits: finalizedDepositsTrie, MerkleTrieIndex: -1}, }, nil @@ -77,7 +76,7 @@ func New() (*DepositCache, error) { // InsertDeposit into the database. If deposit or block number are nil // then this method does nothing. func (dc *DepositCache) InsertDeposit(ctx context.Context, d *ethpb.Deposit, blockNum uint64, index int64, depositRoot [32]byte) error { - ctx, span := trace.StartSpan(ctx, "DepositsCache.InsertDeposit") + _, span := trace.StartSpan(ctx, "DepositsCache.InsertDeposit") defer span.End() if d == nil { log.WithFields(logrus.Fields{ @@ -96,9 +95,9 @@ func (dc *DepositCache) InsertDeposit(ctx context.Context, d *ethpb.Deposit, blo } // Keep the slice sorted on insertion in order to avoid costly sorting on retrieval. heightIdx := sort.Search(len(dc.deposits), func(i int) bool { return dc.deposits[i].Index >= index }) - depCtr := &dbpb.DepositContainer{Deposit: d, Eth1BlockHeight: blockNum, DepositRoot: depositRoot[:], Index: index} + depCtr := ðpb.DepositContainer{Deposit: d, Eth1BlockHeight: blockNum, DepositRoot: depositRoot[:], Index: index} newDeposits := append( - []*dbpb.DepositContainer{depCtr}, + []*ethpb.DepositContainer{depCtr}, dc.deposits[heightIdx:]...) dc.deposits = append(dc.deposits[:heightIdx], newDeposits...) // Append the deposit to our map, in the event no deposits @@ -110,8 +109,8 @@ func (dc *DepositCache) InsertDeposit(ctx context.Context, d *ethpb.Deposit, blo } // InsertDepositContainers inserts a set of deposit containers into our deposit cache. -func (dc *DepositCache) InsertDepositContainers(ctx context.Context, ctrs []*dbpb.DepositContainer) { - ctx, span := trace.StartSpan(ctx, "DepositsCache.InsertDepositContainers") +func (dc *DepositCache) InsertDepositContainers(ctx context.Context, ctrs []*ethpb.DepositContainer) { + _, span := trace.StartSpan(ctx, "DepositsCache.InsertDepositContainers") defer span.End() dc.depositsLock.Lock() defer dc.depositsLock.Unlock() @@ -130,7 +129,7 @@ func (dc *DepositCache) InsertDepositContainers(ctx context.Context, ctrs []*dbp // InsertFinalizedDeposits inserts deposits up to eth1DepositIndex (inclusive) into the finalized deposits cache. func (dc *DepositCache) InsertFinalizedDeposits(ctx context.Context, eth1DepositIndex int64) { - ctx, span := trace.StartSpan(ctx, "DepositsCache.InsertFinalizedDeposits") + _, span := trace.StartSpan(ctx, "DepositsCache.InsertFinalizedDeposits") defer span.End() dc.depositsLock.Lock() defer dc.depositsLock.Unlock() @@ -163,8 +162,8 @@ func (dc *DepositCache) InsertFinalizedDeposits(ctx context.Context, eth1Deposit } // AllDepositContainers returns all historical deposit containers. -func (dc *DepositCache) AllDepositContainers(ctx context.Context) []*dbpb.DepositContainer { - ctx, span := trace.StartSpan(ctx, "DepositsCache.AllDepositContainers") +func (dc *DepositCache) AllDepositContainers(ctx context.Context) []*ethpb.DepositContainer { + _, span := trace.StartSpan(ctx, "DepositsCache.AllDepositContainers") defer span.End() dc.depositsLock.RLock() defer dc.depositsLock.RUnlock() @@ -175,7 +174,7 @@ func (dc *DepositCache) AllDepositContainers(ctx context.Context) []*dbpb.Deposi // AllDeposits returns a list of historical deposits until the given block number // (inclusive). If no block is specified then this method returns all historical deposits. func (dc *DepositCache) AllDeposits(ctx context.Context, untilBlk *big.Int) []*ethpb.Deposit { - ctx, span := trace.StartSpan(ctx, "DepositsCache.AllDeposits") + _, span := trace.StartSpan(ctx, "DepositsCache.AllDeposits") defer span.End() dc.depositsLock.RLock() defer dc.depositsLock.RUnlock() @@ -192,7 +191,7 @@ func (dc *DepositCache) AllDeposits(ctx context.Context, untilBlk *big.Int) []*e // DepositsNumberAndRootAtHeight returns number of deposits made up to blockheight and the // root that corresponds to the latest deposit at that blockheight. func (dc *DepositCache) DepositsNumberAndRootAtHeight(ctx context.Context, blockHeight *big.Int) (uint64, [32]byte) { - ctx, span := trace.StartSpan(ctx, "DepositsCache.DepositsNumberAndRootAtHeight") + _, span := trace.StartSpan(ctx, "DepositsCache.DepositsNumberAndRootAtHeight") defer span.End() dc.depositsLock.RLock() defer dc.depositsLock.RUnlock() @@ -208,7 +207,7 @@ func (dc *DepositCache) DepositsNumberAndRootAtHeight(ctx context.Context, block // DepositByPubkey looks through historical deposits and finds one which contains // a certain public key within its deposit data. func (dc *DepositCache) DepositByPubkey(ctx context.Context, pubKey []byte) (*ethpb.Deposit, *big.Int) { - ctx, span := trace.StartSpan(ctx, "DepositsCache.DepositByPubkey") + _, span := trace.StartSpan(ctx, "DepositsCache.DepositByPubkey") defer span.End() dc.depositsLock.RLock() defer dc.depositsLock.RUnlock() @@ -229,7 +228,7 @@ func (dc *DepositCache) DepositByPubkey(ctx context.Context, pubKey []byte) (*et // FinalizedDeposits returns the finalized deposits trie. func (dc *DepositCache) FinalizedDeposits(ctx context.Context) *FinalizedDeposits { - ctx, span := trace.StartSpan(ctx, "DepositsCache.FinalizedDeposits") + _, span := trace.StartSpan(ctx, "DepositsCache.FinalizedDeposits") defer span.End() dc.depositsLock.RLock() defer dc.depositsLock.RUnlock() diff --git a/beacon-chain/cache/depositcache/deposits_cache_test.go b/beacon-chain/cache/depositcache/deposits_cache_test.go index 18720bb4da7..e281f563bbf 100644 --- a/beacon-chain/cache/depositcache/deposits_cache_test.go +++ b/beacon-chain/cache/depositcache/deposits_cache_test.go @@ -10,7 +10,6 @@ import ( "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/container/trie" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - dbpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -44,31 +43,31 @@ func TestInsertDeposit_MaintainsSortedOrderByIndex(t *testing.T) { }{ { blkNum: 0, - deposit: ðpb.Deposit{Data: &dbpb.Deposit_Data{PublicKey: []byte{'A'}}}, + deposit: ðpb.Deposit{Data: ðpb.Deposit_Data{PublicKey: []byte{'A'}}}, index: 0, expectedErr: "", }, { blkNum: 0, - deposit: ðpb.Deposit{Data: &dbpb.Deposit_Data{PublicKey: []byte{'B'}}}, + deposit: ðpb.Deposit{Data: ðpb.Deposit_Data{PublicKey: []byte{'B'}}}, index: 3, expectedErr: "wanted deposit with index 1 to be inserted but received 3", }, { blkNum: 0, - deposit: ðpb.Deposit{Data: &dbpb.Deposit_Data{PublicKey: []byte{'C'}}}, + deposit: ðpb.Deposit{Data: ðpb.Deposit_Data{PublicKey: []byte{'C'}}}, index: 1, expectedErr: "", }, { blkNum: 0, - deposit: ðpb.Deposit{Data: &dbpb.Deposit_Data{PublicKey: []byte{'D'}}}, + deposit: ðpb.Deposit{Data: ðpb.Deposit_Data{PublicKey: []byte{'D'}}}, index: 4, expectedErr: "wanted deposit with index 2 to be inserted but received 4", }, { blkNum: 0, - deposit: ðpb.Deposit{Data: &dbpb.Deposit_Data{PublicKey: []byte{'E'}}}, + deposit: ðpb.Deposit{Data: ðpb.Deposit_Data{PublicKey: []byte{'E'}}}, index: 2, expectedErr: "", }, @@ -93,7 +92,7 @@ func TestAllDeposits_ReturnsAllDeposits(t *testing.T) { dc, err := New() require.NoError(t, err) - deposits := []*dbpb.DepositContainer{ + deposits := []*ethpb.DepositContainer{ { Eth1BlockHeight: 10, Deposit: ðpb.Deposit{}, @@ -133,7 +132,7 @@ func TestAllDeposits_FiltersDepositUpToAndIncludingBlockNumber(t *testing.T) { dc, err := New() require.NoError(t, err) - deposits := []*dbpb.DepositContainer{ + deposits := []*ethpb.DepositContainer{ { Eth1BlockHeight: 10, Deposit: ðpb.Deposit{}, @@ -174,7 +173,7 @@ func TestDepositsNumberAndRootAtHeight(t *testing.T) { t.Run("requesting_last_item_works", func(t *testing.T) { dc, err := New() require.NoError(t, err) - dc.deposits = []*dbpb.DepositContainer{ + dc.deposits = []*ethpb.DepositContainer{ { Eth1BlockHeight: 10, Index: 0, @@ -205,7 +204,7 @@ func TestDepositsNumberAndRootAtHeight(t *testing.T) { dc, err := New() require.NoError(t, err) - dc.deposits = []*dbpb.DepositContainer{ + dc.deposits = []*ethpb.DepositContainer{ { Eth1BlockHeight: 10, Index: 0, @@ -221,7 +220,7 @@ func TestDepositsNumberAndRootAtHeight(t *testing.T) { dc, err := New() require.NoError(t, err) - dc.deposits = []*dbpb.DepositContainer{ + dc.deposits = []*ethpb.DepositContainer{ { Eth1BlockHeight: 8, Index: 0, @@ -247,7 +246,7 @@ func TestDepositsNumberAndRootAtHeight(t *testing.T) { dc, err := New() require.NoError(t, err) - dc.deposits = []*dbpb.DepositContainer{ + dc.deposits = []*ethpb.DepositContainer{ { Eth1BlockHeight: 8, Index: 0, @@ -263,7 +262,7 @@ func TestDepositsNumberAndRootAtHeight(t *testing.T) { dc, err := New() require.NoError(t, err) - dc.deposits = []*dbpb.DepositContainer{ + dc.deposits = []*ethpb.DepositContainer{ { Eth1BlockHeight: 8, Index: 0, @@ -279,7 +278,7 @@ func TestDepositsNumberAndRootAtHeight(t *testing.T) { dc, err := New() require.NoError(t, err) - dc.deposits = []*dbpb.DepositContainer{ + dc.deposits = []*ethpb.DepositContainer{ { Eth1BlockHeight: 8, Index: 0, @@ -316,7 +315,7 @@ func TestDepositsNumberAndRootAtHeight(t *testing.T) { func TestDepositByPubkey_ReturnsFirstMatchingDeposit(t *testing.T) { dc, err := New() require.NoError(t, err) - ctrs := []*dbpb.DepositContainer{ + ctrs := []*ethpb.DepositContainer{ { Eth1BlockHeight: 9, Deposit: ðpb.Deposit{ @@ -374,7 +373,7 @@ func TestFinalizedDeposits_DepositsCachedCorrectly(t *testing.T) { dc, err := New() require.NoError(t, err) - finalizedDeposits := []*dbpb.DepositContainer{ + finalizedDeposits := []*ethpb.DepositContainer{ { Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ @@ -406,7 +405,7 @@ func TestFinalizedDeposits_DepositsCachedCorrectly(t *testing.T) { Index: 2, }, } - dc.deposits = append(finalizedDeposits, &dbpb.DepositContainer{ + dc.deposits = append(finalizedDeposits, ðpb.DepositContainer{ Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ PublicKey: bytesutil.PadTo([]byte{3}, 48), @@ -438,7 +437,7 @@ func TestFinalizedDeposits_UtilizesPreviouslyCachedDeposits(t *testing.T) { dc, err := New() require.NoError(t, err) - oldFinalizedDeposits := []*dbpb.DepositContainer{ + oldFinalizedDeposits := []*ethpb.DepositContainer{ { Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ @@ -460,7 +459,7 @@ func TestFinalizedDeposits_UtilizesPreviouslyCachedDeposits(t *testing.T) { Index: 1, }, } - newFinalizedDeposit := dbpb.DepositContainer{ + newFinalizedDeposit := ethpb.DepositContainer{ Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ PublicKey: bytesutil.PadTo([]byte{2}, 48), @@ -473,7 +472,7 @@ func TestFinalizedDeposits_UtilizesPreviouslyCachedDeposits(t *testing.T) { dc.deposits = oldFinalizedDeposits dc.InsertFinalizedDeposits(context.Background(), 1) // Artificially exclude old deposits so that they can only be retrieved from previously finalized deposits. - dc.deposits = []*dbpb.DepositContainer{&newFinalizedDeposit} + dc.deposits = []*ethpb.DepositContainer{&newFinalizedDeposit} dc.InsertFinalizedDeposits(context.Background(), 2) @@ -506,7 +505,7 @@ func TestNonFinalizedDeposits_ReturnsAllNonFinalizedDeposits(t *testing.T) { dc, err := New() require.NoError(t, err) - finalizedDeposits := []*dbpb.DepositContainer{ + finalizedDeposits := []*ethpb.DepositContainer{ { Eth1BlockHeight: 10, Deposit: ðpb.Deposit{ @@ -531,7 +530,7 @@ func TestNonFinalizedDeposits_ReturnsAllNonFinalizedDeposits(t *testing.T) { }, } dc.deposits = append(finalizedDeposits, - &dbpb.DepositContainer{ + ðpb.DepositContainer{ Eth1BlockHeight: 10, Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ @@ -542,7 +541,7 @@ func TestNonFinalizedDeposits_ReturnsAllNonFinalizedDeposits(t *testing.T) { }, Index: 2, }, - &dbpb.DepositContainer{ + ðpb.DepositContainer{ Eth1BlockHeight: 11, Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ @@ -563,7 +562,7 @@ func TestNonFinalizedDeposits_ReturnsNonFinalizedDepositsUpToBlockNumber(t *test dc, err := New() require.NoError(t, err) - finalizedDeposits := []*dbpb.DepositContainer{ + finalizedDeposits := []*ethpb.DepositContainer{ { Eth1BlockHeight: 10, Deposit: ðpb.Deposit{ @@ -588,7 +587,7 @@ func TestNonFinalizedDeposits_ReturnsNonFinalizedDepositsUpToBlockNumber(t *test }, } dc.deposits = append(finalizedDeposits, - &dbpb.DepositContainer{ + ðpb.DepositContainer{ Eth1BlockHeight: 10, Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ @@ -599,7 +598,7 @@ func TestNonFinalizedDeposits_ReturnsNonFinalizedDepositsUpToBlockNumber(t *test }, Index: 2, }, - &dbpb.DepositContainer{ + ðpb.DepositContainer{ Eth1BlockHeight: 11, Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ diff --git a/beacon-chain/cache/depositcache/pending_deposits.go b/beacon-chain/cache/depositcache/pending_deposits.go index a0f04544fa9..a317d2e2013 100644 --- a/beacon-chain/cache/depositcache/pending_deposits.go +++ b/beacon-chain/cache/depositcache/pending_deposits.go @@ -8,7 +8,6 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prysmaticlabs/prysm/crypto/hash" - dbpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/sirupsen/logrus" "go.opencensus.io/trace" @@ -24,13 +23,13 @@ var ( // PendingDepositsFetcher specifically outlines a struct that can retrieve deposits // which have not yet been included in the chain. type PendingDepositsFetcher interface { - PendingContainers(ctx context.Context, untilBlk *big.Int) []*dbpb.DepositContainer + PendingContainers(ctx context.Context, untilBlk *big.Int) []*ethpb.DepositContainer } // InsertPendingDeposit into the database. If deposit or block number are nil // then this method does nothing. func (dc *DepositCache) InsertPendingDeposit(ctx context.Context, d *ethpb.Deposit, blockNum uint64, index int64, depositRoot [32]byte) { - ctx, span := trace.StartSpan(ctx, "DepositsCache.InsertPendingDeposit") + _, span := trace.StartSpan(ctx, "DepositsCache.InsertPendingDeposit") defer span.End() if d == nil { log.WithFields(logrus.Fields{ @@ -42,7 +41,7 @@ func (dc *DepositCache) InsertPendingDeposit(ctx context.Context, d *ethpb.Depos dc.depositsLock.Lock() defer dc.depositsLock.Unlock() dc.pendingDeposits = append(dc.pendingDeposits, - &dbpb.DepositContainer{Deposit: d, Eth1BlockHeight: blockNum, Index: index, DepositRoot: depositRoot[:]}) + ðpb.DepositContainer{Deposit: d, Eth1BlockHeight: blockNum, Index: index, DepositRoot: depositRoot[:]}) pendingDepositsCount.Inc() span.AddAttributes(trace.Int64Attribute("count", int64(len(dc.pendingDeposits)))) } @@ -66,13 +65,13 @@ func (dc *DepositCache) PendingDeposits(ctx context.Context, untilBlk *big.Int) // PendingContainers returns a list of deposit containers until the given block number // (inclusive). -func (dc *DepositCache) PendingContainers(ctx context.Context, untilBlk *big.Int) []*dbpb.DepositContainer { - ctx, span := trace.StartSpan(ctx, "DepositsCache.PendingDeposits") +func (dc *DepositCache) PendingContainers(ctx context.Context, untilBlk *big.Int) []*ethpb.DepositContainer { + _, span := trace.StartSpan(ctx, "DepositsCache.PendingDeposits") defer span.End() dc.depositsLock.RLock() defer dc.depositsLock.RUnlock() - var depositCntrs []*dbpb.DepositContainer + var depositCntrs []*ethpb.DepositContainer for _, ctnr := range dc.pendingDeposits { if untilBlk == nil || untilBlk.Uint64() >= ctnr.Eth1BlockHeight { depositCntrs = append(depositCntrs, ctnr) @@ -91,7 +90,7 @@ func (dc *DepositCache) PendingContainers(ctx context.Context, untilBlk *big.Int // RemovePendingDeposit from the database. The deposit is indexed by the // Index. This method does nothing if deposit ptr is nil. func (dc *DepositCache) RemovePendingDeposit(ctx context.Context, d *ethpb.Deposit) { - ctx, span := trace.StartSpan(ctx, "DepositsCache.RemovePendingDeposit") + _, span := trace.StartSpan(ctx, "DepositsCache.RemovePendingDeposit") defer span.End() if d == nil { @@ -129,7 +128,7 @@ func (dc *DepositCache) RemovePendingDeposit(ctx context.Context, d *ethpb.Depos // PrunePendingDeposits removes any deposit which is older than the given deposit merkle tree index. func (dc *DepositCache) PrunePendingDeposits(ctx context.Context, merkleTreeIndex int64) { - ctx, span := trace.StartSpan(ctx, "DepositsCache.PrunePendingDeposits") + _, span := trace.StartSpan(ctx, "DepositsCache.PrunePendingDeposits") defer span.End() if merkleTreeIndex == 0 { @@ -140,7 +139,7 @@ func (dc *DepositCache) PrunePendingDeposits(ctx context.Context, merkleTreeInde dc.depositsLock.Lock() defer dc.depositsLock.Unlock() - var cleanDeposits []*dbpb.DepositContainer + var cleanDeposits []*ethpb.DepositContainer for _, dp := range dc.pendingDeposits { if dp.Index >= merkleTreeIndex { cleanDeposits = append(cleanDeposits, dp) diff --git a/beacon-chain/cache/depositcache/pending_deposits_test.go b/beacon-chain/cache/depositcache/pending_deposits_test.go index ea874f47674..0da07990941 100644 --- a/beacon-chain/cache/depositcache/pending_deposits_test.go +++ b/beacon-chain/cache/depositcache/pending_deposits_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - dbpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/assert" "google.golang.org/protobuf/proto" @@ -42,7 +41,7 @@ func TestRemovePendingDeposit_OK(t *testing.T) { } depToRemove := ðpb.Deposit{Proof: proof1, Data: data} otherDep := ðpb.Deposit{Proof: proof2, Data: data} - db.pendingDeposits = []*dbpb.DepositContainer{ + db.pendingDeposits = []*ethpb.DepositContainer{ {Deposit: depToRemove, Index: 1}, {Deposit: otherDep, Index: 5}, } @@ -55,7 +54,7 @@ func TestRemovePendingDeposit_OK(t *testing.T) { func TestRemovePendingDeposit_IgnoresNilDeposit(t *testing.T) { dc := DepositCache{} - dc.pendingDeposits = []*dbpb.DepositContainer{{Deposit: ðpb.Deposit{}}} + dc.pendingDeposits = []*ethpb.DepositContainer{{Deposit: ðpb.Deposit{}}} dc.RemovePendingDeposit(context.Background(), nil /*deposit*/) assert.Equal(t, 1, len(dc.pendingDeposits), "Deposit unexpectedly removed") } @@ -79,7 +78,7 @@ func TestPendingDeposit_RoundTrip(t *testing.T) { func TestPendingDeposits_OK(t *testing.T) { dc := DepositCache{} - dc.pendingDeposits = []*dbpb.DepositContainer{ + dc.pendingDeposits = []*ethpb.DepositContainer{ {Eth1BlockHeight: 2, Deposit: ðpb.Deposit{Proof: [][]byte{[]byte("A")}}}, {Eth1BlockHeight: 4, Deposit: ðpb.Deposit{Proof: [][]byte{[]byte("B")}}}, {Eth1BlockHeight: 6, Deposit: ðpb.Deposit{Proof: [][]byte{[]byte("c")}}}, @@ -99,7 +98,7 @@ func TestPendingDeposits_OK(t *testing.T) { func TestPrunePendingDeposits_ZeroMerkleIndex(t *testing.T) { dc := DepositCache{} - dc.pendingDeposits = []*dbpb.DepositContainer{ + dc.pendingDeposits = []*ethpb.DepositContainer{ {Eth1BlockHeight: 2, Index: 2}, {Eth1BlockHeight: 4, Index: 4}, {Eth1BlockHeight: 6, Index: 6}, @@ -109,7 +108,7 @@ func TestPrunePendingDeposits_ZeroMerkleIndex(t *testing.T) { } dc.PrunePendingDeposits(context.Background(), 0) - expected := []*dbpb.DepositContainer{ + expected := []*ethpb.DepositContainer{ {Eth1BlockHeight: 2, Index: 2}, {Eth1BlockHeight: 4, Index: 4}, {Eth1BlockHeight: 6, Index: 6}, @@ -123,7 +122,7 @@ func TestPrunePendingDeposits_ZeroMerkleIndex(t *testing.T) { func TestPrunePendingDeposits_OK(t *testing.T) { dc := DepositCache{} - dc.pendingDeposits = []*dbpb.DepositContainer{ + dc.pendingDeposits = []*ethpb.DepositContainer{ {Eth1BlockHeight: 2, Index: 2}, {Eth1BlockHeight: 4, Index: 4}, {Eth1BlockHeight: 6, Index: 6}, @@ -133,7 +132,7 @@ func TestPrunePendingDeposits_OK(t *testing.T) { } dc.PrunePendingDeposits(context.Background(), 6) - expected := []*dbpb.DepositContainer{ + expected := []*ethpb.DepositContainer{ {Eth1BlockHeight: 6, Index: 6}, {Eth1BlockHeight: 8, Index: 8}, {Eth1BlockHeight: 10, Index: 10}, @@ -142,7 +141,7 @@ func TestPrunePendingDeposits_OK(t *testing.T) { assert.DeepEqual(t, expected, dc.pendingDeposits) - dc.pendingDeposits = []*dbpb.DepositContainer{ + dc.pendingDeposits = []*ethpb.DepositContainer{ {Eth1BlockHeight: 2, Index: 2}, {Eth1BlockHeight: 4, Index: 4}, {Eth1BlockHeight: 6, Index: 6}, @@ -152,7 +151,7 @@ func TestPrunePendingDeposits_OK(t *testing.T) { } dc.PrunePendingDeposits(context.Background(), 10) - expected = []*dbpb.DepositContainer{ + expected = []*ethpb.DepositContainer{ {Eth1BlockHeight: 10, Index: 10}, {Eth1BlockHeight: 12, Index: 12}, } diff --git a/beacon-chain/core/blocks/block_operations_fuzz_test.go b/beacon-chain/core/blocks/block_operations_fuzz_test.go index e2b76fbe214..e9479d1cb8e 100644 --- a/beacon-chain/core/blocks/block_operations_fuzz_test.go +++ b/beacon-chain/core/blocks/block_operations_fuzz_test.go @@ -9,7 +9,6 @@ import ( v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" "github.com/prysmaticlabs/prysm/config/params" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/testing/require" @@ -19,7 +18,7 @@ func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) ctx := context.Background() state := ðpb.BeaconState{} - att := ð.Attestation{} + att := ðpb.Attestation{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -34,7 +33,7 @@ func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) { func TestFuzzProcessBlockHeader_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - block := ð.SignedBeaconBlock{} + block := ðpb.SignedBeaconBlock{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -73,7 +72,7 @@ func TestFuzzverifyDepositDataSigningRoot_10000(_ *testing.T) { func TestFuzzProcessEth1DataInBlock_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - e := ð.Eth1Data{} + e := ðpb.Eth1Data{} state := &v1.BeaconState{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -87,8 +86,8 @@ func TestFuzzProcessEth1DataInBlock_10000(t *testing.T) { func TestFuzzareEth1DataEqual_10000(_ *testing.T) { fuzzer := fuzz.NewWithSeed(0) - eth1data := ð.Eth1Data{} - eth1data2 := ð.Eth1Data{} + eth1data := ðpb.Eth1Data{} + eth1data2 := ðpb.Eth1Data{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(eth1data) @@ -100,8 +99,8 @@ func TestFuzzareEth1DataEqual_10000(_ *testing.T) { func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - eth1data := ð.Eth1Data{} - var stateVotes []*eth.Eth1Data + eth1data := ðpb.Eth1Data{} + var stateVotes []*ethpb.Eth1Data for i := 0; i < 100000; i++ { fuzzer.Fuzz(eth1data) fuzzer.Fuzz(&stateVotes) @@ -118,7 +117,7 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) { func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - block := ð.BeaconBlock{} + block := ðpb.BeaconBlock{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -133,7 +132,7 @@ func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) { func TestFuzzProcessRandao_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - b := ð.SignedBeaconBlock{} + b := ðpb.SignedBeaconBlock{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -150,7 +149,7 @@ func TestFuzzProcessRandao_10000(t *testing.T) { func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - blockBody := ð.BeaconBlockBody{} + blockBody := ðpb.BeaconBlockBody{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -167,14 +166,14 @@ func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) { func TestFuzzProcessProposerSlashings_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - p := ð.ProposerSlashing{} + p := ðpb.ProposerSlashing{} ctx := context.Background() for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(p) s, err := v1.InitializeFromProtoUnsafe(state) require.NoError(t, err) - r, err := ProcessProposerSlashings(ctx, s, []*eth.ProposerSlashing{p}, v.SlashValidator) + r, err := ProcessProposerSlashings(ctx, s, []*ethpb.ProposerSlashing{p}, v.SlashValidator) if err != nil && r != nil { t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and slashing: %v", r, err, state, p) } @@ -184,7 +183,7 @@ func TestFuzzProcessProposerSlashings_10000(t *testing.T) { func TestFuzzVerifyProposerSlashing_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - proposerSlashing := ð.ProposerSlashing{} + proposerSlashing := ðpb.ProposerSlashing{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(proposerSlashing) @@ -198,14 +197,14 @@ func TestFuzzVerifyProposerSlashing_10000(t *testing.T) { func TestFuzzProcessAttesterSlashings_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - a := ð.AttesterSlashing{} + a := ðpb.AttesterSlashing{} ctx := context.Background() for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(a) s, err := v1.InitializeFromProtoUnsafe(state) require.NoError(t, err) - r, err := ProcessAttesterSlashings(ctx, s, []*eth.AttesterSlashing{a}, v.SlashValidator) + r, err := ProcessAttesterSlashings(ctx, s, []*ethpb.AttesterSlashing{a}, v.SlashValidator) if err != nil && r != nil { t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and slashing: %v", r, err, state, a) } @@ -215,7 +214,7 @@ func TestFuzzProcessAttesterSlashings_10000(t *testing.T) { func TestFuzzVerifyAttesterSlashing_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - attesterSlashing := ð.AttesterSlashing{} + attesterSlashing := ðpb.AttesterSlashing{} ctx := context.Background() for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -229,8 +228,8 @@ func TestFuzzVerifyAttesterSlashing_10000(t *testing.T) { func TestFuzzIsSlashableAttestationData_10000(_ *testing.T) { fuzzer := fuzz.NewWithSeed(0) - attestationData := ð.AttestationData{} - attestationData2 := ð.AttestationData{} + attestationData := ðpb.AttestationData{} + attestationData2 := ðpb.AttestationData{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(attestationData) @@ -241,7 +240,7 @@ func TestFuzzIsSlashableAttestationData_10000(_ *testing.T) { func TestFuzzslashableAttesterIndices_10000(_ *testing.T) { fuzzer := fuzz.NewWithSeed(0) - attesterSlashing := ð.AttesterSlashing{} + attesterSlashing := ðpb.AttesterSlashing{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(attesterSlashing) @@ -252,7 +251,7 @@ func TestFuzzslashableAttesterIndices_10000(_ *testing.T) { func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - b := ð.SignedBeaconBlock{} + b := ðpb.SignedBeaconBlock{} ctx := context.Background() for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -269,7 +268,7 @@ func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) { func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - idxAttestation := ð.IndexedAttestation{} + idxAttestation := ðpb.IndexedAttestation{} ctx := context.Background() for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -284,7 +283,7 @@ func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) { func TestFuzzVerifyAttestation_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - attestation := ð.Attestation{} + attestation := ðpb.Attestation{} ctx := context.Background() for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -299,7 +298,7 @@ func TestFuzzVerifyAttestation_10000(t *testing.T) { func TestFuzzProcessDeposits_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - deposits := make([]*eth.Deposit, 100) + deposits := make([]*ethpb.Deposit, 100) ctx := context.Background() for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -318,7 +317,7 @@ func TestFuzzProcessDeposits_10000(t *testing.T) { func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - deposit := ð.Deposit{} + deposit := ðpb.Deposit{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -326,7 +325,7 @@ func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) { fuzzer.Fuzz(deposit) s, err := v1.InitializeFromProtoUnsafe(state) require.NoError(t, err) - r, err := ProcessPreGenesisDeposits(ctx, s, []*eth.Deposit{deposit}) + r, err := ProcessPreGenesisDeposits(ctx, s, []*ethpb.Deposit{deposit}) if err != nil && r != nil { t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, deposit) } @@ -336,7 +335,7 @@ func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) { func TestFuzzProcessDeposit_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - deposit := ð.Deposit{} + deposit := ðpb.Deposit{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -353,7 +352,7 @@ func TestFuzzProcessDeposit_10000(t *testing.T) { func TestFuzzverifyDeposit_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - deposit := ð.Deposit{} + deposit := ðpb.Deposit{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(deposit) @@ -367,14 +366,14 @@ func TestFuzzverifyDeposit_10000(t *testing.T) { func TestFuzzProcessVoluntaryExits_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - e := ð.SignedVoluntaryExit{} + e := ðpb.SignedVoluntaryExit{} ctx := context.Background() for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(e) s, err := v1.InitializeFromProtoUnsafe(state) require.NoError(t, err) - r, err := ProcessVoluntaryExits(ctx, s, []*eth.SignedVoluntaryExit{e}) + r, err := ProcessVoluntaryExits(ctx, s, []*ethpb.SignedVoluntaryExit{e}) if err != nil && r != nil { t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and exit: %v", r, err, state, e) } @@ -384,13 +383,13 @@ func TestFuzzProcessVoluntaryExits_10000(t *testing.T) { func TestFuzzProcessVoluntaryExitsNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) state := ðpb.BeaconState{} - e := ð.SignedVoluntaryExit{} + e := ðpb.SignedVoluntaryExit{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(e) s, err := v1.InitializeFromProtoUnsafe(state) require.NoError(t, err) - r, err := ProcessVoluntaryExits(context.Background(), s, []*eth.SignedVoluntaryExit{e}) + r, err := ProcessVoluntaryExits(context.Background(), s, []*ethpb.SignedVoluntaryExit{e}) if err != nil && r != nil { t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, e) } @@ -399,7 +398,7 @@ func TestFuzzProcessVoluntaryExitsNoVerify_10000(t *testing.T) { func TestFuzzVerifyExit_10000(_ *testing.T) { fuzzer := fuzz.NewWithSeed(0) - ve := ð.SignedVoluntaryExit{} + ve := ðpb.SignedVoluntaryExit{} rawVal := ðpb.Validator{} fork := ðpb.Fork{} var slot types.Slot diff --git a/beacon-chain/core/epoch/precompute/new.go b/beacon-chain/core/epoch/precompute/new.go index 1186213e38b..a41d35c3b3c 100644 --- a/beacon-chain/core/epoch/precompute/new.go +++ b/beacon-chain/core/epoch/precompute/new.go @@ -18,7 +18,7 @@ import ( // pre computed instances of validators attesting records and total // balances attested in an epoch. func New(ctx context.Context, s state.BeaconState) ([]*Validator, *Balance, error) { - ctx, span := trace.StartSpan(ctx, "precomputeEpoch.New") + _, span := trace.StartSpan(ctx, "precomputeEpoch.New") defer span.End() pValidators := make([]*Validator, s.NumValidators()) diff --git a/beacon-chain/core/signing/signing_root_test.go b/beacon-chain/core/signing/signing_root_test.go index b6fe6b85386..193f61ed062 100644 --- a/beacon-chain/core/signing/signing_root_test.go +++ b/beacon-chain/core/signing/signing_root_test.go @@ -13,7 +13,6 @@ import ( "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/crypto/bls" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -51,7 +50,7 @@ func TestSigningRoot_ComputeDomainAndSign(t *testing.T) { tests := []struct { name string genState func(t *testing.T) (state.BeaconState, []bls.SecretKey) - genBlock func(t *testing.T, st state.BeaconState, keys []bls.SecretKey) *eth.SignedBeaconBlock + genBlock func(t *testing.T, st state.BeaconState, keys []bls.SecretKey) *ethpb.SignedBeaconBlock domainType [4]byte want []byte }{ @@ -62,7 +61,7 @@ func TestSigningRoot_ComputeDomainAndSign(t *testing.T) { require.NoError(t, beaconState.SetSlot(beaconState.Slot()+1)) return beaconState, privKeys }, - genBlock: func(t *testing.T, st state.BeaconState, keys []bls.SecretKey) *eth.SignedBeaconBlock { + genBlock: func(t *testing.T, st state.BeaconState, keys []bls.SecretKey) *ethpb.SignedBeaconBlock { block, err := util.GenerateFullBlock(st, keys, nil, 1) require.NoError(t, err) return block diff --git a/beacon-chain/db/iface/interface.go b/beacon-chain/db/iface/interface.go index 5fdd9d0a23a..1fda162bf08 100644 --- a/beacon-chain/db/iface/interface.go +++ b/beacon-chain/db/iface/interface.go @@ -13,9 +13,7 @@ import ( slashertypes "github.com/prysmaticlabs/prysm/beacon-chain/slasher/types" "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/monitoring/backup" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - v2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" ) @@ -40,8 +38,8 @@ type ReadOnlyDatabase interface { HasStateSummary(ctx context.Context, blockRoot [32]byte) bool HighestSlotStatesBelow(ctx context.Context, slot types.Slot) ([]state.ReadOnlyBeaconState, error) // Checkpoint operations. - JustifiedCheckpoint(ctx context.Context) (*eth.Checkpoint, error) - FinalizedCheckpoint(ctx context.Context) (*eth.Checkpoint, error) + JustifiedCheckpoint(ctx context.Context) (*ethpb.Checkpoint, error) + FinalizedCheckpoint(ctx context.Context) (*ethpb.Checkpoint, error) ArchivedPointRoot(ctx context.Context, slot types.Slot) [32]byte HasArchivedPoint(ctx context.Context, slot types.Slot) bool LastArchivedRoot(ctx context.Context) [32]byte @@ -49,7 +47,7 @@ type ReadOnlyDatabase interface { // Deposit contract related handlers. DepositContractAddress(ctx context.Context) ([]byte, error) // Powchain operations. - PowchainData(ctx context.Context) (*v2.ETH1ChainData, error) + PowchainData(ctx context.Context) (*ethpb.ETH1ChainData, error) } // NoHeadAccessDatabase defines a struct without access to chain head data. @@ -68,12 +66,12 @@ type NoHeadAccessDatabase interface { SaveStateSummary(ctx context.Context, summary *ethpb.StateSummary) error SaveStateSummaries(ctx context.Context, summaries []*ethpb.StateSummary) error // Checkpoint operations. - SaveJustifiedCheckpoint(ctx context.Context, checkpoint *eth.Checkpoint) error - SaveFinalizedCheckpoint(ctx context.Context, checkpoint *eth.Checkpoint) error + SaveJustifiedCheckpoint(ctx context.Context, checkpoint *ethpb.Checkpoint) error + SaveFinalizedCheckpoint(ctx context.Context, checkpoint *ethpb.Checkpoint) error // Deposit contract related handlers. SaveDepositContractAddress(ctx context.Context, addr common.Address) error // Powchain operations. - SavePowchainData(ctx context.Context, data *v2.ETH1ChainData) error + SavePowchainData(ctx context.Context, data *ethpb.ETH1ChainData) error // Run any required database migrations. RunMigrations(ctx context.Context) error @@ -127,7 +125,7 @@ type SlasherDatabase interface { ) ([][]uint16, []bool, error) CheckDoubleBlockProposals( ctx context.Context, proposals []*slashertypes.SignedBlockHeaderWrapper, - ) ([]*eth.ProposerSlashing, error) + ) ([]*ethpb.ProposerSlashing, error) PruneAttestationsAtEpoch( ctx context.Context, maxEpoch types.Epoch, ) (numPruned uint, err error) diff --git a/beacon-chain/db/kv/archived_point.go b/beacon-chain/db/kv/archived_point.go index 0593b8c44f3..5d77f575a5c 100644 --- a/beacon-chain/db/kv/archived_point.go +++ b/beacon-chain/db/kv/archived_point.go @@ -11,7 +11,7 @@ import ( // LastArchivedSlot from the db. func (s *Store) LastArchivedSlot(ctx context.Context) (types.Slot, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.LastArchivedSlot") + _, span := trace.StartSpan(ctx, "BeaconDB.LastArchivedSlot") defer span.End() var index types.Slot err := s.db.View(func(tx *bolt.Tx) error { @@ -26,7 +26,7 @@ func (s *Store) LastArchivedSlot(ctx context.Context) (types.Slot, error) { // LastArchivedRoot from the db. func (s *Store) LastArchivedRoot(ctx context.Context) [32]byte { - ctx, span := trace.StartSpan(ctx, "BeaconDB.LastArchivedRoot") + _, span := trace.StartSpan(ctx, "BeaconDB.LastArchivedRoot") defer span.End() var blockRoot []byte @@ -44,7 +44,7 @@ func (s *Store) LastArchivedRoot(ctx context.Context) [32]byte { // ArchivedPointRoot returns the block root of an archived point from the DB. // This is essential for cold state management and to restore a cold state. func (s *Store) ArchivedPointRoot(ctx context.Context, slot types.Slot) [32]byte { - ctx, span := trace.StartSpan(ctx, "BeaconDB.ArchivedPointRoot") + _, span := trace.StartSpan(ctx, "BeaconDB.ArchivedPointRoot") defer span.End() var blockRoot []byte @@ -61,7 +61,7 @@ func (s *Store) ArchivedPointRoot(ctx context.Context, slot types.Slot) [32]byte // HasArchivedPoint returns true if an archived point exists in DB. func (s *Store) HasArchivedPoint(ctx context.Context, slot types.Slot) bool { - ctx, span := trace.StartSpan(ctx, "BeaconDB.HasArchivedPoint") + _, span := trace.StartSpan(ctx, "BeaconDB.HasArchivedPoint") defer span.End() var exists bool if err := s.db.View(func(tx *bolt.Tx) error { diff --git a/beacon-chain/db/kv/blocks.go b/beacon-chain/db/kv/blocks.go index 536340b9207..6473399862f 100644 --- a/beacon-chain/db/kv/blocks.go +++ b/beacon-chain/db/kv/blocks.go @@ -125,7 +125,7 @@ func (s *Store) BlockRoots(ctx context.Context, f *filters.QueryFilter) ([][32]b // HasBlock checks if a block by root exists in the db. func (s *Store) HasBlock(ctx context.Context, blockRoot [32]byte) bool { - ctx, span := trace.StartSpan(ctx, "BeaconDB.HasBlock") + _, span := trace.StartSpan(ctx, "BeaconDB.HasBlock") defer span.End() if v, ok := s.blockCache.Get(string(blockRoot[:])); v != nil && ok { return true @@ -293,7 +293,7 @@ func (s *Store) SaveBlocks(ctx context.Context, blocks []block.SignedBeaconBlock // SaveHeadBlockRoot to the db. func (s *Store) SaveHeadBlockRoot(ctx context.Context, blockRoot [32]byte) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveHeadBlockRoot") + _, span := trace.StartSpan(ctx, "BeaconDB.SaveHeadBlockRoot") defer span.End() return s.db.Update(func(tx *bolt.Tx) error { hasStateSummary := s.hasStateSummaryBytes(tx, blockRoot) @@ -328,7 +328,7 @@ func (s *Store) GenesisBlock(ctx context.Context) (block.SignedBeaconBlock, erro // SaveGenesisBlockRoot to the db. func (s *Store) SaveGenesisBlockRoot(ctx context.Context, blockRoot [32]byte) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveGenesisBlockRoot") + _, span := trace.StartSpan(ctx, "BeaconDB.SaveGenesisBlockRoot") defer span.End() return s.db.Update(func(tx *bolt.Tx) error { bucket := tx.Bucket(blocksBucket) @@ -447,7 +447,7 @@ func blockRootsBySlotRange( bkt *bolt.Bucket, startSlotEncoded, endSlotEncoded, startEpochEncoded, endEpochEncoded, slotStepEncoded interface{}, ) ([][]byte, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.blockRootsBySlotRange") + _, span := trace.StartSpan(ctx, "BeaconDB.blockRootsBySlotRange") defer span.End() // Return nothing when all slot parameters are missing @@ -512,7 +512,7 @@ func blockRootsBySlotRange( // blockRootsBySlot retrieves the block roots by slot func blockRootsBySlot(ctx context.Context, tx *bolt.Tx, slot types.Slot) [][]byte { - ctx, span := trace.StartSpan(ctx, "BeaconDB.blockRootsBySlot") + _, span := trace.StartSpan(ctx, "BeaconDB.blockRootsBySlot") defer span.End() roots := make([][]byte, 0) @@ -532,7 +532,7 @@ func blockRootsBySlot(ctx context.Context, tx *bolt.Tx, slot types.Slot) [][]byt // a map of bolt DB index buckets corresponding to each particular key for indices for // data, such as (shard indices bucket -> shard 5). func createBlockIndicesFromBlock(ctx context.Context, block block.BeaconBlock) map[string][]byte { - ctx, span := trace.StartSpan(ctx, "BeaconDB.createBlockIndicesFromBlock") + _, span := trace.StartSpan(ctx, "BeaconDB.createBlockIndicesFromBlock") defer span.End() indicesByBucket := make(map[string][]byte) // Every index has a unique bucket for fast, binary-search @@ -560,7 +560,7 @@ func createBlockIndicesFromBlock(ctx context.Context, block block.BeaconBlock) m // objects. If a certain filter criterion does not apply to // blocks, an appropriate error is returned. func createBlockIndicesFromFilters(ctx context.Context, f *filters.QueryFilter) (map[string][]byte, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.createBlockIndicesFromFilters") + _, span := trace.StartSpan(ctx, "BeaconDB.createBlockIndicesFromFilters") defer span.End() indicesByBucket := make(map[string][]byte) for k, v := range f.Filters() { diff --git a/beacon-chain/db/kv/deposit_contract.go b/beacon-chain/db/kv/deposit_contract.go index caba31c704a..3e67b1925b4 100644 --- a/beacon-chain/db/kv/deposit_contract.go +++ b/beacon-chain/db/kv/deposit_contract.go @@ -12,7 +12,7 @@ import ( // DepositContractAddress returns contract address is the address of // the deposit contract on the proof of work chain. func (s *Store) DepositContractAddress(ctx context.Context) ([]byte, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.DepositContractAddress") + _, span := trace.StartSpan(ctx, "BeaconDB.DepositContractAddress") defer span.End() var addr []byte if err := s.db.View(func(tx *bolt.Tx) error { @@ -27,7 +27,7 @@ func (s *Store) DepositContractAddress(ctx context.Context) ([]byte, error) { // SaveDepositContractAddress to the db. It returns an error if an address has been previously saved. func (s *Store) SaveDepositContractAddress(ctx context.Context, addr common.Address) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.VerifyContractAddress") + _, span := trace.StartSpan(ctx, "BeaconDB.VerifyContractAddress") defer span.End() return s.db.Update(func(tx *bolt.Tx) error { diff --git a/beacon-chain/db/kv/encoding.go b/beacon-chain/db/kv/encoding.go index 2d156e4e020..cfcc348ca2c 100644 --- a/beacon-chain/db/kv/encoding.go +++ b/beacon-chain/db/kv/encoding.go @@ -13,7 +13,7 @@ import ( ) func decode(ctx context.Context, data []byte, dst proto.Message) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.decode") + _, span := trace.StartSpan(ctx, "BeaconDB.decode") defer span.End() data, err := snappy.Decode(nil, data) @@ -27,7 +27,7 @@ func decode(ctx context.Context, data []byte, dst proto.Message) error { } func encode(ctx context.Context, msg proto.Message) ([]byte, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.encode") + _, span := trace.StartSpan(ctx, "BeaconDB.encode") defer span.End() if msg == nil || reflect.ValueOf(msg).IsNil() { diff --git a/beacon-chain/db/kv/finalized_block_roots.go b/beacon-chain/db/kv/finalized_block_roots.go index 88ccc3852a1..04dc89e0c78 100644 --- a/beacon-chain/db/kv/finalized_block_roots.go +++ b/beacon-chain/db/kv/finalized_block_roots.go @@ -8,7 +8,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" "github.com/prysmaticlabs/prysm/encoding/bytesutil" "github.com/prysmaticlabs/prysm/monitoring/tracing" - dbpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" bolt "go.etcd.io/bbolt" @@ -90,7 +89,7 @@ func (s *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, chec } block := signedBlock.Block() - container := &dbpb.FinalizedBlockRootContainer{ + container := ðpb.FinalizedBlockRootContainer{ ParentRoot: block.ParentRoot(), ChildRoot: previousRoot, } @@ -107,7 +106,7 @@ func (s *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, chec // Found parent, loop exit condition. if parentBytes := bkt.Get(block.ParentRoot()); parentBytes != nil { - parent := &dbpb.FinalizedBlockRootContainer{} + parent := ðpb.FinalizedBlockRootContainer{} if err := decode(ctx, parentBytes, parent); err != nil { tracing.AnnotateError(span, err) return err @@ -160,7 +159,7 @@ func (s *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, chec // Note: beacon blocks from the latest finalized epoch return true, whether or not they are // considered canonical in the "head view" of the beacon node. func (s *Store) IsFinalizedBlock(ctx context.Context, blockRoot [32]byte) bool { - ctx, span := trace.StartSpan(ctx, "BeaconDB.IsFinalizedBlock") + _, span := trace.StartSpan(ctx, "BeaconDB.IsFinalizedBlock") defer span.End() var exists bool @@ -195,7 +194,7 @@ func (s *Store) FinalizedChildBlock(ctx context.Context, blockRoot [32]byte) (bl if bytes.Equal(blkBytes, containerFinalizedButNotCanonical) { return nil } - ctr := &dbpb.FinalizedBlockRootContainer{} + ctr := ðpb.FinalizedBlockRootContainer{} if err := decode(ctx, blkBytes, ctr); err != nil { tracing.AnnotateError(span, err) return err diff --git a/beacon-chain/db/kv/powchain.go b/beacon-chain/db/kv/powchain.go index b0907807842..76ddafa2141 100644 --- a/beacon-chain/db/kv/powchain.go +++ b/beacon-chain/db/kv/powchain.go @@ -13,7 +13,7 @@ import ( // SavePowchainData saves the pow chain data. func (s *Store) SavePowchainData(ctx context.Context, data *v2.ETH1ChainData) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.SavePowchainData") + _, span := trace.StartSpan(ctx, "BeaconDB.SavePowchainData") defer span.End() if data == nil { @@ -36,7 +36,7 @@ func (s *Store) SavePowchainData(ctx context.Context, data *v2.ETH1ChainData) er // PowchainData retrieves the powchain data. func (s *Store) PowchainData(ctx context.Context) (*v2.ETH1ChainData, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.PowchainData") + _, span := trace.StartSpan(ctx, "BeaconDB.PowchainData") defer span.End() var data *v2.ETH1ChainData diff --git a/beacon-chain/db/kv/state.go b/beacon-chain/db/kv/state.go index 311c5131ae3..6c49c9deeb5 100644 --- a/beacon-chain/db/kv/state.go +++ b/beacon-chain/db/kv/state.go @@ -275,7 +275,7 @@ func (s *Store) SaveStatesEfficient(ctx context.Context, states []state.ReadOnly // HasState checks if a state by root exists in the db. func (s *Store) HasState(ctx context.Context, blockRoot [32]byte) bool { - ctx, span := trace.StartSpan(ctx, "BeaconDB.HasState") + _, span := trace.StartSpan(ctx, "BeaconDB.HasState") defer span.End() hasState := false err := s.db.View(func(tx *bolt.Tx) error { @@ -513,7 +513,7 @@ func (s *Store) validatorEntries(ctx context.Context, blockRoot [32]byte) ([]*et // retrieves and assembles the state information from multiple buckets. func (s *Store) stateBytes(ctx context.Context, blockRoot [32]byte) ([]byte, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.stateBytes") + _, span := trace.StartSpan(ctx, "BeaconDB.stateBytes") defer span.End() var dst []byte err := s.db.View(func(tx *bolt.Tx) error { @@ -632,7 +632,7 @@ func (s *Store) HighestSlotStatesBelow(ctx context.Context, slot types.Slot) ([] // a map of bolt DB index buckets corresponding to each particular key for indices for // data, such as (shard indices bucket -> shard 5). func createStateIndicesFromStateSlot(ctx context.Context, slot types.Slot) map[string][]byte { - ctx, span := trace.StartSpan(ctx, "BeaconDB.createStateIndicesFromState") + _, span := trace.StartSpan(ctx, "BeaconDB.createStateIndicesFromState") defer span.End() indicesByBucket := make(map[string][]byte) // Every index has a unique bucket for fast, binary-search diff --git a/beacon-chain/db/kv/state_summary.go b/beacon-chain/db/kv/state_summary.go index 6164794f360..b8b15dc0af1 100644 --- a/beacon-chain/db/kv/state_summary.go +++ b/beacon-chain/db/kv/state_summary.go @@ -64,7 +64,7 @@ func (s *Store) StateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.St // HasStateSummary returns true if a state summary exists in DB. func (s *Store) HasStateSummary(ctx context.Context, blockRoot [32]byte) bool { - ctx, span := trace.StartSpan(ctx, "BeaconDB.HasStateSummary") + _, span := trace.StartSpan(ctx, "BeaconDB.HasStateSummary") defer span.End() var hasSummary bool diff --git a/beacon-chain/db/kv/state_test.go b/beacon-chain/db/kv/state_test.go index 9d351f954a1..f251a739070 100644 --- a/beacon-chain/db/kv/state_test.go +++ b/beacon-chain/db/kv/state_test.go @@ -13,7 +13,6 @@ import ( "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - v1alpha "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/testing/assert" @@ -183,7 +182,7 @@ func TestState_CanSaveRetrieveValidatorEntriesFromCache(t *testing.T) { assert.Equal(t, true, ok) require.NotNil(t, data) - valEntry, vType := data.(*v1alpha.Validator) + valEntry, vType := data.(*ethpb.Validator) assert.Equal(t, true, vType) require.NotNil(t, valEntry) diff --git a/beacon-chain/db/kv/utils.go b/beacon-chain/db/kv/utils.go index cd07b797c03..dde90f09523 100644 --- a/beacon-chain/db/kv/utils.go +++ b/beacon-chain/db/kv/utils.go @@ -16,7 +16,7 @@ import ( // we might find roots `0x23` and `0x45` stored under that index. We can then // do a batch read for attestations corresponding to those roots. func lookupValuesForIndices(ctx context.Context, indicesByBucket map[string][]byte, tx *bolt.Tx) [][][]byte { - ctx, span := trace.StartSpan(ctx, "BeaconDB.lookupValuesForIndices") + _, span := trace.StartSpan(ctx, "BeaconDB.lookupValuesForIndices") defer span.End() values := make([][][]byte, 0, len(indicesByBucket)) for k, v := range indicesByBucket { @@ -35,7 +35,7 @@ func lookupValuesForIndices(ctx context.Context, indicesByBucket map[string][]by // values stored at said index. Typically, indices are roots of data that can then // be used for reads or batch reads from the DB. func updateValueForIndices(ctx context.Context, indicesByBucket map[string][]byte, root []byte, tx *bolt.Tx) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.updateValueForIndices") + _, span := trace.StartSpan(ctx, "BeaconDB.updateValueForIndices") defer span.End() for k, idx := range indicesByBucket { bkt := tx.Bucket([]byte(k)) @@ -61,7 +61,7 @@ func updateValueForIndices(ctx context.Context, indicesByBucket map[string][]byt // deleteValueForIndices clears a root stored at each index. func deleteValueForIndices(ctx context.Context, indicesByBucket map[string][]byte, root []byte, tx *bolt.Tx) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.deleteValueForIndices") + _, span := trace.StartSpan(ctx, "BeaconDB.deleteValueForIndices") defer span.End() for k, idx := range indicesByBucket { bkt := tx.Bucket([]byte(k)) diff --git a/beacon-chain/db/slasherkv/slasher.go b/beacon-chain/db/slasherkv/slasher.go index 3b1f8d2ad22..cb755c4f9c7 100644 --- a/beacon-chain/db/slasherkv/slasher.go +++ b/beacon-chain/db/slasherkv/slasher.go @@ -15,7 +15,6 @@ import ( slashertypes "github.com/prysmaticlabs/prysm/beacon-chain/slasher/types" "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - slashpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" bolt "go.etcd.io/bbolt" "go.opencensus.io/trace" "golang.org/x/sync/errgroup" @@ -32,7 +31,7 @@ const ( func (s *Store) LastEpochWrittenForValidators( ctx context.Context, validatorIndices []types.ValidatorIndex, ) ([]*slashertypes.AttestedEpochForValidator, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.LastEpochWrittenForValidators") + _, span := trace.StartSpan(ctx, "BeaconDB.LastEpochWrittenForValidators") defer span.End() attestedEpochs := make([]*slashertypes.AttestedEpochForValidator, 0) encodedIndices := make([][]byte, len(validatorIndices)) @@ -64,7 +63,7 @@ func (s *Store) LastEpochWrittenForValidators( func (s *Store) SaveLastEpochsWrittenForValidators( ctx context.Context, epochByValidator map[types.ValidatorIndex]types.Epoch, ) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveLastEpochsWrittenForValidators") + _, span := trace.StartSpan(ctx, "BeaconDB.SaveLastEpochsWrittenForValidators") defer span.End() encodedIndices := make([][]byte, 0, len(epochByValidator)) encodedEpochs := make([][]byte, 0, len(epochByValidator)) @@ -184,7 +183,7 @@ func (s *Store) CheckAttesterDoubleVotes( func (s *Store) AttestationRecordForValidator( ctx context.Context, validatorIdx types.ValidatorIndex, targetEpoch types.Epoch, ) (*slashertypes.IndexedAttestationWrapper, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.AttestationRecordForValidator") + _, span := trace.StartSpan(ctx, "BeaconDB.AttestationRecordForValidator") defer span.End() var record *slashertypes.IndexedAttestationWrapper encIdx := encodeValidatorIndex(validatorIdx) @@ -216,7 +215,7 @@ func (s *Store) SaveAttestationRecordsForValidators( ctx context.Context, attestations []*slashertypes.IndexedAttestationWrapper, ) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveAttestationRecordsForValidators") + _, span := trace.StartSpan(ctx, "BeaconDB.SaveAttestationRecordsForValidators") defer span.End() encodedTargetEpoch := make([][]byte, len(attestations)) encodedRecords := make([][]byte, len(attestations)) @@ -260,7 +259,7 @@ func (s *Store) SaveAttestationRecordsForValidators( func (s *Store) LoadSlasherChunks( ctx context.Context, kind slashertypes.ChunkKind, diskKeys [][]byte, ) ([][]uint16, []bool, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.LoadSlasherChunk") + _, span := trace.StartSpan(ctx, "BeaconDB.LoadSlasherChunk") defer span.End() chunks := make([][]uint16, 0) var exists []bool @@ -291,7 +290,7 @@ func (s *Store) LoadSlasherChunks( func (s *Store) SaveSlasherChunks( ctx context.Context, kind slashertypes.ChunkKind, chunkKeys [][]byte, chunks [][]uint16, ) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveSlasherChunks") + _, span := trace.StartSpan(ctx, "BeaconDB.SaveSlasherChunks") defer span.End() encodedKeys := make([][]byte, len(chunkKeys)) encodedChunks := make([][]byte, len(chunkKeys)) @@ -321,7 +320,7 @@ func (s *Store) SaveSlasherChunks( func (s *Store) CheckDoubleBlockProposals( ctx context.Context, proposals []*slashertypes.SignedBlockHeaderWrapper, ) ([]*ethpb.ProposerSlashing, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.CheckDoubleBlockProposals") + _, span := trace.StartSpan(ctx, "BeaconDB.CheckDoubleBlockProposals") defer span.End() proposerSlashings := make([]*ethpb.ProposerSlashing, 0, len(proposals)) err := s.db.View(func(tx *bolt.Tx) error { @@ -360,7 +359,7 @@ func (s *Store) CheckDoubleBlockProposals( func (s *Store) BlockProposalForValidator( ctx context.Context, validatorIdx types.ValidatorIndex, slot types.Slot, ) (*slashertypes.SignedBlockHeaderWrapper, error) { - ctx, span := trace.StartSpan(ctx, "BeaconDB.BlockProposalForValidator") + _, span := trace.StartSpan(ctx, "BeaconDB.BlockProposalForValidator") defer span.End() var record *slashertypes.SignedBlockHeaderWrapper key, err := keyForValidatorProposal(slot, validatorIdx) @@ -388,7 +387,7 @@ func (s *Store) BlockProposalForValidator( func (s *Store) SaveBlockProposals( ctx context.Context, proposals []*slashertypes.SignedBlockHeaderWrapper, ) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveBlockProposals") + _, span := trace.StartSpan(ctx, "BeaconDB.SaveBlockProposals") defer span.End() encodedKeys := make([][]byte, len(proposals)) encodedProposals := make([][]byte, len(proposals)) @@ -422,7 +421,7 @@ func (s *Store) SaveBlockProposals( func (s *Store) HighestAttestations( _ context.Context, indices []types.ValidatorIndex, -) ([]*slashpb.HighestAttestation, error) { +) ([]*ethpb.HighestAttestation, error) { if len(indices) == 0 { return nil, nil } @@ -437,7 +436,7 @@ func (s *Store) HighestAttestations( encodedIndices[i] = encodeValidatorIndex(valIdx) } - history := make([]*slashpb.HighestAttestation, 0, len(encodedIndices)) + history := make([]*ethpb.HighestAttestation, 0, len(encodedIndices)) err = s.db.View(func(tx *bolt.Tx) error { signingRootsBkt := tx.Bucket(attestationDataRootsBucket) attRecordsBkt := tx.Bucket(attestationRecordsBucket) @@ -453,7 +452,7 @@ func (s *Store) HighestAttestations( if err != nil { return err } - highestAtt := &slashpb.HighestAttestation{ + highestAtt := ðpb.HighestAttestation{ ValidatorIndex: uint64(indices[i]), HighestSourceEpoch: attWrapper.IndexedAttestation.Data.Source.Epoch, HighestTargetEpoch: attWrapper.IndexedAttestation.Data.Target.Epoch, diff --git a/beacon-chain/db/slasherkv/slasher_test.go b/beacon-chain/db/slasherkv/slasher_test.go index d712d9060d0..ba0eb745c7f 100644 --- a/beacon-chain/db/slasherkv/slasher_test.go +++ b/beacon-chain/db/slasherkv/slasher_test.go @@ -14,7 +14,6 @@ import ( "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - slashpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" ) @@ -346,7 +345,7 @@ func TestStore_HighestAttestations(t *testing.T) { tests := []struct { name string attestationsInDB []*slashertypes.IndexedAttestationWrapper - expected []*slashpb.HighestAttestation + expected []*ethpb.HighestAttestation indices []types.ValidatorIndex wantErr bool }{ @@ -356,7 +355,7 @@ func TestStore_HighestAttestations(t *testing.T) { createAttestationWrapper(0, 3, []uint64{1}, []byte{1}), }, indices: []types.ValidatorIndex{1}, - expected: []*slashpb.HighestAttestation{ + expected: []*ethpb.HighestAttestation{ { ValidatorIndex: 1, HighestSourceEpoch: 0, @@ -373,7 +372,7 @@ func TestStore_HighestAttestations(t *testing.T) { createAttestationWrapper(5, 6, []uint64{5}, []byte{4}), }, indices: []types.ValidatorIndex{2, 3, 4, 5}, - expected: []*slashpb.HighestAttestation{ + expected: []*ethpb.HighestAttestation{ { ValidatorIndex: 2, HighestSourceEpoch: 0, @@ -405,7 +404,7 @@ func TestStore_HighestAttestations(t *testing.T) { createAttestationWrapper(6, 7, []uint64{5}, []byte{4}), }, indices: []types.ValidatorIndex{2, 3, 4, 5}, - expected: []*slashpb.HighestAttestation{ + expected: []*ethpb.HighestAttestation{ { ValidatorIndex: 2, HighestSourceEpoch: 4, diff --git a/beacon-chain/deterministic-genesis/service.go b/beacon-chain/deterministic-genesis/service.go index fa9906984d7..b860f3687c2 100644 --- a/beacon-chain/deterministic-genesis/service.go +++ b/beacon-chain/deterministic-genesis/service.go @@ -102,21 +102,21 @@ func NewService(ctx context.Context, cfg *Config) *Service { } // Start initializes the genesis state from configured flags. -func (s *Service) Start() { +func (_ *Service) Start() { } // Stop does nothing. -func (s *Service) Stop() error { +func (_ *Service) Stop() error { return nil } // Status always returns nil. -func (s *Service) Status() error { +func (_ *Service) Status() error { return nil } // AllDeposits mocks out the deposit cache functionality for interop. -func (s *Service) AllDeposits(_ context.Context, _ *big.Int) []*ethpb.Deposit { +func (_ *Service) AllDeposits(_ context.Context, _ *big.Int) []*ethpb.Deposit { return []*ethpb.Deposit{} } @@ -126,37 +126,37 @@ func (s *Service) ChainStartDeposits() []*ethpb.Deposit { } // ChainStartEth1Data mocks out the powchain functionality for interop. -func (s *Service) ChainStartEth1Data() *ethpb.Eth1Data { +func (_ *Service) ChainStartEth1Data() *ethpb.Eth1Data { return ðpb.Eth1Data{} } // PreGenesisState returns an empty beacon state. -func (s *Service) PreGenesisState() state.BeaconState { +func (_ *Service) PreGenesisState() state.BeaconState { return &v1.BeaconState{} } // ClearPreGenesisData -- -func (s *Service) ClearPreGenesisData() { +func (_ *Service) ClearPreGenesisData() { // no-op } // DepositByPubkey mocks out the deposit cache functionality for interop. -func (s *Service) DepositByPubkey(_ context.Context, _ []byte) (*ethpb.Deposit, *big.Int) { +func (_ *Service) DepositByPubkey(_ context.Context, _ []byte) (*ethpb.Deposit, *big.Int) { return ðpb.Deposit{}, nil } // DepositsNumberAndRootAtHeight mocks out the deposit cache functionality for interop. -func (s *Service) DepositsNumberAndRootAtHeight(_ context.Context, _ *big.Int) (uint64, [32]byte) { +func (_ *Service) DepositsNumberAndRootAtHeight(_ context.Context, _ *big.Int) (uint64, [32]byte) { return 0, [32]byte{} } // FinalizedDeposits mocks out the deposit cache functionality for interop. -func (s *Service) FinalizedDeposits(_ context.Context) *depositcache.FinalizedDeposits { +func (_ *Service) FinalizedDeposits(_ context.Context) *depositcache.FinalizedDeposits { return nil } // NonFinalizedDeposits mocks out the deposit cache functionality for interop. -func (s *Service) NonFinalizedDeposits(_ context.Context, _ *big.Int) []*ethpb.Deposit { +func (_ *Service) NonFinalizedDeposits(_ context.Context, _ *big.Int) []*ethpb.Deposit { return []*ethpb.Deposit{} } diff --git a/beacon-chain/forkchoice/protoarray/helpers.go b/beacon-chain/forkchoice/protoarray/helpers.go index 7460da84402..b096db01d1d 100644 --- a/beacon-chain/forkchoice/protoarray/helpers.go +++ b/beacon-chain/forkchoice/protoarray/helpers.go @@ -15,7 +15,7 @@ func computeDeltas( votes []Vote, oldBalances, newBalances []uint64, ) ([]int, []Vote, error) { - ctx, span := trace.StartSpan(ctx, "protoArrayForkChoice.computeDeltas") + _, span := trace.StartSpan(ctx, "protoArrayForkChoice.computeDeltas") defer span.End() deltas := make([]int, len(blockIndices)) diff --git a/beacon-chain/forkchoice/protoarray/store.go b/beacon-chain/forkchoice/protoarray/store.go index 6f198ac1732..ea6bb59add9 100644 --- a/beacon-chain/forkchoice/protoarray/store.go +++ b/beacon-chain/forkchoice/protoarray/store.go @@ -74,7 +74,7 @@ func (f *ForkChoice) Head( // ProcessAttestation processes attestation for vote accounting, it iterates around validator indices // and update their votes accordingly. func (f *ForkChoice) ProcessAttestation(ctx context.Context, validatorIndices []uint64, blockRoot [32]byte, targetEpoch types.Epoch) { - ctx, span := trace.StartSpan(ctx, "protoArrayForkChoice.ProcessAttestation") + _, span := trace.StartSpan(ctx, "protoArrayForkChoice.ProcessAttestation") defer span.End() f.votesLock.Lock() defer f.votesLock.Unlock() @@ -327,7 +327,7 @@ func (s *Store) insert(ctx context.Context, slot types.Slot, root, parent, graffiti [32]byte, justifiedEpoch, finalizedEpoch types.Epoch) error { - ctx, span := trace.StartSpan(ctx, "protoArrayForkChoice.insert") + _, span := trace.StartSpan(ctx, "protoArrayForkChoice.insert") defer span.End() s.nodesLock.Lock() @@ -379,7 +379,7 @@ func (s *Store) insert(ctx context.Context, // back propagate the nodes delta to its parents delta. After scoring changes, // the best child is then updated along with best descendant. func (s *Store) applyWeightChanges(ctx context.Context, justifiedEpoch, finalizedEpoch types.Epoch, delta []int) error { - ctx, span := trace.StartSpan(ctx, "protoArrayForkChoice.applyWeightChanges") + _, span := trace.StartSpan(ctx, "protoArrayForkChoice.applyWeightChanges") defer span.End() // The length of the nodes can not be different than length of the delta. @@ -557,7 +557,7 @@ func (s *Store) updateBestChildAndDescendant(parentIndex, childIndex uint64) err // pruned if the input finalized root are different than the one in stored and // the number of the nodes in store has met prune threshold. func (s *Store) prune(ctx context.Context, finalizedRoot [32]byte) error { - ctx, span := trace.StartSpan(ctx, "protoArrayForkChoice.prune") + _, span := trace.StartSpan(ctx, "protoArrayForkChoice.prune") defer span.End() s.nodesLock.Lock() diff --git a/beacon-chain/operations/attestations/kv/aggregated.go b/beacon-chain/operations/attestations/kv/aggregated.go index 2ce580ec790..5964753ea65 100644 --- a/beacon-chain/operations/attestations/kv/aggregated.go +++ b/beacon-chain/operations/attestations/kv/aggregated.go @@ -37,7 +37,7 @@ func (c *AttCaches) AggregateUnaggregatedAttestationsBySlotIndex(ctx context.Con } func (c *AttCaches) aggregateUnaggregatedAttestations(ctx context.Context, unaggregatedAtts []*ethpb.Attestation) error { - ctx, span := trace.StartSpan(ctx, "operations.attestations.kv.aggregateUnaggregatedAttestations") + _, span := trace.StartSpan(ctx, "operations.attestations.kv.aggregateUnaggregatedAttestations") defer span.End() attsByDataRoot := make(map[[32]byte][]*ethpb.Attestation, len(unaggregatedAtts)) @@ -168,7 +168,7 @@ func (c *AttCaches) AggregatedAttestations() []*ethpb.Attestation { // AggregatedAttestationsBySlotIndex returns the aggregated attestations in cache, // filtered by committee index and slot. func (c *AttCaches) AggregatedAttestationsBySlotIndex(ctx context.Context, slot types.Slot, committeeIndex types.CommitteeIndex) []*ethpb.Attestation { - ctx, span := trace.StartSpan(ctx, "operations.attestations.kv.AggregatedAttestationsBySlotIndex") + _, span := trace.StartSpan(ctx, "operations.attestations.kv.AggregatedAttestationsBySlotIndex") defer span.End() atts := make([]*ethpb.Attestation, 0) diff --git a/beacon-chain/operations/attestations/kv/unaggregated.go b/beacon-chain/operations/attestations/kv/unaggregated.go index 5d26e9cb6f5..71728001939 100644 --- a/beacon-chain/operations/attestations/kv/unaggregated.go +++ b/beacon-chain/operations/attestations/kv/unaggregated.go @@ -71,7 +71,7 @@ func (c *AttCaches) UnaggregatedAttestations() ([]*ethpb.Attestation, error) { // UnaggregatedAttestationsBySlotIndex returns the unaggregated attestations in cache, // filtered by committee index and slot. func (c *AttCaches) UnaggregatedAttestationsBySlotIndex(ctx context.Context, slot types.Slot, committeeIndex types.CommitteeIndex) []*ethpb.Attestation { - ctx, span := trace.StartSpan(ctx, "operations.attestations.kv.UnaggregatedAttestationsBySlotIndex") + _, span := trace.StartSpan(ctx, "operations.attestations.kv.UnaggregatedAttestationsBySlotIndex") defer span.End() atts := make([]*ethpb.Attestation, 0) diff --git a/beacon-chain/operations/slashings/service.go b/beacon-chain/operations/slashings/service.go index 5d7d201ecab..c6e328c2478 100644 --- a/beacon-chain/operations/slashings/service.go +++ b/beacon-chain/operations/slashings/service.go @@ -33,7 +33,7 @@ func NewPool() *Pool { func (p *Pool) PendingAttesterSlashings(ctx context.Context, state state.ReadOnlyBeaconState, noLimit bool) []*ethpb.AttesterSlashing { p.lock.Lock() defer p.lock.Unlock() - ctx, span := trace.StartSpan(ctx, "operations.PendingAttesterSlashing") + _, span := trace.StartSpan(ctx, "operations.PendingAttesterSlashing") defer span.End() // Update prom metric. @@ -80,7 +80,7 @@ func (p *Pool) PendingAttesterSlashings(ctx context.Context, state state.ReadOnl func (p *Pool) PendingProposerSlashings(ctx context.Context, state state.ReadOnlyBeaconState, noLimit bool) []*ethpb.ProposerSlashing { p.lock.Lock() defer p.lock.Unlock() - ctx, span := trace.StartSpan(ctx, "operations.PendingProposerSlashing") + _, span := trace.StartSpan(ctx, "operations.PendingProposerSlashing") defer span.End() // Update prom metric. @@ -187,7 +187,7 @@ func (p *Pool) InsertProposerSlashing( ) error { p.lock.Lock() defer p.lock.Unlock() - ctx, span := trace.StartSpan(ctx, "operations.InsertProposerSlashing") + _, span := trace.StartSpan(ctx, "operations.InsertProposerSlashing") defer span.End() if err := blocks.VerifyProposerSlashing(state, slashing); err != nil { diff --git a/beacon-chain/operations/voluntaryexits/service.go b/beacon-chain/operations/voluntaryexits/service.go index 4191efa2c67..5767ed16aeb 100644 --- a/beacon-chain/operations/voluntaryexits/service.go +++ b/beacon-chain/operations/voluntaryexits/service.go @@ -66,7 +66,7 @@ func (p *Pool) PendingExits(state state.ReadOnlyBeaconState, slot types.Slot, no // InsertVoluntaryExit into the pool. This method is a no-op if the pending exit already exists, // or the validator is already exited. func (p *Pool) InsertVoluntaryExit(ctx context.Context, state state.ReadOnlyBeaconState, exit *ethpb.SignedVoluntaryExit) { - ctx, span := trace.StartSpan(ctx, "exitPool.InsertVoluntaryExit") + _, span := trace.StartSpan(ctx, "exitPool.InsertVoluntaryExit") defer span.End() p.lock.Lock() defer p.lock.Unlock() diff --git a/beacon-chain/p2p/broadcaster.go b/beacon-chain/p2p/broadcaster.go index 3d16670e653..411e33ef137 100644 --- a/beacon-chain/p2p/broadcaster.go +++ b/beacon-chain/p2p/broadcaster.go @@ -13,7 +13,6 @@ import ( "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/crypto/hash" "github.com/prysmaticlabs/prysm/monitoring/tracing" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/time/slots" "go.opencensus.io/trace" @@ -55,7 +54,7 @@ func (s *Service) Broadcast(ctx context.Context, msg proto.Message) error { // BroadcastAttestation broadcasts an attestation to the p2p network, the message is assumed to be // broadcasted to the current fork. -func (s *Service) BroadcastAttestation(ctx context.Context, subnet uint64, att *eth.Attestation) error { +func (s *Service) BroadcastAttestation(ctx context.Context, subnet uint64, att *ethpb.Attestation) error { ctx, span := trace.StartSpan(ctx, "p2p.BroadcastAttestation") defer span.End() forkDigest, err := s.currentForkDigest() @@ -89,7 +88,7 @@ func (s *Service) BroadcastSyncCommitteeMessage(ctx context.Context, subnet uint return nil } -func (s *Service) broadcastAttestation(ctx context.Context, subnet uint64, att *eth.Attestation, forkDigest [4]byte) { +func (s *Service) broadcastAttestation(ctx context.Context, subnet uint64, att *ethpb.Attestation, forkDigest [4]byte) { ctx, span := trace.StartSpan(ctx, "p2p.broadcastAttestation") defer span.End() ctx = trace.NewContext(context.Background(), span) // clear parent context / deadline. diff --git a/beacon-chain/p2p/broadcaster_test.go b/beacon-chain/p2p/broadcaster_test.go index 3cced728d37..cdffbeada5a 100644 --- a/beacon-chain/p2p/broadcaster_test.go +++ b/beacon-chain/p2p/broadcaster_test.go @@ -18,9 +18,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" testpb "github.com/prysmaticlabs/prysm/proto/testing" "github.com/prysmaticlabs/prysm/testing/assert" @@ -100,17 +98,17 @@ func TestService_Broadcast_ReturnsErr_TopicNotMapped(t *testing.T) { } func TestService_Attestation_Subnet(t *testing.T) { - if gtm := GossipTypeMapping[reflect.TypeOf(ð.Attestation{})]; gtm != AttestationSubnetTopicFormat { + if gtm := GossipTypeMapping[reflect.TypeOf(ðpb.Attestation{})]; gtm != AttestationSubnetTopicFormat { t.Errorf("Constant is out of date. Wanted %s, got %s", AttestationSubnetTopicFormat, gtm) } tests := []struct { - att *eth.Attestation + att *ethpb.Attestation topic string }{ { - att: ð.Attestation{ - Data: ð.AttestationData{ + att: ðpb.Attestation{ + Data: ðpb.AttestationData{ CommitteeIndex: 0, Slot: 2, }, @@ -118,8 +116,8 @@ func TestService_Attestation_Subnet(t *testing.T) { topic: "/eth2/00000000/beacon_attestation_2", }, { - att: ð.Attestation{ - Data: ð.AttestationData{ + att: ðpb.Attestation{ + Data: ðpb.AttestationData{ CommitteeIndex: 11, Slot: 10, }, @@ -127,8 +125,8 @@ func TestService_Attestation_Subnet(t *testing.T) { topic: "/eth2/00000000/beacon_attestation_21", }, { - att: ð.Attestation{ - Data: ð.AttestationData{ + att: ðpb.Attestation{ + Data: ðpb.AttestationData{ CommitteeIndex: 55, Slot: 529, }, @@ -164,7 +162,7 @@ func TestService_BroadcastAttestation(t *testing.T) { }), } - msg := util.HydrateAttestation(ð.Attestation{AggregationBits: bitfield.NewBitlist(7)}) + msg := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.NewBitlist(7)}) subnet := uint64(5) topic := AttestationSubnetTopicFormat @@ -191,7 +189,7 @@ func TestService_BroadcastAttestation(t *testing.T) { incomingMessage, err := sub.Next(ctx) require.NoError(t, err) - result := ð.Attestation{} + result := ðpb.Attestation{} require.NoError(t, p.Encoding().DecodeGossip(incomingMessage.Data, result)) if !proto.Equal(result, msg) { tt.Errorf("Did not receive expected message, got %+v, wanted %+v", result, msg) @@ -255,7 +253,7 @@ func TestService_BroadcastAttestationWithDiscoveryAttempts(t *testing.T) { // Set for 2nd peer if i == 2 { s.dv5Listener = listener - s.metaData = wrapper.WrappedMetadataV0(new(pb.MetaDataV0)) + s.metaData = wrapper.WrappedMetadataV0(new(ethpb.MetaDataV0)) bitV := bitfield.NewBitvector64() bitV.SetBitAt(subnet, true) s.updateSubnetRecordWithMetadata(bitV) @@ -323,7 +321,7 @@ func TestService_BroadcastAttestationWithDiscoveryAttempts(t *testing.T) { }), } - msg := util.HydrateAttestation(ð.Attestation{AggregationBits: bitfield.NewBitlist(7)}) + msg := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.NewBitlist(7)}) topic := AttestationSubnetTopicFormat GossipTypeMapping[reflect.TypeOf(msg)] = topic digest, err := p.currentForkDigest() @@ -352,7 +350,7 @@ func TestService_BroadcastAttestationWithDiscoveryAttempts(t *testing.T) { incomingMessage, err := sub.Next(ctx) require.NoError(t, err) - result := ð.Attestation{} + result := ðpb.Attestation{} require.NoError(t, p.Encoding().DecodeGossip(incomingMessage.Data, result)) if !proto.Equal(result, msg) { tt.Errorf("Did not receive expected message, got %+v, wanted %+v", result, msg) @@ -388,7 +386,7 @@ func TestService_BroadcastSyncCommittee(t *testing.T) { }), } - msg := util.HydrateSyncCommittee(&pb.SyncCommitteeMessage{}) + msg := util.HydrateSyncCommittee(ðpb.SyncCommitteeMessage{}) subnet := uint64(5) topic := SyncCommitteeSubnetTopicFormat @@ -415,7 +413,7 @@ func TestService_BroadcastSyncCommittee(t *testing.T) { incomingMessage, err := sub.Next(ctx) require.NoError(t, err) - result := &pb.SyncCommitteeMessage{} + result := ðpb.SyncCommitteeMessage{} require.NoError(t, p.Encoding().DecodeGossip(incomingMessage.Data, result)) if !proto.Equal(result, msg) { tt.Errorf("Did not receive expected message, got %+v, wanted %+v", result, msg) diff --git a/beacon-chain/p2p/connection_gater.go b/beacon-chain/p2p/connection_gater.go index 3f7a6e181ba..7d5000f581a 100644 --- a/beacon-chain/p2p/connection_gater.go +++ b/beacon-chain/p2p/connection_gater.go @@ -25,7 +25,7 @@ const ( ) // InterceptPeerDial tests whether we're permitted to Dial the specified peer. -func (s *Service) InterceptPeerDial(_ peer.ID) (allow bool) { +func (_ *Service) InterceptPeerDial(_ peer.ID) (allow bool) { return true } @@ -59,12 +59,12 @@ func (s *Service) InterceptAccept(n network.ConnMultiaddrs) (allow bool) { // InterceptSecured tests whether a given connection, now authenticated, // is allowed. -func (s *Service) InterceptSecured(_ network.Direction, _ peer.ID, _ network.ConnMultiaddrs) (allow bool) { +func (_ *Service) InterceptSecured(_ network.Direction, _ peer.ID, _ network.ConnMultiaddrs) (allow bool) { return true } // InterceptUpgraded tests whether a fully capable connection is allowed. -func (s *Service) InterceptUpgraded(_ network.Conn) (allow bool, reason control.DisconnectReason) { +func (_ *Service) InterceptUpgraded(_ network.Conn) (allow bool, reason control.DisconnectReason) { return true, 0 } diff --git a/beacon-chain/p2p/discovery_test.go b/beacon-chain/p2p/discovery_test.go index d944de48c8b..f289aac0ed7 100644 --- a/beacon-chain/p2p/discovery_test.go +++ b/beacon-chain/p2p/discovery_test.go @@ -33,7 +33,6 @@ import ( "github.com/prysmaticlabs/prysm/encoding/bytesutil" prysmNetwork "github.com/prysmaticlabs/prysm/network" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/runtime/version" "github.com/prysmaticlabs/prysm/testing/assert" @@ -337,7 +336,7 @@ func addPeer(t *testing.T, p *peers.Status, state peerdata.PeerConnectionState) require.NoError(t, err) p.Add(new(enr.Record), id, nil, network.DirInbound) p.SetConnectionState(id, state) - p.SetMetadata(id, wrapper.WrappedMetadataV0(&pb.MetaDataV0{ + p.SetMetadata(id, wrapper.WrappedMetadataV0(ðpb.MetaDataV0{ SeqNumber: 0, Attnets: bitfield.NewBitvector64(), })) @@ -367,7 +366,7 @@ func TestRefreshENR_ForkBoundaries(t *testing.T) { listener, err := s.createListener(ipAddr, pkey) assert.NoError(t, err) s.dv5Listener = listener - s.metaData = wrapper.WrappedMetadataV0(new(pb.MetaDataV0)) + s.metaData = wrapper.WrappedMetadataV0(new(ethpb.MetaDataV0)) s.updateSubnetRecordWithMetadata([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}) return s }, @@ -388,7 +387,7 @@ func TestRefreshENR_ForkBoundaries(t *testing.T) { listener, err := s.createListener(ipAddr, pkey) assert.NoError(t, err) s.dv5Listener = listener - s.metaData = wrapper.WrappedMetadataV0(new(pb.MetaDataV0)) + s.metaData = wrapper.WrappedMetadataV0(new(ethpb.MetaDataV0)) s.updateSubnetRecordWithMetadata([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}) cache.SubnetIDs.AddPersistentCommittee([]byte{'A'}, []uint64{1, 2, 3, 23}, 0) return s @@ -417,7 +416,7 @@ func TestRefreshENR_ForkBoundaries(t *testing.T) { params.BeaconConfig().InitializeForkSchedule() s.dv5Listener = listener - s.metaData = wrapper.WrappedMetadataV0(new(pb.MetaDataV0)) + s.metaData = wrapper.WrappedMetadataV0(new(ethpb.MetaDataV0)) s.updateSubnetRecordWithMetadata([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}) cache.SubnetIDs.AddPersistentCommittee([]byte{'A'}, []uint64{1, 2, 3, 23}, 0) return s @@ -448,7 +447,7 @@ func TestRefreshENR_ForkBoundaries(t *testing.T) { params.BeaconConfig().InitializeForkSchedule() s.dv5Listener = listener - s.metaData = wrapper.WrappedMetadataV0(new(pb.MetaDataV0)) + s.metaData = wrapper.WrappedMetadataV0(new(ethpb.MetaDataV0)) s.updateSubnetRecordWithMetadata([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}) return s }, @@ -478,7 +477,7 @@ func TestRefreshENR_ForkBoundaries(t *testing.T) { params.BeaconConfig().InitializeForkSchedule() s.dv5Listener = listener - s.metaData = wrapper.WrappedMetadataV0(new(pb.MetaDataV0)) + s.metaData = wrapper.WrappedMetadataV0(new(ethpb.MetaDataV0)) s.updateSubnetRecordWithMetadata([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}) cache.SubnetIDs.AddPersistentCommittee([]byte{'A'}, []uint64{1, 2, 3, 23}, 0) cache.SyncSubnetIDs.AddSyncCommitteeSubnets([]byte{'A'}, 0, []uint64{0, 1}, 0) diff --git a/beacon-chain/p2p/encoder/ssz.go b/beacon-chain/p2p/encoder/ssz.go index 23f2fa495ea..df53b4a9f55 100644 --- a/beacon-chain/p2p/encoder/ssz.go +++ b/beacon-chain/p2p/encoder/ssz.go @@ -34,7 +34,7 @@ type SszNetworkEncoder struct{} const ProtocolSuffixSSZSnappy = "ssz_snappy" // EncodeGossip the proto gossip message to the io.Writer. -func (e SszNetworkEncoder) EncodeGossip(w io.Writer, msg fastssz.Marshaler) (int, error) { +func (_ SszNetworkEncoder) EncodeGossip(w io.Writer, msg fastssz.Marshaler) (int, error) { if msg == nil { return 0, nil } @@ -51,7 +51,7 @@ func (e SszNetworkEncoder) EncodeGossip(w io.Writer, msg fastssz.Marshaler) (int // EncodeWithMaxLength the proto message to the io.Writer. This encoding prefixes the byte slice with a protobuf varint // to indicate the size of the message. This checks that the encoded message isn't larger than the provided max limit. -func (e SszNetworkEncoder) EncodeWithMaxLength(w io.Writer, msg fastssz.Marshaler) (int, error) { +func (_ SszNetworkEncoder) EncodeWithMaxLength(w io.Writer, msg fastssz.Marshaler) (int, error) { if msg == nil { return 0, nil } @@ -74,17 +74,17 @@ func (e SszNetworkEncoder) EncodeWithMaxLength(w io.Writer, msg fastssz.Marshale return writeSnappyBuffer(w, b) } -func (e SszNetworkEncoder) doDecode(b []byte, to fastssz.Unmarshaler) error { +func doDecode(b []byte, to fastssz.Unmarshaler) error { return to.UnmarshalSSZ(b) } // DecodeGossip decodes the bytes to the protobuf gossip message provided. -func (e SszNetworkEncoder) DecodeGossip(b []byte, to fastssz.Unmarshaler) error { +func (_ SszNetworkEncoder) DecodeGossip(b []byte, to fastssz.Unmarshaler) error { b, err := DecodeSnappy(b, MaxGossipSize) if err != nil { return err } - return e.doDecode(b, to) + return doDecode(b, to) } // DecodeSnappy decodes a snappy compressed message. @@ -133,17 +133,17 @@ func (e SszNetworkEncoder) DecodeWithMaxLength(r io.Reader, to fastssz.Unmarshal if err != nil { return err } - return e.doDecode(buf, to) + return doDecode(buf, to) } // ProtocolSuffix returns the appropriate suffix for protocol IDs. -func (e SszNetworkEncoder) ProtocolSuffix() string { +func (_ SszNetworkEncoder) ProtocolSuffix() string { return "/" + ProtocolSuffixSSZSnappy } // MaxLength specifies the maximum possible length of an encoded // chunk of data. -func (e SszNetworkEncoder) MaxLength(length uint64) (int, error) { +func (_ SszNetworkEncoder) MaxLength(length uint64) (int, error) { // Defensive check to prevent potential issues when casting to int64. if length > math.MaxInt64 { return 0, errors.Errorf("invalid length provided: %d", length) diff --git a/beacon-chain/p2p/gossip_topic_mappings.go b/beacon-chain/p2p/gossip_topic_mappings.go index 3077bcaec7c..68115941d5c 100644 --- a/beacon-chain/p2p/gossip_topic_mappings.go +++ b/beacon-chain/p2p/gossip_topic_mappings.go @@ -6,19 +6,18 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/config/params" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "google.golang.org/protobuf/proto" ) // gossipTopicMappings represent the protocol ID to protobuf message type map for easy // lookup. var gossipTopicMappings = map[string]proto.Message{ - BlockSubnetTopicFormat: &pb.SignedBeaconBlock{}, - AttestationSubnetTopicFormat: &pb.Attestation{}, - ExitSubnetTopicFormat: &pb.SignedVoluntaryExit{}, - ProposerSlashingSubnetTopicFormat: &pb.ProposerSlashing{}, - AttesterSlashingSubnetTopicFormat: &pb.AttesterSlashing{}, - AggregateAndProofSubnetTopicFormat: &pb.SignedAggregateAttestationAndProof{}, + BlockSubnetTopicFormat: ðpb.SignedBeaconBlock{}, + AttestationSubnetTopicFormat: ðpb.Attestation{}, + ExitSubnetTopicFormat: ðpb.SignedVoluntaryExit{}, + ProposerSlashingSubnetTopicFormat: ðpb.ProposerSlashing{}, + AttesterSlashingSubnetTopicFormat: ðpb.AttesterSlashing{}, + AggregateAndProofSubnetTopicFormat: ðpb.SignedAggregateAttestationAndProof{}, SyncContributionAndProofSubnetTopicFormat: ðpb.SignedContributionAndProof{}, SyncCommitteeSubnetTopicFormat: ðpb.SyncCommitteeMessage{}, } diff --git a/beacon-chain/p2p/peers/peerdata/store.go b/beacon-chain/p2p/peers/peerdata/store.go index 1914798152f..5347d2a0d2c 100644 --- a/beacon-chain/p2p/peers/peerdata/store.go +++ b/beacon-chain/p2p/peers/peerdata/store.go @@ -11,7 +11,6 @@ import ( "github.com/libp2p/go-libp2p-core/peer" ma "github.com/multiformats/go-multiaddr" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/metadata" ) @@ -54,7 +53,7 @@ type PeerData struct { NextValidTime time.Time // Chain related data. MetaData metadata.Metadata - ChainState *pb.Status + ChainState *ethpb.Status ChainStateLastUpdated time.Time ChainStateValidationError error // Scorers internal data. @@ -62,7 +61,7 @@ type PeerData struct { ProcessedBlocks uint64 BlockProviderUpdated time.Time // Gossip Scoring data. - TopicScores map[string]*pb.TopicScoreSnapshot + TopicScores map[string]*ethpb.TopicScoreSnapshot GossipScore float64 BehaviourPenalty float64 } diff --git a/beacon-chain/p2p/peers/scorers/block_providers.go b/beacon-chain/p2p/peers/scorers/block_providers.go index 34cfa48e9c1..33ba675bf7c 100644 --- a/beacon-chain/p2p/peers/scorers/block_providers.go +++ b/beacon-chain/p2p/peers/scorers/block_providers.go @@ -178,13 +178,13 @@ func (s *BlockProviderScorer) processedBlocks(pid peer.ID) uint64 { // Block provider scorer cannot guarantee that lower score of a peer is indeed a sign of a bad peer. // Therefore this scorer never marks peers as bad, and relies on scores to probabilistically sort // out low-scorers (see WeightSorted method). -func (s *BlockProviderScorer) IsBadPeer(_ peer.ID) bool { +func (_ *BlockProviderScorer) IsBadPeer(_ peer.ID) bool { return false } // BadPeers returns the peers that are considered bad. // No peers are considered bad by block providers scorer. -func (s *BlockProviderScorer) BadPeers() []peer.ID { +func (_ *BlockProviderScorer) BadPeers() []peer.ID { return []peer.ID{} } diff --git a/beacon-chain/p2p/service.go b/beacon-chain/p2p/service.go index a9eb4453810..11e158f302f 100644 --- a/beacon-chain/p2p/service.go +++ b/beacon-chain/p2p/service.go @@ -303,7 +303,7 @@ func (s *Service) Started() bool { } // Encoding returns the configured networking encoding. -func (s *Service) Encoding() encoder.NetworkEncoding { +func (_ *Service) Encoding() encoder.NetworkEncoding { return &encoder.SszNetworkEncoder{} } diff --git a/beacon-chain/p2p/testing/fuzz_p2p.go b/beacon-chain/p2p/testing/fuzz_p2p.go index e24a4666286..693896f891c 100644 --- a/beacon-chain/p2p/testing/fuzz_p2p.go +++ b/beacon-chain/p2p/testing/fuzz_p2p.go @@ -27,143 +27,143 @@ func NewFuzzTestP2P() *FakeP2P { } // Encoding -- fake. -func (p *FakeP2P) Encoding() encoder.NetworkEncoding { +func (_ *FakeP2P) Encoding() encoder.NetworkEncoding { return &encoder.SszNetworkEncoder{} } // AddConnectionHandler -- fake. -func (p *FakeP2P) AddConnectionHandler(_, _ func(ctx context.Context, id peer.ID) error) { +func (_ *FakeP2P) AddConnectionHandler(_, _ func(ctx context.Context, id peer.ID) error) { } // AddDisconnectionHandler -- fake. -func (p *FakeP2P) AddDisconnectionHandler(_ func(ctx context.Context, id peer.ID) error) { +func (_ *FakeP2P) AddDisconnectionHandler(_ func(ctx context.Context, id peer.ID) error) { } // AddPingMethod -- fake. -func (p *FakeP2P) AddPingMethod(_ func(ctx context.Context, id peer.ID) error) { +func (_ *FakeP2P) AddPingMethod(_ func(ctx context.Context, id peer.ID) error) { } // PeerID -- fake. -func (p *FakeP2P) PeerID() peer.ID { +func (_ *FakeP2P) PeerID() peer.ID { return "fake" } // ENR returns the enr of the local peer. -func (p *FakeP2P) ENR() *enr.Record { +func (_ *FakeP2P) ENR() *enr.Record { return new(enr.Record) } // DiscoveryAddresses -- fake -func (p *FakeP2P) DiscoveryAddresses() ([]multiaddr.Multiaddr, error) { +func (_ *FakeP2P) DiscoveryAddresses() ([]multiaddr.Multiaddr, error) { return nil, nil } // FindPeersWithSubnet mocks the p2p func. -func (p *FakeP2P) FindPeersWithSubnet(_ context.Context, _ string, _, _ uint64) (bool, error) { +func (_ *FakeP2P) FindPeersWithSubnet(_ context.Context, _ string, _, _ uint64) (bool, error) { return false, nil } // RefreshENR mocks the p2p func. -func (p *FakeP2P) RefreshENR() {} +func (_ *FakeP2P) RefreshENR() {} // LeaveTopic -- fake. -func (p *FakeP2P) LeaveTopic(_ string) error { +func (_ *FakeP2P) LeaveTopic(_ string) error { return nil } // Metadata -- fake. -func (p *FakeP2P) Metadata() metadata.Metadata { +func (_ *FakeP2P) Metadata() metadata.Metadata { return nil } // Peers -- fake. -func (p *FakeP2P) Peers() *peers.Status { +func (_ *FakeP2P) Peers() *peers.Status { return nil } // PublishToTopic -- fake. -func (p *FakeP2P) PublishToTopic(_ context.Context, _ string, _ []byte, _ ...pubsub.PubOpt) error { +func (_ *FakeP2P) PublishToTopic(_ context.Context, _ string, _ []byte, _ ...pubsub.PubOpt) error { return nil } // Send -- fake. -func (p *FakeP2P) Send(_ context.Context, _ interface{}, _ string, _ peer.ID) (network.Stream, error) { +func (_ *FakeP2P) Send(_ context.Context, _ interface{}, _ string, _ peer.ID) (network.Stream, error) { return nil, nil } // PubSub -- fake. -func (p *FakeP2P) PubSub() *pubsub.PubSub { +func (_ *FakeP2P) PubSub() *pubsub.PubSub { return nil } // MetadataSeq -- fake. -func (p *FakeP2P) MetadataSeq() uint64 { +func (_ *FakeP2P) MetadataSeq() uint64 { return 0 } // SetStreamHandler -- fake. -func (p *FakeP2P) SetStreamHandler(_ string, _ network.StreamHandler) { +func (_ *FakeP2P) SetStreamHandler(_ string, _ network.StreamHandler) { } // SubscribeToTopic -- fake. -func (p *FakeP2P) SubscribeToTopic(_ string, _ ...pubsub.SubOpt) (*pubsub.Subscription, error) { +func (_ *FakeP2P) SubscribeToTopic(_ string, _ ...pubsub.SubOpt) (*pubsub.Subscription, error) { return nil, nil } // JoinTopic -- fake. -func (p *FakeP2P) JoinTopic(_ string, _ ...pubsub.TopicOpt) (*pubsub.Topic, error) { +func (_ *FakeP2P) JoinTopic(_ string, _ ...pubsub.TopicOpt) (*pubsub.Topic, error) { return nil, nil } // Host -- fake. -func (p *FakeP2P) Host() host.Host { +func (_ *FakeP2P) Host() host.Host { return nil } // Disconnect -- fake. -func (p *FakeP2P) Disconnect(_ peer.ID) error { +func (_ *FakeP2P) Disconnect(_ peer.ID) error { return nil } // Broadcast -- fake. -func (p *FakeP2P) Broadcast(_ context.Context, _ proto.Message) error { +func (_ *FakeP2P) Broadcast(_ context.Context, _ proto.Message) error { return nil } // BroadcastAttestation -- fake. -func (p *FakeP2P) BroadcastAttestation(_ context.Context, _ uint64, _ *ethpb.Attestation) error { +func (_ *FakeP2P) BroadcastAttestation(_ context.Context, _ uint64, _ *ethpb.Attestation) error { return nil } // BroadcastSyncCommitteeMessage -- fake. -func (p *FakeP2P) BroadcastSyncCommitteeMessage(_ context.Context, _ uint64, _ *ethpb.SyncCommitteeMessage) error { +func (_ *FakeP2P) BroadcastSyncCommitteeMessage(_ context.Context, _ uint64, _ *ethpb.SyncCommitteeMessage) error { return nil } // InterceptPeerDial -- fake. -func (p *FakeP2P) InterceptPeerDial(peer.ID) (allow bool) { +func (_ *FakeP2P) InterceptPeerDial(peer.ID) (allow bool) { return true } // InterceptAddrDial -- fake. -func (p *FakeP2P) InterceptAddrDial(peer.ID, multiaddr.Multiaddr) (allow bool) { +func (_ *FakeP2P) InterceptAddrDial(peer.ID, multiaddr.Multiaddr) (allow bool) { return true } // InterceptAccept -- fake. -func (p *FakeP2P) InterceptAccept(_ network.ConnMultiaddrs) (allow bool) { +func (_ *FakeP2P) InterceptAccept(_ network.ConnMultiaddrs) (allow bool) { return true } // InterceptSecured -- fake. -func (p *FakeP2P) InterceptSecured(network.Direction, peer.ID, network.ConnMultiaddrs) (allow bool) { +func (_ *FakeP2P) InterceptSecured(network.Direction, peer.ID, network.ConnMultiaddrs) (allow bool) { return true } // InterceptUpgraded -- fake. -func (p *FakeP2P) InterceptUpgraded(network.Conn) (allow bool, reason control.DisconnectReason) { +func (_ *FakeP2P) InterceptUpgraded(network.Conn) (allow bool, reason control.DisconnectReason) { return true, 0 } diff --git a/beacon-chain/p2p/testing/mock_host.go b/beacon-chain/p2p/testing/mock_host.go index ff0cc37bd23..d9ee59232e0 100644 --- a/beacon-chain/p2p/testing/mock_host.go +++ b/beacon-chain/p2p/testing/mock_host.go @@ -18,12 +18,12 @@ type MockHost struct { } // ID -- -func (m *MockHost) ID() peer.ID { +func (_ *MockHost) ID() peer.ID { return "" } // Peerstore -- -func (m *MockHost) Peerstore() peerstore.Peerstore { +func (_ *MockHost) Peerstore() peerstore.Peerstore { return nil } @@ -33,45 +33,45 @@ func (m *MockHost) Addrs() []ma.Multiaddr { } // Network -- -func (m *MockHost) Network() network.Network { +func (_ *MockHost) Network() network.Network { return nil } // Mux -- -func (m *MockHost) Mux() protocol.Switch { +func (_ *MockHost) Mux() protocol.Switch { return nil } // Connect -- -func (m *MockHost) Connect(ctx context.Context, pi peer.AddrInfo) error { +func (_ *MockHost) Connect(_ context.Context, _ peer.AddrInfo) error { return nil } // SetStreamHandler -- -func (m *MockHost) SetStreamHandler(pid protocol.ID, handler network.StreamHandler) {} +func (_ *MockHost) SetStreamHandler(_ protocol.ID, _ network.StreamHandler) {} // SetStreamHandlerMatch -- -func (m *MockHost) SetStreamHandlerMatch(protocol.ID, func(string) bool, network.StreamHandler) {} +func (_ *MockHost) SetStreamHandlerMatch(protocol.ID, func(string) bool, network.StreamHandler) {} // RemoveStreamHandler -- -func (m *MockHost) RemoveStreamHandler(pid protocol.ID) {} +func (_ *MockHost) RemoveStreamHandler(_ protocol.ID) {} // NewStream -- -func (m *MockHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error) { +func (_ *MockHost) NewStream(_ context.Context, _ peer.ID, _ ...protocol.ID) (network.Stream, error) { return nil, nil } // Close -- -func (m *MockHost) Close() error { +func (_ *MockHost) Close() error { return nil } // ConnManager -- -func (m *MockHost) ConnManager() connmgr.ConnManager { +func (_ *MockHost) ConnManager() connmgr.ConnManager { return nil } // EventBus -- -func (m *MockHost) EventBus() event.Bus { +func (_ *MockHost) EventBus() event.Bus { return nil } diff --git a/beacon-chain/p2p/testing/mock_peermanager.go b/beacon-chain/p2p/testing/mock_peermanager.go index b94157c5682..82e94232aec 100644 --- a/beacon-chain/p2p/testing/mock_peermanager.go +++ b/beacon-chain/p2p/testing/mock_peermanager.go @@ -20,7 +20,7 @@ type MockPeerManager struct { } // Disconnect . -func (m *MockPeerManager) Disconnect(peer.ID) error { +func (_ *MockPeerManager) Disconnect(peer.ID) error { return nil } @@ -48,12 +48,12 @@ func (m MockPeerManager) DiscoveryAddresses() ([]multiaddr.Multiaddr, error) { } // RefreshENR . -func (m MockPeerManager) RefreshENR() {} +func (_ MockPeerManager) RefreshENR() {} // FindPeersWithSubnet . -func (m MockPeerManager) FindPeersWithSubnet(_ context.Context, _ string, _, _ uint64) (bool, error) { +func (_ MockPeerManager) FindPeersWithSubnet(_ context.Context, _ string, _, _ uint64) (bool, error) { return true, nil } // AddPingMethod . -func (m MockPeerManager) AddPingMethod(_ func(ctx context.Context, id peer.ID) error) {} +func (_ MockPeerManager) AddPingMethod(_ func(ctx context.Context, id peer.ID) error) {} diff --git a/beacon-chain/p2p/testing/p2p.go b/beacon-chain/p2p/testing/p2p.go index 994fe76fcb6..b75131f80f1 100644 --- a/beacon-chain/p2p/testing/p2p.go +++ b/beacon-chain/p2p/testing/p2p.go @@ -225,7 +225,7 @@ func (p *TestP2P) LeaveTopic(topic string) error { } // Encoding returns ssz encoding. -func (p *TestP2P) Encoding() encoder.NetworkEncoding { +func (_ *TestP2P) Encoding() encoder.NetworkEncoding { return &encoder.SszNetworkEncoder{} } @@ -252,12 +252,12 @@ func (p *TestP2P) Host() host.Host { } // ENR returns the enr of the local peer. -func (p *TestP2P) ENR() *enr.Record { +func (_ *TestP2P) ENR() *enr.Record { return new(enr.Record) } // DiscoveryAddresses -- -func (p *TestP2P) DiscoveryAddresses() ([]multiaddr.Multiaddr, error) { +func (_ *TestP2P) DiscoveryAddresses() ([]multiaddr.Multiaddr, error) { return nil, nil } @@ -339,7 +339,7 @@ func (p *TestP2P) Send(ctx context.Context, msg interface{}, topic string, pid p } // Started always returns true. -func (p *TestP2P) Started() bool { +func (_ *TestP2P) Started() bool { return true } @@ -349,12 +349,12 @@ func (p *TestP2P) Peers() *peers.Status { } // FindPeersWithSubnet mocks the p2p func. -func (p *TestP2P) FindPeersWithSubnet(_ context.Context, _ string, _, _ uint64) (bool, error) { +func (_ *TestP2P) FindPeersWithSubnet(_ context.Context, _ string, _, _ uint64) (bool, error) { return false, nil } // RefreshENR mocks the p2p func. -func (p *TestP2P) RefreshENR() {} +func (_ *TestP2P) RefreshENR() {} // ForkDigest mocks the p2p func. func (p *TestP2P) ForkDigest() ([4]byte, error) { @@ -372,31 +372,31 @@ func (p *TestP2P) MetadataSeq() uint64 { } // AddPingMethod mocks the p2p func. -func (p *TestP2P) AddPingMethod(_ func(ctx context.Context, id peer.ID) error) { +func (_ *TestP2P) AddPingMethod(_ func(ctx context.Context, id peer.ID) error) { // no-op } // InterceptPeerDial . -func (p *TestP2P) InterceptPeerDial(peer.ID) (allow bool) { +func (_ *TestP2P) InterceptPeerDial(peer.ID) (allow bool) { return true } // InterceptAddrDial . -func (p *TestP2P) InterceptAddrDial(peer.ID, multiaddr.Multiaddr) (allow bool) { +func (_ *TestP2P) InterceptAddrDial(peer.ID, multiaddr.Multiaddr) (allow bool) { return true } // InterceptAccept . -func (p *TestP2P) InterceptAccept(_ network.ConnMultiaddrs) (allow bool) { +func (_ *TestP2P) InterceptAccept(_ network.ConnMultiaddrs) (allow bool) { return true } // InterceptSecured . -func (p *TestP2P) InterceptSecured(network.Direction, peer.ID, network.ConnMultiaddrs) (allow bool) { +func (_ *TestP2P) InterceptSecured(network.Direction, peer.ID, network.ConnMultiaddrs) (allow bool) { return true } // InterceptUpgraded . -func (p *TestP2P) InterceptUpgraded(network.Conn) (allow bool, reason control.DisconnectReason) { +func (_ *TestP2P) InterceptUpgraded(network.Conn) (allow bool, reason control.DisconnectReason) { return true, 0 } diff --git a/beacon-chain/p2p/types/object_mapping.go b/beacon-chain/p2p/types/object_mapping.go index bada076552a..5d422f90ba5 100644 --- a/beacon-chain/p2p/types/object_mapping.go +++ b/beacon-chain/p2p/types/object_mapping.go @@ -3,7 +3,6 @@ package types import ( "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/metadata" @@ -34,7 +33,7 @@ func InitializeDataMaps() { // Reset our block map. BlockMap = map[[4]byte]func() (block.SignedBeaconBlock, error){ bytesutil.ToBytes4(params.BeaconConfig().GenesisForkVersion): func() (block.SignedBeaconBlock, error) { - return wrapper.WrappedPhase0SignedBeaconBlock(ð.SignedBeaconBlock{}), nil + return wrapper.WrappedPhase0SignedBeaconBlock(ðpb.SignedBeaconBlock{}), nil }, bytesutil.ToBytes4(params.BeaconConfig().AltairForkVersion): func() (block.SignedBeaconBlock, error) { return wrapper.WrappedAltairSignedBeaconBlock(ðpb.SignedBeaconBlockAltair{Block: ðpb.BeaconBlockAltair{}}) diff --git a/beacon-chain/powchain/block_reader.go b/beacon-chain/powchain/block_reader.go index aec46028a03..3f5bad3e585 100644 --- a/beacon-chain/powchain/block_reader.go +++ b/beacon-chain/powchain/block_reader.go @@ -47,7 +47,7 @@ func (s *Service) BlockExists(ctx context.Context, hash common.Hash) (bool, *big // BlockExistsWithCache returns true if the block exists in cache, its height and any possible error encountered. func (s *Service) BlockExistsWithCache(ctx context.Context, hash common.Hash) (bool, *big.Int, error) { - ctx, span := trace.StartSpan(ctx, "beacon-chain.web3service.BlockExistsWithCache") + _, span := trace.StartSpan(ctx, "beacon-chain.web3service.BlockExistsWithCache") defer span.End() if exists, hdrInfo, err := s.headerCache.HeaderInfoByHash(hash); exists || err != nil { if err != nil { diff --git a/beacon-chain/powchain/log_processing.go b/beacon-chain/powchain/log_processing.go index d666a531fa3..53824e40bcd 100644 --- a/beacon-chain/powchain/log_processing.go +++ b/beacon-chain/powchain/log_processing.go @@ -22,7 +22,6 @@ import ( "github.com/prysmaticlabs/prysm/crypto/hash" "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/time/slots" "github.com/sirupsen/logrus" ) @@ -245,7 +244,7 @@ func (s *Service) ProcessChainStart(genesisTime uint64, eth1BlockHash [32]byte, } } -func (s *Service) createGenesisTime(timeStamp uint64) uint64 { +func createGenesisTime(timeStamp uint64) uint64 { // adds in the genesis delay to the eth1 block time // on which it was triggered. return timeStamp + params.BeaconConfig().GenesisDelay @@ -487,7 +486,7 @@ func (s *Service) currentCountAndTime(ctx context.Context, blockTime uint64) (ui log.WithError(err).Error("Could not determine active validator count from pre genesis state") return 0, 0 } - return valCount, s.createGenesisTime(blockTime) + return valCount, createGenesisTime(blockTime) } func (s *Service) checkForChainstart(ctx context.Context, blockHash [32]byte, blockNumber *big.Int, blockTime uint64) { @@ -508,7 +507,7 @@ func (s *Service) savePowchainData(ctx context.Context) error { if err != nil { return err } - eth1Data := &protodb.ETH1ChainData{ + eth1Data := ðpb.ETH1ChainData{ CurrentEth1Data: s.latestEth1Data, ChainstartData: s.chainStartData, BeaconState: pbState, // I promise not to mutate it! diff --git a/beacon-chain/powchain/prometheus.go b/beacon-chain/powchain/prometheus.go index 7556c1fbfb4..118b4491f54 100644 --- a/beacon-chain/powchain/prometheus.go +++ b/beacon-chain/powchain/prometheus.go @@ -148,6 +148,6 @@ func NewPowchainCollector(ctx context.Context) (*PowchainCollector, error) { type NopBeaconNodeStatsUpdater struct{} -func (nop *NopBeaconNodeStatsUpdater) Update(_ clientstats.BeaconNodeStats) {} +func (_ *NopBeaconNodeStatsUpdater) Update(_ clientstats.BeaconNodeStats) {} var _ BeaconNodeStatsUpdater = &NopBeaconNodeStatsUpdater{} diff --git a/beacon-chain/powchain/service.go b/beacon-chain/powchain/service.go index 3ee3ad06319..0d3cac5efe9 100644 --- a/beacon-chain/powchain/service.go +++ b/beacon-chain/powchain/service.go @@ -40,7 +40,6 @@ import ( "github.com/prysmaticlabs/prysm/network" "github.com/prysmaticlabs/prysm/network/authorization" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" prysmTime "github.com/prysmaticlabs/prysm/time" "github.com/prysmaticlabs/prysm/time/slots" "github.com/sirupsen/logrus" @@ -152,10 +151,10 @@ type Service struct { eth1DataFetcher RPCDataFetcher rpcClient RPCClient headerCache *headerCache // cache to store block hash/block height. - latestEth1Data *protodb.LatestETH1Data + latestEth1Data *ethpb.LatestETH1Data depositContractCaller *contracts.DepositContractCaller depositTrie *trie.SparseMerkleTrie - chainStartData *protodb.ChainStartData + chainStartData *ethpb.ChainStartData lastReceivedMerkleIndex int64 // Keeps track of the last received index to prevent log spam. runError error preGenesisState state.BeaconState @@ -182,7 +181,7 @@ func NewService(ctx context.Context, opts ...Option) (*Service, error) { beaconNodeStatsUpdater: &NopBeaconNodeStatsUpdater{}, eth1HeaderReqLimit: defaultEth1HeaderReqLimit, }, - latestEth1Data: &protodb.LatestETH1Data{ + latestEth1Data: ðpb.LatestETH1Data{ BlockHeight: 0, BlockTime: 0, BlockHash: []byte{}, @@ -190,7 +189,7 @@ func NewService(ctx context.Context, opts ...Option) (*Service, error) { }, headerCache: newHeaderCache(), depositTrie: depositTrie, - chainStartData: &protodb.ChainStartData{ + chainStartData: ðpb.ChainStartData{ Eth1Data: ðpb.Eth1Data{}, ChainstartDeposits: make([]*ethpb.Deposit, 0), }, @@ -566,7 +565,7 @@ func (s *Service) retryETH1Node(err error) { s.runError = nil } -func (s *Service) initDepositCaches(ctx context.Context, ctrs []*protodb.DepositContainer) error { +func (s *Service) initDepositCaches(ctx context.Context, ctrs []*ethpb.DepositContainer) error { if len(ctrs) == 0 { return nil } @@ -949,7 +948,7 @@ func (s *Service) fallbackToNextEndpoint() { // initializes our service from the provided eth1data object by initializing all the relevant // fields and data. -func (s *Service) initializeEth1Data(ctx context.Context, eth1DataInDB *protodb.ETH1ChainData) error { +func (s *Service) initializeEth1Data(ctx context.Context, eth1DataInDB *ethpb.ETH1ChainData) error { // The node has no eth1data persisted on disk, so we exit and instead // request from contract logs. if eth1DataInDB == nil { @@ -975,7 +974,7 @@ func (s *Service) initializeEth1Data(ctx context.Context, eth1DataInDB *protodb. // validates that all deposit containers are valid and have their relevant indices // in order. -func (s *Service) validateDepositContainers(ctrs []*protodb.DepositContainer) bool { +func validateDepositContainers(ctrs []*ethpb.DepositContainer) bool { ctrLen := len(ctrs) // Exit for empty containers. if ctrLen == 0 { @@ -1011,19 +1010,19 @@ func (s *Service) ensureValidPowchainData(ctx context.Context) error { if err != nil { return errors.Wrap(err, "unable to retrieve eth1 data") } - if eth1Data == nil || !eth1Data.ChainstartData.Chainstarted || !s.validateDepositContainers(eth1Data.DepositContainers) { + if eth1Data == nil || !eth1Data.ChainstartData.Chainstarted || !validateDepositContainers(eth1Data.DepositContainers) { pbState, err := v1.ProtobufBeaconState(s.preGenesisState.InnerStateUnsafe()) if err != nil { return err } - s.chainStartData = &protodb.ChainStartData{ + s.chainStartData = ðpb.ChainStartData{ Chainstarted: true, GenesisTime: genState.GenesisTime(), GenesisBlock: 0, Eth1Data: genState.Eth1Data(), ChainstartDeposits: make([]*ethpb.Deposit, 0), } - eth1Data = &protodb.ETH1ChainData{ + eth1Data = ðpb.ETH1ChainData{ CurrentEth1Data: s.latestEth1Data, ChainstartData: s.chainStartData, BeaconState: pbState, diff --git a/beacon-chain/powchain/service_test.go b/beacon-chain/powchain/service_test.go index 3b6535daff7..665fd955e93 100644 --- a/beacon-chain/powchain/service_test.go +++ b/beacon-chain/powchain/service_test.go @@ -26,7 +26,6 @@ import ( "github.com/prysmaticlabs/prysm/monitoring/clientstats" "github.com/prysmaticlabs/prysm/network" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" "github.com/prysmaticlabs/prysm/testing/util" @@ -117,7 +116,7 @@ func (g *goodFetcher) HeaderByNumber(_ context.Context, number *big.Int) (*gethT return header, nil } -func (g *goodFetcher) SyncProgress(_ context.Context) (*ethereum.SyncProgress, error) { +func (_ *goodFetcher) SyncProgress(_ context.Context) (*ethereum.SyncProgress, error) { return nil, nil } @@ -227,9 +226,9 @@ func TestStart_NoHttpEndpointDefinedSucceeds_WithChainStarted(t *testing.T) { testAcc, err := contracts.Setup() require.NoError(t, err, "Unable to set up simulated backend") - require.NoError(t, beaconDB.SavePowchainData(context.Background(), &protodb.ETH1ChainData{ - ChainstartData: &protodb.ChainStartData{Chainstarted: true}, - Trie: &protodb.SparseMerkleTrie{}, + require.NoError(t, beaconDB.SavePowchainData(context.Background(), ðpb.ETH1ChainData{ + ChainstartData: ðpb.ChainStartData{Chainstarted: true}, + Trie: ðpb.SparseMerkleTrie{}, })) s, err := NewService(context.Background(), WithHttpEndpoints([]string{""}), @@ -350,9 +349,9 @@ func TestStatus(t *testing.T) { testCases := map[*Service]string{ // "status is ok" cases {}: "", - {isRunning: true, latestEth1Data: &protodb.LatestETH1Data{BlockTime: afterFiveMinutesAgo}}: "", - {isRunning: false, latestEth1Data: &protodb.LatestETH1Data{BlockTime: beforeFiveMinutesAgo}}: "", - {isRunning: false, runError: errors.New("test runError")}: "", + {isRunning: true, latestEth1Data: ðpb.LatestETH1Data{BlockTime: afterFiveMinutesAgo}}: "", + {isRunning: false, latestEth1Data: ðpb.LatestETH1Data{BlockTime: beforeFiveMinutesAgo}}: "", + {isRunning: false, runError: errors.New("test runError")}: "", // "status is error" cases {isRunning: true, runError: errors.New("test runError")}: "test runError", } @@ -425,7 +424,7 @@ func TestLogTillGenesis_OK(t *testing.T) { for i := 0; i < 30; i++ { testAcc.Backend.Commit() } - web3Service.latestEth1Data = &protodb.LatestETH1Data{LastRequestedBlock: 0} + web3Service.latestEth1Data = ðpb.LatestETH1Data{LastRequestedBlock: 0} // Spin off to a separate routine go web3Service.run(web3Service.ctx.Done()) // Wait for 2 seconds so that the @@ -436,7 +435,7 @@ func TestLogTillGenesis_OK(t *testing.T) { } func TestInitDepositCache_OK(t *testing.T) { - ctrs := []*protodb.DepositContainer{ + ctrs := []*ethpb.DepositContainer{ {Index: 0, Eth1BlockHeight: 2, Deposit: ðpb.Deposit{Proof: [][]byte{[]byte("A")}, Data: ðpb.Deposit_Data{PublicKey: []byte{}}}}, {Index: 1, Eth1BlockHeight: 4, Deposit: ðpb.Deposit{Proof: [][]byte{[]byte("B")}, Data: ðpb.Deposit_Data{PublicKey: []byte{}}}}, {Index: 2, Eth1BlockHeight: 6, Deposit: ðpb.Deposit{Proof: [][]byte{[]byte("c")}, Data: ðpb.Deposit_Data{PublicKey: []byte{}}}}, @@ -444,7 +443,7 @@ func TestInitDepositCache_OK(t *testing.T) { gs, _ := util.DeterministicGenesisState(t, 1) beaconDB := dbutil.SetupDB(t) s := &Service{ - chainStartData: &protodb.ChainStartData{Chainstarted: false}, + chainStartData: ðpb.ChainStartData{Chainstarted: false}, preGenesisState: gs, cfg: &config{beaconDB: beaconDB}, } @@ -467,7 +466,7 @@ func TestInitDepositCache_OK(t *testing.T) { } func TestInitDepositCacheWithFinalization_OK(t *testing.T) { - ctrs := []*protodb.DepositContainer{ + ctrs := []*ethpb.DepositContainer{ { Index: 0, Eth1BlockHeight: 2, @@ -505,7 +504,7 @@ func TestInitDepositCacheWithFinalization_OK(t *testing.T) { gs, _ := util.DeterministicGenesisState(t, 1) beaconDB := dbutil.SetupDB(t) s := &Service{ - chainStartData: &protodb.ChainStartData{Chainstarted: false}, + chainStartData: ðpb.ChainStartData{Chainstarted: false}, preGenesisState: gs, cfg: &config{beaconDB: beaconDB}, } @@ -752,9 +751,9 @@ func TestService_EnsureValidPowchainData(t *testing.T) { require.NoError(t, s1.cfg.beaconDB.SaveGenesisData(context.Background(), genState)) - err = s1.cfg.beaconDB.SavePowchainData(context.Background(), &protodb.ETH1ChainData{ - ChainstartData: &protodb.ChainStartData{Chainstarted: true}, - DepositContainers: []*protodb.DepositContainer{{Index: 1}}, + err = s1.cfg.beaconDB.SavePowchainData(context.Background(), ðpb.ETH1ChainData{ + ChainstartData: ðpb.ChainStartData{Chainstarted: true}, + DepositContainers: []*ethpb.DepositContainer{{Index: 1}}, }) require.NoError(t, err) require.NoError(t, s1.ensureValidPowchainData(context.Background())) @@ -767,34 +766,24 @@ func TestService_EnsureValidPowchainData(t *testing.T) { } func TestService_ValidateDepositContainers(t *testing.T) { - beaconDB := dbutil.SetupDB(t) - cache, err := depositcache.New() - require.NoError(t, err) - - s1, err := NewService(context.Background(), - WithDatabase(beaconDB), - WithDepositCache(cache), - ) - require.NoError(t, err) - var tt = []struct { name string - ctrsFunc func() []*protodb.DepositContainer + ctrsFunc func() []*ethpb.DepositContainer expectedRes bool }{ { name: "zero containers", - ctrsFunc: func() []*protodb.DepositContainer { - return make([]*protodb.DepositContainer, 0) + ctrsFunc: func() []*ethpb.DepositContainer { + return make([]*ethpb.DepositContainer, 0) }, expectedRes: true, }, { name: "ordered containers", - ctrsFunc: func() []*protodb.DepositContainer { - ctrs := make([]*protodb.DepositContainer, 0) + ctrsFunc: func() []*ethpb.DepositContainer { + ctrs := make([]*ethpb.DepositContainer, 0) for i := 0; i < 10; i++ { - ctrs = append(ctrs, &protodb.DepositContainer{Index: int64(i), Eth1BlockHeight: uint64(i + 10)}) + ctrs = append(ctrs, ðpb.DepositContainer{Index: int64(i), Eth1BlockHeight: uint64(i + 10)}) } return ctrs }, @@ -802,10 +791,10 @@ func TestService_ValidateDepositContainers(t *testing.T) { }, { name: "0th container missing", - ctrsFunc: func() []*protodb.DepositContainer { - ctrs := make([]*protodb.DepositContainer, 0) + ctrsFunc: func() []*ethpb.DepositContainer { + ctrs := make([]*ethpb.DepositContainer, 0) for i := 1; i < 10; i++ { - ctrs = append(ctrs, &protodb.DepositContainer{Index: int64(i), Eth1BlockHeight: uint64(i + 10)}) + ctrs = append(ctrs, ðpb.DepositContainer{Index: int64(i), Eth1BlockHeight: uint64(i + 10)}) } return ctrs }, @@ -813,13 +802,13 @@ func TestService_ValidateDepositContainers(t *testing.T) { }, { name: "skipped containers", - ctrsFunc: func() []*protodb.DepositContainer { - ctrs := make([]*protodb.DepositContainer, 0) + ctrsFunc: func() []*ethpb.DepositContainer { + ctrs := make([]*ethpb.DepositContainer, 0) for i := 0; i < 10; i++ { if i == 5 || i == 7 { continue } - ctrs = append(ctrs, &protodb.DepositContainer{Index: int64(i), Eth1BlockHeight: uint64(i + 10)}) + ctrs = append(ctrs, ðpb.DepositContainer{Index: int64(i), Eth1BlockHeight: uint64(i + 10)}) } return ctrs }, @@ -828,7 +817,7 @@ func TestService_ValidateDepositContainers(t *testing.T) { } for _, test := range tt { - assert.Equal(t, test.expectedRes, s1.validateDepositContainers(test.ctrsFunc())) + assert.Equal(t, test.expectedRes, validateDepositContainers(test.ctrsFunc())) } } diff --git a/beacon-chain/powchain/testing/mock_faulty_powchain.go b/beacon-chain/powchain/testing/mock_faulty_powchain.go index 0e60a2e45f2..51ca92571b4 100644 --- a/beacon-chain/powchain/testing/mock_faulty_powchain.go +++ b/beacon-chain/powchain/testing/mock_faulty_powchain.go @@ -21,12 +21,12 @@ type FaultyMockPOWChain struct { } // Eth2GenesisPowchainInfo -- -func (f *FaultyMockPOWChain) Eth2GenesisPowchainInfo() (uint64, *big.Int) { +func (_ *FaultyMockPOWChain) Eth2GenesisPowchainInfo() (uint64, *big.Int) { return 0, big.NewInt(0) } // LatestBlockHeight -- -func (f *FaultyMockPOWChain) LatestBlockHeight() *big.Int { +func (_ *FaultyMockPOWChain) LatestBlockHeight() *big.Int { return big.NewInt(0) } @@ -40,52 +40,52 @@ func (f *FaultyMockPOWChain) BlockExists(_ context.Context, _ common.Hash) (bool } // BlockHashByHeight -- -func (f *FaultyMockPOWChain) BlockHashByHeight(_ context.Context, _ *big.Int) (common.Hash, error) { +func (_ *FaultyMockPOWChain) BlockHashByHeight(_ context.Context, _ *big.Int) (common.Hash, error) { return [32]byte{}, errors.New("failed") } // BlockTimeByHeight -- -func (f *FaultyMockPOWChain) BlockTimeByHeight(_ context.Context, _ *big.Int) (uint64, error) { +func (_ *FaultyMockPOWChain) BlockTimeByHeight(_ context.Context, _ *big.Int) (uint64, error) { return 0, errors.New("failed") } // BlockByTimestamp -- -func (f *FaultyMockPOWChain) BlockByTimestamp(_ context.Context, _ uint64) (*types.HeaderInfo, error) { +func (_ *FaultyMockPOWChain) BlockByTimestamp(_ context.Context, _ uint64) (*types.HeaderInfo, error) { return &types.HeaderInfo{Number: big.NewInt(0)}, nil } // DepositRoot -- -func (f *FaultyMockPOWChain) DepositRoot() [32]byte { +func (_ *FaultyMockPOWChain) DepositRoot() [32]byte { return [32]byte{} } // DepositTrie -- -func (f *FaultyMockPOWChain) DepositTrie() *trie.SparseMerkleTrie { +func (_ *FaultyMockPOWChain) DepositTrie() *trie.SparseMerkleTrie { return &trie.SparseMerkleTrie{} } // ChainStartDeposits -- -func (f *FaultyMockPOWChain) ChainStartDeposits() []*ethpb.Deposit { +func (_ *FaultyMockPOWChain) ChainStartDeposits() []*ethpb.Deposit { return []*ethpb.Deposit{} } // ChainStartEth1Data -- -func (f *FaultyMockPOWChain) ChainStartEth1Data() *ethpb.Eth1Data { +func (_ *FaultyMockPOWChain) ChainStartEth1Data() *ethpb.Eth1Data { return ðpb.Eth1Data{} } // PreGenesisState -- -func (f *FaultyMockPOWChain) PreGenesisState() state.BeaconState { +func (_ *FaultyMockPOWChain) PreGenesisState() state.BeaconState { return &v1.BeaconState{} } // ClearPreGenesisData -- -func (f *FaultyMockPOWChain) ClearPreGenesisData() { +func (_ *FaultyMockPOWChain) ClearPreGenesisData() { // no-op } // IsConnectedToETH1 -- -func (f *FaultyMockPOWChain) IsConnectedToETH1() bool { +func (_ *FaultyMockPOWChain) IsConnectedToETH1() bool { return true } diff --git a/beacon-chain/powchain/testing/mock_powchain.go b/beacon-chain/powchain/testing/mock_powchain.go index dd8e1e28eac..171d410a595 100644 --- a/beacon-chain/powchain/testing/mock_powchain.go +++ b/beacon-chain/powchain/testing/mock_powchain.go @@ -55,7 +55,7 @@ func (m *POWChain) Eth2GenesisPowchainInfo() (uint64, *big.Int) { } // DepositTrie -- -func (m *POWChain) DepositTrie() *trie.SparseMerkleTrie { +func (_ *POWChain) DepositTrie() *trie.SparseMerkleTrie { return &trie.SparseMerkleTrie{} } @@ -104,13 +104,13 @@ func (m *POWChain) BlockByTimestamp(_ context.Context, time uint64) (*types.Head } // DepositRoot -- -func (m *POWChain) DepositRoot() [32]byte { +func (_ *POWChain) DepositRoot() [32]byte { root := []byte("depositroot") return bytesutil.ToBytes32(root) } // ChainStartDeposits -- -func (m *POWChain) ChainStartDeposits() []*ethpb.Deposit { +func (_ *POWChain) ChainStartDeposits() []*ethpb.Deposit { return []*ethpb.Deposit{} } @@ -125,12 +125,12 @@ func (m *POWChain) PreGenesisState() state.BeaconState { } // ClearPreGenesisData -- -func (m *POWChain) ClearPreGenesisData() { +func (_ *POWChain) ClearPreGenesisData() { // no-op } // IsConnectedToETH1 -- -func (m *POWChain) IsConnectedToETH1() bool { +func (_ *POWChain) IsConnectedToETH1() bool { return true } diff --git a/beacon-chain/rpc/apimiddleware/endpoint_factory.go b/beacon-chain/rpc/apimiddleware/endpoint_factory.go index dea2d356409..dd0f54c2f52 100644 --- a/beacon-chain/rpc/apimiddleware/endpoint_factory.go +++ b/beacon-chain/rpc/apimiddleware/endpoint_factory.go @@ -14,7 +14,7 @@ func (f *BeaconEndpointFactory) IsNil() bool { } // Paths is a collection of all valid beacon chain API paths. -func (f *BeaconEndpointFactory) Paths() []string { +func (_ *BeaconEndpointFactory) Paths() []string { return []string{ "/eth/v1/beacon/genesis", "/eth/v1/beacon/states/{state_id}/root", @@ -67,7 +67,7 @@ func (f *BeaconEndpointFactory) Paths() []string { } // Create returns a new endpoint for the provided API path. -func (f *BeaconEndpointFactory) Create(path string) (*apimiddleware.Endpoint, error) { +func (_ *BeaconEndpointFactory) Create(path string) (*apimiddleware.Endpoint, error) { endpoint := apimiddleware.DefaultEndpoint() switch path { case "/eth/v1/beacon/genesis": diff --git a/beacon-chain/rpc/eth/beacon/config.go b/beacon-chain/rpc/eth/beacon/config.go index 9fd522bb3a2..94935391b66 100644 --- a/beacon-chain/rpc/eth/beacon/config.go +++ b/beacon-chain/rpc/eth/beacon/config.go @@ -18,8 +18,8 @@ import ( ) // GetForkSchedule retrieve all scheduled upcoming forks this node is aware of. -func (bs *Server) GetForkSchedule(ctx context.Context, _ *emptypb.Empty) (*ethpb.ForkScheduleResponse, error) { - ctx, span := trace.StartSpan(ctx, "beacon.GetForkSchedule") +func (_ *Server) GetForkSchedule(ctx context.Context, _ *emptypb.Empty) (*ethpb.ForkScheduleResponse, error) { + _, span := trace.StartSpan(ctx, "beacon.GetForkSchedule") defer span.End() schedule := params.BeaconConfig().ForkVersionSchedule @@ -56,8 +56,8 @@ func (bs *Server) GetForkSchedule(ctx context.Context, _ *emptypb.Empty) (*ethpb // Values are returned with following format: // - any value starting with 0x in the spec is returned as a hex string. // - all other values are returned as number. -func (bs *Server) GetSpec(ctx context.Context, _ *emptypb.Empty) (*ethpb.SpecResponse, error) { - ctx, span := trace.StartSpan(ctx, "beacon.GetSpec") +func (_ *Server) GetSpec(ctx context.Context, _ *emptypb.Empty) (*ethpb.SpecResponse, error) { + _, span := trace.StartSpan(ctx, "beacon.GetSpec") defer span.End() data, err := prepareConfigSpec() @@ -68,8 +68,8 @@ func (bs *Server) GetSpec(ctx context.Context, _ *emptypb.Empty) (*ethpb.SpecRes } // GetDepositContract retrieves deposit contract address and genesis fork version. -func (bs *Server) GetDepositContract(ctx context.Context, _ *emptypb.Empty) (*ethpb.DepositContractResponse, error) { - ctx, span := trace.StartSpan(ctx, "beaconv1.GetDepositContract") +func (_ *Server) GetDepositContract(ctx context.Context, _ *emptypb.Empty) (*ethpb.DepositContractResponse, error) { + _, span := trace.StartSpan(ctx, "beaconv1.GetDepositContract") defer span.End() return ðpb.DepositContractResponse{ diff --git a/beacon-chain/rpc/eth/beacon/pool.go b/beacon-chain/rpc/eth/beacon/pool.go index d9b76dd09e1..89438233a3f 100644 --- a/beacon-chain/rpc/eth/beacon/pool.go +++ b/beacon-chain/rpc/eth/beacon/pool.go @@ -24,7 +24,7 @@ import ( // ListPoolAttestations retrieves attestations known by the node but // not necessarily incorporated into any block. Allows filtering by committee index or slot. func (bs *Server) ListPoolAttestations(ctx context.Context, req *ethpbv1.AttestationsPoolRequest) (*ethpbv1.AttestationsPoolResponse, error) { - ctx, span := trace.StartSpan(ctx, "beacon.ListPoolAttestations") + _, span := trace.StartSpan(ctx, "beacon.ListPoolAttestations") defer span.End() attestations := bs.AttestationsPool.AggregatedAttestations() diff --git a/beacon-chain/rpc/eth/beacon/pool_test.go b/beacon-chain/rpc/eth/beacon/pool_test.go index b66bf0e93b0..5d21744b369 100644 --- a/beacon-chain/rpc/eth/beacon/pool_test.go +++ b/beacon-chain/rpc/eth/beacon/pool_test.go @@ -10,8 +10,7 @@ import ( eth2types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/go-bitfield" grpcutil "github.com/prysmaticlabs/prysm/api/grpc" - chainMock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" - notifiermock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" + blockchainmock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/beacon-chain/core/signing" "github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations" "github.com/prysmaticlabs/prysm/beacon-chain/operations/slashings" @@ -137,7 +136,7 @@ func TestListPoolAttestations(t *testing.T) { Signature: bytesutil.PadTo([]byte("signature2"), 96), } s := &Server{ - ChainInfoFetcher: &chainMock.ChainService{State: state}, + ChainInfoFetcher: &blockchainmock.ChainService{State: state}, AttestationsPool: attestations.NewPool(), } require.NoError(t, s.AttestationsPool.SaveAggregatedAttestations([]*ethpbv1alpha1.Attestation{att1, att2, att3})) @@ -270,7 +269,7 @@ func TestListPoolAttesterSlashings(t *testing.T) { } s := &Server{ - ChainInfoFetcher: &chainMock.ChainService{State: state}, + ChainInfoFetcher: &blockchainmock.ChainService{State: state}, SlashingsPool: &slashings.PoolMock{PendingAttSlashings: []*ethpbv1alpha1.AttesterSlashing{slashing1, slashing2}}, } @@ -330,7 +329,7 @@ func TestListPoolProposerSlashings(t *testing.T) { } s := &Server{ - ChainInfoFetcher: &chainMock.ChainService{State: state}, + ChainInfoFetcher: &blockchainmock.ChainService{State: state}, SlashingsPool: &slashings.PoolMock{PendingPropSlashings: []*ethpbv1alpha1.ProposerSlashing{slashing1, slashing2}}, } @@ -360,7 +359,7 @@ func TestListPoolVoluntaryExits(t *testing.T) { } s := &Server{ - ChainInfoFetcher: &chainMock.ChainService{State: state}, + ChainInfoFetcher: &blockchainmock.ChainService{State: state}, VoluntaryExitsPool: &voluntaryexits.PoolMock{Exits: []*ethpbv1alpha1.SignedVoluntaryExit{exit1, exit2}}, } @@ -432,7 +431,7 @@ func TestSubmitAttesterSlashing_Ok(t *testing.T) { broadcaster := &p2pMock.MockBroadcaster{} s := &Server{ - ChainInfoFetcher: &chainMock.ChainService{State: state}, + ChainInfoFetcher: &blockchainmock.ChainService{State: state}, SlashingsPool: &slashings.PoolMock{}, Broadcaster: broadcaster, } @@ -475,7 +474,7 @@ func TestSubmitAttesterSlashing_InvalidSlashing(t *testing.T) { broadcaster := &p2pMock.MockBroadcaster{} s := &Server{ - ChainInfoFetcher: &chainMock.ChainService{State: state}, + ChainInfoFetcher: &blockchainmock.ChainService{State: state}, SlashingsPool: &slashings.PoolMock{}, Broadcaster: broadcaster, } @@ -539,7 +538,7 @@ func TestSubmitProposerSlashing_Ok(t *testing.T) { broadcaster := &p2pMock.MockBroadcaster{} s := &Server{ - ChainInfoFetcher: &chainMock.ChainService{State: state}, + ChainInfoFetcher: &blockchainmock.ChainService{State: state}, SlashingsPool: &slashings.PoolMock{}, Broadcaster: broadcaster, } @@ -575,7 +574,7 @@ func TestSubmitProposerSlashing_InvalidSlashing(t *testing.T) { broadcaster := &p2pMock.MockBroadcaster{} s := &Server{ - ChainInfoFetcher: &chainMock.ChainService{State: state}, + ChainInfoFetcher: &blockchainmock.ChainService{State: state}, SlashingsPool: &slashings.PoolMock{}, Broadcaster: broadcaster, } @@ -618,7 +617,7 @@ func TestSubmitVoluntaryExit_Ok(t *testing.T) { broadcaster := &p2pMock.MockBroadcaster{} s := &Server{ - ChainInfoFetcher: &chainMock.ChainService{State: state}, + ChainInfoFetcher: &blockchainmock.ChainService{State: state}, VoluntaryExitsPool: &voluntaryexits.PoolMock{}, Broadcaster: broadcaster, } @@ -656,7 +655,7 @@ func TestSubmitVoluntaryExit_InvalidValidatorIndex(t *testing.T) { broadcaster := &p2pMock.MockBroadcaster{} s := &Server{ - ChainInfoFetcher: &chainMock.ChainService{State: state}, + ChainInfoFetcher: &blockchainmock.ChainService{State: state}, VoluntaryExitsPool: &voluntaryexits.PoolMock{}, Broadcaster: broadcaster, } @@ -691,7 +690,7 @@ func TestSubmitVoluntaryExit_InvalidExit(t *testing.T) { broadcaster := &p2pMock.MockBroadcaster{} s := &Server{ - ChainInfoFetcher: &chainMock.ChainService{State: state}, + ChainInfoFetcher: &blockchainmock.ChainService{State: state}, VoluntaryExitsPool: &voluntaryexits.PoolMock{}, Broadcaster: broadcaster, } @@ -778,13 +777,13 @@ func TestServer_SubmitAttestations_Ok(t *testing.T) { } broadcaster := &p2pMock.MockBroadcaster{} - chainService := &chainMock.ChainService{State: state} + chainService := &blockchainmock.ChainService{State: state} s := &Server{ HeadFetcher: chainService, ChainInfoFetcher: chainService, AttestationsPool: attestations.NewPool(), Broadcaster: broadcaster, - OperationNotifier: ¬ifiermock.MockOperationNotifier{}, + OperationNotifier: &blockchainmock.MockOperationNotifier{}, } _, err = s.SubmitAttestations(ctx, ðpbv1.SubmitAttestationsRequest{ @@ -884,13 +883,13 @@ func TestServer_SubmitAttestations_ValidAttestationSubmitted(t *testing.T) { attValid.Signature = sig.Marshal() broadcaster := &p2pMock.MockBroadcaster{} - chainService := &chainMock.ChainService{State: state} + chainService := &blockchainmock.ChainService{State: state} s := &Server{ HeadFetcher: chainService, ChainInfoFetcher: chainService, AttestationsPool: attestations.NewPool(), Broadcaster: broadcaster, - OperationNotifier: ¬ifiermock.MockOperationNotifier{}, + OperationNotifier: &blockchainmock.MockOperationNotifier{}, } _, err = s.SubmitAttestations(ctx, ðpbv1.SubmitAttestationsRequest{ @@ -955,13 +954,13 @@ func TestServer_SubmitAttestations_InvalidAttestationGRPCHeader(t *testing.T) { Signature: nil, } - chain := &chainMock.ChainService{State: state} + chain := &blockchainmock.ChainService{State: state} broadcaster := &p2pMock.MockBroadcaster{} s := &Server{ ChainInfoFetcher: chain, AttestationsPool: attestations.NewPool(), Broadcaster: broadcaster, - OperationNotifier: ¬ifiermock.MockOperationNotifier{}, + OperationNotifier: &blockchainmock.MockOperationNotifier{}, HeadFetcher: chain, } diff --git a/beacon-chain/rpc/eth/beacon/state.go b/beacon-chain/rpc/eth/beacon/state.go index 9365026045b..f3edb3a2236 100644 --- a/beacon-chain/rpc/eth/beacon/state.go +++ b/beacon-chain/rpc/eth/beacon/state.go @@ -27,7 +27,7 @@ type stateRequest struct { // GetGenesis retrieves details of the chain's genesis which can be used to identify chain. func (bs *Server) GetGenesis(ctx context.Context, _ *emptypb.Empty) (*ethpb.GenesisResponse, error) { - ctx, span := trace.StartSpan(ctx, "beacon.GetGenesis") + _, span := trace.StartSpan(ctx, "beacon.GetGenesis") defer span.End() genesisTime := bs.GenesisTimeFetcher.GenesisTime() diff --git a/beacon-chain/rpc/eth/beacon/sync_committee.go b/beacon-chain/rpc/eth/beacon/sync_committee.go index d2e435704b9..2b507f1cfca 100644 --- a/beacon-chain/rpc/eth/beacon/sync_committee.go +++ b/beacon-chain/rpc/eth/beacon/sync_committee.go @@ -13,7 +13,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - "github.com/prysmaticlabs/prysm/proto/eth/v2" ethpbv2 "github.com/prysmaticlabs/prysm/proto/eth/v2" ethpbalpha "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/time/slots" @@ -142,7 +141,7 @@ func nextCommitteeIndicesFromState(st state.BeaconState) ([]types.ValidatorIndex return committeeIndices, committee, nil } -func extractSyncSubcommittees(st state.BeaconState, committee *ethpbalpha.SyncCommittee) ([]*eth.SyncSubcommitteeValidators, error) { +func extractSyncSubcommittees(st state.BeaconState, committee *ethpbalpha.SyncCommittee) ([]*ethpbv2.SyncSubcommitteeValidators, error) { subcommitteeCount := params.BeaconConfig().SyncCommitteeSubnetCount subcommittees := make([]*ethpbv2.SyncSubcommitteeValidators, subcommitteeCount) for i := uint64(0); i < subcommitteeCount; i++ { diff --git a/beacon-chain/rpc/eth/debug/debug.go b/beacon-chain/rpc/eth/debug/debug.go index de51c106498..bf2d31a62d3 100644 --- a/beacon-chain/rpc/eth/debug/debug.go +++ b/beacon-chain/rpc/eth/debug/debug.go @@ -123,7 +123,7 @@ func (ds *Server) GetBeaconStateSSZV2(ctx context.Context, req *ethpbv2.StateReq // ListForkChoiceHeads retrieves the fork choice leaves for the current head. func (ds *Server) ListForkChoiceHeads(ctx context.Context, _ *emptypb.Empty) (*ethpbv1.ForkChoiceHeadsResponse, error) { - ctx, span := trace.StartSpan(ctx, "debug.ListForkChoiceHeads") + _, span := trace.StartSpan(ctx, "debug.ListForkChoiceHeads") defer span.End() headRoots, headSlots := ds.HeadFetcher.ChainHeads() diff --git a/beacon-chain/rpc/eth/node/node.go b/beacon-chain/rpc/eth/node/node.go index a5a323de451..b11dfd70fc0 100644 --- a/beacon-chain/rpc/eth/node/node.go +++ b/beacon-chain/rpc/eth/node/node.go @@ -37,7 +37,7 @@ var ( // GetIdentity retrieves data about the node's network presence. func (ns *Server) GetIdentity(ctx context.Context, _ *emptypb.Empty) (*ethpb.IdentityResponse, error) { - ctx, span := trace.StartSpan(ctx, "node.GetIdentity") + _, span := trace.StartSpan(ctx, "node.GetIdentity") defer span.End() peerId := ns.PeerManager.PeerID().Pretty() @@ -81,7 +81,7 @@ func (ns *Server) GetIdentity(ctx context.Context, _ *emptypb.Empty) (*ethpb.Ide // GetPeer retrieves data about the given peer. func (ns *Server) GetPeer(ctx context.Context, req *ethpb.PeerRequest) (*ethpb.PeerResponse, error) { - ctx, span := trace.StartSpan(ctx, "node.GetPeer") + _, span := trace.StartSpan(ctx, "node.GetPeer") defer span.End() peerStatus := ns.PeersFetcher.Peers() @@ -134,11 +134,11 @@ func (ns *Server) GetPeer(ctx context.Context, req *ethpb.PeerRequest) (*ethpb.P // ListPeers retrieves data about the node's network peers. func (ns *Server) ListPeers(ctx context.Context, req *ethpb.PeersRequest) (*ethpb.PeersResponse, error) { - ctx, span := trace.StartSpan(ctx, "node.ListPeers") + _, span := trace.StartSpan(ctx, "node.ListPeers") defer span.End() peerStatus := ns.PeersFetcher.Peers() - emptyStateFilter, emptyDirectionFilter := ns.handleEmptyFilters(req) + emptyStateFilter, emptyDirectionFilter := handleEmptyFilters(req) if emptyStateFilter && emptyDirectionFilter { allIds := peerStatus.All() @@ -230,7 +230,7 @@ func (ns *Server) ListPeers(ctx context.Context, req *ethpb.PeersRequest) (*ethp // PeerCount retrieves retrieves number of known peers. func (ns *Server) PeerCount(ctx context.Context, _ *emptypb.Empty) (*ethpb.PeerCountResponse, error) { - ctx, span := trace.StartSpan(ctx, "node.PeerCount") + _, span := trace.StartSpan(ctx, "node.PeerCount") defer span.End() peerStatus := ns.PeersFetcher.Peers() @@ -247,8 +247,8 @@ func (ns *Server) PeerCount(ctx context.Context, _ *emptypb.Empty) (*ethpb.PeerC // GetVersion requests that the beacon node identify information about its implementation in a // format similar to a HTTP User-Agent field. -func (ns *Server) GetVersion(ctx context.Context, _ *emptypb.Empty) (*ethpb.VersionResponse, error) { - ctx, span := trace.StartSpan(ctx, "node.GetVersion") +func (_ *Server) GetVersion(ctx context.Context, _ *emptypb.Empty) (*ethpb.VersionResponse, error) { + _, span := trace.StartSpan(ctx, "node.GetVersion") defer span.End() v := fmt.Sprintf("Prysm/%s (%s %s)", version.SemanticVersion(), runtime.GOOS, runtime.GOARCH) @@ -262,7 +262,7 @@ func (ns *Server) GetVersion(ctx context.Context, _ *emptypb.Empty) (*ethpb.Vers // GetSyncStatus requests the beacon node to describe if it's currently syncing or not, and // if it is, what block it is up to. func (ns *Server) GetSyncStatus(ctx context.Context, _ *emptypb.Empty) (*ethpb.SyncingResponse, error) { - ctx, span := trace.StartSpan(ctx, "node.GetSyncStatus") + _, span := trace.StartSpan(ctx, "node.GetSyncStatus") defer span.End() headSlot := ns.HeadFetcher.HeadSlot() @@ -300,7 +300,7 @@ func (ns *Server) GetHealth(ctx context.Context, _ *emptypb.Empty) (*emptypb.Emp return &emptypb.Empty{}, status.Error(codes.Internal, "Node not initialized or having issues") } -func (ns *Server) handleEmptyFilters(req *ethpb.PeersRequest) (emptyState, emptyDirection bool) { +func handleEmptyFilters(req *ethpb.PeersRequest) (emptyState, emptyDirection bool) { emptyState = true for _, stateFilter := range req.State { normalized := strings.ToUpper(stateFilter.String()) diff --git a/beacon-chain/rpc/eth/node/node_test.go b/beacon-chain/rpc/eth/node/node_test.go index 968085dfbca..cdda9956a68 100644 --- a/beacon-chain/rpc/eth/node/node_test.go +++ b/beacon-chain/rpc/eth/node/node_test.go @@ -37,8 +37,8 @@ import ( type dummyIdentity enode.ID -func (id dummyIdentity) Verify(_ *enr.Record, _ []byte) error { return nil } -func (id dummyIdentity) NodeAddr(_ *enr.Record) []byte { return id[:] } +func (_ dummyIdentity) Verify(_ *enr.Record, _ []byte) error { return nil } +func (id dummyIdentity) NodeAddr(_ *enr.Record) []byte { return id[:] } func TestGetVersion(t *testing.T) { semVer := version.SemanticVersion() diff --git a/beacon-chain/rpc/eth/validator/validator.go b/beacon-chain/rpc/eth/validator/validator.go index 825c703ef2a..77401714f40 100644 --- a/beacon-chain/rpc/eth/validator/validator.go +++ b/beacon-chain/rpc/eth/validator/validator.go @@ -324,7 +324,7 @@ func (vs *Server) ProduceAttestationData(ctx context.Context, req *ethpbv1.Produ // GetAggregateAttestation aggregates all attestations matching the given attestation data root and slot, returning the aggregated result. func (vs *Server) GetAggregateAttestation(ctx context.Context, req *ethpbv1.AggregateAttestationRequest) (*ethpbv1.AggregateAttestationResponse, error) { - ctx, span := trace.StartSpan(ctx, "validator.GetAggregateAttestation") + _, span := trace.StartSpan(ctx, "validator.GetAggregateAttestation") defer span.End() allAtts := vs.AttestationsPool.AggregatedAttestations() diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/config.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/config.go index 48963204b02..703baaedb9b 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/config.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/config.go @@ -11,7 +11,7 @@ import ( ) // GetBeaconConfig retrieves the current configuration parameters of the beacon chain. -func (bs *Server) GetBeaconConfig(_ context.Context, _ *emptypb.Empty) (*ethpb.BeaconConfig, error) { +func (_ *Server) GetBeaconConfig(_ context.Context, _ *emptypb.Empty) (*ethpb.BeaconConfig, error) { conf := params.BeaconConfig() val := reflect.ValueOf(conf).Elem() numFields := val.Type().NumField() diff --git a/beacon-chain/rpc/prysm/v1alpha1/debug/block_test.go b/beacon-chain/rpc/prysm/v1alpha1/debug/block_test.go index 7b831830f37..1bafd6b30fc 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/debug/block_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/debug/block_test.go @@ -12,7 +12,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" "github.com/prysmaticlabs/prysm/config/params" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pbrpc "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -31,7 +30,7 @@ func TestServer_GetBlock(t *testing.T) { bs := &Server{ BeaconDB: db, } - res, err := bs.GetBlock(ctx, &pbrpc.BlockRequestByRoot{ + res, err := bs.GetBlock(ctx, ðpb.BlockRequestByRoot{ BlockRoot: blockRoot[:], }) require.NoError(t, err) @@ -41,7 +40,7 @@ func TestServer_GetBlock(t *testing.T) { // Checking for nil block. blockRoot = [32]byte{} - res, err = bs.GetBlock(ctx, &pbrpc.BlockRequestByRoot{ + res, err = bs.GetBlock(ctx, ðpb.BlockRequestByRoot{ BlockRoot: blockRoot[:], }) require.NoError(t, err) @@ -78,10 +77,10 @@ func TestServer_GetAttestationInclusionSlot(t *testing.T) { b.Block.Slot = 2 b.Block.Body.Attestations = []*ethpb.Attestation{a} require.NoError(t, bs.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) - res, err := bs.GetInclusionSlot(ctx, &pbrpc.InclusionSlotRequest{Slot: 1, Id: uint64(c[0])}) + res, err := bs.GetInclusionSlot(ctx, ðpb.InclusionSlotRequest{Slot: 1, Id: uint64(c[0])}) require.NoError(t, err) require.Equal(t, b.Block.Slot, res.Slot) - res, err = bs.GetInclusionSlot(ctx, &pbrpc.InclusionSlotRequest{Slot: 1, Id: 9999999}) + res, err = bs.GetInclusionSlot(ctx, ðpb.InclusionSlotRequest{Slot: 1, Id: 9999999}) require.NoError(t, err) require.Equal(t, params.BeaconConfig().FarFutureSlot, res.Slot) } diff --git a/beacon-chain/rpc/prysm/v1alpha1/debug/p2p.go b/beacon-chain/rpc/prysm/v1alpha1/debug/p2p.go index 3db9acad544..ed43922b18b 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/debug/p2p.go +++ b/beacon-chain/rpc/prysm/v1alpha1/debug/p2p.go @@ -8,13 +8,12 @@ import ( "github.com/libp2p/go-libp2p-core/peer" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pbrpc "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) // GetPeer returns the data known about the peer defined by the provided peer id. -func (ds *Server) GetPeer(_ context.Context, peerReq *ethpb.PeerRequest) (*pbrpc.DebugPeerResponse, error) { +func (ds *Server) GetPeer(_ context.Context, peerReq *ethpb.PeerRequest) (*ethpb.DebugPeerResponse, error) { pid, err := peer.Decode(peerReq.PeerId) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "Unable to parse provided peer id: %v", err) @@ -24,8 +23,8 @@ func (ds *Server) GetPeer(_ context.Context, peerReq *ethpb.PeerRequest) (*pbrpc // ListPeers returns all peers known to the host node, irregardless of if they are connected/ // disconnected. -func (ds *Server) ListPeers(_ context.Context, _ *empty.Empty) (*pbrpc.DebugPeerResponses, error) { - var responses []*pbrpc.DebugPeerResponse +func (ds *Server) ListPeers(_ context.Context, _ *empty.Empty) (*ethpb.DebugPeerResponses, error) { + var responses []*ethpb.DebugPeerResponse for _, pid := range ds.PeersFetcher.Peers().All() { resp, err := ds.getPeer(pid) if err != nil { @@ -33,10 +32,10 @@ func (ds *Server) ListPeers(_ context.Context, _ *empty.Empty) (*pbrpc.DebugPeer } responses = append(responses, resp) } - return &pbrpc.DebugPeerResponses{Responses: responses}, nil + return ðpb.DebugPeerResponses{Responses: responses}, nil } -func (ds *Server) getPeer(pid peer.ID) (*pbrpc.DebugPeerResponse, error) { +func (ds *Server) getPeer(pid peer.ID) (*ethpb.DebugPeerResponse, error) { peers := ds.PeersFetcher.Peers() peerStore := ds.PeerManager.Host().Peerstore() addr, err := peers.Address(pid) @@ -92,7 +91,7 @@ func (ds *Server) getPeer(pid peer.ID) (*pbrpc.DebugPeerResponse, error) { if err != nil || !ok { aVersion = "" } - peerInfo := &pbrpc.DebugPeerResponse_PeerInfo{ + peerInfo := ðpb.DebugPeerResponse_PeerInfo{ Protocols: protocols, FaultCount: uint64(resp), ProtocolVersion: pVersion, @@ -137,7 +136,7 @@ func (ds *Server) getPeer(pid peer.ID) (*pbrpc.DebugPeerResponse, error) { if err != nil { return nil, status.Errorf(codes.NotFound, "Requested peer does not exist: %v", err) } - scoreInfo := &pbrpc.ScoreInfo{ + scoreInfo := ðpb.ScoreInfo{ OverallScore: float32(peers.Scorers().Score(pid)), ProcessedBlocks: peers.Scorers().BlockProviderScorer().ProcessedBlocks(pid), BlockProviderScore: float32(peers.Scorers().BlockProviderScorer().Score(pid)), @@ -146,7 +145,7 @@ func (ds *Server) getPeer(pid peer.ID) (*pbrpc.DebugPeerResponse, error) { BehaviourPenalty: float32(bPenalty), ValidationError: errorToString(peers.Scorers().ValidationError(pid)), } - return &pbrpc.DebugPeerResponse{ + return ðpb.DebugPeerResponse{ ListeningAddresses: stringAddrs, Direction: pbDirection, ConnectionState: ethpb.ConnectionState(connState), diff --git a/beacon-chain/rpc/prysm/v1alpha1/debug/server.go b/beacon-chain/rpc/prysm/v1alpha1/debug/server.go index 7e8587ae17f..b1d06685f6c 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/debug/server.go +++ b/beacon-chain/rpc/prysm/v1alpha1/debug/server.go @@ -34,7 +34,7 @@ type Server struct { // SetLoggingLevel of a beacon node according to a request type, // either INFO, DEBUG, or TRACE. -func (ds *Server) SetLoggingLevel(_ context.Context, req *pbrpc.LoggingLevelRequest) (*empty.Empty, error) { +func (_ *Server) SetLoggingLevel(_ context.Context, req *pbrpc.LoggingLevelRequest) (*empty.Empty, error) { var verbosity string switch req.Level { case pbrpc.LoggingLevelRequest_INFO: diff --git a/beacon-chain/rpc/prysm/v1alpha1/node/server.go b/beacon-chain/rpc/prysm/v1alpha1/node/server.go index 854827e42af..52cfee278a1 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/node/server.go +++ b/beacon-chain/rpc/prysm/v1alpha1/node/server.go @@ -19,7 +19,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/sync" "github.com/prysmaticlabs/prysm/io/logs" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/runtime/version" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -76,7 +75,7 @@ func (ns *Server) GetGenesis(ctx context.Context, _ *empty.Empty) (*ethpb.Genesi } // GetVersion checks the version information of the beacon node. -func (ns *Server) GetVersion(_ context.Context, _ *empty.Empty) (*ethpb.Version, error) { +func (_ *Server) GetVersion(_ context.Context, _ *empty.Empty) (*ethpb.Version, error) { return ðpb.Version{ Version: version.Version(), }, nil @@ -221,7 +220,7 @@ func (ns *Server) ListPeers(ctx context.Context, _ *empty.Empty) (*ethpb.Peers, } // StreamBeaconLogs from the beacon node via a gRPC server-side stream. -func (ns *Server) StreamBeaconLogs(_ *empty.Empty, stream pb.Health_StreamBeaconLogsServer) error { +func (ns *Server) StreamBeaconLogs(_ *empty.Empty, stream ethpb.Health_StreamBeaconLogsServer) error { ch := make(chan []byte, ns.StreamLogsBufferSize) sub := ns.LogsStreamer.LogsFeed().Subscribe(ch) defer func() { @@ -234,7 +233,7 @@ func (ns *Server) StreamBeaconLogs(_ *empty.Empty, stream pb.Health_StreamBeacon for i, log := range recentLogs { logStrings[i] = string(log) } - if err := stream.Send(&pb.LogsResponse{ + if err := stream.Send(ðpb.LogsResponse{ Logs: logStrings, }); err != nil { return status.Errorf(codes.Unavailable, "Could not send over stream: %v", err) @@ -242,7 +241,7 @@ func (ns *Server) StreamBeaconLogs(_ *empty.Empty, stream pb.Health_StreamBeacon for { select { case log := <-ch: - resp := &pb.LogsResponse{ + resp := ðpb.LogsResponse{ Logs: []string{string(log)}, } if err := stream.Send(resp); err != nil { diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_deposits.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_deposits.go index e1012cbb074..34938ac6303 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_deposits.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_deposits.go @@ -174,7 +174,7 @@ func (vs *Server) depositTrie(ctx context.Context, canonicalEth1Data *ethpb.Eth1 } insertIndex++ } - valid, err := vs.validateDepositTrie(depositTrie, canonicalEth1Data) + valid, err := validateDepositTrie(depositTrie, canonicalEth1Data) // Log a warning here, as the cached trie is invalid. if !valid { log.Warnf("Cached deposit trie is invalid, rebuilding it now: %v", err) @@ -204,7 +204,7 @@ func (vs *Server) rebuildDepositTrie(ctx context.Context, canonicalEth1Data *eth return nil, err } - valid, err := vs.validateDepositTrie(depositTrie, canonicalEth1Data) + valid, err := validateDepositTrie(depositTrie, canonicalEth1Data) // Log an error here, as even with rebuilding the trie, it is still invalid. if !valid { log.Errorf("Rebuilt deposit trie is invalid: %v", err) @@ -213,7 +213,7 @@ func (vs *Server) rebuildDepositTrie(ctx context.Context, canonicalEth1Data *eth } // validate that the provided deposit trie matches up with the canonical eth1 data provided. -func (vs *Server) validateDepositTrie(trie *trie.SparseMerkleTrie, canonicalEth1Data *ethpb.Eth1Data) (bool, error) { +func validateDepositTrie(trie *trie.SparseMerkleTrie, canonicalEth1Data *ethpb.Eth1Data) (bool, error) { if trie.NumOfItems() != int(canonicalEth1Data.DepositCount) { return false, errors.Errorf("wanted the canonical count of %d but received %d", canonicalEth1Data.DepositCount, trie.NumOfItems()) } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go index c6a1c92cfb0..93371caab96 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go @@ -29,9 +29,7 @@ import ( "github.com/prysmaticlabs/prysm/container/trie" "github.com/prysmaticlabs/prysm/crypto/bls" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - 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" @@ -418,7 +416,7 @@ func TestProposer_PendingDeposits_OutsideEth1FollowWindow(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), @@ -431,7 +429,7 @@ func TestProposer_PendingDeposits_OutsideEth1FollowWindow(t *testing.T) { var mockCreds [32]byte // Using the merkleTreeIndex as the block number for this test... - readyDeposits := []*dbpb.DepositContainer{ + readyDeposits := []*ethpb.DepositContainer{ { Index: 0, Eth1BlockHeight: 2, @@ -454,7 +452,7 @@ func TestProposer_PendingDeposits_OutsideEth1FollowWindow(t *testing.T) { }, } - recentDeposits := []*dbpb.DepositContainer{ + recentDeposits := []*ethpb.DepositContainer{ { Index: 2, Eth1BlockHeight: 400, @@ -546,7 +544,7 @@ func TestProposer_PendingDeposits_FollowsCorrectEth1Block(t *testing.T) { votes = append(votes, vote) } - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: []byte("0x0"), DepositRoot: make([]byte, 32), @@ -566,7 +564,7 @@ func TestProposer_PendingDeposits_FollowsCorrectEth1Block(t *testing.T) { var mockCreds [32]byte // Using the merkleTreeIndex as the block number for this test... - readyDeposits := []*dbpb.DepositContainer{ + readyDeposits := []*ethpb.DepositContainer{ { Index: 0, Eth1BlockHeight: 8, @@ -589,7 +587,7 @@ func TestProposer_PendingDeposits_FollowsCorrectEth1Block(t *testing.T) { }, } - recentDeposits := []*dbpb.DepositContainer{ + recentDeposits := []*ethpb.DepositContainer{ { Index: 2, Eth1BlockHeight: 5000, @@ -677,7 +675,7 @@ func TestProposer_PendingDeposits_CantReturnBelowStateEth1DepositIndex(t *testin var mockSig [96]byte var mockCreds [32]byte - readyDeposits := []*dbpb.DepositContainer{ + readyDeposits := []*ethpb.DepositContainer{ { Index: 0, Deposit: ðpb.Deposit{ @@ -698,9 +696,9 @@ func TestProposer_PendingDeposits_CantReturnBelowStateEth1DepositIndex(t *testin }, } - var recentDeposits []*dbpb.DepositContainer + var recentDeposits []*ethpb.DepositContainer for i := int64(2); i < 16; i++ { - recentDeposits = append(recentDeposits, &dbpb.DepositContainer{ + recentDeposits = append(recentDeposits, ðpb.DepositContainer{ Index: i, Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ @@ -757,7 +755,7 @@ func TestProposer_PendingDeposits_CantReturnMoreThanMax(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), @@ -773,7 +771,7 @@ func TestProposer_PendingDeposits_CantReturnMoreThanMax(t *testing.T) { var mockSig [96]byte var mockCreds [32]byte - readyDeposits := []*dbpb.DepositContainer{ + readyDeposits := []*ethpb.DepositContainer{ { Index: 0, Deposit: ðpb.Deposit{ @@ -794,9 +792,9 @@ func TestProposer_PendingDeposits_CantReturnMoreThanMax(t *testing.T) { }, } - var recentDeposits []*dbpb.DepositContainer + var recentDeposits []*ethpb.DepositContainer for i := int64(2); i < 22; i++ { - recentDeposits = append(recentDeposits, &dbpb.DepositContainer{ + recentDeposits = append(recentDeposits, ðpb.DepositContainer{ Index: i, Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ @@ -851,7 +849,7 @@ func TestProposer_PendingDeposits_CantReturnMoreThanDepositCount(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), @@ -867,7 +865,7 @@ func TestProposer_PendingDeposits_CantReturnMoreThanDepositCount(t *testing.T) { var mockSig [96]byte var mockCreds [32]byte - readyDeposits := []*dbpb.DepositContainer{ + readyDeposits := []*ethpb.DepositContainer{ { Index: 0, Deposit: ðpb.Deposit{ @@ -888,9 +886,9 @@ func TestProposer_PendingDeposits_CantReturnMoreThanDepositCount(t *testing.T) { }, } - var recentDeposits []*dbpb.DepositContainer + var recentDeposits []*ethpb.DepositContainer for i := int64(2); i < 22; i++ { - recentDeposits = append(recentDeposits, &dbpb.DepositContainer{ + recentDeposits = append(recentDeposits, ðpb.DepositContainer{ Index: i, Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ @@ -945,7 +943,7 @@ func TestProposer_DepositTrie_UtilizesCachedFinalizedDeposits(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), @@ -964,7 +962,7 @@ func TestProposer_DepositTrie_UtilizesCachedFinalizedDeposits(t *testing.T) { var mockCreds [32]byte // Using the merkleTreeIndex as the block number for this test... - finalizedDeposits := []*dbpb.DepositContainer{ + finalizedDeposits := []*ethpb.DepositContainer{ { Index: 0, Eth1BlockHeight: 10, @@ -987,7 +985,7 @@ func TestProposer_DepositTrie_UtilizesCachedFinalizedDeposits(t *testing.T) { }, } - recentDeposits := []*dbpb.DepositContainer{ + recentDeposits := []*ethpb.DepositContainer{ { Index: 2, Eth1BlockHeight: 11, @@ -1055,7 +1053,7 @@ func TestProposer_DepositTrie_RebuildTrie(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), @@ -1074,7 +1072,7 @@ func TestProposer_DepositTrie_RebuildTrie(t *testing.T) { var mockCreds [32]byte // Using the merkleTreeIndex as the block number for this test... - finalizedDeposits := []*dbpb.DepositContainer{ + finalizedDeposits := []*ethpb.DepositContainer{ { Index: 0, Eth1BlockHeight: 10, @@ -1097,7 +1095,7 @@ func TestProposer_DepositTrie_RebuildTrie(t *testing.T) { }, } - recentDeposits := []*dbpb.DepositContainer{ + recentDeposits := []*ethpb.DepositContainer{ { Index: 2, Eth1BlockHeight: 11, @@ -1231,8 +1229,7 @@ func TestProposer_ValidateDepositTrie(t *testing.T) { for _, test := range tt { t.Run(test.name, func(t *testing.T) { - server := &Server{} - valid, err := server.validateDepositTrie(test.trieCreator(), test.eth1dataCreator()) + valid, err := validateDepositTrie(test.trieCreator(), test.eth1dataCreator()) assert.Equal(t, test.success, valid) if valid { assert.NoError(t, err) @@ -1245,7 +1242,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { slot := types.Slot(64) earliestValidTime, latestValidTime := majorityVoteBoundaryTime(slot) - dc := dbpb.DepositContainer{ + dc := ethpb.DepositContainer{ Index: 0, Eth1BlockHeight: 0, Deposit: ðpb.Deposit{ @@ -1269,7 +1266,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("first"), DepositCount: 1}, @@ -1305,7 +1302,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("earliest"), DepositCount: 1}, @@ -1341,7 +1338,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(51, earliestValidTime+1, []byte("first")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("first"), DepositCount: 1}, @@ -1378,7 +1375,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(51, earliestValidTime+1, []byte("first")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("before_range"), DepositCount: 1}, @@ -1415,7 +1412,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(100, latestValidTime, []byte("latest")). InsertBlock(101, latestValidTime+1, []byte("after_range")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("first"), DepositCount: 1}, @@ -1452,7 +1449,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("unknown"), DepositCount: 1}, @@ -1486,7 +1483,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(49, earliestValidTime-1, []byte("before_range")). InsertBlock(101, latestValidTime+1, []byte("after_range")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, }) require.NoError(t, err) @@ -1518,7 +1515,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(101, latestValidTime+1, []byte("after_range")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("before_range"), DepositCount: 1}, @@ -1552,7 +1549,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(50, earliestValidTime, []byte("earliest")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{}}) require.NoError(t, err) @@ -1582,7 +1579,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(50, earliestValidTime, []byte("earliest")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, }) require.NoError(t, err) @@ -1616,7 +1613,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("first"), DepositCount: 1}, @@ -1652,7 +1649,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("no_new_deposits"), DepositCount: 0}, @@ -1685,7 +1682,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { t.Skip() p := mockPOW.NewPOWChain().InsertBlock(50, earliestValidTime, []byte("earliest")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("earliest"), DepositCount: 1}, @@ -1719,7 +1716,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { // because of earliest block increment in the algorithm. InsertBlock(50, earliestValidTime+1, []byte("first")) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("before_range"), DepositCount: 1}, @@ -1758,7 +1755,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { depositCache, err := depositcache.New() require.NoError(t, err) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("earliest"), DepositCount: 1}, @@ -1901,7 +1898,7 @@ func TestProposer_Deposits_ReturnsEmptyList_IfLatestEth1DataEqGenesisEth1Block(t GenesisEth1Block: height, } - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), @@ -1917,7 +1914,7 @@ func TestProposer_Deposits_ReturnsEmptyList_IfLatestEth1DataEqGenesisEth1Block(t var mockSig [96]byte var mockCreds [32]byte - readyDeposits := []*dbpb.DepositContainer{ + readyDeposits := []*ethpb.DepositContainer{ { Index: 0, Deposit: ðpb.Deposit{ @@ -1938,9 +1935,9 @@ func TestProposer_Deposits_ReturnsEmptyList_IfLatestEth1DataEqGenesisEth1Block(t }, } - var recentDeposits []*dbpb.DepositContainer + var recentDeposits []*ethpb.DepositContainer for i := int64(2); i < 22; i++ { - recentDeposits = append(recentDeposits, &dbpb.DepositContainer{ + recentDeposits = append(recentDeposits, ðpb.DepositContainer{ Index: i, Deposit: ðpb.Deposit{ Data: ðpb.Deposit_Data{ diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go index c942ff1331c..bc13a1930e8 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go @@ -49,8 +49,6 @@ func TestValidatorIndex_OK(t *testing.T) { } func TestWaitForActivation_ContextClosed(t *testing.T) { - ctx := context.Background() - beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: 0, Validators: []*ethpb.Validator{}, diff --git a/beacon-chain/slasher/chunks.go b/beacon-chain/slasher/chunks.go index 6c6851e2d8c..f2eb972f4e5 100644 --- a/beacon-chain/slasher/chunks.go +++ b/beacon-chain/slasher/chunks.go @@ -151,12 +151,12 @@ func MaxChunkSpansSliceFrom(params *Parameters, chunk []uint16) (*MaxSpanChunksS // NeutralElement for a min span chunks slice is undefined, in this case // using MaxUint16 as a sane value given it is impossible we reach it. -func (m *MinSpanChunksSlice) NeutralElement() uint16 { +func (_ *MinSpanChunksSlice) NeutralElement() uint16 { return math.MaxUint16 } // NeutralElement for a max span chunks slice is 0. -func (m *MaxSpanChunksSlice) NeutralElement() uint16 { +func (_ *MaxSpanChunksSlice) NeutralElement() uint16 { return 0 } @@ -435,7 +435,7 @@ func (m *MinSpanChunksSlice) StartEpoch( // StartEpoch given a source epoch and current epoch, determines the start epoch of // a max span chunk for use in chunk updates. The source epoch cannot be >= the current epoch. -func (m *MaxSpanChunksSlice) StartEpoch( +func (_ *MaxSpanChunksSlice) StartEpoch( sourceEpoch, currentEpoch types.Epoch, ) (epoch types.Epoch, exists bool) { if sourceEpoch >= currentEpoch { diff --git a/beacon-chain/slasher/service.go b/beacon-chain/slasher/service.go index baa8ea35617..4c01ea5c187 100644 --- a/beacon-chain/slasher/service.go +++ b/beacon-chain/slasher/service.go @@ -167,7 +167,7 @@ func (s *Service) Stop() error { } // Status of the slasher service. -func (s *Service) Status() error { +func (_ *Service) Status() error { return nil } diff --git a/beacon-chain/state/fieldtrie/field_trie_helpers.go b/beacon-chain/state/fieldtrie/field_trie_helpers.go index 5a7c6b687e4..9a37f661ae0 100644 --- a/beacon-chain/state/fieldtrie/field_trie_helpers.go +++ b/beacon-chain/state/fieldtrie/field_trie_helpers.go @@ -234,7 +234,7 @@ func handlePendingAttestation(val []*ethpb.PendingAttestation, indices []uint64, return roots, nil } -func handleBalanceSlice(val []uint64, indices []uint64, convertAll bool) ([][32]byte, error) { +func handleBalanceSlice(val, indices []uint64, convertAll bool) ([][32]byte, error) { if convertAll { balancesMarshaling := make([][]byte, 0) for _, b := range val { diff --git a/beacon-chain/state/stategen/mock.go b/beacon-chain/state/stategen/mock.go index 22d6e843b50..4bef97f00b6 100644 --- a/beacon-chain/state/stategen/mock.go +++ b/beacon-chain/state/stategen/mock.go @@ -24,27 +24,27 @@ func NewMockService() *MockStateManager { } // StateByRootIfCached -func (m *MockStateManager) StateByRootIfCachedNoCopy(_ [32]byte) state.BeaconState { // skipcq: RVV-B0013 +func (_ *MockStateManager) StateByRootIfCachedNoCopy(_ [32]byte) state.BeaconState { panic("implement me") } // Resume -- -func (m *MockStateManager) Resume(_ context.Context, _ state.BeaconState) (state.BeaconState, error) { +func (_ *MockStateManager) Resume(_ context.Context, _ state.BeaconState) (state.BeaconState, error) { panic("implement me") } // SaveFinalizedState -- -func (m *MockStateManager) SaveFinalizedState(_ types.Slot, _ [32]byte, _ state.BeaconState) { +func (_ *MockStateManager) SaveFinalizedState(_ types.Slot, _ [32]byte, _ state.BeaconState) { panic("implement me") } // MigrateToCold -- -func (m *MockStateManager) MigrateToCold(_ context.Context, _ [32]byte) error { +func (_ *MockStateManager) MigrateToCold(_ context.Context, _ [32]byte) error { panic("implement me") } // ReplayBlocks -- -func (m *MockStateManager) ReplayBlocks( +func (_ *MockStateManager) ReplayBlocks( _ context.Context, _ state.BeaconState, _ []block.SignedBeaconBlock, @@ -54,7 +54,7 @@ func (m *MockStateManager) ReplayBlocks( } // LoadBlocks -- -func (m *MockStateManager) LoadBlocks( +func (_ *MockStateManager) LoadBlocks( _ context.Context, _, _ types.Slot, _ [32]byte, @@ -63,12 +63,12 @@ func (m *MockStateManager) LoadBlocks( } // HasState -- -func (m *MockStateManager) HasState(_ context.Context, _ [32]byte) (bool, error) { +func (_ *MockStateManager) HasState(_ context.Context, _ [32]byte) (bool, error) { panic("implement me") } // HasStateInCache -- -func (m *MockStateManager) HasStateInCache(_ context.Context, _ [32]byte) (bool, error) { +func (_ *MockStateManager) HasStateInCache(_ context.Context, _ [32]byte) (bool, error) { panic("implement me") } @@ -78,7 +78,7 @@ func (m *MockStateManager) StateByRoot(_ context.Context, blockRoot [32]byte) (s } // StateByRootInitialSync -- -func (m *MockStateManager) StateByRootInitialSync(_ context.Context, _ [32]byte) (state.BeaconState, error) { +func (_ *MockStateManager) StateByRootInitialSync(_ context.Context, _ [32]byte) (state.BeaconState, error) { panic("implement me") } @@ -88,7 +88,7 @@ func (m *MockStateManager) StateBySlot(_ context.Context, slot types.Slot) (stat } // RecoverStateSummary -- -func (m *MockStateManager) RecoverStateSummary( +func (_ *MockStateManager) RecoverStateSummary( _ context.Context, _ [32]byte, ) (*ethpb.StateSummary, error) { @@ -96,22 +96,22 @@ func (m *MockStateManager) RecoverStateSummary( } // SaveState -- -func (m *MockStateManager) SaveState(_ context.Context, _ [32]byte, _ state.BeaconState) error { +func (_ *MockStateManager) SaveState(_ context.Context, _ [32]byte, _ state.BeaconState) error { panic("implement me") } // ForceCheckpoint -- -func (m *MockStateManager) ForceCheckpoint(_ context.Context, _ []byte) error { +func (_ *MockStateManager) ForceCheckpoint(_ context.Context, _ []byte) error { panic("implement me") } // EnableSaveHotStateToDB -- -func (m *MockStateManager) EnableSaveHotStateToDB(_ context.Context) { +func (_ *MockStateManager) EnableSaveHotStateToDB(_ context.Context) { panic("implement me") } // DisableSaveHotStateToDB -- -func (m *MockStateManager) DisableSaveHotStateToDB(_ context.Context) error { +func (_ *MockStateManager) DisableSaveHotStateToDB(_ context.Context) error { panic("implement me") } diff --git a/beacon-chain/state/stategen/replay.go b/beacon-chain/state/stategen/replay.go index e470fbf6186..7b3f08c8262 100644 --- a/beacon-chain/state/stategen/replay.go +++ b/beacon-chain/state/stategen/replay.go @@ -21,7 +21,7 @@ import ( ) // ReplayBlocks replays the input blocks on the input state until the target slot is reached. -func (s *State) ReplayBlocks( +func (_ *State) ReplayBlocks( ctx context.Context, state state.BeaconState, signed []block.SignedBeaconBlock, diff --git a/beacon-chain/state/v1/getters_block_test.go b/beacon-chain/state/v1/getters_block_test.go index 651106dc638..aee36ec9b0d 100644 --- a/beacon-chain/state/v1/getters_block_test.go +++ b/beacon-chain/state/v1/getters_block_test.go @@ -5,7 +5,6 @@ import ( "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/require" ) @@ -13,9 +12,9 @@ func TestBeaconState_LatestBlockHeader(t *testing.T) { s, err := InitializeFromProto(ðpb.BeaconState{}) require.NoError(t, err) got := s.LatestBlockHeader() - require.DeepEqual(t, (*v1alpha1.BeaconBlockHeader)(nil), got) + require.DeepEqual(t, (*ethpb.BeaconBlockHeader)(nil), got) - want := &v1alpha1.BeaconBlockHeader{Slot: 100} + want := ðpb.BeaconBlockHeader{Slot: 100} s, err = InitializeFromProto(ðpb.BeaconState{LatestBlockHeader: want}) require.NoError(t, err) got = s.LatestBlockHeader() diff --git a/beacon-chain/state/v1/getters_misc.go b/beacon-chain/state/v1/getters_misc.go index 8cb95cd649f..b7c9cec3353 100644 --- a/beacon-chain/state/v1/getters_misc.go +++ b/beacon-chain/state/v1/getters_misc.go @@ -63,7 +63,7 @@ func (b *BeaconState) genesisValidatorRoot() []byte { // Version of the beacon state. This method // is strictly meant to be used without a lock // internally. -func (b *BeaconState) Version() int { +func (_ *BeaconState) Version() int { return version.Phase0 } diff --git a/beacon-chain/state/v1/getters_test.go b/beacon-chain/state/v1/getters_test.go index a985a3f2a2c..976bed6a77d 100644 --- a/beacon-chain/state/v1/getters_test.go +++ b/beacon-chain/state/v1/getters_test.go @@ -6,7 +6,6 @@ import ( "testing" types "github.com/prysmaticlabs/eth2-types" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -79,8 +78,8 @@ func TestNilState_NoPanic(t *testing.T) { } func TestBeaconState_MatchCurrentJustifiedCheckpt(t *testing.T) { - c1 := ð.Checkpoint{Epoch: 1} - c2 := ð.Checkpoint{Epoch: 2} + c1 := ðpb.Checkpoint{Epoch: 1} + c2 := ðpb.Checkpoint{Epoch: 2} beaconState, err := InitializeFromProto(ðpb.BeaconState{CurrentJustifiedCheckpoint: c1}) require.NoError(t, err) require.Equal(t, true, beaconState.MatchCurrentJustifiedCheckpoint(c1)) @@ -92,8 +91,8 @@ func TestBeaconState_MatchCurrentJustifiedCheckpt(t *testing.T) { } func TestBeaconState_MatchPreviousJustifiedCheckpt(t *testing.T) { - c1 := ð.Checkpoint{Epoch: 1} - c2 := ð.Checkpoint{Epoch: 2} + c1 := ðpb.Checkpoint{Epoch: 1} + c2 := ðpb.Checkpoint{Epoch: 2} beaconState, err := InitializeFromProto(ðpb.BeaconState{PreviousJustifiedCheckpoint: c1}) require.NoError(t, err) require.NoError(t, err) @@ -130,7 +129,7 @@ func TestBeaconState_ValidatorByPubkey(t *testing.T) { { name: "retrieve validator", modifyFunc: func(b *BeaconState, key [48]byte) { - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key[:]})) }, exists: true, expectedIdx: 0, @@ -140,9 +139,9 @@ func TestBeaconState_ValidatorByPubkey(t *testing.T) { modifyFunc: func(b *BeaconState, key [48]byte) { key1 := keyCreator([]byte{'C'}) key2 := keyCreator([]byte{'D'}) - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key[:]})) - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key1[:]})) - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key2[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key1[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key2[:]})) }, exists: true, expectedIdx: 0, @@ -152,9 +151,9 @@ func TestBeaconState_ValidatorByPubkey(t *testing.T) { modifyFunc: func(b *BeaconState, key [48]byte) { key1 := keyCreator([]byte{'C'}) key2 := keyCreator([]byte{'D'}) - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key1[:]})) - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key2[:]})) - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key1[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key2[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key[:]})) }, exists: true, expectedIdx: 2, @@ -164,10 +163,10 @@ func TestBeaconState_ValidatorByPubkey(t *testing.T) { modifyFunc: func(b *BeaconState, key [48]byte) { key1 := keyCreator([]byte{'C'}) key2 := keyCreator([]byte{'D'}) - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key[:]})) _ = b.Copy() - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key1[:]})) - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key2[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key1[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key2[:]})) }, exists: true, expectedIdx: 0, @@ -177,11 +176,11 @@ func TestBeaconState_ValidatorByPubkey(t *testing.T) { modifyFunc: func(b *BeaconState, key [48]byte) { key1 := keyCreator([]byte{'C'}) key2 := keyCreator([]byte{'D'}) - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key1[:]})) - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key2[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key1[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key2[:]})) n := b.Copy() // Append to another state - assert.NoError(t, n.AppendValidator(ð.Validator{PublicKey: key[:]})) + assert.NoError(t, n.AppendValidator(ðpb.Validator{PublicKey: key[:]})) }, exists: false, @@ -191,10 +190,10 @@ func TestBeaconState_ValidatorByPubkey(t *testing.T) { name: "retrieve validator with multiple validators with shared state at boundary", modifyFunc: func(b *BeaconState, key [48]byte) { key1 := keyCreator([]byte{'C'}) - assert.NoError(t, b.AppendValidator(ð.Validator{PublicKey: key1[:]})) + assert.NoError(t, b.AppendValidator(ðpb.Validator{PublicKey: key1[:]})) n := b.Copy() // Append to another state - assert.NoError(t, n.AppendValidator(ð.Validator{PublicKey: key[:]})) + assert.NoError(t, n.AppendValidator(ðpb.Validator{PublicKey: key[:]})) }, exists: false, diff --git a/beacon-chain/state/v1/setters_attestation_test.go b/beacon-chain/state/v1/setters_attestation_test.go index 61668250262..46fcd3d3e69 100644 --- a/beacon-chain/state/v1/setters_attestation_test.go +++ b/beacon-chain/state/v1/setters_attestation_test.go @@ -7,7 +7,6 @@ import ( types "github.com/prysmaticlabs/eth2-types" stateTypes "github.com/prysmaticlabs/prysm/beacon-chain/state/types" "github.com/prysmaticlabs/prysm/config/params" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -16,8 +15,8 @@ import ( func TestBeaconState_RotateAttestations(t *testing.T) { st, err := InitializeFromProto(ðpb.BeaconState{ Slot: 1, - CurrentEpochAttestations: []*ethpb.PendingAttestation{{Data: ð.AttestationData{Slot: 456}}}, - PreviousEpochAttestations: []*ethpb.PendingAttestation{{Data: ð.AttestationData{Slot: 123}}}, + CurrentEpochAttestations: []*ethpb.PendingAttestation{{Data: ðpb.AttestationData{Slot: 456}}}, + PreviousEpochAttestations: []*ethpb.PendingAttestation{{Data: ðpb.AttestationData{Slot: 123}}}, }) require.NoError(t, err) @@ -43,10 +42,10 @@ func TestAppendBeyondIndicesLimit(t *testing.T) { } st, err := InitializeFromProto(ðpb.BeaconState{ Slot: 1, - CurrentEpochAttestations: []*ethpb.PendingAttestation{{Data: ð.AttestationData{Slot: 456}}}, - PreviousEpochAttestations: []*ethpb.PendingAttestation{{Data: ð.AttestationData{Slot: 123}}}, - Validators: []*eth.Validator{}, - Eth1Data: ð.Eth1Data{}, + CurrentEpochAttestations: []*ethpb.PendingAttestation{{Data: ðpb.AttestationData{Slot: 456}}}, + PreviousEpochAttestations: []*ethpb.PendingAttestation{{Data: ðpb.AttestationData{Slot: 123}}}, + Validators: []*ethpb.Validator{}, + Eth1Data: ðpb.Eth1Data{}, BlockRoots: mockblockRoots, StateRoots: mockstateRoots, RandaoMixes: mockrandaoMixes, @@ -60,13 +59,13 @@ func TestAppendBeyondIndicesLimit(t *testing.T) { _, err = st.HashTreeRoot(context.Background()) require.NoError(t, err) for i := 0; i < 10; i++ { - assert.NoError(t, st.AppendValidator(ð.Validator{})) + assert.NoError(t, st.AppendValidator(ðpb.Validator{})) } assert.Equal(t, false, st.rebuildTrie[validators]) assert.NotEqual(t, len(st.dirtyIndices[validators]), 0) for i := 0; i < indicesLimit; i++ { - assert.NoError(t, st.AppendValidator(ð.Validator{})) + assert.NoError(t, st.AppendValidator(ðpb.Validator{})) } assert.Equal(t, true, st.rebuildTrie[validators]) assert.Equal(t, len(st.dirtyIndices[validators]), 0) diff --git a/beacon-chain/state/v1/state_test.go b/beacon-chain/state/v1/state_test.go index 20379ca0db6..4056aecf41e 100644 --- a/beacon-chain/state/v1/state_test.go +++ b/beacon-chain/state/v1/state_test.go @@ -143,10 +143,6 @@ func TestBeaconState_AppendBalanceWithTrie(t *testing.T) { for i := 0; i < len(mockrandaoMixes); i++ { mockrandaoMixes[i] = zeroHash[:] } - var pubKeys [][]byte - for i := uint64(0); i < params.BeaconConfig().SyncCommitteeSize; i++ { - pubKeys = append(pubKeys, bytesutil.PadTo([]byte{}, params.BeaconConfig().BLSPubkeyLength)) - } st, err := InitializeFromProto(ðpb.BeaconState{ Slot: 1, GenesisValidatorsRoot: make([]byte, 32), diff --git a/beacon-chain/state/v1/state_trie.go b/beacon-chain/state/v1/state_trie.go index a69ce221819..79b960295c9 100644 --- a/beacon-chain/state/v1/state_trie.go +++ b/beacon-chain/state/v1/state_trie.go @@ -253,7 +253,7 @@ func (b *BeaconState) IsNil() bool { } func (b *BeaconState) rootSelector(ctx context.Context, field types.FieldIndex) ([32]byte, error) { - ctx, span := trace.StartSpan(ctx, "beaconState.rootSelector") + _, span := trace.StartSpan(ctx, "beaconState.rootSelector") defer span.End() span.AddAttributes(trace.StringAttribute("field", field.String(b.Version()))) diff --git a/beacon-chain/state/v1/state_trie_test.go b/beacon-chain/state/v1/state_trie_test.go index d3a155c4f4d..73c1beecf70 100644 --- a/beacon-chain/state/v1/state_trie_test.go +++ b/beacon-chain/state/v1/state_trie_test.go @@ -10,7 +10,6 @@ import ( "github.com/prysmaticlabs/prysm/config/features" "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -253,7 +252,7 @@ func TestBeaconState_AppendValidator_DoesntMutateCopy(t *testing.T) { st1 := st0.Copy() originalCount := st1.NumValidators() - val := ð.Validator{Slashed: true} + val := ðpb.Validator{Slashed: true} assert.NoError(t, st0.AppendValidator(val)) assert.Equal(t, originalCount, st1.NumValidators(), "st1 NumValidators mutated") _, ok := st1.ValidatorIndexByPubkey(bytesutil.ToBytes48(val.PublicKey)) diff --git a/beacon-chain/state/v1/unsupported_getters.go b/beacon-chain/state/v1/unsupported_getters.go index 07ad3bd2b1d..3717aab456f 100644 --- a/beacon-chain/state/v1/unsupported_getters.go +++ b/beacon-chain/state/v1/unsupported_getters.go @@ -6,31 +6,31 @@ import ( ) // CurrentEpochParticipation is not supported for phase 0 beacon state. -func (b *BeaconState) CurrentEpochParticipation() ([]byte, error) { +func (*BeaconState) CurrentEpochParticipation() ([]byte, error) { return nil, errors.New("CurrentEpochParticipation is not supported for phase 0 beacon state") } // PreviousEpochParticipation is not supported for phase 0 beacon state. -func (b *BeaconState) PreviousEpochParticipation() ([]byte, error) { +func (*BeaconState) PreviousEpochParticipation() ([]byte, error) { return nil, errors.New("PreviousEpochParticipation is not supported for phase 0 beacon state") } // InactivityScores is not supported for phase 0 beacon state. -func (b *BeaconState) InactivityScores() ([]uint64, error) { +func (*BeaconState) InactivityScores() ([]uint64, error) { return nil, errors.New("InactivityScores is not supported for phase 0 beacon state") } // CurrentSyncCommittee is not supported for phase 0 beacon state. -func (b *BeaconState) CurrentSyncCommittee() (*ethpb.SyncCommittee, error) { +func (*BeaconState) CurrentSyncCommittee() (*ethpb.SyncCommittee, error) { return nil, errors.New("CurrentSyncCommittee is not supported for phase 0 beacon state") } // NextSyncCommittee is not supported for phase 0 beacon state. -func (b *BeaconState) NextSyncCommittee() (*ethpb.SyncCommittee, error) { +func (*BeaconState) NextSyncCommittee() (*ethpb.SyncCommittee, error) { return nil, errors.New("NextSyncCommittee is not supported for phase 0 beacon state") } // LatestExecutionPayloadHeader is not supported for phase 0 beacon state. -func (b *BeaconState) LatestExecutionPayloadHeader() (*ethpb.ExecutionPayloadHeader, error) { +func (*BeaconState) LatestExecutionPayloadHeader() (*ethpb.ExecutionPayloadHeader, error) { return nil, errors.New("LatestExecutionPayloadHeader is not supported for phase 0 beacon state") } diff --git a/beacon-chain/state/v1/unsupported_setters.go b/beacon-chain/state/v1/unsupported_setters.go index 40cfeeab6a9..251253519ab 100644 --- a/beacon-chain/state/v1/unsupported_setters.go +++ b/beacon-chain/state/v1/unsupported_setters.go @@ -21,31 +21,31 @@ func (*BeaconState) AppendInactivityScore(_ uint64) error { } // SetCurrentSyncCommittee is not supported for phase 0 beacon state. -func (b *BeaconState) SetCurrentSyncCommittee(val *ethpb.SyncCommittee) error { +func (*BeaconState) SetCurrentSyncCommittee(_ *ethpb.SyncCommittee) error { return errors.New("SetCurrentSyncCommittee is not supported for phase 0 beacon state") } // SetNextSyncCommittee is not supported for phase 0 beacon state. -func (b *BeaconState) SetNextSyncCommittee(val *ethpb.SyncCommittee) error { +func (*BeaconState) SetNextSyncCommittee(_ *ethpb.SyncCommittee) error { return errors.New("SetNextSyncCommittee is not supported for phase 0 beacon state") } // SetPreviousParticipationBits is not supported for phase 0 beacon state. -func (b *BeaconState) SetPreviousParticipationBits(val []byte) error { +func (*BeaconState) SetPreviousParticipationBits(_ []byte) error { return errors.New("SetPreviousParticipationBits is not supported for phase 0 beacon state") } // SetCurrentParticipationBits is not supported for phase 0 beacon state. -func (b *BeaconState) SetCurrentParticipationBits(val []byte) error { +func (*BeaconState) SetCurrentParticipationBits(_ []byte) error { return errors.New("SetCurrentParticipationBits is not supported for phase 0 beacon state") } // SetInactivityScores is not supported for phase 0 beacon state. -func (b *BeaconState) SetInactivityScores(val []uint64) error { +func (*BeaconState) SetInactivityScores(_ []uint64) error { return errors.New("SetInactivityScores is not supported for phase 0 beacon state") } // SetLatestExecutionPayloadHeader is not supported for phase 0 beacon state. -func (b *BeaconState) SetLatestExecutionPayloadHeader(val *ethpb.ExecutionPayloadHeader) error { +func (*BeaconState) SetLatestExecutionPayloadHeader(val *ethpb.ExecutionPayloadHeader) error { return errors.New("SetLatestExecutionPayloadHeader is not supported for phase 0 beacon state") } diff --git a/beacon-chain/state/v2/deprecated_getters.go b/beacon-chain/state/v2/deprecated_getters.go index 46caf83d0d4..2257b577e8f 100644 --- a/beacon-chain/state/v2/deprecated_getters.go +++ b/beacon-chain/state/v2/deprecated_getters.go @@ -6,16 +6,16 @@ import ( ) // PreviousEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error) { +func (*BeaconState) PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error) { return nil, errors.New("PreviousEpochAttestations is not supported for hard fork 1 beacon state") } // CurrentEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error) { +func (*BeaconState) CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error) { return nil, errors.New("CurrentEpochAttestations is not supported for hard fork 1 beacon state") } // LatestExecutionPayloadHeader is not supported for hard fork 1 beacon state. -func (b *BeaconState) LatestExecutionPayloadHeader() (*ethpb.ExecutionPayloadHeader, error) { +func (*BeaconState) LatestExecutionPayloadHeader() (*ethpb.ExecutionPayloadHeader, error) { return nil, errors.New("LatestExecutionPayloadHeader is not supported for hard fork 1 beacon state") } diff --git a/beacon-chain/state/v2/deprecated_setters.go b/beacon-chain/state/v2/deprecated_setters.go index 69dfce48d00..449bb82098a 100644 --- a/beacon-chain/state/v2/deprecated_setters.go +++ b/beacon-chain/state/v2/deprecated_setters.go @@ -6,31 +6,31 @@ import ( ) // SetPreviousEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) SetPreviousEpochAttestations(_ []*ethpb.PendingAttestation) error { +func (*BeaconState) SetPreviousEpochAttestations(_ []*ethpb.PendingAttestation) error { return errors.New("SetPreviousEpochAttestations is not supported for hard fork 1 beacon state") } // SetCurrentEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) SetCurrentEpochAttestations(_ []*ethpb.PendingAttestation) error { +func (*BeaconState) SetCurrentEpochAttestations(_ []*ethpb.PendingAttestation) error { return errors.New("SetCurrentEpochAttestations is not supported for hard fork 1 beacon state") } // AppendCurrentEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) AppendCurrentEpochAttestations(_ *ethpb.PendingAttestation) error { +func (*BeaconState) AppendCurrentEpochAttestations(_ *ethpb.PendingAttestation) error { return errors.New("AppendCurrentEpochAttestations is not supported for hard fork 1 beacon state") } // AppendPreviousEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) AppendPreviousEpochAttestations(val *ethpb.PendingAttestation) error { +func (*BeaconState) AppendPreviousEpochAttestations(_ *ethpb.PendingAttestation) error { return errors.New("AppendPreviousEpochAttestations is not supported for hard fork 1 beacon state") } // RotateAttestations is not supported for HF1 beacon state. -func (b *BeaconState) RotateAttestations() error { +func (*BeaconState) RotateAttestations() error { return errors.New("RotateAttestations is not supported for hard fork 1 beacon state") } // SetLatestExecutionPayloadHeader is not supported for hard fork 1 beacon state. -func (b *BeaconState) SetLatestExecutionPayloadHeader(val *ethpb.ExecutionPayloadHeader) error { +func (*BeaconState) SetLatestExecutionPayloadHeader(_ *ethpb.ExecutionPayloadHeader) error { return errors.New("SetLatestExecutionPayloadHeader is not supported for hard fork 1 beacon state") } diff --git a/beacon-chain/state/v2/getters_block_test.go b/beacon-chain/state/v2/getters_block_test.go index d7ae85d0672..c8912cd9491 100644 --- a/beacon-chain/state/v2/getters_block_test.go +++ b/beacon-chain/state/v2/getters_block_test.go @@ -5,7 +5,6 @@ import ( "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/require" ) @@ -13,9 +12,9 @@ func TestBeaconState_LatestBlockHeader(t *testing.T) { s, err := InitializeFromProto(ðpb.BeaconStateAltair{}) require.NoError(t, err) got := s.LatestBlockHeader() - require.DeepEqual(t, (*v1alpha1.BeaconBlockHeader)(nil), got) + require.DeepEqual(t, (*ethpb.BeaconBlockHeader)(nil), got) - want := &v1alpha1.BeaconBlockHeader{Slot: 100} + want := ðpb.BeaconBlockHeader{Slot: 100} s, err = InitializeFromProto(ðpb.BeaconStateAltair{LatestBlockHeader: want}) require.NoError(t, err) got = s.LatestBlockHeader() diff --git a/beacon-chain/state/v2/getters_misc.go b/beacon-chain/state/v2/getters_misc.go index 5a325d2d967..a8fa1d516da 100644 --- a/beacon-chain/state/v2/getters_misc.go +++ b/beacon-chain/state/v2/getters_misc.go @@ -111,7 +111,7 @@ func (b *BeaconState) parentRoot() [32]byte { // Version of the beacon state. This method // is strictly meant to be used without a lock // internally. -func (b *BeaconState) Version() int { +func (_ *BeaconState) Version() int { return version.Altair } diff --git a/beacon-chain/state/v2/setters_test.go b/beacon-chain/state/v2/setters_test.go index 82e692000ba..2935cdc01e5 100644 --- a/beacon-chain/state/v2/setters_test.go +++ b/beacon-chain/state/v2/setters_test.go @@ -11,7 +11,6 @@ import ( stateTypes "github.com/prysmaticlabs/prysm/beacon-chain/state/types" "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -36,8 +35,8 @@ func TestAppendBeyondIndicesLimit(t *testing.T) { Slot: 1, CurrentEpochParticipation: []byte{}, PreviousEpochParticipation: []byte{}, - Validators: []*eth.Validator{}, - Eth1Data: ð.Eth1Data{}, + Validators: []*ethpb.Validator{}, + Eth1Data: ðpb.Eth1Data{}, BlockRoots: mockblockRoots, StateRoots: mockstateRoots, RandaoMixes: mockrandaoMixes, @@ -51,13 +50,13 @@ func TestAppendBeyondIndicesLimit(t *testing.T) { _, err = st.HashTreeRoot(context.Background()) require.NoError(t, err) for i := 0; i < 10; i++ { - assert.NoError(t, st.AppendValidator(ð.Validator{})) + assert.NoError(t, st.AppendValidator(ðpb.Validator{})) } assert.Equal(t, false, st.rebuildTrie[validators]) assert.NotEqual(t, len(st.dirtyIndices[validators]), 0) for i := 0; i < indicesLimit; i++ { - assert.NoError(t, st.AppendValidator(ð.Validator{})) + assert.NoError(t, st.AppendValidator(ðpb.Validator{})) } assert.Equal(t, true, st.rebuildTrie[validators]) assert.Equal(t, len(st.dirtyIndices[validators]), 0) @@ -119,7 +118,7 @@ func TestBeaconState_AppendBalanceWithTrie(t *testing.T) { PreviousEpochParticipation: []byte{}, Validators: vals, Balances: bals, - Eth1Data: ð.Eth1Data{ + Eth1Data: ðpb.Eth1Data{ DepositRoot: make([]byte, 32), BlockHash: make([]byte, 32), }, diff --git a/beacon-chain/state/v2/state_trie.go b/beacon-chain/state/v2/state_trie.go index 6bd873259d8..fc00961abdd 100644 --- a/beacon-chain/state/v2/state_trie.go +++ b/beacon-chain/state/v2/state_trie.go @@ -258,7 +258,7 @@ func (b *BeaconState) IsNil() bool { } func (b *BeaconState) rootSelector(ctx context.Context, field types.FieldIndex) ([32]byte, error) { - ctx, span := trace.StartSpan(ctx, "beaconState.rootSelector") + _, span := trace.StartSpan(ctx, "beaconState.rootSelector") defer span.End() span.AddAttributes(trace.StringAttribute("field", field.String(b.Version()))) diff --git a/beacon-chain/state/v3/deprecated_getters.go b/beacon-chain/state/v3/deprecated_getters.go index a6b7cea7b61..846ace35e29 100644 --- a/beacon-chain/state/v3/deprecated_getters.go +++ b/beacon-chain/state/v3/deprecated_getters.go @@ -6,11 +6,11 @@ import ( ) // PreviousEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error) { +func (*BeaconState) PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error) { return nil, errors.New("PreviousEpochAttestations is not supported for version Merge beacon state") } // CurrentEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error) { +func (*BeaconState) CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error) { return nil, errors.New("CurrentEpochAttestations is not supported for version Merge beacon state") } diff --git a/beacon-chain/state/v3/deprecated_setters.go b/beacon-chain/state/v3/deprecated_setters.go index e4d9a24b1cc..53c61280fd3 100644 --- a/beacon-chain/state/v3/deprecated_setters.go +++ b/beacon-chain/state/v3/deprecated_setters.go @@ -21,11 +21,11 @@ func (*BeaconState) AppendCurrentEpochAttestations(_ *ethpb.PendingAttestation) } // AppendPreviousEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) AppendPreviousEpochAttestations(val *ethpb.PendingAttestation) error { +func (*BeaconState) AppendPreviousEpochAttestations(_ *ethpb.PendingAttestation) error { return errors.New("AppendPreviousEpochAttestations is not supported for version Merge beacon state") } // RotateAttestations is not supported for HF1 beacon state. -func (b *BeaconState) RotateAttestations() error { +func (*BeaconState) RotateAttestations() error { return errors.New("RotateAttestations is not supported for version Merge beacon state") } diff --git a/beacon-chain/state/v3/getters_block_test.go b/beacon-chain/state/v3/getters_block_test.go index 3bdccc52b8f..bb0f88f7ada 100644 --- a/beacon-chain/state/v3/getters_block_test.go +++ b/beacon-chain/state/v3/getters_block_test.go @@ -5,7 +5,6 @@ import ( "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/require" ) @@ -13,9 +12,9 @@ func TestBeaconState_LatestBlockHeader(t *testing.T) { s, err := InitializeFromProto(ðpb.BeaconStateMerge{}) require.NoError(t, err) got := s.LatestBlockHeader() - require.DeepEqual(t, (*v1alpha1.BeaconBlockHeader)(nil), got) + require.DeepEqual(t, (*ethpb.BeaconBlockHeader)(nil), got) - want := &v1alpha1.BeaconBlockHeader{Slot: 100} + want := ðpb.BeaconBlockHeader{Slot: 100} s, err = InitializeFromProto(ðpb.BeaconStateMerge{LatestBlockHeader: want}) require.NoError(t, err) got = s.LatestBlockHeader() diff --git a/beacon-chain/state/v3/getters_misc.go b/beacon-chain/state/v3/getters_misc.go index 211b01ee9eb..99f82adb3b7 100644 --- a/beacon-chain/state/v3/getters_misc.go +++ b/beacon-chain/state/v3/getters_misc.go @@ -111,7 +111,7 @@ func (b *BeaconState) parentRoot() [32]byte { // Version of the beacon state. This method // is strictly meant to be used without a lock // internally. -func (b *BeaconState) Version() int { +func (_ *BeaconState) Version() int { return version.Merge } diff --git a/beacon-chain/state/v3/setters_test.go b/beacon-chain/state/v3/setters_test.go index c5d9f6d40f5..5184ca5918d 100644 --- a/beacon-chain/state/v3/setters_test.go +++ b/beacon-chain/state/v3/setters_test.go @@ -11,7 +11,6 @@ import ( stateTypes "github.com/prysmaticlabs/prysm/beacon-chain/state/types" "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -47,8 +46,8 @@ func TestAppendBeyondIndicesLimit(t *testing.T) { Slot: 1, CurrentEpochParticipation: []byte{}, PreviousEpochParticipation: []byte{}, - Validators: []*eth.Validator{}, - Eth1Data: ð.Eth1Data{}, + Validators: []*ethpb.Validator{}, + Eth1Data: ðpb.Eth1Data{}, BlockRoots: mockblockRoots, StateRoots: mockstateRoots, RandaoMixes: mockrandaoMixes, @@ -63,13 +62,13 @@ func TestAppendBeyondIndicesLimit(t *testing.T) { _, err = st.HashTreeRoot(context.Background()) require.NoError(t, err) for i := 0; i < 10; i++ { - assert.NoError(t, st.AppendValidator(ð.Validator{})) + assert.NoError(t, st.AppendValidator(ðpb.Validator{})) } assert.Equal(t, false, st.rebuildTrie[validators]) assert.NotEqual(t, len(st.dirtyIndices[validators]), 0) for i := 0; i < indicesLimit; i++ { - assert.NoError(t, st.AppendValidator(ð.Validator{})) + assert.NoError(t, st.AppendValidator(ðpb.Validator{})) } assert.Equal(t, true, st.rebuildTrie[validators]) assert.Equal(t, len(st.dirtyIndices[validators]), 0) @@ -142,7 +141,7 @@ func TestBeaconState_AppendBalanceWithTrie(t *testing.T) { PreviousEpochParticipation: []byte{}, Validators: vals, Balances: bals, - Eth1Data: ð.Eth1Data{ + Eth1Data: ðpb.Eth1Data{ DepositRoot: make([]byte, 32), BlockHash: make([]byte, 32), }, diff --git a/beacon-chain/sync/batch_verifier.go b/beacon-chain/sync/batch_verifier.go index 21adebd550a..e4f09823458 100644 --- a/beacon-chain/sync/batch_verifier.go +++ b/beacon-chain/sync/batch_verifier.go @@ -50,7 +50,7 @@ func (s *Service) verifierRoutine() { } func (s *Service) validateWithBatchVerifier(ctx context.Context, message string, set *bls.SignatureBatch) (pubsub.ValidationResult, error) { - ctx, span := trace.StartSpan(ctx, "sync.validateWithBatchVerifier") + _, span := trace.StartSpan(ctx, "sync.validateWithBatchVerifier") defer span.End() resChan := make(chan error) diff --git a/beacon-chain/sync/decode_pubsub.go b/beacon-chain/sync/decode_pubsub.go index d08aa60af7a..53929e78eaf 100644 --- a/beacon-chain/sync/decode_pubsub.go +++ b/beacon-chain/sync/decode_pubsub.go @@ -61,7 +61,7 @@ func (s *Service) decodePubsubMessage(msg *pubsub.Message) (ssz.Unmarshaler, err } // Replaces our fork digest with the formatter. -func (s *Service) replaceForkDigest(topic string) (string, error) { +func (_ *Service) replaceForkDigest(topic string) (string, error) { subStrings := strings.Split(topic, "/") if len(subStrings) != 4 { return "", errInvalidTopic diff --git a/beacon-chain/sync/decode_pubsub_test.go b/beacon-chain/sync/decode_pubsub_test.go index 447a2665d9c..83146f6a718 100644 --- a/beacon-chain/sync/decode_pubsub_test.go +++ b/beacon-chain/sync/decode_pubsub_test.go @@ -85,10 +85,12 @@ func TestService_decodePubsubMessage(t *testing.T) { } else if tt.input.Message == nil { tt.input.Message = &pb.Message{} } - tt.input.Message.Topic = &tt.topic + // reassign because tt is a loop variable + topic := tt.topic + tt.input.Message.Topic = &topic } got, err := s.decodePubsubMessage(tt.input) - if err != tt.wantErr && !strings.Contains(err.Error(), tt.wantErr.Error()) { + if err != nil && err != tt.wantErr && !strings.Contains(err.Error(), tt.wantErr.Error()) { t.Errorf("decodePubsubMessage() error = %v, wantErr %v", err, tt.wantErr) return } diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_peers.go b/beacon-chain/sync/initial-sync/blocks_fetcher_peers.go index 7fdd66be754..09393c94392 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_peers.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_peers.go @@ -92,7 +92,7 @@ func (f *blocksFetcher) waitForMinimumPeers(ctx context.Context) ([]peer.ID, err // filterPeers returns transformed list of peers, weight sorted by scores and capacity remaining. // List can be further constrained using peersPercentage, where only percentage of peers are returned. func (f *blocksFetcher) filterPeers(ctx context.Context, peers []peer.ID, peersPercentage float64) []peer.ID { - ctx, span := trace.StartSpan(ctx, "initialsync.filterPeers") + _, span := trace.StartSpan(ctx, "initialsync.filterPeers") defer span.End() if len(peers) == 0 { diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_test.go b/beacon-chain/sync/initial-sync/blocks_fetcher_test.go index e2aa548187b..786bc61fc9d 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_test.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_test.go @@ -20,8 +20,7 @@ import ( "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/container/slice" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "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/testing/assert" @@ -278,7 +277,7 @@ func TestBlocksFetcher_RoundRobin(t *testing.T) { State: st, Root: genesisRoot[:], DB: beaconDB, - FinalizedCheckPoint: ð.Checkpoint{ + FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: 0, }, Genesis: time.Now(), @@ -507,7 +506,7 @@ func TestBlocksFetcher_requestBeaconBlocksByRange(t *testing.T) { }) _, peerIDs := p2p.Peers().BestFinalized(params.BeaconConfig().MaxPeersToSync, slots.ToEpoch(mc.HeadSlot())) - req := &p2ppb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 1, Step: 1, Count: blockBatchLimit, @@ -530,7 +529,7 @@ func TestBlocksFetcher_RequestBlocksRateLimitingLocks(t *testing.T) { p1.Connect(p2) p1.Connect(p3) require.Equal(t, 2, len(p1.BHost.Network().Peers()), "Expected peers to be connected") - req := &p2ppb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 1, Count: 64, @@ -596,19 +595,19 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) p1 := p2pt.NewTestP2P(t) tests := []struct { name string - req *p2ppb.BeaconBlocksByRangeRequest - handlerGenFn func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) + req *ethpb.BeaconBlocksByRangeRequest + handlerGenFn func(req *ethpb.BeaconBlocksByRangeRequest) func(stream network.Stream) wantedErr string - validate func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) + validate func(req *ethpb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) }{ { name: "no error", - req: &p2ppb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 4, Count: 64, }, - handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) { + handlerGenFn: func(req *ethpb.BeaconBlocksByRangeRequest) func(stream network.Stream) { return func(stream network.Stream) { for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) { blk := util.NewBeaconBlock() @@ -619,18 +618,18 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { + validate: func(req *ethpb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, req.Count, uint64(len(blocks))) }, }, { name: "too many blocks", - req: &p2ppb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 1, Count: 64, }, - handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) { + handlerGenFn: func(req *ethpb.BeaconBlocksByRangeRequest) func(stream network.Stream) { return func(stream network.Stream) { for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step+1); i += types.Slot(req.Step) { blk := util.NewBeaconBlock() @@ -641,19 +640,19 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { + validate: func(req *ethpb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), }, { name: "not in a consecutive order", - req: &p2ppb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 1, Count: 64, }, - handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) { + handlerGenFn: func(req *ethpb.BeaconBlocksByRangeRequest) func(stream network.Stream) { return func(stream network.Stream) { blk := util.NewBeaconBlock() blk.Block.Slot = 163 @@ -666,19 +665,19 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { + validate: func(req *ethpb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), }, { name: "same slot number", - req: &p2ppb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 1, Count: 64, }, - handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) { + handlerGenFn: func(req *ethpb.BeaconBlocksByRangeRequest) func(stream network.Stream) { return func(stream network.Stream) { blk := util.NewBeaconBlock() blk.Block.Slot = 160 @@ -692,19 +691,19 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { + validate: func(req *ethpb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), }, { name: "slot is too low", - req: &p2ppb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 1, Count: 64, }, - handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) { + handlerGenFn: func(req *ethpb.BeaconBlocksByRangeRequest) func(stream network.Stream) { return func(stream network.Stream) { defer func() { assert.NoError(t, stream.Close()) @@ -724,18 +723,18 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) } }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { + validate: func(req *ethpb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, }, { name: "slot is too high", - req: &p2ppb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 1, Count: 64, }, - handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) { + handlerGenFn: func(req *ethpb.BeaconBlocksByRangeRequest) func(stream network.Stream) { return func(stream network.Stream) { defer func() { assert.NoError(t, stream.Close()) @@ -755,18 +754,18 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) } }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { + validate: func(req *ethpb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, }, { name: "valid step increment", - req: &p2ppb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 5, Count: 64, }, - handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) { + handlerGenFn: func(req *ethpb.BeaconBlocksByRangeRequest) func(stream network.Stream) { return func(stream network.Stream) { blk := util.NewBeaconBlock() blk.Block.Slot = 100 @@ -779,18 +778,18 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { + validate: func(req *ethpb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 2, len(blocks)) }, }, { name: "invalid step increment", - req: &p2ppb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 5, Count: 64, }, - handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) { + handlerGenFn: func(req *ethpb.BeaconBlocksByRangeRequest) func(stream network.Stream) { return func(stream network.Stream) { blk := util.NewBeaconBlock() blk.Block.Slot = 100 @@ -803,7 +802,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { + validate: func(req *ethpb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_utils_test.go b/beacon-chain/sync/initial-sync/blocks_fetcher_utils_test.go index f5f8829e4d2..280727597cc 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_utils_test.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_utils_test.go @@ -18,8 +18,7 @@ import ( "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -130,7 +129,7 @@ func TestBlocksFetcher_nonSkippedSlotAfter(t *testing.T) { p2p: p2p, }, ) - mc.FinalizedCheckPoint = ð.Checkpoint{ + mc.FinalizedCheckPoint = ðpb.Checkpoint{ Epoch: 10, } require.NoError(t, mc.State.SetSlot(12*params.BeaconConfig().SlotsPerEpoch)) @@ -159,7 +158,7 @@ func TestBlocksFetcher_findFork(t *testing.T) { p2p := p2pt.NewTestP2P(t) // Chain contains blocks from 8 epochs (from 0 to 7, 256 is the start slot of epoch8). - chain1 := extendBlockSequence(t, []*eth.SignedBeaconBlock{}, 250) + chain1 := extendBlockSequence(t, []*ethpb.SignedBeaconBlock{}, 250) finalizedSlot := types.Slot(63) finalizedEpoch := slots.ToEpoch(finalizedSlot) @@ -174,7 +173,7 @@ func TestBlocksFetcher_findFork(t *testing.T) { State: st, Root: genesisRoot[:], DB: beaconDB, - FinalizedCheckPoint: ð.Checkpoint{ + FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: finalizedEpoch, Root: []byte(fmt.Sprintf("finalized_root %d", finalizedEpoch)), }, @@ -204,7 +203,7 @@ func TestBlocksFetcher_findFork(t *testing.T) { blockBatchLimit := flags.Get().BlockBatchLimit * 2 pidInd := 0 for i := uint64(1); i < uint64(len(chain1)); i += blockBatchLimit { - req := &p2ppb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: types.Slot(i), Step: 1, Count: blockBatchLimit, @@ -227,7 +226,7 @@ func TestBlocksFetcher_findFork(t *testing.T) { assert.Equal(t, types.Slot(250), mc.HeadSlot()) // Assert no blocks on further requests, disallowing to progress. - req := &p2ppb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 251, Step: 1, Count: blockBatchLimit, @@ -243,7 +242,7 @@ func TestBlocksFetcher_findFork(t *testing.T) { // Add peer that has blocks after 250, but those blocks are orphaned i.e. they do not have common // ancestor with what we already have. So, error is expected. - chain1a := extendBlockSequence(t, []*eth.SignedBeaconBlock{}, 265) + chain1a := extendBlockSequence(t, []*ethpb.SignedBeaconBlock{}, 265) connectPeerHavingBlocks(t, p2p, chain1a, finalizedSlot, p2p.Peers()) fork, err = fetcher.findFork(ctx, 251) require.ErrorContains(t, errNoPeersWithAltBlocks.Error(), err) @@ -314,7 +313,7 @@ func TestBlocksFetcher_findForkWithPeer(t *testing.T) { beaconDB := dbtest.SetupDB(t) p1 := p2pt.NewTestP2P(t) - knownBlocks := extendBlockSequence(t, []*eth.SignedBeaconBlock{}, 128) + knownBlocks := extendBlockSequence(t, []*ethpb.SignedBeaconBlock{}, 128) genesisBlock := knownBlocks[0] require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genesisBlock))) genesisRoot, err := genesisBlock.Block.HashTreeRoot() @@ -365,7 +364,7 @@ func TestBlocksFetcher_findForkWithPeer(t *testing.T) { defer func() { assert.NoError(t, p1.Disconnect(p2.PeerID())) }() - p1.Peers().SetChainState(p2.PeerID(), &p2ppb.Status{ + p1.Peers().SetChainState(p2.PeerID(), ðpb.Status{ HeadRoot: nil, HeadSlot: 0, }) @@ -396,7 +395,7 @@ func TestBlocksFetcher_findForkWithPeer(t *testing.T) { }) t.Run("first block is diverging - no common ancestor", func(t *testing.T) { - altBlocks := extendBlockSequence(t, []*eth.SignedBeaconBlock{}, 128) + altBlocks := extendBlockSequence(t, []*ethpb.SignedBeaconBlock{}, 128) p2 := connectPeerHavingBlocks(t, p1, altBlocks, 128, p1.Peers()) defer func() { assert.NoError(t, p1.Disconnect(p2)) @@ -423,7 +422,7 @@ func TestBlocksFetcher_findAncestor(t *testing.T) { beaconDB := dbtest.SetupDB(t) p2p := p2pt.NewTestP2P(t) - knownBlocks := extendBlockSequence(t, []*eth.SignedBeaconBlock{}, 128) + knownBlocks := extendBlockSequence(t, []*ethpb.SignedBeaconBlock{}, 128) finalizedSlot := types.Slot(63) finalizedEpoch := slots.ToEpoch(finalizedSlot) @@ -438,7 +437,7 @@ func TestBlocksFetcher_findAncestor(t *testing.T) { State: st, Root: genesisRoot[:], DB: beaconDB, - FinalizedCheckPoint: ð.Checkpoint{ + FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: finalizedEpoch, Root: []byte(fmt.Sprintf("finalized_root %d", finalizedEpoch)), }, @@ -571,7 +570,7 @@ func TestBlocksFetcher_currentHeadAndTargetEpochs(t *testing.T) { p2p: p2p, }, ) - mc.FinalizedCheckPoint = ð.Checkpoint{ + mc.FinalizedCheckPoint = ðpb.Checkpoint{ Epoch: tt.ourFinalizedEpoch, } require.NoError(t, mc.State.SetSlot(tt.ourHeadSlot)) diff --git a/beacon-chain/sync/initial-sync/blocks_queue.go b/beacon-chain/sync/initial-sync/blocks_queue.go index f9f39e6a7ee..80376c4417d 100644 --- a/beacon-chain/sync/initial-sync/blocks_queue.go +++ b/beacon-chain/sync/initial-sync/blocks_queue.go @@ -439,7 +439,7 @@ func (q *blocksQueue) onProcessSkippedEvent(ctx context.Context) eventHandlerFn // onCheckStaleEvent is an event that allows to mark stale epochs, // so that they can be re-processed. -func (q *blocksQueue) onCheckStaleEvent(ctx context.Context) eventHandlerFn { +func (_ *blocksQueue) onCheckStaleEvent(ctx context.Context) eventHandlerFn { return func(m *stateMachine, in interface{}) (stateID, error) { if ctx.Err() != nil { return m.state, ctx.Err() diff --git a/beacon-chain/sync/initial-sync/initial_sync_test.go b/beacon-chain/sync/initial-sync/initial_sync_test.go index 2094e0afc5d..0bc9fbfb468 100644 --- a/beacon-chain/sync/initial-sync/initial_sync_test.go +++ b/beacon-chain/sync/initial-sync/initial_sync_test.go @@ -25,8 +25,7 @@ import ( "github.com/prysmaticlabs/prysm/container/slice" "github.com/prysmaticlabs/prysm/crypto/hash" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -93,7 +92,7 @@ func initializeTestServices(t *testing.T, slots []types.Slot, peers []*peerData) State: st, Root: genesisRoot[:], DB: beaconDB, - FinalizedCheckPoint: ð.Checkpoint{ + FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: 0, }, Genesis: time.Now(), @@ -174,7 +173,7 @@ func connectPeer(t *testing.T, host *p2pt.TestP2P, datum *peerData, peerStatus * assert.NoError(t, stream.Close()) }() - req := &p2ppb.BeaconBlocksByRangeRequest{} + req := ðpb.BeaconBlocksByRangeRequest{} assert.NoError(t, p.Encoding().DecodeWithMaxLength(stream, req)) requestedBlocks := makeSequence(req.StartSlot, req.StartSlot.Add((req.Count-1)*req.Step)) @@ -192,7 +191,7 @@ func connectPeer(t *testing.T, host *p2pt.TestP2P, datum *peerData, peerStatus * // Determine the correct subset of blocks to return as dictated by the test scenario. slots := slice.IntersectionSlot(datum.blocks, requestedBlocks) - ret := make([]*eth.SignedBeaconBlock, 0) + ret := make([]*ethpb.SignedBeaconBlock, 0) for _, slot := range slots { if (slot - req.StartSlot).Mod(req.Step) != 0 { continue @@ -228,7 +227,7 @@ func connectPeer(t *testing.T, host *p2pt.TestP2P, datum *peerData, peerStatus * peerStatus.Add(new(enr.Record), p.PeerID(), nil, network.DirOutbound) peerStatus.SetConnectionState(p.PeerID(), peers.PeerConnected) - peerStatus.SetChainState(p.PeerID(), &p2ppb.Status{ + peerStatus.SetChainState(p.PeerID(), ðpb.Status{ ForkDigest: params.BeaconConfig().GenesisForkVersion, FinalizedRoot: []byte(fmt.Sprintf("finalized_root %d", datum.finalizedEpoch)), FinalizedEpoch: datum.finalizedEpoch, @@ -240,9 +239,9 @@ func connectPeer(t *testing.T, host *p2pt.TestP2P, datum *peerData, peerStatus * } // extendBlockSequence extends block chain sequentially (creating genesis block, if necessary). -func extendBlockSequence(t *testing.T, inSeq []*eth.SignedBeaconBlock, size int) []*eth.SignedBeaconBlock { +func extendBlockSequence(t *testing.T, inSeq []*ethpb.SignedBeaconBlock, size int) []*ethpb.SignedBeaconBlock { // Start from the original sequence. - outSeq := make([]*eth.SignedBeaconBlock, len(inSeq)+size) + outSeq := make([]*ethpb.SignedBeaconBlock, len(inSeq)+size) copy(outSeq, inSeq) // See if genesis block needs to be created. @@ -271,7 +270,7 @@ func extendBlockSequence(t *testing.T, inSeq []*eth.SignedBeaconBlock, size int) // connectPeerHavingBlocks connect host with a peer having provided blocks. func connectPeerHavingBlocks( - t *testing.T, host *p2pt.TestP2P, blocks []*eth.SignedBeaconBlock, finalizedSlot types.Slot, + t *testing.T, host *p2pt.TestP2P, blocks []*ethpb.SignedBeaconBlock, finalizedSlot types.Slot, peerStatus *peers.Status, ) peer.ID { p := p2pt.NewTestP2P(t) @@ -282,7 +281,7 @@ func connectPeerHavingBlocks( _ = _err }() - req := &p2ppb.BeaconBlocksByRangeRequest{} + req := ðpb.BeaconBlocksByRangeRequest{} assert.NoError(t, p.Encoding().DecodeWithMaxLength(stream, req)) for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) { @@ -326,7 +325,7 @@ func connectPeerHavingBlocks( peerStatus.Add(new(enr.Record), p.PeerID(), nil, network.DirOutbound) peerStatus.SetConnectionState(p.PeerID(), peers.PeerConnected) - peerStatus.SetChainState(p.PeerID(), &p2ppb.Status{ + peerStatus.SetChainState(p.PeerID(), ðpb.Status{ ForkDigest: params.BeaconConfig().GenesisForkVersion, FinalizedRoot: []byte(fmt.Sprintf("finalized_root %d", finalizedEpoch)), FinalizedEpoch: finalizedEpoch, diff --git a/beacon-chain/sync/initial-sync/testing/mock.go b/beacon-chain/sync/initial-sync/testing/mock.go index 8d824599167..dd3835ea5de 100644 --- a/beacon-chain/sync/initial-sync/testing/mock.go +++ b/beacon-chain/sync/initial-sync/testing/mock.go @@ -20,12 +20,12 @@ func (s *Sync) Initialized() bool { } // Status -- -func (s *Sync) Status() error { +func (_ *Sync) Status() error { return nil } // Resync -- -func (s *Sync) Resync() error { +func (_ *Sync) Resync() error { return nil } diff --git a/beacon-chain/sync/pending_attestations_queue.go b/beacon-chain/sync/pending_attestations_queue.go index 427a1d370d3..e9071f2bd31 100644 --- a/beacon-chain/sync/pending_attestations_queue.go +++ b/beacon-chain/sync/pending_attestations_queue.go @@ -180,7 +180,7 @@ func (s *Service) savePendingAtt(att *ethpb.SignedAggregateAttestationAndProof) // check specifies the pending attestation could not fall one epoch behind // of the current slot. func (s *Service) validatePendingAtts(ctx context.Context, slot types.Slot) { - ctx, span := trace.StartSpan(ctx, "validatePendingAtts") + _, span := trace.StartSpan(ctx, "validatePendingAtts") defer span.End() s.pendingAttsLock.Lock() diff --git a/beacon-chain/sync/pending_attestations_queue_test.go b/beacon-chain/sync/pending_attestations_queue_test.go index 84f1701a35a..322d6033676 100644 --- a/beacon-chain/sync/pending_attestations_queue_test.go +++ b/beacon-chain/sync/pending_attestations_queue_test.go @@ -22,7 +22,6 @@ import ( "github.com/prysmaticlabs/prysm/crypto/bls" "github.com/prysmaticlabs/prysm/encoding/bytesutil" 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/testing/assert" @@ -41,7 +40,7 @@ func TestProcessPendingAtts_NoBlockRequestBlock(t *testing.T) { assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected") p1.Peers().Add(new(enr.Record), p2.PeerID(), nil, network.DirOutbound) p1.Peers().SetConnectionState(p2.PeerID(), peers.PeerConnected) - p1.Peers().SetChainState(p2.PeerID(), &pb.Status{}) + p1.Peers().SetChainState(p2.PeerID(), ðpb.Status{}) r := &Service{ cfg: &config{p2p: p1, beaconDB: db, chain: &mock.ChainService{Genesis: prysmTime.Now(), FinalizedCheckPoint: ðpb.Checkpoint{}}}, diff --git a/beacon-chain/sync/rate_limiter.go b/beacon-chain/sync/rate_limiter.go index 68774efceef..250f91efd61 100644 --- a/beacon-chain/sync/rate_limiter.go +++ b/beacon-chain/sync/rate_limiter.go @@ -191,6 +191,6 @@ func (l *limiter) retrieveCollector(topic string) (*leakybucket.Collector, error return collector, nil } -func (l *limiter) topicLogger(topic string) *logrus.Entry { +func (_ *limiter) topicLogger(topic string) *logrus.Entry { return log.WithField("rate limiter", topic) } diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go b/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go index 33a1b871085..e81a0f04186 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go @@ -22,7 +22,6 @@ import ( "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -38,7 +37,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerReturnsBlocks(t *testing.T) { assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected") d := db.SetupDB(t) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 64, Count: 16, @@ -93,7 +92,7 @@ func TestRPCBeaconBlocksByRange_ReturnCorrectNumberBack(t *testing.T) { assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected") d := db.SetupDB(t) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 0, Step: 1, Count: 200, @@ -122,7 +121,7 @@ func TestRPCBeaconBlocksByRange_ReturnCorrectNumberBack(t *testing.T) { wg.Add(1) // Use a new request to test this out - newReq := &pb.BeaconBlocksByRangeRequest{StartSlot: 0, Step: 1, Count: 1} + newReq := ðpb.BeaconBlocksByRangeRequest{StartSlot: 0, Step: 1, Count: 1} p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) { defer wg.Done() @@ -158,7 +157,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerReturnsSortedBlocks(t *testing.T) { assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected") d := db.SetupDB(t) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 200, Step: 21, Count: 33, @@ -220,7 +219,7 @@ func TestRPCBeaconBlocksByRange_ReturnsGenesisBlock(t *testing.T) { assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected") d := db.SetupDB(t) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 0, Step: 1, Count: 4, @@ -275,7 +274,7 @@ func TestRPCBeaconBlocksByRange_ReturnsGenesisBlock(t *testing.T) { func TestRPCBeaconBlocksByRange_RPCHandlerRateLimitOverflow(t *testing.T) { d := db.SetupDB(t) - saveBlocks := func(req *pb.BeaconBlocksByRangeRequest) { + saveBlocks := func(req *ethpb.BeaconBlocksByRangeRequest) { // Populate the database with blocks that would match the request. parentRoot := [32]byte{} for i := req.StartSlot; i < req.StartSlot.Add(req.Step*req.Count); i += types.Slot(req.Step) { @@ -291,7 +290,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerRateLimitOverflow(t *testing.T) { } } sendRequest := func(p1, p2 *p2ptest.TestP2P, r *Service, - req *pb.BeaconBlocksByRangeRequest, validateBlocks bool, success bool) error { + req *ethpb.BeaconBlocksByRangeRequest, validateBlocks bool, success bool) error { var wg sync.WaitGroup wg.Add(1) pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1) @@ -335,7 +334,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerRateLimitOverflow(t *testing.T) { pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1) topic := string(pcl) r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, capacity, false) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 5, Count: uint64(capacity), @@ -362,7 +361,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerRateLimitOverflow(t *testing.T) { topic := string(pcl) r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, capacity, false) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 5, Count: uint64(capacity + 1), @@ -391,7 +390,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerRateLimitOverflow(t *testing.T) { topic := string(pcl) r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, capacity, false) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, Step: 1, Count: flags.Get().BlockBatchLimit, @@ -427,13 +426,13 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { tests := []struct { name string - req *pb.BeaconBlocksByRangeRequest + req *ethpb.BeaconBlocksByRangeRequest expectedError error errorToLog string }{ { name: "Zero Count", - req: &pb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ Count: 0, Step: 1, }, @@ -442,7 +441,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { }, { name: "Over limit Count", - req: &pb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ Count: params.BeaconNetworkConfig().MaxRequestBlocks + 1, Step: 1, }, @@ -451,7 +450,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { }, { name: "Correct Count", - req: &pb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ Count: params.BeaconNetworkConfig().MaxRequestBlocks - 1, Step: 1, }, @@ -459,7 +458,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { }, { name: "Zero Step", - req: &pb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ Step: 0, Count: 1, }, @@ -468,7 +467,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { }, { name: "Over limit Step", - req: &pb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ Step: rangeLimit + 1, Count: 1, }, @@ -477,7 +476,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { }, { name: "Correct Step", - req: &pb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ Step: rangeLimit - 1, Count: 2, }, @@ -485,7 +484,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { }, { name: "Over Limit Start Slot", - req: &pb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ StartSlot: slotsSinceGenesis.Add((2 * rangeLimit) + 1), Step: 1, Count: 1, @@ -495,7 +494,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { }, { name: "Over Limit End Slot", - req: &pb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ Step: 1, Count: params.BeaconNetworkConfig().MaxRequestBlocks + 1, }, @@ -504,7 +503,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { }, { name: "Exceed Range Limit", - req: &pb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ Step: 3, Count: uint64(slotsSinceGenesis / 2), }, @@ -513,7 +512,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { }, { name: "Valid Request", - req: &pb.BeaconBlocksByRangeRequest{ + req: ðpb.BeaconBlocksByRangeRequest{ Step: 1, Count: params.BeaconNetworkConfig().MaxRequestBlocks - 1, StartSlot: 50, @@ -536,7 +535,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { func TestRPCBeaconBlocksByRange_EnforceResponseInvariants(t *testing.T) { d := db.SetupDB(t) hook := logTest.NewGlobal() - saveBlocks := func(req *pb.BeaconBlocksByRangeRequest) { + saveBlocks := func(req *ethpb.BeaconBlocksByRangeRequest) { // Populate the database with blocks that would match the request. parentRoot := [32]byte{} for i := req.StartSlot; i < req.StartSlot.Add(req.Step*req.Count); i += types.Slot(req.Step) { @@ -551,7 +550,7 @@ func TestRPCBeaconBlocksByRange_EnforceResponseInvariants(t *testing.T) { } pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1) sendRequest := func(p1, p2 *p2ptest.TestP2P, r *Service, - req *pb.BeaconBlocksByRangeRequest, processBlocks func([]*ethpb.SignedBeaconBlock)) error { + req *ethpb.BeaconBlocksByRangeRequest, processBlocks func([]*ethpb.SignedBeaconBlock)) error { var wg sync.WaitGroup wg.Add(1) p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) { @@ -587,7 +586,7 @@ func TestRPCBeaconBlocksByRange_EnforceResponseInvariants(t *testing.T) { r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)} r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 448, Step: 1, Count: 64, @@ -612,7 +611,7 @@ func TestRPCBeaconBlocksByRange_EnforceResponseInvariants(t *testing.T) { func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { hook := logTest.NewGlobal() - saveBlocks := func(d db2.Database, chain *chainMock.ChainService, req *pb.BeaconBlocksByRangeRequest, finalized bool) { + saveBlocks := func(d db2.Database, chain *chainMock.ChainService, req *ethpb.BeaconBlocksByRangeRequest, finalized bool) { blk := util.NewBeaconBlock() blk.Block.Slot = 0 previousRoot, err := blk.Block.HashTreeRoot() @@ -657,7 +656,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { } } saveBadBlocks := func(d db2.Database, chain *chainMock.ChainService, - req *pb.BeaconBlocksByRangeRequest, badBlockNum uint64, finalized bool) { + req *ethpb.BeaconBlocksByRangeRequest, badBlockNum uint64, finalized bool) { blk := util.NewBeaconBlock() blk.Block.Slot = 0 previousRoot, err := blk.Block.HashTreeRoot() @@ -707,7 +706,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { } pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1) sendRequest := func(p1, p2 *p2ptest.TestP2P, r *Service, - req *pb.BeaconBlocksByRangeRequest, processBlocks func([]*ethpb.SignedBeaconBlock)) error { + req *ethpb.BeaconBlocksByRangeRequest, processBlocks func([]*ethpb.SignedBeaconBlock)) error { var wg sync.WaitGroup wg.Add(1) p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) { @@ -751,7 +750,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)} r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 1, Step: 1, Count: 64, @@ -782,7 +781,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)} r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 1, Step: 1, Count: 64, @@ -817,7 +816,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)} r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 1, Step: 1, Count: 128, @@ -852,7 +851,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)} r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 1, Step: 1, Count: 64, @@ -892,7 +891,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)} r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 1, Step: 1, Count: 64, diff --git a/beacon-chain/sync/rpc_send_request_test.go b/beacon-chain/sync/rpc_send_request_test.go index 4bcbf0a9cec..2fa2e79aacd 100644 --- a/beacon-chain/sync/rpc_send_request_test.go +++ b/beacon-chain/sync/rpc_send_request_test.go @@ -16,8 +16,7 @@ import ( p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/config/params" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "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/testing/assert" @@ -36,13 +35,13 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { bogusPeer := p2ptest.NewTestP2P(t) p1.Connect(bogusPeer) - req := &pb.BeaconBlocksByRangeRequest{} + req := ðpb.BeaconBlocksByRangeRequest{} chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}} _, err := SendBeaconBlocksByRangeRequest(ctx, chain, p1, bogusPeer.PeerID(), req, nil) assert.ErrorContains(t, "protocol not supported", err) }) - knownBlocks := make([]*eth.SignedBeaconBlock, 0) + knownBlocks := make([]*ethpb.SignedBeaconBlock, 0) genesisBlk := util.NewBeaconBlock() genesisBlkRoot, err := genesisBlk.Block.HashTreeRoot() require.NoError(t, err) @@ -62,7 +61,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { assert.NoError(t, stream.Close()) }() - req := &pb.BeaconBlocksByRangeRequest{} + req := ðpb.BeaconBlocksByRangeRequest{} assert.NoError(t, p2pProvider.Encoding().DecodeWithMaxLength(stream, req)) for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) { @@ -98,7 +97,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { p1.Connect(p2) p2.SetStreamHandler(pcl, knownBlocksProvider(p2, nil)) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 20, Count: 128, Step: 1, @@ -116,7 +115,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { p2.SetStreamHandler(pcl, knownBlocksProvider(p2, nil)) // No error from block processor. - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 20, Count: 128, Step: 1, @@ -139,7 +138,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { p2.SetStreamHandler(pcl, knownBlocksProvider(p2, nil)) // Send error from block processor. - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 20, Count: 128, Step: 1, @@ -159,7 +158,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { p2.SetStreamHandler(pcl, knownBlocksProvider(p2, nil)) // No cap on max roots. - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 20, Count: 128, Step: 1, @@ -202,7 +201,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { return nil })) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 20, Count: 128, Step: 1, @@ -229,7 +228,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { assert.NoError(t, stream.Close()) }() - req := &pb.BeaconBlocksByRangeRequest{} + req := ðpb.BeaconBlocksByRangeRequest{} assert.NoError(t, p2.Encoding().DecodeWithMaxLength(stream, req)) for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) { @@ -244,7 +243,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { } }) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 20, Count: 128, Step: 1, @@ -272,7 +271,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { assert.NoError(t, stream.Close()) }() - req := &pb.BeaconBlocksByRangeRequest{} + req := ðpb.BeaconBlocksByRangeRequest{} assert.NoError(t, p2.Encoding().DecodeWithMaxLength(stream, req)) for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) { @@ -287,7 +286,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { } }) - req := &pb.BeaconBlocksByRangeRequest{ + req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 20, Count: 128, Step: 10, @@ -305,7 +304,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) { defer cancel() pcl := fmt.Sprintf("%s/ssz_snappy", p2p.RPCBlocksByRootTopicV1) - knownBlocks := make(map[[32]byte]*eth.SignedBeaconBlock) + knownBlocks := make(map[[32]byte]*ethpb.SignedBeaconBlock) knownRoots := make([][32]byte, 0) for i := 0; i < 5; i++ { blk := util.NewBeaconBlock() diff --git a/beacon-chain/sync/rpc_status_test.go b/beacon-chain/sync/rpc_status_test.go index 4a725030861..f171e3e253e 100644 --- a/beacon-chain/sync/rpc_status_test.go +++ b/beacon-chain/sync/rpc_status_test.go @@ -24,10 +24,8 @@ import ( "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" - p2pWrapper "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" "github.com/prysmaticlabs/prysm/testing/util" @@ -70,7 +68,7 @@ func TestStatusRPCHandler_Disconnects_OnForkVersionMismatch(t *testing.T) { p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) { defer wg.Done() expectSuccess(t, stream) - out := &pb.Status{} + out := ðpb.Status{} assert.NoError(t, r.cfg.p2p.Encoding().DecodeWithMaxLength(stream, out)) assert.DeepEqual(t, root[:], out.FinalizedRoot) assert.NoError(t, stream.Close()) @@ -91,7 +89,7 @@ func TestStatusRPCHandler_Disconnects_OnForkVersionMismatch(t *testing.T) { stream1, err := p1.BHost.NewStream(context.Background(), p2.BHost.ID(), pcl) require.NoError(t, err) - assert.NoError(t, r.statusRPCHandler(context.Background(), &pb.Status{ForkDigest: bytesutil.PadTo([]byte("f"), 4), HeadRoot: make([]byte, 32), FinalizedRoot: make([]byte, 32)}, stream1)) + assert.NoError(t, r.statusRPCHandler(context.Background(), ðpb.Status{ForkDigest: bytesutil.PadTo([]byte("f"), 4), HeadRoot: make([]byte, 32), FinalizedRoot: make([]byte, 32)}, stream1)) if util.WaitTimeout(&wg, 1*time.Second) { t.Fatal("Did not receive stream within 1 sec") @@ -138,7 +136,7 @@ func TestStatusRPCHandler_ConnectsOnGenesis(t *testing.T) { p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) { defer wg.Done() expectSuccess(t, stream) - out := &pb.Status{} + out := ðpb.Status{} assert.NoError(t, r.cfg.p2p.Encoding().DecodeWithMaxLength(stream, out)) assert.DeepEqual(t, root[:], out.FinalizedRoot) }) @@ -148,7 +146,7 @@ func TestStatusRPCHandler_ConnectsOnGenesis(t *testing.T) { digest, err := r.currentForkDigest() require.NoError(t, err) - err = r.statusRPCHandler(context.Background(), &pb.Status{ForkDigest: digest[:], FinalizedRoot: params.BeaconConfig().ZeroHash[:]}, stream1) + err = r.statusRPCHandler(context.Background(), ðpb.Status{ForkDigest: digest[:], FinalizedRoot: params.BeaconConfig().ZeroHash[:]}, stream1) assert.NoError(t, err) if util.WaitTimeout(&wg, 1*time.Second) { @@ -218,9 +216,9 @@ func TestStatusRPCHandler_ReturnsHelloMessage(t *testing.T) { p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) { defer wg.Done() expectSuccess(t, stream) - out := &pb.Status{} + out := ðpb.Status{} assert.NoError(t, r.cfg.p2p.Encoding().DecodeWithMaxLength(stream, out)) - expected := &pb.Status{ + expected := ðpb.Status{ ForkDigest: digest[:], HeadSlot: genesisState.Slot(), HeadRoot: headRoot[:], @@ -234,7 +232,7 @@ func TestStatusRPCHandler_ReturnsHelloMessage(t *testing.T) { stream1, err := p1.BHost.NewStream(context.Background(), p2.BHost.ID(), pcl) require.NoError(t, err) - err = r.statusRPCHandler(context.Background(), &pb.Status{ + err = r.statusRPCHandler(context.Background(), ðpb.Status{ ForkDigest: digest[:], FinalizedRoot: finalizedRoot[:], FinalizedEpoch: 3, @@ -253,12 +251,12 @@ func TestHandshakeHandlers_Roundtrip(t *testing.T) { p2 := p2ptest.NewTestP2P(t) db := testingDB.SetupDB(t) - p1.LocalMetadata = p2pWrapper.WrappedMetadataV0(&pb.MetaDataV0{ + p1.LocalMetadata = wrapper.WrappedMetadataV0(ðpb.MetaDataV0{ SeqNumber: 2, Attnets: bytesutil.PadTo([]byte{'A', 'B'}, 8), }) - p2.LocalMetadata = p2pWrapper.WrappedMetadataV0(&pb.MetaDataV0{ + p2.LocalMetadata = wrapper.WrappedMetadataV0(ðpb.MetaDataV0{ SeqNumber: 2, Attnets: bytesutil.PadTo([]byte{'C', 'D'}, 8), }) @@ -317,10 +315,10 @@ func TestHandshakeHandlers_Roundtrip(t *testing.T) { wg.Add(1) p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) { defer wg.Done() - out := &pb.Status{} + out := ðpb.Status{} assert.NoError(t, r.cfg.p2p.Encoding().DecodeWithMaxLength(stream, out)) log.WithField("status", out).Warn("received status") - resp := &pb.Status{HeadSlot: 100, HeadRoot: make([]byte, 32), ForkDigest: p2.Digest[:], + resp := ðpb.Status{HeadSlot: 100, HeadRoot: make([]byte, 32), ForkDigest: p2.Digest[:], FinalizedRoot: finalizedRoot[:], FinalizedEpoch: 0} _, err := stream.Write([]byte{responseCodeSuccess}) assert.NoError(t, err) @@ -434,11 +432,11 @@ func TestStatusRPCRequest_RequestSent(t *testing.T) { wg.Add(1) p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) { defer wg.Done() - out := &pb.Status{} + out := ðpb.Status{} assert.NoError(t, r.cfg.p2p.Encoding().DecodeWithMaxLength(stream, out)) digest, err := r.currentForkDigest() assert.NoError(t, err) - expected := &pb.Status{ + expected := ðpb.Status{ ForkDigest: digest[:], HeadSlot: genesisState.Slot(), HeadRoot: headRoot[:], @@ -536,7 +534,7 @@ func TestStatusRPCRequest_FinalizedBlockExists(t *testing.T) { wg.Add(1) p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) { defer wg.Done() - out := &pb.Status{} + out := ðpb.Status{} assert.NoError(t, r.cfg.p2p.Encoding().DecodeWithMaxLength(stream, out)) assert.NoError(t, r2.validateStatusMessage(context.Background(), out)) }) @@ -710,7 +708,7 @@ func TestStatusRPCRequest_FinalizedBlockSkippedSlots(t *testing.T) { wg.Add(1) p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) { defer wg.Done() - out := &pb.Status{} + out := ðpb.Status{} assert.NoError(t, r.cfg.p2p.Encoding().DecodeWithMaxLength(stream, out)) assert.Equal(t, tt.expectError, r2.validateStatusMessage(context.Background(), out) != nil) }) @@ -779,9 +777,9 @@ func TestStatusRPCRequest_BadPeerHandshake(t *testing.T) { wg.Add(1) p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) { defer wg.Done() - out := &pb.Status{} + out := ðpb.Status{} assert.NoError(t, r.cfg.p2p.Encoding().DecodeWithMaxLength(stream, out)) - expected := &pb.Status{ + expected := ðpb.Status{ ForkDigest: []byte{1, 1, 1, 1}, HeadSlot: genesisState.Slot(), HeadRoot: headRoot[:], @@ -849,7 +847,7 @@ func TestStatusRPC_ValidGenesisMessage(t *testing.T) { require.NoError(t, err) // There should be no error for a status message // with a genesis checkpoint. - err = r.validateStatusMessage(r.ctx, &pb.Status{ + err = r.validateStatusMessage(r.ctx, ðpb.Status{ ForkDigest: digest[:], FinalizedRoot: params.BeaconConfig().ZeroHash[:], FinalizedEpoch: 0, diff --git a/beacon-chain/sync/subscriber.go b/beacon-chain/sync/subscriber.go index c05b845e09c..d2350598401 100644 --- a/beacon-chain/sync/subscriber.go +++ b/beacon-chain/sync/subscriber.go @@ -21,7 +21,6 @@ import ( "github.com/prysmaticlabs/prysm/monitoring/tracing" "github.com/prysmaticlabs/prysm/network/forks" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/runtime/messagehandler" "github.com/prysmaticlabs/prysm/time/slots" "github.com/sirupsen/logrus" @@ -443,7 +442,7 @@ func (s *Service) subscribeAggregatorSubnet( ) { // do not subscribe if we have no peers in the same // subnet - topic := p2p.GossipTypeMapping[reflect.TypeOf(&pb.Attestation{})] + topic := p2p.GossipTypeMapping[reflect.TypeOf(ðpb.Attestation{})] subnetTopic := fmt.Sprintf(topic, digest, idx) // check if subscription exists and if not subscribe the relevant subnet. if _, exists := subscriptions[idx]; !exists { @@ -610,7 +609,7 @@ func (s *Service) subscribeDynamicWithSyncSubnets( // lookup peers for attester specific subnets. func (s *Service) lookupAttesterSubnets(digest [4]byte, idx uint64) { - topic := p2p.GossipTypeMapping[reflect.TypeOf(&pb.Attestation{})] + topic := p2p.GossipTypeMapping[reflect.TypeOf(ðpb.Attestation{})] subnetTopic := fmt.Sprintf(topic, digest, idx) if !s.validPeersExist(subnetTopic) { log.Debugf("No peers found subscribed to attestation gossip subnet with "+ @@ -654,7 +653,7 @@ func (s *Service) retrievePersistentSubs(currSlot types.Slot) []uint64 { return slice.SetUint64(append(persistentSubs, wantedSubs...)) } -func (s *Service) retrieveActiveSyncSubnets(currEpoch types.Epoch) []uint64 { +func (_ *Service) retrieveActiveSyncSubnets(currEpoch types.Epoch) []uint64 { subs := cache.SyncSubnetIDs.GetAllSubnets(currEpoch) return slice.SetUint64(subs) } @@ -674,7 +673,7 @@ func (s *Service) filterNeededPeers(pids []peer.ID) []peer.ID { currSlot := s.cfg.chain.CurrentSlot() wantedSubs := s.retrievePersistentSubs(currSlot) wantedSubs = slice.SetUint64(append(wantedSubs, s.attesterSubnetIndices(currSlot)...)) - topic := p2p.GossipTypeMapping[reflect.TypeOf(&pb.Attestation{})] + topic := p2p.GossipTypeMapping[reflect.TypeOf(ðpb.Attestation{})] // Map of peers in subnets peerMap := make(map[peer.ID]bool) @@ -709,7 +708,7 @@ func (s *Service) filterNeededPeers(pids []peer.ID) []peer.ID { } // Add fork digest to topic. -func (s *Service) addDigestToTopic(topic string, digest [4]byte) string { +func (_ *Service) addDigestToTopic(topic string, digest [4]byte) string { if !strings.Contains(topic, "%x") { log.Fatal("Topic does not have appropriate formatter for digest") } @@ -717,7 +716,7 @@ func (s *Service) addDigestToTopic(topic string, digest [4]byte) string { } // Add the digest and index to subnet topic. -func (s *Service) addDigestAndIndexToTopic(topic string, digest [4]byte, idx uint64) string { +func (_ *Service) addDigestAndIndexToTopic(topic string, digest [4]byte, idx uint64) string { if !strings.Contains(topic, "%x") { log.Fatal("Topic does not have appropriate formatter for digest") } diff --git a/beacon-chain/sync/subscriber_beacon_attestation.go b/beacon-chain/sync/subscriber_beacon_attestation.go index 04725bfe9f5..56bcc00d956 100644 --- a/beacon-chain/sync/subscriber_beacon_attestation.go +++ b/beacon-chain/sync/subscriber_beacon_attestation.go @@ -36,11 +36,11 @@ func (s *Service) committeeIndexBeaconAttestationSubscriber(_ context.Context, m return s.cfg.attPool.SaveUnaggregatedAttestation(a) } -func (s *Service) persistentSubnetIndices() []uint64 { +func (_ *Service) persistentSubnetIndices() []uint64 { return cache.SubnetIDs.GetAllSubnets() } -func (s *Service) aggregatorSubnetIndices(currentSlot types.Slot) []uint64 { +func (_ *Service) aggregatorSubnetIndices(currentSlot types.Slot) []uint64 { endEpoch := slots.ToEpoch(currentSlot) + 1 endSlot := params.BeaconConfig().SlotsPerEpoch.Mul(uint64(endEpoch)) var commIds []uint64 @@ -50,7 +50,7 @@ func (s *Service) aggregatorSubnetIndices(currentSlot types.Slot) []uint64 { return slice.SetUint64(commIds) } -func (s *Service) attesterSubnetIndices(currentSlot types.Slot) []uint64 { +func (_ *Service) attesterSubnetIndices(currentSlot types.Slot) []uint64 { endEpoch := slots.ToEpoch(currentSlot) + 1 endSlot := params.BeaconConfig().SlotsPerEpoch.Mul(uint64(endEpoch)) var commIds []uint64 diff --git a/beacon-chain/sync/subscriber_beacon_blocks.go b/beacon-chain/sync/subscriber_beacon_blocks.go index 2520d5eaa21..7dcebee9308 100644 --- a/beacon-chain/sync/subscriber_beacon_blocks.go +++ b/beacon-chain/sync/subscriber_beacon_blocks.go @@ -10,7 +10,6 @@ import ( ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" - wrapperv2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "google.golang.org/protobuf/proto" ) @@ -71,7 +70,7 @@ func blockFromProto(msg proto.Message) (block.SignedBeaconBlock, error) { case *ethpb.SignedBeaconBlock: return wrapper.WrappedPhase0SignedBeaconBlock(t), nil case *ethpb.SignedBeaconBlockAltair: - return wrapperv2.WrappedAltairSignedBeaconBlock(t) + return wrapper.WrappedAltairSignedBeaconBlock(t) default: return nil, errors.Errorf("message has invalid underlying type: %T", msg) } diff --git a/beacon-chain/sync/utils.go b/beacon-chain/sync/utils.go index c5e79002185..2761eb2028d 100644 --- a/beacon-chain/sync/utils.go +++ b/beacon-chain/sync/utils.go @@ -32,7 +32,7 @@ func (s sortedObj) Len() int { } // removes duplicates from provided blocks and roots. -func (s *Service) dedupBlocksAndRoots(blks []block.SignedBeaconBlock, roots [][32]byte) ([]block.SignedBeaconBlock, [][32]byte, error) { +func (_ *Service) dedupBlocksAndRoots(blks []block.SignedBeaconBlock, roots [][32]byte) ([]block.SignedBeaconBlock, [][32]byte, error) { if len(blks) != len(roots) { return nil, nil, errors.New("input blks and roots are diff lengths") } @@ -52,7 +52,7 @@ func (s *Service) dedupBlocksAndRoots(blks []block.SignedBeaconBlock, roots [][3 return newBlks, newRoots, nil } -func (s *Service) dedupRoots(roots [][32]byte) [][32]byte { +func (_ *Service) dedupRoots(roots [][32]byte) [][32]byte { newRoots := make([][32]byte, 0, len(roots)) rootMap := make(map[[32]byte]bool, len(roots)) for i, r := range roots { @@ -67,7 +67,7 @@ func (s *Service) dedupRoots(roots [][32]byte) [][32]byte { // sort the provided blocks and roots in ascending order. This method assumes that the size of // block slice and root slice is equal. -func (s *Service) sortBlocksAndRoots(blks []block.SignedBeaconBlock, roots [][32]byte) ([]block.SignedBeaconBlock, [][32]byte) { +func (_ *Service) sortBlocksAndRoots(blks []block.SignedBeaconBlock, roots [][32]byte) ([]block.SignedBeaconBlock, [][32]byte) { obj := sortedObj{ blks: blks, roots: roots, diff --git a/cmd/beacon-chain/flags/api_module.go b/cmd/beacon-chain/flags/api_module.go index 2bc47344d3c..31dfe707655 100644 --- a/cmd/beacon-chain/flags/api_module.go +++ b/cmd/beacon-chain/flags/api_module.go @@ -13,7 +13,7 @@ func EnableHTTPEthAPI(httpModules string) bool { return enableAPI(httpModules, EthAPIModule) } -func enableAPI(httpModules string, api string) bool { +func enableAPI(httpModules, api string) bool { for _, m := range strings.Split(httpModules, ",") { if strings.EqualFold(m, api) { return true diff --git a/cmd/password_reader.go b/cmd/password_reader.go index 0e9d8593b4a..1c2162ad187 100644 --- a/cmd/password_reader.go +++ b/cmd/password_reader.go @@ -16,7 +16,7 @@ type StdInPasswordReader struct { } // ReadPassword reads a password from stdin. -func (pr StdInPasswordReader) ReadPassword() (string, error) { +func (_ StdInPasswordReader) ReadPassword() (string, error) { pwd, err := terminal.ReadPassword(int(os.Stdin.Fd())) return string(pwd), err } diff --git a/crypto/keystore/keystore.go b/crypto/keystore/keystore.go index 84cc18e43e5..de44cb00f3f 100644 --- a/crypto/keystore/keystore.go +++ b/crypto/keystore/keystore.go @@ -53,7 +53,7 @@ type Keystore struct { } // GetKey from file using the filename path and a decryption password. -func (ks Keystore) GetKey(filename, password string) (*Key, error) { +func (_ Keystore) GetKey(filename, password string) (*Key, error) { // Load the key from the keystore and decrypt its contents // #nosec G304 keyJSON, err := ioutil.ReadFile(filename) @@ -65,7 +65,7 @@ func (ks Keystore) GetKey(filename, password string) (*Key, error) { // GetKeys from directory using the prefix to filter relevant files // and a decryption password. -func (ks Keystore) GetKeys(directory, filePrefix, password string, warnOnFail bool) (map[string]*Key, error) { +func (_ Keystore) GetKeys(directory, filePrefix, password string, warnOnFail bool) (map[string]*Key, error) { // Load the key from the keystore and decrypt its contents // #nosec G304 files, err := ioutil.ReadDir(directory) diff --git a/crypto/rand/rand.go b/crypto/rand/rand.go index b6ea9f04aeb..3f6d2d063ea 100644 --- a/crypto/rand/rand.go +++ b/crypto/rand/rand.go @@ -43,7 +43,7 @@ var lock sync.RWMutex var _ mrand.Source64 = (*source)(nil) /* #nosec G404 */ // Seed does nothing when crypto/rand is used as source. -func (s *source) Seed(_ int64) {} +func (_ *source) Seed(_ int64) {} // Int63 returns uniformly-distributed random (as in CSPRNG) int64 value within [0, 1<<63) range. // Panics if random generator reader cannot return data. @@ -53,7 +53,7 @@ func (s *source) Int63() int64 { // Uint64 returns uniformly-distributed random (as in CSPRNG) uint64 value within [0, 1<<64) range. // Panics if random generator reader cannot return data. -func (s *source) Uint64() (val uint64) { +func (_ *source) Uint64() (val uint64) { lock.RLock() defer lock.RUnlock() if err := binary.Read(rand.Reader, binary.BigEndian, &val); err != nil { diff --git a/monitoring/prometheus/logrus_collector.go b/monitoring/prometheus/logrus_collector.go index 3214e69d5b5..0e010be2bf1 100644 --- a/monitoring/prometheus/logrus_collector.go +++ b/monitoring/prometheus/logrus_collector.go @@ -46,6 +46,6 @@ func (hook *LogrusCollector) Fire(entry *logrus.Entry) error { } // Levels return a slice of levels supported by this hook; -func (hook *LogrusCollector) Levels() []logrus.Level { +func (_ *LogrusCollector) Levels() []logrus.Level { return supportedLevels } diff --git a/monitoring/prometheus/service.go b/monitoring/prometheus/service.go index 3bd1e082784..8abd05127b4 100644 --- a/monitoring/prometheus/service.go +++ b/monitoring/prometheus/service.go @@ -113,7 +113,7 @@ func (s *Service) healthzHandler(w http.ResponseWriter, r *http.Request) { } } -func (s *Service) goroutinezHandler(w http.ResponseWriter, _ *http.Request) { +func (_ *Service) goroutinezHandler(w http.ResponseWriter, _ *http.Request) { stack := debug.Stack() if _, err := w.Write(stack); err != nil { log.WithError(err).Error("Failed to write goroutines stack") diff --git a/monitoring/prometheus/service_test.go b/monitoring/prometheus/service_test.go index 39ee33cbea4..e9ff054d773 100644 --- a/monitoring/prometheus/service_test.go +++ b/monitoring/prometheus/service_test.go @@ -45,10 +45,10 @@ type mockService struct { status error } -func (m *mockService) Start() { +func (_ *mockService) Start() { } -func (m *mockService) Stop() error { +func (_ *mockService) Stop() error { return nil } diff --git a/proto/prysm/v1alpha1/attestation/attestation_utils.go b/proto/prysm/v1alpha1/attestation/attestation_utils.go index ca30c65f2c8..88285627c1b 100644 --- a/proto/prysm/v1alpha1/attestation/attestation_utils.go +++ b/proto/prysm/v1alpha1/attestation/attestation_utils.go @@ -37,7 +37,7 @@ import ( // signature=attestation.signature, // ) func ConvertToIndexed(ctx context.Context, attestation *ethpb.Attestation, committee []types.ValidatorIndex) (*ethpb.IndexedAttestation, error) { - ctx, span := trace.StartSpan(ctx, "attestationutil.ConvertToIndexed") + _, span := trace.StartSpan(ctx, "attestationutil.ConvertToIndexed") defer span.End() attIndices, err := AttestingIndices(attestation.AggregationBits, committee) @@ -101,7 +101,7 @@ func AttestingIndices(bf bitfield.Bitfield, committee []types.ValidatorIndex) ([ // signing_root = compute_signing_root(indexed_attestation.data, domain) // return bls.FastAggregateVerify(pubkeys, signing_root, indexed_attestation.signature) func VerifyIndexedAttestationSig(ctx context.Context, indexedAtt *ethpb.IndexedAttestation, pubKeys []bls.PublicKey, domain []byte) error { - ctx, span := trace.StartSpan(ctx, "attestationutil.VerifyIndexedAttestationSig") + _, span := trace.StartSpan(ctx, "attestationutil.VerifyIndexedAttestationSig") defer span.End() indices := indexedAtt.AttestingIndices messageHash, err := signing.ComputeSigningRoot(indexedAtt.Data, domain) @@ -140,7 +140,7 @@ func VerifyIndexedAttestationSig(ctx context.Context, indexedAtt *ethpb.IndexedA // signing_root = compute_signing_root(indexed_attestation.data, domain) // return bls.FastAggregateVerify(pubkeys, signing_root, indexed_attestation.signature) func IsValidAttestationIndices(ctx context.Context, indexedAttestation *ethpb.IndexedAttestation) error { - ctx, span := trace.StartSpan(ctx, "attestationutil.IsValidAttestationIndices") + _, span := trace.StartSpan(ctx, "attestationutil.IsValidAttestationIndices") defer span.End() if indexedAttestation == nil || indexedAttestation.Data == nil || indexedAttestation.Data.Target == nil || indexedAttestation.AttestingIndices == nil { diff --git a/proto/prysm/v1alpha1/wrapper/beacon_block.go b/proto/prysm/v1alpha1/wrapper/beacon_block.go index 384d2b74582..2ca3b4d3766 100644 --- a/proto/prysm/v1alpha1/wrapper/beacon_block.go +++ b/proto/prysm/v1alpha1/wrapper/beacon_block.go @@ -85,17 +85,17 @@ func (w Phase0SignedBeaconBlock) PbPhase0Block() (*eth.SignedBeaconBlock, error) } // PbAltairBlock is a stub. -func (w Phase0SignedBeaconBlock) PbAltairBlock() (*eth.SignedBeaconBlockAltair, error) { +func (_ Phase0SignedBeaconBlock) PbAltairBlock() (*eth.SignedBeaconBlockAltair, error) { return nil, errors.New("unsupported altair block") } // PbMergeBlock is a stub. -func (w Phase0SignedBeaconBlock) PbMergeBlock() (*eth.SignedBeaconBlockMerge, error) { +func (_ Phase0SignedBeaconBlock) PbMergeBlock() (*eth.SignedBeaconBlockMerge, error) { return nil, errors.New("unsupported merge block") } // Version of the underlying protobuf object. -func (w Phase0SignedBeaconBlock) Version() int { +func (_ Phase0SignedBeaconBlock) Version() int { return version.Phase0 } @@ -193,7 +193,7 @@ func (w Phase0BeaconBlock) Proto() proto.Message { } // Version of the underlying protobuf object. -func (w Phase0BeaconBlock) Version() int { +func (_ Phase0BeaconBlock) Version() int { return version.Phase0 } @@ -249,7 +249,7 @@ func (w Phase0BeaconBlockBody) VoluntaryExits() []*eth.SignedVoluntaryExit { } // SyncAggregate returns the sync aggregate in the block. -func (w Phase0BeaconBlockBody) SyncAggregate() (*eth.SyncAggregate, error) { +func (_ Phase0BeaconBlockBody) SyncAggregate() (*eth.SyncAggregate, error) { return nil, errors.New("Sync aggregate is not supported in phase 0 block") } @@ -270,7 +270,7 @@ func (w Phase0BeaconBlockBody) Proto() proto.Message { } // ExecutionPayload is a stub. -func (w Phase0BeaconBlockBody) ExecutionPayload() (*eth.ExecutionPayload, error) { +func (_ Phase0BeaconBlockBody) ExecutionPayload() (*eth.ExecutionPayload, error) { return nil, errors.New("ExecutionPayload is not supported in phase 0 block body") } @@ -356,17 +356,17 @@ func (w altairSignedBeaconBlock) PbAltairBlock() (*eth.SignedBeaconBlockAltair, } // PbPhase0Block is a stub. -func (w altairSignedBeaconBlock) PbPhase0Block() (*eth.SignedBeaconBlock, error) { +func (_ altairSignedBeaconBlock) PbPhase0Block() (*eth.SignedBeaconBlock, error) { return nil, ErrUnsupportedPhase0Block } // PbMergeBlock is a stub. -func (w altairSignedBeaconBlock) PbMergeBlock() (*eth.SignedBeaconBlockMerge, error) { +func (_ altairSignedBeaconBlock) PbMergeBlock() (*eth.SignedBeaconBlockMerge, error) { return nil, errors.New("unsupported merge block") } // Version of the underlying protobuf object. -func (w altairSignedBeaconBlock) Version() int { +func (_ altairSignedBeaconBlock) Version() int { return version.Altair } @@ -468,7 +468,7 @@ func (w altairBeaconBlock) Proto() proto.Message { } // Version of the underlying protobuf object. -func (w altairBeaconBlock) Version() int { +func (_ altairBeaconBlock) Version() int { return version.Altair } @@ -549,7 +549,7 @@ func (w altairBeaconBlockBody) Proto() proto.Message { } // ExecutionPayload is a stub. -func (w altairBeaconBlockBody) ExecutionPayload() (*eth.ExecutionPayload, error) { +func (_ altairBeaconBlockBody) ExecutionPayload() (*eth.ExecutionPayload, error) { return nil, errors.New("ExecutionPayload is not supported in altair block body") } @@ -622,17 +622,17 @@ func (w mergeSignedBeaconBlock) PbMergeBlock() (*eth.SignedBeaconBlockMerge, err } // PbPhase0Block is a stub. -func (w mergeSignedBeaconBlock) PbPhase0Block() (*eth.SignedBeaconBlock, error) { +func (_ mergeSignedBeaconBlock) PbPhase0Block() (*eth.SignedBeaconBlock, error) { return nil, ErrUnsupportedPhase0Block } // PbAltairBlock returns the underlying protobuf object. -func (w mergeSignedBeaconBlock) PbAltairBlock() (*eth.SignedBeaconBlockAltair, error) { +func (_ mergeSignedBeaconBlock) PbAltairBlock() (*eth.SignedBeaconBlockAltair, error) { return nil, errors.New("unsupported altair block") } // Version of the underlying protobuf object. -func (w mergeSignedBeaconBlock) Version() int { +func (_ mergeSignedBeaconBlock) Version() int { return version.Merge } @@ -734,7 +734,7 @@ func (w mergeBeaconBlock) Proto() proto.Message { } // Version of the underlying protobuf object. -func (w mergeBeaconBlock) Version() int { +func (_ mergeBeaconBlock) Version() int { return version.Merge } diff --git a/proto/prysm/v1alpha1/wrapper/beacon_block_test.go b/proto/prysm/v1alpha1/wrapper/beacon_block_test.go index f54bf9faf37..465984cd8a3 100644 --- a/proto/prysm/v1alpha1/wrapper/beacon_block_test.go +++ b/proto/prysm/v1alpha1/wrapper/beacon_block_test.go @@ -7,7 +7,6 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/runtime/version" "github.com/prysmaticlabs/prysm/testing/assert" @@ -206,7 +205,7 @@ func TestAltairBeaconBlockBody_RandaoReveal(t *testing.T) { } func TestAltairBeaconBlockBody_Eth1Data(t *testing.T) { - data := &v1alpha1.Eth1Data{} + data := ðpb.Eth1Data{} body := ðpb.BeaconBlockBodyAltair{ Eth1Data: data, } @@ -225,8 +224,8 @@ func TestAltairBeaconBlockBody_Graffiti(t *testing.T) { } func TestAltairBeaconBlockBody_ProposerSlashings(t *testing.T) { - ps := []*v1alpha1.ProposerSlashing{ - {Header_1: &v1alpha1.SignedBeaconBlockHeader{ + ps := []*ethpb.ProposerSlashing{ + {Header_1: ðpb.SignedBeaconBlockHeader{ Signature: []byte{0x11, 0x20}, }}, } @@ -238,8 +237,8 @@ func TestAltairBeaconBlockBody_ProposerSlashings(t *testing.T) { } func TestAltairBeaconBlockBody_AttesterSlashings(t *testing.T) { - as := []*v1alpha1.AttesterSlashing{ - {Attestation_1: &v1alpha1.IndexedAttestation{Signature: []byte{0x11}}}, + as := []*ethpb.AttesterSlashing{ + {Attestation_1: ðpb.IndexedAttestation{Signature: []byte{0x11}}}, } body := ðpb.BeaconBlockBodyAltair{AttesterSlashings: as} wbb, err := wrapper.WrappedAltairBeaconBlockBody(body) @@ -249,7 +248,7 @@ func TestAltairBeaconBlockBody_AttesterSlashings(t *testing.T) { } func TestAltairBeaconBlockBody_Attestations(t *testing.T) { - atts := []*v1alpha1.Attestation{{Signature: []byte{0x88}}} + atts := []*ethpb.Attestation{{Signature: []byte{0x88}}} body := ðpb.BeaconBlockBodyAltair{Attestations: atts} wbb, err := wrapper.WrappedAltairBeaconBlockBody(body) @@ -259,7 +258,7 @@ func TestAltairBeaconBlockBody_Attestations(t *testing.T) { } func TestAltairBeaconBlockBody_Deposits(t *testing.T) { - deposits := []*v1alpha1.Deposit{ + deposits := []*ethpb.Deposit{ {Proof: [][]byte{{0x54, 0x10}}}, } body := ðpb.BeaconBlockBodyAltair{Deposits: deposits} @@ -270,8 +269,8 @@ func TestAltairBeaconBlockBody_Deposits(t *testing.T) { } func TestAltairBeaconBlockBody_VoluntaryExits(t *testing.T) { - exits := []*v1alpha1.SignedVoluntaryExit{ - {Exit: &v1alpha1.VoluntaryExit{Epoch: 54}}, + exits := []*ethpb.SignedVoluntaryExit{ + {Exit: ðpb.VoluntaryExit{Epoch: 54}}, } body := ðpb.BeaconBlockBodyAltair{VoluntaryExits: exits} wbb, err := wrapper.WrappedAltairBeaconBlockBody(body) @@ -557,7 +556,7 @@ func TestMergeBeaconBlockBody_RandaoReveal(t *testing.T) { } func TestMergeBeaconBlockBody_Eth1Data(t *testing.T) { - data := &v1alpha1.Eth1Data{} + data := ðpb.Eth1Data{} body := ðpb.BeaconBlockBodyMerge{ Eth1Data: data, } @@ -576,8 +575,8 @@ func TestMergeBeaconBlockBody_Graffiti(t *testing.T) { } func TestMergeBeaconBlockBody_ProposerSlashings(t *testing.T) { - ps := []*v1alpha1.ProposerSlashing{ - {Header_1: &v1alpha1.SignedBeaconBlockHeader{ + ps := []*ethpb.ProposerSlashing{ + {Header_1: ðpb.SignedBeaconBlockHeader{ Signature: []byte{0x11, 0x20}, }}, } @@ -589,8 +588,8 @@ func TestMergeBeaconBlockBody_ProposerSlashings(t *testing.T) { } func TestMergeBeaconBlockBody_AttesterSlashings(t *testing.T) { - as := []*v1alpha1.AttesterSlashing{ - {Attestation_1: &v1alpha1.IndexedAttestation{Signature: []byte{0x11}}}, + as := []*ethpb.AttesterSlashing{ + {Attestation_1: ðpb.IndexedAttestation{Signature: []byte{0x11}}}, } body := ðpb.BeaconBlockBodyMerge{AttesterSlashings: as} wbb, err := wrapper.WrappedMergeBeaconBlockBody(body) @@ -600,7 +599,7 @@ func TestMergeBeaconBlockBody_AttesterSlashings(t *testing.T) { } func TestMergeBeaconBlockBody_Attestations(t *testing.T) { - atts := []*v1alpha1.Attestation{{Signature: []byte{0x88}}} + atts := []*ethpb.Attestation{{Signature: []byte{0x88}}} body := ðpb.BeaconBlockBodyMerge{Attestations: atts} wbb, err := wrapper.WrappedMergeBeaconBlockBody(body) @@ -610,7 +609,7 @@ func TestMergeBeaconBlockBody_Attestations(t *testing.T) { } func TestMergeBeaconBlockBody_Deposits(t *testing.T) { - deposits := []*v1alpha1.Deposit{ + deposits := []*ethpb.Deposit{ {Proof: [][]byte{{0x54, 0x10}}}, } body := ðpb.BeaconBlockBodyMerge{Deposits: deposits} @@ -621,8 +620,8 @@ func TestMergeBeaconBlockBody_Deposits(t *testing.T) { } func TestMergeBeaconBlockBody_VoluntaryExits(t *testing.T) { - exits := []*v1alpha1.SignedVoluntaryExit{ - {Exit: &v1alpha1.VoluntaryExit{Epoch: 54}}, + exits := []*ethpb.SignedVoluntaryExit{ + {Exit: ðpb.VoluntaryExit{Epoch: 54}}, } body := ðpb.BeaconBlockBodyMerge{VoluntaryExits: exits} wbb, err := wrapper.WrappedMergeBeaconBlockBody(body) @@ -659,7 +658,7 @@ func TestMergeBeaconBlockBody_Proto(t *testing.T) { } func TestMergeBeaconBlockBody_ExecutionPayload(t *testing.T) { - payloads := &v1alpha1.ExecutionPayload{ + payloads := ðpb.ExecutionPayload{ BlockNumber: 100, } body := ðpb.BeaconBlockBodyMerge{ExecutionPayload: payloads} diff --git a/proto/prysm/v1alpha1/wrapper/metadata.go b/proto/prysm/v1alpha1/wrapper/metadata.go index 549eaa42b2f..f669af404ea 100644 --- a/proto/prysm/v1alpha1/wrapper/metadata.go +++ b/proto/prysm/v1alpha1/wrapper/metadata.go @@ -74,12 +74,12 @@ func (m MetadataV0) MetadataObjV0() *pb.MetaDataV0 { // MetadataObjV1 returns the inner metatdata object in its type // specified form. If it doesn't exist then we return nothing. -func (m MetadataV0) MetadataObjV1() *pb.MetaDataV1 { +func (_ MetadataV0) MetadataObjV1() *pb.MetaDataV1 { return nil } // Version returns the fork version of the underlying object. -func (m MetadataV0) Version() int { +func (_ MetadataV0) Version() int { return version.Phase0 } @@ -143,7 +143,7 @@ func (m MetadataV1) UnmarshalSSZ(buf []byte) error { // MetadataObjV0 returns the inner metadata object in its type // specified form. If it doesn't exist then we return nothing. -func (m MetadataV1) MetadataObjV0() *pb.MetaDataV0 { +func (_ MetadataV1) MetadataObjV0() *pb.MetaDataV0 { return nil } @@ -154,6 +154,6 @@ func (m MetadataV1) MetadataObjV1() *pb.MetaDataV1 { } // Version returns the fork version of the underlying object. -func (m MetadataV1) Version() int { +func (_ MetadataV1) Version() int { return version.Altair } diff --git a/runtime/service_registry_test.go b/runtime/service_registry_test.go index 9dfed5d9f02..20f066cb6fb 100644 --- a/runtime/service_registry_test.go +++ b/runtime/service_registry_test.go @@ -16,10 +16,10 @@ type secondMockService struct { status error } -func (m *mockService) Start() { +func (_ *mockService) Start() { } -func (m *mockService) Stop() error { +func (_ *mockService) Stop() error { return nil } @@ -27,10 +27,10 @@ func (m *mockService) Status() error { return m.status } -func (s *secondMockService) Start() { +func (_ *secondMockService) Start() { } -func (s *secondMockService) Stop() error { +func (_ *secondMockService) Stop() error { return nil } diff --git a/testing/endtoend/evaluators/api_middleware.go b/testing/endtoend/evaluators/api_middleware.go index 857e007183c..29bc5454c4b 100644 --- a/testing/endtoend/evaluators/api_middleware.go +++ b/testing/endtoend/evaluators/api_middleware.go @@ -248,7 +248,7 @@ func doMiddlewareJSONGetRequestV1(requestPath string, beaconNodeIdx int, dst int return json.NewDecoder(httpResp.Body).Decode(&dst) } -func doMiddlewareJSONPostRequestV1(requestPath string, beaconNodeIdx int, postData interface{}, dst interface{}) error { +func doMiddlewareJSONPostRequestV1(requestPath string, beaconNodeIdx int, postData, dst interface{}) error { b, err := json.Marshal(postData) if err != nil { return err diff --git a/testing/spectest/shared/altair/fork/transition.go b/testing/spectest/shared/altair/fork/transition.go index 88f4d731900..dcb27cfa5d6 100644 --- a/testing/spectest/shared/altair/fork/transition.go +++ b/testing/spectest/shared/altair/fork/transition.go @@ -15,7 +15,6 @@ import ( "github.com/prysmaticlabs/prysm/config/params" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" - wrapperv1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/testing/require" "github.com/prysmaticlabs/prysm/testing/spectest/utils" "github.com/prysmaticlabs/prysm/testing/util" @@ -101,7 +100,7 @@ func RunForkTransitionTest(t *testing.T, config string) { ctx := context.Background() var ok bool for _, b := range preforkBlocks { - st, err := transition.ExecuteStateTransition(ctx, beaconState, wrapperv1.WrappedPhase0SignedBeaconBlock(b)) + st, err := transition.ExecuteStateTransition(ctx, beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) require.NoError(t, err) beaconState, ok = st.(*v1.BeaconState) require.Equal(t, true, ok) diff --git a/time/slots/testing/mock.go b/time/slots/testing/mock.go index 22358b34359..5c6e5b44688 100644 --- a/time/slots/testing/mock.go +++ b/time/slots/testing/mock.go @@ -15,4 +15,4 @@ func (m *MockTicker) C() <-chan types.Slot { } // Done -- -func (m *MockTicker) Done() {} +func (_ *MockTicker) Done() {} diff --git a/tools/forkchecker/forkchecker.go b/tools/forkchecker/forkchecker.go index f1acb42d122..f6857987cdf 100644 --- a/tools/forkchecker/forkchecker.go +++ b/tools/forkchecker/forkchecker.go @@ -28,7 +28,7 @@ var log = logrus.WithField("prefix", "forkchoice_checker") type endpoint []string -func (e *endpoint) String() string { +func (_ *endpoint) String() string { return "gRPC endpoints" } diff --git a/validator/accounts/accounts_list_test.go b/validator/accounts/accounts_list_test.go index 6904b77f669..a5de49428ab 100644 --- a/validator/accounts/accounts_list_test.go +++ b/validator/accounts/accounts_list_test.go @@ -40,11 +40,11 @@ func (m *mockRemoteKeymanager) FetchValidatingPublicKeys(_ context.Context) ([][ return m.publicKeys, nil } -func (m *mockRemoteKeymanager) Sign(context.Context, *validatorpb.SignRequest) (bls.Signature, error) { +func (_ *mockRemoteKeymanager) Sign(context.Context, *validatorpb.SignRequest) (bls.Signature, error) { return nil, nil } -func (m *mockRemoteKeymanager) SubscribeAccountChanges(_ chan [][48]byte) event.Subscription { +func (_ *mockRemoteKeymanager) SubscribeAccountChanges(_ chan [][48]byte) event.Subscription { return nil } diff --git a/validator/accounts/testing/mock.go b/validator/accounts/testing/mock.go index 1cd98b94bdd..82e43ee3e5a 100644 --- a/validator/accounts/testing/mock.go +++ b/validator/accounts/testing/mock.go @@ -72,6 +72,6 @@ func (w *Wallet) ReadFileAtPath(_ context.Context, pathName, fileName string) ([ } // InitializeKeymanager -- -func (w *Wallet) InitializeKeymanager(_ context.Context, _ iface.InitKeymanagerConfig) (keymanager.IKeymanager, error) { +func (_ *Wallet) InitializeKeymanager(_ context.Context, _ iface.InitKeymanagerConfig) (keymanager.IKeymanager, error) { return nil, nil } diff --git a/validator/client/sync_committee_test.go b/validator/client/sync_committee_test.go index bc4099ffbb2..818092f00ed 100644 --- a/validator/client/sync_committee_test.go +++ b/validator/client/sync_committee_test.go @@ -11,7 +11,6 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/crypto/bls" "github.com/prysmaticlabs/prysm/encoding/bytesutil" - eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" @@ -23,7 +22,7 @@ import ( func TestSubmitSyncCommitteeMessage_ValidatorDutiesRequestFailure(t *testing.T) { hook := logTest.NewGlobal() validator, m, validatorKey, finish := setup(t) - validator.duties = ð.DutiesResponse{Duties: []*eth.DutiesResponse_Duty{}} + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{}} defer finish() m.validatorClient.EXPECT().GetSyncMessageBlockRoot( @@ -45,7 +44,7 @@ func TestSubmitSyncCommitteeMessage_BadDomainData(t *testing.T) { hook := logTest.NewGlobal() validatorIndex := types.ValidatorIndex(7) committee := []types.ValidatorIndex{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} - validator.duties = ð.DutiesResponse{Duties: []*eth.DutiesResponse_Duty{ + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{ { PublicKey: validatorKey.PublicKey().Marshal(), Committee: committee, @@ -77,7 +76,7 @@ func TestSubmitSyncCommitteeMessage_CouldNotSubmit(t *testing.T) { hook := logTest.NewGlobal() validatorIndex := types.ValidatorIndex(7) committee := []types.ValidatorIndex{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} - validator.duties = ð.DutiesResponse{Duties: []*eth.DutiesResponse_Duty{ + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{ { PublicKey: validatorKey.PublicKey().Marshal(), Committee: committee, @@ -96,7 +95,7 @@ func TestSubmitSyncCommitteeMessage_CouldNotSubmit(t *testing.T) { m.validatorClient.EXPECT(). DomainData(gomock.Any(), // ctx gomock.Any()). // epoch - Return(ð.DomainResponse{ + Return(ðpb.DomainResponse{ SignatureDomain: make([]byte, 32), }, nil) @@ -118,7 +117,7 @@ func TestSubmitSyncCommitteeMessage_OK(t *testing.T) { hook := logTest.NewGlobal() validatorIndex := types.ValidatorIndex(7) committee := []types.ValidatorIndex{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} - validator.duties = ð.DutiesResponse{Duties: []*eth.DutiesResponse_Duty{ + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{ { PublicKey: validatorKey.PublicKey().Marshal(), Committee: committee, @@ -137,7 +136,7 @@ func TestSubmitSyncCommitteeMessage_OK(t *testing.T) { m.validatorClient.EXPECT(). DomainData(gomock.Any(), // ctx gomock.Any()). // epoch - Return(ð.DomainResponse{ + Return(ðpb.DomainResponse{ SignatureDomain: make([]byte, 32), }, nil) @@ -162,7 +161,7 @@ func TestSubmitSyncCommitteeMessage_OK(t *testing.T) { func TestSubmitSignedContributionAndProof_ValidatorDutiesRequestFailure(t *testing.T) { hook := logTest.NewGlobal() validator, _, validatorKey, finish := setup(t) - validator.duties = ð.DutiesResponse{Duties: []*eth.DutiesResponse_Duty{}} + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{}} defer finish() pubKey := [48]byte{} @@ -176,7 +175,7 @@ func TestSubmitSignedContributionAndProof_GetSyncSubcommitteeIndexFailure(t *tes validator, m, validatorKey, finish := setup(t) validatorIndex := types.ValidatorIndex(7) committee := []types.ValidatorIndex{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} - validator.duties = ð.DutiesResponse{Duties: []*eth.DutiesResponse_Duty{ + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{ { PublicKey: validatorKey.PublicKey().Marshal(), Committee: committee, @@ -204,7 +203,7 @@ func TestSubmitSignedContributionAndProof_NothingToDo(t *testing.T) { validator, m, validatorKey, finish := setup(t) validatorIndex := types.ValidatorIndex(7) committee := []types.ValidatorIndex{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} - validator.duties = ð.DutiesResponse{Duties: []*eth.DutiesResponse_Duty{ + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{ { PublicKey: validatorKey.PublicKey().Marshal(), Committee: committee, @@ -232,7 +231,7 @@ func TestSubmitSignedContributionAndProof_BadDomain(t *testing.T) { validator, m, validatorKey, finish := setup(t) validatorIndex := types.ValidatorIndex(7) committee := []types.ValidatorIndex{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} - validator.duties = ð.DutiesResponse{Duties: []*eth.DutiesResponse_Duty{ + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{ { PublicKey: validatorKey.PublicKey().Marshal(), Committee: committee, @@ -254,7 +253,7 @@ func TestSubmitSignedContributionAndProof_BadDomain(t *testing.T) { m.validatorClient.EXPECT(). DomainData(gomock.Any(), // ctx gomock.Any()). // epoch - Return(ð.DomainResponse{ + Return(ðpb.DomainResponse{ SignatureDomain: make([]byte, 32), }, errors.New("bad domain response")) @@ -273,7 +272,7 @@ func TestSubmitSignedContributionAndProof_CouldNotGetContribution(t *testing.T) validator, m, validatorKey, finish := setupWithKey(t, validatorKey) validatorIndex := types.ValidatorIndex(7) committee := []types.ValidatorIndex{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} - validator.duties = ð.DutiesResponse{Duties: []*eth.DutiesResponse_Duty{ + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{ { PublicKey: validatorKey.PublicKey().Marshal(), Committee: committee, @@ -295,7 +294,7 @@ func TestSubmitSignedContributionAndProof_CouldNotGetContribution(t *testing.T) m.validatorClient.EXPECT(). DomainData(gomock.Any(), // ctx gomock.Any()). // epoch - Return(ð.DomainResponse{ + Return(ðpb.DomainResponse{ SignatureDomain: make([]byte, 32), }, nil) @@ -323,7 +322,7 @@ func TestSubmitSignedContributionAndProof_CouldNotSubmitContribution(t *testing. validator, m, validatorKey, finish := setupWithKey(t, validatorKey) validatorIndex := types.ValidatorIndex(7) committee := []types.ValidatorIndex{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} - validator.duties = ð.DutiesResponse{Duties: []*eth.DutiesResponse_Duty{ + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{ { PublicKey: validatorKey.PublicKey().Marshal(), Committee: committee, @@ -345,7 +344,7 @@ func TestSubmitSignedContributionAndProof_CouldNotSubmitContribution(t *testing. m.validatorClient.EXPECT(). DomainData(gomock.Any(), // ctx gomock.Any()). // epoch - Return(ð.DomainResponse{ + Return(ðpb.DomainResponse{ SignatureDomain: make([]byte, 32), }, nil) @@ -367,7 +366,7 @@ func TestSubmitSignedContributionAndProof_CouldNotSubmitContribution(t *testing. m.validatorClient.EXPECT(). DomainData(gomock.Any(), // ctx gomock.Any()). // epoch - Return(ð.DomainResponse{ + Return(ðpb.DomainResponse{ SignatureDomain: make([]byte, 32), }, nil) @@ -401,7 +400,7 @@ func TestSubmitSignedContributionAndProof_Ok(t *testing.T) { validator, m, validatorKey, finish := setupWithKey(t, validatorKey) validatorIndex := types.ValidatorIndex(7) committee := []types.ValidatorIndex{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} - validator.duties = ð.DutiesResponse{Duties: []*eth.DutiesResponse_Duty{ + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{ { PublicKey: validatorKey.PublicKey().Marshal(), Committee: committee, @@ -423,7 +422,7 @@ func TestSubmitSignedContributionAndProof_Ok(t *testing.T) { m.validatorClient.EXPECT(). DomainData(gomock.Any(), // ctx gomock.Any()). // epoch - Return(ð.DomainResponse{ + Return(ðpb.DomainResponse{ SignatureDomain: make([]byte, 32), }, nil) @@ -445,7 +444,7 @@ func TestSubmitSignedContributionAndProof_Ok(t *testing.T) { m.validatorClient.EXPECT(). DomainData(gomock.Any(), // ctx gomock.Any()). // epoch - Return(ð.DomainResponse{ + Return(ðpb.DomainResponse{ SignatureDomain: make([]byte, 32), }, nil) diff --git a/validator/client/testutil/mock_validator.go b/validator/client/testutil/mock_validator.go index 4580a7a6a58..251b4e796a4 100644 --- a/validator/client/testutil/mock_validator.go +++ b/validator/client/testutil/mock_validator.go @@ -167,21 +167,21 @@ func (fv *FakeValidator) ProposeBlock(_ context.Context, slot types.Slot, _ [48] } // SubmitAggregateAndProof for mocking. -func (fv *FakeValidator) SubmitAggregateAndProof(_ context.Context, _ types.Slot, _ [48]byte) {} +func (_ *FakeValidator) SubmitAggregateAndProof(_ context.Context, _ types.Slot, _ [48]byte) {} // SubmitSyncCommitteeMessage for mocking. -func (fv *FakeValidator) SubmitSyncCommitteeMessage(_ context.Context, _ types.Slot, _ [48]byte) {} +func (_ *FakeValidator) SubmitSyncCommitteeMessage(_ context.Context, _ types.Slot, _ [48]byte) {} // LogAttestationsSubmitted for mocking. -func (fv *FakeValidator) LogAttestationsSubmitted() {} +func (_ *FakeValidator) LogAttestationsSubmitted() {} // LogNextDutyTimeLeft for mocking. -func (fv *FakeValidator) LogNextDutyTimeLeft(_ types.Slot) error { +func (_ *FakeValidator) LogNextDutyTimeLeft(_ types.Slot) error { return nil } // UpdateDomainDataCaches for mocking. -func (fv *FakeValidator) UpdateDomainDataCaches(context.Context, types.Slot) {} +func (_ *FakeValidator) UpdateDomainDataCaches(context.Context, types.Slot) {} // BalancesByPubkeys for mocking. func (fv *FakeValidator) BalancesByPubkeys(_ context.Context) map[[48]byte]uint64 { @@ -204,7 +204,7 @@ func (fv *FakeValidator) PubkeysToStatuses(_ context.Context) map[[48]byte]ethpb } // AllValidatorsAreExited for mocking -func (fv *FakeValidator) AllValidatorsAreExited(ctx context.Context) (bool, error) { +func (_ *FakeValidator) AllValidatorsAreExited(ctx context.Context) (bool, error) { if ctx.Value(AllValidatorsAreExitedCtxKey) == nil { return false, nil } @@ -217,7 +217,7 @@ func (fv *FakeValidator) GetKeymanager() keymanager.IKeymanager { } // CheckDoppelGanger for mocking -func (fv *FakeValidator) CheckDoppelGanger(_ context.Context) error { +func (_ *FakeValidator) CheckDoppelGanger(_ context.Context) error { return nil } @@ -241,5 +241,5 @@ func (fv *FakeValidator) HandleKeyReload(_ context.Context, newKeys [][48]byte) } // SubmitSignedContributionAndProof for mocking -func (fv *FakeValidator) SubmitSignedContributionAndProof(_ context.Context, _ types.Slot, _ [48]byte) { +func (_ *FakeValidator) SubmitSignedContributionAndProof(_ context.Context, _ types.Slot, _ [48]byte) { } diff --git a/validator/db/kv/attester_protection.go b/validator/db/kv/attester_protection.go index da6ba8c74db..883276b3201 100644 --- a/validator/db/kv/attester_protection.go +++ b/validator/db/kv/attester_protection.go @@ -94,7 +94,7 @@ var ( // we have stored in the database for the given validator public key. func (s *Store) AttestationHistoryForPubKey(ctx context.Context, pubKey [48]byte) ([]*AttestationRecord, error) { records := make([]*AttestationRecord, 0) - ctx, span := trace.StartSpan(ctx, "Validator.AttestationHistoryForPubKey") + _, span := trace.StartSpan(ctx, "Validator.AttestationHistoryForPubKey") defer span.End() err := s.view(func(tx *bolt.Tx) error { bucket := tx.Bucket(pubKeysBucket) @@ -192,7 +192,7 @@ func (s *Store) CheckSlashableAttestation( } // Iterate from the back of the bucket since we are looking for target_epoch > att.target_epoch -func (s *Store) checkSurroundedVote( +func (_ *Store) checkSurroundedVote( targetEpochsBucket *bolt.Bucket, att *ethpb.IndexedAttestation, ) (SlashingKind, error) { c := targetEpochsBucket.Cursor() @@ -232,7 +232,7 @@ func (s *Store) checkSurroundedVote( } // Iterate from the back of the bucket since we are looking for source_epoch > att.source_epoch -func (s *Store) checkSurroundingVote( +func (_ *Store) checkSurroundingVote( sourceEpochsBucket *bolt.Bucket, att *ethpb.IndexedAttestation, ) (SlashingKind, error) { c := sourceEpochsBucket.Cursor() @@ -301,7 +301,7 @@ func (s *Store) SaveAttestationsForPubKey( func (s *Store) SaveAttestationForPubKey( ctx context.Context, pubKey [48]byte, signingRoot [32]byte, att *ethpb.IndexedAttestation, ) error { - ctx, span := trace.StartSpan(ctx, "Validator.SaveAttestationForPubKey") + _, span := trace.StartSpan(ctx, "Validator.SaveAttestationForPubKey") defer span.End() s.batchedAttestationsChan <- &AttestationRecord{ PubKey: pubKey, @@ -396,7 +396,7 @@ func (s *Store) flushAttestationRecords(ctx context.Context, records []*Attestat // transaction to minimize write lock contention compared to doing them // all in individual, isolated boltDB transactions. func (s *Store) saveAttestationRecords(ctx context.Context, atts []*AttestationRecord) error { - ctx, span := trace.StartSpan(ctx, "Validator.saveAttestationRecords") + _, span := trace.StartSpan(ctx, "Validator.saveAttestationRecords") defer span.End() return s.update(func(tx *bolt.Tx) error { // Initialize buckets for the lowest target and source epochs. @@ -492,7 +492,7 @@ func (s *Store) saveAttestationRecords(ctx context.Context, atts []*AttestationR // AttestedPublicKeys retrieves all public keys that have attested. func (s *Store) AttestedPublicKeys(ctx context.Context) ([][48]byte, error) { - ctx, span := trace.StartSpan(ctx, "Validator.AttestedPublicKeys") + _, span := trace.StartSpan(ctx, "Validator.AttestedPublicKeys") defer span.End() var err error attestedPublicKeys := make([][48]byte, 0) @@ -511,7 +511,7 @@ func (s *Store) AttestedPublicKeys(ctx context.Context) ([][48]byte, error) { // SigningRootAtTargetEpoch checks for an existing signing root at a specified // target epoch for a given validator public key. func (s *Store) SigningRootAtTargetEpoch(ctx context.Context, pubKey [48]byte, target types.Epoch) ([32]byte, error) { - ctx, span := trace.StartSpan(ctx, "Validator.SigningRootAtTargetEpoch") + _, span := trace.StartSpan(ctx, "Validator.SigningRootAtTargetEpoch") defer span.End() var signingRoot [32]byte err := s.view(func(tx *bolt.Tx) error { @@ -534,7 +534,7 @@ func (s *Store) SigningRootAtTargetEpoch(ctx context.Context, pubKey [48]byte, t // LowestSignedSourceEpoch returns the lowest signed source epoch for a validator public key. // If no data exists, returning 0 is a sensible default. func (s *Store) LowestSignedSourceEpoch(ctx context.Context, publicKey [48]byte) (types.Epoch, bool, error) { - ctx, span := trace.StartSpan(ctx, "Validator.LowestSignedSourceEpoch") + _, span := trace.StartSpan(ctx, "Validator.LowestSignedSourceEpoch") defer span.End() var err error @@ -557,7 +557,7 @@ func (s *Store) LowestSignedSourceEpoch(ctx context.Context, publicKey [48]byte) // LowestSignedTargetEpoch returns the lowest signed target epoch for a validator public key. // If no data exists, returning 0 is a sensible default. func (s *Store) LowestSignedTargetEpoch(ctx context.Context, publicKey [48]byte) (types.Epoch, bool, error) { - ctx, span := trace.StartSpan(ctx, "Validator.LowestSignedTargetEpoch") + _, span := trace.StartSpan(ctx, "Validator.LowestSignedTargetEpoch") defer span.End() var err error diff --git a/validator/db/kv/backup.go b/validator/db/kv/backup.go index c272fbcfad1..7beed06e6f2 100644 --- a/validator/db/kv/backup.go +++ b/validator/db/kv/backup.go @@ -17,7 +17,7 @@ const backupsDirectoryName = "backups" // Backup the database to the datadir backup directory. // Example for backup: $DATADIR/backups/prysm_validatordb_1029019.backup func (s *Store) Backup(ctx context.Context, outputDir string, permissionOverride bool) error { - ctx, span := trace.StartSpan(ctx, "ValidatorDB.Backup") + _, span := trace.StartSpan(ctx, "ValidatorDB.Backup") defer span.End() var backupsDir string @@ -67,7 +67,7 @@ func (s *Store) Backup(ctx context.Context, outputDir string, permissionOverride // Walks through each buckets and looks out for nested buckets so that // the backup db also includes them. -func createNestedBuckets(srcBucket *bolt.Bucket, dstBucket *bolt.Bucket, fn func(k, v []byte) error) func(k, v []byte) error { +func createNestedBuckets(srcBucket, dstBucket *bolt.Bucket, fn func(k, v []byte) error) func(k, v []byte) error { return func(k, v []byte) error { bkt := srcBucket.Bucket(k) if bkt != nil { diff --git a/validator/db/kv/eip_blacklisted_keys.go b/validator/db/kv/eip_blacklisted_keys.go index da397858683..9f83db558b5 100644 --- a/validator/db/kv/eip_blacklisted_keys.go +++ b/validator/db/kv/eip_blacklisted_keys.go @@ -10,7 +10,7 @@ import ( // EIPImportBlacklistedPublicKeys returns keys that were marked as blacklisted during EIP-3076 slashing // protection imports, ensuring that we can prevent these keys from having duties at runtime. func (s *Store) EIPImportBlacklistedPublicKeys(ctx context.Context) ([][48]byte, error) { - ctx, span := trace.StartSpan(ctx, "Validator.EIPImportBlacklistedPublicKeys") + _, span := trace.StartSpan(ctx, "Validator.EIPImportBlacklistedPublicKeys") defer span.End() var err error publicKeys := make([][48]byte, 0) @@ -31,7 +31,7 @@ func (s *Store) EIPImportBlacklistedPublicKeys(ctx context.Context) ([][48]byte, // SaveEIPImportBlacklistedPublicKeys stores a list of blacklisted public keys that // were determined during EIP-3076 slashing protection imports. func (s *Store) SaveEIPImportBlacklistedPublicKeys(ctx context.Context, publicKeys [][48]byte) error { - ctx, span := trace.StartSpan(ctx, "Validator.SaveEIPImportBlacklistedPublicKeys") + _, span := trace.StartSpan(ctx, "Validator.SaveEIPImportBlacklistedPublicKeys") defer span.End() return s.db.Update(func(tx *bolt.Tx) error { bkt := tx.Bucket(slashablePublicKeysBucket) diff --git a/validator/db/kv/proposer_protection.go b/validator/db/kv/proposer_protection.go index c694e7b472e..ee517d95ee9 100644 --- a/validator/db/kv/proposer_protection.go +++ b/validator/db/kv/proposer_protection.go @@ -26,7 +26,7 @@ type Proposal struct { // ProposedPublicKeys retrieves all public keys in our proposals history bucket. func (s *Store) ProposedPublicKeys(ctx context.Context) ([][48]byte, error) { - ctx, span := trace.StartSpan(ctx, "Validator.ProposedPublicKeys") + _, span := trace.StartSpan(ctx, "Validator.ProposedPublicKeys") defer span.End() var err error proposedPublicKeys := make([][48]byte, 0) @@ -46,7 +46,7 @@ func (s *Store) ProposedPublicKeys(ctx context.Context) ([][48]byte, error) { // as a boolean that tells us if we have a proposal history stored at the slot. It is possible we have proposed // a slot but stored a nil signing root, so the boolean helps give full information. func (s *Store) ProposalHistoryForSlot(ctx context.Context, publicKey [48]byte, slot types.Slot) ([32]byte, bool, error) { - ctx, span := trace.StartSpan(ctx, "Validator.ProposalHistoryForSlot") + _, span := trace.StartSpan(ctx, "Validator.ProposalHistoryForSlot") defer span.End() var err error @@ -99,7 +99,7 @@ func (s *Store) ProposalHistoryForPubKey(ctx context.Context, publicKey [48]byte // We also check if the incoming proposal slot is lower than the lowest signed proposal slot // for the validator and override its value on disk. func (s *Store) SaveProposalHistoryForSlot(ctx context.Context, pubKey [48]byte, slot types.Slot, signingRoot []byte) error { - ctx, span := trace.StartSpan(ctx, "Validator.SaveProposalHistoryForEpoch") + _, span := trace.StartSpan(ctx, "Validator.SaveProposalHistoryForEpoch") defer span.End() err := s.update(func(tx *bolt.Tx) error { @@ -146,7 +146,7 @@ func (s *Store) SaveProposalHistoryForSlot(ctx context.Context, pubKey [48]byte, // LowestSignedProposal returns the lowest signed proposal slot for a validator public key. // If no data exists, a boolean of value false is returned. func (s *Store) LowestSignedProposal(ctx context.Context, publicKey [48]byte) (types.Slot, bool, error) { - ctx, span := trace.StartSpan(ctx, "Validator.LowestSignedProposal") + _, span := trace.StartSpan(ctx, "Validator.LowestSignedProposal") defer span.End() var err error @@ -169,7 +169,7 @@ func (s *Store) LowestSignedProposal(ctx context.Context, publicKey [48]byte) (t // HighestSignedProposal returns the highest signed proposal slot for a validator public key. // If no data exists, a boolean of value false is returned. func (s *Store) HighestSignedProposal(ctx context.Context, publicKey [48]byte) (types.Slot, bool, error) { - ctx, span := trace.StartSpan(ctx, "Validator.HighestSignedProposal") + _, span := trace.StartSpan(ctx, "Validator.HighestSignedProposal") defer span.End() var err error diff --git a/validator/db/kv/prune_attester_protection.go b/validator/db/kv/prune_attester_protection.go index 1d83b8c8f60..1c9eee5216a 100644 --- a/validator/db/kv/prune_attester_protection.go +++ b/validator/db/kv/prune_attester_protection.go @@ -15,7 +15,7 @@ import ( // target epoch minus some constant of how many epochs we keep track of for slashing // protection. This routine is meant to run on startup. func (s *Store) PruneAttestations(ctx context.Context) error { - ctx, span := trace.StartSpan(ctx, "Validator.PruneAttestations") + _, span := trace.StartSpan(ctx, "Validator.PruneAttestations") defer span.End() var pubkeys [][]byte err := s.view(func(tx *bolt.Tx) error { diff --git a/validator/keymanager/derived/mnemonic.go b/validator/keymanager/derived/mnemonic.go index 7e01e29758c..afab26ea6e3 100644 --- a/validator/keymanager/derived/mnemonic.go +++ b/validator/keymanager/derived/mnemonic.go @@ -42,7 +42,7 @@ func GenerateAndConfirmMnemonic( // Generate a mnemonic seed phrase in english using a source of // entropy given as raw bytes. -func (m *EnglishMnemonicGenerator) Generate(data []byte) (string, error) { +func (_ *EnglishMnemonicGenerator) Generate(data []byte) (string, error) { return bip39.NewMnemonic(data) } diff --git a/validator/keymanager/imported/backup.go b/validator/keymanager/imported/backup.go index 06274ef6ada..b27d3bc08c9 100644 --- a/validator/keymanager/imported/backup.go +++ b/validator/keymanager/imported/backup.go @@ -15,7 +15,7 @@ import ( // ExtractKeystores retrieves the secret keys for specified public keys // in the function input, encrypts them using the specified password, // and returns their respective EIP-2335 keystores. -func (km *Keymanager) ExtractKeystores( +func (_ *Keymanager) ExtractKeystores( _ context.Context, publicKeys []bls.PublicKey, password string, ) ([]*keymanager.Keystore, error) { lock.Lock() diff --git a/validator/keymanager/imported/import.go b/validator/keymanager/imported/import.go index eb6f659de56..6715fe93038 100644 --- a/validator/keymanager/imported/import.go +++ b/validator/keymanager/imported/import.go @@ -101,7 +101,7 @@ func (km *Keymanager) ImportKeypairs(ctx context.Context, privKeys, pubKeys [][] // Retrieves the private key and public key from an EIP-2335 keystore file // by decrypting using a specified password. If the password fails, // it prompts the user for the correct password until it confirms. -func (km *Keymanager) attemptDecryptKeystore( +func (_ *Keymanager) attemptDecryptKeystore( enc *keystorev4.Encryptor, keystore *keymanager.Keystore, password string, ) ([]byte, []byte, string, error) { // Attempt to decrypt the keystore with the specifies password. diff --git a/validator/keymanager/imported/keymanager.go b/validator/keymanager/imported/keymanager.go index 57fa4ff7ece..d9939098625 100644 --- a/validator/keymanager/imported/keymanager.go +++ b/validator/keymanager/imported/keymanager.go @@ -126,7 +126,7 @@ func (km *Keymanager) SubscribeAccountChanges(pubKeysChan chan [][48]byte) event } // ValidatingAccountNames for a imported keymanager. -func (km *Keymanager) ValidatingAccountNames() ([]string, error) { +func (_ *Keymanager) ValidatingAccountNames() ([]string, error) { lock.RLock() names := make([]string, len(orderedPublicKeys)) for i, pubKey := range orderedPublicKeys { @@ -157,8 +157,8 @@ func (km *Keymanager) initializeKeysCachesFromKeystore() error { } // FetchValidatingPublicKeys fetches the list of active public keys from the imported account keystores. -func (km *Keymanager) FetchValidatingPublicKeys(ctx context.Context) ([][48]byte, error) { - ctx, span := trace.StartSpan(ctx, "keymanager.FetchValidatingPublicKeys") +func (_ *Keymanager) FetchValidatingPublicKeys(ctx context.Context) ([][48]byte, error) { + _, span := trace.StartSpan(ctx, "keymanager.FetchValidatingPublicKeys") defer span.End() lock.RLock() @@ -189,8 +189,8 @@ func (km *Keymanager) FetchValidatingPrivateKeys(ctx context.Context) ([][32]byt } // Sign signs a message using a validator key. -func (km *Keymanager) Sign(ctx context.Context, req *validatorpb.SignRequest) (bls.Signature, error) { - ctx, span := trace.StartSpan(ctx, "keymanager.Sign") +func (_ *Keymanager) Sign(ctx context.Context, req *validatorpb.SignRequest) (bls.Signature, error) { + _, span := trace.StartSpan(ctx, "keymanager.Sign") defer span.End() publicKey := req.PublicKey diff --git a/validator/rpc/beacon.go b/validator/rpc/beacon.go index e373880335c..8042a2cfd1d 100644 --- a/validator/rpc/beacon.go +++ b/validator/rpc/beacon.go @@ -12,7 +12,6 @@ import ( "github.com/pkg/errors" grpcutil "github.com/prysmaticlabs/prysm/api/grpc" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client" "github.com/prysmaticlabs/prysm/validator/client" "google.golang.org/grpc" @@ -48,7 +47,7 @@ func (s *Server) registerBeaconClient() error { } s.beaconChainClient = ethpb.NewBeaconChainClient(conn) s.beaconNodeClient = ethpb.NewNodeClient(conn) - s.beaconNodeHealthClient = pb.NewHealthClient(conn) + s.beaconNodeHealthClient = ethpb.NewHealthClient(conn) s.beaconNodeValidatorClient = ethpb.NewBeaconNodeValidatorClient(conn) return nil } diff --git a/validator/rpc/health.go b/validator/rpc/health.go index aa0bf8d34a3..31511664bf0 100644 --- a/validator/rpc/health.go +++ b/validator/rpc/health.go @@ -39,7 +39,7 @@ func (s *Server) GetBeaconNodeConnection(ctx context.Context, _ *emptypb.Empty) } // GetLogsEndpoints for the beacon and validator client. -func (s *Server) GetLogsEndpoints(_ context.Context, _ *emptypb.Empty) (*validatorpb.LogsEndpointResponse, error) { +func (_ *Server) GetLogsEndpoints(_ context.Context, _ *emptypb.Empty) (*validatorpb.LogsEndpointResponse, error) { return nil, status.Error(codes.Unimplemented, "unimplemented") } diff --git a/validator/rpc/health_test.go b/validator/rpc/health_test.go index dcf61022d1c..a6f902ef203 100644 --- a/validator/rpc/health_test.go +++ b/validator/rpc/health_test.go @@ -23,7 +23,7 @@ func (m *mockSyncChecker) Syncing(_ context.Context) (bool, error) { type mockGenesisFetcher struct{} -func (m *mockGenesisFetcher) GenesisInfo(_ context.Context) (*ethpb.Genesis, error) { +func (_ *mockGenesisFetcher) GenesisInfo(_ context.Context) (*ethpb.Genesis, error) { genesis := timestamppb.New(time.Unix(0, 0)) return ðpb.Genesis{ GenesisTime: genesis, diff --git a/validator/rpc/server.go b/validator/rpc/server.go index 9dfff48b80b..2d14a4e9f09 100644 --- a/validator/rpc/server.go +++ b/validator/rpc/server.go @@ -16,7 +16,6 @@ import ( "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpbservice "github.com/prysmaticlabs/prysm/proto/eth/service" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client" "github.com/prysmaticlabs/prysm/validator/accounts/wallet" "github.com/prysmaticlabs/prysm/validator/client" @@ -63,7 +62,7 @@ type Server struct { beaconChainClient ethpb.BeaconChainClient beaconNodeClient ethpb.NodeClient beaconNodeValidatorClient ethpb.BeaconNodeValidatorClient - beaconNodeHealthClient pb.HealthClient + beaconNodeHealthClient ethpb.HealthClient valDB db.Database ctx context.Context cancel context.CancelFunc diff --git a/validator/rpc/wallet.go b/validator/rpc/wallet.go index b978b242ab5..8c119d11e23 100644 --- a/validator/rpc/wallet.go +++ b/validator/rpc/wallet.go @@ -215,7 +215,7 @@ func (s *Server) RecoverWallet(ctx context.Context, req *pb.RecoverWalletRequest // can indeed be decrypted using a password in the request. If there is no issue, // we return an empty response with no error. If the password is incorrect for a single keystore, // we return an appropriate error. -func (s *Server) ValidateKeystores( +func (_ *Server) ValidateKeystores( _ context.Context, req *pb.ValidateKeystoresRequest, ) (*emptypb.Empty, error) { if req.KeystoresPassword == "" { diff --git a/validator/testing/mock_protector.go b/validator/testing/mock_protector.go index a491a846119..ff55463a7b7 100644 --- a/validator/testing/mock_protector.go +++ b/validator/testing/mock_protector.go @@ -17,18 +17,18 @@ type MockProtector struct { // CheckAttestationSafety returns bool with allow attestation value. func (mp MockProtector) CheckAttestationSafety(_ context.Context, _ *eth.IndexedAttestation) bool { - mp.VerifyAttestationCalled = true + mp.VerifyAttestationCalled = true // skipcq: RVV-B0006 return mp.AllowAttestation } // CheckBlockSafety returns bool with allow block value. func (mp MockProtector) CheckBlockSafety(_ context.Context, _ *eth.SignedBeaconBlockHeader) bool { - mp.VerifyBlockCalled = true + mp.VerifyBlockCalled = true // skipcq: RVV-B0006 return mp.AllowBlock } // Status returns nil. func (mp MockProtector) Status() error { - mp.StatusCalled = true + mp.StatusCalled = true // skipcq: RVV-B0006 return nil } diff --git a/validator/testing/mock_slasher.go b/validator/testing/mock_slasher.go index f421afe6cc0..94f19a51a81 100644 --- a/validator/testing/mock_slasher.go +++ b/validator/testing/mock_slasher.go @@ -26,7 +26,7 @@ func (MockSlasher) HighestAttestations(ctx context.Context, req *eth.HighestAtte // IsSlashableAttestation returns slashbale attestation if slash attestation is set to true. func (ms MockSlasher) IsSlashableAttestation(_ context.Context, in *eth.IndexedAttestation, _ ...grpc.CallOption) (*eth.AttesterSlashingResponse, error) { - ms.IsSlashableAttestationCalled = true + ms.IsSlashableAttestationCalled = true // skipcq: RVV-B0006 if ms.SlashAttestation { slashingAtt, ok := proto.Clone(in).(*eth.IndexedAttestation) @@ -48,7 +48,7 @@ func (ms MockSlasher) IsSlashableAttestation(_ context.Context, in *eth.IndexedA // IsSlashableBlock returns proposer slashing if slash block is set to true. func (ms MockSlasher) IsSlashableBlock(_ context.Context, in *eth.SignedBeaconBlockHeader, _ ...grpc.CallOption) (*eth.ProposerSlashingResponse, error) { - ms.IsSlashableBlockCalled = true + ms.IsSlashableBlockCalled = true // skipcq: RVV-B0006 if ms.SlashBlock { slashingBlk, ok := proto.Clone(in).(*eth.SignedBeaconBlockHeader) if !ok {