clementine_core/
constants.rs

1use bitcoin::{transaction::Version, Address, Amount, ScriptBuf};
2
3/// The amount of the non-ephemeral P2A anchor output.
4pub const NON_EPHEMERAL_ANCHOR_AMOUNT: Amount = Amount::from_sat(240);
5
6/// The minimum possible amount that a UTXO can have when created into a Taproot address.
7pub const MIN_TAPROOT_AMOUNT: Amount = Amount::from_sat(330);
8
9pub const TEN_MINUTES_IN_SECS: u32 = 600;
10
11pub const DEFAULT_CHANNEL_SIZE: usize = 1280;
12
13/// Maximum extra watchtowers that can be added to the deposit (in addition to verifiers).
14/// It is limited because each extra watchtower requires 2 additional utxos in the kickoff tx.
15pub const MAX_EXTRA_WATCHTOWERS: usize = 5;
16
17/// The maximum number of nonces that can be generated in a single nonce generation session.
18/// A single nonce takes 132 (musig2 secret nonce) bytes. We calculate NUM_NONCES so that a nonce
19/// session takes at maximum 150MB.
20pub const NUM_NONCES_LIMIT: u32 = 150 * 1_000_000 / MUSIG_SECNONCE_LEN as u32;
21
22/// The maximum number of bytes that can be used by all nonce sessions.
23/// If it exceeds this limit, the verifier will delete the oldest nonce sessions.
24/// This limit is approximate, because it doesn't take into account the internal extra bytes used in
25/// HashMap and VecDeque used in the AllSessions. It only takes into account bytes used for the secnonces.
26pub const MAX_ALL_SESSIONS_BYTES: usize = 2_000_000_000;
27
28/// The maximum number of nonce sessions that can be stored in the verifier.
29/// It is used so that the allsessions do not store too many small (1 nonce) sessions.
30pub const MAX_NUM_SESSIONS: usize = 2000;
31
32use secp256k1::ffi::MUSIG_SECNONCE_LEN;
33/// The maximum number of Winternitz digits per key.
34/// This is used to limit the size of the Winternitz public keys in the protocol
35/// to prevent excessive memory usage and ensure efficient processing.
36/// This value is achieved when signing a 32-byte message with a Winternitz key,
37/// resulting in a maximum of 64 + 4 digits per key, where the last 4 digits are used for
38/// the sum-check operation.
39pub const MAX_WINTERNITZ_DIGITS_PER_KEY: usize = 68;
40
41/// The maximum number of script replacement operations allowed in a single BitVM operation.
42/// This is a safeguard to prevent excessive resource usage and ensure that the BitVM protocol
43/// remains efficient and manageable.
44/// The limit is set to 100,000 operations, which is a reasonable upper bound for
45/// script replacement operations in the context of BitVM, which is normally a constant
46/// equal to 47544.
47pub const MAX_SCRIPT_REPLACEMENT_OPERATIONS: usize = 100_000;
48
49/// The maximum number of bytes per Winternitz key.
50pub const MAX_BYTES_PER_WINTERNITZ_KEY: usize = MAX_WINTERNITZ_DIGITS_PER_KEY * 20;
51
52pub use timeout::*;
53
54mod timeout {
55    use std::time::Duration;
56
57    pub const OVERALL_DEPOSIT_TIMEOUT: Duration = Duration::from_secs(7200); // 2 hours
58
59    pub const KEY_DISTRIBUTION_TIMEOUT: Duration = Duration::from_secs(1200); // 20 minutes
60    pub const OPERATOR_GET_KEYS_TIMEOUT: Duration = Duration::from_secs(600); // 10 minutes
61    pub const VERIFIER_SEND_KEYS_TIMEOUT: Duration = Duration::from_secs(600); // 10 minutes
62
63    pub const NONCE_STREAM_CREATION_TIMEOUT: Duration = Duration::from_secs(300); // 5 minutes
64    pub const PARTIAL_SIG_STREAM_CREATION_TIMEOUT: Duration = Duration::from_secs(300); // 5 minutes
65    pub const OPERATOR_SIGS_STREAM_CREATION_TIMEOUT: Duration = Duration::from_secs(300); // 5 minutes
66    pub const DEPOSIT_FINALIZE_STREAM_CREATION_TIMEOUT: Duration = Duration::from_secs(300); // 5 minutes
67
68    pub const SETUP_COMPLETION_TIMEOUT: Duration = Duration::from_secs(1800); // 30 minutes
69
70    pub const PIPELINE_COMPLETION_TIMEOUT: Duration = Duration::from_secs(3600); // 60 minutes
71    pub const OPERATOR_SIGS_TIMEOUT: Duration = Duration::from_secs(1200); // 20 minutes
72    pub const SEND_OPERATOR_SIGS_TIMEOUT: Duration = Duration::from_secs(600); // 10 minutes
73    pub const DEPOSIT_FINALIZATION_TIMEOUT: Duration = Duration::from_secs(2400); // 40 minutes
74
75    pub const OPTIMISTIC_PAYOUT_TIMEOUT: Duration = Duration::from_secs(300); // 5 minutes
76
77    pub const RESTART_BACKGROUND_TASKS_TIMEOUT: Duration = Duration::from_secs(120);
78
79    pub const ENTITY_STATUS_POLL_TIMEOUT: Duration = Duration::from_secs(120);
80
81    pub const ENTITY_COMP_DATA_POLL_TIMEOUT: Duration = Duration::from_secs(240); // 4 minutes
82
83    pub const PUBLIC_KEY_COLLECTION_TIMEOUT: Duration = Duration::from_secs(30);
84
85    pub const WITHDRAWAL_TIMEOUT: Duration = Duration::from_secs(120); // 2 minutes
86}
87
88pub const NON_STANDARD_V3: Version = Version(3);
89
90lazy_static::lazy_static! {
91  pub static ref BURN_SCRIPT: ScriptBuf = ("1111111111111111111114oLvT2")
92          .parse::<Address<_>>()
93          .expect("valid burn address")
94          .assume_checked()
95          .script_pubkey();
96
97}