Skip to content

Conversation

Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented Nov 9, 2024

In this commit, we fix some incorrect handling on null bool in SQL, that
looks to be mostly benign. Before this commit, instead of doing .Bool,
we did .Valid. The latter is only useful to check if something is
zero, or NULL. In this case, we can just go with the bool value
directly.

Then, we update InsertScriptKey to allow flipping known to
true, if it was false before.

This is useful as at times a script key from a smart contract might have
been inserting on disk, but with declared known as false. Then if we
tried to insert it again, with known as true, the upsert logic would end
up making no change on disk.

Note that without the initial bug fix, the test added in the last commit
would fail.

@Roasbeef Roasbeef requested review from a team, ffranr and jharveyb and removed request for a team November 9, 2024 01:44
@coveralls
Copy link

coveralls commented Nov 9, 2024

Pull Request Test Coverage Report for Build 11808369738

Details

  • 19 of 19 (100.0%) changed or added relevant lines in 5 files are covered.
  • 14 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.02%) to 40.629%

Files with Coverage Reduction New Missed Lines %
tappsbt/create.go 2 53.22%
asset/asset.go 2 80.02%
tapgarden/caretaker.go 4 68.5%
commitment/tap.go 6 84.7%
Totals Coverage Status
Change from base Build 11804776121: 0.02%
Covered Lines: 24698
Relevant Lines: 60789

💛 - Coveralls

Copy link
Contributor

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the fix!

@jharveyb
Copy link
Contributor

In this commit, we fix some incorrect handling on null bool in SQL, that looks to be mostly benign. Before this commit, instead of doing .Bool, we did .Valid. The latter is only useful to check if something is zero, or NULL. In this case, we can just go with the bool value directly.

This only works for bools that are always set? Vs. other bools that are optional.

I think this would be correct for any spot where we insert data created with sqlBool().

Copy link
Contributor

@jharveyb jharveyb left a comment

Choose a reason for hiding this comment

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

Looks reasonable, though I wonder if we can have an equivalent fix just by changing the existing query; commented separately.

@Roasbeef Roasbeef changed the base branch from main to robust-sqlc-gen November 12, 2024 01:40
@Roasbeef Roasbeef force-pushed the script-key-upsert branch 2 times, most recently from c27ea4d to 922448d Compare November 12, 2024 01:57
@Roasbeef Roasbeef requested review from guggero and jharveyb and removed request for ffranr November 12, 2024 01:58
@Roasbeef
Copy link
Member Author

@guggero @jharveyb PTAL.

@Roasbeef Roasbeef changed the base branch from robust-sqlc-gen to main November 12, 2024 02:49
In this commit, we add a new `extractBool` helper function. In an
upcoming commit, we'll use this to fix incorrect usage of the
`sql.NullBool` type.
In this commit, we fix some incorrect handling on null bool in SQL, that
looks to be mostly benign. Before this commit, instead of doing `.Bool`,
we did `.Valid`. The latter is only useful to check if something is
zero, or NULL. In this case, we can just go with the bool value
directly.
In this commit, we update `InsertScriptKey` to allow flipping known to
true, if it was false before.

This is useful as at times a script key from a smart contract might have
been inserting on disk, but with declared known as false. Then if we
tried to insert it again, with known as true, the upsert logic would end
up making no change on disk.
Copy link
Contributor

@guggero guggero left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

Copy link
Contributor

@jharveyb jharveyb left a comment

Choose a reason for hiding this comment

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

LGTM 💯

@guggero guggero merged commit a17ea40 into lightninglabs:main Nov 13, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

5 participants