Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: prepare MM backend stuff #6448

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2351,7 +2351,7 @@ fn create_pre_mine_output_dir() -> Result<(String, PathBuf), CommandError> {
fn get_embedded_pre_mine_outputs(output_indexes: Vec<usize>) -> Result<Vec<TransactionOutput>, CommandError> {
let pre_mine_contents = match Network::get_current_or_user_setting_or_default() {
Network::MainNet => {
unimplemented!("MainNet pre-mine not yet implemented");
include_str!("../../../../base_layer/core/src/blocks/pre_mine/mainnet_pre_mine.json")
},
Network::StageNet => {
include_str!("../../../../base_layer/core/src/blocks/pre_mine/stagenet_pre_mine.json")
Expand Down
18 changes: 12 additions & 6 deletions applications/minotari_miner/src/run_miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,24 @@ pub async fn start_miner(cli: Cli) -> Result<(), ExitError> {
if !config.mining_worker_name.is_empty() {
miner_address += &format!("{}{}", ".", config.mining_worker_name);
}
let mut mc = Controller::new(config.num_mining_threads).unwrap_or_else(|e| {
let mut mc = Controller::new(config.num_mining_threads).map_err(|e| {
debug!(target: LOG_TARGET_FILE, "Error loading mining controller: {}", e);
panic!("Error loading mining controller: {}", e);
});
ExitError::new(
ExitCode::UnknownError,
format!("Error loading mining controller: {}", e),
)
})?;
let cc = crate::stratum::controller::Controller::new(&url, Some(miner_address), None, None, mc.tx.clone())
.unwrap_or_else(|e| {
.map_err(|e| {
debug!(
target: LOG_TARGET_FILE,
"Error loading stratum client controller: {:?}", e
);
panic!("Error loading stratum client controller: {:?}", e);
});
ExitError::new(
ExitCode::UnknownError,
format!("Error loading mining controller: {}", e),
)
})?;
mc.set_client_tx(cc.tx.clone());

let _join_handle = thread::Builder::new()
Expand Down
45 changes: 44 additions & 1 deletion base_layer/core/src/blocks/genesis_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,50 @@ fn get_nextnet_genesis_block_raw() -> Block {
}

pub fn get_mainnet_genesis_block() -> ChainBlock {
unimplemented!()
let mut block = get_mainnet_genesis_block_raw();

// Add pre-mine utxos - enable/disable as required
let add_pre_mine_utxos = false;
if add_pre_mine_utxos {
// NB: `stagenet_genesis_sanity_check` must pass
let file_contents = include_str!("pre_mine/mainnet_pre_mine.json");
add_pre_mine_utxos_to_genesis_block(file_contents, &mut block);
// Enable print only if you need to generate new Merkle roots, then disable it again
let print_values = false;
print_mr_values(&mut block, print_values);

// Hardcode the Merkle roots once they've been computed above
block.header.kernel_mr =
FixedHash::from_hex("a08ff15219beea81d4131465290443fb3bd99d28b8af85975dbb2c77cb4cb5a0").unwrap();
block.header.output_mr =
FixedHash::from_hex("435f13e21be06b0d0ae9ad3869ac7c723edd933983fa2e26df843c82594b3245").unwrap();
block.header.validator_node_mr =
FixedHash::from_hex("277da65c40b2cf99db86baedb903a3f0a38540f3a94d40c826eecac7e27d5dfc").unwrap();
}

let accumulated_data = BlockHeaderAccumulatedData {
hash: block.hash(),
total_kernel_offset: block.header.total_kernel_offset.clone(),
achieved_difficulty: Difficulty::min(),
total_accumulated_difficulty: 1.into(),
accumulated_randomx_difficulty: AccumulatedDifficulty::min(),
accumulated_sha3x_difficulty: AccumulatedDifficulty::min(),
target_difficulty: Difficulty::min(),
};
ChainBlock::try_construct(Arc::new(block), accumulated_data).unwrap()
}

fn get_mainnet_genesis_block_raw() -> Block {
// Set genesis timestamp
let genesis_timestamp = DateTime::parse_from_rfc2822("05 Aug 2024 08:00:00 +0200").expect("parse may not fail");
let not_before_proof = b"I am the standin mainnet genesis block, \
\
I am not the real mainnet block \
\
I am only a standin \
\
Do not take me for the real one. I am only a placeholder for the real one";
get_raw_block(&genesis_timestamp, &not_before_proof.to_vec())
}

pub fn get_igor_genesis_block() -> ChainBlock {
Expand Down
Loading
Loading