Skip to content

Commit

Permalink
feat!: new esmeralda network (#4391)
Browse files Browse the repository at this point in the history
Description
---
New Esmeralda network.
new genisis block for esmarelda.
new genesis block for igor.
Remove all version of header, transactions, and weights

Motivation and Context
---
This is the first step in getting ready for a new testnet reset. This allows us to start testing esmeralda. 


How Has This Been Tested?
---
All unit tests pass

fixes: #4355
  • Loading branch information
SWvheerden authored Aug 5, 2022
1 parent d25d726 commit 622763a
Show file tree
Hide file tree
Showing 38 changed files with 4,368 additions and 271 deletions.
2 changes: 1 addition & 1 deletion applications/daily_tests/automatic_recovery_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function run(options = {}) {
true,
{
transport: "tor",
network: "dibbler",
network: "esmeralda",
grpc_console_wallet_address: "/ip4/127.0.0.1/tcp/18111",
baseDir: options.baseDir || "./temp/base-nodes/",
},
Expand Down
2 changes: 1 addition & 1 deletion applications/daily_tests/automatic_sync_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const path = require("path");
const helpers = require("./helpers");
const BaseNodeProcess = require("integration_tests/helpers/baseNodeProcess");

const NETWORK = "dibbler";
const NETWORK = "esmeralda";

const SyncType = {
Archival: "Archival",
Expand Down
2 changes: 1 addition & 1 deletion applications/daily_tests/washing_machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ function* transactionGenerator(options) {
function createGrpcWallet(baseNode, opts = {}, excludeTestEnvars = true) {
let process = new WalletProcess("sender", excludeTestEnvars, {
transport: "tor",
network: "dibbler",
network: "esmeralda",
num_confirmations: 0,
...opts,
});
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_app_utilities/src/common_cli_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct CommonCliArgs {
#[clap()]
pub log_level: Option<Level>,

/// Overrides for properties in the config file, e.g. -p base_node.netwok=dibbler
/// Overrides for properties in the config file, e.g. -p base_node.netwok=esmeralda
#[clap(short = 'p', parse(try_from_str = parse_key_val), multiple_occurrences(true))]
pub config_property_overrides: Vec<(String, String)>,
}
Expand Down
6 changes: 3 additions & 3 deletions applications/tari_base_node/src/grpc/hash_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mod test {

// Checks that the moving average hash rate at every block is correct
// We use larger sample data than the SHA window size (12 periods) to check bounds
// We assumed a constant target block time of 300 secs (the SHA3 target time for Dibbler)
// We assumed a constant target block time of 300 secs (the SHA3 target time for Esmeralda)
// These expected hash rate values where calculated in a spreadsheet
#[test]
fn correct_moving_average_calculation() {
Expand Down Expand Up @@ -180,8 +180,8 @@ mod test {
}

fn create_hash_rate_ma(pow_algo: PowAlgorithm) -> HashRateMovingAverage {
let consensus_manager = ConsensusManagerBuilder::new(Network::Dibbler)
.add_consensus_constants(ConsensusConstants::dibbler()[0].clone())
let consensus_manager = ConsensusManagerBuilder::new(Network::Esmeralda)
.add_consensus_constants(ConsensusConstants::esmeralda()[0].clone())
.build();
HashRateMovingAverage::new(pow_algo, consensus_manager)
}
Expand Down
26 changes: 13 additions & 13 deletions applications/tari_collectibles/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
########################################################################################################################

[common]
#override_from="dibbler"
#override_from="esmeralda"
#base_path="<HOME>/.tari"
#data_dir="data"

[auto_update]
override_from="dibbler"
override_from="esmeralda"
# This interval in seconds to check for software updates. Setting this to 0 disables checking.
check_interval = 300

[dibbler.auto_update]
[esmeralda.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.dibbler.taripulse.com"]
update_uris = ["updates.esmeralda.taripulse.com"]
# Customize the location of the update SHA hashes and maintainer-signed signature.
# "auto_update.hashes_url" = "https://<address>/hashes.txt"
# "auto_update.hashes_sig_url" = "https://<address>/hashes.txt.sig"
Expand Down Expand Up @@ -67,18 +67,18 @@ db_resize_threshold_mb = 100
# Set to true to record all reorgs. Recorded reorgs can be viewed using the list-reorgs command.
track_reorgs = true

# Configuration options for testnet dibbler
[dibbler.base_node]
# Configuration options for testnet esmeralda
[esmeralda.base_node]


# db config defaults

# The amount of messages that will be permitted in the flood ban timespan of 100s (Default dibbler = 100000,
# The amount of messages that will be permitted in the flood ban timespan of 100s (Default esmeralda = 100000,
# default mainnet = 100000)
flood_ban_max_msg_count = 100_000

# The relative path to store persistent data
data_dir = "dibbler"
data_dir = "esmeralda"

# This allowlist provides a method to force syncing from any known nodes you may choose, for example if you have a
# couple of nodes that you always want to have in sync.
Expand Down Expand Up @@ -318,7 +318,7 @@ base_node_tor_identity_file = "config/base_node_tor.json"

[wallet]
# Override common.network for wallet
# network = "dibbler"
# network = "esmeralda"

# The relative folder to store your local key data and transaction history. DO NOT EVER DELETE THIS FILE unless you
# a) have backed up your seed phrase and
Expand Down Expand Up @@ -415,8 +415,8 @@ base_node_service_request_max_age = 180
# Required for control_auth_type = "password"
#control_auth_password = "super-secure-password"

# Wallet configuration options for dibbler
[wallet.dibbler]
# Wallet configuration options for esmeralda
[wallet.esmeralda]
# -------------- Transport configuration --------------
# Use TCP to connect to the Tari network. This transport can only communicate with TCP/IP addresses, so peers with
# e.g. tor onion addresses will not be contactable.
Expand Down Expand Up @@ -567,7 +567,7 @@ tor_control_address = "/ip4/127.0.0.1/tcp/9051"
########################################################################################################################

[merge_mining_proxy]
#override_from = "dibbler"
#override_from = "esmeralda"
monerod_url = [ # stagenet
"http://stagenet.xmr-tw.org:38081",
"http://stagenet.community.xmr.to:38081",
Expand Down Expand Up @@ -597,7 +597,7 @@ monerod_username = ""
monerod_password = ""
monerod_use_auth = false

#[merge_mining_proxy.dibbler]
#[merge_mining_proxy.esmeralda]
# Put any network specific settings here


Expand Down
2 changes: 1 addition & 1 deletion applications/tari_collectibles/src-tauri/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use tari_app_utilities::common_cli_args::CommonCliArgs;
use tari_common::exit_codes::{ExitCode, ExitError};
use uuid::Uuid;

const DEFAULT_NETWORK: &str = "dibbler";
const DEFAULT_NETWORK: &str = "esmeralda";

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_console_wallet/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use tari_utilities::{
SafePassword,
};

const DEFAULT_NETWORK: &str = "dibbler";
const DEFAULT_NETWORK: &str = "esmeralda";

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_merge_mining_proxy/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use clap::Parser;
use tari_app_utilities::common_cli_args::CommonCliArgs;

const DEFAULT_NETWORK: &str = "dibbler";
const DEFAULT_NETWORK: &str = "esmeralda";

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_merge_mining_proxy/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ mod test {
[config_b.merge_mining_proxy]
submit_to_origin = false
monerod_url = [ "http://network.b.org" ]
monerod_password = "password_dibbler"
monerod_password = "password_esmeralda"
base_node_grpc_address = "/dns4/base_node_b/tcp/8080"
"#;

Expand All @@ -124,7 +124,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_dibbler");
assert_eq!(config.monerod_password.as_str(), "password_esmeralda");
assert_eq!(
config.base_node_grpc_address.to_string().as_str(),
"/dns4/base_node_b/tcp/8080"
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_validator_node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use clap::Parser;
use tari_app_utilities::common_cli_args::CommonCliArgs;

const DEFAULT_NETWORK: &str = "dibbler";
const DEFAULT_NETWORK: &str = "esmeralda";

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
Expand Down
6 changes: 3 additions & 3 deletions base_layer/core/src/blocks/accumulated_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,19 +507,19 @@ mod test {

mod chain_block {
use super::*;
use crate::blocks::genesis_block::get_dibbler_genesis_block;
use crate::blocks::genesis_block::get_esmeralda_genesis_block;

#[test]
fn it_converts_to_a_chain_header() {
let genesis = get_dibbler_genesis_block();
let genesis = get_esmeralda_genesis_block();
let header = genesis.to_chain_header();
assert_eq!(header.header(), genesis.header());
assert_eq!(header.accumulated_data(), genesis.accumulated_data());
}

#[test]
fn it_provides_guarantees_about_data_integrity() {
let mut genesis = get_dibbler_genesis_block();
let mut genesis = get_esmeralda_genesis_block();
// Mess with the header, only possible using the non-public fields
genesis.block = Arc::new({
let mut b = (*genesis.block).clone();
Expand Down
46 changes: 8 additions & 38 deletions base_layer/core/src/blocks/block_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use std::{
};

use chrono::{DateTime, NaiveDateTime, Utc};
use digest::Digest;
use serde::{
de::{self, Visitor},
Deserialize,
Expand All @@ -59,7 +58,6 @@ use tari_common_types::{
array::{copy_into_fixed_array, copy_into_fixed_array_lossy},
types::{BlindingFactor, BlockHash, BLOCK_HASH_LENGTH},
};
use tari_crypto::hash::blake2::Blake256;
use tari_utilities::{epoch_time::EpochTime, hex::Hex, ByteArray, Hashable};
use thiserror::Error;

Expand Down Expand Up @@ -218,25 +216,7 @@ impl BlockHeader {
/// Provides a hash of the header, used for the merge mining.
/// This differs from the normal hash by not hashing the nonce and kernel pow.
pub fn merged_mining_hash(&self) -> Vec<u8> {
if self.version <= 2 {
// TODO: Remove deprecated header hashing #testnetreset
Blake256::new()
.chain(self.version.to_le_bytes())
.chain(self.height.to_le_bytes())
.chain(self.prev_hash.as_bytes())
.chain(self.timestamp.as_u64().to_le_bytes())
.chain(self.input_mr.as_bytes())
.chain(self.output_mr.as_bytes())
.chain(self.output_mmr_size.to_le_bytes())
.chain(self.witness_mr.as_bytes())
.chain(self.kernel_mr.as_bytes())
.chain(self.kernel_mmr_size.to_le_bytes())
.chain(self.total_kernel_offset.as_bytes())
.chain(self.total_script_offset.as_bytes())
.finalize()
.to_vec()
} else {
ConsensusHasher::default()
ConsensusHasher::default()
.chain(&self.version)
.chain(&self.height)
.chain(&self.prev_hash)
Expand All @@ -251,7 +231,6 @@ impl BlockHeader {
.chain(&self.total_kernel_offset)
.chain(&self.total_script_offset)
.finalize().to_vec()
}
}

#[inline]
Expand Down Expand Up @@ -295,22 +274,13 @@ impl From<NewBlockHeaderTemplate> for BlockHeader {

impl Hashable for BlockHeader {
fn hash(&self) -> Vec<u8> {
if self.version <= 2 {
Blake256::new()
.chain(self.merged_mining_hash())
.chain(self.pow.to_bytes())
.chain(self.nonce.to_le_bytes())
.finalize()
.to_vec()
} else {
ConsensusHasher::default()
// TODO: this excludes extraneous length varint used for Vec<u8> since a hash is always 32-bytes. Clean this
// up if we decide to migrate to a fixed 32-byte type
.chain(&copy_into_fixed_array::<_, 32>(&self.merged_mining_hash()).unwrap())
.chain(&self.pow)
.chain(&self.nonce)
.finalize().to_vec()
}
ConsensusHasher::default()
// TODO: this excludes extraneous length varint used for Vec<u8> since a hash is always 32-bytes. Clean this
// up if we decide to migrate to a fixed 32-byte type
.chain(&copy_into_fixed_array::<_, 32>(&self.merged_mining_hash()).unwrap())
.chain(&self.pow)
.chain(&self.nonce)
.finalize().to_vec()
}
}

Expand Down
Loading

0 comments on commit 622763a

Please sign in to comment.