Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comments #8802

Merged
merged 2 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion beacon-chain/core/epoch/epoch_processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/core/helpers/weak_subjectivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/db/kafka/passthrough.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
26 changes: 26 additions & 0 deletions beacon-chain/operations/attestations/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
7 changes: 6 additions & 1 deletion beacon-chain/rpc/beacon/attestations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 6 additions & 1 deletion beacon-chain/rpc/beacon/validators_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/rpc/beaconv1/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/rpc/debugv1/server.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/rpc/testutil/mock_state_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion beacon-chain/state/stateutil/eth1_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/state/stateutil/pending_attestation_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/state/stateutil/validator_map_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
3 changes: 3 additions & 0 deletions beacon-chain/sync/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/beacon-chain/flags/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion endtoend/components/boot_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion endtoend/components/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions endtoend/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions fuzz/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion proto/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions shared/backuputil/http_backup_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions shared/event/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,15 @@ type feedSub struct {
err chan error
}

// Unsubscribe remove feed subscription.
func (sub *feedSub) Unsubscribe() {
sub.errOnce.Do(func() {
sub.feed.remove(sub)
close(sub.err)
})
}

// Err returns error channel.
func (sub *feedSub) Err() <-chan error {
return sub.err
}
Expand Down
Loading