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] Add implementation for transaction statuses data providers #6818

Open
wants to merge 96 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
38e7151
Implemented pending transaction trigger
Guitarheroua Nov 19, 2024
2ac2742
fixed tests
Guitarheroua Nov 19, 2024
8eee89a
Added documentation
Guitarheroua Nov 19, 2024
6766a38
revert unnecessary changes
Guitarheroua Nov 19, 2024
fed835a
Added skeleton for events data provider
AndriiDiachuk Nov 22, 2024
ea73371
Merge branch 'UlyanaAndrukhiv/6585-block-data-provider' of github.com…
AndriiDiachuk Nov 22, 2024
9c10d24
Added initializing of events filter, added missing data to factory
AndriiDiachuk Nov 22, 2024
9547b5d
Fixed factory test
AndriiDiachuk Nov 22, 2024
b7f5ca7
Merge branch 'UlyanaAndrukhiv/6585-block-data-provider' of github.com…
AndriiDiachuk Nov 25, 2024
0f34ae1
Added test skeleton for testing invalid arguments
AndriiDiachuk Nov 25, 2024
411f9e5
Added test for messageIndex check
AndriiDiachuk Nov 26, 2024
9a402de
Merged
AndriiDiachuk Nov 27, 2024
636740a
Added check for a valid event types in parse function
AndriiDiachuk Nov 28, 2024
f70c8e1
Merge branch 'UlyanaAndrukhiv/6585-block-data-provider' of github.com…
AndriiDiachuk Nov 28, 2024
588688e
Changed type of arguments for consistency
AndriiDiachuk Nov 28, 2024
b537a5f
Added test case for event provider in factory_test
AndriiDiachuk Nov 28, 2024
4f63403
Added implementations for account provider functions
AndriiDiachuk Nov 29, 2024
867fcf7
Merge branch 'UlyanaAndrukhiv/6585-block-data-provider' of github.com…
AndriiDiachuk Nov 29, 2024
dca9a25
Fixed remarks
AndriiDiachuk Nov 29, 2024
867fc98
Merge branch 'AndriiDiachuk/6588-events-data-provider' of github.com:…
AndriiDiachuk Nov 29, 2024
9624894
Added test for invalid arguments and for message index
AndriiDiachuk Nov 29, 2024
6456d40
Merge branch 'master' into AndriiSlisarchuk/6573-pending-should-retur…
Guitarheroua Dec 2, 2024
309b148
Added check for starting index value
AndriiDiachuk Dec 2, 2024
756c21d
Merge branch 'AndriiDiachuk/6588-events-data-provider' of github.com:…
AndriiDiachuk Dec 2, 2024
47a4c19
Added check for msgIndex
AndriiDiachuk Dec 2, 2024
8f1f99c
Merge branch 'UlyanaAndrukhiv/6585-block-data-provider' of github.com…
AndriiDiachuk Dec 2, 2024
0abe203
Merge branch 'UlyanaAndrukhiv/6585-block-data-provider' of github.com…
AndriiDiachuk Dec 2, 2024
8ffe023
changed handleResponse to generic
AndriiDiachuk Dec 2, 2024
1384405
Added happy path for testing all subscribe methods
AndriiDiachuk Dec 3, 2024
57a7c0f
Linted
AndriiDiachuk Dec 3, 2024
3e48960
Merge branch 'master' into AndriiDiachuk/6588-events-data-provider
peterargue Dec 3, 2024
378afa8
Merge branch 'master' into AndriiSlisarchuk/6573-pending-should-retur…
Guitarheroua Dec 4, 2024
e076072
Changed order of params
AndriiDiachuk Dec 4, 2024
89bc4c2
Fixed issues with params order
AndriiDiachuk Dec 4, 2024
1cc0a74
Merge branch 'master' of github.com:The-K-R-O-K/flow-go into AndriiDi…
AndriiDiachuk Dec 4, 2024
a1d7aa7
Refactored parse function
AndriiDiachuk Dec 4, 2024
8d9e090
Using json arrays instead of comma separeted lists
AndriiDiachuk Dec 4, 2024
416ff58
Added heartbeat handling in handleResponse, updated type of expected …
AndriiDiachuk Dec 4, 2024
2239802
Merge branch 'AndriiDiachuk/6588-events-data-provider' of github.com:…
AndriiDiachuk Dec 4, 2024
0e85d16
Merged
AndriiDiachuk Dec 5, 2024
179a664
Fixed small remarks
AndriiDiachuk Dec 5, 2024
e0aa808
Made parse function private
AndriiDiachuk Dec 5, 2024
19bf3c9
Changed Arguments type and refactored code
AndriiDiachuk Dec 5, 2024
8d0543d
Removed comment
AndriiDiachuk Dec 5, 2024
d6fc9df
Fixed parse function for event privoder
AndriiDiachuk Dec 6, 2024
1bb4112
Linted
AndriiDiachuk Dec 9, 2024
2e90387
Merge branch 'master' into AndriiDiachuk/6588-events-data-provider
AndriiDiachuk Dec 9, 2024
30e27df
Merge branch 'master' of github.com:The-K-R-O-K/flow-go into AndriiDi…
AndriiDiachuk Dec 9, 2024
bb04f4a
Merge branch 'AndriiDiachuk/6588-events-data-provider' of github.com:…
AndriiDiachuk Dec 9, 2024
df387ec
Merge branch 'AndriiDiachuk/6588-events-data-provider' of github.com:…
AndriiDiachuk Dec 9, 2024
f81c794
Changed parse args function, added hearbeat for hadnling
AndriiDiachuk Dec 9, 2024
50fd289
Fixed error msg
AndriiDiachuk Dec 9, 2024
8ced75a
Implemented subsscribe tx statuses. Make refactoring.
Guitarheroua Dec 9, 2024
ff1a95f
linted
Guitarheroua Dec 9, 2024
c817414
Merge branch 'master' into AndriiSlisarchuk/6573-pending-should-retur…
Guitarheroua Dec 9, 2024
37836f9
Added happy path cases, fixed remarks from event provider PR
AndriiDiachuk Dec 9, 2024
815419b
Clean up code. Added comments
Guitarheroua Dec 10, 2024
88e0333
Merge branch 'AndriiDiachuk/6587-accounts-data-provider' of github.co…
AndriiDiachuk Dec 10, 2024
8432297
Fixed account statuses test
AndriiDiachuk Dec 11, 2024
3ba47e8
Refacored events provider tests to use generic testHappyPath function
AndriiDiachuk Dec 11, 2024
85e4464
Refactored account statuses test
AndriiDiachuk Dec 11, 2024
03e5e42
Decreased expected events count
AndriiDiachuk Dec 11, 2024
32d4850
Merge branch 'master' into AndriiDiachuk/6588-events-data-provider
AndriiDiachuk Dec 11, 2024
a9e7bc3
Merge branch 'AndriiDiachuk/6588-events-data-provider' of github.com:…
AndriiDiachuk Dec 11, 2024
2bbd399
Added skeleton for tx account data provider
AndriiDiachuk Dec 11, 2024
de5f077
Added description for missing func params
AndriiDiachuk Dec 11, 2024
683f026
Implemented tx statuses provider
AndriiDiachuk Dec 11, 2024
3b19cd0
Separate subscribe tx statuses to 3 function
Guitarheroua Dec 12, 2024
699b243
Added invalid params test
AndriiDiachuk Dec 13, 2024
71c7f6c
Merge branch 'AndriiSlisarchuk/6573-pending-should-return-immediately…
AndriiDiachuk Dec 13, 2024
e83930e
Refactored parse functions
AndriiDiachuk Dec 13, 2024
5c9f16c
Refactored args filter init
AndriiDiachuk Dec 13, 2024
c002841
Created separate file for generic testHappyPath method and for testTy…
AndriiDiachuk Dec 13, 2024
90d86fd
Merge branch 'master' of github.com:The-K-R-O-K/flow-go into AndriiDi…
AndriiDiachuk Dec 13, 2024
39f7a48
Merged
AndriiDiachuk Dec 13, 2024
9ed9207
Changed parse args function, added invalid args testcases
AndriiDiachuk Dec 13, 2024
d660c7f
Linted
AndriiDiachuk Dec 13, 2024
3126cd9
Changed api in test to mock api
AndriiDiachuk Dec 13, 2024
2f0142d
Removed commented code
AndriiDiachuk Dec 13, 2024
213a5ed
Merge branch 'onflow:master' into AndriiDiachuk/6586-tx-statuses-data…
UlyanaAndrukhiv Dec 17, 2024
e028162
Merge branch 'AndriiDiachuk/6586-tx-statuses-data-providers-impl' of …
AndriiDiachuk Dec 17, 2024
2ec3817
Linted
AndriiDiachuk Dec 17, 2024
a7a6f76
Fixed type in the log msg
AndriiDiachuk Dec 17, 2024
cb81354
Merge branch 'master' into AndriiDiachuk/6588-events-data-provider
AndriiDiachuk Dec 17, 2024
e34d787
Added new topic for send and subcribe tx statuses
AndriiDiachuk Dec 18, 2024
13c4102
Renamed util filke for tests
AndriiDiachuk Dec 18, 2024
1360891
Merge branch 'AndriiDiachuk/6588-events-data-provider' of github.com:…
AndriiDiachuk Dec 18, 2024
7b8ee77
Initializing msg index by 0
AndriiDiachuk Dec 18, 2024
dd23b79
Changed type of msgIndex in model to uint64:
AndriiDiachuk Dec 18, 2024
bf28e2f
Refactored parse arguments function
AndriiDiachuk Dec 18, 2024
f419a5c
Merge branch 'master' into AndriiDiachuk/6588-events-data-provider
AndriiDiachuk Dec 18, 2024
907c708
Fixed msg index start from 0
AndriiDiachuk Dec 19, 2024
101ff68
Merge branch 'master' into AndriiDiachuk/6588-events-data-provider
AndriiDiachuk Dec 19, 2024
3492dc1
Merge branch 'AndriiDiachuk/6588-events-data-provider' of github.com:…
AndriiDiachuk Dec 19, 2024
08f4b29
Refactored tx statuses parse function
AndriiDiachuk Dec 19, 2024
80c97a6
Added test for tx statuses data provider for msgIndex increment
AndriiDiachuk Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions access/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,50 @@ type API interface {
//
// If invalid parameters will be supplied SubscribeBlockDigestsFromLatest will return a failed subscription.
SubscribeBlockDigestsFromLatest(ctx context.Context, blockStatus flow.BlockStatus) subscription.Subscription
// SubscribeTransactionStatuses streams transaction statuses starting from the reference block saved in the
// transaction itself until the block containing the transaction becomes sealed or expired. When the transaction
// status becomes TransactionStatusSealed or TransactionStatusExpired, the subscription will automatically shut down.
SubscribeTransactionStatuses(ctx context.Context, tx *flow.TransactionBody, requiredEventEncodingVersion entities.EventEncodingVersion) subscription.Subscription
// SubscribeTransactionStatusesFromStartBlockID subscribes to transaction status updates for a given transaction ID.
// Monitoring begins from the specified block ID. 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.
//
// Parameters:
// - ctx: The context to manage the subscription's lifecycle, including cancellation.
// - txID: The identifier of the transaction to monitor.
// - startBlockID: The block ID from which to start monitoring.
// - requiredEventEncodingVersion: The version of event encoding required for the subscription.
SubscribeTransactionStatusesFromStartBlockID(ctx context.Context, txID flow.Identifier, startBlockID flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) subscription.Subscription
// SubscribeTransactionStatusesFromStartHeight subscribes to transaction status updates for a given transaction ID.
// 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.
//
// Parameters:
// - ctx: The context to manage the subscription's lifecycle, including cancellation.
// - txID: The unique identifier of the transaction to monitor.
// - startHeight: The block height from which to start monitoring.
// - requiredEventEncodingVersion: The version of event encoding required for the subscription.
SubscribeTransactionStatusesFromStartHeight(ctx context.Context, txID flow.Identifier, startHeight uint64, requiredEventEncodingVersion entities.EventEncodingVersion) subscription.Subscription
// SubscribeTransactionStatusesFromLatest subscribes to transaction status updates for a given transaction ID.
// Monitoring begins from the latest block. 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.
//
// Parameters:
// - ctx: The context to manage the subscription's lifecycle, including cancellation.
// - txID: The unique identifier of the transaction to monitor.
// - requiredEventEncodingVersion: The version of event encoding required for the subscription.
SubscribeTransactionStatusesFromLatest(ctx context.Context, txID flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) subscription.Subscription
// SendAndSubscribeTransactionStatuses sends a transaction to the execution node and subscribes to its status updates.
// Monitoring begins from the reference block saved in the transaction itself and streams status updates until the transaction
// reaches a final state (TransactionStatusSealed or TransactionStatusExpired). Once a final status is reached, the subscription
// automatically terminates.
//
// Parameters:
// - ctx: The context to manage the transaction sending and subscription lifecycle, including cancellation.
// - tx: The transaction body to be sent and monitored.
// - requiredEventEncodingVersion: The version of event encoding required for the subscription.
//
// If the transaction cannot be sent, the subscription will fail and return a failed subscription.
SendAndSubscribeTransactionStatuses(ctx context.Context, tx *flow.TransactionBody, requiredEventEncodingVersion entities.EventEncodingVersion) subscription.Subscription
}

