Skip to content

Commit

Permalink
feat: add Igor testnet (#3256)
Browse files Browse the repository at this point in the history
Description
---
This PR adds support for the Igor testnet to the repo. This involves adding Igor to the Network Enum, adding a Igor generic block and adding a config file with the details of 4 Igor seed nodes (still to be rolled out)

Motivation and Context
---
We need a second testnet to test network switching

How Has This Been Tested?
---
Manually ran the network to generate seed nodes details.
  • Loading branch information
philipr-za committed Aug 30, 2021
1 parent d1bb737 commit 0f6d3b1
Show file tree
Hide file tree
Showing 7 changed files with 706 additions and 2 deletions.
86 changes: 86 additions & 0 deletions base_layer/core/src/blocks/genesis_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,92 @@ pub fn get_ridcully_genesis_block_raw() -> Block {
}
}

pub fn get_igor_genesis_block() -> ChainBlock {
// lets get the block
let block = get_igor_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()
}

#[allow(deprecated)]
pub fn get_igor_genesis_block_raw() -> Block {
let sig = Signature::new(
PublicKey::from_hex("f2139d1cdbcfa670bbb60d4d03d9d50b0a522e674b11280e8064f6dc30e84133").unwrap(),
PrivateKey::from_hex("3ff7522d9a744ebf99c7b6664c0e2c8c64d2a7b902a98b78964766f9f7f2b107").unwrap(),
);
let mut body = AggregateBody::new(
vec![],
vec![TransactionOutput {
features: OutputFeatures {
flags: OutputFlags::COINBASE_OUTPUT,
maturity: 60,
},
commitment: Commitment::from_hex(
"fadafb12de96d90042dcbf839985aadb7ae88baa3446d5c6a17937ef2b36783e",
)
.unwrap(),
proof: BulletRangeProof::from_hex("845c947cbf23683f6ff6a56d0aa55fca14a618f7476d4e29348c5cbadf2bb062b8da701a0f058eb69c88492895c3f034db194f6d1b2d29ea83c1a68cbdd19a3f90ae080cfd0315bb20cd05a462c4e06e708b015da1d70c0f87e8c7413b579008e43a6c8dc1edb72b0b67612e897d251ec55798184ff35c80d18262e98034677b73f2dcc7ae25c9119900aadaf04a16068bf57b9e8b9bb694331750dc8acc6102b8961be183419dce2f96c48ced9892e4cdb091dcda0d6a0bb4ed94fc0c63ca065f25ce1e560504d49970bcaac007f33368f15ffa0dd3f56bf799b66fa684fe0fbeb882aee4a6fe05a3ca7c488a6ba22779a42f0f5d875175b8ebc517dd49df20b4f04f027b7d22b7c62cb93727f35c18a0b776d95fac4ff5405d6ed3dbb7613152178cecea4b712aa6e6701804ded71d94cf67de2e86ae401499b39de81b7344185c9eb3bd570ac6121143a690f118d9413abb894729b6b3e057f4771b2c2204285151a56695257992f2b0331f27066270718b37ab472c339d2560c1f6559f3c4ce31ec7f7e2acdbebb1715951d8177283a1ccc2f393ce292956de5db4afde419c0264d5cc4758e6e2c07b730ad43819f3761658d63794cc8071b30f9d7cd622bece4f086b0ca6a04fee888856084543a99848f06334acf48cace58e5ef8c85412017c400b4ec92481ba6d745915aef40531db73d1d84d07d7fce25737629e0fc4ee71e7d505bfd382e362cd1ac03a67c93b8f20cb4285ce240cf1e000d48332ba32e713d6cdf6266449a0a156241f7b1b36753f46f1ecb8b1836625508c5f31bc7ebc1d7cd634272be02cc109bf86983a0591bf00bacea1287233fc12324846398be07d44e8e14bd78cd548415f6de60b5a0c43a84ac29f6a8ac0b1b748dd07a8a4124625e1055b5f5b19da79c319b6e465ca5df0eb70cb4e3dc399891ce90b").unwrap(),
// For genesis block: A default script can never be spent, intentionally
script: TariScript::default(),
// Script offset never checked for coinbase, thus can use default
sender_offset_public_key: Default::default(),
// For genesis block: Metadata signature will never be checked
metadata_signature: Default::default(),
}],
vec![TransactionKernel {
features: KernelFeatures::COINBASE_KERNEL,
fee: MicroTari(0),
lock_height: 0,
excess: Commitment::from_hex(
"f472cc347a1006b7390f9c93b3c62fba334fd99f6c9c1daf9302646cd4781f61",
)
.unwrap(),
excess_sig: sig,
}],
);
body.sort();
// set genesis timestamp
let genesis = DateTime::parse_from_rfc2822("27 Aug 2021 06:00:00 +0200").unwrap();
let timestamp = genesis.timestamp() as u64;
Block {
header: BlockHeader {
version: 0,
height: 0,
prev_hash: vec![0; BLOCK_HASH_LENGTH],
timestamp: timestamp.into(),
output_mr: from_hex("dcc44f39b65e5e1e526887e7d56f7b85e2ea44bd29bc5bc195e6e015d19e1c06").unwrap(),
witness_mr: from_hex("e4d7dab49a66358379a901b9a36c10f070aa9d7bdc8ae752947b6fc4e55d255f").unwrap(),
output_mmr_size: 1,
kernel_mr: from_hex("589bc62ac5d9139f921c68b8075c32d8d130024acaf3196d1d6a89df601e2bcf").unwrap(),
kernel_mmr_size: 1,
input_mr: vec![0; BLOCK_HASH_LENGTH],
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![],
},
},
body,
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down
32 changes: 32 additions & 0 deletions base_layer/core/src/consensus/consensus_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,38 @@ impl ConsensusConstants {
}]
}

