Skip to content

Commit

Permalink
feat!: update faucet for genesis block (tari-project#5633)
Browse files Browse the repository at this point in the history
Description
---
- Updated faucet for esmeralda, nextnet and stagenet genesis blocks
- Updated genesis timestamp for esmeralda, nextnet and stagenet genesis
blocks
- Updated toolchain (nightly-2023-06-03 was incompatible with Windows)
- Fixed formatting issue for auto generated FFI header files

Motivation and Context
---
Testnet reset

How Has This Been Tested?
---
Updated unit tests 

What process can a PR reviewer use to test or verify this change?
---
Code review changes
Verify CI passes

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [ ] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [X] Other - Requires network reset

<!-- Does this include a breaking change? If so, include this line as a
footer -->
BREAKING CHANGE: Delete blockchain and wallets, re-sync nodes from
scratch.
  • Loading branch information
hansieodendaal committed Aug 11, 2023
1 parent 29700c3 commit ffb987a
Show file tree
Hide file tree
Showing 19 changed files with 509 additions and 5,008 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/base_node_binaries.json
Expand Up @@ -2,7 +2,7 @@
{
"name": "linux-x86_64",
"runs-on": "ubuntu-20.04",
"rust": "nightly-2022-11-03",
"rust": "nightly-2023-06-04",
"target": "x86_64-unknown-linux-gnu",
"cross": false,
"target_cpu": "x86-64",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/base_node_binaries.yml
Expand Up @@ -19,7 +19,7 @@ name: Build Matrix of Binaries
env:
TBN_FILENAME: "tari_suite"
TBN_BUNDLEID_BASE: "com.tarilabs.pkg"
toolchain: nightly-2023-06-03
toolchain: nightly-2023-06-04
matrix-json-file: ".github/workflows/base_node_binaries.json"
CARGO_HTTP_MULTIPLEXING: false
CARGO_UNSTABLE_SPARSE_REGISTRY: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_dockers.yml
Expand Up @@ -47,7 +47,7 @@ name: Build docker images
- xmrig

env:
toolchain_default: nightly-2023-06-03
toolchain_default: nightly-2023-06-04

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_dockers_workflow.yml
Expand Up @@ -14,7 +14,7 @@ name: Build docker images - workflow_call/on-demand
toolchain:
type: string
description: 'Rust toolchain'
default: nightly-2023-06-03
default: nightly-2023-06-04
arch:
type: string
default: x86-64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -11,7 +11,7 @@ name: CI
merge_group:

env:
toolchain: nightly-2023-06-03
toolchain: nightly-2023-06-04
CARGO_HTTP_MULTIPLEXING: false
CARGO_TERM_COLOR: always
CARGO_UNSTABLE_SPARSE_REGISTRY: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Expand Up @@ -11,7 +11,7 @@ name: Source Coverage
- ci-coverage-*

env:
toolchain: nightly-2023-06-03
toolchain: nightly-2023-06-04

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Expand Up @@ -27,7 +27,7 @@ name: Integration tests
type: string

env:
toolchain: nightly-2023-06-03
toolchain: nightly-2023-06-04

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
3 changes: 2 additions & 1 deletion base_layer/chat_ffi/build.rs
Expand Up @@ -3,7 +3,7 @@

use std::{env, path::PathBuf};

use cbindgen::{Config, ExportConfig, Language, ParseConfig, Style};
use cbindgen::{Config, ExportConfig, Language, LineEndingStyle, ParseConfig, Style};
use tari_common::build::StaticApplicationInfo;

fn main() {
Expand Down Expand Up @@ -38,6 +38,7 @@ fn main() {
include: vec!["TariUtxo".to_string()],
..Default::default()
},
line_endings: LineEndingStyle::Native,
..Default::default()
};

Expand Down
5,422 changes: 456 additions & 4,966 deletions base_layer/core/src/blocks/faucets/esmeralda_faucet.json

Large diffs are not rendered by default.

42 changes: 25 additions & 17 deletions base_layer/core/src/blocks/genesis_block.rs
Expand Up @@ -105,7 +105,7 @@ pub fn get_stagenet_genesis_block() -> ChainBlock {
let mut block = get_stagenet_genesis_block_raw();

// Add faucet utxos - enable/disable as required
let add_faucet_utxos = false;
let add_faucet_utxos = true;
if add_faucet_utxos {
// NB! Update 'consensus_constants.rs/pub fn igor()/ConsensusConstants {faucet_value: ?}' with total value
// NB: `stagenet_genesis_sanity_check` must pass
Expand All @@ -116,9 +116,13 @@ pub fn get_stagenet_genesis_block() -> ChainBlock {
print_mr_values(&mut block, print_values);

// Hardcode the Merkle roots once they've been computed above
block.header.kernel_mr = FixedHash::from_hex("TODO: Update when required").unwrap();
block.header.output_mr = FixedHash::from_hex("TODO: Update when required").unwrap();
block.header.validator_node_mr = FixedHash::from_hex("TODO: Update when required").unwrap();
// Hardcode the Merkle roots once they've been computed above
block.header.kernel_mr =
FixedHash::from_hex("9d09a1400740160c28b5ce4ef81c35e40b55cbd966e0eee4373f18bfc2d53823").unwrap();
block.header.output_mr =
FixedHash::from_hex("557b1d314988e5d32b29472179e6f857c067eb13d9e9099862d5aab67444df08").unwrap();
block.header.validator_node_mr =
FixedHash::from_hex("277da65c40b2cf99db86baedb903a3f0a38540f3a94d40c826eecac7e27d5dfc").unwrap();
}

let accumulated_data = BlockHeaderAccumulatedData {
Expand All @@ -135,7 +139,7 @@ pub fn get_stagenet_genesis_block() -> ChainBlock {

fn get_stagenet_genesis_block_raw() -> Block {
// Set genesis timestamp
let genesis_timestamp = DateTime::parse_from_rfc2822("15 Jun 2023 14:00:00 +0200").expect("parse may not fail");
let genesis_timestamp = DateTime::parse_from_rfc2822("11 Aug 2023 15:10:00 +0200").expect("parse may not fail");
let not_before_proof = b"i am the stagenet genesis block, watch out, here i come \
\
The New York Times , 2000/01/01 \
Expand All @@ -154,7 +158,7 @@ pub fn get_nextnet_genesis_block() -> ChainBlock {
let mut block = get_nextnet_genesis_block_raw();

// Add faucet utxos - enable/disable as required
let add_faucet_utxos = false;
let add_faucet_utxos = true;
if add_faucet_utxos {
// NB! Update 'consensus_constants.rs/pub fn igor()/ConsensusConstants {faucet_value: ?}' with total value
// NB: `nextnet_genesis_sanity_check` must pass
Expand All @@ -165,9 +169,13 @@ pub fn get_nextnet_genesis_block() -> ChainBlock {
print_mr_values(&mut block, print_values);

// Hardcode the Merkle roots once they've been computed above
block.header.kernel_mr = FixedHash::from_hex("TODO: Update when required").unwrap();
block.header.output_mr = FixedHash::from_hex("TODO: Update when required").unwrap();
block.header.validator_node_mr = FixedHash::from_hex("TODO: Update when required").unwrap();
// Hardcode the Merkle roots once they've been computed above
block.header.kernel_mr =
FixedHash::from_hex("9d09a1400740160c28b5ce4ef81c35e40b55cbd966e0eee4373f18bfc2d53823").unwrap();
block.header.output_mr =
FixedHash::from_hex("557b1d314988e5d32b29472179e6f857c067eb13d9e9099862d5aab67444df08").unwrap();
block.header.validator_node_mr =
FixedHash::from_hex("277da65c40b2cf99db86baedb903a3f0a38540f3a94d40c826eecac7e27d5dfc").unwrap();
}

let accumulated_data = BlockHeaderAccumulatedData {
Expand All @@ -184,7 +192,7 @@ pub fn get_nextnet_genesis_block() -> ChainBlock {

fn get_nextnet_genesis_block_raw() -> Block {
// Set genesis timestamp
let genesis_timestamp = DateTime::parse_from_rfc2822("15 Jun 2023 14:00:00 +0200").expect("parse may not fail");
let genesis_timestamp = DateTime::parse_from_rfc2822("11 Aug 2023 15:20:00 +0200").expect("parse may not fail");
// Let us add a "not before" proof to the genesis block
let not_before_proof = b"nextnet has a blast, its prowess echoed in every gust \
\
Expand Down Expand Up @@ -242,7 +250,7 @@ pub fn get_igor_genesis_block() -> ChainBlock {

fn get_igor_genesis_block_raw() -> Block {
// Set genesis timestamp
let genesis_timestamp = DateTime::parse_from_rfc2822("15 Jun 2023 14:00:00 +0200").expect("parse may not fail");
let genesis_timestamp = DateTime::parse_from_rfc2822("11 Aug 2023 15:30:00 +0200").expect("parse may not fail");
// Let us add a "not before" proof to the genesis block
let not_before_proof = b"but igor is the best, it is whispered in the wind \
\
Expand Down Expand Up @@ -275,9 +283,9 @@ pub fn get_esmeralda_genesis_block() -> ChainBlock {

// Hardcode the Merkle roots once they've been computed above
block.header.kernel_mr =
FixedHash::from_hex("f81830934480825e9289e00e45de3ce8e21744e629a2b49e12f1963a8e53d542").unwrap();
FixedHash::from_hex("9d09a1400740160c28b5ce4ef81c35e40b55cbd966e0eee4373f18bfc2d53823").unwrap();
block.header.output_mr =
FixedHash::from_hex("877825d5f58127dd6319a9b852dc0d785e6a951f3fd62b6e3f7c306d65541c82").unwrap();
FixedHash::from_hex("557b1d314988e5d32b29472179e6f857c067eb13d9e9099862d5aab67444df08").unwrap();
block.header.validator_node_mr =
FixedHash::from_hex("277da65c40b2cf99db86baedb903a3f0a38540f3a94d40c826eecac7e27d5dfc").unwrap();
}
Expand All @@ -296,7 +304,7 @@ pub fn get_esmeralda_genesis_block() -> ChainBlock {

fn get_esmeralda_genesis_block_raw() -> Block {
// Set genesis timestamp
let genesis_timestamp = DateTime::parse_from_rfc2822("15 Jun 2023 14:00:00 +0200").expect("parse may not fail");
let genesis_timestamp = DateTime::parse_from_rfc2822("11 Aug 2023 15:40:00 +0200").expect("parse may not fail");
// Let us add a "not before" proof to the genesis block
let not_before_proof =
b"as I sip my drink, thoughts of esmeralda consume my mind, like a refreshing nourishing draught \
Expand Down Expand Up @@ -378,23 +386,23 @@ mod test {
// 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, 0, 0);
check_block(Network::StageNet, &block, 455, 1);
}

#[test]
fn nextnet_genesis_sanity_check() {
// Note: Generate new data for `pub fn get_nextnet_genesis_block()` and `fn get_stagenet_genesis_block_raw()`
// if consensus values change, e.g. new faucet or other
let block = get_nextnet_genesis_block();
check_block(Network::NextNet, &block, 0, 0);
check_block(Network::NextNet, &block, 455, 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()`
// if consensus values change, e.g. new faucet or other
let block = get_esmeralda_genesis_block();
check_block(Network::Esmeralda, &block, 4965, 1);
check_block(Network::Esmeralda, &block, 455, 1);
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions base_layer/core/src/consensus/consensus_constants.rs
Expand Up @@ -149,7 +149,7 @@ pub struct PowAlgorithmConstants {
pub target_time: u64,
}

const ESMERALDA_FAUCET_VALUE: u64 = 5_025_126_665_742_480;
const ESMERALDA_FAUCET_VALUE: u64 = 3_798_996_893_688_987;

// The target time used by the difficulty adjustment algorithms, their target time is the target block interval * PoW
// algorithm count
Expand Down Expand Up @@ -549,7 +549,7 @@ impl ConsensusConstants {
emission_tail: 800 * T,
max_randomx_seed_height: 3000,
proof_of_work: algos,
faucet_value: 0.into(),
faucet_value: ESMERALDA_FAUCET_VALUE.into(), // The esmeralda genesis block is re-used for stagenet
transaction_weight: TransactionWeight::v1(),
max_script_byte_size: 2048,
input_version_range,
Expand Down Expand Up @@ -597,7 +597,7 @@ impl ConsensusConstants {
emission_tail: 800 * T,
max_randomx_seed_height: 3000,
proof_of_work: algos,
faucet_value: 0.into(),
faucet_value: ESMERALDA_FAUCET_VALUE.into(), // The esmeralda genesis block is re-used for stagenet
transaction_weight: TransactionWeight::v1(),
max_script_byte_size: 2048,
input_version_range,
Expand Down
1 change: 1 addition & 0 deletions base_layer/core/src/proof_of_work/monero_rx/helpers.rs
Expand Up @@ -550,6 +550,7 @@ mod test {
};
let hash = block_header.merge_mining_hash();
append_merge_mining_tag(&mut block, hash).unwrap();
#[allow(clippy::redundant_clone)]
let mut block_header2 = block_header.clone();
block_header2.version = 1;
let hash2 = block_header.merge_mining_hash();
Expand Down
10 changes: 5 additions & 5 deletions base_layer/tari_mining_helper_ffi/src/lib.rs
Expand Up @@ -386,8 +386,8 @@ mod tests {

#[test]
fn detect_change_in_consensus_encoding() {
const NONCE: u64 = 15177346899007969885;
let difficulty = Difficulty::from_u64(10695).expect("Failed to create difficulty");
const NONCE: u64 = 10923100584592193928;
let difficulty = Difficulty::from_u64(8251).expect("Failed to create difficulty");
unsafe {
let mut error = -1;
let error_ptr = &mut error as *mut c_int;
Expand All @@ -402,9 +402,9 @@ mod tests {
if result != difficulty.as_u64() {
// Use this to generate new NONCE and DIFFICULTY
// Use ONLY if you know encoding has changed
// let (difficulty, nonce) = generate_nonce_with_min_difficulty(min_difficulty()).unwrap();
// eprintln!("nonce = {:?}", nonce);
// eprintln!("difficulty = {:?}", difficulty);
let (difficulty, nonce) = generate_nonce_with_min_difficulty(min_difficulty()).unwrap();
eprintln!("nonce = {:?}", nonce);
eprintln!("difficulty = {:?}", difficulty);
panic!(
"detect_change_in_consensus_encoding has failed. This might be a change in consensus encoding \
which requires an update to the pool miner code."
Expand Down
2 changes: 1 addition & 1 deletion base_layer/wallet/src/output_manager_service/service.rs
Expand Up @@ -706,7 +706,7 @@ where
// if the script is Push_pubkey(default_key) we know we have to fill it in.
let script = if single_round_sender_data.script == script!(Nop) {
single_round_sender_data.script.clone()
} else if single_round_sender_data.script == script!(PushPubKey(Box::new(PublicKey::default()))) {
} else if single_round_sender_data.script == script!(PushPubKey(Box::default())) {
script!(PushPubKey(Box::new(script_public_key.clone())))
} else {
return Err(OutputManagerError::InvalidScriptHash);
Expand Down
4 changes: 2 additions & 2 deletions base_layer/wallet_ffi/README.md
Expand Up @@ -132,8 +132,8 @@ Install [Rust](https://www.rust-lang.org/tools/install)

Install the following tools and system images
```Shell Script
rustup toolchain add nightly-2020-01-08
rustup default nightly-2020-01-08
rustup toolchain add nightly-2023-06-04
rustup default nightly-2023-06-04
rustup component add rustfmt --toolchain nightly
rustup component add clippy
rustup target add x86_64-apple-ios aarch64-apple-ios # iPhone and emulator cross compiling
Expand Down
3 changes: 2 additions & 1 deletion base_layer/wallet_ffi/build.rs
Expand Up @@ -3,7 +3,7 @@

use std::{env, path::PathBuf};

use cbindgen::{Config, ExportConfig, Language, ParseConfig, Style};
use cbindgen::{Config, ExportConfig, Language, LineEndingStyle, ParseConfig, Style};
use tari_common::build::StaticApplicationInfo;

fn main() {
Expand Down Expand Up @@ -37,6 +37,7 @@ fn main() {
include: vec!["TariUtxo".to_string()],
..Default::default()
},
line_endings: LineEndingStyle::Native,
..Default::default()
};

Expand Down
4 changes: 2 additions & 2 deletions buildtools/docker/base_node.Dockerfile
@@ -1,13 +1,13 @@
# syntax=docker/dockerfile:1
#FROM rust:1.42.0 as builder
FROM quay.io/tarilabs/rust_tari-build-with-deps:nightly-2021-11-20 as builder
FROM quay.io/tarilabs/rust_tari-build-with-deps:nightly-2023-06-04 as builder

# Copy the dependency lists
#ADD Cargo.toml ./
ADD . /tari_base_node
WORKDIR /tari_base_node

# RUN rustup component add rustfmt --toolchain nightly-2020-08-13-x86_64-unknown-linux-gnu
# RUN rustup component add rustfmt --toolchain nightly-2023-06-04-x86_64-unknown-linux-gnu
#ARG TBN_ARCH=native
ARG TBN_ARCH=x86-64
#ARG TBN_FEATURES=avx2
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Expand Up @@ -13,4 +13,4 @@
# - the CI files in .github folder
# - the Makefile in base_layer/key_manager/Makefile
[toolchain]
channel = "nightly-2023-06-03"
channel = "nightly-2023-06-04"
4 changes: 2 additions & 2 deletions scripts/test_in_docker.sh
Expand Up @@ -2,8 +2,8 @@

# Run the Tari test suite locally inside a suitable docker container

IMAGE=quay.io/tarilabs/rust_tari-build-with-deps:nightly-2020-08-13
TOOLCHAIN_VERSION=nightly-2020-08-13
IMAGE=quay.io/tarilabs/rust_tari-build-with-deps:nightly-2023-06-04
TOOLCHAIN_VERSION=nightly-2023-06-04
CONTAINER=tari_test

echo "Deleting old container"
Expand Down

0 comments on commit ffb987a

Please sign in to comment.