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

cleanup: remove invite code from client db #4326

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

joschisan
Copy link
Contributor

@joschisan joschisan commented Feb 14, 2024

We can generate invite codes from the client config, the separate invite code in the db is a remnant from a time when we had to request an invite code from the guardian.

@justinmoon
Copy link
Contributor

Does this require a client migration? We'll be leaving behind a key in the database that may represent something else in the future.

@justinmoon
Copy link
Contributor

justinmoon commented Feb 23, 2024

Now that #3417 is closed, we should be able to write this migration?

Copy link
Contributor

@elsirion elsirion left a comment

Choose a reason for hiding this comment

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

Two nts, what do you think about merge order @joschisan?

@@ -19,7 +19,7 @@ pub enum DbKeyPrefix {
ChronologicalOperationLog = 0x2d,
CommonApiVersionCache = 0x2e,
ClientConfig = 0x2f,
ClientInviteCode = 0x30,
ClientInviteCode = 0x30, // Unused, we can get an invite code from the client config
Copy link
Contributor

Choose a reason for hiding this comment

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

As long as this stays here future developers will know to clean out remnant data before re-using, but ideally we'd add a migration that removes all entries with that prefix, then we can also remove this enum variant.

Copy link
Contributor

Choose a reason for hiding this comment

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

@joschisan what are your thoughts about this?

Copy link
Contributor Author

@joschisan joschisan Mar 9, 2024

Choose a reason for hiding this comment

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

I added a comment about cleaning out remnants before reusing and would not do it for now as it would need a new migration hook for non-module db migration and maybe we get a chance in the future to toss it out with less effort, should we ever make a breaking change to the client for some unrelated reason for example.

Comment on lines 619 to 628
let invite_code = client_config
.global
.api_endpoints
.get(&peer)
.map(|peer_url| {
InviteCode::new(peer_url.url.clone(), peer, client_config.federation_id())
})
.ok_or_cli_msg(CliErrorKind::GeneralFailure, "peer not found")?;
Copy link
Contributor

Choose a reason for hiding this comment

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

If we merged #4297 first we wouldn't have to manually construct the invite here but could rather use ClientConfig::invite_code(&Self, PeerId).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I always intended to rebase on #4297, that's why this is still a draft.

@joschisan joschisan force-pushed the rm_invite_code branch 3 times, most recently from 09d5e1b to c6fb0bd Compare February 23, 2024 14:35
@joschisan joschisan force-pushed the rm_invite_code branch 3 times, most recently from 8ebf37e to f183a63 Compare March 9, 2024 07:12
@joschisan joschisan marked this pull request as ready for review March 9, 2024 08:16
@joschisan joschisan requested review from a team as code owners March 9, 2024 08:16
@@ -35,7 +35,7 @@ pub enum DbKeyPrefix {
ChronologicalOperationLog = 0x2d,
CommonApiVersionCache = 0x2e,
ClientConfig = 0x2f,
ClientInviteCode = 0x30,
ClientInviteCode = 0x30, // Unused; clean out remnant data before re-using!
Copy link
Contributor

@dpc dpc Mar 9, 2024

Choose a reason for hiding this comment

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

We don't need a migration. We can just always delete this key on module start, and over time it will get deleted from all clients and rotated out of existence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered this, but we could never be sure could we?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need a migration. We can just always delete this key on module start, and over time it will get deleted from all clients and rotated out of existence.

This PR has an example of how to do this https://github.com/fedimint/fedimint/pull/4427/files#diff-d754f9b1f77285e47d11bdecd4e3df652f846e5cedd12ded095ae84816a64cc2

Copy link
Contributor

@dpc dpc Mar 10, 2024

Choose a reason for hiding this comment

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

I considered this, but we could never be sure could we?

I mean - we would still keep ClientInviteCode variant in the code with annotation not to use it, but instead of a note to the future self: "clean out remnant data before re-using!" we would just do it eagerly.

After long enough time for all practical purposes we'd be sure no supported client can possibly still have it there.

I doubt it is going to matter in practice, but conceptually it's strictly better approach.

Copy link
Member

Choose a reason for hiding this comment

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

#[deprecated] ?

Copy link
Contributor Author

@joschisan joschisan Mar 12, 2024

Choose a reason for hiding this comment

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

I doubt it is going to matter in practice, but conceptually it's strictly better approach.

I agree with both, would however prefer to get this merged now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Deleting unconditionally is a hack imo and DB migrations are basically free to add.

If we eventually remove old migrations the client can refuse to start if a too old DB is encountered, but that only works if all DB migrations are modeled properly.

Copy link
Contributor

@dpc dpc left a comment

Choose a reason for hiding this comment

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

LGTM, but @elsirion should take a look, also consider just deleting unconditionally to avoid any remnants whatsoever.

Copy link
Contributor

@elsirion elsirion left a comment

Choose a reason for hiding this comment

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

Not a fan of the missing DB migration, but let's get this in.

@joschisan joschisan added this pull request to the merge queue Mar 13, 2024
Merged via the queue into fedimint:master with commit 53a671b Mar 13, 2024
20 checks passed
@joschisan joschisan deleted the rm_invite_code branch March 13, 2024 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants