Skip to content

Conversation

AmbientTea
Copy link
Contributor

@AmbientTea AmbientTea commented Jul 16, 2025

Description

Showcase of changes to the queries required to make use of the tx_out.value = "consumed" option in db-sync configuration. When this option is set:

  1. the tx_out table has an additional column consumed_by_tx_id which references the transaction in tx table that consumed given output
  2. the tx_in does not exist
    In practice this means we can use a single join between tx and tx_out when we need to determine inputs to a transaction instead of two joins going through tx_in, which also makes the queries easier to understand.

Next steps

If we decide to support this option, I see three ways to go about it:

  1. update the queries and strictly require db-sync to be configured with tx_out.value = "consumed"
  2. preserve the old queries, supporting both old and new configurations, and either:
    a. let the user control which queries are run by some TX_OUT_STYLE environment variable
    b. automatically detect the setting by checking for existence of tx_in

I lean towards option 1

Testing

I run two nodes compiled from this branch and master and they synced each other's blocks without issues.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages.
  • The size limit of 400 LOC isn't needlessly exceeded
  • The PR refers to a JIRA ticket (if one exists)
  • New tests are added if needed and existing tests are updated.
  • New code is documented and existing documentation is updated.
  • Relevant logging and metrics added
  • Any changes are noted in the changelog.md for affected crate
  • Self-reviewed the diff

@AmbientTea AmbientTea marked this pull request as ready for review July 16, 2025 10:04
@gilligan
Copy link
Contributor

I lean towards option 1

yeah, for sure. I think option 2 just introduces too much complication..

@AmbientTea AmbientTea closed this Jul 25, 2025
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