From b7264570d5aaf93d498205ff035c4543245dc54c Mon Sep 17 00:00:00 2001 From: brianp Date: Wed, 8 Feb 2023 16:09:43 -0800 Subject: [PATCH 1/3] Make StageNet network available Adds StageNet, with consnsus and genesis block in preparation for the release of the StageNet network. --- base_layer/core/src/blocks/genesis_block.rs | 96 ++++++++++++++++++- .../core/src/consensus/consensus_constants.rs | 47 +++++++++ base_layer/core/src/consensus/network.rs | 3 +- common/src/configuration/bootstrap.rs | 2 + common/src/configuration/network.rs | 13 ++- 5 files changed, 157 insertions(+), 4 deletions(-) diff --git a/base_layer/core/src/blocks/genesis_block.rs b/base_layer/core/src/blocks/genesis_block.rs index 33ef0c451a..e37e0bcaeb 100644 --- a/base_layer/core/src/blocks/genesis_block.rs +++ b/base_layer/core/src/blocks/genesis_block.rs @@ -50,9 +50,10 @@ use crate::{ /// Returns the genesis block for the selected network. pub fn get_genesis_block(network: Network) -> ChainBlock { - use Network::{Dibbler, Esmeralda, Igor, LocalNet, MainNet, Ridcully, Stibbons, Weatherwax}; + use Network::{Dibbler, Esmeralda, Igor, LocalNet, MainNet, Ridcully, StageNet, Stibbons, Weatherwax}; match network { MainNet => get_mainnet_genesis_block(), + StageNet => get_stagenet_genesis_block(), Igor => get_igor_genesis_block(), Esmeralda => get_esmeralda_genesis_block(), LocalNet => get_esmeralda_genesis_block(), @@ -63,6 +64,99 @@ pub fn get_genesis_block(network: Network) -> ChainBlock { } } +pub fn get_stagenet_genesis_block() -> ChainBlock { + let block = get_stagenet_genesis_block_raw(); + + let accumulated_data = BlockHeaderAccumulatedData { + hash: block.hash(), + total_kernel_offset: block.header.total_kernel_offset.clone(), + achieved_difficulty: 1.into(), + total_accumulated_difficulty: 1, + accumulated_monero_difficulty: 1.into(), + accumulated_sha_difficulty: 1.into(), + target_difficulty: 1.into(), + }; + ChainBlock::try_construct(Arc::new(block), accumulated_data).unwrap() +} + +fn get_stagenet_genesis_block_raw() -> Block { + // Note: Use print_new_genesis_block_stagenet in core/tests/helpers/block_builders.rs to generate the required + // fields below + let excess_sig = Signature::new( + PublicKey::from_hex("fcd46ec2a4ad022319b903972c4a30e9ec08ed353e9245f67b474a3028aaf917").unwrap(), + PrivateKey::from_hex("74744c8ecaa03c18ab767090590bac45830c47f4cd2b0b40c358d9e6de73080e").unwrap(), + ); + let coinbase_meta_sig = CommitmentAndPublicKeySignature::new( + Commitment::from_hex("7e236c28aeac44c79a65d855dc678ccc19f960bc0a9c50a2d5bc19ee1df20d23").unwrap(), + PublicKey::from_hex("241f5034fd1dda26b223d2b12e816a1f729da86e0faa5609f2258ee6dd2c8e6e").unwrap(), + PrivateKey::from_hex("5271e5e4d4c8c4f791a6268aa3b21823a1e56c1c557304853192a876764aa902").unwrap(), + PrivateKey::from_hex("75b8fba7ecb555785bca632d142d33d464669c6c6288fb17122a220ca8cceb01").unwrap(), + PrivateKey::from_hex("b3000fb10de4c100cc271b3cb5065a916904dc265b37c4c0b45f9cb9a0f7cc00").unwrap(), + ); + let coinbase = TransactionOutput::new( + TransactionOutputVersion::get_current_version(), + OutputFeatures::create_coinbase(6, None), + Commitment::from_hex("f47a5c3e60f5048829411fa20597827b97466d75a08944f269459008db85f678").unwrap(), + BulletRangeProof::from_hex("01321cc9e1c5bcdd29caf074acbed7de56557c4a03a74db0d9cc652ea38bd06f347e269a30088356eb8fb4299ea47fc867b823ba61241e59b508db9880d2cc961360ba8a3d47377b53bc552d904306baa1086375d2b60140c1619c15e9a718dc366014f3cd0d0fc248a21d62b093eaebfedb8acafef836d31d8151a33752ac4023ba57069033b3e21d125c1fadd07142f12d463527675b78d88780158bb18c9f68a25857c12c9322a60601012591747e8c98766de4e4200218dd9b417c3b537c0f169b61fcf63692ccc722cebbcc88e3d4066eab6c4a7af01fae79efc97bf8ca17cac86747c7696537d82dbc623c422361d98d7eae4d7d86d0a0f3f1a6a8bae55598170094ee06532a55ad83af980ea43a197785eaefaa028c4b6489364e191943d6cfdda824ec10e3bfb7c3639e8821248bdbc193a56a9a1d2366041af782aa5146a6b8b4387b40ed94a4f27c0f6ba6f1849c0ca5ecdcaf268e6102a7ce6e6b39ae79a574ea8cd88e339cdafa8e5cf8d13bb32c939f2c1ff62344be8a233ae318fc858d1c24cab167c0a0590bffafea86288d84fbe57e069b5cbaf86823bafe243818506d80c7a33c504b6d1989ca0b2c60315dbb6e85f0b2ebd0e616c0b9010952fd2c3f32c7bce24bcb9866a1320780e80fbfed4d144f0b4ae310b84a077109ee71a6c7c0e7658f33c86745064ab64fd1d910d098f9055e2cbd591ced3e6e05750ea2898530f078c06c7e17a3e9aedf5e569b1ac8fe7ca623ed48eddffae209f361269af40e7b06ff8740661fefae75f4aa85d39de298f0c816be8bf0254004").unwrap(), + // A default script can never be spent, intentionally + script!(Nop), + // The Sender offset public key is not checked for coinbase outputs + PublicKey::from_hex("f4b9a7b76491b096be5e0b40d995151b18dcde09e34eecc9a91385d9b16a3634").unwrap(), + coinbase_meta_sig, + // Covenant + Covenant::default(), + EncryptedValue::default(), + // Genesis blocks don't need to prove a minimum value + MicroTari::zero(), + ); + let kernel = TransactionKernel::new( + TransactionKernelVersion::V0, + KernelFeatures::COINBASE_KERNEL, + MicroTari(0), + 0, + Commitment::from_hex("a23aa2ebc878f201f1958fabd1467bac60526b18231b8a2e1a52587678be0f31").unwrap(), + excess_sig, + None, + ); + let mut body = AggregateBody::new(vec![], vec![coinbase], vec![kernel]); + body.sort(); + // set genesis timestamp + let genesis = DateTime::parse_from_rfc2822("8 Feb 2023 13:00:00 -0800").unwrap(); + #[allow(clippy::cast_sign_loss)] + let timestamp = genesis.timestamp() as u64; + Block { + header: BlockHeader { + version: 0, + height: 0, + prev_hash: FixedHash::zero(), + timestamp: timestamp.into(), + output_mr: FixedHash::from_hex("f52f31e506f3873eef04737aaaaa119e385338dda58b16affa414dc277c20577").unwrap(), + witness_mr: FixedHash::from_hex("75e7f57c00bd536ad157543d117034e8ce7f12a39ed43f65e304fb77d5a360b3") + .unwrap(), + output_mmr_size: 1, + kernel_mr: FixedHash::from_hex("cf5faaed9a852f62758f3d005fac7dacdc6234f2d0dfad3281d625aeca50e0a8").unwrap(), + kernel_mmr_size: 1, + input_mr: FixedHash::zero(), + total_kernel_offset: PrivateKey::from_hex( + "0000000000000000000000000000000000000000000000000000000000000000", + ) + .unwrap(), + total_script_offset: PrivateKey::from_hex( + "0000000000000000000000000000000000000000000000000000000000000000", + ) + .unwrap(), + nonce: 0, + pow: ProofOfWork { + pow_algo: PowAlgorithm::Sha3, + pow_data: vec![], + }, + validator_node_mr: FixedHash::from_hex("e1d55f91ecc7e435080ac2641280516a355a5ecbe231158987da217b5af30047") + .unwrap(), + }, + body, + } +} + pub fn get_mainnet_genesis_block() -> ChainBlock { unimplemented!() } diff --git a/base_layer/core/src/consensus/consensus_constants.rs b/base_layer/core/src/consensus/consensus_constants.rs index 54724bfef6..314d10df61 100644 --- a/base_layer/core/src/consensus/consensus_constants.rs +++ b/base_layer/core/src/consensus/consensus_constants.rs @@ -615,6 +615,53 @@ impl ConsensusConstants { vec![consensus_constants_1] } + pub fn stagenet() -> Vec { + // Note these values are all placeholders for final values + let difficulty_block_window = 90; + let mut algos = HashMap::new(); + algos.insert(PowAlgorithm::Sha3, PowAlgorithmConstants { + max_target_time: 1800, + min_difficulty: 40_000.into(), + max_difficulty: u64::MAX.into(), + target_time: 300, + }); + algos.insert(PowAlgorithm::Monero, PowAlgorithmConstants { + max_target_time: 800, + min_difficulty: 70_000_000.into(), + max_difficulty: u64::MAX.into(), + target_time: 200, + }); + let (input_version_range, output_version_range, kernel_version_range) = version_zero(); + vec![ConsensusConstants { + effective_from_height: 0, + coinbase_lock_height: 1, + blockchain_version: 1, + valid_blockchain_version_range: 0..=1, + future_time_limit: 540, + difficulty_block_window, + max_block_transaction_weight: 19500, + median_timestamp_count: 11, + emission_initial: 10_000_000.into(), + emission_decay: &EMISSION_DECAY, + emission_tail: 100.into(), + max_randomx_seed_height: u64::MAX, + proof_of_work: algos, + faucet_value: MicroTari::from(0), + transaction_weight: TransactionWeight::v1(), + max_script_byte_size: 2048, + input_version_range, + output_version_range, + kernel_version_range, + permitted_output_types: Self::current_permitted_output_types(), + vn_epoch_length: 60, + vn_validity_period_epochs: VnEpoch(100), + vn_registration_min_deposit_amount: MicroTari(0), + vn_registration_lock_height: 0, + vn_registration_shuffle_interval: VnEpoch(100), + coinbase_output_features_extra_max_length: 64, + }] + } + pub fn mainnet() -> Vec { // Note these values are all placeholders for final values let difficulty_block_window = 90; diff --git a/base_layer/core/src/consensus/network.rs b/base_layer/core/src/consensus/network.rs index 23ddc5019c..b98a92cdf0 100644 --- a/base_layer/core/src/consensus/network.rs +++ b/base_layer/core/src/consensus/network.rs @@ -30,9 +30,10 @@ pub struct NetworkConsensus(Network); impl NetworkConsensus { pub fn create_consensus_constants(&self) -> Vec { - use Network::{Dibbler, Esmeralda, Igor, LocalNet, MainNet, Ridcully, Stibbons, Weatherwax}; + use Network::{Dibbler, Esmeralda, Igor, LocalNet, MainNet, Ridcully, StageNet, Stibbons, Weatherwax}; match self.as_network() { MainNet => ConsensusConstants::mainnet(), + StageNet => ConsensusConstants::stagenet(), LocalNet => ConsensusConstants::localnet(), Dibbler => ConsensusConstants::dibbler(), Igor => ConsensusConstants::igor(), diff --git a/common/src/configuration/bootstrap.rs b/common/src/configuration/bootstrap.rs index d2298b129f..898a9ba6fc 100644 --- a/common/src/configuration/bootstrap.rs +++ b/common/src/configuration/bootstrap.rs @@ -103,6 +103,7 @@ pub fn grpc_default_port(app_type: ApplicationType, network: Network) -> u16 { match app_type { ApplicationType::BaseNode => match network { Network::MainNet => 18102u16, + Network::StageNet => 18172u16, Network::Weatherwax => 18112, Network::Dibbler => 18122, Network::Esmeralda => 18142, @@ -112,6 +113,7 @@ pub fn grpc_default_port(app_type: ApplicationType, network: Network) -> u16 { }, ApplicationType::ConsoleWallet => match network { Network::MainNet => 18103u16, + Network::StageNet => 18173u16, Network::Weatherwax => 18113, Network::Dibbler => 18123, Network::Esmeralda => 18143, diff --git a/common/src/configuration/network.rs b/common/src/configuration/network.rs index 2b2e0aba6a..140a88cc56 100644 --- a/common/src/configuration/network.rs +++ b/common/src/configuration/network.rs @@ -38,6 +38,7 @@ use crate::ConfigurationError; #[serde(try_from = "String", into = "String")] pub enum Network { MainNet = 0x00, + StageNet = 0x01, LocalNet = 0x10, Ridcully = 0x21, Stibbons = 0x22, @@ -57,6 +58,7 @@ impl Network { use Network::*; match self { MainNet => "mainnet", + StageNet => "stagenet", Ridcully => "ridcully", Stibbons => "stibbons", Weatherwax => "weatherwax", @@ -72,7 +74,7 @@ impl Network { impl Default for Network { fn default() -> Self { // TODO: set the default network to mainnet - Network::Esmeralda + Network::StageNet } } @@ -87,6 +89,7 @@ impl FromStr for Network { "stibbons" => Ok(Stibbons), "weatherwax" => Ok(Weatherwax), "mainnet" => Ok(MainNet), + "stagenet" => Ok(StageNet), "localnet" => Ok(LocalNet), "igor" => Ok(Igor), "dibbler" => Ok(Dibbler), @@ -119,6 +122,7 @@ impl TryFrom for Network { fn try_from(v: u8) -> Result { match v { x if x == Network::MainNet as u8 => Ok(Network::MainNet), + x if x == Network::StageNet as u8 => Ok(Network::StageNet), x if x == Network::LocalNet as u8 => Ok(Network::LocalNet), x if x == Network::Ridcully as u8 => Ok(Network::Ridcully), x if x == Network::Stibbons as u8 => Ok(Network::Stibbons), @@ -149,6 +153,7 @@ mod test { fn network_bytes() { // get networks let mainnet = Network::MainNet; + let stagenet = Network::StageNet; let localnet = Network::LocalNet; let ridcully = Network::Ridcully; let stibbons = Network::Stibbons; @@ -159,6 +164,7 @@ mod test { // test .as_byte() assert_eq!(mainnet.as_byte(), 0x00_u8); + assert_eq!(stagenet.as_byte(), 0x01_u8); assert_eq!(localnet.as_byte(), 0x10_u8); assert_eq!(ridcully.as_byte(), 0x21_u8); assert_eq!(stibbons.as_byte(), 0x22_u8); @@ -169,6 +175,7 @@ mod test { // test .as_key_str() assert_eq!(mainnet.as_key_str(), "mainnet"); + assert_eq!(stagenet.as_key_str(), "stagenet"); assert_eq!(localnet.as_key_str(), "localnet"); assert_eq!(ridcully.as_key_str(), "ridcully"); assert_eq!(stibbons.as_key_str(), "stibbons"); @@ -181,13 +188,14 @@ mod test { #[test] fn network_default() { let network = Network::default(); - assert_eq!(network, Network::Esmeralda); + assert_eq!(network, Network::StageNet); } #[test] fn network_from_str() { // test .from_str() assert_eq!(Network::from_str("mainnet").unwrap(), Network::MainNet); + assert_eq!(Network::from_str("stagenet").unwrap(), Network::StageNet); assert_eq!(Network::from_str("localnet").unwrap(), Network::LocalNet); assert_eq!(Network::from_str("ridcully").unwrap(), Network::Ridcully); assert_eq!(Network::from_str("stibbons").unwrap(), Network::Stibbons); @@ -204,6 +212,7 @@ mod test { #[test] fn network_from_byte() { assert_eq!(Network::try_from(0x00).unwrap(), Network::MainNet); + assert_eq!(Network::try_from(0x01).unwrap(), Network::StageNet); assert_eq!(Network::try_from(0x10).unwrap(), Network::LocalNet); assert_eq!(Network::try_from(0x21).unwrap(), Network::Ridcully); assert_eq!(Network::try_from(0x22).unwrap(), Network::Stibbons); From 261950615996ff516c9950f3933ef9ca6cab2766 Mon Sep 17 00:00:00 2001 From: brianp Date: Wed, 8 Feb 2023 16:11:34 -0800 Subject: [PATCH 2/3] Update StageNet configuration Adds additional configuration for StageNet as the deafult network. --- .../tari_merge_mining_proxy/src/config.rs | 4 +- base_layer/core/src/blocks/genesis_block.rs | 39 ++++++++++++------- .../core/src/consensus/consensus_constants.rs | 33 +++++++++------- .../core/tests/helpers/block_builders.rs | 11 ++++++ base_layer/wallet_ffi/src/lib.rs | 2 +- base_layer/wallet_ffi/wallet.h | 2 +- common/config/presets/a_common.toml | 6 +-- common/config/presets/b_peer_seeds.toml | 7 ++++ common/config/presets/c_base_node.toml | 5 ++- 9 files changed, 72 insertions(+), 37 deletions(-) diff --git a/applications/tari_merge_mining_proxy/src/config.rs b/applications/tari_merge_mining_proxy/src/config.rs index ebd3bcaff3..53d3a7d40e 100644 --- a/applications/tari_merge_mining_proxy/src/config.rs +++ b/applications/tari_merge_mining_proxy/src/config.rs @@ -114,7 +114,7 @@ mod test { [config_b.merge_mining_proxy] submit_to_origin = false monerod_url = [ "http://network.b.org" ] - monerod_password = "password_esmeralda" + monerod_password = "password_stagenet" base_node_grpc_address = "/dns4/base_node_b/tcp/8080" "#; @@ -133,7 +133,7 @@ mod test { assert_eq!(config.monerod_url.as_slice(), &["http://network.b.org".to_string()]); assert!(!config.submit_to_origin); assert_eq!(config.monerod_username.as_str(), "cmot"); - assert_eq!(config.monerod_password.as_str(), "password_esmeralda"); + assert_eq!(config.monerod_password.as_str(), "password_stagenet"); assert_eq!( config.base_node_grpc_address.to_string().as_str(), "/dns4/base_node_b/tcp/8080" diff --git a/base_layer/core/src/blocks/genesis_block.rs b/base_layer/core/src/blocks/genesis_block.rs index e37e0bcaeb..7251799eaa 100644 --- a/base_layer/core/src/blocks/genesis_block.rs +++ b/base_layer/core/src/blocks/genesis_block.rs @@ -83,25 +83,26 @@ fn get_stagenet_genesis_block_raw() -> Block { // Note: Use print_new_genesis_block_stagenet in core/tests/helpers/block_builders.rs to generate the required // fields below let excess_sig = Signature::new( - PublicKey::from_hex("fcd46ec2a4ad022319b903972c4a30e9ec08ed353e9245f67b474a3028aaf917").unwrap(), - PrivateKey::from_hex("74744c8ecaa03c18ab767090590bac45830c47f4cd2b0b40c358d9e6de73080e").unwrap(), + PublicKey::from_hex("e487276e01039473094f492f20b707d3805399f799fc9d4ad77c648f2a5c0d18").unwrap(), + PrivateKey::from_hex("544bea13bfa55f26f3cbdf986b0f7fff4a056316b252531896577d201f362704").unwrap(), ); let coinbase_meta_sig = CommitmentAndPublicKeySignature::new( - Commitment::from_hex("7e236c28aeac44c79a65d855dc678ccc19f960bc0a9c50a2d5bc19ee1df20d23").unwrap(), - PublicKey::from_hex("241f5034fd1dda26b223d2b12e816a1f729da86e0faa5609f2258ee6dd2c8e6e").unwrap(), - PrivateKey::from_hex("5271e5e4d4c8c4f791a6268aa3b21823a1e56c1c557304853192a876764aa902").unwrap(), - PrivateKey::from_hex("75b8fba7ecb555785bca632d142d33d464669c6c6288fb17122a220ca8cceb01").unwrap(), - PrivateKey::from_hex("b3000fb10de4c100cc271b3cb5065a916904dc265b37c4c0b45f9cb9a0f7cc00").unwrap(), + Commitment::from_hex("b60caad21427512b85ccc38a455419481ff4f45253b611374c68d8e82533ee66").unwrap(), + PublicKey::from_hex("76dfffcfa2c67c1b140ee04cf04fc271df193bdb4914e0b163b2507504f28b0f").unwrap(), + PrivateKey::from_hex("81631e30518430fd864a010fdba2f08f63c63f974972de179e0c9d7bdfb0d000").unwrap(), + PrivateKey::from_hex("be45ce74a588437453c4dc27ed5cc368c422cd6d86f4f180d66a6fd20a458d07").unwrap(), + PrivateKey::from_hex("43227a2310450b9adcc9d3d0ebdfa8eb6f260e6d7a8e7e5ad9b8230916333104").unwrap(), ); + let extra = "Tokenized and connected"; let coinbase = TransactionOutput::new( TransactionOutputVersion::get_current_version(), - OutputFeatures::create_coinbase(6, None), - Commitment::from_hex("f47a5c3e60f5048829411fa20597827b97466d75a08944f269459008db85f678").unwrap(), - BulletRangeProof::from_hex("01321cc9e1c5bcdd29caf074acbed7de56557c4a03a74db0d9cc652ea38bd06f347e269a30088356eb8fb4299ea47fc867b823ba61241e59b508db9880d2cc961360ba8a3d47377b53bc552d904306baa1086375d2b60140c1619c15e9a718dc366014f3cd0d0fc248a21d62b093eaebfedb8acafef836d31d8151a33752ac4023ba57069033b3e21d125c1fadd07142f12d463527675b78d88780158bb18c9f68a25857c12c9322a60601012591747e8c98766de4e4200218dd9b417c3b537c0f169b61fcf63692ccc722cebbcc88e3d4066eab6c4a7af01fae79efc97bf8ca17cac86747c7696537d82dbc623c422361d98d7eae4d7d86d0a0f3f1a6a8bae55598170094ee06532a55ad83af980ea43a197785eaefaa028c4b6489364e191943d6cfdda824ec10e3bfb7c3639e8821248bdbc193a56a9a1d2366041af782aa5146a6b8b4387b40ed94a4f27c0f6ba6f1849c0ca5ecdcaf268e6102a7ce6e6b39ae79a574ea8cd88e339cdafa8e5cf8d13bb32c939f2c1ff62344be8a233ae318fc858d1c24cab167c0a0590bffafea86288d84fbe57e069b5cbaf86823bafe243818506d80c7a33c504b6d1989ca0b2c60315dbb6e85f0b2ebd0e616c0b9010952fd2c3f32c7bce24bcb9866a1320780e80fbfed4d144f0b4ae310b84a077109ee71a6c7c0e7658f33c86745064ab64fd1d910d098f9055e2cbd591ced3e6e05750ea2898530f078c06c7e17a3e9aedf5e569b1ac8fe7ca623ed48eddffae209f361269af40e7b06ff8740661fefae75f4aa85d39de298f0c816be8bf0254004").unwrap(), + OutputFeatures::create_coinbase(360, Some(extra.as_bytes().to_vec())), + Commitment::from_hex("002354d7fb5a0e173a7351ebd2ea169998b891542c2995c36621ab30c7e89004").unwrap(), + BulletRangeProof::from_hex("01c24948f13b2dd0ebfb0a3e0697d882d05eef5744f7da5703d6525ffb9e34f556803ea04a2cbe040161ac805a0c3f598f3ad5744e313a175ac6fa2b52a80464499aa29a326ffbee4e3ce54d2f16528be30be1179ae6b8711e2602201d3193bc33ca5fd6812b94c16c50137c42935d856300313facdcc77493783522a7d945546a98f6a76a47c1546260e5b42d5a37be51f5d796568bc725e5aedc190bcbedc8506ed3a1b5e79490d62d10cf79e1440682988acc22d26a81ee5c591831652f967a4026f82b935ffed77e7f53636a9c91df6ccf292e97930da2e149d8c38e5c39301cff35fe5f81a1ee8ccd2f1897726a5530f47b8fc09f7ea63452d546a9fa1130d002041a6a8ac64f4239d8bcda752679df132b4c60a7ed14042ad5a8430eb4075e7d9eefcddb7155d1a8cd077ec567f49679567cdacdda7d6ccd63ca7c3f69232095ad1ff86338cf02a388a5614f563fac0d1cf5916663b2e5a1e1cf5d7bdb70a60231e9582ac23432bfc527daaba93806973fe0cf6261556fa75bc25e2bd653b4cf47727b54b163716be622b8e9e59e931425b154f98360c9d152c50856e34c0a1146ca2ba7f79720e4303b6e4f4f0b87f268b8c9ef36f0c8499fbd58f79129de3b5bb0c3e40fb5e21e1f01c03b3b2c01c973a142fe3385c7bc07c846c2a8002f50e43d544635ce42f031d046a0030b3209d42e4975988a54625eac0ecf6e009064acaeeba32ba641fa8b026891f518e7c5c2c9971e988064033841bbffb200fc6aecb9c24fb6f0ea6f382fa30fb01e55ca552ec38150218e0336ed6ce65407").unwrap(), // A default script can never be spent, intentionally script!(Nop), // The Sender offset public key is not checked for coinbase outputs - PublicKey::from_hex("f4b9a7b76491b096be5e0b40d995151b18dcde09e34eecc9a91385d9b16a3634").unwrap(), + PublicKey::from_hex("bc94d6502fa7c1dde829ca5a8d2672784454dc6c42e4f62f5ce83eccbe63b038").unwrap(), coinbase_meta_sig, // Covenant Covenant::default(), @@ -114,7 +115,7 @@ fn get_stagenet_genesis_block_raw() -> Block { KernelFeatures::COINBASE_KERNEL, MicroTari(0), 0, - Commitment::from_hex("a23aa2ebc878f201f1958fabd1467bac60526b18231b8a2e1a52587678be0f31").unwrap(), + Commitment::from_hex("02c0544ac33b2baba6da92a13a7b54b454edaacaa5b76eaf561aacf078142471").unwrap(), excess_sig, None, ); @@ -130,11 +131,11 @@ fn get_stagenet_genesis_block_raw() -> Block { height: 0, prev_hash: FixedHash::zero(), timestamp: timestamp.into(), - output_mr: FixedHash::from_hex("f52f31e506f3873eef04737aaaaa119e385338dda58b16affa414dc277c20577").unwrap(), - witness_mr: FixedHash::from_hex("75e7f57c00bd536ad157543d117034e8ce7f12a39ed43f65e304fb77d5a360b3") + output_mr: FixedHash::from_hex("a00d1c95378f383cb53f2fda0658b680d15b530ffb251b72d5fdf0af386ae775").unwrap(), + witness_mr: FixedHash::from_hex("945bad8a49c1c74501002ae227a9282a2148c793355c1c2517c07e5c15972d50") .unwrap(), output_mmr_size: 1, - kernel_mr: FixedHash::from_hex("cf5faaed9a852f62758f3d005fac7dacdc6234f2d0dfad3281d625aeca50e0a8").unwrap(), + kernel_mr: FixedHash::from_hex("ad201fe393372af2313f5c55f491c9d4e864a7a796401453ef52eaf2cd042132").unwrap(), kernel_mmr_size: 1, input_mr: FixedHash::zero(), total_kernel_offset: PrivateKey::from_hex( @@ -469,6 +470,14 @@ mod test { WitnessMmr, }; + #[test] + fn stagenet_genesis_sanity_check() { + // Note: Generate new data for `pub fn get_stagenet_genesis_block()` and `fn get_stagenet_genesis_block_raw()` + // if consensus values change, e.g. new faucet or other + let block = get_stagenet_genesis_block(); + check_block(Network::StageNet, &block, 1, 1); + } + #[test] fn esmeralda_genesis_sanity_check() { // Note: Generate new data for `pub fn get_esmeralda_genesis_block()` and `fn get_esmeralda_genesis_block_raw()` diff --git a/base_layer/core/src/consensus/consensus_constants.rs b/base_layer/core/src/consensus/consensus_constants.rs index 314d10df61..96b64467f9 100644 --- a/base_layer/core/src/consensus/consensus_constants.rs +++ b/base_layer/core/src/consensus/consensus_constants.rs @@ -615,38 +615,43 @@ impl ConsensusConstants { vec![consensus_constants_1] } + /// * + /// Stagenet has the following characteristics: + /// * 2 min blocks on average (5 min SHA-3, 3 min MM) + /// * 21 billion tXTR with a 3-year half-life + /// * 800 T tail emission (± 1% inflation after initial 21 billion has been mined) + /// * Coinbase lock height - 12 hours = 360 blocks pub fn stagenet() -> Vec { // Note these values are all placeholders for final values - let difficulty_block_window = 90; let mut algos = HashMap::new(); algos.insert(PowAlgorithm::Sha3, PowAlgorithmConstants { max_target_time: 1800, - min_difficulty: 40_000.into(), + min_difficulty: 60_000_000.into(), max_difficulty: u64::MAX.into(), target_time: 300, }); algos.insert(PowAlgorithm::Monero, PowAlgorithmConstants { - max_target_time: 800, - min_difficulty: 70_000_000.into(), + max_target_time: 1200, + min_difficulty: 60_000.into(), max_difficulty: u64::MAX.into(), target_time: 200, }); let (input_version_range, output_version_range, kernel_version_range) = version_zero(); vec![ConsensusConstants { effective_from_height: 0, - coinbase_lock_height: 1, - blockchain_version: 1, - valid_blockchain_version_range: 0..=1, + coinbase_lock_height: 360, + blockchain_version: 0, + valid_blockchain_version_range: 0..=0, future_time_limit: 540, - difficulty_block_window, - max_block_transaction_weight: 19500, + difficulty_block_window: 90, + max_block_transaction_weight: 127_795, median_timestamp_count: 11, - emission_initial: 10_000_000.into(), + emission_initial: 18_462_816_327 * uT, emission_decay: &EMISSION_DECAY, - emission_tail: 100.into(), - max_randomx_seed_height: u64::MAX, + emission_tail: 800 * T, + max_randomx_seed_height: 3000, proof_of_work: algos, - faucet_value: MicroTari::from(0), + faucet_value: 0.into(), transaction_weight: TransactionWeight::v1(), max_script_byte_size: 2048, input_version_range, @@ -714,7 +719,7 @@ impl ConsensusConstants { } } -static EMISSION_DECAY: [u64; 5] = [22, 23, 24, 26, 27]; +static EMISSION_DECAY: [u64; 6] = [21u64, 22, 23, 25, 26, 37]; const DIBBLER_DECAY_PARAMS: [u64; 6] = [21u64, 22, 23, 25, 26, 37]; // less significant values don't matter const ESMERALDA_DECAY_PARAMS: [u64; 6] = [21u64, 22, 23, 25, 26, 37]; // less significant values don't matter diff --git a/base_layer/core/tests/helpers/block_builders.rs b/base_layer/core/tests/helpers/block_builders.rs index b20a43cffd..cd0e3b4c96 100644 --- a/base_layer/core/tests/helpers/block_builders.rs +++ b/base_layer/core/tests/helpers/block_builders.rs @@ -119,6 +119,17 @@ fn genesis_template( (block, output) } +// #[ignore = "used to generate a new stagenet genesis block"] +/// This is a helper function to generate and print out a block that can be used as the genesis block. +/// 1. Run `cargo test --package tari_core --test mempool -- helpers::block_builders::print_new_genesis_block_stagenet +/// --exact --nocapture` +/// 1. The block and range proof will be printed +/// 1. Profit! +#[test] +fn print_new_genesis_block_stagenet() { + print_new_genesis_block(Network::StageNet, "Tokenized and connected"); +} + // #[ignore = "used to generate a new esmeralda genesis block"] /// This is a helper function to generate and print out a block that can be used as the genesis block. /// 1. Run `cargo test --package tari_core --test mempool -- helpers::block_builders::print_new_genesis_block_esmeralda diff --git a/base_layer/wallet_ffi/src/lib.rs b/base_layer/wallet_ffi/src/lib.rs index ca6cbd10ce..53b7dc8f36 100644 --- a/base_layer/wallet_ffi/src/lib.rs +++ b/base_layer/wallet_ffi/src/lib.rs @@ -4650,7 +4650,7 @@ pub unsafe extern "C" fn transport_config_destroy(transport: *mut TariTransportC /// `database_path` - The database path char array pointer which. This is the folder path where the /// database files will be created and the application has write access to /// `discovery_timeout_in_secs`: specify how long the Discovery Timeout for the wallet is. -/// `network`: name of network to connect to. Valid values are: esmeralda, dibbler, igor, localnet, mainnet +/// `network`: name of network to connect to. Valid values are: esmeralda, dibbler, igor, localnet, mainnet, stagenet /// `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions /// as an out parameter. /// diff --git a/base_layer/wallet_ffi/wallet.h b/base_layer/wallet_ffi/wallet.h index cbae1a0de6..3a0cf244b6 100644 --- a/base_layer/wallet_ffi/wallet.h +++ b/base_layer/wallet_ffi/wallet.h @@ -2478,7 +2478,7 @@ void transport_config_destroy(TariTransportConfig *transport); * `database_path` - The database path char array pointer which. This is the folder path where the * database files will be created and the application has write access to * `discovery_timeout_in_secs`: specify how long the Discovery Timeout for the wallet is. - * `network`: name of network to connect to. Valid values are: esmeralda, dibbler, igor, localnet, mainnet + * `network`: name of network to connect to. Valid values are: esmeralda, dibbler, igor, localnet, mainnet, stagenet * `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions * as an out parameter. * diff --git a/common/config/presets/a_common.toml b/common/config/presets/a_common.toml index cc421be6cb..cbc1716d92 100644 --- a/common/config/presets/a_common.toml +++ b/common/config/presets/a_common.toml @@ -6,12 +6,12 @@ ######################################################################################################################## [common] -#override_from="esmeralda" +#override_from="stagenet" #base_path="/.tari" -[esmeralda.auto_update] +[stagenet.auto_update] # Customize the hosts that are used to check for updates. These hosts must contain update information in DNS TXT records. -update_uris = ["updates.esmeralda.taripulse.com"] +update_uris = ["updates.stagenet.taripulse.com"] [auto_update] # Name server for auto update (default = "1.1.1.1:53/cloudflare.net") diff --git a/common/config/presets/b_peer_seeds.toml b/common/config/presets/b_peer_seeds.toml index 826574beb7..bd9c5cfbc4 100644 --- a/common/config/presets/b_peer_seeds.toml +++ b/common/config/presets/b_peer_seeds.toml @@ -15,6 +15,13 @@ # All DNS seed records must pass DNSSEC validation #dns_seeds_use_dnssec = false +[stagenet.p2p.seeds] +# DNS seeds hosts - DNS TXT records are queried from these hosts and the resulting peers added to the comms peer list. +dns_seeds = ["seeds.stagenet.tari.com"] +# Custom specified peer seed nodes +peer_seeds = [ +] + [esmeralda.p2p.seeds] # DNS seeds hosts - DNS TXT records are queried from these hosts and the resulting peers added to the comms peer list. dns_seeds = ["seeds.esmeralda.tari.com"] diff --git a/common/config/presets/c_base_node.toml b/common/config/presets/c_base_node.toml index 092be9a138..02607a8c9f 100644 --- a/common/config/presets/c_base_node.toml +++ b/common/config/presets/c_base_node.toml @@ -24,12 +24,15 @@ identity_file = "config/base_node_id_igor.json" # A path to the file that stores your node identity and secret key (default = "config/base_node_id.json") identity_file = "config/base_node_id_esmeralda.json" +[stagenet.base_node] +# A path to the file that stores your node identity and secret key (default = "config/base_node_id.json") +identity_file = "config/base_node_id_stagenet.json" # The socket to expose for the gRPC base node server (default = "/ip4/127.0.0.1/tcp/18142") #grpc_address = "/ip4/127.0.0.1/tcp/18142" [base_node] # Selected network (Note: Not implemented properly, please specify on the command line) (default = "emseralda") -#network = "emseralda" +#network = "stagenet" # Set to false to disable the base node GRPC server (default = true) #grpc_enabled = true From c19b1f67e930d0c0d348af86eaee864564abd73a Mon Sep 17 00:00:00 2001 From: brianp Date: Mon, 13 Feb 2023 15:58:09 -0400 Subject: [PATCH 3/3] Add stagenet seednodes to config --- common/config/presets/b_peer_seeds.toml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/config/presets/b_peer_seeds.toml b/common/config/presets/b_peer_seeds.toml index bd9c5cfbc4..fd829bc57f 100644 --- a/common/config/presets/b_peer_seeds.toml +++ b/common/config/presets/b_peer_seeds.toml @@ -20,6 +20,26 @@ dns_seeds = ["seeds.stagenet.tari.com"] # Custom specified peer seed nodes peer_seeds = [ + # 1337e9449e63134fd5e0ba3207 + "a062ae2345b0db0df9fb1504b99511e23d98f8513f9b5503efcc6dad8eca7e47::/onion3/rhoqxfbzz3uidp23erxu4mkwwexc2gg4q45rcxfpbhb35ycdv4ex2fid:18141", + # 1a1a1a4b79a81467a2c815a371 + "b2c5db3a2858451d241d4e88677536f9e82a760111962785fb6a3cddc41f766e::/onion3/q32yxdg7l7os2zzx64e3f5u4mzib3lxlkdyguybkhtkd4pwfkpunjcyd:18141", + # 2b2b2b56e8e1479f1685d5f4ce + "1cdf34d27bee5e1edbc343a17f7d79a8a1974fe3f790e899d8987c1f11697e41::/onion3/fwvmhhcifr7yh7neqsweyjvu4bnlmljg6a6fsjdwify3b4aals2oc3yd:18141", + # 3c3c3c8c3aa72ea4c2a943564a + "a42eea2088e0ef663b8d29a9d039b0e5d51c1ddc1cf5ae28feb05ed52ead5a69::/onion3/k5khqg7fwkq7ujxievps22r42i5ykuieai64ze3kj5snsjkew3v7piid:18141", + # 4d4d4df1add5ac00a8c276f11e + "d49df057e1f1ae399ffabdeb59e7ad542439ab2b0bbd9ed23042175a93e4d03c::/onion3/hjeczose7rjo6o6qhsszkuzhrm6qfs7s4yeqzeuz2m67rkpijrtrwsad:18141", + # 5e5e5eace5fc25c4ce83fbaab6 + "e65f18cb4a362b33667e0d39b3c93f06c0e822af09906914bdc65907b7cdc130::/onion3/uuv6j3vwq4dac6z3dblc2mjcoecrnxfka3wg43bcass5avbzix4nmzyd:18141", + # 6f6f6f01facc230ad923de9159 + "0a755298f4bee8e6db64e345fe8f937e3882693a48c71b942b88744761b02067::/onion3/ksdogedobmqoud6ampvrjrhoozftgfkolhxqvnt7mo7ajqczku5tyyqd:18141", + # 777777aec8a3e4add50054d457 + "0c22d3dc3983c74131d7dfb0c4c8ae9fb90c434826cf8ccc71e793bb72d36213::/onion3/so2be7uyg4kf5l7ys3fbk4eqovsfi63yuaqj7pahkkw2crujq43jdnyd:18141", + # 8888883587be3e94600c246c3b + "2ade610a2e95f1c686873944096f5a1f2c7ffcf47d67112b472c9208cc6e9532::/onion3/rmiknlrf7ngfvgpayf5qzuer2c547rzmyqbkbw45w5uessi3jodasdqd:18141", + # 99999903f5951fa1ca9505c3c2 + "369ae9a89c3fc2804d6ec07e20bf10e5d0e72f565a71821fc7c611ae5bee0116::/onion3/crvsrmoyrk5uatvnafsmoykiqgywdqowupn3auq25iz7zxyf7xusjxid:18141", ] [esmeralda.p2p.seeds]