-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: nonce handling with signer (#3196)
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 (cherry picked from commit deefb54) # Conflicts: # Makefile # app/errors/insufficient_gas_price_test.go # app/errors/nonce_mismatch_test.go # app/test/big_blob_test.go # app/test/priority_test.go # go.work.sum # pkg/user/signer.go # pkg/user/signer_test.go # test/util/blobfactory/payforblob_factory.go # test/util/blobfactory/test_util.go # test/util/direct_tx_gen.go # x/blob/types/blob_tx_test.go
- Loading branch information
1 parent
fb20954
commit 1930c89
Showing
14 changed files
with
1,912 additions
and
66 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
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,89 @@ | ||
package app_test | ||
|
||
import ( | ||
"context" | ||
"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/testfactory" | ||
"github.com/celestiaorg/celestia-app/test/util/testnode" | ||
blobtypes "github.com/celestiaorg/celestia-app/x/blob/types" | ||
"github.com/celestiaorg/go-square/blob" | ||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
func TestBigBlobSuite(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("skipping big blob suite in short mode.") | ||
} | ||
suite.Run(t, &BigBlobSuite{}) | ||
} | ||
|
||
type BigBlobSuite struct { | ||
suite.Suite | ||
|
||
ecfg encoding.Config | ||
accounts []string | ||
cctx testnode.Context | ||
} | ||
|
||
func (s *BigBlobSuite) SetupSuite() { | ||
t := s.T() | ||
|
||
s.accounts = testfactory.GenerateAccounts(1) | ||
|
||
tmConfig := testnode.DefaultTendermintConfig() | ||
tmConfig.Mempool.MaxTxBytes = 10 * mebibyte | ||
|
||
cParams := testnode.DefaultConsensusParams() | ||
cParams.Block.MaxBytes = 10 * mebibyte | ||
|
||
cfg := testnode.DefaultConfig(). | ||
WithFundedAccounts(s.accounts...). | ||
WithTendermintConfig(tmConfig). | ||
WithConsensusParams(cParams) | ||
|
||
cctx, _, _ := testnode.NewNetwork(t, cfg) | ||
s.cctx = cctx | ||
s.ecfg = encoding.MakeConfig(app.ModuleEncodingRegisters...) | ||
|
||
require.NoError(t, cctx.WaitForNextBlock()) | ||
} | ||
|
||
// TestErrBlobsTooLarge verifies that submitting a 2 MiB blob hits ErrBlobsTooLarge. | ||
func (s *BigBlobSuite) TestErrBlobsTooLarge() { | ||
t := s.T() | ||
|
||
type testCase struct { | ||
name string | ||
blob *blob.Blob | ||
// want is the expected tx response ABCI code. | ||
want uint32 | ||
} | ||
testCases := []testCase{ | ||
{ | ||
name: "2 mebibyte blob", | ||
blob: newBlobWithSize(2 * mebibyte), | ||
want: blobtypes.ErrBlobsTooLarge.ABCICode(), | ||
}, | ||
} | ||
|
||
signer, err := testnode.NewSignerFromContext(s.cctx, s.accounts[0]) | ||
require.NoError(t, err) | ||
|
||
for _, tc := range testCases { | ||
s.Run(tc.name, func() { | ||
subCtx, cancel := context.WithTimeout(s.cctx.GoContext(), 30*time.Second) | ||
defer cancel() | ||
res, err := signer.SubmitPayForBlob(subCtx, []*blob.Blob{tc.blob}, user.SetGasLimitAndFee(1e9, appconsts.DefaultGlobalMinGasPrice)) | ||
require.Error(t, err) | ||
require.NotNil(t, res) | ||
require.Equal(t, tc.want, res.Code, res.Logs) | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.