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 38 commits into
base: master
Choose a base branch
from

Conversation

UlyanaAndrukhiv
Copy link
Contributor

@UlyanaAndrukhiv UlyanaAndrukhiv commented Oct 3, 2024

Closes: #6413

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 48.37209% with 111 lines in your changes missing coverage. Please review.

Project coverage is 41.09%. Comparing base (b5fab5c) to head (b610309).

Files with missing lines Patch % Lines
cmd/access/node_builder/access_node_builder.go 0.00% 54 Missing ⚠️
cmd/observer/node_builder/observer_builder.go 0.00% 35 Missing ⚠️
...min/commands/storage/backfill_tx_error_messages.go 82.17% 12 Missing and 6 partials ⚠️
...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.09%   -0.07%     
==========================================
  Files        2052     1934     -118     
  Lines      182212   169729   -12483     
==========================================
- Hits        74989    69744    -5245     
+ Misses     100944    94232    -6712     
+ Partials     6279     5753     -526     
Flag Coverage Δ
unittests 41.09% <48.37%> (-0.07%) ⬇️

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.

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!

Comment on lines +76 to +78
} else if startHeight > rootHeight {
data.startHeight = startHeight
}
Copy link
Contributor

Choose a reason for hiding this comment

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

let's have it return an error if startHeight < rootHeight rather than silently updating the value

if startHeightIn, ok := input["start-height"]; ok {
if startHeight, err := parseN(startHeightIn); err != nil {
return admin.NewInvalidAdminReqErrorf("invalid 'start-height' field: %w", err)
} else if startHeight > lastSealedHeight {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: start a new conditional when the previous one returns. it makes the code a bit easier to read

Suggested change
} else if startHeight > lastSealedHeight {
}
if startHeight > lastSealedHeight {

if endHeightIn, ok := input["end-height"]; ok {
if endHeight, err := parseN(endHeightIn); err != nil {
return admin.NewInvalidAdminReqErrorf("invalid 'end-height' field: %w", err)
} else if endHeight < lastSealedHeight {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here. return an error if endHeight > lastSealedHeight


if data.endHeight < data.startHeight {
return admin.NewInvalidAdminReqErrorf(
"'start-height' %d should not be smaller than 'end-height' %d",
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
"'start-height' %d should not be smaller than 'end-height' %d",
"'start-height' %d must not be smaller than 'end-height' %d",

for _, en := range requestedENIdentifiers {
id, exists := allIdentities.ByNodeID(en)
if !exists {
return nil, admin.NewInvalidAdminReqParameterError("execution-node-ids", "could not found execution nodes by provided ids", executionNodeIdsIn)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add the specific nodeID that's missing to the error. that would make it easier to debug

}

blockID := header.ID()
err = b.txErrorMessagesCore.HandleTransactionResultErrorMessagesByENs(ctx, blockID, data.executionNodeIds.ToSkeleton())
Copy link
Contributor

Choose a reason for hiding this comment

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

rather than calling data.executionNodeIds.ToSkeleton() each height and rebuilding the list, either cache it before the loop, or store the IdentitySkeletonList into data.

@@ -303,13 +303,10 @@ func (b *backendEvents) getBlockEventsFromExecutionNode(
// choose the last block ID to find the list of execution nodes
lastBlockID := blockIDs[len(blockIDs)-1]

execNodes, err := rpc.ExecutionNodesForBlockID(ctx,
execNodes, err := b.execNodeIdentitiesProvider.ExecutionNodesForBlockID(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

	execNodes, err := b.execNodeIdentitiesProvider.ExecutionNodesForBlockID(ctx, lastBlockID)

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
4 participants