Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gd tn11 uni #88

Open
wants to merge 51 commits into
base: omega-gd
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5d3b10f
Refactor pruning proof validation to many functions
coderofstuff Jun 4, 2024
40f1cc9
Use blue score as work for higher levels
coderofstuff Jun 4, 2024
4af6773
Remove pruning processor dependency on gd managers
coderofstuff Jun 4, 2024
1df5a22
Consistency renaming
coderofstuff Jun 4, 2024
d12592c
Update db version
coderofstuff Jun 4, 2024
2bea765
GD Optimizations
coderofstuff Jun 4, 2024
902b217
Remove remnant of old impl. optimize db prefixes
coderofstuff Jun 4, 2024
7f1f412
Ensure parents are in relations; Add comments
coderofstuff Jun 19, 2024
f49478a
Match depth check to block_at_depth logic
coderofstuff Jun 19, 2024
879c135
Use singular GD store for header processing
coderofstuff Jun 19, 2024
56c0b40
Relax the panic to warn when finished_headers and couldn't find suffi…
coderofstuff Jun 12, 2024
43e9f9e
Error handling for gd on higher levels
coderofstuff Jun 19, 2024
34f20ab
remove using deeper requirements in lower levels
coderofstuff Jun 15, 2024
2654b25
Fix missed references to self.ghostdag_stores in validate_pruning_poi…
coderofstuff Jun 18, 2024
ba04929
Refactoring for single GD header processing
coderofstuff Jun 19, 2024
a45b571
Add assertion to check root vs old_root
coderofstuff Jun 19, 2024
edb5cd3
Lint fix current_dag_level
coderofstuff Jun 19, 2024
e81394f
Keep DB Version at 3
coderofstuff Jun 19, 2024
0e8c788
Cleanup apply_proof logic and handle more ghostdag_stores logic
coderofstuff Jun 19, 2024
56f9dab
remove simpa changes
coderofstuff Jun 19, 2024
c5be8ad
Remove rewriting origin to primary GD
coderofstuff Jun 19, 2024
8d15e27
More refactoring to use single GD store/manager
coderofstuff Jun 19, 2024
1c6b585
Lint fixes
coderofstuff Jun 21, 2024
273aa81
warn to trace for common retry
coderofstuff Jun 21, 2024
f9b3fda
Address initial comments
coderofstuff Jun 26, 2024
ca8bb42
Remove "primary" in ghostdag store/manager references
coderofstuff Jun 26, 2024
61183fa
Add small safety margin to proof at level 0
coderofstuff Jun 27, 2024
34bc88f
Revert to only do proof rebuilding on sanity check
coderofstuff Jun 29, 2024
da1cfe3
Proper "better" proof check
coderofstuff Jun 29, 2024
a23d1dd
Update comment on find_selected_parent_header_at_level
coderofstuff Jul 5, 2024
974d200
Re-apply missed comment
coderofstuff Jul 5, 2024
6ea8328
Implement db upgrade logic from 3 to 4
coderofstuff Jul 4, 2024
f8baf69
Explain further the workaround for GD ordering.rs
coderofstuff Jul 10, 2024
4f6ad73
Minor update to Display of TempGD keys
coderofstuff Jul 10, 2024
bc56e65
Various fixes
coderofstuff Jul 10, 2024
b917e21
Squashed commit of the following:
michaelsutton Jul 14, 2024
99eed7c
Squashed commit of the following:
michaelsutton Jul 14, 2024
d41073b
Squashed commit of the following:
michaelsutton Jul 14, 2024
9e9b1da
increase caches (reachability sets is the most important)
michaelsutton Jul 14, 2024
e65789d
experiment with reachability alg consts
michaelsutton Jul 14, 2024
cd5dad1
optimize low levels (turned out to be negligible)
michaelsutton Jul 14, 2024
4452295
count utxo entries
michaelsutton Jul 14, 2024
4e97811
reduce log verbosity
michaelsutton Jul 14, 2024
24f86b9
fix an edge case important for tests
michaelsutton Jul 14, 2024
240c3ad
relax proof revalidation requirement
michaelsutton Jul 14, 2024
3999050
patch proof validation (disallowed for mainnet)
michaelsutton Jul 14, 2024
efbb083
Revert "Various fixes"
coderofstuff Jul 14, 2024
eba3448
Merge branch 'gd-optimization' into gd-tn11-uni
michaelsutton Jul 14, 2024
fde1d7c
lint
michaelsutton Jul 14, 2024
b393777
increase pruning depth so that new reachability depth is covered
michaelsutton Jul 14, 2024
aad317d
chain depth of 100 is sufficient
michaelsutton Jul 15, 2024
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
168 changes: 111 additions & 57 deletions Cargo.lock

