-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Closes: #1910 This covers most cases by serializing the actual broadcasts to the consensus node and enabling resubmissions in the case that there is a sequence mismatch. This covers most fail cases with the possible exception of proposal nodes receiving the transactions in the reverse order to the initial nodes that the user broadcasted to There are also some interesting side affects that need to be handled when an existing accepted transaction is later kicked out of the mempool via CheckTx but overall I think this is a huge improvement for the UX of users<hr>This is an automatic backport of pull request #3196 done by [Mergify](https://mergify.com). Co-authored-by: Callum Waters <[email protected]>
- Loading branch information
1 parent
1ada3c2
commit 4118c49
Showing
7 changed files
with
417 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package user_test | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"sync" | ||
"testing" | ||
"time" | ||
|
||
"github.com/celestiaorg/celestia-app/app" | ||
"github.com/celestiaorg/celestia-app/app/encoding" | ||
"github.com/celestiaorg/celestia-app/pkg/appconsts" | ||
"github.com/celestiaorg/celestia-app/pkg/user" | ||
"github.com/celestiaorg/celestia-app/test/util/blobfactory" | ||
"github.com/celestiaorg/celestia-app/test/util/testnode" | ||
"github.com/stretchr/testify/require" | ||
tmrand "github.com/tendermint/tendermint/libs/rand" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
) | ||
|
||
func TestConcurrentTxSubmission(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("skipping in short mode") | ||
} | ||
|
||
// Setup network | ||
tmConfig := testnode.DefaultTendermintConfig() | ||
tmConfig.Consensus.TimeoutCommit = 10 * time.Second | ||
ctx, _, _ := testnode.NewNetwork(t, testnode.DefaultConfig().WithTendermintConfig(tmConfig)) | ||
_, err := ctx.WaitForHeight(1) | ||
require.NoError(t, err) | ||
|
||
// Setup signer | ||
signer, err := newSingleSignerFromContext(ctx) | ||
require.NoError(t, err) | ||
|
||
// Pregenerate all the blobs | ||
numTxs := 10 | ||
blobs := blobfactory.ManyRandBlobs(t, tmrand.NewRand(), blobfactory.Repeat(2048, numTxs)...) | ||
|
||
// Prepare transactions | ||
var ( | ||
wg sync.WaitGroup | ||
errCh = make(chan error) | ||
) | ||
|
||
subCtx, cancel := context.WithCancel(ctx.GoContext()) | ||
defer cancel() | ||
time.AfterFunc(time.Minute, cancel) | ||
for i := 0; i < numTxs; i++ { | ||
wg.Add(1) | ||
go func(b *tmproto.Blob) { | ||
defer wg.Done() | ||
_, err := signer.SubmitPayForBlob(subCtx, []*tmproto.Blob{b}, user.SetGasLimitAndFee(500_000, appconsts.DefaultMinGasPrice)) | ||
if err != nil && !errors.Is(err, context.Canceled) { | ||
// only catch the first error | ||
select { | ||
case errCh <- err: | ||
cancel() | ||
default: | ||
} | ||
} | ||
}(blobs[i]) | ||
} | ||
wg.Wait() | ||
|
||
select { | ||
case err := <-errCh: | ||
require.NoError(t, err) | ||
default: | ||
} | ||
} | ||
|
||
func newSingleSignerFromContext(ctx testnode.Context) (*user.Signer, error) { | ||
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...) | ||
record, err := ctx.Keyring.Key("validator") | ||
if err != nil { | ||
return nil, err | ||
} | ||
address, err := record.GetAddress() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return user.SetupSigner(ctx.GoContext(), ctx.Keyring, ctx.GRPCClient, address, encCfg) | ||
} |
Oops, something went wrong.