Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nonce handling with signer #3196

Merged
merged 11 commits into from
Mar 26, 2024
Merged

feat: nonce handling with signer #3196

merged 11 commits into from
Mar 26, 2024

Conversation

cmwaters
Copy link
Contributor

@cmwaters cmwaters commented Mar 20, 2024

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

@cmwaters cmwaters self-assigned this Mar 20, 2024
@cmwaters cmwaters marked this pull request as ready for review March 20, 2024 10:35
Copy link
Contributor

coderabbitai bot commented Mar 20, 2024

Walkthrough

Walkthrough

The recent changes focus on refining transaction handling and error parsing, specifically targeting nonce mismatch and gas price issues. Enhancements include simplifying transaction creation and submission, improving sequence number management, and introducing new testing for concurrent operations. These updates aim to address user experience problems related to transaction ordering and nonce management, ensuring efficient processing and prioritization of transactions in environments where block production may outpace finalization.

Changes

Files Change Summary
app/errors/insufficient_gas_price_test.go, app/errors/nonce_mismatch.go, app/errors/nonce_mismatch_test.go Simplified transaction handling by removing decoding steps in tests and enhanced nonce mismatch error parsing.
app/test/big_blob_test.go, app/test/priority_test.go, test/util/blobfactory/payforblob_factory.go, test/util/blobfactory/test_util.go Replaced transaction creation functions with submission functions, refining transaction handling.
pkg/user/signer.go, pkg/user/e2e_test.go, pkg/user/signer_test.go Updated Signer struct and tests for better sequence number handling and concurrent transaction submission.
go.work.sum Added github.com/mxk/go-flowrate dependency.
test/util/direct_tx_gen.go, x/blob/types/blob_tx_test.go Improved transaction handling, encoding clarity, and error management.

Assessment against linked issues

Objective Addressed Explanation
Address UX problems from fast rollup block production vs. Celestia network finalization (#1910)
Solve incorrect transaction ordering due to invalid nonce numbers (#1910)
Group transactions by signer with weighted gas prices to ensure bundle success or failure together (#1910) It's unclear if transactions are grouped by signer with weighted gas prices without specific implementation details.
Implement mechanism to reorder transactions with incorrect nonces (#1910) The summary does not explicitly mention the implementation of a reordering mechanism for transactions with incorrect nonces.
Explore using nonce lanes for transaction segregation if order is not critical (#1910) There's no mention of exploring or implementing nonce lanes for transaction segregation.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@celestia-bot celestia-bot requested a review from a team March 20, 2024 10:44
Comment on lines +38 to +40
// FIXME: the signer is currently incapable of detecting an appversion
// change and could produce incorrect PFBs if it the network is at an
// appVersion that the signer does not support
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FIXME comment highlights a potential issue with the Signer not detecting appVersion changes. This could lead to producing incorrect PayForBlob transactions if the network's appVersion is not supported by the Signer.

Consider implementing a mechanism to check and update the appVersion dynamically or at least document a process for manually updating it to ensure the Signer remains compatible with the network.

Comment on lines +146 to +151
tx, err := s.CreateTx(msgs, opts...)
if err != nil {
return nil, err
}

resp, err := s.BroadcastTx(ctx, txBytes)
resp, err := s.BroadcastTx(ctx, tx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When submitting a transaction using SubmitTx, the error handling for the transaction broadcast is minimal. It only checks if resp.Code is not 0 but does not handle specific error codes or retry logic.

Enhance error handling by implementing specific checks for common error codes related to nonce mismatches or other transaction failures. Consider adding retry logic for recoverable errors to improve the robustness of transaction submission.

Comment on lines 165 to 170
resp, err := s.broadcastPayForBlob(ctx, blobs, opts...)
if err != nil {
return nil, err
}

resp, err := s.BroadcastTx(ctx, txBytes)
return s.ConfirmTx(ctx, resp.TxHash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the SubmitTx method, SubmitPayForBlob also has minimal error handling for the transaction broadcast. It directly returns the response from broadcastPayForBlob without additional checks or handling.

Apply the same enhancements recommended for SubmitTx to SubmitPayForBlob for consistent and robust error handling across transaction submission methods.

pkg/user/signer.go Outdated Show resolved Hide resolved
pkg/user/signer.go Show resolved Hide resolved
pkg/user/signer.go Show resolved Hide resolved
pkg/user/signer.go Outdated Show resolved Hide resolved
pkg/user/signer.go Outdated Show resolved Hide resolved
app/errors/nonce_mismatch.go Show resolved Hide resolved
test/util/blobfactory/test_util.go Show resolved Hide resolved
rootulp
rootulp previously approved these changes Mar 21, 2024
@cmwaters cmwaters requested a review from rootulp March 25, 2024 10:00
@cmwaters cmwaters added the backport:v1.x PR will be backported automatically to the v1.x branch upon merging label Mar 25, 2024
@cmwaters cmwaters merged commit deefb54 into main Mar 26, 2024
33 checks passed
@cmwaters cmwaters deleted the cal/nonce-handling branch March 26, 2024 10:47
mergify bot pushed a commit that referenced this pull request Mar 26, 2024
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
ninabarbakadze pushed a commit to ninabarbakadze/celestia-app that referenced this pull request Apr 2, 2024
Closes: celestiaorg#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
cmwaters added a commit that referenced this pull request Apr 4, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:v1.x PR will be backported automatically to the v1.x branch upon merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handling multiple blobTxs in a block
3 participants