Skip to main content

xmtp_configuration/common/
scw.rs

1/// Local chain address when no worktree environment is loaded.
2pub const ANVIL_URL_DEFAULT: &str = "http://127.0.0.1:8545";
3
4/// The longest ERC-6492 signature a validator verifies: the verifier's
5/// ceiling.
6///
7/// Deployless verification sends initcode, which EIP-3860 limits to 49,152
8/// bytes: the 1,792 bytes of the universal signature validator, then its
9/// ABI-encoded constructor arguments, a 128-byte head (the signer, the hash,
10/// the signature's offset and its length) and the signature padded to a
11/// multiple of 32 bytes. 49,152 - 1,792 - 128 = 47,232, itself a multiple of
12/// 32, so a signature one byte longer can never be verified this way.
13pub const MAX_SCW_SIGNATURE_BYTES: usize = 47_232;
14
15/// The most chain calls one batch of smart contract wallet checks keeps in
16/// flight, so a batch never starts every check before the first completes.
17pub const MAX_CHAIN_CALLS_IN_FLIGHT: usize = 8;
18
19/// The longest one chain RPC call may take, its permit wait included.
20pub const CHAIN_CALL_TIMEOUT_MS: u64 = 10_000;
21
22/// The most calls one chain provider has in flight, across all requests.
23pub const MAX_CHAIN_CALLS_PER_PROVIDER: usize = 64;
24
25/// The most ERC-6492 signatures one verify request carries: two for each
26/// action of the largest identity update, so no update needs more. The
27/// backend refuses a larger `max_scw_signatures`, and a client sizes its
28/// requests by the smaller of this and the published value.
29pub const MAX_SCW_SIGNATURES_PER_REQUEST: usize = 2 * super::MAX_IDENTITY_UPDATE_ACTIONS;
30
31/// Local chain used for smart-contract-wallet verification.
32pub struct DockerUrls;
33impl DockerUrls {
34    /// Anvil's address. Each worktree publishes it on its own port, so the
35    /// value comes from `ANVIL_URL`, which `dev/worktree-env` writes.
36    pub fn anvil() -> String {
37        #[cfg(not(target_arch = "wasm32"))]
38        {
39            std::env::var("ANVIL_URL").unwrap_or_else(|_| ANVIL_URL_DEFAULT.to_string())
40        }
41        #[cfg(target_arch = "wasm32")]
42        {
43            option_env!("ANVIL_URL")
44                .unwrap_or(ANVIL_URL_DEFAULT)
45                .to_string()
46        }
47    }
48}