Skip to content

Commit

Permalink
Last High-BPS testnet requirements (for the coming kaspa-testnet-11) (#…
Browse files Browse the repository at this point in the history
…205)

* Add NetworkId::iter()

* In `Params`, make `deflationary_phase_daa_score` and `pre_deflationary_phase_base_subsidy` BPS dependent

* Add a DNS seeder to testnet-11

* Make `CoinbaseManager` BPS dependent

* Test pre-deflationary phase subsidy

* Address review

* Bump version to 0.1.1
  • Loading branch information
tiram88 authored Jun 23, 2023
1 parent e4770c7 commit 3d2f000
Show file tree
Hide file tree
Showing 17 changed files with 336 additions and 176 deletions.
90 changes: 45 additions & 45 deletions Cargo.lock

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ members = [
]

[workspace.package]
version = "0.1.0"
version = "0.1.1"
authors = ["Kaspa developers"]
license = "MIT/Apache-2.0"
edition = "2021"
Expand All @@ -65,33 +65,33 @@ kaspa-p2p-flows = { path = "protocol/flows" }
kaspa-p2p-lib = { path = "protocol/p2p" }
kaspa-testing-integration = { path = "testing/integration" }
kaspa-utxoindex = { path = "indexes/utxoindex" }
kaspa-rpc-service = { version = "0.1.0", path = "rpc/service" }
kaspa-rpc-service = { version = "0.1.1", path = "rpc/service" }

# published
kaspa-addresses = { version = "0.1.0", path = "crypto/addresses" }
kaspa-bip32 = { version = "0.1.0", path = "wallet/bip32" }
kaspa-consensus = { version = "0.1.0", path = "consensus" }
kaspa-consensus-core = { version = "0.1.0", path = "consensus/core" }
kaspa-consensus-notify = { version = "0.1.0", path = "consensus/notify" }
kaspa-core = { version = "0.1.0", path = "core" }
kaspa-database = { version = "0.1.0", path = "database" }
kaspa-grpc-client = { version = "0.1.0", path = "rpc/grpc/client" }
kaspa-grpc-core = { version = "0.1.0", path = "rpc/grpc/core" }
kaspa-hashes = { version = "0.1.0", path = "crypto/hashes" }
kaspa-math = { version = "0.1.0", path = "math" }
kaspa-merkle = { version = "0.1.0", path = "crypto/merkle" }
kaspa-muhash = { version = "0.1.0", path = "crypto/muhash" }
kaspa-notify = { version = "0.1.0", path = "notify" }
kaspa-pow = { version = "0.1.0", path = "consensus/pow" }
kaspa-rpc-core = { version = "0.1.0", path = "rpc/core" }
kaspa-rpc-macros = { version = "0.1.0", path = "rpc/macros" }
kaspa-txscript = { version = "0.1.0", path = "crypto/txscript" }
kaspa-txscript-errors = { version = "0.1.0", path = "crypto/txscript/errors" }
kaspa-utils = { version = "0.1.0", path = "utils" }
kaspa-wallet-core = { version = "0.1.0", path = "wallet/core" }
kaspa-wasm = { version = "0.1.0", path = "wasm" }
kaspa-wrpc-client = { version = "0.1.0", path = "rpc/wrpc/client" }
kaspa-wrpc-wasm = { version = "0.1.0", path = "rpc/wrpc/wasm" }
kaspa-addresses = { version = "0.1.1", path = "crypto/addresses" }
kaspa-bip32 = { version = "0.1.1", path = "wallet/bip32" }
kaspa-consensus = { version = "0.1.1", path = "consensus" }
kaspa-consensus-core = { version = "0.1.1", path = "consensus/core" }
kaspa-consensus-notify = { version = "0.1.1", path = "consensus/notify" }
kaspa-core = { version = "0.1.1", path = "core" }
kaspa-database = { version = "0.1.1", path = "database" }
kaspa-grpc-client = { version = "0.1.1", path = "rpc/grpc/client" }
kaspa-grpc-core = { version = "0.1.1", path = "rpc/grpc/core" }
kaspa-hashes = { version = "0.1.1", path = "crypto/hashes" }
kaspa-math = { version = "0.1.1", path = "math" }
kaspa-merkle = { version = "0.1.1", path = "crypto/merkle" }
kaspa-muhash = { version = "0.1.1", path = "crypto/muhash" }
kaspa-notify = { version = "0.1.1", path = "notify" }
kaspa-pow = { version = "0.1.1", path = "consensus/pow" }
kaspa-rpc-core = { version = "0.1.1", path = "rpc/core" }
kaspa-rpc-macros = { version = "0.1.1", path = "rpc/macros" }
kaspa-txscript = { version = "0.1.1", path = "crypto/txscript" }
kaspa-txscript-errors = { version = "0.1.1", path = "crypto/txscript/errors" }
kaspa-utils = { version = "0.1.1", path = "utils" }
kaspa-wallet-core = { version = "0.1.1", path = "wallet/core" }
kaspa-wasm = { version = "0.1.1", path = "wasm" }
kaspa-wrpc-client = { version = "0.1.1", path = "rpc/wrpc/client" }
kaspa-wrpc-wasm = { version = "0.1.1", path = "rpc/wrpc/wasm" }

