* modify light imports * change abci.header to tmproto.header * use rc * rc * fix import * Merge PR #6893: fix key imports * fix rc2 * tendermint: update 3 (#6899) * tendermint: update 4 (#6919) Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> * tendermint: update 5 (#6923) Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * bump to latest master * tendermint: update (#6972) Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com> Co-authored-by: Cory Levinson <cjlevinson@gmail.com> * Update x/ibc/07-tendermint/types/test_utils.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * address comment * go mod * bring back things * fix test * update tm proto files Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com> Co-authored-by: Cory Levinson <cjlevinson@gmail.com> Co-authored-by: Federico Kunze <federico.kunze94@gmail.com>
91 lines
2.5 KiB
Go
91 lines
2.5 KiB
Go
package baseapp
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
// Paramspace defines the parameter subspace to be used for the paramstore.
|
|
const Paramspace = "baseapp"
|
|
|
|
// Parameter store keys for all the consensus parameter types.
|
|
var (
|
|
ParamStoreKeyBlockParams = []byte("BlockParams")
|
|
ParamStoreKeyEvidenceParams = []byte("EvidenceParams")
|
|
ParamStoreKeyValidatorParams = []byte("ValidatorParams")
|
|
)
|
|
|
|
// ParamStore defines the interface the parameter store used by the BaseApp must
|
|
// fulfill.
|
|
type ParamStore interface {
|
|
Get(ctx sdk.Context, key []byte, ptr interface{})
|
|
Has(ctx sdk.Context, key []byte) bool
|
|
Set(ctx sdk.Context, key []byte, param interface{})
|
|
}
|
|
|
|
// ValidateBlockParams defines a stateless validation on BlockParams. This function
|
|
// is called whenever the parameters are updated or stored.
|
|
func ValidateBlockParams(i interface{}) error {
|
|
v, ok := i.(abci.BlockParams)
|
|
if !ok {
|
|
return fmt.Errorf("invalid parameter type: %T", i)
|
|
}
|
|
|
|
if v.MaxBytes <= 0 {
|
|
return fmt.Errorf("block maximum bytes must be positive: %d", v.MaxBytes)
|
|
}
|
|
|
|
if v.MaxGas < -1 {
|
|
return fmt.Errorf("block maximum gas must be greater than or equal to -1: %d", v.MaxGas)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ValidateEvidenceParams defines a stateless validation on EvidenceParams. This
|
|
// function is called whenever the parameters are updated or stored.
|
|
func ValidateEvidenceParams(i interface{}) error {
|
|
v, ok := i.(tmproto.EvidenceParams)
|
|
if !ok {
|
|
return fmt.Errorf("invalid parameter type: %T", i)
|
|
}
|
|
|
|
if v.MaxAgeNumBlocks <= 0 {
|
|
return fmt.Errorf("evidence maximum age in blocks must be positive: %d", v.MaxAgeNumBlocks)
|
|
}
|
|
|
|
if v.MaxAgeDuration <= 0 {
|
|
return fmt.Errorf("evidence maximum age time duration must be positive: %v", v.MaxAgeDuration)
|
|
}
|
|
|
|
if v.MaxNum <= 0 {
|
|
return fmt.Errorf("evidence maximum number of evidence must be positive: %v", v.MaxAgeDuration)
|
|
}
|
|
|
|
if v.ProofTrialPeriod <= 0 {
|
|
return fmt.Errorf("proof of trial period must be greater than 0: %v", v.MaxAgeDuration)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ValidateValidatorParams defines a stateless validation on ValidatorParams. This
|
|
// function is called whenever the parameters are updated or stored.
|
|
func ValidateValidatorParams(i interface{}) error {
|
|
v, ok := i.(tmproto.ValidatorParams)
|
|
if !ok {
|
|
return fmt.Errorf("invalid parameter type: %T", i)
|
|
}
|
|
|
|
if len(v.PubKeyTypes) == 0 {
|
|
return errors.New("validator allowed pubkey types must not be empty")
|
|
}
|
|
|
|
return nil
|
|
}
|