domain.rs (5119B)
1 #[cfg(test)] 2 use std::collections::{BTreeMap, BTreeSet}; 3 4 mod blinded; 5 mod block; 6 mod fork; 7 mod genesis; 8 mod hex; 9 mod history; 10 mod ledger_apply; 11 mod ledger_builders; 12 mod ledger_chain; 13 mod ledger_consensus; 14 mod ledger_mempool; 15 mod ledger_ops; 16 mod ledger_pending; 17 mod ledger_prepare; 18 mod ledger_queries; 19 mod ledger_reveal; 20 mod ledger_state; 21 mod mine_policy; 22 mod mining; 23 mod profile; 24 mod protocol; 25 mod reveal; 26 mod selection; 27 mod stratum; 28 mod ticket; 29 mod transaction; 30 mod validation; 31 mod vdf; 32 mod wallet; 33 use blinded::{ActiveBlindedTransaction, blinded_fee_share}; 34 #[cfg(test)] 35 use blinded::{ 36 blinded_committer_fee_outpoint, blinded_executor_fee_outpoint, blinded_expiry_change_outpoint, 37 blinded_reveal_bundle_signer_fee_outpoint, blinded_transaction_commitment, 38 credit_blinded_fee_outputs, decrypt_blinded_payload, decrypt_blinded_transaction, 39 }; 40 use block::LeaderProofPayload; 41 pub use block::{ 42 Block, BurnLeaderRank, ChainSnapshot, ChainStatus, FinalizerMode, LeaderProof, PreparedBlock, 43 }; 44 use fork::LeaderScore; 45 #[cfg(test)] 46 use genesis::balances_from_utxos; 47 use genesis::genesis_allocation_outpoint; 48 pub use hex::hex_hash; 49 use hex::{decode_hex, decode_hex_array, hex_encode}; 50 pub use history::revealed_blinded_transactions; 51 #[cfg(test)] 52 use ledger_ops::estimated_block_selection_size_bytes; 53 #[cfg(test)] 54 use ledger_ops::fee_reward; 55 #[cfg(test)] 56 use ledger_ops::reward_outpoint; 57 use ledger_ops::{ 58 apply_transaction, credit_reward_output, ensure_block_has_burn, ensure_block_has_burn_from, 59 ensure_outputs_do_not_overflow, ensure_single_input_owner_for_inputs, 60 recovery_vdf_seed_for_child, validate_genesis_burn_transaction, vdf_seed_for_child, 61 }; 62 pub use ledger_state::Ledger; 63 use ledger_state::unix_now_ms; 64 #[cfg(test)] 65 use mine_policy::MINE_RETARGET_WINDOW_BLOCKS; 66 #[cfg(test)] 67 use mine_policy::{ 68 MINE_MAX_ANCHOR_AGE_BLOCKS, MINE_MAX_RETARGET_STEP_BITS, MINE_MIN_DIFFICULTY_BITS, 69 }; 70 use mining::{mine_payload, mine_signature}; 71 pub use profile::{GenesisBurn, LaunchProfile}; 72 pub use protocol::{ 73 Amount, BLINDED_COMMITTER_FEE_BPS, BLINDED_FEE_BPS_DENOMINATOR, 74 BLINDED_REVEAL_BUNDLE_SIGNER_FEE_BPS, BLINDED_REVEAL_FINALIZER_FEE_BPS, BLOCK_REWARD, 75 DEFAULT_FEE_PER_BYTE, DEFAULT_MINE_FEE, DEFAULT_TRANSACTION_FEE, 76 MAX_BLINDED_TRANSACTION_EXPIRY_HEIGHTS, MAX_BLOCK_BYTES, MAX_PENDING_TRANSACTIONS, 77 MAX_REVEAL_BUNDLE_BYTES, MAX_VDF_ROUNDS, MICRO_IUNA, MINE_ACTIONS_PER_ANCHOR_LIMIT, 78 MINE_DIFFICULTY_BITS, MINE_FINALIZER_FEE, MINE_REWARD, RECOVERY_BLOCK_DELAY_MS, 79 REVEAL_COMMITTEE_SIZE, TransactionSubmitOutcome, VDF_TARGET_BLOCK_MS, 80 }; 81 use protocol::{ 82 BLINDED_KEY_BYTES, BLINDED_NONCE_BYTES, BLOCK_MEDIAN_TIME_PAST_WINDOW, 83 DEFAULT_TICKET_EXPIRY_WINDOW, DEFAULT_TICKET_MATURITY_DELAY, FORK_FINALITY_DEPTH, HASH_BYTES, 84 MAX_BLOCK_TIMESTAMP_FUTURE_DRIFT_MS, MAX_BLOCK_TRANSACTIONS, MAX_ORPHAN_TRANSACTIONS, 85 PUBLIC_KEY_BYTES, SIGNATURE_BYTES, 86 }; 87 use reveal::RevealBundlePayload; 88 #[cfg(test)] 89 use reveal::reveal_bundle_hashes; 90 pub use reveal::{ 91 MaskedBlindedReveal, RevealBundle, RevealBundleSection, RevealBundleSignature, 92 RevealCommitteeMember, default_reveal_bundle_hash, 93 }; 94 use selection::BlockSelection; 95 pub use stratum::{ 96 STRATUM_EXTRANONCE1_HEX, STRATUM_EXTRANONCE2_SIZE, StratumMineShare, StratumMineTemplate, 97 pack_stratum_nonce, 98 }; 99 use stratum::{hash_meets_difficulty, stratum_mine_header_bytes, stratum_mine_signature}; 100 use ticket::{BurnTicket, ticket_block_min_timestamp}; 101 #[cfg(test)] 102 use ticket::{ 103 MISSED_FALLBACK_TICKET_INVALIDATION_HEIGHT, consume_leader_ticket, ranked_tickets_for_height, 104 ticket_is_eligible_for_height, 105 }; 106 pub use transaction::{ 107 BlindedReveal, BlindedTransaction, BuiltBlindedTransaction, MineSearchOutcome, OutPoint, 108 OwnedBlindedTransaction, RevealedBlindedTransaction, Transaction, TxInput, TxOutput, 109 }; 110 #[cfg(test)] 111 use transaction::{ 112 UnsignedTxInput, UnsignedUtxoTransaction, signed_blinded_inputs, unsigned_inputs, 113 }; 114 pub use validation::validate_address; 115 use validation::{ 116 canonical_transaction_size_bytes, validate_hash, validate_protocol_id, validate_signature, 117 }; 118 #[cfg(test)] 119 use vdf::{ 120 MAX_VDF_RETARGET_OBSERVED_BLOCK_MS, MIN_VDF_RETARGET_OBSERVED_BLOCK_MS, 121 VDF_RETARGET_DEADBAND_PERCENT, clamped_vdf_retarget_observed_block_ms, retarget_vdf_rounds, 122 vdf_retarget_observed_block_ms, 123 }; 124 pub use vdf::{run_vdf, verify_vdf}; 125 pub use wallet::Wallet; 126 127 pub fn reveal_committee_slot_count(eligible_rank_count: usize) -> usize { 128 eligible_rank_count.min(REVEAL_COMMITTEE_SIZE) 129 } 130 131 pub fn blinded_reveal_finalizer_fee( 132 fee: Amount, 133 included_bundle_count: usize, 134 available_bundle_slots: usize, 135 ) -> Amount { 136 if included_bundle_count == 0 { 137 return 0; 138 } 139 let available_bundle_slots = available_bundle_slots.clamp(1, REVEAL_COMMITTEE_SIZE); 140 let included_bundle_count = included_bundle_count.min(available_bundle_slots); 141 let full_share = blinded_fee_share(fee, BLINDED_REVEAL_FINALIZER_FEE_BPS); 142 ((full_share as u128 * included_bundle_count as u128) / available_bundle_slots as u128) 143 as Amount 144 } 145 146 #[cfg(test)] 147 mod tests;