Skip to content
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
30 changes: 15 additions & 15 deletions consensus/core/src/config/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,16 @@ pub const TESTNET_GENESIS: GenesisBlock = GenesisBlock {
],
};

pub const TESTNET11_GENESIS: GenesisBlock = GenesisBlock {
pub const TESTNET12_GENESIS: GenesisBlock = GenesisBlock {
hash: Hash::from_bytes([
0xcf, 0xa2, 0xa7, 0xeb, 0xfb, 0x8b, 0x4e, 0xa3, 0x45, 0x30, 0x7b, 0xc2, 0x5e, 0xf9, 0x42, 0x1b, 0x23, 0x91, 0xf0, 0x9c, 0x8b,
0x2c, 0xf2, 0x15, 0xf0, 0x75, 0x60, 0xaf, 0x0d, 0x4d, 0x71, 0x64,
0xdb, 0x62, 0x88, 0x0f, 0x1f, 0xc8, 0xca, 0x33, 0xbe, 0x99, 0xf0, 0x82, 0x67, 0x18, 0x69, 0x1c, 0x95, 0x6c, 0x4e, 0x4f, 0x25,
0x1d, 0x19, 0xbc, 0xf1, 0x23, 0x3f, 0x3e, 0x0d, 0xb8, 0xb2, 0x13,
]),
hash_merkle_root: Hash::from_bytes([
0x3c, 0x35, 0xdb, 0x98, 0x02, 0x7e, 0x84, 0x6e, 0x02, 0xcc, 0x60, 0xb7, 0xa7, 0xfa, 0xb1, 0x6d, 0x6c, 0xf2, 0xa5, 0x42, 0xd8,
0xe1, 0x60, 0xad, 0x9c, 0xd9, 0x08, 0x5f, 0x51, 0x0c, 0x47, 0xbb,
0x57, 0x52, 0x65, 0xb8, 0xfd, 0x4e, 0x33, 0x0a, 0x92, 0xd6, 0xfd, 0x97, 0x3a, 0x33, 0xe6, 0xc0, 0x00, 0xbc, 0x4a, 0xb2, 0x63,
0x7b, 0x34, 0xac, 0x6e, 0x14, 0x77, 0x15, 0x96, 0x87, 0xe5, 0xa0,
]),
bits: 504155340, // see `gen_testnet11_genesis`
bits: 504155340, // see `gen_testnet12_genesis`
#[rustfmt::skip]
coinbase_payload: &[
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Blue score
Expand All @@ -164,7 +164,7 @@ pub const TESTNET11_GENESIS: GenesisBlock = GenesisBlock {
0x01, // Varint
0x00, // OP-FALSE
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x6e, 0x65, 0x74, // kaspa-testnet
11, 4 // TN11, Relaunch 4
12, 1 // TN12, Launch 1
],
..TESTNET_GENESIS
};
Expand Down Expand Up @@ -234,30 +234,30 @@ mod tests {

#[test]
fn test_genesis_hashes() {
[GENESIS, TESTNET_GENESIS, TESTNET11_GENESIS, SIMNET_GENESIS, DEVNET_GENESIS].into_iter().for_each(|genesis| {
[GENESIS, TESTNET_GENESIS, TESTNET12_GENESIS, SIMNET_GENESIS, DEVNET_GENESIS].into_iter().for_each(|genesis| {
let block: Block = (&genesis).into();
assert_hashes_eq(calc_hash_merkle_root(block.transactions.iter()), block.header.hash_merkle_root);
assert_hashes_eq(block.hash(), genesis.hash);
assert_hashes_eq(calc_hash_merkle_root(block.transactions.iter()), block.header.hash_merkle_root, "hash_merkle_root");
assert_hashes_eq(block.hash(), genesis.hash, "genesis hash");
});
}

#[test]
fn gen_testnet11_genesis() {
fn gen_testnet12_genesis() {
let bps = TenBps::bps();
let mut genesis = TESTNET_GENESIS;
let target = kaspa_math::Uint256::from_compact_target_bits(genesis.bits);
let scaled_target = target * bps / 100;
let scaled_bits = scaled_target.compact_target_bits();
genesis.bits = scaled_bits;
if genesis.bits != TESTNET11_GENESIS.bits {
panic!("Testnet 11: new bits: {}\nnew hash: {:#04x?}", scaled_bits, Block::from(&genesis).hash().as_bytes());
if genesis.bits != TESTNET12_GENESIS.bits {
panic!("Testnet 12: new bits: {}\nnew hash: {:#04x?}", scaled_bits, Block::from(&genesis).hash().as_bytes());
}
}

fn assert_hashes_eq(got: Hash, expected: Hash) {
fn assert_hashes_eq(got: Hash, expected: Hash, field: &str) {
if got != expected {
// Special hex print to ease changing the genesis hash according to the print if needed
panic!("Got hash {:#04x?} while expecting {:#04x?}", got.as_bytes(), expected.as_bytes());
panic!("Invalid field '{}': Got hash {:#04x?} while expecting {:#04x?}", field, got.as_bytes(), expected.as_bytes());
}
}
}
14 changes: 13 additions & 1 deletion consensus/core/src/config/params.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use super::{
bps::{Bps, TenBps},
constants::consensus::*,
genesis::{GenesisBlock, DEVNET_GENESIS, GENESIS, SIMNET_GENESIS, TESTNET11_GENESIS, TESTNET_GENESIS},
genesis::{GenesisBlock, DEVNET_GENESIS, GENESIS, SIMNET_GENESIS, TESTNET12_GENESIS, TESTNET_GENESIS},
};
use crate::{
constants::STORAGE_MASS_PARAMETER,
Expand Down Expand Up @@ -530,6 +530,7 @@ impl From<NetworkId> for Params {
NetworkType::Mainnet => MAINNET_PARAMS,
NetworkType::Testnet => match value.suffix {
Some(10) => TESTNET_PARAMS,
Some(12) => TESTNET12_PARAMS,
Some(x) => panic!("Testnet suffix {} is not supported", x),
None => panic!("Testnet suffix not provided"),
},
Expand Down Expand Up @@ -664,6 +665,17 @@ pub const TESTNET_PARAMS: Params = Params {
covenants_activation: ForkActivation::never(),
};

pub const TESTNET12_PARAMS: Params = Params {
dns_seeders: &[
// This DNS seeder is run by someone235
"tn12-dnsseed.kas.pa.kas.pa",
],
net: NetworkId::with_suffix(NetworkType::Testnet, 12),
genesis: TESTNET12_GENESIS,
covenants_activation: ForkActivation::always(),
..TESTNET_PARAMS
};

pub const SIMNET_PARAMS: Params = Params {
dns_seeders: &[],
net: NetworkId::new(NetworkType::Simnet),
Expand Down
2 changes: 1 addition & 1 deletion consensus/core/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl NetworkId {
NetworkType::Mainnet => 16111,
NetworkType::Testnet => match self.suffix {
Some(10) => 16211,
Some(11) => 16311,
Some(12) => 16311,
None | Some(_) => 16411,
},
NetworkType::Simnet => 16511,
Expand Down
72 changes: 72 additions & 0 deletions docs/testnet12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Testnet 12

*Testnet 12* is the test network running Kaspa with covenants. The goal of this document is to provide a quick guide for anyone who wants to participate.

In the future testnet 12 will act as a staging zone for all sorts of experiments, allowing us to stress test various approaches and ideas on a global scale with the participation of the community. The approaches we decide to adopt will then be stress tested for longer periods on testnet 10 before being incorporated into the mainnet.

## Overview

On the software side, participating requires three components:
1. *kaspad* - the Kaspa client
2. *kaspa-miner* - the Kaspa CPU miner
3. *Rothschild* - a transaction generator

The Rothschild tool is used to create a wallet, and once the wallet has some funds within, Rothschild will continuously create transactions from that wallet back to itself at the prescribed rate.

The Rothschild wallet could be funded by either mining to it directly (either for a short period or continuously) or by asking other experiment participants for some funds (e.g. on the Discord \#testnet channel).

## How to participate

The only prerequisite is running a node that's connected to Testnet 12. Other than that you produce blocks by running a miner, produce transactions by running Rothschild, or both.

Since we want the test condition to be as close as possible to organic, we encourage users to diversify their roles, and the hardware they use to participate.

The venue for discussing and monitoring the experiment will be the \#testnet channel on Discord. We encourage participants to describe the experience in general, and also tell us what hardware they are using and how well it handles the load.

The recommended hardware requirements are 16GB of RAM, preferably a CPU with at least 8 cores, and an SSD drive with at least 250GB of free space (the 300GB for a safety margin is preferable). It might also be possible to operate with 8GB of RAM, by passing the `--ram-scale=0.6` parameter to `kaspad`.

## Setup Instructions

Testnet12 uses a dedicated P2P port (16311) so that nodes from the usual testnet (10) do not automatically attempt connecting to it.

We reiterate that only the included miner should be used to maintain a level playing field.

First, we set-up a node:
1. Download and extract the [rusty-kaspa binaries](https://github.com/kaspanet/rusty-kaspa/releases). Alternatively, you can compile it from source yourself by following the instructions [here](https://github.com/kaspanet/rusty-kaspa/blob/master/README.md). The rest of the instructions are written assuming the former option. If you choose to locally compile the code, replace any command of the form ``<program> <arguments>`` with ``cargo run --bin <program> --release -- <arguments>`` (see example in the next item). All actions described below should be performed on a command line window where you navigated to the directory into which the binaries were extracted.
2. Start the ``kaspad`` client with ``utxoindex`` enabled:

```
kaspad --testnet --netsuffix=12 --utxoindex
```
It is **very important** not to forget the ``--netsuffix=12`` flag, otherwise your node will connect to mainnet or to the default testnet.
If you complied the code yourself, you should instead run
```
cargo run --bin kaspad --release -- --testnet --netsuffix=12 --utxoindex
```
Leave this window open, there is no need to touch it as long as the node is running. Closing it will stop the node.

If you want to transmit transactions, first create a Rothschild wallet
1. Run ``rothschild`` to generate a wallet
2. The output will provide you with a private key (that looks like a bunch of gibberish) and a public address (that looks like "kaspatest:" followed by a bunch of gibberish). For example, the output could look like this:
```
2023-06-25 18:00:58.677+00:00 [INFO ] Connected to RPC
2023-06-25 18:00:58.677+00:00 [INFO ] Generated private key aa1c554386218eb28c4bsf6a02e5943799cf951dac7301324d88dec2d0119fce and address kaspatest:qzlpwt49f0useql6w0tzpnf8k2symdv5tu2x2pe9r9nvngw8mvx57q0tt9lr5. Send some funds to this address and rerun rothschild with `--private-key aa1c554386218eb28c4bsf6a02e5943799cf951dac7301324d88dec2d0119fce`
```
Here, the private key is ```aa1c554386218eb28c4bsf6a02e5943799cf951dac7301324d88dec2d0119fce``` and the address is ```kaspatest:qzlpwt49f0useql6w0tzpnf8k2symdv5tu2x2pe9r9nvngw8mvx57q0tt9lr5```
3. Put some money into the wallet. This could be done by either mining to that wallet (see below) or asking other participants to send money to your public address in the \#testnet Discord channel.
4. Once the wallet has been funded, run Rothschild with the private key:
```
rothschild --private-key <private-key> -t=50
```
The last parameter ``-t=50`` means Rothschild will attempt broadcasting 50 transactions per second. We encourage participants to run with different TPS values. However, in order to encourage transaction spread and to simulate organic usage we highly recommend not to go above 100 TPS.

Like kaspad, the Rothschild window should remain open and undisturbed.

For mining, grab `kaspa-miner` from within the latest [Release](https://github.com/elichai/kaspa-miner/releases) and run it with the following flags (**this is currently the only miner that supports testnet-12**):
```
kaspa-miner --testnet --mining-address <address> -p 16210 -t 1
```

If you intend to run Rothschild, replace ``<address>`` with the address of the wallet generated by ``rothschild``, you should then wait for a while before your wallet accumulates enough funds. Assuming several dozen participants, 20 minutes should be more than enough. If you just mine for the sake of mining, you could use any address, such as the one provided in the example above.

Like the Kaspad and Rothschild windows, the miner window should also be left undisturbed, and closing it will stop the mining.