-
Notifications
You must be signed in to change notification settings - Fork 23
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
Adding Key Update Before Every New GroupIntent #658
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
neekolas
reviewed
Apr 15, 2024
…- both scripts can run from this directory instead of libxmtp/
Idea for test 1:
Idea for test 2: |
lfzkoala
commented
Jun 5, 2024
lfzkoala
commented
Jun 5, 2024
richardhuaaa
force-pushed
the
dz/key-update
branch
from
October 2, 2024 05:56
24ea88e
to
bb75ed4
Compare
Please see #1108 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
trying to solve this issue - #347
This is what I'm doing
Follow the readme file (xmtp_mls/migrations) to create a migration for SQL database
Install the CLI onto local system (one-time)
cargo install diesel_cli --no-default-features --features sqlite
Create migration SQL
diesel migration generate key_update
Edit the up.sql and down.sql files created
Put in up.sql
ALTER TABLE key_update ADD COLUMN rotated_at_ns BIGINT NOT NULL DEFAULT 0
Leave down.sql blank
Generate application code
cargo run --bin update-schema
This updates the generated schema.rs file. This updates models.rs to reference it and encrypted_store/mod.rs to define queries against the model.
Add a new item called
rotated_at_ns
in the StoredGroup struct in storage/encrypted_store/group.rsWrite a function called
get_rotated_time_checked
, which is similar to the functionget_installations_time_checked
, in order to fetch therotated_at_ns
time stamp.Then in the
create_from_welcome
function, set therotated_at_ns = 0
when creating the StoredGroup.Write an async function called
pre_intent_hook()
, which does the followingrotated_at_ns == 0
maybe_update_installations()
Before every
GroupIntent::New(...)
, call thepre_intent_hook()
function.Add a boolean flag as an input of the
maybe_update_installations
function, set the flag to be true to skip the hook when it is called inside from thepre_intent_hook()
function. This is intended to avoid infinite loops and make sure it is not called before the key update intent.