Documentation
¶
Index ¶
- Constants
- Variables
- func AccountKeyspaceInvariant(ak AccountKeeper) sdk.Invariant
- func AddressStoreKey(addr crypto.Address) []byte
- func AllInvariants(ak AccountKeeper) sdk.Invariant
- func CheckAndDeductSessionSpend(ctx sdk.Context, ak SessionAccountSetter, signerAddr crypto.Address, ...) error
- func CheckSessionSpend(da std.DelegatedAccount, amount std.Coins, blockTime int64) error
- func DecodeAccountSafe(bz []byte) (acc std.Account, err error)
- func DeductFees(bk BankKeeperI, ctx sdk.Context, acc std.Account, collector crypto.Address, ...) sdk.Result
- func DeductSessionSpend(da std.DelegatedAccount, amount std.Coins, blockTime int64) error
- 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 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 GasPriceKeeperI, gp std.GasPrice)
- func NewAnteHandler(ak AccountKeeper, bank BankKeeperI, ...) sdk.AnteHandler
- func NewHandler(acck AccountKeeper, gpKpr GasPriceKeeper) authHandler
- func SessionPrefixKey(master crypto.Address) []byte
- func SessionStoreKey(master, session crypto.Address) []byte
- func SetGasMeter(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 AccountEntry
- type AccountKeeper
- func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) GenesisState
- func (ak AccountKeeper) FeeCollectorAddress(ctx sdk.Context) crypto.Address
- 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) GetSessionAccount(ctx sdk.Context, master, session crypto.Address) std.Account
- func (ak AccountKeeper) HasAccount(ctx sdk.Context, addr crypto.Address) bool
- func (ak AccountKeeper) InitGenesis(ctx sdk.Context, data GenesisState)
- func (ak AccountKeeper) IterateAccountEntries(ctx sdk.Context, cb func(AccountEntry) bool) error
- func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, process func(std.Account) (stop bool))
- func (ak AccountKeeper) IterateSessions(ctx sdk.Context, master crypto.Address, cb func(std.Account) 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) NewAccountWithUncheckedNumber(ctx sdk.Context, addr crypto.Address, accNum uint64) std.Account
- func (ak AccountKeeper) NewSessionAccount(ctx sdk.Context, master crypto.Address, pubKey crypto.PubKey) std.Account
- func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc std.Account)
- func (ak AccountKeeper) RemoveAllSessions(ctx sdk.Context, master crypto.Address)
- func (ak AccountKeeper) RemoveSessionAccount(ctx sdk.Context, master, session crypto.Address)
- func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc std.Account)
- func (ak AccountKeeper) SetFeesCollectorAddress(ctx sdk.Context, addr crypto.Address)
- func (ak AccountKeeper) SetParams(ctx sdk.Context, params Params) error
- func (ak AccountKeeper) SetSessionAccount(ctx sdk.Context, master crypto.Address, acc std.Account)
- func (ak AccountKeeper) WillSetParam(ctx sdk.Context, key string, value any)
- type AccountKeeperI
- type AccountKeyKind
- type AnteOptions
- type AuthParamsContextKey
- type BankKeeperI
- type DummyBankKeeper
- func (bankk DummyBankKeeper) GetCoin(ctx sdk.Context, addr crypto.Address, denom string) int64
- func (bankk DummyBankKeeper) SendCoins(ctx sdk.Context, fromAddr crypto.Address, toAddr crypto.Address, amt std.Coins) error
- func (bankk DummyBankKeeper) SendCoinsUnrestricted(ctx sdk.Context, fromAddr crypto.Address, toAddr crypto.Address, amt std.Coins) error
- func (bankk DummyBankKeeper) WillSetParam(ctx sdk.Context, key string, value any)
- type GasPriceContextKey
- type GasPriceKeeper
- type GasPriceKeeperI
- type GenesisReplayKey
- type GenesisState
- type MsgCreateSession
- func (msg MsgCreateSession) GetSignBytes() []byte
- func (msg MsgCreateSession) GetSigners() []crypto.Address
- func (goo MsgCreateSession) MarshalBinary2(cdc *amino.Codec, buf []byte, offset int) (int, error)
- func (msg MsgCreateSession) Route() string
- func (goo MsgCreateSession) SizeBinary2(cdc *amino.Codec) (int, error)
- func (msg MsgCreateSession) Type() string
- func (goo *MsgCreateSession) UnmarshalBinary2(cdc *amino.Codec, bz []byte, anyDepth int) error
- func (msg MsgCreateSession) ValidateBasic() error
- type MsgRevokeAllSessions
- func (msg MsgRevokeAllSessions) GetSignBytes() []byte
- func (msg MsgRevokeAllSessions) GetSigners() []crypto.Address
- func (goo MsgRevokeAllSessions) MarshalBinary2(cdc *amino.Codec, buf []byte, offset int) (int, error)
- func (msg MsgRevokeAllSessions) Route() string
- func (goo MsgRevokeAllSessions) SizeBinary2(cdc *amino.Codec) (int, error)
- func (msg MsgRevokeAllSessions) Type() string
- func (goo *MsgRevokeAllSessions) UnmarshalBinary2(cdc *amino.Codec, bz []byte, anyDepth int) error
- func (msg MsgRevokeAllSessions) ValidateBasic() error
- type MsgRevokeSession
- func (msg MsgRevokeSession) GetSignBytes() []byte
- func (msg MsgRevokeSession) GetSigners() []crypto.Address
- func (goo MsgRevokeSession) MarshalBinary2(cdc *amino.Codec, buf []byte, offset int) (int, error)
- func (msg MsgRevokeSession) Route() string
- func (goo MsgRevokeSession) SizeBinary2(cdc *amino.Codec) (int, error)
- func (msg MsgRevokeSession) Type() string
- func (goo *MsgRevokeSession) UnmarshalBinary2(cdc *amino.Codec, bz []byte, anyDepth int) error
- func (msg MsgRevokeSession) ValidateBasic() error
- type Params
- func (p Params) Equals(p2 Params) bool
- func (goo Params) MarshalBinary2(cdc *amino.Codec, buf []byte, offset int) (int, error)
- func (goo Params) SizeBinary2(cdc *amino.Codec) (int, error)
- func (p Params) String() string
- func (goo *Params) UnmarshalBinary2(cdc *amino.Codec, bz []byte, anyDepth int) error
- func (p Params) Validate() error
- type SessionAccountSetter
- type SignatureVerificationGasConsumer
- type SkipGasMeteringKey
Constants ¶
const ( // module name ModuleName = "auth" // StoreKey is string representation of the store key for auth StoreKey = "acc" // QuerierRoute is the querier route for acc QuerierRoute = StoreKey // AddressStoreKeyPrefix prefix for account-by-address store. // // IMPORTANT: Session accounts are also stored under this prefix, // at /a/<master>/s/<session>. This means a PrefixIterator on "/a/" // returns BOTH regular accounts and session accounts. Use // AccountStoreKeyLen to filter: regular account keys are exactly // len("/a/") + crypto.AddressSize bytes. Anything longer is a // session sub-key. See IterateAccounts for the canonical filter. AddressStoreKeyPrefix = "/a/" // AccountStoreKeyLen is the exact byte length of a regular account // store key: len("/a/") + crypto.AddressSize. Keys under "/a/" that // are longer than this are session sub-keys, not regular accounts. // Used by IterateAccounts to skip session accounts during iteration. AccountStoreKeyLen = len(AddressStoreKeyPrefix) + crypto.AddressSize // key for gas price GasPriceKey = "gasPrice" // param key for global account number GlobalAccountNumberKey = "globalAccountNumber" // SessionStoreKeyInfix separates master and session addresses in // session account keys. The full key format is: // // /a/<master 20 bytes>/s/<session 20 bytes> // // This nests sessions under the "/a/" prefix so they share IAVL // tree nodes with the master account (cheap second read). The "/s/" // infix acts as a visual delimiter for debugging raw store dumps. // // IMPORTANT: Because sessions share the "/a/" prefix, any code // that iterates "/a/" MUST filter by key length to exclude session // keys. See AccountStoreKeyLen and IterateAccounts. SessionStoreKeyInfix = "/s/" )
const ( QueryAccount = "accounts" QueryGasPrice = "gasprice" QuerySessions = "sessions" // /auth/accounts/{addr}/sessions QuerySessionAccount = "session" // /auth/accounts/{addr}/session/{sessionAddr} )
query path
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 DefaultFeeCollectorName string = "fee_collector" )
Default parameter values
const SessionStoreKeyLen = AccountStoreKeyLen + len(SessionStoreKeyInfix) + crypto.AddressSize
SessionStoreKeyLen is the exact byte length of a session account key, /a/<master>/s/<session>.
Variables ¶
var Package = amino.RegisterPackage(amino.NewPackage( "github.com/gnolang/gno/tm2/pkg/sdk/auth", "auth", amino.GetCallersDirname(), ).WithDependencies( std.Package, ).WithTypes( GenesisState{}, "GenesisState", Params{}, "Params", MsgCreateSession{}, "m_create_session", MsgRevokeSession{}, "m_revoke_session", MsgRevokeAllSessions{}, "m_revoke_all_sessions", ))
Functions ¶
func AccountKeyspaceInvariant ¶
func AccountKeyspaceInvariant(ak AccountKeeper) sdk.Invariant
AccountKeyspaceInvariant sweeps the account keyspace.
Checks that every key is a shape some iterator enumerates; that every value decodes to a non-nil account; that the account's own Address agrees with the key it is filed under; that account numbers are unique and below the global counter; and that every session names a master that exists and claims that same master.
The key/field agreement check is the important one. SetAccount files an account under AddressStoreKey(acc.GetAddress()) while every reader looks it up by the address it already has, so a disagreement silently redirects writes: crediting one address can land the coins in another.
func AddressStoreKey ¶
AddressStoreKey returns the store key for a regular account: /a/<addr>. The resulting key is exactly AccountStoreKeyLen bytes.
func AllInvariants ¶
func AllInvariants(ak AccountKeeper) sdk.Invariant
AllInvariants runs every auth invariant.
func CheckAndDeductSessionSpend ¶
func CheckAndDeductSessionSpend(ctx sdk.Context, ak SessionAccountSetter, signerAddr crypto.Address, amount std.Coins) error
CheckAndDeductSessionSpend looks up the session for a signer from context and checks/deducts spending. Persists the updated session account to store. Returns nil if not a session tx or signer isn't using a session.
func CheckSessionSpend ¶
CheckSessionSpend verifies that `amount` could be deducted from the session's current budget without exceeding SpendLimit — WITHOUT mutating da. Uses the same semantics as DeductSessionSpend for empty-limit rejection and period-reset, but returns the same error without touching state.
Used by the ante's session pre-check to fail fast on obviously- over-limit session-signed txs before any gas fee is deducted, which prevents the mempool-gas-bleed attack where repeated over- limit submissions would otherwise charge gas per attempt.
func DecodeAccountSafe ¶
DecodeAccountSafe decodes stored account bytes where decodeAccount would panic.
A zero-length value is accepted by the store and unmarshals to a nil interface with no error, so "err == nil" is not enough to conclude the account is usable — every caller must treat a nil account as a finding, not as an empty one.
The recover is a backstop, like sdk.Guard's, and is not the mechanism: the panic this function exists to avoid is decodeAccount's, which panics on an unmarshal error rather than returning it. Amino itself returns errors for malformed input in practice — a zero-length value, random bytes, a huge length prefix, a truncated varint, a bad type prefix and a deeply nested payload were all tried and all errored — so the recover should not be read as evidence that it panics, nor removed for being unreached. An invariant that dies on the state it exists to report is worse than one that reports a decoder bug.
func DeductFees ¶
func DeductFees(bk BankKeeperI, ctx sdk.Context, acc std.Account, collector crypto.Address, fees std.Coins) sdk.Result
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 DeductSessionSpend ¶
DeductSessionSpend checks and deducts spending from a session's spend limit. If SpendLimit is empty, any non-zero amount is rejected — the session cannot spend coins at all (useful when another signer pays gas, or for zero-send calls). Mutates da.SpendUsed in memory. Caller must persist via SetSessionAccount.
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 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 GasPriceKeeperI, 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, gpKpr GasPriceKeeper) authHandler
NewHandler returns a handler for "auth" type messages.
func SessionPrefixKey ¶
SessionPrefixKey returns the prefix for all sessions of a master: /a/<master>/s/. Used for prefix iteration and RevokeAll.
func SessionStoreKey ¶
SessionStoreKey returns the store key for a session account: /a/<master>/s/<session>. This key is longer than AccountStoreKeyLen, which is how IterateAccounts distinguishes sessions from regular accounts.
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 genesis data returning an error for any failed validation criteria.
func ValidateMemo ¶
ValidateMemo validates the memo size.
Types ¶
type AccountEntry ¶
type AccountEntry struct {
Key []byte
Kind AccountKeyKind
Addr crypto.Address // the session address for a session key
Master crypto.Address // sessions only
Account std.Account // nil iff DecodeErr != nil
DecodeErr error
}
AccountEntry is one key under AddressStoreKeyPrefix, decoded where possible.
type AccountKeeper ¶
type AccountKeeper struct {
// contains filtered or unexported fields
}
Concrete implementation of AccountKeeper.
func NewAccountKeeper ¶
func NewAccountKeeper( key store.StoreKey, pk params.ParamsKeeperI, proto func() std.Account, sessionProto 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) FeeCollectorAddress ¶
func (ak AccountKeeper) FeeCollectorAddress(ctx sdk.Context) crypto.Address
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 regular accounts (excludes session accounts). Session accounts are stored under the same "/a/" prefix but are filtered out by IterateAccounts via key length. Use IterateSessions to access sessions.
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) GetSessionAccount ¶
func (ak AccountKeeper) GetSessionAccount(ctx sdk.Context, master, session crypto.Address) std.Account
GetSessionAccount returns a session account stored at /a/<master>/s/<session>.
func (AccountKeeper) HasAccount ¶
HasAccount reports whether addr has an account object, without decoding it.
Reads with a nil gas context: an invariant must not perturb metering. Callers outside this package need this because the account store key is unexported, and probing /a/ through another module's store handle would silently read the wrong store if the two were ever mounted separately.
func (AccountKeeper) InitGenesis ¶
func (ak AccountKeeper) InitGenesis(ctx sdk.Context, data GenesisState)
InitGenesis - Init store state from genesis data
func (AccountKeeper) IterateAccountEntries ¶
func (ak AccountKeeper) IterateAccountEntries(ctx sdk.Context, cb func(AccountEntry) bool) error
IterateAccountEntries walks every key under AddressStoreKeyPrefix — regular and session alike, unfiltered — surfacing decode failures instead of panicking.
For invariants and offline tooling. Ordinary code wants IterateAccounts, which filters to regular accounts and panics on a value it cannot decode. Iteration is gas-free; see HasAccount.
Returns an error if the iteration itself failed. A store iterator can fail mid-sweep — the bptree store panics from Valid()/Close() if the error is never read, and the iavl store reports nothing at all, which reads as silent truncation. Callers must therefore report a non-nil error rather than concluding the keyspace is healthy.
func (AccountKeeper) IterateAccounts ¶
IterateAccounts implements AccountKeeper. It iterates over regular accounts only — session accounts (which are also stored under the "/a/" prefix at /a/<master>/s/<session>) are skipped by checking key length. Regular account keys are exactly AccountStoreKeyLen bytes; session sub-keys are longer.
func (AccountKeeper) IterateSessions ¶
func (ak AccountKeeper) IterateSessions(ctx sdk.Context, master crypto.Address, cb func(std.Account) bool)
IterateSessions iterates over all sessions of a master account.
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) NewAccountWithUncheckedNumber ¶
func (ak AccountKeeper) NewAccountWithUncheckedNumber(ctx sdk.Context, addr crypto.Address, accNum uint64) std.Account
NewAccountWithUncheckedNumber creates an account with a specific account number, bypassing the auto-increment counter. Updates the global counter if the given number would cause future collisions.
PRECONDITION (caller-enforced): the (addr, accNum) pair MUST be unique across all accounts. The keeper does NOT verify that addr is unused or that accNum is unassigned to a different address. A future call with the same accNum but a different addr will silently corrupt account identity (zeroing balances at the original address), and a call with an existing addr will overwrite the existing account.
Intended use: one-shot hardfork genesis replay where the caller (see gno.land/pkg/gnoland.loadAppState) does its own preflight validation across all SignerInfo entries and balance-init accounts. Do NOT call from any post-genesis code path without re-implementing that preflight.
func (AccountKeeper) NewSessionAccount ¶
func (ak AccountKeeper) NewSessionAccount(ctx sdk.Context, master crypto.Address, pubKey crypto.PubKey) std.Account
NewSessionAccount creates a new session account using the session prototype.
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) RemoveAllSessions ¶
func (ak AccountKeeper) RemoveAllSessions(ctx sdk.Context, master crypto.Address)
RemoveAllSessions deletes all session accounts for a master via prefix delete.
func (AccountKeeper) RemoveSessionAccount ¶
func (ak AccountKeeper) RemoveSessionAccount(ctx sdk.Context, master, session crypto.Address)
RemoveSessionAccount deletes a session account.
func (AccountKeeper) SetAccount ¶
func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc std.Account)
SetAccount implements AccountKeeper.
func (AccountKeeper) SetFeesCollectorAddress ¶
func (ak AccountKeeper) SetFeesCollectorAddress(ctx sdk.Context, addr crypto.Address)
func (AccountKeeper) SetParams ¶
func (ak AccountKeeper) SetParams(ctx sdk.Context, params Params) error
func (AccountKeeper) SetSessionAccount ¶
SetSessionAccount stores a session account at /a/<master>/s/<session>.
func (AccountKeeper) WillSetParam ¶
func (ak AccountKeeper) WillSetParam(ctx sdk.Context, key string, value any)
type AccountKeeperI ¶
type AccountKeeperI interface {
NewAccountWithAddress(ctx sdk.Context, addr crypto.Address) std.Account
NewAccountWithUncheckedNumber(ctx sdk.Context, addr crypto.Address, accNum uint64) std.Account
GetNextAccountNumber(ctx sdk.Context) uint64
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 AccountKeyKind ¶
type AccountKeyKind int
AccountKeyKind classifies a key under AddressStoreKeyPrefix.
const ( // AccountKeyRegular is /a/<addr>, what IterateAccounts enumerates. AccountKeyRegular AccountKeyKind = iota // AccountKeySession is /a/<master>/s/<session>. AccountKeySession // AccountKeyUnknown is neither, so no iterator enumerates it. Such a key is // invisible to IterateAccounts, which filters on length. AccountKeyUnknown )
func ParseAccountKey ¶
func ParseAccountKey(key []byte) (kind AccountKeyKind, master, addr crypto.Address)
ParseAccountKey classifies a key under AddressStoreKeyPrefix. master is zero for a regular key.
Length alone is not enough to classify: a key can be exactly session length without having the /s/ infix, and a length-only classifier would then hand it to a session decoder.
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 {
// GetCoin reads one denom without touching any other. The fee check needs
// it because a balance does not necessarily live in the account object —
// realm-issued denoms have their own keys — so it cannot be read from
// std.Account.
GetCoin(ctx sdk.Context, addr crypto.Address, denom string) int64
SendCoins(ctx sdk.Context, fromAddr crypto.Address, toAddr crypto.Address, amt std.Coins) error
SendCoinsUnrestricted(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, prmk params.ParamsKeeperI) DummyBankKeeper
NewDummyBankKeeper creates a DummyBankKeeper instance
func (DummyBankKeeper) GetCoin ¶
GetCoin mirrors the real keeper's per-denom read. The dummy keeps every balance in the account object, so it reads from there.
func (DummyBankKeeper) SendCoins ¶
func (bankk DummyBankKeeper) SendCoins(ctx sdk.Context, fromAddr crypto.Address, toAddr crypto.Address, amt std.Coins) error
SendCoins for the dummy supply keeper
func (DummyBankKeeper) SendCoinsUnrestricted ¶
func (DummyBankKeeper) WillSetParam ¶
func (bankk DummyBankKeeper) WillSetParam(ctx sdk.Context, key string, value any)
WillSetParam checks if the key contains the module's parameter key prefix and updates the module parameter accordingly.
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 GenesisReplayKey ¶
type GenesisReplayKey struct{}
GenesisReplayKey is a context key marking a tx delivery as part of an InitChain genesis replay. During a hardfork replay, historical and patched txs carry a BlockHeight > 0 (overridden for faithful re-execution), so the ctx.BlockHeight()==0 genesis check under-reports them; this key covers those txs.
It never bypasses signature verification on its own: the ante skips verification for a replay tx only when the node was also started with --skip-genesis-sig-verification (VerifyGenesisSignatures=false). In a normally-configured node that flag is unset, so this key has no effect on signature verification. Set only by gnoland's InitChainer per-tx delivery wrapper.
type GenesisState ¶
type GenesisState struct {
Params Params `json:"params" yaml:"params"`
}
GenesisState - all 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
func (GenesisState) MarshalBinary2 ¶
func (GenesisState) SizeBinary2 ¶
func (goo GenesisState) SizeBinary2(cdc *amino.Codec) (int, error)
func (*GenesisState) UnmarshalBinary2 ¶
type MsgCreateSession ¶
type MsgCreateSession struct {
Creator crypto.Address `json:"creator" yaml:"creator"`
SessionKey crypto.PubKey `json:"session_key" yaml:"session_key"`
ExpiresAt int64 `json:"expires_at" yaml:"expires_at"` // unix timestamp; 0 = no expiry
AllowPaths []string `json:"allow_paths,omitempty" yaml:"allow_paths"` // typed entries: "*" or <route>/<type>[:<path>]; required (gno.land-specific grammar)
SpendLimit std.Coins `json:"spend_limit,omitempty" yaml:"spend_limit"` // max spend per period; empty = no spending
SpendPeriod int64 `json:"spend_period,omitempty" yaml:"spend_period"` // seconds; 0 = lifetime cap
}
MsgCreateSession creates a new session key on the creator's account.
ExpiresAt is a unix timestamp; 0 means no expiry (valid until revoked). SpendLimit caps coin spending per period (gas fees, MsgCall.Send, etc.). Empty SpendLimit means no spending is allowed — the session can only sign txs where another signer pays gas, or call functions with zero Send. SpendPeriod is in seconds; 0 means SpendLimit is a lifetime cap.
func (MsgCreateSession) GetSignBytes ¶
func (msg MsgCreateSession) GetSignBytes() []byte
func (MsgCreateSession) GetSigners ¶
func (msg MsgCreateSession) GetSigners() []crypto.Address
func (MsgCreateSession) MarshalBinary2 ¶
func (MsgCreateSession) Route ¶
func (msg MsgCreateSession) Route() string
func (MsgCreateSession) SizeBinary2 ¶
func (goo MsgCreateSession) SizeBinary2(cdc *amino.Codec) (int, error)
func (MsgCreateSession) Type ¶
func (msg MsgCreateSession) Type() string
func (*MsgCreateSession) UnmarshalBinary2 ¶
func (MsgCreateSession) ValidateBasic ¶
func (msg MsgCreateSession) ValidateBasic() error
type MsgRevokeAllSessions ¶
MsgRevokeAllSessions removes all sessions from the creator's account.
func (MsgRevokeAllSessions) GetSignBytes ¶
func (msg MsgRevokeAllSessions) GetSignBytes() []byte
func (MsgRevokeAllSessions) GetSigners ¶
func (msg MsgRevokeAllSessions) GetSigners() []crypto.Address
func (MsgRevokeAllSessions) MarshalBinary2 ¶
func (MsgRevokeAllSessions) Route ¶
func (msg MsgRevokeAllSessions) Route() string
func (MsgRevokeAllSessions) SizeBinary2 ¶
func (goo MsgRevokeAllSessions) SizeBinary2(cdc *amino.Codec) (int, error)
func (MsgRevokeAllSessions) Type ¶
func (msg MsgRevokeAllSessions) Type() string
func (*MsgRevokeAllSessions) UnmarshalBinary2 ¶
func (MsgRevokeAllSessions) ValidateBasic ¶
func (msg MsgRevokeAllSessions) ValidateBasic() error
type MsgRevokeSession ¶
type MsgRevokeSession struct {
Creator crypto.Address `json:"creator" yaml:"creator"`
SessionKey crypto.PubKey `json:"session_key" yaml:"session_key"`
}
MsgRevokeSession removes a specific session from the creator's account.
func (MsgRevokeSession) GetSignBytes ¶
func (msg MsgRevokeSession) GetSignBytes() []byte
func (MsgRevokeSession) GetSigners ¶
func (msg MsgRevokeSession) GetSigners() []crypto.Address
func (MsgRevokeSession) MarshalBinary2 ¶
func (MsgRevokeSession) Route ¶
func (msg MsgRevokeSession) Route() string
func (MsgRevokeSession) SizeBinary2 ¶
func (goo MsgRevokeSession) SizeBinary2(cdc *amino.Codec) (int, error)
func (MsgRevokeSession) Type ¶
func (msg MsgRevokeSession) Type() string
func (*MsgRevokeSession) UnmarshalBinary2 ¶
func (MsgRevokeSession) ValidateBasic ¶
func (msg MsgRevokeSession) ValidateBasic() error
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"`
UnrestrictedAddrs []crypto.Address `json:"unrestricted_addrs" yaml:"unrestricted_addrs"`
FeeCollector crypto.Address `json:"fee_collector" yaml:"fee_collector"`
}
Params defines the parameters for the auth module.
func NewParams ¶
func NewParams(maxMemoBytes, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1, gasPricesChangeCompressor, targetGasRatio int64, feeCollector crypto.Address, ) Params
NewParams creates a new Params object
func (Params) MarshalBinary2 ¶
func (*Params) UnmarshalBinary2 ¶
type SessionAccountSetter ¶
type SessionAccountSetter interface {
SetSessionAccount(ctx sdk.Context, master crypto.Address, acc std.Account)
}
SessionAccountSetter can persist session accounts after spend deduction.
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
type SkipGasMeteringKey ¶
type SkipGasMeteringKey struct{}
SkipGasMeteringKey is a context key used to bypass gas metering for historical tx replay during chain upgrades. When set on the context, SetGasMeter installs an infinite gas meter even for non-genesis blocks. Used by gnoland's GasReplayMode="source" during genesis replay to preserve source-chain outcomes when gas requirements have changed.