mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
Lint: Fix violations of non-constant format string in call (#14974)
* Fix violations of non-constant format string in call * Changelog fragment
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package doublylinkedtree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
)
|
||||
@@ -15,7 +13,7 @@ func (f *ForkChoice) applyProposerBoostScore() error {
|
||||
if s.previousProposerBoostRoot != params.BeaconConfig().ZeroHash {
|
||||
previousNode, ok := s.nodeByRoot[s.previousProposerBoostRoot]
|
||||
if !ok || previousNode == nil {
|
||||
log.WithError(errInvalidProposerBoostRoot).Errorf(fmt.Sprintf("invalid prev root %#x", s.previousProposerBoostRoot))
|
||||
log.WithError(errInvalidProposerBoostRoot).Errorf("invalid prev root %#x", s.previousProposerBoostRoot)
|
||||
} else {
|
||||
previousNode.balance -= s.previousProposerBoostScore
|
||||
}
|
||||
@@ -24,7 +22,7 @@ func (f *ForkChoice) applyProposerBoostScore() error {
|
||||
if s.proposerBoostRoot != params.BeaconConfig().ZeroHash {
|
||||
currentNode, ok := s.nodeByRoot[s.proposerBoostRoot]
|
||||
if !ok || currentNode == nil {
|
||||
log.WithError(errInvalidProposerBoostRoot).Errorf(fmt.Sprintf("invalid current root %#x", s.proposerBoostRoot))
|
||||
log.WithError(errInvalidProposerBoostRoot).Errorf("invalid current root %#x", s.proposerBoostRoot)
|
||||
} else {
|
||||
proposerScore = (s.committeeWeight * params.BeaconConfig().ProposerScoreBoost) / 100
|
||||
currentNode.balance += proposerScore
|
||||
|
||||
@@ -166,7 +166,7 @@ func configureExecutionSetting(cliCtx *cli.Context) error {
|
||||
}
|
||||
|
||||
if !cliCtx.IsSet(flags.SuggestedFeeRecipient.Name) {
|
||||
log.Warnf("In order to receive transaction fees from proposing blocks, " +
|
||||
log.Warn("In order to receive transaction fees from proposing blocks, " +
|
||||
"you must provide flag --" + flags.SuggestedFeeRecipient.Name + " with a valid ethereum address when starting your beacon node. " +
|
||||
"Please see our documentation for more information on this requirement (https://docs.prylabs.network/docs/execution-node/fee-recipient).")
|
||||
return nil
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package p2p
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
@@ -28,7 +27,7 @@ func TestVerifyConnectivity(t *testing.T) {
|
||||
{"123.123.123.123", 19000, false, "Dialing an unreachable IP: 123.123.123.123:19000"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(fmt.Sprintf(tc.name),
|
||||
t.Run(tc.name,
|
||||
func(t *testing.T) {
|
||||
verifyConnectivity(tc.address, tc.port, "tcp")
|
||||
logMessage := "IP address is not accessible"
|
||||
|
||||
@@ -126,7 +126,7 @@ func buildExpectedWithdrawalsData(withdrawals []*enginev1.Withdrawal) []*structs
|
||||
|
||||
func handleWrapError(err error, message string, code int) *httputil.DefaultJsonError {
|
||||
return &httputil.DefaultJsonError{
|
||||
Message: errors.Wrapf(err, message).Error(),
|
||||
Message: errors.Wrap(err, message).Error(),
|
||||
Code: code,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ func newTopicRequest(topics []string) (*topicRequest, error) {
|
||||
} else if topicsForOpsFeed[name] {
|
||||
req.needOpsFeed = true
|
||||
} else {
|
||||
return nil, errors.Wrapf(errInvalidTopicName, name)
|
||||
return nil, errors.Wrap(errInvalidTopicName, name)
|
||||
}
|
||||
req.topics[name] = true
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ func TestGetPeers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("Expected ID '" + expectedId + "' not found")
|
||||
t.Error("Expected ID '" + expectedId + "' not found")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -417,7 +417,7 @@ func (vs *Server) PrepareBeaconProposer(
|
||||
for _, r := range request.Recipients {
|
||||
recipient := hexutil.Encode(r.FeeRecipient)
|
||||
if !common.IsHexAddress(recipient) {
|
||||
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("Invalid fee recipient address: %v", recipient))
|
||||
return nil, status.Errorf(codes.InvalidArgument, "Invalid fee recipient address: %v", recipient)
|
||||
}
|
||||
// Use default address if the burn address is return
|
||||
feeRecipient := primitives.ExecutionAddress(r.FeeRecipient)
|
||||
@@ -470,7 +470,7 @@ func (vs *Server) GetFeeRecipientByPubKey(ctx context.Context, request *ethpb.Fe
|
||||
}, nil
|
||||
} else {
|
||||
log.WithError(err).Error("An error occurred while retrieving fee recipient from db")
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "error=%s", err)
|
||||
}
|
||||
}
|
||||
return ðpb.FeeRecipientByPubKeyResponse{
|
||||
|
||||
@@ -269,7 +269,7 @@ func (vs *Server) optimisticStatus(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
return status.Errorf(codes.Unavailable, errOptimisticMode.Error())
|
||||
return status.Errorf(codes.Unavailable, "error=%v", errOptimisticMode)
|
||||
}
|
||||
|
||||
// validatorStatus searches for the requested validator's state and deposit to retrieve its inclusion estimate. Also returns the validators index.
|
||||
|
||||
@@ -36,7 +36,7 @@ func (vs *Server) GetSyncMessageBlockRoot(
|
||||
// It also saves the sync committee message into the pending pool for block inclusion.
|
||||
func (vs *Server) SubmitSyncMessage(ctx context.Context, msg *ethpb.SyncCommitteeMessage) (*emptypb.Empty, error) {
|
||||
if err := vs.CoreService.SubmitSyncMessage(ctx, msg); err != nil {
|
||||
return &emptypb.Empty{}, status.Errorf(core.ErrorReasonToGRPC(err.Reason), err.Err.Error())
|
||||
return &emptypb.Empty{}, status.Errorf(core.ErrorReasonToGRPC(err.Reason), "error=%s", err.Err)
|
||||
}
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func (vs *Server) SubmitSignedContributionAndProof(
|
||||
) (*emptypb.Empty, error) {
|
||||
err := vs.CoreService.SubmitSignedContributionAndProof(ctx, s)
|
||||
if err != nil {
|
||||
return &emptypb.Empty{}, status.Errorf(core.ErrorReasonToGRPC(err.Reason), err.Err.Error())
|
||||
return &emptypb.Empty{}, status.Errorf(core.ErrorReasonToGRPC(err.Reason), "error=%s", err.Err)
|
||||
}
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ func readChunkedBlobSidecar(stream network.Stream, encoding encoder.NetworkEncod
|
||||
|
||||
v, found := ctxMap[bytesutil.ToBytes4(ctxb)]
|
||||
if !found {
|
||||
return b, errors.Wrapf(errBlobUnmarshal, fmt.Sprintf("unrecognized fork digest %#x", ctxb))
|
||||
return b, errors.Wrapf(errBlobUnmarshal, "unrecognized fork digest %#x", ctxb)
|
||||
}
|
||||
// Only deneb and electra are supported at this time, because we lack a fork-spanning interface/union type for blobs.
|
||||
// In electra, there's no changes to blob type.
|
||||
|
||||
3
changelog/pvl_fmt-fix.md
Normal file
3
changelog/pvl_fmt-fix.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Fixed
|
||||
|
||||
- Lint: Fix violations of non-constant format string in call
|
||||
@@ -77,7 +77,7 @@ func (s *SignatureBatch) VerifyVerbosely() (bool, error) {
|
||||
}
|
||||
}
|
||||
|
||||
return false, errors.Errorf(errmsg)
|
||||
return false, errors.New(errmsg)
|
||||
}
|
||||
|
||||
// Copy the attached signature batch and return it
|
||||
|
||||
@@ -47,10 +47,10 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
case token.EQL, token.NEQ, token.GEQ, token.LEQ, token.GTR, token.LSS:
|
||||
var xBuf, yBuf bytes.Buffer
|
||||
if err := printer.Fprint(&xBuf, pass.Fset, expr.X); err != nil {
|
||||
pass.Reportf(expr.X.Pos(), err.Error())
|
||||
pass.Reportf(expr.X.Pos(), "error=%s", err)
|
||||
}
|
||||
if err := printer.Fprint(&yBuf, pass.Fset, expr.Y); err != nil {
|
||||
pass.Reportf(expr.Y.Pos(), err.Error())
|
||||
pass.Reportf(expr.Y.Pos(), "error=%s", err)
|
||||
}
|
||||
if xBuf.String() == yBuf.String() {
|
||||
switch expr.Op {
|
||||
|
||||
@@ -4,7 +4,6 @@ package cryptorand
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"strings"
|
||||
|
||||
@@ -62,8 +61,8 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
for pkg, path := range aliases {
|
||||
for _, fn := range disallowedFns {
|
||||
if isPkgDot(stmt.Fun, pkg, fn) {
|
||||
pass.Reportf(node.Pos(), fmt.Sprintf(
|
||||
"%s: %s.%s() (from %s)", errWeakCrypto.Error(), pkg, fn, path))
|
||||
pass.Reportf(node.Pos(),
|
||||
"%s: %s.%s() (from %s)", errWeakCrypto.Error(), pkg, fn, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
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())
|
||||
pass.Reportf(node.Pos(), "error=%s", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -6,7 +6,6 @@ package properpermissions
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
|
||||
"golang.org/x/tools/go/analysis"
|
||||
@@ -75,13 +74,11 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
if isPkgDot(stmt.Fun, alias, fn) {
|
||||
pass.Reportf(
|
||||
node.Pos(),
|
||||
fmt.Sprintf(
|
||||
"%v: %s.%s() (from %s)",
|
||||
errUnsafePackage,
|
||||
alias,
|
||||
fn,
|
||||
pkg,
|
||||
),
|
||||
"%v: %s.%s() (from %s)",
|
||||
errUnsafePackage,
|
||||
alias,
|
||||
fn,
|
||||
pkg,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,30 +236,24 @@ func checkForRecLocks(node ast.Node, pass *analysis.Pass, inspect *inspector.Ins
|
||||
if lockTracker.rLockSelector.isRelated(selMap, 0) {
|
||||
pass.Reportf(
|
||||
node.Pos(),
|
||||
fmt.Sprintf(
|
||||
"%v",
|
||||
errNestedMixedLock,
|
||||
),
|
||||
"%v",
|
||||
errNestedMixedLock,
|
||||
)
|
||||
}
|
||||
if lockTracker.rLockSelector.isEqual(selMap, 0) {
|
||||
pass.Reportf(
|
||||
node.Pos(),
|
||||
fmt.Sprintf(
|
||||
"%v",
|
||||
lockmode.ErrorFound(),
|
||||
),
|
||||
"%v",
|
||||
lockmode.ErrorFound(),
|
||||
)
|
||||
} else {
|
||||
if stack := hasNestedlock(lockTracker.rLockSelector, lockTracker.goroutinePos, selMap, call, inspect, pass, make(map[string]bool),
|
||||
lockmode.UnLockName()); stack != "" {
|
||||
pass.Reportf(
|
||||
node.Pos(),
|
||||
fmt.Sprintf(
|
||||
"%v\n%v",
|
||||
lockmode.ErrorFound(),
|
||||
stack,
|
||||
),
|
||||
"%v\n%v",
|
||||
lockmode.ErrorFound(),
|
||||
stack,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ func buildResponse(
|
||||
func (c *beaconApiValidatorClient) indexToLiveness(ctx context.Context, epoch primitives.Epoch, indexes []string) (map[string]bool, error) {
|
||||
livenessResponse, err := c.liveness(ctx, epoch, indexes)
|
||||
if err != nil || livenessResponse.Data == nil {
|
||||
return nil, errors.Wrapf(err, fmt.Sprintf("failed to get liveness for epoch %d", epoch))
|
||||
return nil, errors.Wrapf(err, "failed to get liveness for epoch %d", epoch)
|
||||
}
|
||||
|
||||
indexToLiveness := make(map[string]bool, len(livenessResponse.Data))
|
||||
|
||||
Reference in New Issue
Block a user