Documentation ¶
Index ¶
- Constants
- func AddressStoreKey(addr crypto.Address) []byte
- func DeductFees(bank BankKeeperI, ctx sdk.Context, acc std.Account, fees std.Coins) sdk.Result
- func DefaultSigVerificationGasConsumer(meter store.GasMeter, sig []byte, pubkey crypto.PubKey, params Params) sdk.Result
- func EndBlocker(ctx sdk.Context, gk GasPriceKeeperI)
- func EnsureSufficientMempoolFees(ctx sdk.Context, fee std.Fee) sdk.Result
- func FeeCollectorAddress() crypto.Address
- func GetSignBytes(chainID string, tx std.Tx, acc std.Account, genesis bool) ([]byte, error)
- func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr crypto.Address) (std.Account, sdk.Result)
- func InitChainer(ctx sdk.Context, gk GasPriceKeeper, gp std.GasPrice)
- func NewAnteHandler(ak AccountKeeper, bank BankKeeperI, ...) sdk.AnteHandler
- func NewHandler(acck AccountKeeper) authHandler
- func ProcessPubKey(acc std.Account, sig std.Signature, simulate bool) (crypto.PubKey, sdk.Result)
- func SetGasMeter(simulate bool, ctx sdk.Context, gasLimit int64) sdk.Context
- func ValidateGenesis(data GenesisState) error
- func ValidateMemo(tx std.Tx, params Params) sdk.Result
- func ValidateSigCount(tx std.Tx, params Params) sdk.Result
- type AccountKeeper
- func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) GenesisState
- func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr crypto.Address) std.Account
- func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) []std.Account
- func (ak AccountKeeper) GetNextAccountNumber(ctx sdk.Context) uint64
- func (ak AccountKeeper) GetParams(ctx sdk.Context) Params
- func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr crypto.Address) (crypto.PubKey, error)
- func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr crypto.Address) (uint64, error)
- func (ak AccountKeeper) InitGenesis(ctx sdk.Context, data GenesisState)
- func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, process func(std.Account) (stop bool))
- func (ak AccountKeeper) Logger(ctx sdk.Context) *slog.Logger
- func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr crypto.Address) std.Account
- func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc std.Account)
- func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc std.Account)
- func (ak AccountKeeper) SetParams(ctx sdk.Context, params Params) error
- type AccountKeeperI
- type AnteOptions
- type AuthParamsContextKey
- type BankKeeperI
- type DummyBankKeeper
- type GasPriceContextKey
- type GasPriceKeeper
- type GasPriceKeeperI
- type GenesisState
- type Params
- type SignatureVerificationGasConsumer
Constants ¶
const ( // module name ModuleName = "auth" // StoreKey is string representation of the store key for auth StoreKey = "acc" // FeeCollectorName the root string for the fee collector account address FeeCollectorName = "fee_collector" // QuerierRoute is the querier route for acc QuerierRoute = StoreKey // AddressStoreKeyPrefix prefix for account-by-address store AddressStoreKeyPrefix = "/a/" // key for gas price GasPriceKey = "gasPrice" // param key for global account number GlobalAccountNumberKey = "globalAccountNumber" )
const ( DefaultMaxMemoBytes int64 = 65536 DefaultTxSigLimit int64 = 7 DefaultTxSizeCostPerByte int64 = 10 DefaultSigVerifyCostED25519 int64 = 590 DefaultSigVerifyCostSecp256k1 int64 = 1000 DefaultGasPricesChangeCompressor int64 = 10 DefaultTargetGasRatio int64 = 70 // 70% of the MaxGas in a block )
Default parameter values
const QueryAccount = "accounts"
query account path
Variables ¶
This section is empty.
Functions ¶
func AddressStoreKey ¶
AddressStoreKey turn an address to key used to get it from the account store
func DeductFees ¶
DeductFees deducts fees from the given account.
NOTE: We could use the CoinKeeper (in addition to the AccountKeeper, because the CoinKeeper doesn't give us accounts), but it seems easier to do this.
func DefaultSigVerificationGasConsumer ¶
func DefaultSigVerificationGasConsumer( meter store.GasMeter, sig []byte, pubkey crypto.PubKey, params Params, ) sdk.Result
DefaultSigVerificationGasConsumer is the default implementation of SignatureVerificationGasConsumer. It consumes gas for signature verification based upon the public key type. The cost is fetched from the given params and is matched by the concrete type.
func EndBlocker ¶
func EndBlocker(ctx sdk.Context, gk GasPriceKeeperI)
EndBlocker is called in the EndBlock(), it calcuates the minimum gas price for the next gas price
func EnsureSufficientMempoolFees ¶
EnsureSufficientMempoolFees verifies that the given transaction has supplied enough fees to cover a proposer's minimum fees. A result object is returned indicating success or failure.
Contract: This should only be called during CheckTx as it cannot be part of consensus.
func FeeCollectorAddress ¶
func GetSignBytes ¶
GetSignBytes returns a slice of bytes to sign over for a given transaction and an account.
func GetSignerAcc ¶
GetSignerAcc returns an account for a given address that is expected to sign a transaction.
func InitChainer ¶
func InitChainer(ctx sdk.Context, gk GasPriceKeeper, gp std.GasPrice)
InitChainer is called in the InitChain(), it set the initial gas price in the GasPriceKeeper store for the next gas price
func NewAnteHandler ¶
func NewAnteHandler(ak AccountKeeper, bank BankKeeperI, sigGasConsumer SignatureVerificationGasConsumer, opts AnteOptions) sdk.AnteHandler
NewAnteHandler returns an AnteHandler that checks and increments sequence numbers, checks signatures & account numbers, and deducts fees from the first signer.
func NewHandler ¶
func NewHandler(acck AccountKeeper) authHandler
NewHandler returns a handler for "auth" type messages.
func ProcessPubKey ¶
ProcessPubKey verifies that the given account address matches that of the std.Signature. In addition, it will set the public key of the account if it has not been set.
func SetGasMeter ¶
SetGasMeter returns a new context with a gas meter set from a given context.
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis performs basic validation of auth genesis data returning an error for any failed validation criteria.
func ValidateMemo ¶
ValidateMemo validates the memo size.
Types ¶
type AccountKeeper ¶
type AccountKeeper struct {
// contains filtered or unexported fields
}
Concrete implementation of AccountKeeper.
func NewAccountKeeper ¶
func NewAccountKeeper( key store.StoreKey, pk params.ParamsKeeper, proto func() std.Account, ) AccountKeeper
NewAccountKeeper returns a new AccountKeeper that uses go-amino to (binary) encode and decode concrete std.Accounts.
func (AccountKeeper) ExportGenesis ¶
func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) GenesisState
ExportGenesis returns a GenesisState for a given context and keeper
func (AccountKeeper) GetAccount ¶
GetAccount returns a specific account in the AccountKeeper.
func (AccountKeeper) GetAllAccounts ¶
func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) []std.Account
GetAllAccounts returns all accounts in the AccountKeeper.
func (AccountKeeper) GetNextAccountNumber ¶
func (ak AccountKeeper) GetNextAccountNumber(ctx sdk.Context) uint64
GetNextAccountNumber Returns and increments the global account number counter
func (AccountKeeper) GetSequence ¶
GetSequence Returns the Sequence of the account at address
func (AccountKeeper) InitGenesis ¶
func (ak AccountKeeper) InitGenesis(ctx sdk.Context, data GenesisState)
InitGenesis - Init store state from genesis data
func (AccountKeeper) IterateAccounts ¶
IterateAccounts implements AccountKeeper.
func (AccountKeeper) Logger ¶
func (ak AccountKeeper) Logger(ctx sdk.Context) *slog.Logger
Logger returns a module-specific logger.
func (AccountKeeper) NewAccountWithAddress ¶
NewAccountWithAddress implements AccountKeeper.
func (AccountKeeper) RemoveAccount ¶
func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc std.Account)
RemoveAccount removes an account for the account mapper store. NOTE: this will cause supply invariant violation if called
func (AccountKeeper) SetAccount ¶
func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc std.Account)
SetAccount implements AccountKeeper.
type AccountKeeperI ¶
type AccountKeeperI interface { NewAccountWithAddress(ctx sdk.Context, addr crypto.Address) std.Account GetAccount(ctx sdk.Context, addr crypto.Address) std.Account GetAllAccounts(ctx sdk.Context) []std.Account SetAccount(ctx sdk.Context, acc std.Account) IterateAccounts(ctx sdk.Context, process func(std.Account) bool) InitGenesis(ctx sdk.Context, data GenesisState) GetParams(ctx sdk.Context) Params }
AccountKeeper manages access to accounts.
type AnteOptions ¶
type AnteOptions struct { // If verifyGenesisSignatures is false, does not check signatures when Height==0. // This is useful for development, and maybe production chains. // Always check your settings and inspect genesis transactions. VerifyGenesisSignatures bool }
type AuthParamsContextKey ¶
type AuthParamsContextKey struct{}
type BankKeeperI ¶
type BankKeeperI interface {
SendCoins(ctx sdk.Context, fromAddr crypto.Address, toAddr crypto.Address, amt std.Coins) error
}
Limited interface only needed for auth.
type DummyBankKeeper ¶
type DummyBankKeeper struct {
// contains filtered or unexported fields
}
DummyBankKeeper defines a supply keeper used only for testing to avoid circle dependencies
func NewDummyBankKeeper ¶
func NewDummyBankKeeper(acck AccountKeeper) DummyBankKeeper
NewDummyBankKeeper creates a DummyBankKeeper instance
type GasPriceContextKey ¶
type GasPriceContextKey struct{}
type GasPriceKeeper ¶
type GasPriceKeeper struct {
// contains filtered or unexported fields
}
func NewGasPriceKeeper ¶
func NewGasPriceKeeper(key store.StoreKey) GasPriceKeeper
GasPriceKeeper The GasPriceKeeper stores the history of gas prices and calculates new gas price with formula parameters
func (GasPriceKeeper) LastGasPrice ¶
func (gk GasPriceKeeper) LastGasPrice(ctx sdk.Context) std.GasPrice
It returns the gas price for the last block.
func (GasPriceKeeper) SetGasPrice ¶
func (gk GasPriceKeeper) SetGasPrice(ctx sdk.Context, gp std.GasPrice)
SetGasPrice is called in InitChainer to store initial gas price set in the genesis
func (GasPriceKeeper) UpdateGasPrice ¶
func (gk GasPriceKeeper) UpdateGasPrice(ctx sdk.Context)
We store the history. If the formula changes, we can replay blocks and apply the formula to a specific block range. The new gas price is calculated in EndBlock().
type GasPriceKeeperI ¶
type GenesisState ¶
type GenesisState struct {
Params Params `json:"params"`
}
GenesisState - all auth state that must be provided at genesis
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState - Return a default genesis state
func NewGenesisState ¶
func NewGenesisState(params Params) GenesisState
NewGenesisState - Create a new genesis state
type Params ¶
type Params struct { MaxMemoBytes int64 `json:"max_memo_bytes" yaml:"max_memo_bytes"` TxSigLimit int64 `json:"tx_sig_limit" yaml:"tx_sig_limit"` TxSizeCostPerByte int64 `json:"tx_size_cost_per_byte" yaml:"tx_size_cost_per_byte"` SigVerifyCostED25519 int64 `json:"sig_verify_cost_ed25519" yaml:"sig_verify_cost_ed25519"` SigVerifyCostSecp256k1 int64 `json:"sig_verify_cost_secp256k1" yaml:"sig_verify_cost_secp256k1"` GasPricesChangeCompressor int64 `json:"gas_price_change_compressor" yaml:"gas_price_change_compressor"` TargetGasRatio int64 `json:"target_gas_ratio" yaml:"target_gas_ratio"` InitialGasPrice std.GasPrice `json:"initial_gasprice"` }
Params defines the parameters for the auth module.
func NewParams ¶
func NewParams(maxMemoBytes, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1, gasPricesChangeCompressor, targetGasRatio int64, ) Params
NewParams creates a new Params object
type SignatureVerificationGasConsumer ¶
type SignatureVerificationGasConsumer = func(meter store.GasMeter, sig []byte, pubkey crypto.PubKey, params Params) sdk.Result
SignatureVerificationGasConsumer is the type of function that is used to both consume gas when verifying signatures and also to accept or reject different types of PubKey's. This is where apps can define their own PubKey