Large diffs are not rendered by default.

118 changes: 61 additions & 57 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"wallet/wasm",
"wallet/bip32",
"wallet/keys",
"wallet/pskt",
"consensus",
"consensus/core",
"consensus/client",
Expand Down Expand Up @@ -62,7 +63,7 @@ members = [

[workspace.package]
rust-version = "1.78.0"
version = "0.14.1"
version = "0.14.2"
authors = ["Kaspa developers"]
license = "ISC"
repository = "https://github.com/kaspanet/rusty-kaspa"
Expand All @@ -79,62 +80,63 @@ include = [
]

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

# external
aes = "0.8.3"
Expand Down Expand Up @@ -162,6 +164,7 @@ ctrlc = "3.4.1"
crypto_box = { version = "0.9.1", features = ["chacha20"] }
dashmap = "5.5.3"
derivative = "2.2.0"
derive_builder = "0.20.0"
derive_more = "0.99.17"
dhat = "0.3.2"
dirs = "5.0.1"
Expand Down Expand Up @@ -228,6 +231,7 @@ serde = { version = "1.0.190", features = ["derive", "rc"] }
serde_bytes = "0.11.12"
serde_json = "1.0.107"
serde_repr = "0.1.18"
serde-value = "0.7.0"
serde-wasm-bindgen = "0.6.1"
sha1 = "0.10.6"
sha2 = "0.10.8"
Expand Down
5 changes: 5 additions & 0 deletions consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,16 @@ serde_json.workspace = true
flate2.workspace = true
rand_distr.workspace = true
kaspa-txscript-errors.workspace = true
kaspa-addresses.workspace = true

[[bench]]
name = "hash_benchmarks"
harness = false

[[bench]]
name = "check_scripts"
harness = false

[features]
html_reports = []
devnet-prealloc = ["kaspa-consensus-core/devnet-prealloc"]
126 changes: 126 additions & 0 deletions consensus/benches/check_scripts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion, SamplingMode};
use kaspa_addresses::{Address, Prefix, Version};
use kaspa_consensus::processes::transaction_validator::transaction_validator_populated::{
check_scripts_par_iter, check_scripts_par_iter_thread, check_scripts_single_threaded,
};
use kaspa_consensus_core::hashing::sighash::{calc_schnorr_signature_hash, SigHashReusedValuesUnsync};
use kaspa_consensus_core::hashing::sighash_type::SIG_HASH_ALL;
use kaspa_consensus_core::subnets::SubnetworkId;
use kaspa_consensus_core::tx::{MutableTransaction, Transaction, TransactionInput, TransactionOutpoint, UtxoEntry};
use kaspa_txscript::caches::Cache;
use kaspa_txscript::pay_to_address_script;
use rand::{thread_rng, Rng};
use secp256k1::Keypair;
use std::thread::available_parallelism;

