Skip to content

Conversation

@whankinsiv
Copy link
Collaborator

@whankinsiv whankinsiv commented Nov 7, 2025

Description

This PR implements the /accounts/{stake_address}/addresses/assets endpoint. It also refactors the ImmutableAddressStore to merge block deltas in memory before persistence, fixing a bug where UTxOs spent in the same epoch they were created not being removed correctly.

Related Issue(s)

#256 & #335

How was this tested?

Compared REST responses against Blockfrost using accounts with long standing balances such as stake1u88...cq5e4eww.
Screenshot 2025-11-07 at 3 18 28 PM
The handler itself serves as a runtime correctness test. The query fails if address_state returns any UTxO not found in utxo_state.

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

Merging block deltas in memory before persistence reduces DB access frequency, improving sync performance when address UTxO, transaction, or totals indexing is enabled.

Reviewer notes / Areas to focus

Most logic changes are in modules/address_state/src/immutable_address_store.rs.
A known bug in totals persistence (tx count) will be addressed in a follow up PR implementing the /accounts/{stake_address}/addresses/total endpoint.

Signed-off-by: William Hankins <william@sundae.fi>
Signed-off-by: William Hankins <william@sundae.fi>
Signed-off-by: William Hankins <william@sundae.fi>
Signed-off-by: William Hankins <william@sundae.fi>
Signed-off-by: William Hankins <william@sundae.fi>
Signed-off-by: William Hankins <william@sundae.fi>
@whankinsiv whankinsiv marked this pull request as ready for review November 8, 2025 00:06
Signed-off-by: William Hankins <william@sundae.fi>

for block_map in drained_blocks {
for (addr, entry) in block_map {
let target = merged.entry(addr.clone()).or_insert_with(MergedDeltas::default);
Copy link
Collaborator

@lowhung lowhung Nov 8, 2025

Choose a reason for hiding this comment

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

Why do we insert defaults as our fallback here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is to populate an empty entry for an address if the current block delta is the first time the address is detected in the epoch.

Signed-off-by: William Hankins <william@sundae.fi>
@whankinsiv whankinsiv merged commit 1db69bc into main Nov 10, 2025
2 checks passed
@whankinsiv whankinsiv deleted the whankinsiv/accounts-assets-endpoint branch November 10, 2025 21:32
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