Page MenuHomePhabricator

[protos] Add initial_device_list field
ClosedPublic

Authored by bartek on May 13 2024, 8:15 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 2, 12:50 AM
Unknown Object (File)
Thu, Oct 31, 10:57 AM
Unknown Object (File)
Tue, Oct 15, 9:25 AM
Unknown Object (File)
Tue, Oct 15, 6:05 AM
Unknown Object (File)
Tue, Oct 15, 4:01 AM
Unknown Object (File)
Oct 4 2024, 8:49 PM
Unknown Object (File)
Oct 2 2024, 5:11 PM
Unknown Object (File)
Oct 2 2024, 5:11 PM
Subscribers

Details

Summary

Addresses:

Added the initial_device_list to registration requests' proto messages.

We need it in the following rpcs:

  • RegisterPasswordUserStart
  • RegisterReservedPasswordUser
  • RegisterWalletUser
  • RegisterReservedWalletUser

The WalletAuthRequest is also used in LogInWalletUser so we always put empty string there

Test Plan

Made sure the change is backwards compatible

  1. Compiled native without this changes
  2. Applied this change and compiled Identity Service. Added server-side log to print the initial_device_list.is_empty() value.
  3. Without recompiling, ran the registration on native.
  4. Made sure the value is an empty string
  5. Compiled native with changes from this diff, ran registration again and verified it's empty string

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.May 13 2024, 8:50 AM

Interesting that this change is backwards compatible! What's the significance of the optional keyword in the .proto definition – is that just an annotation so that types can be codegenned correctly?

ashoat requested changes to this revision.May 15 2024, 7:12 PM

Passing back with question

This revision now requires changes to proceed.May 15 2024, 7:12 PM

Interesting that this change is backwards compatible! What's the significance of the optional keyword in the .proto definition – is that just an annotation so that types can be codegenned correctly?

Yes, looks like the optional keyword is mainly for codegen. In Rust, it's String vs Option<String>, in JS it's string vs ?string etc.
Technically, on proto side it doesn't matter, except unset optionals are not serialized to save bandwidth. If the received message from client doesn't contain a field with given number/index (here 5 or 6), but the proto definition expects it, it will be assigned a default value when parsing the message.
As long as we don't change existing field types nor rearrange field numbers, we're safe.
Interestingly, you can unfold identity-unauth-structs.cjs in this diff and there you can see a call getFieldWithDefault(msg, 5, "") for all fields, regardless if it's optional farcaster_id or non-optional initial_device_list.

From proto docs:

optional: An optional field is in one of two possible states:

  • the field is set, and contains a value that was explicitly set or parsed from the wire. It will be serialized to the wire.
  • the field is unset, and will return the default value. It will not be serialized to the wire.

You can check to see if the value was explicitly set.

Also, a note about backwards compatibility when adding new fields:

If you add new fields, any messages serialized by code using your “old” message format can still be parsed by your new generated code. You should keep in mind the default values for these elements so that new code can properly interact with messages generated by old code. Similarly, messages created by your new code can be parsed by your old code: old binaries simply ignore the new field when parsing.

ashoat added 1 blocking reviewer(s): will.

Thanks for explaining! Proto and JS changes look good to me, but would appreciate it if @will could take a look at the Rust

This revision is now accepted and ready to land.May 16 2024, 12:05 PM
This revision was automatically updated to reflect the committed changes.