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

Move public tx listing API to host DB query #1900

Merged
merged 9 commits into from
May 8, 2024
Merged

Conversation

badgersrus
Copy link
Contributor

@badgersrus badgersrus commented May 8, 2024

Why this change is needed

We currently query this from the enclave client but its producing some strange pagination errors and we don't need to access the enclave for this data now we have it in the host DB.

https://github.com/ten-protocol/ten-internal/issues/3324

What changes were made as part of this PR

  • Expose a new FetchTransactions API to the host DB
  • Switch the underlying call Tenscan API from the EnclaveClient to the new host interface method
  • Refactored the transactions APIs into a new file
  • Renamed the table transactions_host > transaction_host to match naming convention
  • Remove the now redundant EnclaveClient API

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

@badgersrus badgersrus requested review from tudor-malene and BedrockSquirrel and removed request for tudor-malene May 8, 2024 14:02
Copy link
Collaborator

@BedrockSquirrel BedrockSquirrel left a comment

Choose a reason for hiding this comment

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

LGTM, couple minor things

"fmt"
"math/big"

common2 "github.com/ethereum/go-ethereum/common"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Something's gone awry here, this looks the same as the gethcommon import below (which is the naming convention we've been using, Goland autogenerates common2 sometimes).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Kinda crappy that the linter doesn't pick this up...

query := selectTxs + db.GetSQLStatement().Pagination
rows, err := db.GetSQLDB().Query(query, pagination.Size, pagination.Offset)
if err != nil {
return nil, err
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a pain in the ass but good practice to wrap all these errors with a short description, because it makes it easier to figure out what step an error came from when debugging.

e.g. return nil, fmt.Errorf("unable to execute query - %w", err)

There's a couple more of these return errs below so be good to remove the ambiguity with them too 🙏

Copy link
Collaborator

@BedrockSquirrel BedrockSquirrel left a comment

Choose a reason for hiding this comment

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

j'approve

@badgersrus badgersrus removed the request for review from tudor-malene May 8, 2024 14:47
@badgersrus badgersrus merged commit 3eb620f into main May 8, 2024
2 checks passed
@badgersrus badgersrus deleted the will/tx-api-pagination branch May 8, 2024 15:18
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