Fix comments (#8802)

* fix incorrect exported name in comments

* add comments to exported methods
This commit is contained in:
Victor Farazdagi
2021-04-23 15:06:05 +03:00
committed by GitHub
parent 648e360842
commit 386b69f473
77 changed files with 178 additions and 27 deletions

View File

@@ -28,8 +28,13 @@ type sortableIndices struct {
validators []*ethpb.Validator
}
func (s sortableIndices) Len() int { return len(s.indices) }
// Len is the number of elements in the collection.
func (s sortableIndices) Len() int { return len(s.indices) }
// Swap swaps the elements with indexes i and j.
func (s sortableIndices) Swap(i, j int) { s.indices[i], s.indices[j] = s.indices[j], s.indices[i] }
// Less reports whether the element with index i must sort before the element with index j.
func (s sortableIndices) Less(i, j int) bool {
if s.validators[s.indices[i]].ActivationEligibilityEpoch == s.validators[s.indices[j]].ActivationEligibilityEpoch {
return s.indices[i] < s.indices[j]

View File

@@ -108,7 +108,7 @@ func ComputeWeakSubjectivityPeriod(st iface.ReadOnlyBeaconState) (types.Epoch, e
//
// Reference implementation:
// https://github.com/ethereum/eth2.0-specs/blob/master/specs/phase0/weak-subjectivity.md#checking-for-stale-weak-subjectivity-checkpoint
//
// def is_within_weak_subjectivity_period(store: Store, ws_state: BeaconState, ws_checkpoint: Checkpoint) -> bool:
// # Clients may choose to validate the input state against the input Weak Subjectivity Checkpoint
// assert ws_state.latest_block_header.state_root == ws_checkpoint.root

View File

@@ -268,7 +268,7 @@ func (e Exporter) CleanUpDirtyStates(ctx context.Context, slotsPerArchivedPoint
return e.db.RunMigrations(ctx)
}
// LoadGenesisFromFile -- passthrough
// LoadGenesis -- passthrough
func (e Exporter) LoadGenesis(ctx context.Context, r io.Reader) error {
return e.db.LoadGenesis(ctx, r)
}

View File

@@ -7,107 +7,133 @@ import (
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
)
// PoolMock --
type PoolMock struct {
AggregatedAtts []*ethpb.Attestation
}
// AggregateUnaggregatedAttestations --
func (*PoolMock) AggregateUnaggregatedAttestations(_ context.Context) error {
panic("implement me")
}
// AggregateUnaggregatedAttestationsBySlotIndex --
func (*PoolMock) AggregateUnaggregatedAttestationsBySlotIndex(_ context.Context, _ types.Slot, _ types.CommitteeIndex) error {
panic("implement me")
}
// SaveAggregatedAttestation --
func (*PoolMock) SaveAggregatedAttestation(_ *ethpb.Attestation) error {
panic("implement me")
}
// SaveAggregatedAttestations --
func (m *PoolMock) SaveAggregatedAttestations(atts []*ethpb.Attestation) error {
m.AggregatedAtts = append(m.AggregatedAtts, atts...)
return nil
}
// AggregatedAttestations --
func (m *PoolMock) AggregatedAttestations() []*ethpb.Attestation {
return m.AggregatedAtts
}
// AggregatedAttestationsBySlotIndex --
func (*PoolMock) AggregatedAttestationsBySlotIndex(_ context.Context, _ types.Slot, _ types.CommitteeIndex) []*ethpb.Attestation {
panic("implement me")
}
// DeleteAggregatedAttestation --
func (*PoolMock) DeleteAggregatedAttestation(_ *ethpb.Attestation) error {
panic("implement me")
}
// HasAggregatedAttestation --
func (*PoolMock) HasAggregatedAttestation(_ *ethpb.Attestation) (bool, error) {
panic("implement me")
}
// AggregatedAttestationCount --
func (*PoolMock) AggregatedAttestationCount() int {
panic("implement me")
}
// SaveUnaggregatedAttestation --
func (*PoolMock) SaveUnaggregatedAttestation(_ *ethpb.Attestation) error {
panic("implement me")
}
// SaveUnaggregatedAttestations --
func (*PoolMock) SaveUnaggregatedAttestations(_ []*ethpb.Attestation) error {
panic("implement me")
}
// UnaggregatedAttestations --
func (*PoolMock) UnaggregatedAttestations() ([]*ethpb.Attestation, error) {
panic("implement me")
}
// UnaggregatedAttestationsBySlotIndex --
func (*PoolMock) UnaggregatedAttestationsBySlotIndex(_ context.Context, _ types.Slot, _ types.CommitteeIndex) []*ethpb.Attestation {
panic("implement me")
}
// DeleteUnaggregatedAttestation --
func (*PoolMock) DeleteUnaggregatedAttestation(_ *ethpb.Attestation) error {
panic("implement me")
}
// DeleteSeenUnaggregatedAttestations --
func (*PoolMock) DeleteSeenUnaggregatedAttestations() (int, error) {
panic("implement me")
}
// UnaggregatedAttestationCount --
func (*PoolMock) UnaggregatedAttestationCount() int {
panic("implement me")
}
// SaveBlockAttestation --
func (*PoolMock) SaveBlockAttestation(_ *ethpb.Attestation) error {
panic("implement me")
}
// SaveBlockAttestations --
func (*PoolMock) SaveBlockAttestations(_ []*ethpb.Attestation) error {
panic("implement me")
}
// BlockAttestations --
func (*PoolMock) BlockAttestations() []*ethpb.Attestation {
panic("implement me")
}
// DeleteBlockAttestation --
func (*PoolMock) DeleteBlockAttestation(_ *ethpb.Attestation) error {
panic("implement me")
}
// SaveForkchoiceAttestation --
func (*PoolMock) SaveForkchoiceAttestation(_ *ethpb.Attestation) error {
panic("implement me")
}
// SaveForkchoiceAttestations --
func (*PoolMock) SaveForkchoiceAttestations(_ []*ethpb.Attestation) error {
panic("implement me")
}
// ForkchoiceAttestations --
func (*PoolMock) ForkchoiceAttestations() []*ethpb.Attestation {
panic("implement me")
}
// DeleteForkchoiceAttestation --
func (*PoolMock) DeleteForkchoiceAttestation(_ *ethpb.Attestation) error {
panic("implement me")
}
// ForkchoiceAttestationCount --
func (*PoolMock) ForkchoiceAttestationCount() int {
panic("implement me")
}

View File

@@ -27,8 +27,13 @@ import (
// by slot as the canonical sorting attribute.
type sortableAttestations []*ethpb.Attestation
func (s sortableAttestations) Len() int { return len(s) }
// Len is the number of elements in the collection.
func (s sortableAttestations) Len() int { return len(s) }
// Swap swaps the elements with indexes i and j.
func (s sortableAttestations) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// Less reports whether the element with index i must sort before the element with index j.
func (s sortableAttestations) Less(i, j int) bool {
return s[i].Data.Slot < s[j].Data.Slot
}

View File

@@ -470,8 +470,13 @@ type indicesSorter struct {
indices []types.ValidatorIndex
}
func (s indicesSorter) Len() int { return len(s.indices) }
// Len is the number of elements in the collection.
func (s indicesSorter) Len() int { return len(s.indices) }
// Swap swaps the elements with indexes i and j.
func (s indicesSorter) Swap(i, j int) { s.indices[i], s.indices[j] = s.indices[j], s.indices[i] }
// Less reports whether the element with index i must sort before the element with index j.
func (s indicesSorter) Less(i, j int) bool {
return s.indices[i] < s.indices[j]
}

View File

@@ -21,7 +21,7 @@ func (bs *Server) ListPoolAttestations(ctx context.Context, req *ethpb.Attestati
return nil, errors.New("unimplemented")
}
// SubmitAttestation submits Attestation object to node. If attestation passes all validation
// SubmitAttestations submits Attestation object to node. If attestation passes all validation
// constraints, node MUST publish attestation on appropriate subnet.
func (bs *Server) SubmitAttestations(ctx context.Context, req *ethpb.SubmitAttestationsRequest) (*ptypes.Empty, error) {
ctx, span := trace.StartSpan(ctx, "beaconv1.SubmitAttestation")

View File

@@ -1,4 +1,4 @@
// Package beaconv1 defines a gRPC beacon service implementation,
// Package debugv1 defines a gRPC beacon service implementation,
// following the official API standards https://ethereum.github.io/eth2.0-APIs/#/.
// This package includes the beacon and config endpoints.
package debugv1

View File

@@ -11,6 +11,7 @@ type MockFetcher struct {
BeaconState iface.BeaconState
}
// State --
func (m *MockFetcher) State(context.Context, []byte) (iface.BeaconState, error) {
return m.BeaconState, nil
}

View File

@@ -62,7 +62,7 @@ func Eth1DataRootWithHasher(hasher htrutils.HashFn, eth1Data *ethpb.Eth1Data) ([
return root, nil
}
// Eth1DataEncKey returns the encoded key in bytes of input `eth1Data`s,
// Eth1DatasEncKey returns the encoded key in bytes of input `eth1Data`s,
// the returned key bytes can be used for caching purposes.
func Eth1DatasEncKey(eth1Datas []*ethpb.Eth1Data) ([32]byte, error) {
hasher := hashutil.CustomSHA256Hasher()

View File

@@ -11,7 +11,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
// PendingAttestationRoot describes a method from which the hash tree root
// PendingAttRootWithHasher describes a method from which the hash tree root
// of a pending attestation is returned.
func PendingAttRootWithHasher(hasher htrutils.HashFn, att *pb.PendingAttestation) ([32]byte, error) {
var fieldRoots [][32]byte

View File

@@ -21,7 +21,7 @@ func NewValMapHandler(vals []*ethpb.Validator) *ValidatorMapHandler {
}
}
// Copy the whole map and returns a map handler with the copied map.
// AddRef copies the whole map and returns a map handler with the copied map.
func (v *ValidatorMapHandler) AddRef() {
v.mapRef.AddRef()
}

View File

@@ -15,15 +15,18 @@ type sortedObj struct {
roots [][32]byte
}
// Less reports whether the element with index i must sort before the element with index j.
func (s sortedObj) Less(i, j int) bool {
return s.blks[i].Block.Slot < s.blks[j].Block.Slot
}
// Swap swaps the elements with indexes i and j.
func (s sortedObj) Swap(i, j int) {
s.blks[i], s.blks[j] = s.blks[j], s.blks[i]
s.roots[i], s.roots[j] = s.roots[j], s.roots[i]
}
// Len is the number of elements in the collection.
func (s sortedObj) Len() int {
return len(s.blks)
}

View File

@@ -14,6 +14,7 @@ var (
Usage: "A mainchain web3 provider string http endpoint. Can contain auth header as well in the format --http-web3provider=\"https://goerli.infura.io/v3/xxxx,Basic xxx\" for project secret (base64 encoded) and --http-web3provider=\"https://goerli.infura.io/v3/xxxx,Bearer xxx\" for jwt use",
Value: "",
}
// FallbackWeb3ProviderFlag provides a fallback endpoint to an ETH 1.0 RPC.
FallbackWeb3ProviderFlag = &cli.StringSliceFlag{
Name: "fallback-web3provider",
Usage: "A mainchain web3 provider string http endpoint. This is our fallback web3 provider, this flag may be used multiple times.",
@@ -135,6 +136,7 @@ var (
Name: "enable-debug-rpc-endpoints",
Usage: "Enables the debug rpc service, containing utility endpoints such as /eth/v1alpha1/beacon/state.",
}
// SubscribeToAllSubnets defines a flag to specify whether to subscribe to all possible attestation subnets or not.
SubscribeToAllSubnets = &cli.BoolFlag{
Name: "subscribe-all-subnets",
Usage: "Subscribe to all possible attestation subnets.",

View File

@@ -35,7 +35,7 @@ func (node *BootNode) ENR() string {
return node.enr
}
// StartBootnode starts a bootnode blocks up until ctx is cancelled.
// Start starts a bootnode blocks up until ctx is cancelled.
func (node *BootNode) Start(ctx context.Context) error {
binaryPath, found := bazel.FindBinary("tools/bootnode", "bootnode")
if !found {

View File

@@ -95,7 +95,7 @@ func NewValidatorNode(config *e2etypes.E2EConfig, validatorNum, index, offset in
}
}
// StartNewValidatorNode starts a validator client.
// Start starts a validator client.
func (v *ValidatorNode) Start(ctx context.Context) error {
binaryPath, found := bazel.FindBinary("cmd/validator", "validator")
if !found {

View File

@@ -35,6 +35,7 @@ const (
maxFileBufferSize = 1024 * 1024
)
// Graffiti is a list of sample graffiti strings.
var Graffiti = []string{"Sushi", "Ramen", "Takoyaki"}
// DeleteAndCreateFile checks if the file path given exists, if it does, it deletes it and creates a new file.
@@ -91,6 +92,7 @@ func WaitForTextInFile(file *os.File, text string) error {
}
}
// GraffitiYamlFile outputs graffiti YAML file into a testing directory.
func GraffitiYamlFile(testDir string) (string, error) {
b := []byte(`default: "Rice"
random:

View File

@@ -6,6 +6,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/featureconfig"
)
// EnvBls defines an environment variable name to check whether BLS is enabled or not.
const EnvBls = "BLS_ENABLED"
func init() {

View File

@@ -25,7 +25,7 @@ func V1Alpha1BlockToV1BlockHeader(block *ethpb_alpha.SignedBeaconBlock) (*ethpb.
}, nil
}
// V1Alpha1BlockToV1Block converts a v1alpha1 SignedBeaconBlock proto to a v1 proto.
// V1Alpha1ToV1Block converts a v1alpha1 SignedBeaconBlock proto to a v1 proto.
func V1Alpha1ToV1Block(alphaBlk *ethpb_alpha.SignedBeaconBlock) (*ethpb.SignedBeaconBlock, error) {
marshaledBlk, err := alphaBlk.Marshal()
if err != nil {

View File

@@ -8,6 +8,7 @@ import (
"github.com/sirupsen/logrus"
)
// BackupExporter defines a backup exporter methods.
type BackupExporter interface {
Backup(ctx context.Context, outputPath string) error
}

View File

@@ -196,6 +196,7 @@ type feedSub struct {
err chan error
}
// Unsubscribe remove feed subscription.
func (sub *feedSub) Unsubscribe() {
sub.errOnce.Do(func() {
sub.feed.remove(sub)
@@ -203,6 +204,7 @@ func (sub *feedSub) Unsubscribe() {
})
}
// Err returns error channel.
func (sub *feedSub) Err() <-chan error {
return sub.err
}

View File

@@ -74,6 +74,7 @@ type funcSub struct {
unsubscribed bool
}
// Unsubscribe unsubscribes from subscription.
func (s *funcSub) Unsubscribe() {
s.mu.Lock()
if s.unsubscribed {
@@ -87,6 +88,7 @@ func (s *funcSub) Unsubscribe() {
<-s.err
}
// Err exposes error channel.
func (s *funcSub) Err() <-chan error {
return s.err
}
@@ -122,6 +124,7 @@ type resubscribeSub struct {
waitTime, backoffMax time.Duration
}
// Unsubscribe unsubscribes from subscription.
func (s *resubscribeSub) Unsubscribe() {
s.unsubOnce.Do(func() {
s.unsub <- struct{}{}
@@ -129,6 +132,7 @@ func (s *resubscribeSub) Unsubscribe() {
})
}
// Err exposes error channel.
func (s *resubscribeSub) Err() <-chan error {
return s.err
}
@@ -267,6 +271,7 @@ func (sc *SubscriptionScope) Count() int {
return len(sc.subs)
}
// Unsubscribe unsubscribes from subscription.
func (s *scopeSub) Unsubscribe() {
s.s.Unsubscribe()
s.sc.mu.Lock()
@@ -274,6 +279,7 @@ func (s *scopeSub) Unsubscribe() {
delete(s.sc.subs, s)
}
// Err exposes error channel.
func (s *scopeSub) Err() <-chan error {
return s.s.Err()
}

View File

@@ -136,6 +136,7 @@ func FileExists(filename string) bool {
// Define non-fatal error to stop the recursive directory walk
var stopWalk = errors.New("stop walking")
// RecursiveFileFind searches for file in a directory and its subdirectories.
func RecursiveFileFind(filename, dir string) (bool, string, error) {
var found bool
var fpath string

View File

@@ -19,10 +19,12 @@ type AuthorizationData struct {
Value string
}
// Equals compares two endpoints for equality.
func (e Endpoint) Equals(other Endpoint) bool {
return e.Url == other.Url && e.Auth.Equals(other.Auth)
}
// Equals compares two authorization data objects for equality.
func (d AuthorizationData) Equals(other AuthorizationData) bool {
return d.Method == other.Method && d.Value == other.Value
}

View File

@@ -31,7 +31,7 @@ func ConfigurePersistentLogging(logFileName string) error {
return nil
}
// Masks the url credentials before logging for security purpose
// MaskCredentialsLogging masks the url credentials before logging for security purpose
// [scheme:][//[userinfo@]host][/]path[?query][#fragment] --> [scheme:][//[***]host][/***][#***]
// if the format is not matched nothing is done, string is returned as is.
func MaskCredentialsLogging(currUrl string) string {

View File

@@ -19,7 +19,7 @@ type Service interface {
// Stop terminates all goroutines belonging to the service,
// blocking until they are all terminated.
Stop() error
// Returns error if the service is not considered healthy.
// Status returns error if the service is not considered healthy.
Status() error
}

View File

@@ -10,6 +10,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunEffectiveBalanceUpdatesTests executes "epoch_processing/effective_balance_updates" tests.
func RunEffectiveBalanceUpdatesTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -10,6 +10,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunEth1DataResetTests executes "epoch_processing/eth1_data_reset" tests.
func RunEth1DataResetTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -10,6 +10,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunHistoricalRootsUpdateTests executes "epoch_processing/historical_roots_update" tests.
func RunHistoricalRootsUpdateTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -11,6 +11,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunJustificationAndFinalizationTests executes "epoch_processing/justification_and_finalization" tests.
func RunJustificationAndFinalizationTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -10,6 +10,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunParticipationRecordUpdatesTests executes "epoch_processing/participation_record_updates" tests.
func RunParticipationRecordUpdatesTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -10,6 +10,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunRandaoMixesResetTests executes "epoch_processing/randao_mixes_reset" tests.
func RunRandaoMixesResetTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -10,6 +10,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunRegistryUpdatesTests executes "epoch_processing/registry_updates" tests.
func RunRegistryUpdatesTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -12,6 +12,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunRewardsAndPenaltiesTests executes "epoch_processing/rewards_and_penalties" tests.
func RunRewardsAndPenaltiesTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -12,6 +12,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunSlashingsTests executes "epoch_processing/slashings" tests.
func RunSlashingsTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -10,6 +10,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunSlashingsResetTests executes "epoch_processing/slashings_reset" tests.
func RunSlashingsResetTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -12,6 +12,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunAttestationTest executes "operations/attestation" tests.
func RunAttestationTest(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "phase0", "operations/attestation/pyspec_tests")

View File

@@ -15,6 +15,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunAttesterSlashingTest executes "operations/attester_slashing" tests.
func RunAttesterSlashingTest(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "phase0", "operations/attester_slashing/pyspec_tests")

View File

@@ -19,6 +19,7 @@ import (
"gopkg.in/d4l3k/messagediff.v1"
)
// RunBlockHeaderTest executes "operations/block_header" tests.
func RunBlockHeaderTest(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "phase0", "operations/block_header/pyspec_tests")

View File

@@ -14,6 +14,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunDepositTest executes "operations/deposit" tests.
func RunDepositTest(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "phase0", "operations/deposit/pyspec_tests")

View File

@@ -15,6 +15,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunProposerSlashingTest executes "operations/proposer_slashing" tests.
func RunProposerSlashingTest(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "phase0", "operations/proposer_slashing/pyspec_tests")

View File

@@ -14,6 +14,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunVoluntaryExitTest executes "operations/voluntary_exit" tests.
func RunVoluntaryExitTest(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "phase0", "operations/voluntary_exit/pyspec_tests")

View File

@@ -17,6 +17,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// Delta contains list of rewards and penalties.
type Delta struct {
Rewards []uint64 `json:"rewards"`
Penalties []uint64 `json:"penalties"`
@@ -42,6 +43,7 @@ var deltaFiles = []string{
"inclusion_delay_deltas.ssz_snappy",
}
// RunPrecomputeRewardsAndPenaltiesTests executes "rewards/{basic, leak, random}" tests.
func RunPrecomputeRewardsAndPenaltiesTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testPaths := []string{"rewards/basic/pyspec_tests", "rewards/leak/pyspec_tests", "rewards/random/pyspec_tests"}

View File

@@ -27,6 +27,7 @@ func init() {
state.SkipSlotCache.Disable()
}
// RunBlockProcessingTest executes "sanity/blocks" tests.
func RunBlockProcessingTest(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -20,6 +20,7 @@ func init() {
state.SkipSlotCache.Disable()
}
// RunSlotProcessingTests executes "sanity/slots" tests.
func RunSlotProcessingTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -16,6 +16,7 @@ import (
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunShuffleTests executes "shuffling/core/shuffle" tests.
func RunShuffleTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))

View File

@@ -23,6 +23,7 @@ type SSZRoots struct {
SigningRoot string `json:"signing_root"`
}
// RunSSZStaticTests executes "ssz_static" tests.
func RunSSZStaticTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
@@ -89,6 +90,7 @@ func RunSSZStaticTests(t *testing.T, config string) {
}
}
// UnmarshalledSSZ unmarshalls serialized input.
func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (interface{}, error) {
var obj interface{}
switch folderName {

View File

@@ -1,35 +1,41 @@
package testdata
// Equal --
func Equal() {
x := []string{"a"}
if len(x) == len(x) { // want "Boolean expression has identical expressions on both sides. The result is always true."
}
}
// NotEqual --
func NotEqual() {
x := []string{"a"}
if len(x) != len(x) { // want "Boolean expression has identical expressions on both sides. The result is always true."
}
}
// GreaterThanOrEqual --
func GreaterThanOrEqual() {
x := []string{"a"}
if len(x) >= len(x) { // want "Boolean expression has identical expressions on both sides. The result is always true."
}
}
// LessThanOrEqual --
func LessThanOrEqual() {
x := []string{"a"}
if len(x) <= len(x) { // want "Boolean expression has identical expressions on both sides. The result is always true."
}
}
// GreaterThan --
func GreaterThan() {
x := []string{"a"}
if len(x) > len(x) { // want "Boolean expression has identical expressions on both sides. The result is always false."
}
}
// LessThan --
func LessThan() {
x := []string{"a"}
if len(x) < len(x) { // want "Boolean expression has identical expressions on both sides. The result is always false."

View File

@@ -6,6 +6,7 @@ import (
"time"
)
// UseRandNewCustomImport --
func UseRandNewCustomImport() {
source := mathRand.NewSource(time.Now().UnixNano()) // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
randGenerator := mathRand.New(source) // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
@@ -16,7 +17,8 @@ func UseRandNewCustomImport() {
randGenerator = mathRand.New(source) // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
}
func UseWithoutSeeCustomImportd() {
// UseWithoutSeeCustomImport --
func UseWithoutSeeCustomImport() {
assignedIndex := mathRand.Intn(128) // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
_ = assignedIndex
foobar.Shuffle(10, func(i, j int) { // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"

View File

@@ -6,6 +6,7 @@ import (
"time"
)
// UseRandNew --
func UseRandNew() {
source := rand.NewSource(time.Now().UnixNano()) // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
randGenerator := mathRand.New(source) // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
@@ -16,6 +17,7 @@ func UseRandNew() {
randGenerator = rand.New(source) // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
}
// UseWithoutSeed --
func UseWithoutSeed() {
assignedIndex := rand.Intn(128) // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
_ = assignedIndex

View File

@@ -41,6 +41,7 @@ func (bld *builder) walk(n ast.Node) {
}
}
// Visit --
func (bld *builder) Visit(n ast.Node) ast.Visitor {
switch n := n.(type) {
case *ast.FuncDecl:
@@ -545,6 +546,11 @@ func used(obj *ast.Object, b *block, seen map[*block]bool) bool {
type idents []*ast.Ident
func (ids idents) Len() int { return len(ids) }
// Len --
func (ids idents) Len() int { return len(ids) }
// Less --
func (ids idents) Less(i, j int) bool { return ids[i].Pos() < ids[j].Pos() }
func (ids idents) Swap(i, j int) { ids[i], ids[j] = ids[j], ids[i] }
// Swap --
func (ids idents) Swap(i, j int) { ids[i], ids[j] = ids[j], ids[i] }

View File

@@ -13,6 +13,7 @@ func headState(ctx context.Context) {
return
}
// StartSpan --
func StartSpan(ctx context.Context, name string) (context.Context, int) {
return ctx, 42
}

View File

@@ -78,13 +78,17 @@ type byAlignAndSize struct {
sizeofs []int64
}
// Len --
func (s *byAlignAndSize) Len() int { return len(s.fields) }
// Swap --
func (s *byAlignAndSize) Swap(i, j int) {
s.fields[i], s.fields[j] = s.fields[j], s.fields[i]
s.alignofs[i], s.alignofs[j] = s.alignofs[j], s.alignofs[i]
s.sizeofs[i], s.sizeofs[j] = s.sizeofs[j], s.sizeofs[i]
}
// Less --
func (s *byAlignAndSize) Less(i, j int) bool {
// Place zero sized objects before non-zero sized objects.
if s.sizeofs[i] == 0 && s.sizeofs[j] != 0 {
@@ -114,6 +118,7 @@ type gcSizes struct {
MaxAlign int64
}
// Alignof --
func (s *gcSizes) Alignof(T types.Type) int64 {
// NOTE: On amd64, complex64 is 8 byte aligned,
// even though float32 is only 4 byte aligned.
@@ -164,6 +169,7 @@ var basicSizes = [...]byte{
types.Complex128: 16,
}
// Sizeof --
func (s *gcSizes) Sizeof(T types.Type) int64 {
switch t := T.Underlying().(type) {
case *types.Basic:

View File

@@ -3,11 +3,13 @@ package testdata
type foo struct {
}
// AddressOfDereferencedValue --
func AddressOfDereferencedValue() {
x := &foo{}
_ = &*x // want "Found a no-op instruction that can be safely removed. It might be a result of writing code that does not do what was intended."
}
// DereferencedAddressOfValue --
func DereferencedAddressOfValue() {
x := foo{}
_ = *&x // want "Found a no-op instruction that can be safely removed. It might be a result of writing code that does not do what was intended."

View File

@@ -9,6 +9,7 @@ import (
"path/filepath"
)
// UseAliasedPackages --
func UseAliasedPackages() {
randPath, _ := rand.Int(rand.Reader, big.NewInt(1000000))
p := filepath.Join(tempDir(), fmt.Sprintf("/%d", randPath))

View File

@@ -17,6 +17,7 @@ func tempDir() string {
return d
}
// UseOsMkdirAllAndWriteFile --
func UseOsMkdirAllAndWriteFile() {
randPath, _ := rand.Int(rand.Reader, big.NewInt(1000000))
p := filepath.Join(tempDir(), fmt.Sprintf("/%d", randPath))

View File

@@ -8,16 +8,19 @@ type int interface { // want "Type 'int' shadows a predeclared identifier with t
}
// Struct --
func Struct() {
type error struct { // want "Type 'error' shadows a predeclared identifier with the same name. Choose another name."
int int // No diagnostic because the name is always referenced indirectly through a struct variable.
}
}
// TypeAlias --
func TypeAlias() {
type error string // want "Type 'error' shadows a predeclared identifier with the same name. Choose another name."
}
// UninitializedVarAndAssignments --
func UninitializedVarAndAssignments() {
var error int // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name."
error = 1 // No diagnostic because the original declaration already triggered one.
@@ -25,24 +28,28 @@ func UninitializedVarAndAssignments() {
}
}
// InitializedVar --
func InitializedVar() {
error := 0 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name."
if error == 0 {
}
}
// FirstInVarList --
func FirstInVarList() {
error, x := 0, 1 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name."
if error == x {
}
}
// SecondInVarList --
func SecondInVarList() {
x, error := 0, 1 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name."
if error == x {
}
}
// Const --
func Const() {
const error = 0 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name."
}
@@ -63,7 +70,7 @@ func error(len int) { // want "Function 'error' shadows a predeclared identifier
type receiver struct {
}
// Test receiver function.
// Receiver is a test receiver function.
func (s *receiver) Receiver(len int) {
}

View File

@@ -1,5 +1,6 @@
package testdata
// NoIndexProvided --
func NoIndexProvided() {
x := []byte{'f', 'o', 'o'}
y := x[:] // want "Expression is already a slice."
@@ -7,6 +8,7 @@ func NoIndexProvided() {
}
}
// StartindexprovidedNodiagnostic --
func StartindexprovidedNodiagnostic() {
x := []byte{'f', 'o', 'o'}
y := x[1:]
@@ -14,6 +16,7 @@ func StartindexprovidedNodiagnostic() {
}
}
// EndindexprovidedNodiagnostic --
func EndindexprovidedNodiagnostic() {
x := []byte{'f', 'o', 'o'}
y := x[:2]
@@ -21,6 +24,7 @@ func EndindexprovidedNodiagnostic() {
}
}
// BothindicesprovidedNodiagnostic --
func BothindicesprovidedNodiagnostic() {
x := []byte{'f', 'o', 'o'}
y := x[1:2]
@@ -28,6 +32,7 @@ func BothindicesprovidedNodiagnostic() {
}
}
// StringSlice --
func StringSlice() {
x := "foo"
y := x[:] // want "Expression is already a slice."
@@ -35,6 +40,7 @@ func StringSlice() {
}
}
// SliceFromFunction --
func SliceFromFunction() {
x := slice()[:] // want "Expression is already a slice."
if len(x) == 3 {

View File

@@ -118,6 +118,7 @@ func (d *db) UnallocatedPKs(_ context.Context, numKeys uint64) (*pb.PrivateKeys,
return pks, nil
}
// DeleteUnallocatedKey removes provided private key.
func (d *db) DeleteUnallocatedKey(_ context.Context, privateKey []byte) error {
return d.db.Update(func(tx *bolt.Tx) error {
if err := tx.Bucket(unassignedPkBucket).Delete(privateKey); err != nil {
@@ -132,7 +133,7 @@ func (d *db) DeleteUnallocatedKey(_ context.Context, privateKey []byte) error {
})
}
// PodPK returns an assigned private key to the given pod name, if one exists.
// PodPKs returns an assigned private key to the given pod name, if one exists.
func (d *db) PodPKs(_ context.Context, podName string) (*pb.PrivateKeys, error) {
pks := &pb.PrivateKeys{}
if err := d.db.View(func(tx *bolt.Tx) error {
@@ -173,7 +174,7 @@ func (d *db) AllocateNewPkToPod(
})
}
// RemovePKAssignments from pod and put the private keys into the unassigned
// RemovePKAssignment from pod and put the private keys into the unassigned
// bucket.
func (d *db) RemovePKAssignment(_ context.Context, podName string) error {
return d.db.Update(func(tx *bolt.Tx) error {
@@ -245,6 +246,7 @@ func (d *db) AllocatedPodNames(_ context.Context) ([]string, error) {
return podNames, nil
}
// Allocations builds and returns key allocations.
func (d *db) Allocations() (map[string][][]byte, error) {
m := make(map[string][][]byte)
if err := d.db.View(func(tx *bolt.Tx) error {
@@ -274,6 +276,7 @@ func (d *db) Allocations() (map[string][][]byte, error) {
return m, nil
}
// KeyMap builds and returns key map.
func (d *db) KeyMap() ([][]byte, map[[48]byte]keyMap, error) {
m := make(map[[48]byte]keyMap)
pubkeys := make([][]byte, 0)

View File

@@ -87,6 +87,7 @@ func (s *server) makeDeposit(pubkey, withdrawalCredentials, signature []byte, de
return tx, nil
}
// Request processes private keys requests.
func (s *server) Request(ctx context.Context, req *pb.PrivateKeyRequest) (*pb.PrivateKeyResponse, error) {
s.clientLock.Lock()
defer s.clientLock.Unlock()

View File

@@ -32,6 +32,7 @@ func (e *endpoint) String() string {
return "gRPC endpoints"
}
// Set adds endpoint value to list.
func (e *endpoint) Set(value string) error {
*e = append(*e, value)
return nil

View File

@@ -7,7 +7,7 @@ import (
var (
errKeymanagerNotSupported = "keymanager kind not supported: %s"
// MsgCouldNotInitializeKeymanager informs about failed keymanager initialization
// ErrCouldNotInitializeKeymanager informs about failed keymanager initialization
ErrCouldNotInitializeKeymanager = "could not initialize keymanager"
)

View File

@@ -36,7 +36,10 @@ var derivationPathRegex = regexp.MustCompile(`m_12381_3600_(\d+)_(\d+)_(\d+)`)
// in a directory and import them nicely in order of the derivation path.
type byDerivationPath []string
// Len is the number of elements in the collection.
func (fileNames byDerivationPath) Len() int { return len(fileNames) }
// Less reports whether the element with index i must sort before the element with index j.
func (fileNames byDerivationPath) Less(i, j int) bool {
// We check if file name at index i has a derivation path
// in the filename. If it does not, then it is not less than j, and
@@ -63,6 +66,7 @@ func (fileNames byDerivationPath) Less(i, j int) bool {
return a < b
}
// Swap swaps the elements with indexes i and j.
func (fileNames byDerivationPath) Swap(i, j int) {
fileNames[i], fileNames[j] = fileNames[j], fileNames[i]
}

View File

@@ -1,4 +1,4 @@
// Package v2 defines a new model for accounts management in Prysm, using best
// Package accounts defines a new model for accounts management in Prysm, using best
// practices for user security, UX, and extensibility via different wallet types
// including HD wallets, imported (non-HD) wallets, and remote-signing capable configurations. This model
// is compliant with the EIP-2333, EIP-2334, and EIP-2335 standards for key management in eth2.

View File

@@ -21,6 +21,7 @@ type attSubmitted struct {
aggregatorIndices []types.ValidatorIndex
}
// LogAttestationsSubmitted logs info about submitted attestations.
func (v *validator) LogAttestationsSubmitted() {
v.attLogsLock.Lock()
defer v.attLogsLock.Unlock()
@@ -42,6 +43,7 @@ func (v *validator) LogAttestationsSubmitted() {
v.attLogs = make(map[[32]byte]*attSubmitted)
}
// LogNextDutyTimeLeft logs the next duty info.
func (v *validator) LogNextDutyTimeLeft(slot types.Slot) error {
if !v.logDutyCountDown {
return nil

View File

@@ -14,6 +14,7 @@ import (
// grpc.WithDefaultServiceConfig("{\"loadBalancingConfig\":[{\"round_robin\":{}}]}")
type multipleEndpointsGrpcResolverBuilder struct{}
// Build creates and starts multiple endpoints resolver.
func (*multipleEndpointsGrpcResolverBuilder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) {
r := &multipleEndpointsGrpcResolver{
target: target,
@@ -23,6 +24,7 @@ func (*multipleEndpointsGrpcResolverBuilder) Build(target resolver.Target, cc re
return r, nil
}
// Scheme returns default scheme.
func (*multipleEndpointsGrpcResolverBuilder) Scheme() string {
return resolver.GetDefaultScheme()
}
@@ -41,6 +43,8 @@ func (r *multipleEndpointsGrpcResolver) start() {
r.cc.UpdateState(resolver.State{Addresses: addrs})
}
// ResolveNow --
func (*multipleEndpointsGrpcResolver) ResolveNow(_ resolver.ResolveNowOptions) {}
// Close --
func (*multipleEndpointsGrpcResolver) Close() {}

View File

@@ -172,7 +172,7 @@ func (fv *FakeValidator) SubmitAggregateAndProof(_ context.Context, _ types.Slot
// LogAttestationsSubmitted for mocking.
func (fv *FakeValidator) LogAttestationsSubmitted() {}
// LogNextDutyCountDown for mocking.
// LogNextDutyTimeLeft for mocking.
func (fv *FakeValidator) LogNextDutyTimeLeft(slot types.Slot) error {
return nil
}

View File

@@ -50,6 +50,7 @@ var blockedBuckets = [][]byte{
attestationTargetEpochsBucket,
}
// Config represents store's config object.
type Config struct {
PubKeys [][48]byte
InitialMMapSize int

View File

@@ -8,6 +8,7 @@ import (
"gopkg.in/yaml.v2"
)
// Graffiti is a graffiti container.
type Graffiti struct {
Hash [32]byte
Default string `yaml:"default,omitempty"`

View File

@@ -1,3 +1,4 @@
package keymanager
// KeysReloaded is a "key reloaded" message.
const KeysReloaded = "Reloaded validator keys into keymanager"

View File

@@ -19,6 +19,7 @@ type EnglishMnemonicGenerator struct {
skipMnemonicConfirm bool
}
// GenerateAndConfirmMnemonic requires confirming the generated mnemonics.
func GenerateAndConfirmMnemonic(
skipMnemonicConfirm bool,
) (string, error) {

View File

@@ -207,6 +207,7 @@ func (km *Keymanager) KeymanagerOpts() *KeymanagerOpts {
return km.opts
}
// ReloadPublicKeys reloads public keys.
func (km *Keymanager) ReloadPublicKeys(ctx context.Context) ([][48]byte, error) {
pubKeys, err := km.FetchValidatingPublicKeys(ctx)
if err != nil {

View File

@@ -8,22 +8,27 @@ import (
"github.com/prysmaticlabs/prysm/shared/event"
)
// MockKeymanager --
type MockKeymanager struct {
PublicKeys [][48]byte
}
// FetchValidatingPublicKeys --
func (m *MockKeymanager) FetchValidatingPublicKeys(context.Context) ([][48]byte, error) {
return m.PublicKeys, nil
}
// Sign --
func (*MockKeymanager) Sign(context.Context, *validatorpb.SignRequest) (bls.Signature, error) {
panic("implement me")
}
// SubscribeAccountChanges --
func (*MockKeymanager) SubscribeAccountChanges(chan [][48]byte) event.Subscription {
panic("implement me")
}
// ReloadPublicKeys --
func (m *MockKeymanager) ReloadPublicKeys(context.Context) ([][48]byte, error) {
return m.PublicKeys, nil
}

View File

@@ -99,7 +99,7 @@ func (s *Server) GetValidatorPerformance(
return s.beaconChainClient.GetValidatorPerformance(ctx, req)
}
// GetValidatorBalance is a wrapper around the /eth/v1alpha1 endpoint of the same name.
// GetValidatorBalances is a wrapper around the /eth/v1alpha1 endpoint of the same name.
func (s *Server) GetValidatorBalances(
ctx context.Context, req *ethpb.ListValidatorBalancesRequest,
) (*ethpb.ValidatorBalances, error) {

View File

@@ -1,4 +1,4 @@
// Package interchangeformat defines methods to parse, import, and export slashing protection data
// Package format defines methods to parse, import, and export slashing protection data
// from a standard JSON file according to EIP-3076 https://eips.ethereum.org/EIPS/eip-3076. This format
// is critical to allow safe interoperability between eth2 clients.
package format

View File

@@ -34,7 +34,7 @@ func Uint64FromString(str string) (uint64, error) {
return strconv.ParseUint(str, 10, 64)
}
// Uint64FromString converts a string into Epoch.
// EpochFromString converts a string into Epoch.
func EpochFromString(str string) (types.Epoch, error) {
e, err := strconv.ParseUint(str, 10, 64)
if err != nil {

View File

@@ -1,3 +1,4 @@
package testing
// TestMnemonic --
const TestMnemonic = "tumble turn jewel sudden social great water general cabin jacket bounce dry flip monster advance problem social half flee inform century chicken hard reason"