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

refactor: signer to use txstatus #3767

Merged
merged 5 commits into from
Aug 16, 2024
Merged

refactor: signer to use txstatus #3767

merged 5 commits into from
Aug 16, 2024

Conversation

ninabarbakadze
Copy link
Member

@ninabarbakadze ninabarbakadze commented Aug 8, 2024

@ninabarbakadze ninabarbakadze marked this pull request as ready for review August 13, 2024 13:30
Copy link
Contributor

coderabbitai bot commented Aug 13, 2024

Walkthrough

Walkthrough

The changes primarily enhance transaction handling and testing by incorporating the sdktx service client for querying transaction details. This shift replaces direct access to raw logs with calls to GetTx, improving reliability and accuracy. The introduction of a new TxResponse struct standardizes responses across various functions, simplifying error handling and enhancing clarity in transaction confirmations.

Changes

Files Change Summary
app/test/... Updated test functions to use sdktx service client for transaction log retrieval, replacing direct access to RawLog. Error handling improvements for more reliable assertions.
pkg/user/tx_client.go Introduced TxResponse struct to standardize transaction responses. Updated several functions to return this new struct instead of sdktypes.TxResponse, improving clarity.
pkg/user/tx_client_test.go Enhanced tests to leverage the sdktx service client, replacing direct response checks with service client calls for improved accuracy.
test/txsim/account.go Changed transaction response type in Submit method to use *user.TxResponse, indicating a shift in response handling context.
x/blobstream/integration_test.go Updated TestBlobstream to retrieve transaction logs using sdktx, improving the accuracy of transaction code assertions.
x/signal/legacy_test.go Modified tests to utilize serviceClient for transaction details, improving clarity and robustness in error handling and transaction log retrieval.

Assessment against linked issues

Objective Addressed Explanation
Signer should use TxStatus instead of Tx to confirm submission (#3366)

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. 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 testing code 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 testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (5)
app/test/big_blob_test.go (1)

86-87: Reminder: Address the FIXME comment.

The comment indicates an intention to assert RawLog once TxStatus supports it. Ensure to track this update.

Consider opening a tracking issue or adding a more detailed comment for future reference.

x/blobstream/integration_test.go (1)

93-99: Reminder: Address the FIXME comment.

The comment indicates a temporary solution for querying the raw log. Ensure to update this once TxStatus supports the feature.

Consider opening a tracking issue or adding a more detailed comment for future reference.

app/test/prepare_proposal_context_test.go (1)

84-90: Reminder: Address the FIXME comment.

The comment indicates a temporary solution for querying the raw log. Ensure to update this once TxStatus supports the feature.

Consider opening a tracking issue or adding a more detailed comment for future reference.

pkg/user/tx_client_test.go (1)

50-52: Track the resolution of the temporary solution.

The initialization of serviceClient is marked as a temporary solution with a FIXME comment. Ensure this is tracked for future resolution.

-  // FIXME: Temporary way of querying the raw log.
+  // FIXME: Temporary way of querying the raw log. Track this issue for future resolution.
app/test/std_sdk_test.go (1)

329-335: Track the resolution of the temporary solution.

The use of serviceClient.GetTx improves transaction result validation. The FIXME comment indicates a temporary solution that should be tracked for future resolution.

-  // FIXME: Temporary way of querying the raw log.
+  // FIXME: Temporary way of querying the raw log. Track this issue for future resolution.

@evan-forbes evan-forbes added the WS: BestTxs Reliable and seamless transaction flow label Aug 13, 2024
Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

LGTM - just a few minor nits

Comment on lines +50 to +52
// FIXME: Temporary way of querying the raw log.
// TxStatus will natively support this in the future.
suite.serviceClient = sdktx.NewServiceClient(suite.ctx.GRPCClient)
Copy link
Contributor

Choose a reason for hiding this comment

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

Well we will still need this to get the gas wanted and gas used

Copy link
Member Author

Choose a reason for hiding this comment

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

true i think i automatically copied this. will remove!

Comment on lines +273 to 277
if err != nil && resp != nil {
return &TxResponse{Code: resp.Code, TxHash: resp.TxHash}, fmt.Errorf("failed to broadcast tx: %v", err)
} else if err != nil {
return &TxResponse{}, fmt.Errorf("failed to broadcast tx: %v", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: would be a little cleaner to use a helper function:

if err != nil {
    return parseTxResp(resp), fmt.Errorf("failed to broadcast tx: %w", err)
}

which turns the broadcastTxResponse to a TxResponse or nil if it's nil

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah i considered it but I thought that maybe this was more straight-forward and easy to understand

Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

overall LGTM, had two questions

Code: resp.ExecutionCode,
}
if resp.ExecutionCode != 0 {
return txResponse, fmt.Errorf("tx was included but failed with code %d: %s", resp.ExecutionCode, resp.Status)
Copy link
Member

Choose a reason for hiding this comment

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

[not blocking]

using the word committed instead of included here I think is a smidge clearer as there's a less of a chance to confuse with inclusion into the mempool

Suggested change
return txResponse, fmt.Errorf("tx was included but failed with code %d: %s", resp.ExecutionCode, resp.Status)
return txResponse, fmt.Errorf("tx was committed but failed with code %d: %s", resp.ExecutionCode, resp.Status)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll address this in a follow-up

Comment on lines +43 to +49
// TxResponse is a response from the chain after
// a transaction has been submitted.
type TxResponse struct {
Height int64
TxHash string
Code uint32
}
Copy link
Member

Choose a reason for hiding this comment

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

what's the benefit of having our own type here? if this is different from the sdk TxResponse, is there a way to indicate it in the name?

Copy link
Member Author

Choose a reason for hiding this comment

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

because for example in SubmitTx BroadcastTx and ConfirmTx have different responses now that we've switched to a new indexer

case <-ctx.Done():
return &sdktypes.TxResponse{}, ctx.Err()
case <-pollTicker.C:
if err == nil && resp != nil {
Copy link
Member

Choose a reason for hiding this comment

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

where are we notifying the user that their tx is in the mempool?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we need to notify a user in this instance cause we're just confirming the inclusion in a block

@ninabarbakadze ninabarbakadze merged commit a28b9e7 into main Aug 16, 2024
32 of 34 checks passed
@ninabarbakadze ninabarbakadze deleted the nina/signer-txstatus branch August 16, 2024 12:15
@ninabarbakadze ninabarbakadze added the backport:v2.x PR will be backported automatically to the v2.x branch upon merging label Aug 19, 2024
mergify bot pushed a commit that referenced this pull request Aug 19, 2024
## Overview

Fixes #3366

Opens - celestiaorg/celestia-core#1453 and
celestiaorg/celestia-core#1454

(cherry picked from commit a28b9e7)

# Conflicts:
#	pkg/user/tx_client.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:v2.x PR will be backported automatically to the v2.x branch upon merging WS: BestTxs Reliable and seamless transaction flow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Signer should use TxStatus instead of Tx to confirm submission
3 participants