Skip to content

tapdb: implement basic migration downgrade protection #973

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

Merged
merged 3 commits into from
Jun 26, 2024

Conversation

Roasbeef
Copy link
Member

In this commit, we implement basic migration downgrade protection. This ensures that tapd will refuse to downgrade versions if a migration happened in the latest software version.

We achieved this by hard coding the latest version as a constant. Then when we go to migrate, we check this version against the latest version stored in the database. If the hard coded version is less than the latest version, then we conclude this is a downgrade attempt.

@Roasbeef Roasbeef requested a review from jharveyb June 25, 2024 21:37
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 👍🏽

Confirmed that this failed in itest if I downgraded LeatestMigrationVersion to 20. mint_batch_resume failed as we restart a node there.

In this commit, we implement basic migration downgrade protection. This
ensures that tapd will refuse to downgrade versions if a migration
happened in the latest software version.

We achieved this by hard coding the latest version as a constant. Then
when we go to migrate, we check this version against the latest version
stored in the database. If the hard coded version is less than the
latest version, then we conclude this is a downgrade attempt.
@Roasbeef Roasbeef force-pushed the prevent-db-downgrade branch from f288136 to 5b6c6b8 Compare June 26, 2024 00:50
@dstadulis dstadulis added this to the v0.4 milestone Jun 26, 2024
@dstadulis dstadulis requested review from ffranr and gijswijs and removed request for ffranr June 26, 2024 06:27
@guggero
Copy link
Member

guggero commented Jun 26, 2024

Added a commit to check the hard coded version in the Golang code with a CI step.

Copy link
Member

@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.

tACK, LGTM 🎉

@guggero guggero merged commit d2148ce into lightninglabs:main Jun 26, 2024
15 checks passed
@ffranr ffranr mentioned this pull request Jul 8, 2024
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.

4 participants