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

Log Transaction Codes and Operation Traces #228

Merged
merged 2 commits into from
Mar 5, 2024
Merged

Conversation

sydneynotthecity
Copy link
Contributor

Adding transaction and operation level trace codes to stellar-etl. This gives a more detailed view into error reasons when a transaction fails to execute successfully.

@sydneynotthecity sydneynotthecity requested a review from a team as a code owner March 5, 2024 06:11
case xdr.OperationTypeRestoreFootprint:
operationTraceDescription = operationTrace.RestoreFootprintResult.Code.String()
default:
return operationTraceDescription, fmt.Errorf("Unknown operation type: %s", operationTrace.Type.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think operationTrace.Type.String() would cause an error if the OperationType is bad.

// String returns the name of `e`
func (e OperationType) String() string {
	name, _ := operationTypeMap[int32(e)]
	return name
}

And operationTypeMap[int32(e)] would return a invalid key in map or something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought this default error was designed to raise when the Operation Type is valid, we just haven't mapped it in our case statements. The behavior mirrors the way we define mapOperationType. My understanding is if the operationtype itself is bad, our code would already error and be unable to parse that operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want to change how we handle that in both functions? And if so, any guidance? Looks like the operation.Type.String() function does not return an error, so we don't have the ability to pass the error through

Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is if the operationtype itself is bad, our code would already error and be unable to parse that operation

Ah you're right. I think the only time this would actually be a problem is if XDR was updated ahead of what stellar-etl is using. And most likely something else would error out before it even reached this point

Do you want to change how we handle that in both functions?

Nope it's fine as is

@sydneynotthecity sydneynotthecity merged commit 68b8588 into master Mar 5, 2024
4 checks passed
@sydneynotthecity sydneynotthecity deleted the add-error-codes branch March 5, 2024 22:29
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.

2 participants