Skip to content

Conversation

guggero
Copy link
Contributor

@guggero guggero commented Jun 19, 2025

We added the dedicated burn table after introducing the burn functionality. Which means, some asset burns users made before the table was added didn't show up when querying burns with tapcli assets listburns (only when listing all assets, the is_burn: true would show in the output).

This fixes the problem by inserting any asset burns into the dedicated table.
We also fix an issue with the type of the foreign key.

@Roasbeef does this also have an impact on the burn tree? Should we also insert the burns there?

@guggero guggero requested a review from Roasbeef June 19, 2025 16:01
@Roasbeef
Copy link
Member

does this also have an impact on the burn tree? Should we also insert the burns there?

Not yet, as we haven't hooked up inserting elements into the tree yet. We also haven't implemented retroactively creation of supply updates into the tree.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🩱

burn_id INTEGER PRIMARY KEY,

-- A reference to the primary key of the transfer that includes this burn.
transfer_id BIGINT NOT NULL REFERENCES asset_transfers(id),
Copy link
Member

Choose a reason for hiding this comment

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

So we only need to make this BIGINT for foreign key refs? Do we need to do this anywhere else? '

I think in some of my recent PRs, I don't declare foreign key refs as BIGINT.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should add a new linting script for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if the primary key that is referenced is INTEGER PRIMARY KEY then it will become a BIGSERIAL PRIMARY KEY on postgres and the foreign key should be BIGINT to match that (you'll mainly notice because you have to cast the ID from int32 to int64 and back in the tapdb Golang code.
I did a quick scan and the only other instance I found was mint_anchor_uni_commitments.batch_id. Perhaps this can be updated in one of the in-flight PRs?

I also started looking into sqlfluff that can do linting and also custom plugins, so we could add our own rule. Will create a PR soon.

@coveralls
Copy link

coveralls commented Jun 20, 2025

Pull Request Test Coverage Report for Build 15845300932

Details

  • 64 of 83 (77.11%) changed or added relevant lines in 2 files are covered.
  • 14 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.1%) to 38.455%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapdb/assets_store.go 0 5 0.0%
tapdb/post_migration_checks.go 64 78 82.05%
Files with Coverage Reduction New Missed Lines %
address/address.go 2 70.93%
asset/group_key.go 2 62.64%
tapchannel/aux_leaf_signer.go 2 43.08%
tappsbt/create.go 2 26.74%
tapgarden/caretaker.go 6 67.63%
Totals Coverage Status
Change from base Build 15845204436: 0.1%
Covered Lines: 29213
Relevant Lines: 75967

💛 - Coveralls

@levmi levmi added the burning label Jun 23, 2025
@levmi levmi moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board Jun 23, 2025
@levmi levmi moved this from 🏗 In progress to 👀 In review in Taproot-Assets Project Board Jun 23, 2025
Copy link
Member

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix!

@GeorgeTsagk GeorgeTsagk added this pull request to the merge queue Jun 24, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 24, 2025
guggero added 2 commits June 24, 2025 10:26
This aligns the foreign key to be the same type as the referenced
table's primary key. This was an oversight that resulted from our type
replacement map we use to change the types of our primary keys to be
compatible with what SQLite and Postgres support.
So even though all our primary keys in the SQL files are defined as
INTEGER PRIMARY KEY, they are rewritten to BIGSERIAL PRIMARY KEY in
Postgres to allow auto increment, which corresponds to a BIGINT.
See scripts/gen_sqlc_docker.sh for a more in-depth explanation.
We only added the burn table in the most recent release. But users might
have burned assets before, which wouldn't be shown when listing burns
(only with is_burn=true when listing assets).
This migration retroactively inserts burned assets into the burn table
that aren't there yet.
@guggero guggero merged commit 2e91cb5 into main Jun 24, 2025
17 of 18 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Jun 24, 2025
@guggero guggero deleted the insert-burns branch June 24, 2025 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants