Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Many SPL tokens have an associated metadata account but lack a defined
token_standard
. The current ingester version incorrectly categorizes such SPL tokens as having anownership_type
due to this undefinedtoken_standard
. Thetoken_account_update
handler, responsible for account changes, references the associatedasset
. If thetoken_account
's held amount ist.amount > 0 AND asset.ownership_type == OwnerType::Single
, the asset's owner field updates to the token account's owner. This leads to SPL token exchanges triggering frequent ownership updates on the asset, resulting in excessive single-row updates in the database. These updates cause locks that severely hamper the database's message processing capabilities, leading to queue backups.Fix
The logic dictating when an asset is marked as single and an associated token account update occurs. Ownership changes now only trigger when the amount is exactly 1. Additionally, when saving an asset where the single ownership case is activated, only token accounts with an amount of 1 are returned. Changes in single ownership should exclusively represent the exchange of 1 amount between token accounts. Values exceeding 1 inherently suggest the token is fungible.
Disclaimer
This approach is not entirely accurate logically, as fungible tokens can experience a transfer scenario where exactly 1 unit is exchanged. However, this is highly improbable in practice, considering that mints typically have a decimal field where 1 "token" represents an amount of 1,000,000.
While this PR doesn't rectify the incorrect assignment of SPL tokens when
token_standard
is unset, it effectively prevents unnecessary ownership updates from being triggered.