Skip to content

Conversation

@whankinsiv
Copy link
Collaborator

@whankinsiv whankinsiv commented Nov 10, 2025

Description

This PR implements the /addresses/{address}/total and /accounts/{stake_address}/total endpoints. It also refactors apply_address_deltas to fix a bug that overcounted total transaction counts for address UTxO deltas within the same transaction.

Related Issue(s)

#256 & #335

How was this tested?

  • Added unit test to ensure transaction identifiers are deduplicated during same block processing.
  • Added unit test to ensure deltas for the same transaction have their ValueDelta values summed correctly.
  • Compared REST responses against Blockfrost using addresses with long standing balances such as addr1q8n...3qve5s.

Checklist

  • My code builds and passes local tests
  • I added/updated tests for my changes, where applicable
  • I updated documentation (if applicable)
  • CI is green for this PR

Impact / Side effects

No major side effects. Converting ValueDelta to ValueDeltaMap before summing same address
same transaction UTxO deltas adds a minor performance cost, but fixes overcounting.
Note: total tx count for the accounts version of this endpoint will need to be persisted in historical_accounts_state, since summing address counts overestimates totals for multi-address transactions. This will be implemented in a follow up PR.

Reviewer notes / Areas to focus

apply_address_deltas in modules/address_state/src/state.rs. Considering a potential refactor of the upstream AddressDeltas publisher in utxo_state to pre aggregate deltas by transaction before publishing.

…nting txs

Signed-off-by: William Hankins <william@sundae.fi>
Signed-off-by: William Hankins <william@sundae.fi>
Signed-off-by: William Hankins <william@sundae.fi>
…x entries

Signed-off-by: William Hankins <william@sundae.fi>
@whankinsiv whankinsiv changed the title feat: address and account totals REST endpoints feat: address totals REST endpoint Nov 11, 2025
Signed-off-by: William Hankins <william@sundae.fi>
…cessed

Signed-off-by: William Hankins <william@sundae.fi>
@whankinsiv whankinsiv marked this pull request as ready for review November 11, 2025 23:22
}

#[tokio::test]
async fn test_same_tx_deltas_sums_totals_in_volatile() -> Result<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice tests

)
.await?;

// TODO: Query historical accounts state to retrieve account tx count instead of
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good TODO / comment here.

@whankinsiv whankinsiv merged commit 5eb7ff9 into main Nov 12, 2025
2 checks passed
@whankinsiv whankinsiv deleted the whankinsiv/totals-endpoints branch November 12, 2025 17:02
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.

4 participants