add modules, move cuprate_helper::constants
Some checks failed
Audit / audit (push) Has been cancelled
Deny / audit (push) Has been cancelled

This commit is contained in:
hinto.janai 2024-09-13 20:47:13 -04:00
parent 1bd45002de
commit 59a4794635
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
18 changed files with 443 additions and 390 deletions

View file

@ -10,7 +10,6 @@ keywords = ["cuprate", "constants"]
[features] [features]
default = [] default = []
cryptonote = []
[dependencies] [dependencies]

View file

@ -1,9 +1,7 @@
fn main() { fn main() {
#[cfg(feature = "constants")]
set_commit_env(); set_commit_env();
} }
#[cfg(feature = "constants")]
/// This sets the git `COMMIT` environment variable. /// This sets the git `COMMIT` environment variable.
fn set_commit_env() { fn set_commit_env() {
const PATH: &str = "../.git/refs/heads/"; const PATH: &str = "../.git/refs/heads/";

64
constants/src/block.rs Normal file
View file

@ -0,0 +1,64 @@
//! TODO
use crate::{difficulty, macros::monero_definition_link};
/// The maximum block height possible.
#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 40)]
pub const MAX_BLOCK_HEIGHT: usize = 500_000_000;
/// TODO
pub const CURRENT_BLOCK_MAJOR_VERSION: u64 = 1;
/// TODO
pub const CURRENT_BLOCK_MINOR_VERSION: u64 = 0;
/// TODO
pub const CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT: u64 = 60 * 60 * 2;
/// TODO
pub const CRYPTONOTE_REWARD_BLOCKS_WINDOW: u64 = 100;
/// TODO
pub const CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2: u64 = 60000; //size of block (bytes) after which reward for block calculated ;using block size
/// TODO
pub const CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1: u64 = 20000; //size of block (bytes) after which reward for block calculated ;using block size - before first fork
/// TODO
pub const CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5: u64 = 300000; //size of block (bytes) after which reward for block calculated ;using block size - second change, from v5
/// TODO
pub const CRYPTONOTE_LONG_TERM_BLOCK_WEIGHT_WINDOW_SIZE: u64 = 100000; // size in blocks of the long term block weight median window;
/// TODO
pub const CRYPTONOTE_SHORT_TERM_BLOCK_WEIGHT_SURGE_FACTOR: u64 = 50;
/// TODO
pub const ORPHANED_BLOCKS_MAX_COUNT: u64 = 100;
/// TODO
pub const CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE: u64 = 600;
/// TODO
pub const DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN: u64 = difficulty::DIFFICULTY_TARGET_V1.as_secs(); //just alias; used by tests;
/// TODO
pub const BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT: u64 = 10000; //by default, blocks ids count in synchronizing;
/// TODO
pub const BLOCKS_IDS_SYNCHRONIZING_MAX_COUNT: u64 = 25000; //max blocks ids count in synchronizing;
/// TODO
pub const BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4: u64 = 100; //by default, blocks count in blocks downloading;
/// TODO
pub const BLOCKS_SYNCHRONIZING_DEFAULT_COUNT: u64 = 20; //by default, blocks count in blocks downloading;
/// TODO
pub const BLOCKS_SYNCHRONIZING_MAX_COUNT: u64 = 2048; //must be a power of 2, greater than 128, equal to ;SEEDHASH_EPOCH_BLOCKS
/// TODO
pub const BULLETPROOF_MAX_OUTPUTS: u64 = 16;
/// TODO
pub const BULLETPROOF_PLUS_MAX_OUTPUTS: u64 = 16;

22
constants/src/build.rs Normal file
View file

@ -0,0 +1,22 @@
//! TODO
/// The current commit hash of the root Cuprate repository.
///
/// # Case & length
/// It is guaranteed that `COMMIT` will be:
/// - Lowercase ASCII
/// - 40 characters long (no newline)
///
/// ```rust
/// # use cuprate_constants::build::*;
/// assert_eq!(COMMIT.is_ascii());
/// assert_eq!(COMMIT.as_bytes().len(), 40);
/// assert_eq!(COMMIT.to_lowercase(), COMMIT);
/// ```
pub const COMMIT: &str = core::env!("COMMIT"); // Set in `helper/build.rs`.
/// TODO
pub const DEBUG: bool = cfg!(debug_assertions);
/// TODO
pub const RELEASE: bool = !DEBUG;

View file

@ -1,359 +0,0 @@
//! TODO
use crate::macros::monero_definition_link;
/// TODO
///
#[doc = monero_definition_link!()]
pub const CRYPTONOTE_MAX_BLOCK_HEIGHT: usize = 500_000_000;
/// The default log stripes for Monero pruning.
pub const CRYPTONOTE_PRUNING_LOG_STRIPES: u32 = 3;
/// The amount of blocks that peers keep before another stripe starts storing blocks.
pub const CRYPTONOTE_PRUNING_STRIPE_SIZE: usize = 4096;
/// The amount of blocks from the top of the chain that should not be pruned.
pub const CRYPTONOTE_PRUNING_TIP_BLOCKS: usize = 5500;
/// TODO
pub const CRYPTONOTE_DNS_TIMEOUT_MS: u64 = 20000;
/// TODO
pub const CRYPTONOTE_MAX_BLOCK_NUMBER: u64 = 500000000;
/// TODO
pub const CRYPTONOTE_MAX_TX_SIZE: u64 = 1000000;
/// TODO
pub const CRYPTONOTE_MAX_TX_PER_BLOCK: u64 = 0x10000000;
/// TODO
pub const CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER: u64 = 0;
/// TODO
pub const CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW: u64 = 60;
/// TODO
pub const CURRENT_TRANSACTION_VERSION: u64 = 2;
/// TODO
pub const CURRENT_BLOCK_MAJOR_VERSION: u64 = 1;
/// TODO
pub const CURRENT_BLOCK_MINOR_VERSION: u64 = 0;
/// TODO
pub const CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT: u64 = 60 * 60 * 2;
/// TODO
pub const CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE: u64 = 10;
/// TODO
pub const BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW: u64 = 60;
// MONEY_SUPPLY - total number coins to be generated
pub const MONEY_SUPPLY: u64 = u64::MAX - 1;
/// TODO
pub const EMISSION_SPEED_FACTOR_PER_MINUTE: u64 = 20;
/// TODO
pub const FINAL_SUBSIDY_PER_MINUTE: u64 = 300000000000; // 3 * pow(10, 11);
/// TODO
pub const CRYPTONOTE_REWARD_BLOCKS_WINDOW: u64 = 100;
/// TODO
pub const CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2: u64 = 60000; //size of block (bytes) after which reward for block calculated ;using block size
/// TODO
pub const CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1: u64 = 20000; //size of block (bytes) after which reward for block calculated ;using block size - before first fork
/// TODO
pub const CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5: u64 = 300000; //size of block (bytes) after which reward for block calculated ;using block size - second change, from v5
/// TODO
pub const CRYPTONOTE_LONG_TERM_BLOCK_WEIGHT_WINDOW_SIZE: u64 = 100000; // size in blocks of the long term block weight median window;
/// TODO
pub const CRYPTONOTE_SHORT_TERM_BLOCK_WEIGHT_SURGE_FACTOR: u64 = 50;
/// TODO
pub const CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE: u64 = 600;
/// TODO
pub const CRYPTONOTE_DISPLAY_DECIMAL_POINT: u64 = 12;
// COIN - number of smallest units in one coin
pub const COIN: u64 = 1000000000000; // pow(10, 12);
/// TODO
pub const FEE_PER_KB_OLD: u64 = 10000000000; // pow(10, 10);
/// TODO
pub const FEE_PER_KB: u64 = 2000000000; // 2 * pow(10, 9);
/// TODO
pub const FEE_PER_BYTE: u64 = 300000;
/// TODO
pub const DYNAMIC_FEE_PER_KB_BASE_FEE: u64 = 2000000000; // 2 * pow(10,9);
/// TODO
pub const DYNAMIC_FEE_PER_KB_BASE_BLOCK_REWARD: u64 = 10000000000000; // 10 * pow(10,12);
/// TODO
pub const DYNAMIC_FEE_PER_KB_BASE_FEE_V5: u64 = 2000000000
* CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2
/ CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5;
/// TODO
pub const DYNAMIC_FEE_REFERENCE_TRANSACTION_WEIGHT: u64 = 3000;
/// TODO
pub const ORPHANED_BLOCKS_MAX_COUNT: u64 = 100;
/// TODO
pub const DIFFICULTY_TARGET_V2: u64 = 120; // seconds;
/// TODO
pub const DIFFICULTY_TARGET_V1: u64 = 60; // seconds - before first fork;
/// TODO
pub const DIFFICULTY_WINDOW: u64 = 720; // blocks;
/// TODO
pub const DIFFICULTY_LAG: u64 = 15; // !!!;
/// TODO
pub const DIFFICULTY_CUT: u64 = 60; // timestamps to cut after sorting;
/// TODO
pub const DIFFICULTY_BLOCKS_COUNT: u64 = DIFFICULTY_WINDOW + DIFFICULTY_LAG;
/// TODO
pub const CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1: u64 =
DIFFICULTY_TARGET_V1 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS;
/// TODO
pub const CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2: u64 =
DIFFICULTY_TARGET_V2 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS;
/// TODO
pub const CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS: u64 = 1;
/// TODO
pub const DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN: u64 = DIFFICULTY_TARGET_V1; //just alias; used by tests;
/// TODO
pub const BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT: u64 = 10000; //by default, blocks ids count in synchronizing;
/// TODO
pub const BLOCKS_IDS_SYNCHRONIZING_MAX_COUNT: u64 = 25000; //max blocks ids count in synchronizing;
/// TODO
pub const BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4: u64 = 100; //by default, blocks count in blocks downloading;
/// TODO
pub const BLOCKS_SYNCHRONIZING_DEFAULT_COUNT: u64 = 20; //by default, blocks count in blocks downloading;
/// TODO
pub const BLOCKS_SYNCHRONIZING_MAX_COUNT: u64 = 2048; //must be a power of 2, greater than 128, equal to ;SEEDHASH_EPOCH_BLOCKS
/// TODO
pub const CRYPTONOTE_MEMPOOL_TX_LIFETIME: u64 = (86400 * 3); //seconds, three days;
/// TODO
pub const CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME: u64 = 604800; //seconds, one week;
/// TODO
pub const CRYPTONOTE_DANDELIONPP_STEMS: u64 = 2; // number of outgoing stem connections per epoch;
/// TODO
pub const CRYPTONOTE_DANDELIONPP_FLUFF_PROBABILITY: u64 = 20; // out of 100;
/// TODO
pub const CRYPTONOTE_DANDELIONPP_MIN_EPOCH: u64 = 10; // minutes;
/// TODO
pub const CRYPTONOTE_DANDELIONPP_EPOCH_RANGE: u64 = 30; // seconds;
/// TODO
pub const CRYPTONOTE_DANDELIONPP_FLUSH_AVERAGE: u64 = 5; // seconds average for poisson distributed fluff flush;
/// TODO
pub const CRYPTONOTE_DANDELIONPP_EMBARGO_AVERAGE: u64 = 39; // seconds (see tx_pool.cpp for more info);
// see src/cryptonote_protocol/levin_notify.cpp
/// TODO
pub const CRYPTONOTE_NOISE_MIN_EPOCH: u64 = 5; // minutes;
/// TODO
pub const CRYPTONOTE_NOISE_EPOCH_RANGE: u64 = 30; // seconds;
/// TODO
pub const CRYPTONOTE_NOISE_MIN_DELAY: u64 = 10; // seconds;
/// TODO
pub const CRYPTONOTE_NOISE_DELAY_RANGE: u64 = 5; // seconds;
/// TODO
pub const CRYPTONOTE_NOISE_BYTES: u64 = 3 * 1024; // 3 KiB;
/// TODO
pub const CRYPTONOTE_NOISE_CHANNELS: u64 = 2; // Max outgoing connections per zone used for noise/covert sending;
// Both below are in seconds. The idea is to delay forwarding from i2p/tor
// to ipv4/6, such that 2+ incoming connections _could_ have sent the tx
/// TODO
pub const CRYPTONOTE_FORWARD_DELAY_BASE: u64 =
CRYPTONOTE_NOISE_MIN_DELAY + CRYPTONOTE_NOISE_DELAY_RANGE;
/// TODO
pub const CRYPTONOTE_FORWARD_DELAY_AVERAGE: u64 =
CRYPTONOTE_FORWARD_DELAY_BASE + (CRYPTONOTE_FORWARD_DELAY_BASE / 2);
/// TODO
pub const CRYPTONOTE_MAX_FRAGMENTS: u64 = 20; // ~20 * NOISE_BYTES max payload size for covert/noise send;
/// TODO
pub const COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT: u64 = 1000;
/// TODO
pub const COMMAND_RPC_GET_BLOCKS_FAST_MAX_TX_COUNT: u64 = 20000;
/// TODO
pub const MAX_RPC_CONTENT_LENGTH: u64 = 1048576; // 1 MB
/// TODO
pub const P2P_LOCAL_WHITE_PEERLIST_LIMIT: u64 = 1000;
/// TODO
pub const P2P_LOCAL_GRAY_PEERLIST_LIMIT: u64 = 5000;
/// TODO
pub const P2P_DEFAULT_CONNECTIONS_COUNT: u64 = 12;
/// TODO
pub const P2P_DEFAULT_HANDSHAKE_INTERVAL: u64 = 60; //secondes
/// TODO
pub const P2P_DEFAULT_PACKET_MAX_SIZE: u64 = 50000000; //50000000 bytes maximum packet size
/// TODO
pub const P2P_DEFAULT_PEERS_IN_HANDSHAKE: u64 = 250;
/// TODO
pub const P2P_MAX_PEERS_IN_HANDSHAKE: u64 = 250;
/// TODO
pub const P2P_DEFAULT_CONNECTION_TIMEOUT: u64 = 5000; //5 seconds
/// TODO
pub const P2P_DEFAULT_SOCKS_CONNECT_TIMEOUT: u64 = 45; // seconds
/// TODO
pub const P2P_DEFAULT_PING_CONNECTION_TIMEOUT: u64 = 2000; //2 seconds
/// TODO
pub const P2P_DEFAULT_INVOKE_TIMEOUT: u64 = 60 * 2 * 1000; //2 minutes
/// TODO
pub const P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT: u64 = 5000; //5 seconds
/// TODO
pub const P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT: u64 = 70;
/// TODO
pub const P2P_DEFAULT_ANCHOR_CONNECTIONS_COUNT: u64 = 2;
/// TODO
pub const P2P_DEFAULT_SYNC_SEARCH_CONNECTIONS_COUNT: u64 = 2;
/// TODO
pub const P2P_DEFAULT_LIMIT_RATE_UP: u64 = 2048; // kB/s
/// TODO
pub const P2P_DEFAULT_LIMIT_RATE_DOWN: u64 = 8192; // kB/s
/// TODO
pub const P2P_FAILED_ADDR_FORGET_SECONDS: u64 = 60 * 60; //1 hour
/// TODO
pub const P2P_IP_BLOCKTIME: u64 = 60 * 60 * 24; //24 hour
/// TODO
pub const P2P_IP_FAILS_BEFORE_BLOCK: u64 = 10;
/// TODO
pub const P2P_IDLE_CONNECTION_KILL_INTERVAL: u64 = 5 * 60; //5 minutes
/// TODO
pub const P2P_SUPPORT_FLAG_FLUFFY_BLOCKS: u64 = 0x01;
/// TODO
pub const P2P_SUPPORT_FLAGS: u64 = P2P_SUPPORT_FLAG_FLUFFY_BLOCKS;
/// TODO
pub const RPC_IP_FAILS_BEFORE_BLOCK: u64 = 3;
/// TODO
pub const THREAD_STACK_SIZE: u64 = 5 * 1024 * 1024;
/// TODO
pub const HF_VERSION_DYNAMIC_FEE: u64 = 4;
/// TODO
pub const HF_VERSION_MIN_MIXIN_4: u64 = 6;
/// TODO
pub const HF_VERSION_MIN_MIXIN_6: u64 = 7;
/// TODO
pub const HF_VERSION_MIN_MIXIN_10: u64 = 8;
/// TODO
pub const HF_VERSION_MIN_MIXIN_15: u64 = 15;
/// TODO
pub const HF_VERSION_ENFORCE_RCT: u64 = 6;
/// TODO
pub const HF_VERSION_PER_BYTE_FEE: u64 = 8;
/// TODO
pub const HF_VERSION_SMALLER_BP: u64 = 10;
/// TODO
pub const HF_VERSION_LONG_TERM_BLOCK_WEIGHT: u64 = 10;
/// TODO
pub const HF_VERSION_MIN_2_OUTPUTS: u64 = 12;
/// TODO
pub const HF_VERSION_MIN_V2_COINBASE_TX: u64 = 12;
/// TODO
pub const HF_VERSION_SAME_MIXIN: u64 = 12;
/// TODO
pub const HF_VERSION_REJECT_SIGS_IN_COINBASE: u64 = 12;
/// TODO
pub const HF_VERSION_ENFORCE_MIN_AGE: u64 = 12;
/// TODO
pub const HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY: u64 = 12;
/// TODO
pub const HF_VERSION_EXACT_COINBASE: u64 = 13;
/// TODO
pub const HF_VERSION_CLSAG: u64 = 13;
/// TODO
pub const HF_VERSION_DETERMINISTIC_UNLOCK_TIME: u64 = 13;
/// TODO
pub const HF_VERSION_BULLETPROOF_PLUS: u64 = 15;
/// TODO
pub const HF_VERSION_VIEW_TAGS: u64 = 15;
/// TODO
pub const HF_VERSION_2021_SCALING: u64 = 15;
/// TODO
pub const PER_KB_FEE_QUANTIZATION_DECIMALS: u64 = 8;
/// TODO
pub const CRYPTONOTE_SCALING_2021_FEE_ROUNDING_PLACES: u64 = 2;
/// TODO
pub const HASH_OF_HASHES_STEP: u64 = 512;
/// TODO
pub const DEFAULT_TXPOOL_MAX_WEIGHT: u64 = 648000000; // 3 days at 300000, in bytes
/// TODO
pub const BULLETPROOF_MAX_OUTPUTS: u64 = 16;
/// TODO
pub const BULLETPROOF_PLUS_MAX_OUTPUTS: u64 = 16;
/// TODO
pub const CRYPTONOTE_PRUNING_STRIPE_SIZE: u64 = 4096; // the smaller, the smoother the increase
/// TODO
pub const CRYPTONOTE_PRUNING_LOG_STRIPES: u64 = 3; // the higher, the more space saved
/// TODO
pub const CRYPTONOTE_PRUNING_TIP_BLOCKS: u64 = 5500; // the smaller, the more space saved
/// TODO
pub const RPC_CREDITS_PER_HASH_SCALE: u64 = 1 << 24;
/// TODO
pub const DNS_BLOCKLIST_LIFETIME: u64 = 86400 * 8;
//The limit is enough for the mandatory transaction content with 16 outputs (547 bytes),
//a custom tag (1 byte) and up to 32 bytes of custom data for each recipient.
// (1+32) + (1+1+16*32) + (1+16*32) = 1060
/// TODO
pub const MAX_TX_EXTRA_SIZE: u64 = 1060;

View file

@ -0,0 +1,35 @@
//! TODO
use std::time::Duration;
use crate::macros::monero_definition_link;
/// TODO
#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 81)]
///
/// ```rust
/// # use cuprate_constants::difficulty::*;
/// assert_eq!(DIFFICULTY_TARGET_V1.as_secs(), 60);
/// ```
pub const DIFFICULTY_TARGET_V1: Duration = Duration::from_secs(60);
/// TODO
#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 80)]
///
/// ```rust
/// # use cuprate_constants::difficulty::*;
/// assert_eq!(DIFFICULTY_TARGET_V2.as_secs(), 120);
/// ```
pub const DIFFICULTY_TARGET_V2: Duration = Duration::from_secs(120);
/// TODO
pub const DIFFICULTY_WINDOW: u64 = 720; // blocks;
/// TODO
pub const DIFFICULTY_LAG: u64 = 15; // !!!;
/// TODO
pub const DIFFICULTY_CUT: u64 = 60; // timestamps to cut after sorting;
/// TODO
pub const DIFFICULTY_BLOCKS_COUNT: u64 = DIFFICULTY_WINDOW + DIFFICULTY_LAG;

View file

@ -0,0 +1,64 @@
//! TODO
/// TODO
pub const HF_VERSION_DYNAMIC_FEE: u64 = 4;
/// TODO
pub const HF_VERSION_MIN_MIXIN_4: u64 = 6;
/// TODO
pub const HF_VERSION_MIN_MIXIN_6: u64 = 7;
/// TODO
pub const HF_VERSION_MIN_MIXIN_10: u64 = 8;
/// TODO
pub const HF_VERSION_MIN_MIXIN_15: u64 = 15;
/// TODO
pub const HF_VERSION_ENFORCE_RCT: u64 = 6;
/// TODO
pub const HF_VERSION_PER_BYTE_FEE: u64 = 8;
/// TODO
pub const HF_VERSION_SMALLER_BP: u64 = 10;
/// TODO
pub const HF_VERSION_LONG_TERM_BLOCK_WEIGHT: u64 = 10;
/// TODO
pub const HF_VERSION_MIN_2_OUTPUTS: u64 = 12;
/// TODO
pub const HF_VERSION_MIN_V2_COINBASE_TX: u64 = 12;
/// TODO
pub const HF_VERSION_SAME_MIXIN: u64 = 12;
/// TODO
pub const HF_VERSION_REJECT_SIGS_IN_COINBASE: u64 = 12;
/// TODO
pub const HF_VERSION_ENFORCE_MIN_AGE: u64 = 12;
/// TODO
pub const HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY: u64 = 12;
/// TODO
pub const HF_VERSION_EXACT_COINBASE: u64 = 13;
/// TODO
pub const HF_VERSION_CLSAG: u64 = 13;
/// TODO
pub const HF_VERSION_DETERMINISTIC_UNLOCK_TIME: u64 = 13;
/// TODO
pub const HF_VERSION_BULLETPROOF_PLUS: u64 = 15;
/// TODO
pub const HF_VERSION_VIEW_TAGS: u64 = 15;
/// TODO
pub const HF_VERSION_2021_SCALING: u64 = 15;

View file

@ -3,5 +3,14 @@
mod macros; mod macros;
#[cfg(feature = "cryptonote")] pub mod block;
pub mod cryptonote; pub mod build;
pub mod difficulty;
pub mod hard_fork;
pub mod money;
pub mod net;
pub mod p2p;
pub mod pruning;
pub mod rpc;
pub mod sys;
pub mod tx;

View file

@ -6,7 +6,8 @@ macro_rules! monero_definition_link {
$start:literal$(..=$end:literal)? // File lines, e.g. `0..=123` or `0` $start:literal$(..=$end:literal)? // File lines, e.g. `0..=123` or `0`
) => { ) => {
concat!( concat!(
"[Definition](https://github.com/monero-project/monero/blob/", "",
"[Original definition](https://github.com/monero-project/monero/blob/",
stringify!($commit), stringify!($commit),
"/src/", "/src/",
$file_path, $file_path,

41
constants/src/money.rs Normal file
View file

@ -0,0 +1,41 @@
//! TODO
use crate::block;
/// `MONEY_SUPPLY` - total number coins to be generated
pub const MONEY_SUPPLY: u64 = u64::MAX - 1;
/// TODO
pub const EMISSION_SPEED_FACTOR_PER_MINUTE: u64 = 20;
/// TODO
pub const FINAL_SUBSIDY_PER_MINUTE: u64 = 300_000_000_000; // 3 * pow(10, 11);
/// TODO
pub const CRYPTONOTE_DISPLAY_DECIMAL_POINT: u64 = 12;
/// COIN - number of smallest units in one coin
pub const COIN: u64 = 1000000000000; // pow(10, 12);
/// TODO
pub const FEE_PER_KB_OLD: u64 = 10000000000; // pow(10, 10);
/// TODO
pub const FEE_PER_KB: u64 = 2000000000; // 2 * pow(10, 9);
/// TODO
pub const FEE_PER_BYTE: u64 = 300000;
/// TODO
pub const DYNAMIC_FEE_PER_KB_BASE_FEE: u64 = 2000000000; // 2 * pow(10,9);
/// TODO
pub const DYNAMIC_FEE_PER_KB_BASE_BLOCK_REWARD: u64 = 10000000000000; // 10 * pow(10,12);
/// TODO
pub const DYNAMIC_FEE_PER_KB_BASE_FEE_V5: u64 = 2000000000
* block::CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2
/ block::CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5;
/// TODO
pub const DYNAMIC_FEE_REFERENCE_TRANSACTION_WEIGHT: u64 = 3000;

7
constants/src/net.rs Normal file
View file

@ -0,0 +1,7 @@
//! TODO
/// TODO
pub const CRYPTONOTE_DNS_TIMEOUT_MS: u64 = 20000;
/// TODO
pub const DNS_BLOCKLIST_LIFETIME: u64 = 86400 * 8;

76
constants/src/p2p.rs Normal file
View file

@ -0,0 +1,76 @@
//! TODO
/// TODO
pub const CRYPTONOTE_DNS_TIMEOUT_MS: u64 = 20000;
/// TODO
pub const DNS_BLOCKLIST_LIFETIME: u64 = 86400 * 8;
/// TODO
pub const P2P_LOCAL_WHITE_PEERLIST_LIMIT: u64 = 1000;
/// TODO
pub const P2P_LOCAL_GRAY_PEERLIST_LIMIT: u64 = 5000;
/// TODO
pub const P2P_DEFAULT_CONNECTIONS_COUNT: u64 = 12;
/// TODO
pub const P2P_DEFAULT_HANDSHAKE_INTERVAL: u64 = 60; //secondes
/// TODO
pub const P2P_DEFAULT_PACKET_MAX_SIZE: u64 = 50000000; //50000000 bytes maximum packet size
/// TODO
pub const P2P_DEFAULT_PEERS_IN_HANDSHAKE: u64 = 250;
/// TODO
pub const P2P_MAX_PEERS_IN_HANDSHAKE: u64 = 250;
/// TODO
pub const P2P_DEFAULT_CONNECTION_TIMEOUT: u64 = 5000; //5 seconds
/// TODO
pub const P2P_DEFAULT_SOCKS_CONNECT_TIMEOUT: u64 = 45; // seconds
/// TODO
pub const P2P_DEFAULT_PING_CONNECTION_TIMEOUT: u64 = 2000; //2 seconds
/// TODO
pub const P2P_DEFAULT_INVOKE_TIMEOUT: u64 = 60 * 2 * 1000; //2 minutes
/// TODO
pub const P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT: u64 = 5000; //5 seconds
/// TODO
pub const P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT: u64 = 70;
/// TODO
pub const P2P_DEFAULT_ANCHOR_CONNECTIONS_COUNT: u64 = 2;
/// TODO
pub const P2P_DEFAULT_SYNC_SEARCH_CONNECTIONS_COUNT: u64 = 2;
/// TODO
pub const P2P_DEFAULT_LIMIT_RATE_UP: u64 = 2048; // kB/s
/// TODO
pub const P2P_DEFAULT_LIMIT_RATE_DOWN: u64 = 8192; // kB/s
/// TODO
pub const P2P_FAILED_ADDR_FORGET_SECONDS: u64 = 60 * 60; //1 hour
/// TODO
pub const P2P_IP_BLOCKTIME: u64 = 60 * 60 * 24; //24 hour
/// TODO
pub const P2P_IP_FAILS_BEFORE_BLOCK: u64 = 10;
/// TODO
pub const P2P_IDLE_CONNECTION_KILL_INTERVAL: u64 = 5 * 60; //5 minutes
/// TODO
pub const P2P_SUPPORT_FLAG_FLUFFY_BLOCKS: u64 = 0x01;
/// TODO
pub const P2P_SUPPORT_FLAGS: u64 = P2P_SUPPORT_FLAG_FLUFFY_BLOCKS;

10
constants/src/pruning.rs Normal file
View file

@ -0,0 +1,10 @@
//! TODO
/// The default log stripes for Monero pruning.
pub const CRYPTONOTE_PRUNING_LOG_STRIPES: u32 = 3;
/// The amount of blocks that peers keep before another stripe starts storing blocks.
pub const CRYPTONOTE_PRUNING_STRIPE_SIZE: usize = 4096;
/// The amount of blocks from the top of the chain that should not be pruned.
pub const CRYPTONOTE_PRUNING_TIP_BLOCKS: usize = 5500;

40
constants/src/rpc.rs Normal file
View file

@ -0,0 +1,40 @@
//! TODO
//!
//! - <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L63-L77>
//! - <https://github.com/monero-project/monero/blob/a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623/src/cryptonote_core/cryptonote_core.cpp#L63-L72>
/// TODO
pub const MAX_RESTRICTED_FAKE_OUTS_COUNT: usize = 40;
/// TODO
pub const MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT: usize = 5000;
/// 3 days max, the wallet requests 1.8: usize = days.
pub const OUTPUT_HISTOGRAM_RECENT_CUTOFF_RESTRICTION: usize = 3 * 86400;
/// TODO
pub const RESTRICTED_BLOCK_HEADER_RANGE: u64 = 1000;
/// TODO
pub const RESTRICTED_TRANSACTIONS_COUNT: usize = 100;
/// TODO
pub const RESTRICTED_SPENT_KEY_IMAGES_COUNT: usize = 5000;
/// TODO
pub const RESTRICTED_BLOCK_COUNT: usize = 1000;
/// TODO
pub const BLOCK_SIZE_SANITY_LEEWAY: usize = 100;
/// TODO
pub const COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT: u64 = 1000;
/// TODO
pub const COMMAND_RPC_GET_BLOCKS_FAST_MAX_TX_COUNT: u64 = 20_000;
/// TODO
pub const MAX_RPC_CONTENT_LENGTH: u64 = 1_048_576; // 1 MB
/// TODO
pub const RPC_IP_FAILS_BEFORE_BLOCK: u64 = 3;

4
constants/src/sys.rs Normal file
View file

@ -0,0 +1,4 @@
//! TODO
/// TODO
pub const THREAD_STACK_SIZE: u64 = 5 * 1024 * 1024;

67
constants/src/tx.rs Normal file
View file

@ -0,0 +1,67 @@
//! TODO
use std::time::Duration;
use crate::{difficulty, macros::monero_definition_link};
/// TODO
#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 41)]
pub const MAX_TX_SIZE: u64 = 1_000_000;
/// TODO
#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 42)]
pub const MAX_TX_PER_BLOCK: u64 = 0x10000000;
/// TODO
#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 44)]
pub const MINED_MONEY_UNLOCK_WINDOW: u64 = 60;
/// TODO
#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 45)]
pub const CURRENT_TRANSACTION_VERSION: u64 = 2;
/// TODO
#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 49)]
pub const DEFAULT_TX_SPENDABLE_AGE: u64 = 10;
/// TODO
pub const LOCKED_TX_ALLOWED_DELTA_SECONDS_V1: u64 =
difficulty::DIFFICULTY_TARGET_V1.as_secs() * LOCKED_TX_ALLOWED_DELTA_BLOCKS;
/// TODO
pub const LOCKED_TX_ALLOWED_DELTA_SECONDS_V2: u64 =
difficulty::DIFFICULTY_TARGET_V2.as_secs() * LOCKED_TX_ALLOWED_DELTA_BLOCKS;
/// TODO
pub const LOCKED_TX_ALLOWED_DELTA_BLOCKS: u64 = 1;
/// TODO
#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 213)]
pub const MAX_TX_EXTRA_SIZE: u64 = 1060;
/// Three days.
#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 102)]
///
/// ```rust
/// # use cuprate_constants::tx::*;
/// assert_eq!(MEMPOOL_TX_LIFETIME.as_secs(), 86_400 * 3);
/// ```
pub const MEMPOOL_TX_LIFETIME: Duration = Duration::from_secs(86_400 * 3);
/// One week.
#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 103)]
///
/// ```rust
/// # use cuprate_constants::tx::*;
/// assert_eq!(MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME.as_secs(), 86_400 * 7);
/// ```
pub const MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME: u64 = 86_400 * 7;
/// TODO
pub const PER_KB_FEE_QUANTIZATION_DECIMALS: u64 = 8;
/// TODO
pub const SCALING_2021_FEE_ROUNDING_PLACES: u64 = 2;
/// TODO
pub const DEFAULT_TXPOOL_MAX_WEIGHT: u64 = 648_000_000; // 3 days at 300000, in bytes

View file

@ -1,22 +0,0 @@
//! General `const`ants and `static`s.
//!
//! `#[no_std]` compatible.
//---------------------------------------------------------------------------------------------------- Commit
/// The current commit hash of the root Cuprate repository.
///
/// # Case & length
/// It is guaranteed that `COMMIT` will be:
/// - Lowercase
/// - 40 characters long (no newline)
///
/// ```rust
/// # use cuprate_helper::constants::*;
/// assert_eq!(COMMIT.as_bytes().len(), 40);
/// assert_eq!(COMMIT.to_lowercase(), COMMIT);
/// ```
pub const COMMIT: &str = core::env!("COMMIT"); // Set in `helper/build.rs`.
//---------------------------------------------------------------------------------------------------- Tests
#[cfg(test)]
mod test {}

View file

@ -11,9 +11,6 @@ pub mod atomic;
#[cfg(feature = "cast")] #[cfg(feature = "cast")]
pub mod cast; pub mod cast;
#[cfg(feature = "constants")]
pub mod constants;
#[cfg(feature = "fs")] #[cfg(feature = "fs")]
pub mod fs; pub mod fs;