Repository navigation
Fix backward incompatible changes - #1990
Conversation
wysiwys
left a comment
There was a problem hiding this comment.
Thanks, this looks good to me, with one small point on the usize conversion.
Additionally, I agree that it makes sense to add tests for other serde providers, or to adapt the existing tests focusing on backwards compatibility to test multiple serde providers
…ot just serde_json
8eed83c to
36c303a
Compare
keks
left a comment
There was a problem hiding this comment.
Looks pretty good to me.
One thing that I also noticed but don't have a better idea for off the top of my head is that the methods are all called timestamp, but the field is called added_at. The former is not super descriptive, but with_added_at also roll off the tongue super well. Not sure what to do there.
335aa2e to
bbaf62a
Compare
|
I somehow pulled in all of xmtp's changes yesterday. That is fixed now. Let me know if there's anything else I need to change. |
|
I think this looks good now but wanted to way for CI before I give this my green light - but looks Actions is not picking up the jobs. |
`usize` is 32 bits on `wasm32` and 64 bits on most host targets. Serde's default `usize` impl already routes through `serialize_u64` / `deserialize_u64` so common formats (JSON, bincode, postcard) produce identical wire bytes on both platforms — but PR openmls#1990's hand-written serializer for `PastEpochDeletionPolicy::KeepAll` wrote `usize::MAX as u64`, which differs by platform: * wasm32: `usize::MAX as u64 == u32::MAX == 4_294_967_295` * 64-bit: `usize::MAX as u64 == u64::MAX == 18_446_744_073_709_551_615` The deserializer compounded the problem by calling `usize::try_from(v)` before checking the sentinel, so a `KeepAll` policy written by a 64-bit host failed to deserialize at all on `wasm32` (since `u64::MAX` does not fit in a 32-bit `usize`). New code emits `u64::MAX` unconditionally and checks the sentinel *before* narrowing to `usize`, so cross-architecture group state with `KeepAll` now round-trips cleanly. Legacy `wasm32`-written `KeepAll` (encoded as `u32::MAX`) loads as `MaxEpochs(u32::MAX)` — functionally equivalent to "keep all" given the practical ceiling on past-epoch counts — so existing wasm32 data is not broken by this change. Defensively annotate every remaining persisted `usize` field with a new `usize_as_u64` serde adapter so any future format change cannot re-introduce platform-native encoding by accident: * `MlsGroupJoinConfig.padding_size` * `MlsGroupJoinConfig.number_of_resumption_psks` * `MessageSecretsStore.max_epochs` * `ResumptionPskStore.max_number_of_secrets` * `ResumptionPskStore.cursor` * `Pprf.width` These fields are bookkeeping (cache caps, ring-buffer cursor, message padding length, PPRF tree width); none feed key derivation, which is sized exclusively by ciphersuite constants and TLS-encoded length-prefixed byte slices.
`usize` is 32 bits on `wasm32` and 64 bits on most host targets. Serde's default `usize` impl already routes through `serialize_u64` / `deserialize_u64` so common formats (JSON, bincode, postcard) produce identical wire bytes on both platforms — but PR openmls#1990's hand-written serializer for `PastEpochDeletionPolicy::KeepAll` wrote `usize::MAX as u64`, which differs by platform: * wasm32: `usize::MAX as u64 == u32::MAX == 4_294_967_295` * 64-bit: `usize::MAX as u64 == u64::MAX == 18_446_744_073_709_551_615` The deserializer compounded the problem by calling `usize::try_from(v)` before checking the sentinel, so a `KeepAll` policy written by a 64-bit host failed to deserialize at all on `wasm32` (since `u64::MAX` does not fit in a 32-bit `usize`). New code emits `u64::MAX` unconditionally and checks the sentinel *before* narrowing to `usize`, so cross-architecture group state with `KeepAll` now round-trips cleanly. Legacy `wasm32`-written `KeepAll` (encoded as `u32::MAX`) loads as `MaxEpochs(u32::MAX)` — functionally equivalent to "keep all" given the practical ceiling on past-epoch counts — so existing wasm32 data is not broken by this change. Defensively annotate every remaining persisted `usize` field with a new `usize_as_u64` serde adapter so any future format change cannot re-introduce platform-native encoding by accident: * `MlsGroupJoinConfig.padding_size` * `MlsGroupJoinConfig.number_of_resumption_psks` * `MessageSecretsStore.max_epochs` * `ResumptionPskStore.max_number_of_secrets` * `ResumptionPskStore.cursor` * `Pprf.width` These fields are bookkeeping (cache caps, ring-buffer cursor, message padding length, PPRF tree width); none feed key derivation, which is sized exclusively by ciphersuite constants and TLS-encoded length-prefixed byte slices.
* upstream/main: (23 commits) Also publish getters on PrivateMessageIn (openmls#2048) Expose public information of PrivateMessage and PublicMessage through getters (openmls#2042) Virtual clients: Allow processing of own commits (openmls#2017) feat: Implement Safe AAD capabilities from extensions doc (openmls#2037) Add methods to access nodes in RatchetTree and RatchetTreeIn (openmls#2036) allow creating an `AddProposal` from a `KeyPackage` (openmls#2035) feat: add virtual-clients feature flag and confirmable app messages (openmls#1963) make the CI leaner (openmls#2029) Migrate to web-time. (openmls#2016) chore(deps): bump the cargo-dependencies group across 1 directory with 13 updates (openmls#2014) chore(deps): bump codecov/codecov-action from 5 to 6 (openmls#1985) chore(deps): bump rustls-webpki from 0.103.12 to 0.103.13 (openmls#2011) Fix backward incompatible changes (openmls#1990) Don't explicitly include `openmls_sqlite_storage` in `extensions-draft-08` feature (openmls#2012) dependabot: group PRs feat: Allow proposing a self update that includes a new signer (openmls#2010) chore(deps): bump actix-http from 3.12.0 to 3.12.1 (openmls#2007) fix: replace `rand` with `rand_core` (openmls#2000) chore: remove debug asserts (openmls#2001) chore: fix warnings and clippy for not-enabled features (openmls#1992) ... # Conflicts: # basic_credential/src/lib.rs
Fixes #1989
The contract is with serde and not just serde_json, so all fields changes are essentially breaking changes.
To test this more formally, we could use multiple serde providers in the tests, especially those that have the hardest compatibility guarantees.