Skip to main content

xmtp_configuration/common/
mls.rs

1//! Common configuration values between dev & prod
2use openmls::versions::ProtocolVersion;
3
4use xmtp_common::{NS_IN_30_DAYS, NS_IN_SEC};
5pub use xmtp_cryptography::configuration::{CIPHERSUITE, POST_QUANTUM_CIPHERSUITE};
6
7/// Duration to wait before restarting workers in case of an error.
8pub const WORKER_RESTART_DELAY: std::time::Duration = std::time::Duration::from_secs(1);
9
10pub const MLS_PROTOCOL_VERSION: ProtocolVersion = ProtocolVersion::Mls10;
11
12pub const WELCOME_HPKE_LABEL: &str = "MLS_WELCOME";
13
14pub const MAX_GROUP_SYNC_RETRIES: usize = 3;
15
16pub const MAX_INTENT_PUBLISH_ATTEMPTS: usize = 3;
17
18pub const GROUP_KEY_ROTATION_INTERVAL_NS: i64 = NS_IN_30_DAYS;
19
20pub const KEY_PACKAGE_QUEUE_INTERVAL_NS: i64 = 5 * NS_IN_SEC; // 5 secs
21
22/// Interval in NS used to compute `next_key_package_rotation_ns`.
23/// This defines how often a new KeyPackage should be *rotated*,
24/// but does *not* determine the actual KeyPackage expiration.
25pub const KEY_PACKAGE_ROTATION_INTERVAL_NS: i64 = NS_IN_30_DAYS; // 30 days
26
27pub const SEND_MESSAGE_UPDATE_INSTALLATIONS_INTERVAL_NS: i64 = 5 * NS_IN_SEC;
28
29pub const MAX_GROUP_SIZE: usize = 250;
30
31pub const MAX_INSTALLATIONS_PER_INBOX: usize = 10;
32
33pub const MAX_PAST_EPOCHS: usize = 3;
34
35/// Healthy primary-read time allowed for an absent pinned identity update.
36/// This exceeds the backend's default statement timeout.
37pub const IDENTITY_REFERENCE_WAIT: std::time::Duration = std::time::Duration::from_secs(30);
38
39/// Minimum interval between primary reads for an absent identity update.
40pub const IDENTITY_REFERENCE_RETRY_INTERVAL: std::time::Duration =
41    std::time::Duration::from_millis(250);
42
43/// Maximum concurrent identity proof requests in one resolver batch.
44pub const IDENTITY_DEPENDENCY_CONCURRENCY: usize = 8;
45
46pub const CREATE_PQ_KEY_PACKAGE_EXTENSION: bool = true;
47
48// If a metadata field name starts with this character,
49// and it does not have a policy set, it is a super admin only field
50pub const SUPER_ADMIN_METADATA_PREFIX: &str = "_";
51pub const HMAC_SALT: &[u8] = b"libXMTP HKDF salt!";
52
53pub const ENABLE_COMMIT_LOG: bool = true;
54pub const MIN_RECOVERY_REQUEST_VERSION: &str = "1.6.0";
55
56/// Default floor written into `MIN_SUPPORTED_PROTOCOL_VERSION` when a
57/// group is migrated via `enable_proposals` without an explicit override.
58///
59/// Set to the release where the AppData-migration / proposals feature
60/// first ships. Clients older than this version cannot read the
61/// AppData dictionary, so the welcome-time / commit-time pause path
62/// uses this value to gate them out of migrated groups before they
63/// fork.
64///
65/// **Invariant**: must be `<= CARGO_PKG_VERSION`. The send-side clamp
66/// in `enable_proposals` refuses any `min_version > own pkg_version`
67/// (you can't legally write a floor you yourself don't satisfy), so
68/// a constant ahead of the workspace version would brick every
69/// production call to `enable_proposals` that takes the default. Bump
70/// this in lockstep with the workspace version, never independently.
71///
72/// Callers that need a different floor (testing, dev nightlies,
73/// staged rollouts) pass `EnableProposalsOptions::min_version` instead
74/// of relying on this default.
75pub const PROPOSALS_MIN_PROTOCOL_VERSION: &str = "1.11.0-dev";
76
77// Welcome pointers are mostly the hpke public key and less than 100 bytes for the welcome pointer
78// so as long as we have 2 installations that need a single welcome it will result in less data being
79// ingested by the nodes and stored. There is a slight penalty for egress data, but the amount needed
80// to be stored can be 100x less than using regular welcome messages.
81pub const INSTALLATION_THRESHOLD_FOR_WELCOME_POINTER_SENDING: usize = 2;
82
83/// the base backoff time that is multiplied by 3
84pub const SYNC_BACKOFF_WAIT_MS: u16 = 50;
85/// the total wait for all attempts
86pub const SYNC_BACKOFF_TOTAL_WAIT_MAX_SECS: u16 = 10;
87/// jitter time between attempts in ms
88pub const SYNC_JITTER_MS: u16 = 25;