Skip to content

Maintain an auxillary state locally to reduce the bandwidth#144

Merged
adithyaov merged 6 commits intomainfrom
minimal-utxo
Feb 18, 2026
Merged

Maintain an auxillary state locally to reduce the bandwidth#144
adithyaov merged 6 commits intomainfrom
minimal-utxo

Conversation

@adithyaov
Copy link
Member

@adithyaov adithyaov commented Feb 12, 2026

Closes: #122

  • Cleanup
  • Test

Copy link
Contributor

@axman6 axman6 left a comment

Choose a reason for hiding this comment

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

Looks interesting, I hadn't considered this approach. Just making sure I understand, we're basically keeping the UTxO map in memory, but filtered to only scripts? Any idea what effect this has on memory? I imagine it's not too bad (and if we really need to bring memory usage down, we could specialise things).

Does this handle the case where a script is added to the ledger after the app starts? That will be the common case when starting from genesis. I couldn't quite follow how the scan was working.

I assume the big pay off here is that we now know when a script uses a script that we care about so only need to request UTxO state when we see that, and not for every block?

@adithyaov
Copy link
Member Author

we're basically keeping the UTxO map in memory, but filtered to only scripts? Any idea what effect this has on memory? I imagine it's not too bad (and if we really need to bring memory usage down, we could specialise things).

Yes, we start with some valid utxo map and incrementally build it while going through blocks.

and if we really need to bring memory usage down, we could specialise things

I'm not sure what this means. Do you mean specialise a function?

Does this handle the case where a script is added to the ledger after the app starts? That will be the common case when starting from genesis. I couldn't quite follow how the scan was working.

Yes. TLDR:

Invariant on the local UTxO map: It only contains the UTxOs with script addressess that have an intersection with the configured scripts.

The PSR can start at any chainpoint. When it start we create the local UTxO map.
While consuming transactions in a block we modify the local UTxO map while maintaining these invariants.

I assume the big pay off here is that we now know when a script uses a script that we care about so only need to request UTxO state when we see that, and not for every block?

Yes. 2 big pay offs:

  1. Skip blocks without interesting transactions.
  2. The filter that queries the UTxO state is more agressive - we only query the inputs of transactions that are interesting.

@adithyaov adithyaov marked this pull request as ready for review February 17, 2026 10:12
Comment on lines +1 to +9
#!/usr/bin/env bash

while true; do
clear
curl -s http://localhost:8090/metrics |
grep -v -E '^(#)' |
awk '{ printf "\033[1;36m%-60s\033[0m \033[1;33m%s\033[0m\n", $1, $2 }'
sleep 1
done
Copy link
Member Author

Choose a reason for hiding this comment

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

Will we use this?
We can remove this now and maybe add this on demand,

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can keep it

Copy link
Collaborator

@tweag-ev-ak tweag-ev-ak left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@axman6 axman6 left a comment

Choose a reason for hiding this comment

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

LGTM! Great work, this should really improve how often we query the node.

@adithyaov adithyaov merged commit bbd25c6 into main Feb 18, 2026
2 checks passed
@adithyaov adithyaov deleted the minimal-utxo branch February 18, 2026 11:54
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.

Filter the UTxO map based only on the script inputs (and not the transactions that exist in the block)

3 participants

Comments