// TODO: Combine this with flow.TransactionResult?
Expand Down
7 changes: 1 addition & 6 deletions access/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1425,12 +1425,7 @@ func (h *Handler) SendAndSubscribeTransactionStatuses(
return status.Error(codes.InvalidArgument, err.Error())
}

err = h.api.SendTransaction(ctx, &tx)
if err != nil {
return err
}

sub := h.api.SubscribeTransactionStatuses(ctx, &tx, request.GetEventEncodingVersion())
sub := h.api.SendAndSubscribeTransactionStatuses(ctx, &tx, request.GetEventEncodingVersion())

messageIndex := counters.NewMonotonousCounter(0)
return subscription.HandleRPCSubscription(sub, func(txResults []*TransactionResult) error {
Expand Down
72 changes: 66 additions & 6 deletions access/mock/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 26 additions & 1 deletion cmd/util/cmd/run-script/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,32 @@ func (*api) SubscribeBlockDigestsFromLatest(
return nil
}

func (*api) SubscribeTransactionStatuses(
func (a *api) SubscribeTransactionStatusesFromStartBlockID(
_ context.Context,
_ flow.Identifier,
_ flow.Identifier,
_ entities.EventEncodingVersion,
) subscription.Subscription {
return nil
}

func (a *api) SubscribeTransactionStatusesFromStartHeight(
_ context.Context,
_ flow.Identifier,
_ uint64,
_ entities.EventEncodingVersion,
) subscription.Subscription {
return nil
}

func (a *api) SubscribeTransactionStatusesFromLatest(
_ context.Context,
_ flow.Identifier,
_ entities.EventEncodingVersion,
) subscription.Subscription {
return nil
}
func (a *api) SendAndSubscribeTransactionStatuses(
_ context.Context,
_ *flow.TransactionBody,
_ entities.EventEncodingVersion,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package request
package parser

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion engine/access/rest/http/request/get_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (g *GetEvents) Parse(rawType string, rawStart string, rawEnd string, rawBlo
if rawType == "" {
return fmt.Errorf("event type must be provided")
}
var eventType EventType
var eventType parser.EventType
err = eventType.Parse(rawType)
if err != nil {
return err
Expand Down
8 changes: 7 additions & 1 deletion engine/access/rest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ func NewServer(serverAPI access.API,
builder.AddLegacyWebsocketsRoutes(stateStreamApi, chain, stateStreamConfig, config.MaxRequestSize)
}

dataProviderFactory := dp.NewDataProviderFactory(logger, stateStreamApi, serverAPI)
dataProviderFactory := dp.NewDataProviderFactory(
logger,
stateStreamApi,
serverAPI,
chain,
stateStreamConfig.EventFilterConfig,
stateStreamConfig.HeartbeatInterval)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
stateStreamConfig.HeartbeatInterval)
stateStreamConfig.HeartbeatInterval,
)

builder.AddWebsocketsRoute(chain, wsConfig, config.MaxRequestSize, dataProviderFactory)

c := cors.New(cors.Options{
Expand Down
Loading
Loading