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 util command to backfill tx error messages db #6525

Draft
wants to merge 36 commits into
base: master
Choose a base branch
from

Conversation

UlyanaAndrukhiv
Copy link
Contributor

@UlyanaAndrukhiv UlyanaAndrukhiv commented Oct 3, 2024

Closes: #6413

Note: #6468 and #6499 should be merged first.

Context

This pull request introduces a utility command that allows ANs to backfill missing transaction error messages from start to end height and a set of ENs to their local databases. This ensures that historical ANs have the necessary data to serve requests moving forward.

The command accepts a list of EN IDs (execution-node-ids) , if not provided, it defaults to query any available EN. It optionally takes a start and end block height (start-height, end-height); if not provided, it defaults to the root block and latest sealed block.

Before execution, the command checks if AN indexing is enabled. For each failed transaction within the block range, it retrieves and stores the error messages locally. It queries ENs in order and stops after the first successful response.

The command uses GetTransactionErrorMessagesByBlockID for optimized batch retrieval.

Unit tests are included to ensure functionality.

@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 39.26380% with 99 lines in your changes missing coverage. Please review.

Project coverage is 41.35%. Comparing base (3496c0f) to head (0380c35).

Files with missing lines Patch % Lines
cmd/access/node_builder/access_node_builder.go 0.00% 56 Missing ⚠️
cmd/observer/node_builder/observer_builder.go 0.00% 35 Missing ⚠️
engine/access/rpc/backend/node_selector.go 0.00% 4 Missing ⚠️
...e/common/rpc/execution_node_identities_provider.go 87.50% 3 Missing ⚠️
utils/unittest/mocks/closer.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6525      +/-   ##
==========================================
+ Coverage   41.15%   41.35%   +0.19%     
==========================================
  Files        2052     2025      -27     
  Lines      182196   180649    -1547     
==========================================
- Hits        74983    74699     -284     
+ Misses     100933    99709    -1224     
+ Partials     6280     6241      -39     
Flag Coverage Δ
unittests 41.35% <39.26%> (+0.19%) ⬆️

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.

fetchTxErrorMessages := false
for _, txResult := range results {
if txResult.Failed {
fetchTxErrorMessages = true
Copy link
Collaborator

@Guitarheroua Guitarheroua Oct 30, 2024

Choose a reason for hiding this comment

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

Could we break in the loop after we found at least one failed result? It looks to me, that we could do this, maybe I missed something.

},
})
suite.Error(err)
suite.Equal(err, admin.NewInvalidAdminReqErrorf(
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a dedicated method called ErrorIs. Equal is also good, just nitpicking :)

func createSnapshot(head *flow.Header) protocol.Snapshot {
snapshot := &protocolmock.Snapshot{}
func createSnapshot(head *flow.Header) *protocolmock.Snapshot {
snapshot := new(protocolmock.Snapshot)
Copy link
Collaborator

@Guitarheroua Guitarheroua Oct 30, 2024

Choose a reason for hiding this comment

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

nit: better to use protocolmock.NewSnapshot(t) as all New mock functions have additional checks inside.

Copy link
Collaborator

@Guitarheroua Guitarheroua 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, have a few comments!

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] Add util command to backfill tx error messages db
3 participants