diff --git a/client/broadcast.go b/client/broadcast.go index 5598cbcebaa1..bc5f65d8f2e9 100644 --- a/client/broadcast.go +++ b/client/broadcast.go @@ -78,6 +78,13 @@ func CheckCometError(err error, tx cmttypes.Tx) *sdk.TxResponse { TxHash: txHash, } + case strings.Contains(errStr, "mempool rate limit exceeded"): + return &sdk.TxResponse{ + Code: sdkerrors.ErrMempoolRateLimitExceeded.ABCICode(), + Codespace: sdkerrors.ErrMempoolRateLimitExceeded.Codespace(), + TxHash: txHash, + } + default: return nil } diff --git a/client/broadcast_test.go b/client/broadcast_test.go index fcd7d1d604ac..248ba3a31451 100644 --- a/client/broadcast_test.go +++ b/client/broadcast_test.go @@ -39,9 +39,10 @@ func CreateContextWithErrorAndMode(err error, mode string) Context { // Test the correct code is returned when func TestBroadcastError(t *testing.T) { errors := map[error]uint32{ - mempool.ErrTxInCache: sdkerrors.ErrTxInMempoolCache.ABCICode(), - mempool.ErrTxTooLarge{}: sdkerrors.ErrTxTooLarge.ABCICode(), - mempool.ErrMempoolIsFull{}: sdkerrors.ErrMempoolIsFull.ABCICode(), + mempool.ErrTxInCache: sdkerrors.ErrTxInMempoolCache.ABCICode(), + mempool.ErrTxTooLarge{}: sdkerrors.ErrTxTooLarge.ABCICode(), + mempool.ErrMempoolIsFull{}: sdkerrors.ErrMempoolIsFull.ABCICode(), + mempool.ErrMempoolRateLimitExceeded{}: sdkerrors.ErrMempoolRateLimitExceeded.ABCICode(), } modes := []string{ diff --git a/errors/errors_test.go b/errors/errors_test.go index 48a978c8f3b7..57a8f5d229b5 100644 --- a/errors/errors_test.go +++ b/errors/errors_test.go @@ -256,4 +256,6 @@ var ( ErrNotSupported = RegisterWithGRPCCode(testCodespace, 37, codes.Unimplemented, "feature not supported") ErrNotFound = RegisterWithGRPCCode(testCodespace, 38, codes.NotFound, "not found") ErrIO = Register(testCodespace, 39, "Internal IO error") + + ErrMempoolRateLimitExceeded = Register(testCodespace, 10001, "mempool rate limit exceeded") ) diff --git a/go.mod b/go.mod index 6ad6f2c94e3d..a5a79daa77df 100644 --- a/go.mod +++ b/go.mod @@ -175,7 +175,7 @@ require ( // replace the store module with the b-harvest fork replace ( cosmossdk.io/store => github.com/b-harvest/cosmos-sdk/store v0.0.0-20241219054141-7fb019ef389e - github.com/cometbft/cometbft => github.com/b-harvest/cometbft v0.0.0-20250114065503-2209f5c8c820 + github.com/cometbft/cometbft => github.com/b-harvest/cometbft v0.0.0-20250117081724-782b0da6a158 ) // Below are the long-lived replace of the Cosmos SDK diff --git a/go.sum b/go.sum index c5b6fe3387f5..46c190bfc360 100644 --- a/go.sum +++ b/go.sum @@ -56,8 +56,8 @@ github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6l github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/b-harvest/cometbft v0.0.0-20250114065503-2209f5c8c820 h1:HSi5iZWa3bzjmJuVMXHSgHr5rxzpGyuaCTkEici0S+8= -github.com/b-harvest/cometbft v0.0.0-20250114065503-2209f5c8c820/go.mod h1:a8NBI2IdO283RZdpH0MuXlze3j+lv6PXuzOtTCq4YGE= +github.com/b-harvest/cometbft v0.0.0-20250117081724-782b0da6a158 h1:08cYQa2CGagj4QX8toaCuVobI0CxpEwF3WS+S7LNIqU= +github.com/b-harvest/cometbft v0.0.0-20250117081724-782b0da6a158/go.mod h1:a8NBI2IdO283RZdpH0MuXlze3j+lv6PXuzOtTCq4YGE= github.com/b-harvest/cosmos-sdk/store v0.0.0-20241219054141-7fb019ef389e h1:e5quTVfHOIYOwKiqDZG9euFWjmEtAMu7m9N6PjlXK4Q= github.com/b-harvest/cosmos-sdk/store v0.0.0-20241219054141-7fb019ef389e/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= diff --git a/simapp/go.mod b/simapp/go.mod index 12275a3d7628..1bab29a436db 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -209,7 +209,7 @@ require ( // replace the store module with the b-harvest fork replace ( cosmossdk.io/store => github.com/b-harvest/cosmos-sdk/store v0.0.0-20241219054141-7fb019ef389e - github.com/cometbft/cometbft => github.com/b-harvest/cometbft v0.0.0-20250114065503-2209f5c8c820 + github.com/cometbft/cometbft => github.com/b-harvest/cometbft v0.0.0-20250117081724-782b0da6a158 ) // Below are the long-lived replace of the SimApp diff --git a/simapp/go.sum b/simapp/go.sum index a66520f66d6f..2d4ecb1ad703 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -256,8 +256,8 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ= github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/b-harvest/cometbft v0.0.0-20250114065503-2209f5c8c820 h1:HSi5iZWa3bzjmJuVMXHSgHr5rxzpGyuaCTkEici0S+8= -github.com/b-harvest/cometbft v0.0.0-20250114065503-2209f5c8c820/go.mod h1:a8NBI2IdO283RZdpH0MuXlze3j+lv6PXuzOtTCq4YGE= +github.com/b-harvest/cometbft v0.0.0-20250117081724-782b0da6a158 h1:08cYQa2CGagj4QX8toaCuVobI0CxpEwF3WS+S7LNIqU= +github.com/b-harvest/cometbft v0.0.0-20250117081724-782b0da6a158/go.mod h1:a8NBI2IdO283RZdpH0MuXlze3j+lv6PXuzOtTCq4YGE= github.com/b-harvest/cosmos-sdk/store v0.0.0-20241219054141-7fb019ef389e h1:e5quTVfHOIYOwKiqDZG9euFWjmEtAMu7m9N6PjlXK4Q= github.com/b-harvest/cosmos-sdk/store v0.0.0-20241219054141-7fb019ef389e/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= diff --git a/types/errors/errors.go b/types/errors/errors.go index 5e17f2df481a..cca4a675da18 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -140,6 +140,10 @@ var ( // supplied. ErrInvalidGasLimit = errorsmod.Register(RootCodespace, 41, "invalid gas limit") + // ErrMempoolRateLimitExceeded defines an error when the mempool rate limit is exceeded. + // Starting at 10001 for future errors added in the cosmos-sdk. + ErrMempoolRateLimitExceeded = errorsmod.Register(RootCodespace, 10001, "mempool rate limit exceeded") + // ErrPanic should only be set when we recovering from a panic ErrPanic = errorsmod.ErrPanic )