Skip to content

Conversation

whankinsiv
Copy link
Collaborator

@whankinsiv whankinsiv commented Sep 2, 2025

This PR introduces native asset decoding support in tx_unpacker and integrate it with utxo_state storage. TxOutputs now carry full Values (lovelace + assets) instead of only lovelace. These are propagated through UTXODeltasMessage into ledger storage.

Main changes:

  • Added Value and ValueDelta types to represent balances:
pub struct Value {
    pub lovelace: u64,
    pub assets: NativeAssets,
}
pub struct ValueDelta {
    pub lovelace: i64,
    pub assets: Vec<(PolicyId, Vec<NativeAssetDelta>)>,
}
pub struct NativeAsset {
    pub name: AssetName,  
    pub amount: u64,
}
pub struct NativeAssetDelta {
    pub name: AssetName,  
    pub amount: i64,
}
  • Added map_value() in tx_unpacker/src/map_parameters to decode Pallas MultiEraValue into Value.
  • Updated TxOutput to use Valueinstead of a raw u64.
  • Refactored /utxo_state/state.rs to process and persist native asset vectors.
  • Refactored /utxo_state/rest.rs to expose asset balances in REST responses.

Memory usage benchmark (epoch 300):
main: 2.465 GB
this branch: 2.854 GB

@whankinsiv whankinsiv changed the title feat: add multi-asset decoding to TxOutput feat: add native asset decoding to tx_unpacker Sep 2, 2025
@whankinsiv whankinsiv changed the title feat: add native asset decoding to tx_unpacker feat: add native asset decoding to tx_unpacker and store balances in utxo_state Sep 4, 2025
Copy link
Collaborator

@sandtreader sandtreader left a comment

Choose a reason for hiding this comment

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

Looks great generally - just concern about use of expect() and would like unit tests extended too.

@whankinsiv
Copy link
Collaborator Author

All feedback has been implemented. Merging so that I can continue progress on #148.

@whankinsiv whankinsiv merged commit 30a5585 into main Sep 5, 2025
2 checks passed
@whankinsiv whankinsiv deleted the whankinsiv/multiassets-in-utxo-deltas branch September 5, 2025 19:53
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.

3 participants