From a63de303b8005a9143e696d8918bb4101d605a2c Mon Sep 17 00:00:00 2001 From: Alexander Bezobchuk Date: Tue, 18 Feb 2020 14:43:00 +0100 Subject: [PATCH] Merge PR #5665: Bump Module ABCI Error Codes --- types/errors/abci.go | 7 +-- x/auth/types/errors.go | 8 ++- x/bank/internal/types/errors.go | 8 +-- x/crisis/internal/types/errors.go | 4 +- x/distribution/types/errors.go | 24 ++++---- x/evidence/internal/types/errors.go | 8 +-- x/gov/types/errors.go | 16 ++--- x/params/types/errors.go | 12 ++-- x/slashing/internal/types/errors.go | 14 ++--- x/staking/types/errors.go | 92 ++++++++++++++--------------- 10 files changed, 97 insertions(+), 96 deletions(-) diff --git a/types/errors/abci.go b/types/errors/abci.go index cc5633543..04ba8413d 100644 --- a/types/errors/abci.go +++ b/types/errors/abci.go @@ -154,10 +154,9 @@ func errIsNil(err error) bool { return false } -// Redact replace all errors that do not initialize with a weave error with a -// generic internal error instance. This function is supposed to hide -// implementation details errors and leave only those that weave framework -// originates. +// Redact replaces an error that is not initialized as an ABCI Error with a +// generic internal error instance. If the error is an ABCI Error, that error is +// simply returned. func Redact(err error) error { if ErrPanic.Is(err) { return errors.New(internalABCILog) diff --git a/x/auth/types/errors.go b/x/auth/types/errors.go index 3333cc8a4..8e765ceb9 100644 --- a/x/auth/types/errors.go +++ b/x/auth/types/errors.go @@ -1,8 +1,10 @@ package types -import "errors" +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) var ( - ErrorInvalidSigner = errors.New("tx intended signer does not match the given signer") - ErrorInvalidGasAdjustment = errors.New("invalid gas adjustment") + ErrorInvalidSigner = sdkerrors.Register(ModuleName, 2, "tx intended signer does not match the given signer") + ErrorInvalidGasAdjustment = sdkerrors.Register(ModuleName, 3, "invalid gas adjustment") ) diff --git a/x/bank/internal/types/errors.go b/x/bank/internal/types/errors.go index 157408c94..dce69d0ac 100644 --- a/x/bank/internal/types/errors.go +++ b/x/bank/internal/types/errors.go @@ -6,8 +6,8 @@ import ( // x/bank module sentinel errors var ( - ErrNoInputs = sdkerrors.Register(ModuleName, 1, "no inputs to send transaction") - ErrNoOutputs = sdkerrors.Register(ModuleName, 2, "no outputs to send transaction") - ErrInputOutputMismatch = sdkerrors.Register(ModuleName, 3, "sum inputs != sum outputs") - ErrSendDisabled = sdkerrors.Register(ModuleName, 4, "send transactions are disabled") + ErrNoInputs = sdkerrors.Register(ModuleName, 2, "no inputs to send transaction") + ErrNoOutputs = sdkerrors.Register(ModuleName, 3, "no outputs to send transaction") + ErrInputOutputMismatch = sdkerrors.Register(ModuleName, 4, "sum inputs != sum outputs") + ErrSendDisabled = sdkerrors.Register(ModuleName, 5, "send transactions are disabled") ) diff --git a/x/crisis/internal/types/errors.go b/x/crisis/internal/types/errors.go index ac63f3ff4..cf8c4901b 100644 --- a/x/crisis/internal/types/errors.go +++ b/x/crisis/internal/types/errors.go @@ -6,6 +6,6 @@ import ( // x/crisis module sentinel errors var ( - ErrNoSender = sdkerrors.Register(ModuleName, 1, "sender address is empty") - ErrUnknownInvariant = sdkerrors.Register(ModuleName, 2, "unknown invariant") + ErrNoSender = sdkerrors.Register(ModuleName, 2, "sender address is empty") + ErrUnknownInvariant = sdkerrors.Register(ModuleName, 3, "unknown invariant") ) diff --git a/x/distribution/types/errors.go b/x/distribution/types/errors.go index c06b731b6..147cfd320 100644 --- a/x/distribution/types/errors.go +++ b/x/distribution/types/errors.go @@ -6,16 +6,16 @@ import ( // x/distribution module sentinel errors var ( - ErrEmptyDelegatorAddr = sdkerrors.Register(ModuleName, 1, "delegator address is empty") - ErrEmptyWithdrawAddr = sdkerrors.Register(ModuleName, 2, "withdraw address is empty") - ErrEmptyValidatorAddr = sdkerrors.Register(ModuleName, 3, "validator address is empty") - ErrEmptyDelegationDistInfo = sdkerrors.Register(ModuleName, 4, "no delegation distribution info") - ErrNoValidatorDistInfo = sdkerrors.Register(ModuleName, 5, "no validator distribution info") - ErrNoValidatorCommission = sdkerrors.Register(ModuleName, 6, "no validator commission to withdraw") - ErrSetWithdrawAddrDisabled = sdkerrors.Register(ModuleName, 7, "set withdraw address disabled") - ErrBadDistribution = sdkerrors.Register(ModuleName, 8, "community pool does not have sufficient coins to distribute") - ErrInvalidProposalAmount = sdkerrors.Register(ModuleName, 9, "invalid community pool spend proposal amount") - ErrEmptyProposalRecipient = sdkerrors.Register(ModuleName, 10, "invalid community pool spend proposal recipient") - ErrNoValidatorExists = sdkerrors.Register(ModuleName, 11, "validator does not exist") - ErrNoDelegationExists = sdkerrors.Register(ModuleName, 12, "delegation does not exist") + ErrEmptyDelegatorAddr = sdkerrors.Register(ModuleName, 2, "delegator address is empty") + ErrEmptyWithdrawAddr = sdkerrors.Register(ModuleName, 3, "withdraw address is empty") + ErrEmptyValidatorAddr = sdkerrors.Register(ModuleName, 4, "validator address is empty") + ErrEmptyDelegationDistInfo = sdkerrors.Register(ModuleName, 5, "no delegation distribution info") + ErrNoValidatorDistInfo = sdkerrors.Register(ModuleName, 6, "no validator distribution info") + ErrNoValidatorCommission = sdkerrors.Register(ModuleName, 7, "no validator commission to withdraw") + ErrSetWithdrawAddrDisabled = sdkerrors.Register(ModuleName, 8, "set withdraw address disabled") + ErrBadDistribution = sdkerrors.Register(ModuleName, 9, "community pool does not have sufficient coins to distribute") + ErrInvalidProposalAmount = sdkerrors.Register(ModuleName, 10, "invalid community pool spend proposal amount") + ErrEmptyProposalRecipient = sdkerrors.Register(ModuleName, 11, "invalid community pool spend proposal recipient") + ErrNoValidatorExists = sdkerrors.Register(ModuleName, 12, "validator does not exist") + ErrNoDelegationExists = sdkerrors.Register(ModuleName, 13, "delegation does not exist") ) diff --git a/x/evidence/internal/types/errors.go b/x/evidence/internal/types/errors.go index 83ffe0600..f44802709 100644 --- a/x/evidence/internal/types/errors.go +++ b/x/evidence/internal/types/errors.go @@ -7,8 +7,8 @@ import ( // x/evidence module sentinel errors var ( - ErrNoEvidenceHandlerExists = sdkerrors.Register(ModuleName, 1, "unregistered handler for evidence type") - ErrInvalidEvidence = sdkerrors.Register(ModuleName, 2, "invalid evidence") - ErrNoEvidenceExists = sdkerrors.Register(ModuleName, 3, "evidence does not exist") - ErrEvidenceExists = sdkerrors.Register(ModuleName, 4, "evidence already exists") + ErrNoEvidenceHandlerExists = sdkerrors.Register(ModuleName, 2, "unregistered handler for evidence type") + ErrInvalidEvidence = sdkerrors.Register(ModuleName, 3, "invalid evidence") + ErrNoEvidenceExists = sdkerrors.Register(ModuleName, 4, "evidence does not exist") + ErrEvidenceExists = sdkerrors.Register(ModuleName, 5, "evidence already exists") ) diff --git a/x/gov/types/errors.go b/x/gov/types/errors.go index 2327a6f05..96973f175 100644 --- a/x/gov/types/errors.go +++ b/x/gov/types/errors.go @@ -6,12 +6,12 @@ import ( // x/gov module sentinel errors var ( - ErrUnknownProposal = sdkerrors.Register(ModuleName, 1, "unknown proposal") - ErrInactiveProposal = sdkerrors.Register(ModuleName, 2, "inactive proposal") - ErrAlreadyActiveProposal = sdkerrors.Register(ModuleName, 3, "proposal already active") - ErrInvalidProposalContent = sdkerrors.Register(ModuleName, 4, "invalid proposal content") - ErrInvalidProposalType = sdkerrors.Register(ModuleName, 5, "invalid proposal type") - ErrInvalidVote = sdkerrors.Register(ModuleName, 6, "invalid vote option") - ErrInvalidGenesis = sdkerrors.Register(ModuleName, 7, "invalid genesis state") - ErrNoProposalHandlerExists = sdkerrors.Register(ModuleName, 8, "no handler exists for proposal type") + ErrUnknownProposal = sdkerrors.Register(ModuleName, 2, "unknown proposal") + ErrInactiveProposal = sdkerrors.Register(ModuleName, 3, "inactive proposal") + ErrAlreadyActiveProposal = sdkerrors.Register(ModuleName, 4, "proposal already active") + ErrInvalidProposalContent = sdkerrors.Register(ModuleName, 5, "invalid proposal content") + ErrInvalidProposalType = sdkerrors.Register(ModuleName, 6, "invalid proposal type") + ErrInvalidVote = sdkerrors.Register(ModuleName, 7, "invalid vote option") + ErrInvalidGenesis = sdkerrors.Register(ModuleName, 8, "invalid genesis state") + ErrNoProposalHandlerExists = sdkerrors.Register(ModuleName, 9, "no handler exists for proposal type") ) diff --git a/x/params/types/errors.go b/x/params/types/errors.go index 4b218d944..0611a3de2 100644 --- a/x/params/types/errors.go +++ b/x/params/types/errors.go @@ -6,10 +6,10 @@ import ( // x/params module sentinel errors var ( - ErrUnknownSubspace = sdkerrors.Register(ModuleName, 1, "unknown subspace") - ErrSettingParameter = sdkerrors.Register(ModuleName, 2, "failed to set parameter") - ErrEmptyChanges = sdkerrors.Register(ModuleName, 3, "submitted parameter changes are empty") - ErrEmptySubspace = sdkerrors.Register(ModuleName, 4, "parameter subspace is empty") - ErrEmptyKey = sdkerrors.Register(ModuleName, 5, "parameter key is empty") - ErrEmptyValue = sdkerrors.Register(ModuleName, 6, "parameter value is empty") + ErrUnknownSubspace = sdkerrors.Register(ModuleName, 2, "unknown subspace") + ErrSettingParameter = sdkerrors.Register(ModuleName, 3, "failed to set parameter") + ErrEmptyChanges = sdkerrors.Register(ModuleName, 4, "submitted parameter changes are empty") + ErrEmptySubspace = sdkerrors.Register(ModuleName, 5, "parameter subspace is empty") + ErrEmptyKey = sdkerrors.Register(ModuleName, 6, "parameter key is empty") + ErrEmptyValue = sdkerrors.Register(ModuleName, 7, "parameter value is empty") ) diff --git a/x/slashing/internal/types/errors.go b/x/slashing/internal/types/errors.go index 290ed36ca..daff6ecc0 100644 --- a/x/slashing/internal/types/errors.go +++ b/x/slashing/internal/types/errors.go @@ -6,11 +6,11 @@ import ( // x/slashing module sentinel errors var ( - ErrNoValidatorForAddress = sdkerrors.Register(ModuleName, 1, "address is not associated with any known validator") - ErrBadValidatorAddr = sdkerrors.Register(ModuleName, 2, "validator does not exist for that address") - ErrValidatorJailed = sdkerrors.Register(ModuleName, 3, "validator still jailed; cannot be unjailed") - ErrValidatorNotJailed = sdkerrors.Register(ModuleName, 4, "validator not jailed; cannot be unjailed") - ErrMissingSelfDelegation = sdkerrors.Register(ModuleName, 5, "validator has no self-delegation; cannot be unjailed") - ErrSelfDelegationTooLowToUnjail = sdkerrors.Register(ModuleName, 6, "validator's self delegation less than minimum; cannot be unjailed") - ErrNoSigningInfoFound = sdkerrors.Register(ModuleName, 7, "no validator signing info found") + ErrNoValidatorForAddress = sdkerrors.Register(ModuleName, 2, "address is not associated with any known validator") + ErrBadValidatorAddr = sdkerrors.Register(ModuleName, 3, "validator does not exist for that address") + ErrValidatorJailed = sdkerrors.Register(ModuleName, 4, "validator still jailed; cannot be unjailed") + ErrValidatorNotJailed = sdkerrors.Register(ModuleName, 5, "validator not jailed; cannot be unjailed") + ErrMissingSelfDelegation = sdkerrors.Register(ModuleName, 6, "validator has no self-delegation; cannot be unjailed") + ErrSelfDelegationTooLowToUnjail = sdkerrors.Register(ModuleName, 7, "validator's self delegation less than minimum; cannot be unjailed") + ErrNoSigningInfoFound = sdkerrors.Register(ModuleName, 8, "no validator signing info found") ) diff --git a/x/staking/types/errors.go b/x/staking/types/errors.go index 62fdd0725..d6c31a15d 100644 --- a/x/staking/types/errors.go +++ b/x/staking/types/errors.go @@ -11,50 +11,50 @@ import ( // // REF: https://github.com/cosmos/cosmos-sdk/issues/5450 var ( - ErrEmptyValidatorAddr = sdkerrors.Register(ModuleName, 1, "empty validator address") - ErrBadValidatorAddr = sdkerrors.Register(ModuleName, 2, "validator address is invalid") - ErrNoValidatorFound = sdkerrors.Register(ModuleName, 3, "validator does not exist") - ErrValidatorOwnerExists = sdkerrors.Register(ModuleName, 4, "validator already exist for this operator address; must use new validator operator address") - ErrValidatorPubKeyExists = sdkerrors.Register(ModuleName, 5, "validator already exist for this pubkey; must use new validator pubkey") - ErrValidatorPubKeyTypeNotSupported = sdkerrors.Register(ModuleName, 6, "validator pubkey type is not supported") - ErrValidatorJailed = sdkerrors.Register(ModuleName, 7, "validator for this address is currently jailed") - ErrBadRemoveValidator = sdkerrors.Register(ModuleName, 8, "failed to remove validator") - ErrCommissionNegative = sdkerrors.Register(ModuleName, 9, "commission must be positive") - ErrCommissionHuge = sdkerrors.Register(ModuleName, 10, "commission cannot be more than 100%") - ErrCommissionGTMaxRate = sdkerrors.Register(ModuleName, 11, "commission cannot be more than the max rate") - ErrCommissionUpdateTime = sdkerrors.Register(ModuleName, 12, "commission cannot be changed more than once in 24h") - ErrCommissionChangeRateNegative = sdkerrors.Register(ModuleName, 13, "commission change rate must be positive") - ErrCommissionChangeRateGTMaxRate = sdkerrors.Register(ModuleName, 14, "commission change rate cannot be more than the max rate") - ErrCommissionGTMaxChangeRate = sdkerrors.Register(ModuleName, 15, "commission cannot be changed more than max change rate") - ErrSelfDelegationBelowMinimum = sdkerrors.Register(ModuleName, 16, "validator's self delegation must be greater than their minimum self delegation") - ErrMinSelfDelegationInvalid = sdkerrors.Register(ModuleName, 17, "minimum self delegation must be a positive integer") - ErrMinSelfDelegationDecreased = sdkerrors.Register(ModuleName, 18, "minimum self delegation cannot be decrease") - ErrEmptyDelegatorAddr = sdkerrors.Register(ModuleName, 19, "empty delegator address") - ErrBadDenom = sdkerrors.Register(ModuleName, 20, "invalid coin denomination") - ErrBadDelegationAddr = sdkerrors.Register(ModuleName, 21, "invalid address for (address, validator) tuple") - ErrBadDelegationAmount = sdkerrors.Register(ModuleName, 22, "invalid delegation amount") - ErrNoDelegation = sdkerrors.Register(ModuleName, 23, "no delegation for (address, validator) tuple") - ErrBadDelegatorAddr = sdkerrors.Register(ModuleName, 24, "delegator does not exist with address") - ErrNoDelegatorForAddress = sdkerrors.Register(ModuleName, 25, "delegator does not contain delegation") - ErrInsufficientShares = sdkerrors.Register(ModuleName, 26, "insufficient delegation shares") - ErrDelegationValidatorEmpty = sdkerrors.Register(ModuleName, 27, "cannot delegate to an empty validator") - ErrNotEnoughDelegationShares = sdkerrors.Register(ModuleName, 28, "not enough delegation shares") - ErrBadSharesAmount = sdkerrors.Register(ModuleName, 29, "invalid shares amount") - ErrBadSharesPercent = sdkerrors.Register(ModuleName, 30, "Invalid shares percent") - ErrNotMature = sdkerrors.Register(ModuleName, 31, "entry not mature") - ErrNoUnbondingDelegation = sdkerrors.Register(ModuleName, 32, "no unbonding delegation found") - ErrMaxUnbondingDelegationEntries = sdkerrors.Register(ModuleName, 33, "too many unbonding delegation entries for (delegator, validator) tuple") - ErrBadRedelegationAddr = sdkerrors.Register(ModuleName, 34, "invalid address for (address, src-validator, dst-validator) tuple") - ErrNoRedelegation = sdkerrors.Register(ModuleName, 35, "no redelegation found") - ErrSelfRedelegation = sdkerrors.Register(ModuleName, 36, "cannot redelegate to the same validator") - ErrTinyRedelegationAmount = sdkerrors.Register(ModuleName, 37, "too few tokens to redelegate (truncates to zero tokens)") - ErrBadRedelegationDst = sdkerrors.Register(ModuleName, 38, "redelegation destination validator not found") - ErrTransitiveRedelegation = sdkerrors.Register(ModuleName, 39, "redelegation to this validator already in progress; first redelegation to this validator must complete before next redelegation") - ErrMaxRedelegationEntries = sdkerrors.Register(ModuleName, 40, "too many redelegation entries for (delegator, src-validator, dst-validator) tuple") - ErrDelegatorShareExRateInvalid = sdkerrors.Register(ModuleName, 41, "cannot delegate to validators with invalid (zero) ex-rate") - ErrBothShareMsgsGiven = sdkerrors.Register(ModuleName, 42, "both shares amount and shares percent provided") - ErrNeitherShareMsgsGiven = sdkerrors.Register(ModuleName, 43, "neither shares amount nor shares percent provided") - ErrInvalidHistoricalInfo = sdkerrors.Register(ModuleName, 44, "invalid historical info") - ErrNoHistoricalInfo = sdkerrors.Register(ModuleName, 45, "no historical info found") - ErrEmptyValidatorPubKey = sdkerrors.Register(ModuleName, 46, "empty validator public key") + ErrEmptyValidatorAddr = sdkerrors.Register(ModuleName, 2, "empty validator address") + ErrBadValidatorAddr = sdkerrors.Register(ModuleName, 3, "validator address is invalid") + ErrNoValidatorFound = sdkerrors.Register(ModuleName, 4, "validator does not exist") + ErrValidatorOwnerExists = sdkerrors.Register(ModuleName, 5, "validator already exist for this operator address; must use new validator operator address") + ErrValidatorPubKeyExists = sdkerrors.Register(ModuleName, 6, "validator already exist for this pubkey; must use new validator pubkey") + ErrValidatorPubKeyTypeNotSupported = sdkerrors.Register(ModuleName, 7, "validator pubkey type is not supported") + ErrValidatorJailed = sdkerrors.Register(ModuleName, 8, "validator for this address is currently jailed") + ErrBadRemoveValidator = sdkerrors.Register(ModuleName, 9, "failed to remove validator") + ErrCommissionNegative = sdkerrors.Register(ModuleName, 10, "commission must be positive") + ErrCommissionHuge = sdkerrors.Register(ModuleName, 11, "commission cannot be more than 100%") + ErrCommissionGTMaxRate = sdkerrors.Register(ModuleName, 12, "commission cannot be more than the max rate") + ErrCommissionUpdateTime = sdkerrors.Register(ModuleName, 13, "commission cannot be changed more than once in 24h") + ErrCommissionChangeRateNegative = sdkerrors.Register(ModuleName, 14, "commission change rate must be positive") + ErrCommissionChangeRateGTMaxRate = sdkerrors.Register(ModuleName, 15, "commission change rate cannot be more than the max rate") + ErrCommissionGTMaxChangeRate = sdkerrors.Register(ModuleName, 16, "commission cannot be changed more than max change rate") + ErrSelfDelegationBelowMinimum = sdkerrors.Register(ModuleName, 17, "validator's self delegation must be greater than their minimum self delegation") + ErrMinSelfDelegationInvalid = sdkerrors.Register(ModuleName, 18, "minimum self delegation must be a positive integer") + ErrMinSelfDelegationDecreased = sdkerrors.Register(ModuleName, 19, "minimum self delegation cannot be decrease") + ErrEmptyDelegatorAddr = sdkerrors.Register(ModuleName, 20, "empty delegator address") + ErrBadDenom = sdkerrors.Register(ModuleName, 21, "invalid coin denomination") + ErrBadDelegationAddr = sdkerrors.Register(ModuleName, 22, "invalid address for (address, validator) tuple") + ErrBadDelegationAmount = sdkerrors.Register(ModuleName, 23, "invalid delegation amount") + ErrNoDelegation = sdkerrors.Register(ModuleName, 24, "no delegation for (address, validator) tuple") + ErrBadDelegatorAddr = sdkerrors.Register(ModuleName, 25, "delegator does not exist with address") + ErrNoDelegatorForAddress = sdkerrors.Register(ModuleName, 26, "delegator does not contain delegation") + ErrInsufficientShares = sdkerrors.Register(ModuleName, 27, "insufficient delegation shares") + ErrDelegationValidatorEmpty = sdkerrors.Register(ModuleName, 28, "cannot delegate to an empty validator") + ErrNotEnoughDelegationShares = sdkerrors.Register(ModuleName, 29, "not enough delegation shares") + ErrBadSharesAmount = sdkerrors.Register(ModuleName, 30, "invalid shares amount") + ErrBadSharesPercent = sdkerrors.Register(ModuleName, 31, "Invalid shares percent") + ErrNotMature = sdkerrors.Register(ModuleName, 32, "entry not mature") + ErrNoUnbondingDelegation = sdkerrors.Register(ModuleName, 33, "no unbonding delegation found") + ErrMaxUnbondingDelegationEntries = sdkerrors.Register(ModuleName, 34, "too many unbonding delegation entries for (delegator, validator) tuple") + ErrBadRedelegationAddr = sdkerrors.Register(ModuleName, 35, "invalid address for (address, src-validator, dst-validator) tuple") + ErrNoRedelegation = sdkerrors.Register(ModuleName, 36, "no redelegation found") + ErrSelfRedelegation = sdkerrors.Register(ModuleName, 37, "cannot redelegate to the same validator") + ErrTinyRedelegationAmount = sdkerrors.Register(ModuleName, 38, "too few tokens to redelegate (truncates to zero tokens)") + ErrBadRedelegationDst = sdkerrors.Register(ModuleName, 39, "redelegation destination validator not found") + ErrTransitiveRedelegation = sdkerrors.Register(ModuleName, 40, "redelegation to this validator already in progress; first redelegation to this validator must complete before next redelegation") + ErrMaxRedelegationEntries = sdkerrors.Register(ModuleName, 41, "too many redelegation entries for (delegator, src-validator, dst-validator) tuple") + ErrDelegatorShareExRateInvalid = sdkerrors.Register(ModuleName, 42, "cannot delegate to validators with invalid (zero) ex-rate") + ErrBothShareMsgsGiven = sdkerrors.Register(ModuleName, 43, "both shares amount and shares percent provided") + ErrNeitherShareMsgsGiven = sdkerrors.Register(ModuleName, 44, "neither shares amount nor shares percent provided") + ErrInvalidHistoricalInfo = sdkerrors.Register(ModuleName, 45, "invalid historical info") + ErrNoHistoricalInfo = sdkerrors.Register(ModuleName, 46, "no historical info found") + ErrEmptyValidatorPubKey = sdkerrors.Register(ModuleName, 47, "empty validator public key") )