Skip to content

Fix backward incompatible changes - #1990

Merged
keks merged 3 commits into
openmls:mainfrom
xmtp:tyler/fix-backward-incompat
Apr 30, 2026
Merged

keks merged 3 commits into
openmls:mainfrom
xmtp:tyler/fix-backward-incompat

Conversation

@tylerhawkes

Copy link
Copy Markdown
Contributor

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.

wysiwys
wysiwys previously approved these changes Apr 2, 2026

@wysiwys wysiwys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread openmls/src/group/mls_group/config.rs Resolved

@keks keks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread openmls/src/schedule/message_secrets.rs Resolved
@tylerhawkes
tylerhawkes force-pushed the tyler/fix-backward-incompat branch from 335aa2e to bbaf62a Compare April 21, 2026 21:31
@tylerhawkes

Copy link
Copy Markdown
Contributor Author

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.

@keks

keks commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

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.

@keks
keks enabled auto-merge (squash) April 30, 2026 12:29
@keks
keks merged commit 8bdba6f into openmls:main Apr 30, 2026
83 checks passed
@tylerhawkes
tylerhawkes deleted the tyler/fix-backward-incompat branch April 30, 2026 19:57
tylerhawkes added a commit to xmtp/openmls that referenced this pull request May 11, 2026
`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.
insipx pushed a commit to xmtp/openmls that referenced this pull request May 12, 2026
`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.
lekevicius added a commit to silent-app/openmls that referenced this pull request Jun 6, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug] serde untagged and flatten break bincode

3 participants