* Add params error types * Update param module keeper to take a codespace * Update imports * Implement SetRaw and SetRawWithSubkey * Implement ParamChange and update aliases * Add types codec * Implement ParameterChangeProposal * Implement TestParameterChangeProposal * Fix linting errors * Update tags * Implement content * Updata params aliases * Finish params handler and proposal types * Move deposit and vote logic to types package * Move proposal type to types package * Move errors to types package * Update proposal * Move gov messages to types package * Minor updates to naming * Move keys to types package * Move codec to types package * Move proposal types to types package * Update aliases * Add governance alias types * Implement governance router * Update gov aliases * Update gov keeper * Update private functions needed for the keeper * Update godocs * Update the gov message handler * Update Gaia app * Make updates to auth * Update the message codec in the keeper * Update gov end blocker * Update types tests * Minor tweaks * Add legacy genesis logic * Update gov aliases * Move gov keys to types package * Revertt to using gov/types in params * Implement params handler test * Update governance tests * Fix endblocker tests * Fix governance querier tests * Add seal support to gov router * Update simulationCreateMsgSubmitProposal * Disable software upgrade proposals * Move params keys to types package * Implement param module proposal client logic * Update gov client logic * Update gaia app client hooks * Fix linting errors * Fix ValidateBasic * Remove legacy files * Update paramchange to use strings * Update paramchange cli cmd * Update ValidateBasic and errors * Use PostCommands when adding child cmds * Fix codec logic * Update params client and handler * Update IsValidProposalType * Update SubmitProposal to test exec * Implement TestGaiaCLISubmitParamChangeProposal * Implement TestSubmitParamChangeProposal * Update swagger.yaml * Update gaiacli.md * Update gov spec docs * Fix linting errors * Fix unit tests * Add pending log entries * Update docs * Update docs * Update client/lcd/swagger-ui/swagger.yaml Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update docs/cosmos-hub/gaiacli.md Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update cmd/gaia/cli_test/test_helpers.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update client/lcd/test_helpers.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update docs/cosmos-hub/gaiacli.md Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update docs/cosmos-hub/gaiacli.md Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update docs/cosmos-hub/gaiacli.md Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update x/gov/types/proposal.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update docs/cosmos-hub/gaiacli.md Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update docs/cosmos-hub/gaiacli.md Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Address PR comments * Update docs/cosmos-hub/gaiacli.md Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update gov docs to include quorum notes * Add logs to handleParameterChangeProposal * Update docs/spec/governance/02_state.md Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Support and use new StatusFailed when proposal passes but fails exec * Add docs/notes warning on param validity * Update docs * Update docs/spec/governance/02_state.md Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update docs/spec/governance/02_state.md Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Minor doc update * Update x/gov/client/cli/tx.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Fix usage of fromAddr * Rige code style suggestion * Update x/params/types/proposal.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Fix CI lint errors * Update NewModuleClient godoc * Add godoc to rtr.Seal() call * Rename files * Rename NewProposalHandler
91 lines
2.9 KiB
Go
91 lines
2.9 KiB
Go
package auth
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/params"
|
|
"github.com/cosmos/cosmos-sdk/x/params/subspace"
|
|
)
|
|
|
|
// DefaultParamspace defines the default auth module parameter subspace
|
|
const DefaultParamspace = "auth"
|
|
|
|
// Default parameter values
|
|
const (
|
|
DefaultMaxMemoCharacters uint64 = 256
|
|
DefaultTxSigLimit uint64 = 7
|
|
DefaultTxSizeCostPerByte uint64 = 10
|
|
DefaultSigVerifyCostED25519 uint64 = 590
|
|
DefaultSigVerifyCostSecp256k1 uint64 = 1000
|
|
)
|
|
|
|
// Parameter keys
|
|
var (
|
|
KeyMaxMemoCharacters = []byte("MaxMemoCharacters")
|
|
KeyTxSigLimit = []byte("TxSigLimit")
|
|
KeyTxSizeCostPerByte = []byte("TxSizeCostPerByte")
|
|
KeySigVerifyCostED25519 = []byte("SigVerifyCostED25519")
|
|
KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1")
|
|
)
|
|
|
|
var _ subspace.ParamSet = &Params{}
|
|
|
|
// Params defines the parameters for the auth module.
|
|
type Params struct {
|
|
MaxMemoCharacters uint64 `json:"max_memo_characters"`
|
|
TxSigLimit uint64 `json:"tx_sig_limit"`
|
|
TxSizeCostPerByte uint64 `json:"tx_size_cost_per_byte"`
|
|
SigVerifyCostED25519 uint64 `json:"sig_verify_cost_ed25519"`
|
|
SigVerifyCostSecp256k1 uint64 `json:"sig_verify_cost_secp256k1"`
|
|
}
|
|
|
|
// ParamKeyTable for auth module
|
|
func ParamKeyTable() params.KeyTable {
|
|
return params.NewKeyTable().RegisterParamSet(&Params{})
|
|
}
|
|
|
|
// ParamSetPairs implements the ParamSet interface and returns all the key/value pairs
|
|
// pairs of auth module's parameters.
|
|
// nolint
|
|
func (p *Params) ParamSetPairs() subspace.ParamSetPairs {
|
|
return subspace.ParamSetPairs{
|
|
{KeyMaxMemoCharacters, &p.MaxMemoCharacters},
|
|
{KeyTxSigLimit, &p.TxSigLimit},
|
|
{KeyTxSizeCostPerByte, &p.TxSizeCostPerByte},
|
|
{KeySigVerifyCostED25519, &p.SigVerifyCostED25519},
|
|
{KeySigVerifyCostSecp256k1, &p.SigVerifyCostSecp256k1},
|
|
}
|
|
}
|
|
|
|
// Equal returns a boolean determining if two Params types are identical.
|
|
func (p Params) Equal(p2 Params) bool {
|
|
bz1 := msgCdc.MustMarshalBinaryLengthPrefixed(&p)
|
|
bz2 := msgCdc.MustMarshalBinaryLengthPrefixed(&p2)
|
|
return bytes.Equal(bz1, bz2)
|
|
}
|
|
|
|
// DefaultParams returns a default set of parameters.
|
|
func DefaultParams() Params {
|
|
return Params{
|
|
MaxMemoCharacters: DefaultMaxMemoCharacters,
|
|
TxSigLimit: DefaultTxSigLimit,
|
|
TxSizeCostPerByte: DefaultTxSizeCostPerByte,
|
|
SigVerifyCostED25519: DefaultSigVerifyCostED25519,
|
|
SigVerifyCostSecp256k1: DefaultSigVerifyCostSecp256k1,
|
|
}
|
|
}
|
|
|
|
// String implements the stringer interface.
|
|
func (p Params) String() string {
|
|
var sb strings.Builder
|
|
sb.WriteString("Params: \n")
|
|
sb.WriteString(fmt.Sprintf("MaxMemoCharacters: %d\n", p.MaxMemoCharacters))
|
|
sb.WriteString(fmt.Sprintf("TxSigLimit: %d\n", p.TxSigLimit))
|
|
sb.WriteString(fmt.Sprintf("TxSizeCostPerByte: %d\n", p.TxSizeCostPerByte))
|
|
sb.WriteString(fmt.Sprintf("SigVerifyCostED25519: %d\n", p.SigVerifyCostED25519))
|
|
sb.WriteString(fmt.Sprintf("SigVerifyCostSecp256k1: %d\n", p.SigVerifyCostSecp256k1))
|
|
return sb.String()
|
|
}
|