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

[Access] Implement subscribe transaction statuses by transaction ID #6737

Open
wants to merge 51 commits into
base: master
Choose a base branch
from

Conversation

Guitarheroua
Copy link
Contributor

@Guitarheroua Guitarheroua commented Nov 19, 2024

Closes #6573 and #6574

This PR implements a new subscription to a transaction by txID and changes the existing send and subscribe endpoint.

This PR introduces a separate transactionSubscriptionMetadata private module and moves the handling of transactions status logic there to simplify streaming module logic.

@codecov-commenter
Copy link

codecov-commenter commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 70.28302% with 63 lines in your changes missing coverage. Please review.

Project coverage is 41.20%. Comparing base (ab355ee) to head (0b49be0).

Files with missing lines Patch % Lines
...s/rpc/backend/transaction_subscription_metadata.go 63.88% 30 Missing and 9 partials ⚠️
.../access/rpc/backend/backend_stream_transactions.go 75.43% 10 Missing and 4 partials ⚠️
access/api.go 0.00% 4 Missing ⚠️
access/mock/api.go 0.00% 2 Missing ⚠️
cmd/util/cmd/run-script/cmd.go 0.00% 2 Missing ⚠️
engine/access/rpc/backend/backend_transactions.go 83.33% 1 Missing ⚠️
...ss/rpc/backend/transactions_local_data_provider.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6737   +/-   ##
=======================================
  Coverage   41.19%   41.20%           
=======================================
  Files        2149     2150    +1     
  Lines      189039   188999   -40     
=======================================
- Hits        77881    77879    -2     
+ Misses     104652   104610   -42     
- Partials     6506     6510    +4     
Flag Coverage Δ
unittests 41.20% <70.28%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Guitarheroua Guitarheroua self-assigned this Nov 20, 2024
@Guitarheroua Guitarheroua marked this pull request as ready for review November 21, 2024 07:42
Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

added a few small comments, but otherwise looks good

Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

added a couple more comments, but otherwise looks good.

peterargue
peterargue previously approved these changes Dec 27, 2024
Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

looks good other than missing irrecoverable error

@peterargue peterargue requested a review from durkmurder January 2, 2025 17:55
@Guitarheroua Guitarheroua requested a review from a team as a code owner January 16, 2025 08:02
@Guitarheroua Guitarheroua marked this pull request as ready for review January 31, 2025 13:58
@peterargue peterargue dismissed their stale review February 10, 2025 22:27

there was a significant refactor since my review

Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

added some comments about finishing touches, but otherwise I think this looks good

@peterargue
Copy link
Contributor

@durkmurder can you take another look 🙏

Copy link
Member

@durkmurder durkmurder left a comment

Choose a reason for hiding this comment

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

First batch of comments, still have tests to review.

block, err := tm.blocks.ByCollectionID(tm.txResult.CollectionID)
if err != nil {
if errors.Is(err, storage.ErrNotFound) {
return subscription.ErrBlockNotReady
Copy link
Member

Choose a reason for hiding this comment

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

it returns ErrBlockNotReady but this is not explained in the godoc.

// - height: The block height used for searching transaction data.
//
// Expected errors during normal operation:
// - `ErrBlockNotReady` if the block at the given height is not found.
Copy link
Member

Choose a reason for hiding this comment

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

I believe there are more errors that can happen in sub-routines, can we describe them?

access/api.go Outdated
// Monitoring begins from the specified block height. The subscription streams status updates until the transaction
// reaches a final state (TransactionStatusSealed or TransactionStatusExpired). When the transaction reaches one of
// these final statuses, the subscription will automatically terminate.
// SubscribeTransactionStatuses subscribes to transaction status updates for a given transaction ID. Monitoring begins
Copy link
Member

Choose a reason for hiding this comment

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

It seems this documentation is out of sync with the implementation file. I a big fan of copying the same documentation to the implementation and having it in sync, it's easier to check if the implementation really follows the interface. Can you also expand it to mention how it will behave if you pass transaction from past time? The "last block ID" makes it hard to understand.

@@ -22,9 +21,7 @@ import (

// transactionStatusesArguments contains the arguments required for subscribing to transaction statuses
type transactionStatusesArguments struct {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? It holds a single field, might be simpler just to replace it with that field?

"fmt"
"os"
"testing"
"time"

"github.com/onflow/flow-go/module/irrecoverable"
Copy link
Member

Choose a reason for hiding this comment

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

Can we properly group those imports? There is no need to have that many groups that are repeating themselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Access] Pending response from send and subscribe should return immediately
4 participants