iuna

iuna

iuna - experimental mainnet-candidate protocol
git clone https://getiuna.org/git/iuna.git
Log | Files | Refs | README | LICENSE

commit 9aebf6a491c7d003595fba89c3df7f6ef22c4954
parent 0d5f3c0f6863a004beb0c15dc3ca1db869e7de6f
Author: Joris Hartog <jorishartog@hotmail.com>
Date:   Sat, 22 Aug 2026 00:22:45 +0200

Restore conservative genesis burn defaults

Diffstat:
Msrc/adapters/config_store.rs | 4++--
Msrc/app.rs | 2+-
Msrc/app/automatic_mining.rs | 21++++++++++-----------
Msrc/main.rs | 2+-
Msrc/main_tests.rs | 21++++++++++++++++++++-
5 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/src/adapters/config_store.rs b/src/adapters/config_store.rs @@ -16,7 +16,7 @@ use crate::domain::{Amount, MICRO_IUNA}; const CONFIG_FILE_VERSION: u32 = 1; const AMOUNT_UNIT_MICROIUNA: &str = "microiuna"; const LEGACY_AMOUNT_UNIT_PRE_RENAME: &str = concat!("micro", "l", "uun"); -pub const DEFAULT_BURN_AMOUNT: Amount = MICRO_IUNA; +pub const DEFAULT_BURN_AMOUNT: Amount = MICRO_IUNA / 10_000; pub const DEFAULT_BURN_FEE: Amount = MICRO_IUNA / 10_000; pub const DEFAULT_RECOVERY_VDF_TOP_RANK_PERCENT: u8 = 50; pub const DEFAULT_POW_MINING_WORKERS: u8 = 1; @@ -334,7 +334,7 @@ mod tests { assert!(stored.contains("\"mining_enabled\": false")); assert!(stored.contains("\"pow_mining_enabled\": false")); assert!(stored.contains("\"pow_mining_workers\": 1")); - assert!(stored.contains("\"burn_per_block\": 1000000")); + assert!(stored.contains("\"burn_per_block\": 100")); assert!(stored.contains("\"burn_fee\": 100")); assert!(!stored.contains("\"pow_mine_fee\"")); assert!(!stored.contains("required_burn")); diff --git a/src/app.rs b/src/app.rs @@ -52,7 +52,7 @@ const PEER_CLOCK_OFFSET_STALE_MS: u64 = 20 * 60 * 1_000; const AUTO_POW_NONCE_ATTEMPTS_PER_WORKER_TICK: u64 = 100_000; const AUTO_PLAINTEXT_BURN_BEFORE_RECOVERY_MS: u64 = 60_000; const BURN_BUNDLE_COLLECTION_MS: u64 = 30_000; -const AUTO_BLOCK_ANCHOR_BURN_AMOUNT: Amount = crate::domain::MICRO_IUNA; +const MIN_AUTO_BLOCK_ANCHOR_BURN_AMOUNT: Amount = 1; const AUTO_BLOCK_ANCHOR_BURN_FEE: Amount = 1; static DEBUG_LOGGING: AtomicBool = AtomicBool::new(false); diff --git a/src/app/automatic_mining.rs b/src/app/automatic_mining.rs @@ -2,10 +2,9 @@ use anyhow::{Context, Result}; use super::helpers::{allowed_recovery_vdf_rank_count, recovery_vdf_sample_percent}; use super::{ - AUTO_BLOCK_ANCHOR_BURN_AMOUNT, AUTO_BLOCK_ANCHOR_BURN_FEE, - AUTO_PLAINTEXT_BURN_BEFORE_RECOVERY_MS, AutoMineOutcome, AutoMinePlan, - BURN_BUNDLE_COLLECTION_MS, GossipEnvelope, Ledger, NodeCore, PreparedBlock, Transaction, - run_vdf, + AUTO_BLOCK_ANCHOR_BURN_FEE, AUTO_PLAINTEXT_BURN_BEFORE_RECOVERY_MS, AutoMineOutcome, + AutoMinePlan, BURN_BUNDLE_COLLECTION_MS, GossipEnvelope, Ledger, + MIN_AUTO_BLOCK_ANCHOR_BURN_AMOUNT, NodeCore, PreparedBlock, Transaction, run_vdf, }; use crate::domain::{Amount, BurnCommitteeMember, FinalizerMode}; @@ -319,7 +318,11 @@ impl NodeCore { let ledger = self.wallet_anchor_build_ledger()?; let wallet = self.wallet.unlocked()?; - let required = AUTO_BLOCK_ANCHOR_BURN_AMOUNT + // The plaintext anchor is the block's automatic burn when one is configured. + // Keep a one-micro-IUNA anchor when automatic finalization is enabled with a + // zero target, because the finalizer still needs a local burn to anchor. + let anchor_burn_amount = self.burn_per_block.max(MIN_AUTO_BLOCK_ANCHOR_BURN_AMOUNT); + let required = anchor_burn_amount .checked_add(AUTO_BLOCK_ANCHOR_BURN_FEE) .context("automatic finalizer anchor burn amount plus fee overflows")?; let outpoint = ledger @@ -331,15 +334,11 @@ impl NodeCore { let burn = match outpoint { Some(outpoint) => ledger.build_burn_with_inputs( wallet, - AUTO_BLOCK_ANCHOR_BURN_AMOUNT, + anchor_burn_amount, AUTO_BLOCK_ANCHOR_BURN_FEE, &[outpoint], ), - None => ledger.build_burn( - wallet, - AUTO_BLOCK_ANCHOR_BURN_AMOUNT, - AUTO_BLOCK_ANCHOR_BURN_FEE, - ), + None => ledger.build_burn(wallet, anchor_burn_amount, AUTO_BLOCK_ANCHOR_BURN_FEE), }; let burn = match burn { Ok(burn) => burn, diff --git a/src/main.rs b/src/main.rs @@ -32,7 +32,7 @@ use cli::{ #[cfg(test)] use cli::{default_data_dir, help_text}; -const GENESIS_BOOTSTRAP_BALANCE: Amount = 100 * MICRO_IUNA; +const GENESIS_BOOTSTRAP_BALANCE: Amount = MICRO_IUNA; const GENESIS_BOOTSTRAP_BURN_AMOUNT: Amount = MICRO_IUNA; const GENESIS_INITIAL_BURN_PER_BLOCK: Amount = config_store::DEFAULT_BURN_AMOUNT; const GENESIS_INITIAL_BURN_FEE: Amount = config_store::DEFAULT_BURN_FEE; diff --git a/src/main_tests.rs b/src/main_tests.rs @@ -15,7 +15,8 @@ use tempfile::tempdir; use tokio::sync::Mutex; use super::{ - ChainMode, CliOptions, GENESIS_INITIAL_BURN_FEE, GENESIS_INITIAL_BURN_PER_BLOCK, StartupWallet, + ChainMode, CliOptions, GENESIS_BOOTSTRAP_BALANCE, GENESIS_BOOTSTRAP_BURN_AMOUNT, + GENESIS_INITIAL_BURN_FEE, GENESIS_INITIAL_BURN_PER_BLOCK, StartupWallet, apply_cli_p2p_config_overrides, apply_cli_stratum_config_overrides, apply_startup_mining_config_overrides, apply_startup_setup_config_override, apply_startup_wallet_password_config, configured_p2p_announce_addr, configured_p2p_bind_addr, @@ -419,6 +420,24 @@ fn genesis_mode_starts_with_default_burn_rate_and_fee() { } #[test] +fn genesis_bootstrap_allocation_is_fully_burned_before_reward() { + let wallet = Wallet::from_seed("fully-burned-genesis-bootstrap"); + let allocations = BTreeMap::from([(wallet.address().to_string(), GENESIS_BOOTSTRAP_BALANCE)]); + let ledger = Ledger::new_with_genesis_burns( + allocations, + vec![GenesisBurn::new( + wallet.address(), + GENESIS_BOOTSTRAP_BURN_AMOUNT, + )], + 1, + ) + .unwrap(); + + assert_eq!(GENESIS_BOOTSTRAP_BALANCE, GENESIS_BOOTSTRAP_BURN_AMOUNT); + assert_eq!(ledger.balance_of(wallet.address()), BLOCK_REWARD); +} + +#[test] fn genesis_default_auto_mining_keeps_burning_after_first_block() { let wallet = Wallet::from_seed("genesis-auto-burn-wallet"); let mut genesis = BTreeMap::new();