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 usage of the local transaction result in Access API #5306

Merged

Conversation

Guitarheroua
Copy link
Contributor

#4753

Add implementation for usage of the local transaction result index for existing Access API endpoints(GetTransactionResult, GetTransactionResultByIndex, GetTransactionResultsByBlockID) to get transaction results for indexed blocks.

The errors for transaction results are requested separately and were implemented as part of the issue #4754.

@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2024

Codecov Report

Attention: Patch coverage is 56.90476% with 181 lines in your changes are missing coverage. Please review.

Project coverage is 57.42%. Comparing base (6908b7e) to head (c7c489b).

Files Patch % Lines
...ss/rpc/backend/transactions_local_data_provider.go 60.00% 58 Missing and 24 partials ⚠️
.../access/rpc/backend/transaction_results_indexer.go 36.50% 31 Missing and 9 partials ⚠️
engine/access/rpc/backend/backend_transactions.go 62.85% 38 Missing and 1 partial ⚠️
engine/common/rpc/errors.go 0.00% 14 Missing ⚠️
engine/access/rpc/backend/events_index.go 53.84% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5306      +/-   ##
==========================================
+ Coverage   56.06%   57.42%   +1.35%     
==========================================
  Files        1026      798     -228     
  Lines      100116    80463   -19653     
==========================================
- Hits        56129    46205    -9924     
+ Misses      39688    30565    -9123     
+ Partials     4299     3693     -606     
Flag Coverage Δ
unittests 57.42% <56.90%> (+1.35%) ⬆️

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 marked this pull request as ready for review January 26, 2024 15:10
engine/access/rpc/backend/config.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/backend_transactions.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/backend_transactions.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/backend_transactions.go Outdated Show resolved Hide resolved
Guitarheroua and others added 2 commits February 6, 2024 11:34
Co-authored-by: Peter Argue <89119817+peterargue@users.noreply.github.com>
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.

thanks for the PR @Guitarheroua! it's all coming together.

cmd/access/node_builder/access_node_builder.go Outdated Show resolved Hide resolved
cmd/access/node_builder/access_node_builder.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/config.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/transaction_results_indexer.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/events_index.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/backend_transactions.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/backend_transactions.go Outdated Show resolved Hide resolved
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.

Great job, very big lift. Most of my comments are stylistic and around documentation.
The only thing I am unsure is Initialize, I would prefer to avoid such patterns but if they are absolutely needed then they need to be carefully explained. Additionally I don't think case of "not initialized" should be threaten as sentinel error to me it seems that we require initialization before we can serve clients, in other words our invariant is: "Initialize MUST to be called before serving clients" if this invariant is broken then we should bail out with exception, not a sentinel error.

engine/access/rpc/backend/events_index.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/events_index.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/events_index.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/events_index.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/events_index.go Show resolved Hide resolved
// get the latest finalized block from the state
finalized, err := t.state.Final().Head()
if err != nil {
return flow.TransactionStatusUnknown, irrecoverable.NewExceptionf("failed to lookup final header: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

👍

engine/access/rpc/backend/backend_transactions_test.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/backend_transactions_test.go Outdated Show resolved Hide resolved
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.

Proposed a few more godoc changes, otherwise looks good!

engine/access/rpc/backend/events_index.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/transaction_results_indexer.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/events_index.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/transaction_results_indexer.go Outdated Show resolved Hide resolved
engine/access/rpc/backend/events_index.go Outdated Show resolved Hide resolved
return reporter.HighestIndexedHeight()
}

func (t *TransactionResultsIndex) checkDataAvailability(height uint64) error {
Copy link
Member

Choose a reason for hiding this comment

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

We need some godoc for this function, don't forget to describe errors

Comment on lines 1027 to 1033
func (suite *Suite) checkTransactionResultResponse(
err error,
response *acc.TransactionResult,
block flow.Block,
txId flow.Identifier,
txFailed bool,
eventsForTx []flow.Event,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (suite *Suite) checkTransactionResultResponse(
err error,
response *acc.TransactionResult,
block flow.Block,
txId flow.Identifier,
txFailed bool,
eventsForTx []flow.Event,
func (suite *Suite) assertTransactionResultResponse(
err error,
response *acc.TransactionResult,
expectedBlock flow.Block,
expectedTxId flow.Identifier,
expectedTxFailed bool,
expectedEvents []flow.Event,

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.

Proposed a few more godoc changes, otherwise looks good!

@peterargue peterargue added this pull request to the merge queue Feb 28, 2024
Merged via the queue into onflow:master with commit ecc58a2 Feb 28, 2024
51 checks passed
peterargue added a commit that referenced this pull request Mar 15, 2024
…dex-tx-result

[Access] Add implementation for usage of the local transaction result in Access API
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.

5 participants