Skip to content

Commit

Permalink
Merge branch 'master' into eviction_logic
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Stacks authored Mar 12, 2024
2 parents e2b3ec2 + 8b70061 commit 4279555
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 182 deletions.
174 changes: 87 additions & 87 deletions Cargo.lock

Large diffs are not rendered by default.

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

[workspace.package]
version = "0.13.4"
version = "0.13.5"
authors = ["Kaspa developers"]
license = "MIT/Apache-2.0"
repository = "https://github.com/kaspanet/rusty-kaspa"
Expand All @@ -74,58 +74,58 @@ include = [
]

[workspace.dependencies]
# kaspa-testing-integration = { version = "0.13.4", path = "testing/integration" }
kaspa-addresses = { version = "0.13.4", path = "crypto/addresses" }
kaspa-addressmanager = { version = "0.13.4", path = "components/addressmanager" }
kaspa-bip32 = { version = "0.13.4", path = "wallet/bip32" }
kaspa-cli = { version = "0.13.4", path = "cli" }
kaspa-connectionmanager = { version = "0.13.4", path = "components/connectionmanager" }
kaspa-consensus = { version = "0.13.4", path = "consensus" }
kaspa-consensus-core = { version = "0.13.4", path = "consensus/core" }
kaspa-consensus-notify = { version = "0.13.4", path = "consensus/notify" }
kaspa-consensus-wasm = { version = "0.13.4", path = "consensus/wasm" }
kaspa-consensusmanager = { version = "0.13.4", path = "components/consensusmanager" }
kaspa-core = { version = "0.13.4", path = "core" }
kaspa-daemon = { version = "0.13.4", path = "daemon" }
kaspa-database = { version = "0.13.4", path = "database" }
kaspa-grpc-client = { version = "0.13.4", path = "rpc/grpc/client" }
kaspa-grpc-core = { version = "0.13.4", path = "rpc/grpc/core" }
kaspa-grpc-server = { version = "0.13.4", path = "rpc/grpc/server" }
kaspa-hashes = { version = "0.13.4", path = "crypto/hashes" }
kaspa-index-core = { version = "0.13.4", path = "indexes/core" }
kaspa-index-processor = { version = "0.13.4", path = "indexes/processor" }
kaspa-math = { version = "0.13.4", path = "math" }
kaspa-merkle = { version = "0.13.4", path = "crypto/merkle" }
kaspa-metrics-core = { version = "0.13.4", path = "metrics/core" }
kaspa-mining = { version = "0.13.4", path = "mining" }
kaspa-mining-errors = { version = "0.13.4", path = "mining/errors" }
kaspa-muhash = { version = "0.13.4", path = "crypto/muhash" }
kaspa-notify = { version = "0.13.4", path = "notify" }
kaspa-os = { version = "0.13.4", path = "kaspa-os" }
kaspa-p2p-flows = { version = "0.13.4", path = "protocol/flows" }
kaspa-p2p-lib = { version = "0.13.4", path = "protocol/p2p" }
kaspa-perf-monitor = { version = "0.13.4", path = "metrics/perf_monitor" }
kaspa-pow = { version = "0.13.4", path = "consensus/pow" }
kaspa-rpc-core = { version = "0.13.4", path = "rpc/core" }
kaspa-rpc-macros = { version = "0.13.4", path = "rpc/macros" }
kaspa-rpc-service = { version = "0.13.4", path = "rpc/service" }
kaspa-txscript = { version = "0.13.4", path = "crypto/txscript" }
kaspa-txscript-errors = { version = "0.13.4", path = "crypto/txscript/errors" }
kaspa-utils = { version = "0.13.4", path = "utils" }
kaspa-utils-tower = { version = "0.13.4", path = "utils/tower" }
kaspa-utxoindex = { version = "0.13.4", path = "indexes/utxoindex" }
kaspa-wallet = { version = "0.13.4", path = "wallet/native" }
kaspa-wallet-cli-wasm = { version = "0.13.4", path = "wallet/wasm" }
kaspa-wallet-core = { version = "0.13.4", path = "wallet/core" }
kaspa-wallet-macros = { version = "0.13.4", path = "wallet/macros" }
kaspa-wasm = { version = "0.13.4", path = "wasm" }
kaspa-wrpc-client = { version = "0.13.4", path = "rpc/wrpc/client" }
kaspa-wrpc-core = { version = "0.13.4", path = "rpc/wrpc/core" }
kaspa-wrpc-proxy = { version = "0.13.4", path = "rpc/wrpc/proxy" }
kaspa-wrpc-server = { version = "0.13.4", path = "rpc/wrpc/server" }
kaspa-wrpc-wasm = { version = "0.13.4", path = "rpc/wrpc/wasm" }
kaspad = { version = "0.13.4", path = "kaspad" }
kaspa-alloc = { version = "0.13.4", path = "utils/alloc" }
# kaspa-testing-integration = { version = "0.13.5", path = "testing/integration" }
kaspa-addresses = { version = "0.13.5", path = "crypto/addresses" }
kaspa-addressmanager = { version = "0.13.5", path = "components/addressmanager" }
kaspa-bip32 = { version = "0.13.5", path = "wallet/bip32" }
kaspa-cli = { version = "0.13.5", path = "cli" }
kaspa-connectionmanager = { version = "0.13.5", path = "components/connectionmanager" }
kaspa-consensus = { version = "0.13.5", path = "consensus" }
kaspa-consensus-core = { version = "0.13.5", path = "consensus/core" }
kaspa-consensus-notify = { version = "0.13.5", path = "consensus/notify" }
kaspa-consensus-wasm = { version = "0.13.5", path = "consensus/wasm" }
kaspa-consensusmanager = { version = "0.13.5", path = "components/consensusmanager" }
kaspa-core = { version = "0.13.5", path = "core" }
kaspa-daemon = { version = "0.13.5", path = "daemon" }
kaspa-database = { version = "0.13.5", path = "database" }
kaspa-grpc-client = { version = "0.13.5", path = "rpc/grpc/client" }
kaspa-grpc-core = { version = "0.13.5", path = "rpc/grpc/core" }
kaspa-grpc-server = { version = "0.13.5", path = "rpc/grpc/server" }
kaspa-hashes = { version = "0.13.5", path = "crypto/hashes" }
kaspa-index-core = { version = "0.13.5", path = "indexes/core" }
kaspa-index-processor = { version = "0.13.5", path = "indexes/processor" }
kaspa-math = { version = "0.13.5", path = "math" }
kaspa-merkle = { version = "0.13.5", path = "crypto/merkle" }
kaspa-metrics-core = { version = "0.13.5", path = "metrics/core" }
kaspa-mining = { version = "0.13.5", path = "mining" }
kaspa-mining-errors = { version = "0.13.5", path = "mining/errors" }
kaspa-muhash = { version = "0.13.5", path = "crypto/muhash" }
kaspa-notify = { version = "0.13.5", path = "notify" }
kaspa-os = { version = "0.13.5", path = "kaspa-os" }
kaspa-p2p-flows = { version = "0.13.5", path = "protocol/flows" }
kaspa-p2p-lib = { version = "0.13.5", path = "protocol/p2p" }
kaspa-perf-monitor = { version = "0.13.5", path = "metrics/perf_monitor" }
kaspa-pow = { version = "0.13.5", path = "consensus/pow" }
kaspa-rpc-core = { version = "0.13.5", path = "rpc/core" }
kaspa-rpc-macros = { version = "0.13.5", path = "rpc/macros" }
kaspa-rpc-service = { version = "0.13.5", path = "rpc/service" }
kaspa-txscript = { version = "0.13.5", path = "crypto/txscript" }
kaspa-txscript-errors = { version = "0.13.5", path = "crypto/txscript/errors" }
kaspa-utils = { version = "0.13.5", path = "utils" }
kaspa-utils-tower = { version = "0.13.5", path = "utils/tower" }
kaspa-utxoindex = { version = "0.13.5", path = "indexes/utxoindex" }
kaspa-wallet = { version = "0.13.5", path = "wallet/native" }
kaspa-wallet-cli-wasm = { version = "0.13.5", path = "wallet/wasm" }
kaspa-wallet-core = { version = "0.13.5", path = "wallet/core" }
kaspa-wallet-macros = { version = "0.13.5", path = "wallet/macros" }
kaspa-wasm = { version = "0.13.5", path = "wasm" }
kaspa-wrpc-client = { version = "0.13.5", path = "rpc/wrpc/client" }
kaspa-wrpc-core = { version = "0.13.5", path = "rpc/wrpc/core" }
kaspa-wrpc-proxy = { version = "0.13.5", path = "rpc/wrpc/proxy" }
kaspa-wrpc-server = { version = "0.13.5", path = "rpc/wrpc/server" }
kaspa-wrpc-wasm = { version = "0.13.5", path = "rpc/wrpc/wasm" }
kaspad = { version = "0.13.5", path = "kaspad" }
kaspa-alloc = { version = "0.13.5", path = "utils/alloc" }


