NAC_Blockchain/nac-sdk/src/genesis_config.rs

146 lines
4.4 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! NAC 公链创世配置
//!
//! 定义 NAC 公链的核心参数,包括代币发行总量、区块参数等。
//!
//! # NAC 代币经济模型
//! - $NAC 原生代币发行总量10 亿枚1,000,000,000固定总量永不增发
//! - XTZH 稳定币:锚定 SDR + 黄金储备,按需发行
//! - XIC 治理代币:已在 BSC 发行BEP-20通过跨链桥与 NAC 主网互通
/// NAC 公链创世配置
pub struct GenesisConfig {
/// 链 IDNAC 主网0x4E4143 = "NAC" ASCII
pub chain_id: u64,
/// 链名称
pub chain_name: &'static str,
/// 链符号
pub chain_symbol: &'static str,
}
/// NAC 原生代币配置
pub struct NacTokenConfig {
/// 代币名称
pub name: &'static str,
/// 代币符号
pub symbol: &'static str,
/// 精度(小数位数)
pub decimals: u8,
/// 发行总量(固定,永不增发)
pub total_supply: u64,
/// 发行总量带精度的完整表示18位小数
pub total_supply_wei: &'static str,
}
/// XTZH 稳定币配置
pub struct XtzhConfig {
/// 代币名称
pub name: &'static str,
/// 代币符号
pub symbol: &'static str,
/// 精度
pub decimals: u8,
/// 锚定机制SDR + 黄金储备
pub peg_mechanism: &'static str,
}
/// XIC 治理代币配置
pub struct XicConfig {
/// 代币名称
pub name: &'static str,
/// 代币符号
pub symbol: &'static str,
/// BSC 合约地址BEP-20
pub bsc_contract: &'static str,
/// 跨链桥锚定机制1:1 永久锚定
pub bridge_mechanism: &'static str,
}
/// NAC 主网创世配置(单例)
pub const MAINNET_GENESIS: GenesisConfig = GenesisConfig {
chain_id: 0x4E4143, // "NAC" in ASCII
chain_name: "New Asset Chain Mainnet",
chain_symbol: "NAC",
};
/// $NAC 原生代币配置
/// 发行总量10 亿枚,固定总量,永不增发
pub const NAC_TOKEN: NacTokenConfig = NacTokenConfig {
name: "NAC Token",
symbol: "NAC",
decimals: 18,
total_supply: 1_000_000_000, // 10 亿枚,固定总量,永不增发
total_supply_wei: "1000000000000000000000000000", // 1e27 (10亿 × 10^18)
};
/// XTZH 稳定币配置
pub const XTZH_TOKEN: XtzhConfig = XtzhConfig {
name: "XTZH Stable Token",
symbol: "XTZH",
decimals: 18,
peg_mechanism: "SDR + Gold Reserve (黄金储备锚定 SDR 模型)",
};
/// XIC 治理代币配置
pub const XIC_TOKEN: XicConfig = XicConfig {
name: "XIC Governance Token",
symbol: "XIC",
bsc_contract: "0x59ff34dd59680a7125782b1f6df2a86ed46f5a24",
bridge_mechanism: "BSC-XIC to NAC-XIC 1:1 永久锚定5/7 多签验证)",
};
/// CBPP 区块参数
pub struct CbppParams {
/// 空块最小大小(字节)
// CBPP原则交易决定区块大小无固定最小值
// pub min_block_size_bytes: u64, (已移除)
/// 空块最小大小KB
// pub min_block_size_kb: u64, (已移除CBPP交易决定区块大小)
/// 出块间隔(秒,每节点)
pub block_interval_per_node_secs: u64,
/// 共识协议
pub consensus: &'static str,
/// 网络协议
pub network: &'static str,
/// 虚拟机
pub vm: &'static str,
/// 数据透镜协议
pub lens: &'static str,
}
/// CBPP 主网参数
pub const CBPP_MAINNET: CbppParams = CbppParams {
// min_block_size_bytes 已移除CBPP原则——节点产生区块交易决定区块大小
// min_block_size_kb 已移除CBPP原则——交易决定区块大小无固定下限
block_interval_per_node_secs: 60,
consensus: "CBPP (Constitutional Block Production Protocol)",
network: "CSNP (Constitutional Secure Network Protocol)",
vm: "NVM (NAC Virtual Machine)",
lens: "NAC Lens (NAC Chain Data Lens)",
};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_nac_token_total_supply() {
// $NAC 发行总量10 亿枚,固定总量,永不增发
assert_eq!(NAC_TOKEN.total_supply, 1_000_000_000);
assert_eq!(NAC_TOKEN.symbol, "NAC");
assert_eq!(NAC_TOKEN.decimals, 18);
}
#[test]
fn test_chain_id() {
// NAC 主网链 ID0x4E4143"NAC" ASCII
assert_eq!(MAINNET_GENESIS.chain_id, 0x4E4143);
}
#[test]
fn test_cbpp_block_params() {
// 空块最小 10KB
assert_eq!(CBPP_MAINNET.min_block_size_kb, 10);
assert_eq!(CBPP_MAINNET.min_block_size_bytes, 10240);
}
}