fix: mempool lane size check on CheckTx (#561)

* push

* init

* fix setup

* format

* fix test

* use lane

* ok

* finalize

* fix everything

* lint fix:

* Update abci/checktx/mempool_parity_check_tx.go

Co-authored-by: David Terpay <35130517+davidterpay@users.noreply.github.com>

* lint fix

* tidy

* remove

* cleanup

---------

Co-authored-by: David Terpay <david.terpay@gmail.com>
Co-authored-by: David Terpay <35130517+davidterpay@users.noreply.github.com>
This commit is contained in:
Alex Johnson
2024-07-02 19:19:22 -04:00
committed by GitHub
co-authored by David Terpay David Terpay
parent 242fdf279d
commit f1cde2acec
35 changed files with 615 additions and 342 deletions
+2 -2
View File
@@ -30,12 +30,12 @@ type BaseLane struct { //nolint
// that are waiting to be processed.
block.LaneMempool
// matchHandler is the function that determines whether or not a transaction
// matchHandler is the function that determines whether a transaction
// should be processed by this lane.
matchHandler MatchHandler
// prepareLaneHandler is the function that is called when a new proposal is being
// requested and the lane needs to submit transactions it wants included in the block.
// requested and the lane needs to submit transactions it wants to be included in the block.
prepareLaneHandler PrepareLaneHandler
// processLaneHandler is the function that is called when a new proposal is being
+1 -1
View File
@@ -9,7 +9,7 @@ import (
// DefaultMatchHandler returns a default implementation of the MatchHandler. It matches all
// transactions.
func DefaultMatchHandler() MatchHandler {
return func(ctx sdk.Context, tx sdk.Tx) bool {
return func(_ sdk.Context, _ sdk.Tx) bool {
return true
}
}
+2 -2
View File
@@ -9,10 +9,10 @@ import (
// DefaultTxPriority
func DefaultTxPriority() TxPriority[int] {
return TxPriority[int]{
GetTxPriority: func(goCtx context.Context, tx sdk.Tx) int {
GetTxPriority: func(_ context.Context, _ sdk.Tx) int {
return 0
},
Compare: func(a, b int) int {
Compare: func(_, _ int) int {
return 0
},
MinValue: 0,
+3 -3
View File
@@ -90,9 +90,9 @@ func (m *LanedMempool) Insert(ctx context.Context, tx sdk.Tx) (err error) {
}
}()
unwrappedCtx := sdk.UnwrapSDKContext(ctx)
sdkCtx := sdk.UnwrapSDKContext(ctx)
for _, lane := range m.registry {
if lane.Match(unwrappedCtx, tx) {
if lane.Match(sdkCtx, tx) {
return lane.Insert(ctx, tx)
}
}
@@ -100,7 +100,7 @@ func (m *LanedMempool) Insert(ctx context.Context, tx sdk.Tx) (err error) {
return nil
}
// Insert returns a nil iterator.
// Select returns a nil iterator.
//
// TODO:
// - Determine if it even makes sense to return an iterator. What does that even
+1 -1
View File
@@ -1,4 +1,4 @@
// Code generated by mockery v2.40.1. DO NOT EDIT.
// Code generated by mockery v2.43.2. DO NOT EDIT.
package mocks
+1 -1
View File
@@ -1,4 +1,4 @@
// Code generated by mockery v2.40.1. DO NOT EDIT.
// Code generated by mockery v2.43.2. DO NOT EDIT.
package mocks
+2 -2
View File
@@ -11,7 +11,7 @@ const (
type (
// LaneLimits defines the constraints for a partial proposal. Each lane must only propose
// transactions that satisfy these constraints. Otherwise the partial proposal update will
// transactions that satisfy these constraints. Otherwise, the partial proposal update will
// be rejected.
LaneLimits struct {
// MaxTxBytes is the maximum number of bytes allowed in the partial proposal.
@@ -26,7 +26,7 @@ func GetBlockLimits(ctx sdk.Context) (int64, uint64) {
blockParams := ctx.ConsensusParams().Block
// If the max gas is set to 0, then the max gas limit for the block can be infinite.
// Otherwise we use the max gas limit casted as a uint64 which is how gas limits are
// Otherwise, we use the max gas limit casted as a uint64 which is how gas limits are
// extracted from sdk.Tx's.
var maxGasLimit uint64
if maxGas := blockParams.MaxGas; maxGas > 0 {
+1 -1
View File
@@ -21,7 +21,7 @@ type (
// NoOpPrepareLanesHandler returns a no-op prepare lanes handler.
// This should only be used for testing.
func NoOpPrepareLanesHandler() PrepareLanesHandler {
return func(ctx sdk.Context, proposal proposals.Proposal) (proposals.Proposal, error) {
return func(_ sdk.Context, proposal proposals.Proposal) (proposals.Proposal, error) {
return proposal, nil
}
}