Fix error formatting inside fmt.Errorf (#8439)

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Radosław Kapka
2021-02-13 00:44:46 +01:00
committed by GitHub
parent 068f758f49
commit 0716519be9
3 changed files with 11 additions and 11 deletions

View File

@@ -261,7 +261,7 @@ func (f *blocksFetcher) handleRequest(ctx context.Context, start, count uint64)
if f.mode == modeStopOnFinalizedEpoch {
highestFinalizedSlot := uint64(targetEpoch+1) * params.BeaconConfig().SlotsPerEpoch
if start > highestFinalizedSlot {
response.err = fmt.Errorf("%v, slot: %d, highest finalized slot: %d",
response.err = fmt.Errorf("%w, slot: %d, highest finalized slot: %d",
errSlotIsTooHigh, start, highestFinalizedSlot)
return response
}

View File

@@ -262,7 +262,7 @@ func inputKeymanagerKind(cliCtx *cli.Context) (keymanager.Kind, error) {
}
selection, _, err := promptSelect.Run()
if err != nil {
return keymanager.Imported, fmt.Errorf("could not select wallet type: %v", prompt.FormatPromptError(err))
return keymanager.Imported, fmt.Errorf("could not select wallet type: %w", prompt.FormatPromptError(err))
}
return keymanager.Kind(selection), nil
}

View File

@@ -9,7 +9,7 @@ import (
"io/ioutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/eth2-types"
types "github.com/prysmaticlabs/eth2-types"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/slashutil"
@@ -152,7 +152,7 @@ func validateMetadata(ctx context.Context, validatorDB db.Database, interchangeJ
// the imported slashing protection JSON was created on a different chain.
gvr, err := RootFromHex(interchangeJSON.Metadata.GenesisValidatorsRoot)
if err != nil {
return fmt.Errorf("%#x is not a valid root: %v", interchangeJSON.Metadata.GenesisValidatorsRoot, err)
return fmt.Errorf("%#x is not a valid root: %w", interchangeJSON.Metadata.GenesisValidatorsRoot, err)
}
dbGvr, err := validatorDB.GenesisValidatorsRoot(ctx)
if err != nil {
@@ -191,7 +191,7 @@ func parseBlocksForUniquePublicKeys(data []*format.ProtectionData) (map[[48]byte
for _, validatorData := range data {
pubKey, err := PubKeyFromHex(validatorData.Pubkey)
if err != nil {
return nil, fmt.Errorf("%s is not a valid public key: %v", validatorData.Pubkey, err)
return nil, fmt.Errorf("%s is not a valid public key: %w", validatorData.Pubkey, err)
}
for _, sBlock := range validatorData.SignedBlocks {
if sBlock == nil {
@@ -223,7 +223,7 @@ func parseAttestationsForUniquePublicKeys(data []*format.ProtectionData) (map[[4
for _, validatorData := range data {
pubKey, err := PubKeyFromHex(validatorData.Pubkey)
if err != nil {
return nil, fmt.Errorf("%s is not a valid public key: %v", validatorData.Pubkey, err)
return nil, fmt.Errorf("%s is not a valid public key: %w", validatorData.Pubkey, err)
}
for _, sAtt := range validatorData.SignedAttestations {
if sAtt == nil {
@@ -316,14 +316,14 @@ func transformSignedBlocks(ctx context.Context, signedBlocks []*format.SignedBlo
for i, proposal := range signedBlocks {
slot, err := Uint64FromString(proposal.Slot)
if err != nil {
return nil, fmt.Errorf("%d is not a valid slot: %v", slot, err)
return nil, fmt.Errorf("%d is not a valid slot: %w", slot, err)
}
var signingRoot [32]byte
// Signing roots are optional in the standard JSON file.
if proposal.SigningRoot != "" {
signingRoot, err = RootFromHex(proposal.SigningRoot)
if err != nil {
return nil, fmt.Errorf("%#x is not a valid root: %v", signingRoot, err)
return nil, fmt.Errorf("%#x is not a valid root: %w", signingRoot, err)
}
}
proposals[i] = kv.Proposal{
@@ -341,18 +341,18 @@ func transformSignedAttestations(pubKey [48]byte, atts []*format.SignedAttestati
for _, attestation := range atts {
target, err := EpochFromString(attestation.TargetEpoch)
if err != nil {
return nil, fmt.Errorf("%d is not a valid epoch: %v", target, err)
return nil, fmt.Errorf("%d is not a valid epoch: %w", target, err)
}
source, err := EpochFromString(attestation.SourceEpoch)
if err != nil {
return nil, fmt.Errorf("%d is not a valid epoch: %v", source, err)
return nil, fmt.Errorf("%d is not a valid epoch: %w", source, err)
}
var signingRoot [32]byte
// Signing roots are optional in the standard JSON file.
if attestation.SigningRoot != "" {
signingRoot, err = RootFromHex(attestation.SigningRoot)
if err != nil {
return nil, fmt.Errorf("%#x is not a valid root: %v", signingRoot, err)
return nil, fmt.Errorf("%#x is not a valid root: %w", signingRoot, err)
}
}
historicalAtts = append(historicalAtts, &kv.AttestationRecord{