Skip to content

Commit 4952631

Browse files
more fixes
1 parent 1c7ef06 commit 4952631

File tree

11 files changed

+37
-33
lines changed

11 files changed

+37
-33
lines changed

dash/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ edition = "2021"
1919

2020
# Please don't forget to add relevant features to docs.rs below
2121
[features]
22-
default = [ "std", "secp-recovery" ]
22+
default = [ "std", "secp-recovery", "bincode", "quorum_validation" ]
2323
base64 = [ "base64-compat" ]
2424
rand-std = ["secp256k1/rand"]
2525
rand = ["secp256k1/rand"]
@@ -80,7 +80,6 @@ secp256k1 = { features = [ "recovery", "rand", "hashes" ], version="0.30.0" }
8080
bip39 = "2.0.0"
8181
bincode_test = {package = "bincode", version= "1.3.3" }
8282
assert_matches = "1.5.0"
83-
bincode = { version= "2.0.0-rc.3"}
8483

8584
[[example]]
8685
name = "bip32"

dash/src/blockdata/transaction/special_transaction/coinbase.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use crate::bls_sig_utils::BLSSignature;
2525
use crate::consensus::encode::{compact_size_len, read_compact_size, write_compact_size};
2626
use crate::consensus::{Decodable, Encodable, encode};
2727
use crate::hash_types::{MerkleRootMasternodeList, MerkleRootQuorums};
28+
use crate::io;
2829
use crate::io::{Error, ErrorKind};
29-
use crate::{VarInt, io};
3030

3131
/// A Coinbase payload. This is contained as the payload of a coinbase special transaction.
3232
/// The Coinbase payload is described in DIP4.

dash/src/blockdata/transaction/special_transaction/quorum_commitment.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
//! It is defined in DIP6 [dip-0006.md](https://github.com/dashpay/dips/blob/master/dip-0006.md).
1818
//!
1919
20-
use std::io::{Read, Write};
21-
2220
#[cfg(feature = "bincode")]
2321
use bincode::{Decode, Encode};
2422

dash/src/bls_sig_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use internals::impl_array_newtype;
2727
use crate::core::fmt;
2828
use crate::internal_macros::impl_bytes_newtype;
2929
use crate::prelude::String;
30+
#[cfg(feature = "bls")]
3031
use crate::sml::quorum_validation_error::QuorumValidationError;
3132

3233
/// A BLS Public key is 48 bytes in the scheme used for Dash Core

dash/src/consensus/serde.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use serde::de::{SeqAccess, Unexpected, Visitor};
1414
use serde::ser::SerializeSeq;
1515
use serde::{Deserializer, Serializer};
1616

17-
use super::encode::{Error as ConsensusError, Error};
17+
use super::encode::Error as ConsensusError;
1818
use super::{Decodable, Encodable};
1919
use crate::alloc::string::ToString;
2020
use crate::io;

