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

Feature/fallback pairing seed2 #5614

Merged
merged 11 commits into from
Jul 30, 2024
Merged

Feature/fallback pairing seed2 #5614

merged 11 commits into from
Jul 30, 2024

Conversation

qfrank
Copy link
Contributor

@qfrank qfrank commented Jul 29, 2024

this is a continue PR to PR.
with this PR, syncing will work with both direction: v2.29 <-> v2.30
also will work between v2.30 <-> v2.31

once frontend added the 2 invocations FinishPairingThroughSeedPhraseProcess, EnableAndSyncInstallation and backend disabled the flag keep229Compatibility, fall back should work between v2.31 -> v2.30 or v2.31 <-> v2.31

@cammellos @ilmotta

cammellos and others added 3 commits July 28, 2024 20:46
This commit includes the following changes:

I have added a flag to maintain 2.29 compatibility.

Breaking change in connection string

The local pairing code that was parsing the connection string had a few non-upgradable features:

It was strictly checking the number of parameters, throwing an error if the number was different. This made it impossible to add parameters to it without breaking.
It was strictly checking the version number. This made increasing the version number impossible as older client would just refuse to connect.
The code has been changed so that:

Two parameters have been added, installation-id and key-uid. Those are needed for the fallback flow.
I have also removed version from the payload, since it wasn't used.

