Documentation
¶
Index ¶
- Constants
- func EncodeTx(encCache *EncoderCache, enc sdk.TxEncoder, tx sdk.Tx) (bz []byte, hit bool, err error)
- func NewCachingDecoder(base sdk.TxDecoder, cache *DecodeCache) sdk.TxDecoder
- func NewReapTxsHandler(mpool mempool.Mempool, txEncoder sdk.TxEncoder, encCache *EncoderCache, ...) sdk.ReapTxsHandler
- func PoolSnapshot(ctx context.Context, mp sdkmempool.Mempool) []sdk.Tx
- func ProtoSizeForTx(bz []byte) int64
- func UnorderedPoolSnapshot(ctx context.Context, mp sdkmempool.Mempool) []sdk.Tx
- type DecodeCache
- type EncoderCache
- type FinalizeNeutralMempool
- type Manager
- func (a *Manager) AdmissionMutex() *sync.Mutex
- func (a *Manager) CheckTxHandler() sdk.CheckTxHandler
- func (a *Manager) Close()
- func (a *Manager) CountTx() int
- func (a *Manager) InsertTx(txBytes []byte) (*sdk.TxResponse, error)
- func (a *Manager) InsertTxHandler() sdk.InsertTxHandler
- func (a *Manager) PendingTxs() []sdk.Tx
- func (a *Manager) RecheckDisabled() bool
- func (a *Manager) RecheckTxs()
- func (a *Manager) SetAnteCache(ac *antecache.AnteCache)
- func (a *Manager) SetPreVerify(fn func([]byte) error)
- func (a *Manager) StageRecheckSenders(height int64, txs [][]byte)
- func (a *Manager) StageSkippedSenders(txs [][]byte)
- func (a *Manager) TriggerRecheck()
- func (a *Manager) WaitForRecheck(ctx context.Context)
- func (a *Manager) WaitForRecheckTimedOut(ctx context.Context, timeout time.Duration) bool
- type MsgSignerExtractionAdapter
- type PreVerifierRegistry
- type PubKeyPolicy
Constants ¶
const TypeApp = "app"
Variables ¶
This section is empty.
Functions ¶
func EncodeTx ¶
func EncodeTx(encCache *EncoderCache, enc sdk.TxEncoder, tx sdk.Tx) (bz []byte, hit bool, err error)
EncodeTx returns the raw bytes of a transaction, prioritizing the cache if available.
func NewCachingDecoder ¶
func NewCachingDecoder(base sdk.TxDecoder, cache *DecodeCache) sdk.TxDecoder
NewCachingDecoder wraps base with the shared cache, so PrepareProposal and BaseApp.runTx reuse each other's decodes.
func NewReapTxsHandler ¶
func NewReapTxsHandler(mpool mempool.Mempool, txEncoder sdk.TxEncoder, encCache *EncoderCache, ttl time.Duration, maxPerReap int, logger log.Logger) sdk.ReapTxsHandler
NewReapTxsHandler scans the app mempool to gather txs to be gossiped to other peers, stopping at MaxBytes/MaxGas (0 = no cap, per CometBFT convention). Prefix scan: breaks at the first tx over a cap (not best-fit), so a large high-priority tx may leave budget unused. Encode errors and per-tx panics skip the tx; a pool-scan panic returns an empty reap. encCache hits skip proto.Marshal.
func PoolSnapshot ¶
PoolSnapshot returns a snapshot of the current mempool transactions.
func ProtoSizeForTx ¶
ProtoSizeForTx returns the wire size one tx contributes to a CometBFT block's Data message. Same result as cmttypes.ComputeProtoSizeForTxs([]cmttypes.Tx{bz}) but without its ~4 allocs/tx ([]Tx slice + Data{}.ToProto) in the proposal hot loop. Data.Txs is `repeated bytes txs = 1`: each element is a 1-byte field tag + varint length + payload, matching gogoproto's generated Size().
func UnorderedPoolSnapshot ¶
UnorderedPoolSnapshot returns pooled txs without priority ordering.
Types ¶
type DecodeCache ¶
type DecodeCache struct {
// contains filtered or unexported fields
}
DecodeCache is a sharded LRU cache of decoded txs. Returned sdk.Tx pointers are shared across consumers (PrepareProposal, runTx, CheckTx) — callers MUST NOT mutate them. Safe today because decode is the only writer: the EVM ante's VerifySender only compares against MsgEthereumTx.From (set at proto-decode), never writes it. A future ante that mutates a decoded msg would break sharing. Exception: encoding fills empty body/auth-info bytes; Manager.encodeMu serializes that.
func NewDecodeCache ¶
func NewDecodeCache(size, maxTxBytes uint) *DecodeCache
NewDecodeCache returns a cache with total capacity ~size and per-entry payload cap maxTxBytes. Pass 0 for either to use defaults.
type EncoderCache ¶
type EncoderCache struct {
// contains filtered or unexported fields
}
EncoderCache caches tx encoding
func NewEncoderCache ¶
func NewEncoderCache(size, maxTxBytes uint) *EncoderCache
NewEncoderCache returns an LRU-bounded cache holding at most size entries, skipping txs whose canonical bytes exceed maxTxBytes (mirrors DecodeCache). Pass 0 for size or maxTxBytes to fall back to the cmdcfg defaults.
func (*EncoderCache) Evict ¶
func (e *EncoderCache) Evict(tx sdk.Tx)
Evict drops tx's entry so a stale/removed tx stops pinning the heap. No op if tx is absent.
func (*EncoderCache) Get ¶
func (e *EncoderCache) Get(tx sdk.Tx) ([]byte, bool)
Get returns a copy of the registered bytes for tx, promoting it to MRU. Safe on a nil *EncoderCache (returns nil, false). Copies because the bytes escape into block proposals/reap/ReCheck; sharing the internal slice would let a caller corrupt every hit.
func (*EncoderCache) HashTx ¶
func (e *EncoderCache) HashTx(tx sdk.Tx, bz []byte) [32]byte
HashTx returns sha256(bz), caching it on tx's entry so repeated reaps don't re-hash the same canonical bytes. bz must be the canonical bytes EncodeTx returned for tx. Safe on a nil receiver (hashes without caching). The hash is computed outside the lock so a slow hash never blocks admission's Set.
type FinalizeNeutralMempool ¶ added in v1.8.2
type FinalizeNeutralMempool struct {
*sdkmempool.PriorityNonceMempool[int64]
// contains filtered or unexported fields
}
FinalizeNeutralMempool keeps a block tx's result independent of the local pool. runTx fails the tx on any finalize-mode removal error but ErrTxNotFound, and NoOp-mempool nodes never fail, so any other outcome here would make results depend on mempool config.
func NewFinalizeNeutralMempool ¶ added in v1.8.2
func NewFinalizeNeutralMempool(pool *sdkmempool.PriorityNonceMempool[int64], logger log.Logger) FinalizeNeutralMempool
func (FinalizeNeutralMempool) RemoveWithReason ¶ added in v1.8.2
func (p FinalizeNeutralMempool) RemoveWithReason(ctx context.Context, tx sdk.Tx, reason sdkmempool.RemoveReason) error
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns the app-side mempool for mempool.type=app
func NewManager ¶
func NewManager(app *baseapp.BaseApp, logger log.Logger, encCache *EncoderCache, txEncoder sdk.TxEncoder, mpool sdkmempool.Mempool, signer sdkmempool.SignerExtractionAdapter, decoder sdk.TxDecoder, recheckBatchSize int, ttlNumBlocks int64, recheckDisabled, pendingCacheEnabled bool) *Manager
NewManager builds the Manager for mempool.type=app.
func (*Manager) AdmissionMutex ¶
AdmissionMutex exposes mu so App.Commit can serialize its checkState reset against lock-free admission.
func (*Manager) CheckTxHandler ¶
func (a *Manager) CheckTxHandler() sdk.CheckTxHandler
CheckTxHandler runs RPC CheckTx.
func (*Manager) InsertTx ¶
func (a *Manager) InsertTx(txBytes []byte) (*sdk.TxResponse, error)
InsertTx returns the sync ABCI result; error is always nil (failures surface as ABCI codes).
func (*Manager) InsertTxHandler ¶
func (a *Manager) InsertTxHandler() sdk.InsertTxHandler
InsertTxHandler validates peer-relayed txs via RunTx(ExecModeCheck) before admitting them.
func (*Manager) PendingTxs ¶
PendingTxs returns a snapshot of pooled txs, safe for the caller to mutate.
func (*Manager) RecheckDisabled ¶
RecheckDisabled reports whether mempool recheck is disabled
func (*Manager) RecheckTxs ¶
func (a *Manager) RecheckTxs()
RecheckTxs evicts pool txs invalidated by the last block.
func (*Manager) SetAnteCache ¶
SetAnteCache wires the ante-layer nonce cache so evict can clear a tx's entries.
func (*Manager) SetPreVerify ¶
SetPreVerify sets the pre-verification hook.
func (*Manager) StageRecheckSenders ¶
StageRecheckSenders records committed-block senders for RecheckTxs and stages the committed height.
func (*Manager) StageSkippedSenders ¶
StageSkippedSenders merges the senders of proposal-gate-rejected txs into recheckSenders without touching lastCommittedHeight
func (*Manager) TriggerRecheck ¶
func (a *Manager) TriggerRecheck()
TriggerRecheck schedules an async recheck. Call only from the consensus path (App.Commit).
func (*Manager) WaitForRecheck ¶
WaitForRecheck blocks until the pending recheck finishes;
type MsgSignerExtractionAdapter ¶ added in v1.8.2
type MsgSignerExtractionAdapter struct {
// contains filtered or unexported fields
}
MsgSignerExtractionAdapter is the SDK default adapter, except it takes each signer from the tx's msg signers instead of its SignerInfo public key, which the SDK adapter panics on when missing or malformed.
func NewMsgSignerExtractionAdapter ¶ added in v1.8.2
func NewMsgSignerExtractionAdapter(policy PubKeyPolicy) MsgSignerExtractionAdapter
func (MsgSignerExtractionAdapter) GetSigners ¶ added in v1.8.2
func (a MsgSignerExtractionAdapter) GetSigners(tx sdk.Tx) ([]sdkmempool.SignerData, error)
type PreVerifierRegistry ¶
type PreVerifierRegistry struct {
// contains filtered or unexported fields
}
PreVerifierRegistry collects lock-free admission pre-verifiers contributed by modules. The app composes them and hands Verify to the mempool manager, which runs it before the admission mutex (mempool.type=app). First rejection wins; a nil result defers to the locked admission path.
func (*PreVerifierRegistry) Register ¶
func (r *PreVerifierRegistry) Register(v func([]byte) error)
Register adds a pre-verifier; nil is ignored.
func (*PreVerifierRegistry) Verify ¶
func (r *PreVerifierRegistry) Verify(raw []byte) error
Verify runs the registered pre-verifiers, returning the first rejection or nil.
type PubKeyPolicy ¶ added in v1.8.2
type PubKeyPolicy int
PubKeyPolicy sets whether MsgSignerExtractionAdapter accepts a SignerInfo without a public key.
const ( // PubKeyIgnore accepts it: a missing key is valid once the signer's key is on-chain. PubKeyIgnore PubKeyPolicy = iota // PubKeyRequire rejects it; a malformed key is left to ante. PubKeyRequire )