Skip to content

Commit 430c8ad

Browse files
michaelsuttonreshmemsupertyposupertypo
authored
Crescendo hardfork transitioning (#633)
* deactivate tn11 * wip fork params * wip fork params (2) * we are not forking the timestamp deviation tolerance param * min difficulty len can be defined only once * forked param * use only a single (crescendo) activation flag. fix tx related activation tests to calc storage mass correctly * rename _len -> _size for consistency * wip bps forking * wip bps forking: filter non activated blocks from DAA window * bps forking logic * fix gated feature tests * media time window should exclude non activated blocks as well * unused * ghostdag k forking logic * coinbase reward forking logic * parents and mergeset size limits forking logic * merge depth and finality depth forking logic * pruning point forking logic * fix doc test * various todos and leftovers * mempool-related forking logic, more todos * KIP-13 (part of crescendo) (#639) * kip13 * inline tracking per mass unit * various small fixes * docs * ghostdag: comments; extract var and reuse; handle origin edge case * permanent -> persistent * use bool -> option -> iter and remove code duplication * coinbase misc * header misc * comments * log the hardfork (initial) * fix block depth origin case * initial ascii art + human readable difficulty print * countdown log * utxo-related forking activation should be based on block daa score and not pov daa score * todo * handle edge cases related to trusted blocks being checked for activation * Generalized KIP9--storage mass plurality (Crescendo) (#641) * implement storage mass plurality * move plurality calculation to mass module and add a useful trait for accessing it * utxo cell * consume outputs iterator only once, fix theoretic overflow * add sanity check for plurality limits, align comments * optimize input iterator consumption * extended comment rewrite * fix doc build * inline the relaxed formula conditions * test_storage_mass_pluralities * Change expected pruning point to chain qualification check (Crescendo) (#642) * change expected pruning point check from header validity to chain qualification * adjust `pruning points valid chain` verification to the new rule change * tx limits forking logic * coinbase maturity forking logic * finalize tx-related limit values * delete todo * post fork activation: log window sizes with frequency 100 * KIP-15 (#636) * feat(consensus): implement kip-15 1. Accepted-ID-MR = Hash ( SP.Accepted-ID-MR, MR of Accepted-TXs ) * fix(consensus): after rebase ... * fix: after review * log activation of UTXO state processing rules * comment * Smooth transition of pruning points/samples (Crescendo) (#643) * add a simpa activation test * print * wip (working w/o fork) * wip * working prototype (up to storage) * inline * print stats * comments and asserts * pruning samples database storage (todo: database upgrade; syncee import) * fix tests * syncee import * database upgrade procedure * minor * logs * database upgrade: populate past pruning points * save to store during pruning points valid chain check * next pruning points sanity checks * reposition log call, add comments * use headers store; more comments * address most review comments * adjust todo within daa_score timestamp estimate * adjust todo for tx log aggregation * next pruning points: keep the candidate valid also post v2 call * add a test explicitly verifying the emission schedule (long; ignored) * Add n-testnet-10.kaspa.ws DNS seeder (#644) Co-authored-by: supertypo <suprtypo@pm.me> * add assert * use ghostdag data from ctx * unrelated to crescendo: minor fix to `are_pruning_points_in_valid_chain` for the case where the syncer is sending a deep pruning point (e.g., a future archive) * fix text of comments * specialized info logs [CRND ] * use a const for keyword * set TN10 activation date and bump version to 0.17.0 * fix and extend subsidy tests --------- Co-authored-by: Ro Ma <roman@igralabs.com> Co-authored-by: supertypo <mthoring@gmail.com> Co-authored-by: supertypo <suprtypo@pm.me>
1 parent ea0b251 commit 430c8ad

File tree

91 files changed

+3442
-1417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3442
-1417
lines changed

Cargo.lock

+61-60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+56-56
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ members = [
6363

6464
[workspace.package]
6565
rust-version = "1.82.0"
66-
version = "0.16.1"
66+
version = "0.17.0"
6767
authors = ["Kaspa developers"]
6868
license = "ISC"
6969
repository = "https://github.com/kaspanet/rusty-kaspa"
@@ -80,61 +80,61 @@ include = [
8080
]
8181

8282
[workspace.dependencies]
83-
# kaspa-testing-integration = { version = "0.16.1", path = "testing/integration" }
84-
kaspa-addresses = { version = "0.16.1", path = "crypto/addresses" }
85-
kaspa-addressmanager = { version = "0.16.1", path = "components/addressmanager" }
86-
kaspa-bip32 = { version = "0.16.1", path = "wallet/bip32" }
87-
kaspa-cli = { version = "0.16.1", path = "cli" }
88-
kaspa-connectionmanager = { version = "0.16.1", path = "components/connectionmanager" }
89-
kaspa-consensus = { version = "0.16.1", path = "consensus" }
90-
kaspa-consensus-core = { version = "0.16.1", path = "consensus/core" }
91-
kaspa-consensus-client = { version = "0.16.1", path = "consensus/client" }
92-
kaspa-consensus-notify = { version = "0.16.1", path = "consensus/notify" }
93-
kaspa-consensus-wasm = { version = "0.16.1", path = "consensus/wasm" }
94-
kaspa-consensusmanager = { version = "0.16.1", path = "components/consensusmanager" }
95-
kaspa-core = { version = "0.16.1", path = "core" }
96-
kaspa-daemon = { version = "0.16.1", path = "daemon" }
97-
kaspa-database = { version = "0.16.1", path = "database" }
98-
kaspa-grpc-client = { version = "0.16.1", path = "rpc/grpc/client" }
99-
kaspa-grpc-core = { version = "0.16.1", path = "rpc/grpc/core" }
100-
kaspa-grpc-server = { version = "0.16.1", path = "rpc/grpc/server" }
101-
kaspa-hashes = { version = "0.16.1", path = "crypto/hashes" }
102-
kaspa-index-core = { version = "0.16.1", path = "indexes/core" }
103-
kaspa-index-processor = { version = "0.16.1", path = "indexes/processor" }
104-
kaspa-math = { version = "0.16.1", path = "math" }
105-
kaspa-merkle = { version = "0.16.1", path = "crypto/merkle" }
106-
kaspa-metrics-core = { version = "0.16.1", path = "metrics/core" }
107-
kaspa-mining = { version = "0.16.1", path = "mining" }
108-
kaspa-mining-errors = { version = "0.16.1", path = "mining/errors" }
109-
kaspa-muhash = { version = "0.16.1", path = "crypto/muhash" }
110-
kaspa-notify = { version = "0.16.1", path = "notify" }
111-
kaspa-p2p-flows = { version = "0.16.1", path = "protocol/flows" }
112-
kaspa-p2p-lib = { version = "0.16.1", path = "protocol/p2p" }
113-
kaspa-perf-monitor = { version = "0.16.1", path = "metrics/perf_monitor" }
114-
kaspa-pow = { version = "0.16.1", path = "consensus/pow" }
115-
kaspa-rpc-core = { version = "0.16.1", path = "rpc/core" }
116-
kaspa-rpc-macros = { version = "0.16.1", path = "rpc/macros" }
117-
kaspa-rpc-service = { version = "0.16.1", path = "rpc/service" }
118-
kaspa-txscript = { version = "0.16.1", path = "crypto/txscript" }
119-
kaspa-txscript-errors = { version = "0.16.1", path = "crypto/txscript/errors" }
120-
kaspa-utils = { version = "0.16.1", path = "utils" }
121-
kaspa-utils-tower = { version = "0.16.1", path = "utils/tower" }
122-
kaspa-utxoindex = { version = "0.16.1", path = "indexes/utxoindex" }
123-
kaspa-wallet = { version = "0.16.1", path = "wallet/native" }
124-
kaspa-wallet-cli-wasm = { version = "0.16.1", path = "wallet/wasm" }
125-
kaspa-wallet-keys = { version = "0.16.1", path = "wallet/keys" }
126-
kaspa-wallet-pskt = { version = "0.16.1", path = "wallet/pskt" }
127-
kaspa-wallet-core = { version = "0.16.1", path = "wallet/core" }
128-
kaspa-wallet-macros = { version = "0.16.1", path = "wallet/macros" }
129-
kaspa-wasm = { version = "0.16.1", path = "wasm" }
130-
kaspa-wasm-core = { version = "0.16.1", path = "wasm/core" }
131-
kaspa-wrpc-client = { version = "0.16.1", path = "rpc/wrpc/client" }
132-
kaspa-wrpc-proxy = { version = "0.16.1", path = "rpc/wrpc/proxy" }
133-
kaspa-wrpc-server = { version = "0.16.1", path = "rpc/wrpc/server" }
134-
kaspa-wrpc-wasm = { version = "0.16.1", path = "rpc/wrpc/wasm" }
135-
kaspa-wrpc-example-subscriber = { version = "0.16.1", path = "rpc/wrpc/examples/subscriber" }
136-
kaspad = { version = "0.16.1", path = "kaspad" }
137-
kaspa-alloc = { version = "0.16.1", path = "utils/alloc" }
83+
# kaspa-testing-integration = { version = "0.17.0", path = "testing/integration" }
84+
kaspa-addresses = { version = "0.17.0", path = "crypto/addresses" }
85+
kaspa-addressmanager = { version = "0.17.0", path = "components/addressmanager" }
86+
kaspa-bip32 = { version = "0.17.0", path = "wallet/bip32" }
87+
kaspa-cli = { version = "0.17.0", path = "cli" }
88+
kaspa-connectionmanager = { version = "0.17.0", path = "components/connectionmanager" }
89+
kaspa-consensus = { version = "0.17.0", path = "consensus" }
90+
kaspa-consensus-core = { version = "0.17.0", path = "consensus/core" }
91+
kaspa-consensus-client = { version = "0.17.0", path = "consensus/client" }
92+
kaspa-consensus-notify = { version = "0.17.0", path = "consensus/notify" }
93+
kaspa-consensus-wasm = { version = "0.17.0", path = "consensus/wasm" }
94+
kaspa-consensusmanager = { version = "0.17.0", path = "components/consensusmanager" }
95+
kaspa-core = { version = "0.17.0", path = "core" }
96+
kaspa-daemon = { version = "0.17.0", path = "daemon" }
97+
kaspa-database = { version = "0.17.0", path = "database" }
98+
kaspa-grpc-client = { version = "0.17.0", path = "rpc/grpc/client" }
99+
kaspa-grpc-core = { version = "0.17.0", path = "rpc/grpc/core" }
100+
kaspa-grpc-server = { version = "0.17.0", path = "rpc/grpc/server" }
101+
kaspa-hashes = { version = "0.17.0", path = "crypto/hashes" }
102+
kaspa-index-core = { version = "0.17.0", path = "indexes/core" }
103+
kaspa-index-processor = { version = "0.17.0", path = "indexes/processor" }
104+
kaspa-math = { version = "0.17.0", path = "math" }
105+
kaspa-merkle = { version = "0.17.0", path = "crypto/merkle" }
106+
kaspa-metrics-core = { version = "0.17.0", path = "metrics/core" }
107+
kaspa-mining = { version = "0.17.0", path = "mining" }
108+
kaspa-mining-errors = { version = "0.17.0", path = "mining/errors" }
109+
kaspa-muhash = { version = "0.17.0", path = "crypto/muhash" }
110+
kaspa-notify = { version = "0.17.0", path = "notify" }
111+
kaspa-p2p-flows = { version = "0.17.0", path = "protocol/flows" }
112+
kaspa-p2p-lib = { version = "0.17.0", path = "protocol/p2p" }
113+
kaspa-perf-monitor = { version = "0.17.0", path = "metrics/perf_monitor" }
114+
kaspa-pow = { version = "0.17.0", path = "consensus/pow" }
115+
kaspa-rpc-core = { version = "0.17.0", path = "rpc/core" }
116+
kaspa-rpc-macros = { version = "0.17.0", path = "rpc/macros" }
117+
kaspa-rpc-service = { version = "0.17.0", path = "rpc/service" }
118+
kaspa-txscript = { version = "0.17.0", path = "crypto/txscript" }
119+
kaspa-txscript-errors = { version = "0.17.0", path = "crypto/txscript/errors" }
120+
kaspa-utils = { version = "0.17.0", path = "utils" }
121+
kaspa-utils-tower = { version = "0.17.0", path = "utils/tower" }
122+
kaspa-utxoindex = { version = "0.17.0", path = "indexes/utxoindex" }
123+
kaspa-wallet = { version = "0.17.0", path = "wallet/native" }
124+
kaspa-wallet-cli-wasm = { version = "0.17.0", path = "wallet/wasm" }
125+
kaspa-wallet-keys = { version = "0.17.0", path = "wallet/keys" }
126+
kaspa-wallet-pskt = { version = "0.17.0", path = "wallet/pskt" }
127+
kaspa-wallet-core = { version = "0.17.0", path = "wallet/core" }
128+
kaspa-wallet-macros = { version = "0.17.0", path = "wallet/macros" }
129+
kaspa-wasm = { version = "0.17.0", path = "wasm" }
130+
kaspa-wasm-core = { version = "0.17.0", path = "wasm/core" }
131+
kaspa-wrpc-client = { version = "0.17.0", path = "rpc/wrpc/client" }
132+
kaspa-wrpc-proxy = { version = "0.17.0", path = "rpc/wrpc/proxy" }
133+
kaspa-wrpc-server = { version = "0.17.0", path = "rpc/wrpc/server" }
134+
kaspa-wrpc-wasm = { version = "0.17.0", path = "rpc/wrpc/wasm" }
135+
kaspa-wrpc-example-subscriber = { version = "0.17.0", path = "rpc/wrpc/examples/subscriber" }
136+
kaspad = { version = "0.17.0", path = "kaspad" }
137+
kaspa-alloc = { version = "0.17.0", path = "utils/alloc" }
138138

139139
# external
140140
aes = "0.8.3"

components/consensusmanager/src/session.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use kaspa_consensus_core::{
1010
daa_score_timestamp::DaaScoreTimestamp,
1111
errors::consensus::ConsensusResult,
1212
header::Header,
13+
mass::{ContextualMasses, NonContextualMasses},
1314
pruning::{PruningPointProof, PruningPointTrustedData, PruningPointsList},
1415
trusted::{ExternalGhostdagData, TrustedBlock},
1516
tx::{MutableTransaction, SignableTransaction, Transaction, TransactionOutpoint, UtxoEntry},
@@ -191,14 +192,14 @@ impl ConsensusSessionOwned {
191192
self.consensus.validate_and_insert_trusted_block(tb)
192193
}
193194

194-
pub fn calculate_transaction_compute_mass(&self, transaction: &Transaction) -> u64 {
195+
pub fn calculate_transaction_non_contextual_masses(&self, transaction: &Transaction) -> NonContextualMasses {
195196
// This method performs pure calculations so no need for an async wrapper
196-
self.consensus.calculate_transaction_compute_mass(transaction)
197+
self.consensus.calculate_transaction_non_contextual_masses(transaction)
197198
}
198199

199-
pub fn calculate_transaction_storage_mass(&self, transaction: &MutableTransaction) -> Option<u64> {
200+
pub fn calculate_transaction_contextual_masses(&self, transaction: &MutableTransaction) -> Option<ContextualMasses> {
200201
// This method performs pure calculations so no need for an async wrapper
201-
self.consensus.calculate_transaction_storage_mass(transaction)
202+
self.consensus.calculate_transaction_contextual_masses(transaction)
202203
}
203204

204205
pub fn get_virtual_daa_score(&self) -> u64 {
@@ -442,8 +443,8 @@ impl ConsensusSessionOwned {
442443
self.clone().spawn_blocking(move |c| c.estimate_network_hashes_per_second(start_hash, window_size)).await
443444
}
444445

445-
pub async fn async_validate_pruning_points(&self) -> ConsensusResult<()> {
446-
self.clone().spawn_blocking(move |c| c.validate_pruning_points()).await
446+
pub async fn async_validate_pruning_points(&self, syncer_virtual_selected_parent: Hash) -> ConsensusResult<()> {
447+
self.clone().spawn_blocking(move |c| c.validate_pruning_points(syncer_virtual_selected_parent)).await
447448
}
448449

449450
pub async fn async_are_pruning_points_violating_finality(&self, pp_list: PruningPointsList) -> bool {

consensus/client/src/utxo.rs

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::imports::*;
1212
use crate::outpoint::{TransactionOutpoint, TransactionOutpointInner};
1313
use crate::result::Result;
1414
use kaspa_addresses::Address;
15+
use kaspa_consensus_core::mass::{UtxoCell, UtxoPlurality};
1516

1617
#[wasm_bindgen(typescript_custom_section)]
1718
const TS_UTXO_ENTRY: &'static str = r#"
@@ -249,6 +250,12 @@ impl From<UtxoEntry> for UtxoEntryReference {
249250
}
250251
}
251252

253+
impl From<&UtxoEntryReference> for UtxoCell {
254+
fn from(entry: &UtxoEntryReference) -> Self {
255+
Self::new(entry.utxo.script_public_key.plurality(), entry.amount())
256+
}
257+
}
258+
252259
impl Eq for UtxoEntryReference {}
253260

254261
impl PartialEq for UtxoEntryReference {

consensus/core/src/api/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::{
1717
tx::TxResult,
1818
},
1919
header::Header,
20+
mass::{ContextualMasses, NonContextualMasses},
2021
pruning::{PruningPointProof, PruningPointTrustedData, PruningPointsList, PruningProofMetadata},
2122
trusted::{ExternalGhostdagData, TrustedBlock},
2223
tx::{MutableTransaction, SignableTransaction, Transaction, TransactionOutpoint, UtxoEntry},
@@ -90,11 +91,11 @@ pub trait ConsensusApi: Send + Sync {
9091
unimplemented!()
9192
}
9293

93-
fn calculate_transaction_compute_mass(&self, transaction: &Transaction) -> u64 {
94+
fn calculate_transaction_non_contextual_masses(&self, transaction: &Transaction) -> NonContextualMasses {
9495
unimplemented!()
9596
}
9697

97-
fn calculate_transaction_storage_mass(&self, transaction: &MutableTransaction) -> Option<u64> {
98+
fn calculate_transaction_contextual_masses(&self, transaction: &MutableTransaction) -> Option<ContextualMasses> {
9899
unimplemented!()
99100
}
100101

@@ -218,7 +219,7 @@ pub trait ConsensusApi: Send + Sync {
218219
unimplemented!()
219220
}
220221

221-
fn import_pruning_points(&self, pruning_points: PruningPointsList) {
222+
fn import_pruning_points(&self, pruning_points: PruningPointsList) -> PruningImportResult<()> {
222223
unimplemented!()
223224
}
224225

@@ -354,7 +355,7 @@ pub trait ConsensusApi: Send + Sync {
354355
unimplemented!()
355356
}
356357

357-
fn validate_pruning_points(&self) -> ConsensusResult<()> {
358+
fn validate_pruning_points(&self, syncer_virtual_selected_parent: Hash) -> ConsensusResult<()> {
358359
unimplemented!()
359360
}
360361

consensus/core/src/config/bps.rs

+10-18
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ pub fn calculate_ghostdag_k(x: f64, delta: f64) -> u64 {
2020
}
2121
}
2222

23-
/// Bps-related constants generator for testnet 11
24-
pub type Testnet11Bps = Bps<10>;
23+
/// Bps-related constants generator for 10-bps networks
24+
pub type TenBps = Bps<10>;
2525

2626
/// Struct representing network blocks-per-second. Provides a bunch of const functions
2727
/// computing various constants which are functions of the BPS value
@@ -93,29 +93,21 @@ impl<const BPS: u64> Bps<BPS> {
9393
BPS * NEW_FINALITY_DURATION
9494
}
9595

96-
/// Limit used to previously calculate the pruning depth.
97-
const fn prev_mergeset_size_limit() -> u64 {
98-
Self::ghostdag_k() as u64 * 10
99-
}
100-
10196
pub const fn pruning_depth() -> u64 {
10297
// Based on the analysis at https://github.com/kaspanet/docs/blob/main/Reference/prunality/Prunality.pdf
10398
// and on the decomposition of merge depth (rule R-I therein) from finality depth (φ)
10499
// We add an additional merge depth unit as a safety margin for anticone finalization
105-
Self::finality_depth()
100+
let lower_bound = Self::finality_depth()
106101
+ Self::merge_depth_bound() * 2
107-
+ 4 * Self::prev_mergeset_size_limit() * Self::ghostdag_k() as u64
102+
+ 4 * Self::mergeset_size_limit() * Self::ghostdag_k() as u64
108103
+ 2 * Self::ghostdag_k() as u64
109-
+ 2
110-
111-
// TODO (HF or restart of TN11):
112-
// Return `Self::finality_depth() * 3` and assert that this value is equal or larger than the above expression.
113-
// This will give us a round easy number to track which is not sensitive to minor changes in other related params.
114-
}
104+
+ 2;
115105

116-
pub const fn pruning_proof_m() -> u64 {
117-
// No need to scale this constant with BPS since the important block levels (higher) remain logarithmically short
118-
PRUNING_PROOF_M
106+
if lower_bound > BPS * NEW_PRUNING_DURATION {
107+
lower_bound
108+
} else {
109+
BPS * NEW_PRUNING_DURATION
110+
}
119111
}
120112

121113
/// Sample rate for sampling blocks to the median time window (in block units, hence dependent on BPS)

consensus/core/src/config/constants.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,15 @@ pub mod consensus {
2323
// ~~~~~~~~~~~~~~~~~~ Timestamp deviation & Median time ~~~~~~~~~~~~~~~~~~
2424
//
2525

26-
/// **Legacy** timestamp deviation tolerance (seconds)
27-
pub const LEGACY_TIMESTAMP_DEVIATION_TOLERANCE: u64 = 132;
28-
29-
/// **New** timestamp deviation tolerance (seconds).
30-
/// TODO: KIP-0004: 605 (~10 minutes)
31-
pub const NEW_TIMESTAMP_DEVIATION_TOLERANCE: u64 = 132;
26+
/// Timestamp deviation tolerance (seconds)
27+
pub const TIMESTAMP_DEVIATION_TOLERANCE: u64 = 132;
3228

3329
/// The desired interval between samples of the median time window (seconds).
34-
/// KIP-0004: 10 seconds
3530
pub const PAST_MEDIAN_TIME_SAMPLE_INTERVAL: u64 = 10;
3631

3732
/// Size of the **sampled** median time window (independent of BPS)
3833
pub const MEDIAN_TIME_SAMPLED_WINDOW_SIZE: u64 =
39-
(2 * NEW_TIMESTAMP_DEVIATION_TOLERANCE - 1).div_ceil(PAST_MEDIAN_TIME_SAMPLE_INTERVAL);
34+
(2 * TIMESTAMP_DEVIATION_TOLERANCE - 1).div_ceil(PAST_MEDIAN_TIME_SAMPLE_INTERVAL);
4035

4136
//
4237
// ~~~~~~~~~~~~~~~~~~~~~~~~~ Max difficulty target ~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -56,18 +51,21 @@ pub mod consensus {
5651
// ~~~~~~~~~~~~~~~~~~~ Difficulty Adjustment Algorithm (DAA) ~~~~~~~~~~~~~~~~~~~
5752
//
5853

59-
/// Minimal size of the difficulty window. Affects the DA algorithm only at the starting period of a new net
60-
pub const MIN_DIFFICULTY_WINDOW_LEN: usize = 10;
54+
/// Minimal size of the difficulty window. Affects the DA algorithm at the starting period of a new net.
55+
/// Also used during BPS fork transitions to stabilize the new rate before applying DA (see KIP-14).
56+
/// With 4 seconds sampling interval, a value of 150 indicates 10 minutes of fixed
57+
/// difficulty until the window grows large enough.
58+
///
59+
/// TODO (crescendo): finalize
60+
pub const MIN_DIFFICULTY_WINDOW_SIZE: usize = 150;
6161

6262
/// **Legacy** difficulty adjustment window size corresponding to ~44 minutes with 1 BPS
6363
pub const LEGACY_DIFFICULTY_WINDOW_SIZE: usize = 2641;
6464

6565
/// **New** difficulty window duration expressed in time units (seconds).
66-
/// TODO: KIP-0004: 30,000 (500 minutes)
6766
pub const NEW_DIFFICULTY_WINDOW_DURATION: u64 = 2641;
6867

6968
/// The desired interval between samples of the difficulty window (seconds).
70-
/// TODO: KIP-0004: 30 seconds
7169
pub const DIFFICULTY_WINDOW_SAMPLE_INTERVAL: u64 = 4;
7270

7371
/// Size of the **sampled** difficulty window (independent of BPS)
@@ -81,9 +79,11 @@ pub mod consensus {
8179
pub const LEGACY_FINALITY_DEPTH: u64 = 86_400;
8280

8381
/// **New** finality duration expressed in time units (seconds).
84-
/// TODO: finalize this value (consider 6-24 hours)
8582
pub const NEW_FINALITY_DURATION: u64 = 43_200; // 12 hours
8683

84+
/// **New** pruning duration expressed in time units (seconds).
85+
pub const NEW_PRUNING_DURATION: u64 = 108_000; // 30 hours
86+
8787
/// Merge depth bound duration (in seconds). For 1 BPS networks this equals the legacy depth
8888
/// bound in block units. For higher BPS networks this should be scaled up.
8989
///
@@ -166,7 +166,7 @@ pub mod perf {
166166
impl PerfParams {
167167
pub fn adjust_to_consensus_params(&mut self, consensus_params: &Params) {
168168
// Allow caching up to 10x over the baseline
169-
self.block_data_cache_size *= consensus_params.bps().clamp(1, 10) as usize;
169+
self.block_data_cache_size *= consensus_params.bps().upper_bound().clamp(1, 10) as usize;
170170
}
171171
}
172172
}

consensus/core/src/config/genesis.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub const DEVNET_GENESIS: GenesisBlock = GenesisBlock {
225225
#[cfg(test)]
226226
mod tests {
227227
use super::*;
228-
use crate::{config::bps::Testnet11Bps, merkle::calc_hash_merkle_root};
228+
use crate::{config::bps::TenBps, merkle::calc_hash_merkle_root};
229229

230230
#[test]
231231
fn test_genesis_hashes() {
@@ -238,7 +238,7 @@ mod tests {
238238

239239
#[test]
240240
fn gen_testnet11_genesis() {
241-
let bps = Testnet11Bps::bps();
241+
let bps = TenBps::bps();
242242
let mut genesis = TESTNET_GENESIS;
243243
let target = kaspa_math::Uint256::from_compact_target_bits(genesis.bits);
244244
let scaled_target = target * bps / 100;

0 commit comments

Comments
 (0)