Skip to content

Conversation

jkawan
Copy link
Contributor

@jkawan jkawan commented Sep 1, 2025

  1. Create Assets table and related get and set functions
  2. Added Assets to Utxo table

For the fields in Assets table, took reference from this : https://github.com/Andamio-Platform/andamio-indexer/blob/master/database/plugin/metadata/sqlite/models/asset.go

Closes #339

Jenita added 4 commits August 18, 2025 21:45
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
@jkawan jkawan requested a review from a team as a code owner September 1, 2025 22:18
Signed-off-by: jkawan <kawanjenita@outlook.com>
@jkawan jkawan changed the title Added changes to add Assets to Utxo table to track coin amount Added changes to add Assets to Utxo table to track assets Sep 1, 2025
Signed-off-by: Jenita <jkawan@blinklabs.io>
Jenita added 5 commits September 14, 2025 00:53
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Jenita added 4 commits September 14, 2025 01:00
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Copy link
Member

@wolf31o2 wolf31o2 left a comment

Choose a reason for hiding this comment

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

This is in the right direction. Since Asset is always connected to Utxo, they should be saved along with Utxo and returned with them.


// GetAssetsByUTxO returns all assets for a given UTxO
func (d *MetadataStoreSqlite) GetAssetsByUTxO(
utxoId uint,
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for being unclear previously. Getting Assets by UTxO should use the reference, the combination of txId []byte and idx uint32 which we can look up the Utxo using the compound index.

}

// SetAsset saves an asset into the database
func (d *MetadataStoreSqlite) SetAsset(
Copy link
Member

Choose a reason for hiding this comment

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

Remove write functionality here. The only way to create/update/delete an asset is via a transaction and a UTxO. You should move handling of the assets to the Utxo functions.

payment []byte, // payment
stake []byte, // stake
amount uint64, // amount
asset *lcommon.MultiAsset[lcommon.MultiAssetTypeOutput], // asset
Copy link
Member

Choose a reason for hiding this comment

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

This should be assets (it's multi-asset, so multiple). Add them to tmpUtxo.Assets before saving tmpUtxo if it's not nil.

return tmpUtxo, err
}
tmpUtxo = Utxo(utxo)
tmpUtxo = Utxo{
Copy link
Member

Choose a reason for hiding this comment

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

We need to add assets to the Utxo struct above so this doesn't need to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wolf31o2 what should be the type for assets in Utxo struct here ?

Copy link
Member

Choose a reason for hiding this comment

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

*lcommon.MultiAsset[T]

Copy link
Contributor

Choose a reason for hiding this comment

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

The type that we're getting from d.metadata.GetUtxo() is a models.Utxo with an embedded []models.Asset. We can create a duplicate Asset type in this package and modify the duplicate Utxo type accordingly in the short term, but we're eventually going to need to do some conversion to get it back in a lcommon.MultiAsset. It probably makes sense to just do that here, since this PR already has a conversion function for the other direction.

Jenita and others added 3 commits September 19, 2025 20:38
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
@wolf31o2 wolf31o2 changed the title Added changes to add Assets to Utxo table to track assets feat: track assets with utxos Oct 2, 2025
@wolf31o2
Copy link
Member

wolf31o2 commented Oct 3, 2025

While trying to test this, I ran into an interesting issue.

{"time":"2025-10-02T20:36:17.258199-04:00","level":"ERROR","msg":"failed to process block: add produced UTxO: sql: converting argument $36 type: uint64 values with high bit set are not supported"}

This only occurs with Asset tracking. Checking the Dingo tip, we're here:

Ledger Tip: Slot: 31283557, Hash: d6dba37f653ebfa2f6bd8261673e270f7c03ada3cef86a7f48f34144aee373d5

The block after d6b is bf6bdd159d595cac19ebd2b51ff4cb81b6022192372288718e528de26581ac2f which includes Tx 901d297b9c56b2e8efd273c3778c90636d62a304e4f291029dc271e1ce5f00ce which is doing some mad stuff with minting and outputs.

Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
@wolf31o2 wolf31o2 merged commit 5354f19 into main Oct 3, 2025
11 checks passed
@wolf31o2 wolf31o2 deleted the track-asset branch October 3, 2025 18:57
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.

Track coin amount and assets for UTxOs
3 participants