pub fn igor() -> Vec<Self> {
let mut algos = HashMap::new();
// seting sha3/monero to 40/60 split
algos.insert(PowAlgorithm::Sha3, PowAlgorithmConstants {
max_target_time: 1800,
min_difficulty: 60_000_000.into(),
max_difficulty: u64::MAX.into(),
target_time: 300,
});
algos.insert(PowAlgorithm::Monero, PowAlgorithmConstants {
max_target_time: 1200,
min_difficulty: 60_000.into(),
max_difficulty: u64::MAX.into(),
target_time: 200,
});
vec![ConsensusConstants {
effective_from_height: 0,
coinbase_lock_height: 6,
blockchain_version: 1,
future_time_limit: 540,
difficulty_block_window: 90,
max_block_transaction_weight: 19500,
median_timestamp_count: 11,
emission_initial: 5_538_846_115 * uT,
emission_decay: &EMISSION_DECAY,
emission_tail: 100.into(),
max_randomx_seed_height: std::u64::MAX,
proof_of_work: algos,
faucet_value: (5000 * 4000) * T,
}]
}

pub fn mainnet() -> Vec<Self> {
// Note these values are all placeholders for final values
let difficulty_block_window = 90;
Expand Down
2 changes: 2 additions & 0 deletions base_layer/core/src/consensus/consensus_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use crate::{
blocks::{
genesis_block::{
get_igor_genesis_block,
get_mainnet_genesis_block,
get_ridcully_genesis_block,
get_stibbons_genesis_block,
Expand Down Expand Up @@ -82,6 +83,7 @@ impl ConsensusManager {
.gen_block
.clone()
.unwrap_or_else(get_weatherwax_genesis_block),
Network::Igor => get_igor_genesis_block(),
}
}

Expand Down
1 change: 1 addition & 0 deletions base_layer/core/src/consensus/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl NetworkConsensus {
Stibbons => ConsensusConstants::stibbons(),
Weatherwax => ConsensusConstants::weatherwax(),
LocalNet => ConsensusConstants::localnet(),
Igor => ConsensusConstants::igor(),
}
}

Expand Down
Loading

0 comments on commit 0f6d3b1

Please sign in to comment.