This means that we don't support v1 anymore. V2 parsing is supported . Going forward there's a clear strategy on how to update the protocol (append parameters, don't change existing one).

https://www.youtube.com/watch?v=oyLBGkS5ICk Is a must watch video for understanding the strategy

Changed MessengerResponse to use internally a map of installations rather than an array (minor)
Just moving towards maps as arrays tend to lead to subtle bugs.

Moved pairing methods to messenger_pairing.go
Just moved some methods

Added 2 new methods for the fallback flow
FinishPairingThroughSeedPhraseProcess
https://github.com/status-im/status-go/pull/5567/files#diff-1ad620b07fa3bd5fbc96c9f459d88829938a162bf1aaf41c61dea6e38b488d54R29

EnableAndSyncInstallation

https://github.com/status-im/status-go/pull/5567/files#diff-1ad620b07fa3bd5fbc96c9f459d88829938a162bf1aaf41c61dea6e38b488d54R18

Flow for clients
Client A1 is logged in
Client A2 is logged out

Client A1 shows a QR code
Client A2 scans a QR code
If connection fails on A2, the user will be prompted to enter a seed phrase.
If the generated account matches the key-uid from the QR code, A2 should call FinishPairingThroughSeedPhraseProcess with the installation id passed in the QR code. This will send installation information over waku. The user should be shown its own installation id and prompted to check the other device.
Client A1 will receive new installation data through waku, if they are still on the qr code page, they should show a popup to the user showing the received installation id, and a way to Enable and Sync, which should call the EnableAndSyncInstallation endpoint. This should finish the fallback syncing flow.
Current issues
Currently I haven't tested that all the data is synced after finishing the flow. I see that the two devices are paired correctly, but for example the DisplayName is not changed on the receiving device. I haven't had time to look into it further.
@status-im-auto
Copy link
Member

status-im-auto commented Jul 29, 2024

Jenkins Builds

Click to see older builds (33)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ e740f5c #1 2024-07-29 04:31:54 ~2 min tests-rpc 📄log
✔️ e740f5c #1 2024-07-29 04:33:19 ~4 min linux 📦zip
✔️ e740f5c #1 2024-07-29 04:34:26 ~5 min ios 📦zip
✔️ e740f5c #1 2024-07-29 04:34:29 ~5 min android 📦aar
✔️ e740f5c #1 2024-07-29 05:14:34 ~45 min tests 📄log
✔️ 45f17e1 #2 2024-07-29 07:08:25 ~2 min tests-rpc 📄log
✔️ 45f17e1 #2 2024-07-29 07:09:04 ~3 min ios 📦zip
✔️ 45f17e1 #2 2024-07-29 07:09:48 ~3 min linux 📦zip
✔️ 45f17e1 #2 2024-07-29 07:11:17 ~5 min android 📦aar
✔️ 45f17e1 #2 2024-07-29 07:50:12 ~44 min tests 📄log
✔️ bace192 #3 2024-07-29 09:29:52 ~1 min android 📦aar
✔️ bace192 #3 2024-07-29 09:30:18 ~2 min linux 📦zip
✔️ bace192 #3 2024-07-29 09:30:23 ~2 min tests-rpc 📄log
✔️ bace192 #3 2024-07-29 09:32:55 ~4 min ios 📦zip
✔️ bace192 #3 2024-07-29 10:13:16 ~45 min tests 📄log
✔️ 1563b95 #4 2024-07-29 14:26:58 ~2 min android 📦aar
✔️ 1563b95 #4 2024-07-29 14:27:11 ~2 min linux 📦zip
✔️ 1563b95 #4 2024-07-29 14:27:16 ~2 min tests-rpc 📄log
✔️ 1563b95 #4 2024-07-29 14:28:19 ~3 min ios 📦zip
✔️ 1563b95 #4 2024-07-29 15:10:38 ~45 min tests 📄log
✔️ 811c533 #5 2024-07-29 14:31:23 ~1 min android 📦aar
✔️ 811c533 #5 2024-07-29 14:32:15 ~2 min tests-rpc 📄log
✔️ 811c533 #5 2024-07-29 14:33:28 ~3 min linux 📦zip
✔️ 811c533 #5 2024-07-29 14:34:44 ~5 min ios 📦zip
✔️ ae19375 #6 2024-07-29 14:36:24 ~2 min android 📦aar
✔️ ae19375 #6 2024-07-29 14:36:26 ~2 min tests-rpc 📄log
✔️ ae19375 #6 2024-07-29 14:36:34 ~2 min linux 📦zip
✔️ ae19375 #6 2024-07-29 14:38:21 ~3 min ios 📦zip
✔️ cc1ecdf #7 2024-07-29 15:05:59 ~1 min android 📦aar
✔️ cc1ecdf #7 2024-07-29 15:06:36 ~2 min tests-rpc 📄log
✔️ cc1ecdf #7 2024-07-29 15:06:45 ~2 min linux 📦zip
✔️ cc1ecdf #7 2024-07-29 15:07:42 ~3 min ios 📦zip
✔️ cc1ecdf #5 2024-07-29 15:55:47 ~44 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 347ca73 #8 2024-07-30 00:44:40 ~1 min linux 📦zip
✔️ 347ca73 #8 2024-07-30 00:44:49 ~2 min tests-rpc 📄log
✔️ 347ca73 #8 2024-07-30 00:44:53 ~2 min android 📦aar
✔️ 347ca73 #8 2024-07-30 00:45:52 ~3 min ios 📦zip
✔️ 347ca73 #6 2024-07-30 01:27:04 ~44 min tests 📄log
✔️ c96b661 #9 2024-07-30 08:29:41 ~2 min android 📦aar
✔️ c96b661 #9 2024-07-30 08:29:55 ~2 min linux 📦zip
✔️ c96b661 #9 2024-07-30 08:30:06 ~2 min tests-rpc 📄log
✔️ c96b661 #9 2024-07-30 08:31:19 ~3 min ios 📦zip
✔️ c96b661 #7 2024-07-30 09:11:32 ~43 min tests 📄log

mobile/status.go Outdated Show resolved Hide resolved
protocol/messenger.go Outdated Show resolved Hide resolved
protocol/messenger_pairing.go Outdated Show resolved Hide resolved
protocol/messenger_response.go Outdated Show resolved Hide resolved
server/pairing/connection.go Show resolved Hide resolved
server/pairing/connection.go Show resolved Hide resolved
api/geth_backend.go Outdated Show resolved Hide resolved
server/pairing/server_pairing_test.go Show resolved Hide resolved
Copy link
Collaborator

@igor-sirotin igor-sirotin left a comment

Choose a reason for hiding this comment

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

Thank you for the changes ❤️
I still have 2 comments opened, please take a look if you think it make sense.

Also I think @Samyoul review is important to have here.

Also cc @jrainville about this PR.

Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

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

Looks good

api/geth_backend.go Outdated Show resolved Hide resolved
Copy link
Member

@Samyoul Samyoul left a comment

Choose a reason for hiding this comment

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

Thank you @qfrank really nice work.

@qfrank qfrank merged commit f123e98 into develop Jul 30, 2024
10 checks passed
@qfrank qfrank deleted the feature/fallback-pairing-seed2 branch July 30, 2024 09:14
ilmotta pushed a commit that referenced this pull request Jul 30, 2024
* feat(pairing)!: Add extra parameters and remove v2 compatibility

This commit includes the following changes:

I have added a flag to maintain 2.29 compatibility.

Breaking change in connection string

The local pairing code that was parsing the connection string had a few non-upgradable features:

It was strictly checking the number of parameters, throwing an error if the number was different. This made it impossible to add parameters to it without breaking.
It was strictly checking the version number. This made increasing the version number impossible as older client would just refuse to connect.
The code has been changed so that:

Two parameters have been added, installation-id and key-uid. Those are needed for the fallback flow.
I have also removed version from the payload, since it wasn't used.

This means that we don't support v1 anymore. V2 parsing is supported . Going forward there's a clear strategy on how to update the protocol (append parameters, don't change existing one).

https://www.youtube.com/watch?v=oyLBGkS5ICk Is a must watch video for understanding the strategy

Changed MessengerResponse to use internally a map of installations rather than an array (minor)
Just moving towards maps as arrays tend to lead to subtle bugs.

Moved pairing methods to messenger_pairing.go
Just moved some methods

Added 2 new methods for the fallback flow
FinishPairingThroughSeedPhraseProcess
https://github.com/status-im/status-go/pull/5567/files#diff-1ad620b07fa3bd5fbc96c9f459d88829938a162bf1aaf41c61dea6e38b488d54R29

EnableAndSyncInstallation

https://github.com/status-im/status-go/pull/5567/files#diff-1ad620b07fa3bd5fbc96c9f459d88829938a162bf1aaf41c61dea6e38b488d54R18

Flow for clients
Client A1 is logged in
Client A2 is logged out

Client A1 shows a QR code
Client A2 scans a QR code
If connection fails on A2, the user will be prompted to enter a seed phrase.
If the generated account matches the key-uid from the QR code, A2 should call FinishPairingThroughSeedPhraseProcess with the installation id passed in the QR code. This will send installation information over waku. The user should be shown its own installation id and prompted to check the other device.
Client A1 will receive new installation data through waku, if they are still on the qr code page, they should show a popup to the user showing the received installation id, and a way to Enable and Sync, which should call the EnableAndSyncInstallation endpoint. This should finish the fallback syncing flow.
Current issues
Currently I haven't tested that all the data is synced after finishing the flow. I see that the two devices are paired correctly, but for example the DisplayName is not changed on the receiving device. I haven't had time to look into it further.

* test_: add more test for connection string parser

* fix_: fix panic when parse old connection string

* test_: add comments for TestMessengerPairAfterSeedPhrase

* fix_: correct error description

* feat_:rename FinishPairingThroughSeedPhraseProcess to EnableInstallationAndPair

* fix_: delete leftover

* fix_: add UniqueKey method

* fix_: unify the response for InputConnectionStringForBootstrapping

* fix_: remove fields installationID and keyUID in GethStatusBackend

* fix_: rename messenger_pairing to messenger_pairing_and_syncing

---------

Co-authored-by: Andrea Maria Piana <[email protected]>
ilmotta pushed a commit that referenced this pull request Jul 30, 2024
* feat(pairing)!: Add extra parameters and remove v2 compatibility

This commit includes the following changes:

I have added a flag to maintain 2.29 compatibility.

Breaking change in connection string

The local pairing code that was parsing the connection string had a few non-upgradable features:

It was strictly checking the number of parameters, throwing an error if the number was different. This made it impossible to add parameters to it without breaking.
It was strictly checking the version number. This made increasing the version number impossible as older client would just refuse to connect.
The code has been changed so that:

Two parameters have been added, installation-id and key-uid. Those are needed for the fallback flow.
I have also removed version from the payload, since it wasn't used.

This means that we don't support v1 anymore. V2 parsing is supported . Going forward there's a clear strategy on how to update the protocol (append parameters, don't change existing one).

https://www.youtube.com/watch?v=oyLBGkS5ICk Is a must watch video for understanding the strategy

Changed MessengerResponse to use internally a map of installations rather than an array (minor)
Just moving towards maps as arrays tend to lead to subtle bugs.

Moved pairing methods to messenger_pairing.go
Just moved some methods

Added 2 new methods for the fallback flow
FinishPairingThroughSeedPhraseProcess
https://github.com/status-im/status-go/pull/5567/files#diff-1ad620b07fa3bd5fbc96c9f459d88829938a162bf1aaf41c61dea6e38b488d54R29

EnableAndSyncInstallation

https://github.com/status-im/status-go/pull/5567/files#diff-1ad620b07fa3bd5fbc96c9f459d88829938a162bf1aaf41c61dea6e38b488d54R18

Flow for clients
Client A1 is logged in
Client A2 is logged out

Client A1 shows a QR code
Client A2 scans a QR code
If connection fails on A2, the user will be prompted to enter a seed phrase.
If the generated account matches the key-uid from the QR code, A2 should call FinishPairingThroughSeedPhraseProcess with the installation id passed in the QR code. This will send installation information over waku. The user should be shown its own installation id and prompted to check the other device.
Client A1 will receive new installation data through waku, if they are still on the qr code page, they should show a popup to the user showing the received installation id, and a way to Enable and Sync, which should call the EnableAndSyncInstallation endpoint. This should finish the fallback syncing flow.
Current issues
Currently I haven't tested that all the data is synced after finishing the flow. I see that the two devices are paired correctly, but for example the DisplayName is not changed on the receiving device. I haven't had time to look into it further.

* test_: add more test for connection string parser

* fix_: fix panic when parse old connection string

* test_: add comments for TestMessengerPairAfterSeedPhrase

* fix_: correct error description

* feat_:rename FinishPairingThroughSeedPhraseProcess to EnableInstallationAndPair

* fix_: delete leftover

* fix_: add UniqueKey method

* fix_: unify the response for InputConnectionStringForBootstrapping

* fix_: remove fields installationID and keyUID in GethStatusBackend

* fix_: rename messenger_pairing to messenger_pairing_and_syncing

---------

Co-authored-by: Andrea Maria Piana <[email protected]>
@churik
Copy link
Member

churik commented Jul 30, 2024

@qfrank
can we create PR for checking it on the client side?
I'm not sure how happened that it was merged before.

@qfrank
Copy link
Contributor Author

qfrank commented Jul 30, 2024

@qfrank can we create PR for checking it on the client side? I'm not sure how happened that it was merged before.

oh sure, sorry, generally I will create a mobile PR to test, but the time is urgent and I forget to do this for the first time(I tested it several times with different client version on my side before merging) @churik

@qfrank
Copy link
Contributor Author

qfrank commented Jul 30, 2024

here it is 🙏 @churik

ilmotta added a commit that referenced this pull request Jul 30, 2024
* feat(pairing)!: Add extra parameters and remove v2 compatibility

This commit includes the following changes:

I have added a flag to maintain 2.29 compatibility.

Breaking change in connection string

The local pairing code that was parsing the connection string had a few non-upgradable features:

It was strictly checking the number of parameters, throwing an error if the number was different. This made it impossible to add parameters to it without breaking.
It was strictly checking the version number. This made increasing the version number impossible as older client would just refuse to connect.
The code has been changed so that:

Two parameters have been added, installation-id and key-uid. Those are needed for the fallback flow.
I have also removed version from the payload, since it wasn't used.

This means that we don't support v1 anymore. V2 parsing is supported . Going forward there's a clear strategy on how to update the protocol (append parameters, don't change existing one).

https://www.youtube.com/watch?v=oyLBGkS5ICk Is a must watch video for understanding the strategy

Changed MessengerResponse to use internally a map of installations rather than an array (minor)
Just moving towards maps as arrays tend to lead to subtle bugs.

Moved pairing methods to messenger_pairing.go
Just moved some methods

Added 2 new methods for the fallback flow
FinishPairingThroughSeedPhraseProcess
https://github.com/status-im/status-go/pull/5567/files#diff-1ad620b07fa3bd5fbc96c9f459d88829938a162bf1aaf41c61dea6e38b488d54R29

EnableAndSyncInstallation

https://github.com/status-im/status-go/pull/5567/files#diff-1ad620b07fa3bd5fbc96c9f459d88829938a162bf1aaf41c61dea6e38b488d54R18

Flow for clients
Client A1 is logged in
Client A2 is logged out

Client A1 shows a QR code
Client A2 scans a QR code
If connection fails on A2, the user will be prompted to enter a seed phrase.
If the generated account matches the key-uid from the QR code, A2 should call FinishPairingThroughSeedPhraseProcess with the installation id passed in the QR code. This will send installation information over waku. The user should be shown its own installation id and prompted to check the other device.
Client A1 will receive new installation data through waku, if they are still on the qr code page, they should show a popup to the user showing the received installation id, and a way to Enable and Sync, which should call the EnableAndSyncInstallation endpoint. This should finish the fallback syncing flow.
Current issues
Currently I haven't tested that all the data is synced after finishing the flow. I see that the two devices are paired correctly, but for example the DisplayName is not changed on the receiving device. I haven't had time to look into it further.

* test_: add more test for connection string parser

* fix_: fix panic when parse old connection string

* test_: add comments for TestMessengerPairAfterSeedPhrase

* fix_: correct error description

* feat_:rename FinishPairingThroughSeedPhraseProcess to EnableInstallationAndPair

* fix_: delete leftover

* fix_: add UniqueKey method

* fix_: unify the response for InputConnectionStringForBootstrapping

* fix_: remove fields installationID and keyUID in GethStatusBackend

* fix_: rename messenger_pairing to messenger_pairing_and_syncing

---------

Co-authored-by: frank <[email protected]>
Co-authored-by: Andrea Maria Piana <[email protected]>
ilmotta pushed a commit to status-im/status-mobile that referenced this pull request Jul 30, 2024
Creating this PR for regression testing the comparability of feature sync
between different versions(mainly current PR build vs v2.29) after adding
backend fallback pairing support. Because frontend haven't added the invocations
relate to fallback pairing API yet, so fallback pairing won't support with
current build.

relate status-go PR status-im/status-go#5614

Testing notes expected: sync should work as before between different versions
like following: v2.29 <-> PR build PR build <-> recent desktop build

NOTE: It breaks with v1 of pairing, but that's ancient (last year I believe), so
safe to break.
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.

8 participants