dash/src/dip9.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ impl<const N: usize> From<IndexConstPath<N>> for DerivationPath {
6363

6464
impl<const N: usize> IndexConstPath<N> {
6565
pub fn append_path(&self, derivation_path: DerivationPath) -> DerivationPath {
66-
let mut root_derivation_path = DerivationPath::from(self.indexes.as_ref());
66+
let root_derivation_path = DerivationPath::from(self.indexes.as_ref());
6767
root_derivation_path.extend(derivation_path);
6868
root_derivation_path
6969
}
7070

7171
pub fn append(&self, child_number: ChildNumber) -> DerivationPath {
72-
let mut root_derivation_path = DerivationPath::from(self.indexes.as_ref());
72+
let root_derivation_path = DerivationPath::from(self.indexes.as_ref());
7373
root_derivation_path.extend(&[child_number]);
7474
root_derivation_path
7575
}

dash/src/sml/masternode_list/masternode_helpers.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use hashes::Hash;
55

66
use crate::ProTxHash;
77
use crate::sml::masternode_list::MasternodeList;
8-
use crate::sml::masternode_list_entry::MasternodeListEntry;
98
use crate::sml::masternode_list_entry::qualified_masternode_list_entry::QualifiedMasternodeListEntry;
109

1110
impl MasternodeList {

dash/src/sml/masternode_list/merkle_roots.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use hashes::{Hash, sha256d};
22

33
use crate::Transaction;
4-
use crate::hash_types::{MerkleRootMasternodeList, MerkleRootQuorums, QuorumCommitmentHash};
4+
use crate::hash_types::{MerkleRootMasternodeList, MerkleRootQuorums};
55
use crate::sml::masternode_list::MasternodeList;
66
use crate::transaction::special_transaction::TransactionPayload;
77

dash/src/sml/masternode_list_engine/mod.rs

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::network::message_qrinfo::{QRInfo, QuorumSnapshot};
1515
use crate::network::message_sml::MnListDiff;
1616
use crate::prelude::CoreBlockHeight;
1717
use crate::sml::error::SmlError;
18-
use crate::sml::error::SmlError::CorruptedCodeExecution;
1918
use crate::sml::llmq_type::LLMQType;
2019
use crate::sml::masternode_list::MasternodeList;
2120
use crate::sml::masternode_list::from_diff::TryIntoWithBlockHashLookup;
@@ -355,34 +354,41 @@ impl MasternodeListEngine {
355354
Some(diff_end_height) => diff_end_height,
356355
};
357356

358-
let mut masternode_list =
359-
base_masternode_list.apply_diff(masternode_list_diff.clone(), diff_end_height)?;
360-
361357
#[cfg(feature = "quorum_validation")]
362-
if verify_quorums {
363-
// We only need to verify new quorums
364-
for new_quorum in &masternode_list_diff.new_quorums {
365-
let quorum = masternode_list
366-
.quorum_entry_of_type_for_quorum_hash_mut(
367-
new_quorum.llmq_type,
368-
new_quorum.quorum_hash,
369-
)
370-
.ok_or(CorruptedCodeExecution(
371-
"masternode list after diff does not contain new quorum".to_string(),
372-
))?;
373-
self.validate_and_update_quorum_status(quorum);
358+
{
359+
let mut masternode_list =
360+
base_masternode_list.apply_diff(masternode_list_diff.clone(), diff_end_height)?;
361+
if verify_quorums {
362+
// We only need to verify new quorums
363+
for new_quorum in &masternode_list_diff.new_quorums {
364+
let quorum = masternode_list
365+
.quorum_entry_of_type_for_quorum_hash_mut(
366+
new_quorum.llmq_type,
367+
new_quorum.quorum_hash,
368+
)
369+
.ok_or(SmlError::CorruptedCodeExecution(
370+
"masternode list after diff does not contain new quorum".to_string(),
371+
))?;
372+
self.validate_and_update_quorum_status(quorum);
373+
}
374374
}
375+
self.masternode_lists.insert(diff_end_height, masternode_list);
375376
}
377+
376378
#[cfg(not(feature = "quorum_validation"))]
377-
if verify_quorums {
378-
return Err(SmlError::FeatureNotTurnedOn(
379-
"quorum validation feature is not turned on".to_string(),
380-
));
379+
{
380+
let masternode_list =
381+
base_masternode_list.apply_diff(masternode_list_diff.clone(), diff_end_height)?;
382+
if verify_quorums {
383+
return Err(SmlError::FeatureNotTurnedOn(
384+
"quorum validation feature is not turned on".to_string(),
385+
));
386+
}
387+
self.masternode_lists.insert(diff_end_height, masternode_list);
381388
}
382389

383390
self.block_hashes.insert(diff_end_height, block_hash);
384391
self.block_heights.insert(block_hash, diff_end_height);
385-
self.masternode_lists.insert(diff_end_height, masternode_list);
386392

387393
Ok(())
388394
}
@@ -441,6 +447,8 @@ impl MasternodeListEngine {
441447
#[cfg(test)]
442448
mod tests {
443449

450+
use bincode::Decode;
451+
444452
use crate::sml::llmq_entry_verification::LLMQEntryVerificationStatus;
445453
use crate::sml::llmq_type::LLMQType;
446454
use crate::sml::llmq_type::LLMQType::{Llmqtype50_60, Llmqtype400_60, Llmqtype400_85};

dash/src/sml/masternode_list_entry/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::net::SocketAddr;
99
use crate::bls_sig_utils::BLSPublicKey;
1010
use crate::consensus::encode::Error;
1111
use crate::consensus::{Decodable, Encodable};
12-
use crate::hash_types::{ConfirmedHash, Sha256dHash};
12+
use crate::hash_types::ConfirmedHash;
1313
use crate::internal_macros::impl_consensus_encoding;
1414
use crate::{ProTxHash, PubkeyHash};
1515

0 commit comments

Comments
 (0)