Skip to content
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

tapdb: expand allowed proof types in universe-related tables #1386

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Roasbeef
Copy link
Member

This commit introduces a migration that expands the allowed values for the "proof_type" column in the universe-related tables by adding new proof types: "burn" and "ignore".

Key changes include:

  • Creation of a new table proof_types to store valid proof type values. Before this commit, we used a CHECK statement. With the way sqlite works, we can't alter the CHECK statement, and just dropping the row would lose data.

    So instead, we add a new enum-like table instead. This can be updated in future migrations to add new proof types. We then do a migration to update all tables to use this instead.

  • Updates to the universe_roots, federation_global_sync_config, and federation_uni_sync_config tables to accommodate the new proof types. This involves adding a new column proof_type_ext that references the proof_types table, copying existing data, and renaming columns to maintain the original structure.

  • A new test case TestMigration29 has been added to ensure the migration works as expected, verifying both the migration of existing data and the insertion of new rows with the new proof types.

  • The .gitignore file has been updated to exclude files matching the pattern .aider*.

Additionally, a down migration script has been created to revert these changes if necessary. This ensures that the database schema can be rolled back to its previous state without data loss.

@coveralls
Copy link

coveralls commented Feb 14, 2025

Pull Request Test Coverage Report for Build 13448911508

Details

  • 18 of 21 (85.71%) changed or added relevant lines in 5 files are covered.
  • 31 unchanged lines in 11 files lost coverage.
  • Overall coverage increased (+0.009%) to 54.426%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapdb/universe_stats.go 5 8 62.5%
Files with Coverage Reduction New Missed Lines %
commitment/tap.go 1 85.0%
fn/context_guard.go 1 88.71%
asset/asset.go 2 79.74%
asset/group_key.go 2 72.65%
tapgarden/custodian.go 2 75.54%
asset/mock.go 3 72.3%
itest/assertions.go 3 90.52%
itest/multisig.go 3 97.86%
proof/courier.go 3 80.02%
tapchannel/aux_leaf_signer.go 3 43.43%
Totals Coverage Status
Change from base Build 13435465457: 0.009%
Covered Lines: 48623
Relevant Lines: 89338

💛 - Coveralls

-- ******************************************************************************************

-- For universe_roots
ALTER TABLE universe_roots ADD COLUMN proof_type TEXT NOT NULL CHECK(proof_type IN ('issuance', 'transfer'));
Copy link
Member

Choose a reason for hiding this comment

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

seems like you're using a max line length 100 here, instead of 80

Copy link
Member Author

Choose a reason for hiding this comment

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

So I don't think we currently have that rule for SQL queries. Eg: queries/mssmt.sql

This commit introduces a migration that expands the allowed values for
the "proof_type" column in the universe-related tables by adding new
proof types: "burn" and "ignore".

Key changes include:
- Creation of a new table `proof_types` to store valid proof type
  values. Before this commit, we used a `CHECK` statement. With the way
  sqlite works, we can't _alter_ the `CHECK` statement, and just
  dropping the row would lose data.

  So instead, we add a new enum-like table instead. This can be updated
  in future migrations to add new proof types. We then do a migration to
  update all tables to use this instead.

- Updates to the `universe_roots`, `federation_global_sync_config`, and
  `federation_uni_sync_config` tables to accommodate the new proof
  types. This involves adding a new column `proof_type_ext` that
  references the `proof_types` table, copying existing data, and
  renaming columns to maintain the original structure.

- A new test case `TestMigration29` has been added to ensure the
  migration works as expected, verifying both the migration of existing
  data and the insertion of new rows with the new proof types.

- The `.gitignore` file has been updated to exclude files matching the
  pattern `.aider*`.

Additionally, a down migration script has been created to revert these
changes if necessary. This ensures that the database schema can be
rolled back to its previous state without data loss.
@@ -632,6 +619,10 @@ CREATE TABLE proof_transfer_log (
time_unix TIMESTAMP NOT NULL
);

CREATE TABLE proof_types (
Copy link
Member Author

Choose a reason for hiding this comment

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

Nice part about this is that you can spot check the end result of a migration.

allow_sync_insert BOOLEAN NOT NULL,

-- This field is a boolean that indicates whether or not the given universe
-- should accept remote proof export via federation sync.
allow_sync_export BOOLEAN NOT NULL,
allow_sync_export BOOLEAN NOT NULL, proof_type TEXT REFERENCES proof_types(proof_type),
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure why it didn't do a new line here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

4 participants