mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 11:32:09 +00:00
Code inspect - clean ups (#8445)
This commit is contained in:
parent
e2c5ae53e7
commit
068f758f49
@ -156,15 +156,15 @@ func (vs *Server) duties(ctx context.Context, req *ethpb.DutiesRequest) (*ethpb.
|
||||
}
|
||||
idx, ok := s.ValidatorIndexByPubkey(bytesutil.ToBytes48(pubKey))
|
||||
if ok {
|
||||
status := assignmentStatus(s, idx)
|
||||
s := assignmentStatus(s, idx)
|
||||
|
||||
assignment.ValidatorIndex = idx
|
||||
assignment.Status = status
|
||||
assignment.Status = s
|
||||
assignment.ProposerSlots = proposerIndexToSlots[idx]
|
||||
|
||||
// The next epoch has no lookup for proposer indexes.
|
||||
nextAssignment.ValidatorIndex = idx
|
||||
nextAssignment.Status = status
|
||||
nextAssignment.Status = s
|
||||
|
||||
ca, ok := committeeAssignments[idx]
|
||||
if ok {
|
||||
|
@ -59,7 +59,7 @@ func CustomSHA256Hasher() func([]byte) [32]byte {
|
||||
} else {
|
||||
hasher.Reset()
|
||||
}
|
||||
var hash [32]byte
|
||||
var h [32]byte
|
||||
|
||||
return func(data []byte) [32]byte {
|
||||
// The hash interface never returns an error, for that reason
|
||||
@ -68,10 +68,10 @@ func CustomSHA256Hasher() func([]byte) [32]byte {
|
||||
|
||||
// #nosec G104
|
||||
hasher.Write(data)
|
||||
hasher.Sum(hash[:0])
|
||||
hasher.Sum(h[:0])
|
||||
hasher.Reset()
|
||||
|
||||
return hash
|
||||
return h
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,12 +197,12 @@ func (s *Service) restartBeaconConnection(ctx context.Context) error {
|
||||
log.Info("Beacon node is still down")
|
||||
continue
|
||||
}
|
||||
status, err := s.nodeClient.GetSyncStatus(ctx, &ptypes.Empty{})
|
||||
s, err := s.nodeClient.GetSyncStatus(ctx, &ptypes.Empty{})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not fetch sync status")
|
||||
continue
|
||||
}
|
||||
if status == nil || status.Syncing {
|
||||
if s == nil || s.Syncing {
|
||||
log.Info("Waiting for beacon node to be fully synced...")
|
||||
continue
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@ -37,7 +37,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.BinaryExpr)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
expr, ok := node.(*ast.BinaryExpr)
|
||||
if !ok {
|
||||
return
|
||||
|
@ -27,7 +27,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@ -42,7 +42,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
disallowedFns := []string{"NewSource", "New", "Seed", "Int63", "Uint32", "Uint64", "Int31", "Int",
|
||||
"Int63n", "Int31n", "Intn", "Float64", "Float32", "Perm", "Shuffle", "Read"}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
switch stmt := node.(type) {
|
||||
case *ast.File:
|
||||
// Reset aliases (per file).
|
||||
|
@ -63,7 +63,7 @@ func init() {
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@ -76,7 +76,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.AssignStmt)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
switch stmt := node.(type) {
|
||||
case *ast.ExprStmt:
|
||||
if call, ok := stmt.X.(*ast.CallExpr); ok {
|
||||
|
@ -23,7 +23,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@ -36,7 +36,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.AssignStmt)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
if ce, ok := node.(*ast.CallExpr); ok && isPkgDot(ce.Fun, "featureconfig", "Init") {
|
||||
reportForbiddenUsage(pass, ce.Pos())
|
||||
return
|
||||
|
@ -23,7 +23,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@ -32,7 +32,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.StructType)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
if s, ok := node.(*ast.StructType); ok {
|
||||
if err := malign(node.Pos(), pass.TypesInfo.Types[s].Type.(*types.Struct)); err != nil {
|
||||
pass.Reportf(node.Pos(), err.Error())
|
||||
|
@ -26,7 +26,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@ -36,7 +36,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.UnaryExpr)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
switch expr := node.(type) {
|
||||
case *ast.StarExpr:
|
||||
unaryExpr, ok := expr.X.(*ast.UnaryExpr)
|
||||
|
@ -33,7 +33,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@ -46,7 +46,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
|
||||
aliases := make(map[string]string)
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
switch stmt := node.(type) {
|
||||
case *ast.File:
|
||||
// Reset aliases (per file).
|
||||
|
@ -32,7 +32,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@ -45,7 +45,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.ValueSpec)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
switch declaration := node.(type) {
|
||||
case *ast.FuncDecl:
|
||||
if declaration.Recv != nil {
|
||||
|
@ -24,7 +24,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@ -35,7 +35,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
|
||||
typeInfo := types.Info{Types: make(map[ast.Expr]types.TypeAndValue)}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
sliceExpr, ok := node.(*ast.SliceExpr)
|
||||
if !ok {
|
||||
return
|
||||
|
@ -142,14 +142,14 @@ func selectAccounts(selectionPrompt string, pubKeys [][48]byte) (filteredPubKeys
|
||||
results := make([]int, 0)
|
||||
au := aurora.NewAurora(true)
|
||||
for result != exit {
|
||||
prompt := promptui.Select{
|
||||
p := promptui.Select{
|
||||
Label: selectionPrompt,
|
||||
HideSelected: true,
|
||||
Items: append([]string{exit, allAccountsText}, pubKeyStrings...),
|
||||
Templates: templates,
|
||||
}
|
||||
|
||||
_, result, err = prompt.Run()
|
||||
_, result, err = p.Run()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ func DeleteAccountCli(cliCtx *cli.Context) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not open wallet")
|
||||
}
|
||||
keymanager, err := w.InitializeKeymanager(cliCtx.Context)
|
||||
kManager, err := w.InitializeKeymanager(cliCtx.Context)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, ErrCouldNotInitializeKeymanager)
|
||||
}
|
||||
validatingPublicKeys, err := keymanager.FetchAllValidatingPublicKeys(cliCtx.Context)
|
||||
validatingPublicKeys, err := kManager.FetchAllValidatingPublicKeys(cliCtx.Context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -87,7 +87,7 @@ func DeleteAccountCli(cliCtx *cli.Context) error {
|
||||
}
|
||||
if err := DeleteAccount(cliCtx.Context, &Config{
|
||||
Wallet: w,
|
||||
Keymanager: keymanager,
|
||||
Keymanager: kManager,
|
||||
DeletePublicKeys: rawPublicKeys,
|
||||
}); err != nil {
|
||||
return err
|
||||
|
@ -36,7 +36,7 @@ const exitPassphrase = "Exit my validator"
|
||||
|
||||
// ExitAccountsCli performs a voluntary exit on one or more accounts.
|
||||
func ExitAccountsCli(cliCtx *cli.Context, r io.Reader) error {
|
||||
validatingPublicKeys, keymanager, err := prepareWallet(cliCtx)
|
||||
validatingPublicKeys, kManager, err := prepareWallet(cliCtx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -58,7 +58,7 @@ func ExitAccountsCli(cliCtx *cli.Context, r io.Reader) error {
|
||||
cfg := performExitCfg{
|
||||
*validatorClient,
|
||||
*nodeClient,
|
||||
keymanager,
|
||||
kManager,
|
||||
rawPubKeys,
|
||||
trimmedPubKeys,
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ func (v *validator) SubmitAggregateAndProof(ctx context.Context, slot uint64, pu
|
||||
SlotSignature: slotSig,
|
||||
})
|
||||
if err != nil {
|
||||
status, ok := status.FromError(err)
|
||||
if ok && status.Code() == codes.NotFound {
|
||||
s, ok := status.FromError(err)
|
||||
if ok && s.Code() == codes.NotFound {
|
||||
log.WithField("slot", slot).WithError(err).Warn("No attestations to aggregate")
|
||||
} else {
|
||||
log.WithField("slot", slot).WithError(err).Error("Could not submit slot signature to beacon node")
|
||||
|
@ -39,7 +39,7 @@ func (v *validator) ProposeBlock(ctx context.Context, slot uint64, pubKey [48]by
|
||||
log.Debug("Assigned to genesis slot, skipping proposal")
|
||||
return
|
||||
}
|
||||
lock := mputil.NewMultilock(string(roleProposer), string(pubKey[:]))
|
||||
lock := mputil.NewMultilock(string(rune(roleProposer)), string(pubKey[:]))
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
ctx, span := trace.StartSpan(ctx, "validator.ProposeBlock")
|
||||
|
Loading…
Reference in New Issue
Block a user