Documentation ¶
Index ¶
- func DefaultPriorityMempool() mempool.Mempool
- func IsEmpty(mempool mempool.Mempool) error
- func NoOpPrepareProposal() sdk.PrepareProposalHandler
- func NoOpProcessProposal() sdk.ProcessProposalHandler
- type CustomProposalHandler
- type GasTx
- type PriorityNonceIterator
- type PriorityNonceMempool
- func (mp *PriorityNonceMempool) CountTx() int
- func (mp *PriorityNonceMempool) Insert(ctx context.Context, tx sdk.Tx) error
- func (mp *PriorityNonceMempool) NextSenderTx(sender string) sdk.Tx
- func (mp *PriorityNonceMempool) Remove(tx sdk.Tx) error
- func (mp *PriorityNonceMempool) Select(_ context.Context, _ [][]byte) mempool.Iterator
- type PriorityNonceMempoolOption
- type ProposalTxVerifier
- type SenderWithNonce
- type TxSelector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPriorityMempool ¶
DefaultPriorityMempool returns a priorityNonceMempool with no options.
func NoOpPrepareProposal ¶
func NoOpPrepareProposal() sdk.PrepareProposalHandler
NoOpPrepareProposal defines a no-op PrepareProposal handler. It will always return the transactions sent by the client's request.
func NoOpProcessProposal ¶
func NoOpProcessProposal() sdk.ProcessProposalHandler
NoOpProcessProposal defines a no-op ProcessProposal Handler. It will always return ACCEPT.
Types ¶
type CustomProposalHandler ¶
type CustomProposalHandler struct {
// contains filtered or unexported fields
}
CustomProposalHandler defines the default ABCI PrepareProposal and ProcessProposal handlers.
func NewCustomProposalHandler ¶
func NewCustomProposalHandler(mp mempool.Mempool, txVerifier ProposalTxVerifier) *CustomProposalHandler
func (*CustomProposalHandler) PrepareProposalHandler ¶
func (h *CustomProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler
PrepareProposalHandler returns the default implementation for processing an ABCI proposal. The application's mempool is enumerated and all valid transactions are added to the proposal. Transactions are valid if they:
1) Successfully encode to bytes. 2) Are valid (i.e. pass runTx, AnteHandler only).
Enumeration is halted once RequestPrepareProposal.MaxBytes of transactions is reached or the mempool is exhausted.
Note:
- Step (2) is identical to the validation step performed in DefaultProcessProposal. It is very important that the same validation logic is used in both steps, and applications must ensure that this is the case in non-default handlers.
- If no mempool is set or if the mempool is a no-op mempool, the transactions requested from CometBFT will simply be returned, which, by default, are in FIFO order.
func (*CustomProposalHandler) ProcessProposalHandler ¶
func (h *CustomProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler
ProcessProposalHandler returns the default implementation for processing an ABCI proposal. Every transaction in the proposal must pass 2 conditions:
1. The transaction bytes must decode to a valid transaction. 2. The transaction must be valid (i.e. pass runTx, AnteHandler only)
If any transaction fails to pass either condition, the proposal is rejected. Note that step (2) is identical to the validation step performed in DefaultPrepareProposal. It is very important that the same validation logic is used in both steps, and applications must ensure that this is the case in non-default handlers.
func (*CustomProposalHandler) SetTxSelector ¶
func (h *CustomProposalHandler) SetTxSelector(ts TxSelector)
SetTxSelector sets the TxSelector function on the CustomProposalHandler.
type GasTx ¶
type GasTx interface {
GetGas() uint64
}
GasTx defines the contract that a transaction with a gas limit must implement.
type PriorityNonceIterator ¶
type PriorityNonceIterator struct {
// contains filtered or unexported fields
}
func (*PriorityNonceIterator) Next ¶
func (i *PriorityNonceIterator) Next() mempool.Iterator
func (*PriorityNonceIterator) Tx ¶
func (i *PriorityNonceIterator) Tx() sdk.Tx
type PriorityNonceMempool ¶
type PriorityNonceMempool struct {
// contains filtered or unexported fields
}
PriorityNonceMempool is a mempool implementation that stores txs in a partially ordered set by 2 dimensions: priority, and sender-nonce (sequence number). Internally it uses one priority ordered skip list and one skip list per sender ordered by sender-nonce (sequence number). When there are multiple txs from the same sender, they are not always comparable by priority to other sender txs and must be partially ordered by both sender-nonce and priority.
func NewPriorityMempool ¶
func NewPriorityMempool(opts ...PriorityNonceMempoolOption) *PriorityNonceMempool
NewPriorityMempool returns the SDK's default mempool implementation which returns txs in a partial order by 2 dimensions; priority, and sender-nonce.
func (*PriorityNonceMempool) CountTx ¶
func (mp *PriorityNonceMempool) CountTx() int
CountTx returns the number of transactions in the mempool.
func (*PriorityNonceMempool) Insert ¶
Insert attempts to insert a Tx into the app-side mempool in O(log n) time, returning an error if unsuccessful. Sender and nonce are derived from the transaction's first signature.
Transactions are unique by sender and nonce. Inserting a duplicate tx is an O(log n) no-op.
Inserting a duplicate tx with a different priority overwrites the existing tx, changing the total order of the mempool.
func (*PriorityNonceMempool) NextSenderTx ¶
func (mp *PriorityNonceMempool) NextSenderTx(sender string) sdk.Tx
NextSenderTx returns the next transaction for a given sender by nonce order, i.e. the next valid transaction for the sender. If no such transaction exists, nil will be returned.
func (*PriorityNonceMempool) Remove ¶
func (mp *PriorityNonceMempool) Remove(tx sdk.Tx) error
Remove removes a transaction from the mempool in O(log n) time, returning an error if unsuccessful.
func (*PriorityNonceMempool) Select ¶
Select returns a set of transactions from the mempool, ordered by priority and sender-nonce in O(n) time. The passed in list of transactions are ignored. This is a readonly operation, the mempool is not modified.
The maxBytes parameter defines the maximum number of bytes of transactions to return.
NOTE: It is not safe to use this iterator while removing transactions from the underlying mempool.
type PriorityNonceMempoolOption ¶
type PriorityNonceMempoolOption func(*PriorityNonceMempool)
func PriorityNonceWithMaxTx ¶
func PriorityNonceWithMaxTx(maxTx int) PriorityNonceMempoolOption
PriorityNonceWithMaxTx sets the maximum number of transactions allowed in the mempool with the semantics:
<0: disabled, `Insert` is a no-op 0: unlimited >0: maximum number of transactions allowed
func PriorityNonceWithOnRead ¶
func PriorityNonceWithOnRead(onRead func(tx sdk.Tx)) PriorityNonceMempoolOption
PriorityNonceWithOnRead sets a callback to be called when a tx is read from the mempool.
func PriorityNonceWithTxReplacement ¶
func PriorityNonceWithTxReplacement( txReplacementRule func(op, np int64, oTx, nTx sdk.Tx) bool, ) PriorityNonceMempoolOption
PriorityNonceWithTxReplacement sets a callback to be called when duplicated transaction nonce detected during mempool insert. An application can define a transaction replacement rule based on tx priority or certain transaction fields.
type ProposalTxVerifier ¶
type ProposalTxVerifier interface { PrepareProposalVerifyTx(tx sdk.Tx) ([]byte, error) ProcessProposalVerifyTx(txBz []byte) (sdk.Tx, error) }
ProposalTxVerifier defines the interface that is implemented by BaseApp, that any custom ABCI PrepareProposal and ProcessProposal handler can use to verify a transaction.
type SenderWithNonce ¶
func GetSendersWithNonce ¶
func GetSendersWithNonce(tx sdk.Tx) ([]SenderWithNonce, error)
GetSendersWithNonce is used to extract sender and nonce information txs if tx is ethermint, it is extracted using from and nonce field if it's cosmos tx, default cosmos way using signatures is used
type TxSelector ¶
type TxSelector interface { // SelectedTxs should return a copy of the selected transactions. SelectedTxs() [][]byte // Clear should clear the TxSelector, nulling out all relevant fields. Clear() // SelectTxForProposal should attempt to select a transaction for inclusion in // a proposal based on inclusion criteria defined by the TxSelector. It must // return <true> if the caller should halt the transaction selection loop // (typically over a mempool) or <false> otherwise. SelectTxForProposal(maxTxBytes, maxBlockGas uint64, memTx sdk.Tx, txBz []byte) bool }
TxSelector defines a helper type that assists in selecting transactions during mempool transaction selection in PrepareProposal. It keeps track of the total number of bytes and total gas of the selected transactions. It also keeps track of the selected transactions themselves.
func NewDefaultTxSelector ¶
func NewDefaultTxSelector() TxSelector