// You may need to add more detailed mocks depending on your actual code.
fn mock_tx(inputs_count: usize, non_uniq_signatures: usize) -> (Transaction, Vec<UtxoEntry>) {
let reused_values = SigHashReusedValuesUnsync::new();
let dummy_prev_out = TransactionOutpoint::new(kaspa_hashes::Hash::from_u64_word(1), 1);
let mut tx = Transaction::new(
0,
vec![],
vec![],
0,
SubnetworkId::from_bytes([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
0,
vec![],
);
let mut utxos = vec![];
let mut kps = vec![];
for _ in 0..inputs_count - non_uniq_signatures {
let kp = Keypair::new(secp256k1::SECP256K1, &mut thread_rng());
tx.inputs.push(TransactionInput { previous_outpoint: dummy_prev_out, signature_script: vec![], sequence: 0, sig_op_count: 1 });
let address = Address::new(Prefix::Mainnet, Version::PubKey, &kp.x_only_public_key().0.serialize());
utxos.push(UtxoEntry {
amount: thread_rng().gen::<u32>() as u64,
script_public_key: pay_to_address_script(&address),
block_daa_score: 333,
is_coinbase: false,
});
kps.push(kp);
}
for _ in 0..non_uniq_signatures {
let kp = kps.last().unwrap();
tx.inputs.push(TransactionInput { previous_outpoint: dummy_prev_out, signature_script: vec![], sequence: 0, sig_op_count: 1 });
let address = Address::new(Prefix::Mainnet, Version::PubKey, &kp.x_only_public_key().0.serialize());
utxos.push(UtxoEntry {
amount: thread_rng().gen::<u32>() as u64,
script_public_key: pay_to_address_script(&address),
block_daa_score: 444,
is_coinbase: false,
});
}
for (i, kp) in kps.iter().enumerate().take(inputs_count - non_uniq_signatures) {
let mut_tx = MutableTransaction::with_entries(&tx, utxos.clone());
let sig_hash = calc_schnorr_signature_hash(&mut_tx.as_verifiable(), i, SIG_HASH_ALL, &reused_values);
let msg = secp256k1::Message::from_digest_slice(sig_hash.as_bytes().as_slice()).unwrap();
let sig: [u8; 64] = *kp.sign_schnorr(msg).as_ref();
// This represents OP_DATA_65 <SIGNATURE+SIGHASH_TYPE> (since signature length is 64 bytes and SIGHASH_TYPE is one byte)
tx.inputs[i].signature_script = std::iter::once(65u8).chain(sig).chain([SIG_HASH_ALL.to_u8()]).collect();
}
let length = tx.inputs.len();
for i in (inputs_count - non_uniq_signatures)..length {
let kp = kps.last().unwrap();
let mut_tx = MutableTransaction::with_entries(&tx, utxos.clone());
let sig_hash = calc_schnorr_signature_hash(&mut_tx.as_verifiable(), i, SIG_HASH_ALL, &reused_values);
let msg = secp256k1::Message::from_digest_slice(sig_hash.as_bytes().as_slice()).unwrap();
let sig: [u8; 64] = *kp.sign_schnorr(msg).as_ref();
// This represents OP_DATA_65 <SIGNATURE+SIGHASH_TYPE> (since signature length is 64 bytes and SIGHASH_TYPE is one byte)
tx.inputs[i].signature_script = std::iter::once(65u8).chain(sig).chain([SIG_HASH_ALL.to_u8()]).collect();
}
(tx, utxos)
}

fn benchmark_check_scripts(c: &mut Criterion) {
for inputs_count in [100, 50, 25, 10, 5, 2] {
for non_uniq_signatures in [0, inputs_count / 2] {
let (tx, utxos) = mock_tx(inputs_count, non_uniq_signatures);
let mut group = c.benchmark_group(format!("inputs: {inputs_count}, non uniq: {non_uniq_signatures}"));
group.sampling_mode(SamplingMode::Flat);

group.bench_function("single_thread", |b| {
let tx = MutableTransaction::with_entries(&tx, utxos.clone());
let cache = Cache::new(inputs_count as u64);
b.iter(|| {
cache.map.write().clear();
check_scripts_single_threaded(black_box(&cache), black_box(&tx.as_verifiable())).unwrap();
})
});

group.bench_function("rayon par iter", |b| {
let tx = MutableTransaction::with_entries(tx.clone(), utxos.clone());
let cache = Cache::new(inputs_count as u64);
b.iter(|| {
cache.map.write().clear();
check_scripts_par_iter(black_box(&cache), black_box(&tx.as_verifiable())).unwrap();
})
});

for i in (2..=available_parallelism().unwrap().get()).step_by(2) {
if inputs_count >= i {
group.bench_function(&format!("rayon, custom threadpool, thread count {i}"), |b| {
let tx = MutableTransaction::with_entries(tx.clone(), utxos.clone());
let cache = Cache::new(inputs_count as u64);
let pool = rayon::ThreadPoolBuilder::new().num_threads(i).build().unwrap();
b.iter(|| {
// Create a custom thread pool with the specified number of threads
cache.map.write().clear();
check_scripts_par_iter_thread(black_box(&cache), black_box(&tx.as_verifiable()), black_box(&pool))
.unwrap();
})
});
}
}
}
}
}

criterion_group! {
name = benches;
// This can be any expression that returns a `Criterion` object.
config = Criterion::default().with_output_color(true).measurement_time(std::time::Duration::new(20, 0));
targets = benchmark_check_scripts
}

criterion_main!(benches);
6 changes: 3 additions & 3 deletions consensus/client/src/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::iter::once;
use itertools::Itertools;
use kaspa_consensus_core::{
hashing::{
sighash::{calc_schnorr_signature_hash, SigHashReusedValues},
sighash::{calc_schnorr_signature_hash, SigHashReusedValuesUnsync},
sighash_type::SIG_HASH_ALL,
},
tx::PopulatedTransaction,
Expand Down Expand Up @@ -40,7 +40,7 @@ pub fn sign_with_multiple_v3(tx: Transaction, privkeys: &[[u8; 32]]) -> crate::r
map.insert(script_pub_key_script, schnorr_key);
}

let mut reused_values = SigHashReusedValues::new();
let reused_values = SigHashReusedValuesUnsync::new();
let mut additional_signatures_required = false;
{
let input_len = tx.inner().inputs.len();
Expand All @@ -55,7 +55,7 @@ pub fn sign_with_multiple_v3(tx: Transaction, privkeys: &[[u8; 32]]) -> crate::r
};
let script = script_pub_key.script();
if let Some(schnorr_key) = map.get(script) {
let sig_hash = calc_schnorr_signature_hash(&populated_transaction, i, SIG_HASH_ALL, &mut reused_values);
let sig_hash = calc_schnorr_signature_hash(&populated_transaction, i, SIG_HASH_ALL, &reused_values);
let msg = secp256k1::Message::from_digest_slice(sig_hash.as_bytes().as_slice()).unwrap();
let sig: [u8; 64] = *schnorr_key.sign_schnorr(msg).as_ref();
// This represents OP_DATA_65 <SIGNATURE+SIGHASH_TYPE> (since signature length is 64 bytes and SIGHASH_TYPE is one byte)
Expand Down
10 changes: 5 additions & 5 deletions consensus/client/src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl SigHashCache {
}
}

pub fn sig_op_counts_hash(&mut self, tx: &Transaction, hash_type: SigHashType, reused_values: &mut SigHashReusedValues) -> Hash {
pub fn sig_op_counts_hash(&mut self, tx: &Transaction, hash_type: SigHashType, reused_values: &SigHashReusedValues) -> Hash {
if hash_type.is_sighash_anyone_can_pay() {
return ZERO_HASH;
}
Expand Down Expand Up @@ -185,16 +185,16 @@ pub fn calc_schnorr_signature_hash(
let mut hasher = TransactionSigningHash::new();
hasher
.write_u16(tx.version)
.update(previous_outputs_hash(&tx, hash_type, &mut reused_values))
.update(sequences_hash(&tx, hash_type, &mut reused_values))
.update(sig_op_counts_hash(&tx, hash_type, &mut reused_values));
.update(previous_outputs_hash(&tx, hash_type, &reused_values))
.update(sequences_hash(&tx, hash_type, &reused_values))
.update(sig_op_counts_hash(&tx, hash_type, &reused_values));
hash_outpoint(&mut hasher, input.previous_outpoint);
hash_script_public_key(&mut hasher, &utxo.script_public_key);
hasher
.write_u64(utxo.amount)
.write_u64(input.sequence)
.write_u8(input.sig_op_count)
.update(outputs_hash(&tx, hash_type, &mut reused_values, input_index))
.update(outputs_hash(&tx, hash_type, &reused_values, input_index))
.write_u64(tx.lock_time)
.update(&tx.subnetwork_id)
.write_u64(tx.gas)
Expand Down
1 change: 1 addition & 0 deletions consensus/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ wasm32-sdk = []
default = []

[dependencies]
arc-swap.workspace = true
async-trait.workspace = true
borsh.workspace = true
cfg-if.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion consensus/core/src/config/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub mod perf {

/// The default slack interval used by the reachability
/// algorithm to encounter for blocks out of the selected chain.
pub const DEFAULT_REINDEX_SLACK: u64 = 1 << 12;
pub const DEFAULT_REINDEX_SLACK: u64 = 1 << 14;

const BASELINE_HEADER_DATA_CACHE_SIZE: usize = 10_000;
const BASELINE_BLOCK_DATA_CACHE_SIZE: usize = 200;
Expand Down
Loading