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/// The protocol floor written when a group or DM is created.
57///
58/// Its runtime effect is nil by construction: this floor must be at or below
59/// `CARGO_PKG_VERSION`. The version gate becomes load-bearing when a later
60/// floor is raised above a shipped client version. Keep the gate wired so
61/// those clients pause and resume after an upgrade.
62///
63/// Follow the floor-bump convention in the component registry when changing
64/// the wire format. Raise this constant with the workspace version.
65pub const PROPOSALS_MIN_PROTOCOL_VERSION: &str = "1.12.0-dev";
66
67// Welcome pointers are mostly the hpke public key and less than 100 bytes for the welcome pointer
68// so as long as we have 2 installations that need a single welcome it will result in less data being
69// ingested by the nodes and stored. There is a slight penalty for egress data, but the amount needed
70// to be stored can be 100x less than using regular welcome messages.
71pub const INSTALLATION_THRESHOLD_FOR_WELCOME_POINTER_SENDING: usize = 2;
72
73/// the base backoff time that is multiplied by 3
74pub const SYNC_BACKOFF_WAIT_MS: u16 = 50;
75/// the total wait for all attempts
76pub const SYNC_BACKOFF_TOTAL_WAIT_MAX_SECS: u16 = 10;
77/// jitter time between attempts in ms
78pub const SYNC_JITTER_MS: u16 = 25;