# external
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,33 @@ The framework is compatible with all major desktop and mobile browsers.
cargo run --release --bin kaspad -- --testnet
```
<details>
<summary>
Use a configuration file
</summary>
```bash
cargo run --release --bin kaspad -- --configfile /path/to/configfile.toml
# or
cargo run --release --bin kaspad -- -C /path/to/configfile.toml
```
The config file should be a list of \<CLI argument\> = \<value\> separated by newlines.
For example:
```
testnet=true
utxoindex=false
disable-upnp=true
perf-metrics=true
appdir="some-dir"
testnet-suffix=11
```
note that some arguments have no space between words and some use kebab-case, pass the --help flag to view all possible arguments
```bash
cargo run --release --bin kaspad -- --help
```
</details>
<details>
Expand Down
15 changes: 12 additions & 3 deletions consensus/src/processes/difficulty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ trait DifficultyManagerExtension {
pub struct FullDifficultyManager<T: HeaderStoreReader> {
headers_store: Arc<T>,
genesis_bits: u32,
max_difficulty_target: Uint320,
difficulty_window_size: usize,
min_difficulty_window_len: usize,
target_time_per_block: u64,
Expand All @@ -89,12 +90,20 @@ impl<T: HeaderStoreReader> FullDifficultyManager<T> {
pub fn new(
headers_store: Arc<T>,
genesis_bits: u32,
max_difficulty_target: Uint256,
difficulty_window_size: usize,
min_difficulty_window_len: usize,
target_time_per_block: u64,
) -> Self {
Self::check_min_difficulty_window_len(difficulty_window_size, min_difficulty_window_len);
Self { headers_store, genesis_bits, difficulty_window_size, min_difficulty_window_len, target_time_per_block }
Self {
headers_store,
genesis_bits,
max_difficulty_target: max_difficulty_target.into(),
difficulty_window_size,
min_difficulty_window_len,
target_time_per_block,
}
}

pub fn calc_daa_score_and_mergeset_non_daa_blocks<'a>(
Expand Down Expand Up @@ -141,7 +150,7 @@ impl<T: HeaderStoreReader> FullDifficultyManager<T> {
difficulty_blocks.into_iter().map(|diff_block| Uint320::from(Uint256::from_compact_target_bits(diff_block.bits))).sum();
let average_target = targets_sum / (difficulty_blocks_len);
let new_target = average_target * max(max_ts - min_ts, 1) / (self.target_time_per_block * difficulty_blocks_len);
Uint256::try_from(new_target).expect("Expected target should be less than 2^256").compact_target_bits()
Uint256::try_from(new_target.min(self.max_difficulty_target)).expect("max target < Uint256::MAX").compact_target_bits()
}

pub fn estimate_network_hashes_per_second(&self, window: &BlockWindowHeap) -> DifficultyResult<u64> {
Expand Down Expand Up @@ -247,7 +256,7 @@ impl<T: HeaderStoreReader> SampledDifficultyManager<T> {
let measured_duration = max(max_ts - min_ts, 1);
let expected_duration = self.target_time_per_block * self.difficulty_sample_rate * difficulty_blocks_len; // This does differ from FullDifficultyManager version
let new_target = average_target * measured_duration / expected_duration;
Uint256::try_from(new_target.min(self.max_difficulty_target)).unwrap().compact_target_bits()
Uint256::try_from(new_target.min(self.max_difficulty_target)).expect("max target < Uint256::MAX").compact_target_bits()
}

pub fn estimate_network_hashes_per_second(&self, window: &BlockWindowHeap) -> DifficultyResult<u64> {
Expand Down
3 changes: 3 additions & 0 deletions consensus/src/processes/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl<T: GhostdagStoreReader, U: BlockWindowCacheReader, V: HeaderStoreReader> Fu
headers_store: Arc<V>,
block_window_cache_for_difficulty: Arc<U>,
block_window_cache_for_past_median_time: Arc<U>,
max_difficulty_target: Uint256,
target_time_per_block: u64,
difficulty_window_size: usize,
min_difficulty_window_len: usize,
Expand All @@ -84,6 +85,7 @@ impl<T: GhostdagStoreReader, U: BlockWindowCacheReader, V: HeaderStoreReader> Fu
let difficulty_manager = FullDifficultyManager::new(
headers_store.clone(),
genesis.bits,
max_difficulty_target,
difficulty_window_size,
min_difficulty_window_len,
target_time_per_block,
Expand Down Expand Up @@ -554,6 +556,7 @@ impl<T: GhostdagStoreReader, U: BlockWindowCacheReader, V: HeaderStoreReader, W:
headers_store.clone(),
block_window_cache_for_difficulty.clone(),
block_window_cache_for_past_median_time.clone(),
max_difficulty_target,
target_time_per_block,
full_difficulty_window_size,
min_difficulty_window_len.min(full_difficulty_window_size),
Expand Down
2 changes: 2 additions & 0 deletions kaspad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ kaspa-wrpc-server.workspace = true
async-channel.workspace = true
clap.workspace = true
dhat = { workspace = true, optional = true }
serde.workspace = true
dirs.workspace = true
futures-util.workspace = true
log.workspace = true
Expand All @@ -51,6 +52,7 @@ tempfile.workspace = true
thiserror.workspace = true
tokio = { workspace = true, features = ["rt", "macros", "rt-multi-thread"] }
workflow-log.workspace = true
toml = "0.8.10"

[features]
heap = ["dhat", "kaspa-alloc/heap"]
Expand Down
Loading

0 comments on commit 4279555

Please sign in to comment.