Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions chain/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/InjectiveLabs/sdk-go/chain/crypto/ethsecp256k1"
retry "github.com/avast/retry-go/v4"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
cmtrpcjson "github.com/cometbft/cometbft/rpc/jsonrpc/client"
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
cosmoserrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand All @@ -39,7 +41,17 @@ var errRetry = errors.New("retry required")

// TODO: replace with https://github.com/InjectiveLabs/sdk-go/tree/master/client/chain
func NewClient(chainID string, addr string, grpcAddr string) Client {
rpcClient, err := client.NewClientFromNode("tcp://" + addr)
rpcHTTPClient, err := cmtrpcjson.DefaultHTTPClient("tcp://" + addr)
orPanic(err)

// if you're experiencing
if transport, ok := rpcHTTPClient.Transport.(*http.Transport); ok {
transport.MaxIdleConns = 4096
transport.MaxIdleConnsPerHost = 4096
transport.IdleConnTimeout = 90 * time.Second
}

rpcClient, err := rpchttp.NewWithClient("tcp://"+addr, rpcHTTPClient)
orPanic(err)

grpcClient, err := grpc.NewClient(grpcAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
Expand Down Expand Up @@ -302,9 +314,9 @@ func (c Client) Broadcast(ctx context.Context, encodedTx []byte, await bool) (st
}

if !result.alreadyInMempool && result.txHash != "" {
logger.WithFields(log.Fields{
"txHash": result.txHash,
}).Info("🔄 Tx reinserted into mempool")
//logger.WithFields(log.Fields{
// "txHash": result.txHash,
//}).Info("🔄 Tx reinserted into mempool")
return result.txHash, true, nil
}

Expand Down
8 changes: 8 additions & 0 deletions stresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,14 @@ func buildBroadcastClient(config StressConfig) (ratelimit.BroadcastFunc, error)

txHash, err = baseClient.Broadcast(ctx, txBytes, config.AwaitTxConfirmation)
if err != nil {
//if strings.Contains(err.Error(), "already in mempool cache") {
// return nil
//}
//
//if strings.Contains(err.Error(), "transaction already in mempool") {
// return nil
//}

if _, ok := chain.IsSequenceError(err); ok {
return retry.Unrecoverable(err)
}
Expand Down