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

[M3] WIP Use the FxA Rust backend behind a pref #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

eoger
Copy link

@eoger eoger commented May 20, 2020

This is a WIP patch that keeps the FxAccount and friends API intact while using the Rust backend if the identity.fxaccounts.useExperimentalRustClient pref is present.

It's very much prototype quality, but I think it could be a good start. So far I've been able to show the profile info in the UI and trigger a sync. Device stuff is not working yet though.

How do you feel @mhammond @vladikoff @lougeniaC64 about contributing to this branch to achieve the M3 milestone? (maybe we could make PRs against this PR). (I didn't touch #1 since there seem to be rebase problems there)

@vladikoff vladikoff requested a review from a team May 20, 2020 21:37
@vladikoff
Copy link
Member

(I didn't touch #1 since there seem to be rebase problems there)

We should bring in some stuff from that PR into this. using the m3 name sgtm

Comment on lines 420 to 421
// There's a high chance the JS event loop will mess up everything,
// such as doing OP1 "write-state" AFTER OP2 "write-state".
Copy link
Author

Choose a reason for hiding this comment

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

Because of this, we might have to guard the RustFxAccount ops in a promise queue like we've done on other occasions on Desktop, what do you think @mhammond?

Copy link

Choose a reason for hiding this comment

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

Interesting. IIUC we do get queue-like behaviour from punt, which ensures that each operation at the rust level is executed serially and in order. I wonder if we can also convince it to guarantee calling these callbacks in order rather than having to add another layer of queueing here.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I think it's a good idea, we can access the password manager from C++ I believe.

Copy link
Author

Choose a reason for hiding this comment

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

(and even from Rust using XPCOM magic)

Choose a reason for hiding this comment

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

Sorry I missed this - but yeah, I think the order of these callbacks being called can be deterministic, but as soon as the JS code in the callbacks start awaiting etc, then all bets are off. These notifications aren't async, which we faced in sync too, so we have a "promise queue" there, but that's more about ensuring they are all finished at certain points than about guaranteeing the order of them resolving. A strict ordering queue is tricky because at some points we explicitly chose to let a promise complete in the background - just grep for "background" in services/fxaccounts - often actual persisting of data is done in the background,

Note sure I'm answering the question, but I'm strongly sympathizing with the problem :)

Copy link
Author

Choose a reason for hiding this comment

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

I've moved the persistence to the Rust layer as suggested by @rfk in 81d5094.

@vladikoff
Copy link
Member

vladikoff commented May 20, 2020 via email

let {
key: { kid, k: kSync },
} = await this._fxia.rustFxa.getAccessToken(SCOPE_OLD_SYNC);
let kXCS = kid.split("-")[1];
Copy link

Choose a reason for hiding this comment

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

Yikes! I understand why we're doing this, but I wonder if we could do the inverse refactoring here instead - rather than carving up the scoped-keys data held by the rust component so we can return it in the older format expected by desktop, could we refactor the desktop code that is calling this so that it instead works with scoped keys? I think @vladikoff's work to access sync via OAuth headed a bit in this direction already.

const scopedKeys = {};
if (this._fxia.rustFxa) {
for (const scope of scopes.split(" ")) {
const { key } = await this._fxia.rustFxa.getAccessToken(scope);
Copy link

Choose a reason for hiding this comment

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

Hrm, if we don't already have an OAuth token with that scope, this is going to create one for no reason. I guess that's proably OK in practice because we'll usually have one already, but still, it's a shame.

kSync,
kXCS,
kExtSync: null, // huuuuh
kExtKbHash: null, // yeah huuh.
Copy link

Choose a reason for hiding this comment

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

It's OK, these keys will go away with the landing of the new webext-storage work, which causes us to stop using special keys and start using the same kSync as all the other synced datatypes. So the fact that we don't have them will not be a problem.

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.

4 participants