# not published
kaspa-grpc-server = { path = "rpc/grpc/server" }
Expand Down
16 changes: 16 additions & 0 deletions consensus/core/src/config/bps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ impl<const BPS: u64> Bps<BPS> {
BPS * LEGACY_COINBASE_MATURITY
}

/// DAA score after which the pre-deflationary period switches to the deflationary period.
///
/// This number is calculated as follows:
///
/// - We define a year as 365.25 days
/// - Half a year in seconds = 365.25 / 2 * 24 * 60 * 60 = 15778800
/// - The network was down for three days shortly after launch
/// - Three days in seconds = 3 * 24 * 60 * 60 = 259200
pub const fn deflationary_phase_daa_score() -> u64 {
BPS * (15778800 - 259200)
}

pub const fn pre_deflationary_phase_base_subsidy() -> u64 {
50000000000 / BPS
}

// TODO: we might need to increase max_block_level (at least for mainnet) as a function of BPS
// since higher BPS means easier difficulty puzzles -> less zeros in pow hash
// pub const fn max_block_level() -> u64 { }
Expand Down
16 changes: 7 additions & 9 deletions consensus/core/src/config/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ pub struct Params {
pub mass_per_script_pub_key_byte: u64,
pub mass_per_sig_op: u64,
pub max_block_mass: u64,

/// DAA score after which the pre-deflationary period switches to the deflationary period
pub deflationary_phase_daa_score: u64,

pub pre_deflationary_phase_base_subsidy: u64,
pub coinbase_maturity: u64,
pub skip_proof_of_work: bool,
Expand Down Expand Up @@ -394,7 +397,8 @@ pub const TESTNET_PARAMS: Params = Params {

pub const TESTNET11_PARAMS: Params = Params {
dns_seeders: &[
// No seeders yet
// This DNS seeder is run by Tiram
"seeder1-testnet-11.kaspad.net",
],
net: NetworkId::with_suffix(NetworkType::Testnet, 11),
genesis: TESTNET11_GENESIS,
Expand All @@ -421,6 +425,8 @@ pub const TESTNET11_PARAMS: Params = Params {
finality_depth: Testnet11Bps::finality_depth(),
pruning_depth: Testnet11Bps::pruning_depth(),
pruning_proof_m: Testnet11Bps::pruning_proof_m(),
deflationary_phase_daa_score: Testnet11Bps::deflationary_phase_daa_score(),
pre_deflationary_phase_base_subsidy: Testnet11Bps::pre_deflationary_phase_base_subsidy(),
coinbase_maturity: Testnet11Bps::coinbase_maturity(),

coinbase_payload_script_public_key_max_len: 150,
Expand All @@ -440,14 +446,6 @@ pub const TESTNET11_PARAMS: Params = Params {
mass_per_sig_op: 1000,
max_block_mass: 500_000,

// deflationary_phase_daa_score is the DAA score after which the pre-deflationary period
// switches to the deflationary period. This number is calculated as follows:
// We define a year as 365.25 days
// Half a year in seconds = 365.25 / 2 * 24 * 60 * 60 = 15778800
// The network was down for three days shortly after launch
// Three days in seconds = 3 * 24 * 60 * 60 = 259200
deflationary_phase_daa_score: 15778800 - 259200,
pre_deflationary_phase_base_subsidy: 50000000000,
skip_proof_of_work: false,
max_block_level: 250,
};
Expand Down
11 changes: 11 additions & 0 deletions consensus/core/src/networktype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ impl NetworkId {
NetworkType::Devnet => 16611,
}
}

pub fn iter() -> impl Iterator<Item = Self> {
static NETWORK_IDS: [NetworkId; 5] = [
NetworkId::new(NetworkType::Mainnet),
NetworkId::with_suffix(NetworkType::Testnet, 10),
NetworkId::with_suffix(NetworkType::Testnet, 11),
NetworkId::new(NetworkType::Devnet),
NetworkId::new(NetworkType::Simnet),
];
NETWORK_IDS.iter().copied()
}
}

impl Deref for NetworkId {
Expand Down
7 changes: 5 additions & 2 deletions consensus/pow/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[package]
name = "kaspa-pow"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true
authors.workspace = true
include.workspace = true
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
1 change: 1 addition & 0 deletions consensus/src/consensus/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl ConsensusServices {
params.max_coinbase_payload_len,
params.deflationary_phase_daa_score,
params.pre_deflationary_phase_base_subsidy,
params.target_time_per_block,
);

let mass_calculator =
Expand Down
Loading

0 comments on commit 3d2f000

Please sign in to comment.