-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix duplicate asset creation in itest #965
Conversation
651af43
to
1083cf1
Compare
bceae3b
to
dd8ba78
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR touches ApplyPendingOutput
which creates new assets. We still need to address Oli's comment about not reusing lock_time and relative_lock_time from the spent asset. See:
taproot-assets/tapdb/assets_store.go
Lines 2781 to 2784 in daf9676
// TODO(guggero): This will need an update once we want | |
// to support full lock_time and relative_lock_time | |
// support. | |
templateID := spentAssetIDs[0] |
Although not relevant for this specific PR, I wanted to raise it here for future reference.
dd8ba78
to
16ae4dd
Compare
1083cf1
to
84c739d
Compare
16ae4dd
to
42a9d57
Compare
lgtm 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great catch 👍🏽
Fixes #691 by adding a unique constraint that will actually work. The assumption of the constraint is that there will never be an asset of the same asset ID with the same script key in the same anchor transaction output. This would be impossible anyway because the asset leaves would collide within the asset-level MS-SMT tree. So this unique key is safe to use as an upsert detection mechanism.
To make sure we don't insert duplicate assets, we turn all queries that insert into the assets table into upserts.
The test that discovered the duplicate asset issue in the first place would've shown the issue more clearly if we actually asserted the number of asset UTXOs created. We now add this assertion to make sure we only have the expected number of assets in the asset table.
42a9d57
to
e6713c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🦔
Fixes #691.
Depends on #954.
It turns out that in one of our itests (
multi_address
), because we do an address self-transfer, we sometimes created duplicate asset entries, if the timing was unfortunate.Basically both the send logic (freighter) as well as the address receive logic (custodian) inserted the same asset (one materializing it from the transfer output, the other from the proof found in the DB).