Skip to content

Commit 5f66b20

Browse files
feat: Deterministic Masternode List and Quorum Rotation (DIP24) support (#51)
1 parent 811e0cf commit 5f66b20

Some content is hidden

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

80 files changed

+4959
-130
lines changed

.github/workflows/fuzz.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
steps:
4040
- name: Install test dependencies
4141
run: sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev
42-
- uses: actions/checkout@v2
43-
- uses: actions/cache@v2
42+
- uses: actions/checkout@v4
43+
- uses: actions/cache@v4
4444
id: cache-fuzz
4545
with:
4646
path: |
@@ -50,13 +50,13 @@ jobs:
5050
key: cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
5151
- uses: actions-rs/toolchain@v1
5252
with:
53-
toolchain: 1.65
53+
toolchain: 1.80
5454
override: true
5555
profile: minimal
5656
- name: fuzz
5757
run: cd fuzz && ./fuzz.sh "${{ matrix.fuzz_target }}"
5858
- run: echo "${{ matrix.fuzz_target }}" >executed_${{ matrix.fuzz_target }}
59-
- uses: actions/upload-artifact@v2
59+
- uses: actions/upload-artifact@v4
6060
with:
6161
name: executed_${{ matrix.fuzz_target }}
6262
path: executed_${{ matrix.fuzz_target }}
@@ -66,8 +66,8 @@ jobs:
6666
needs: fuzz
6767
runs-on: ubuntu-latest
6868
steps:
69-
- uses: actions/checkout@v2
70-
- uses: actions/download-artifact@v2
69+
- uses: actions/checkout@v4
70+
- uses: actions/download-artifact@v4
7171
- name: Display structure of downloaded files
7272
run: ls -R
7373
- run: find executed_* -type f -exec cat {} + | sort > executed

.github/workflows/rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ jobs:
2626
AS_DEPENDENCY: true
2727
DO_NO_STD: false
2828
DO_DOCS: true
29-
- rust: 1.65.0
29+
- rust: 1.80.0
3030
env:
3131
AS_DEPENDENCY: true
3232
steps:
3333
- name: Checkout Crate
34-
uses: actions/checkout@v2
34+
uses: actions/checkout@v4
3535
- name: Checkout Toolchain
3636
uses: actions-rs/toolchain@v1
3737
with:

Cargo.lock

Lines changed: 75 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
members = ["dash", "hashes", "internals", "fuzz"]
3+
resolver = "2"
34

45
[patch.crates-io.dashcore_hashes]
56
path = "hashes"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ architectural mismatches.
6666

6767
## Minimum Supported Rust Version (MSRV)
6868

69-
This library should always compile with any combination of features on **Rust 1.60**.
69+
This library should always compile with any combination of features on **Rust 1.80**.
7070

7171
## Installing Rust
7272

dash/Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dashcore"
3-
version = "0.35.0"
3+
version = "0.36.0"
44
authors = [
55
"Samuel Westrich <sam@dash.org>",
66
"Anton Suprunchuk <anton@dash.org>",
@@ -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", "core-block-hash-use-x11" ]
22+
default = [ "std", "secp-recovery", "bincode", "quorum_validation" ]
2323
base64 = [ "base64-compat" ]
2424
rand-std = ["secp256k1/rand"]
2525
rand = ["secp256k1/rand"]
@@ -30,6 +30,8 @@ signer = ["secp-recovery", "rand"]
3030
core-block-hash-use-x11 = ["dashcore_hashes/x11"]
3131
bls = ["blsful"]
3232
eddsa = ["ed25519-dalek"]
33+
quorum_validation = ["bls"]
34+
bincode = [ "dep:bincode", "dashcore_hashes/bincode" ]
3335

3436
# At least one of std, no-std must be enabled.
3537
#
@@ -61,11 +63,14 @@ anyhow = { version= "1.0" }
6163
hex = { version= "0.4" }
6264
bincode = { version= "2.0.0-rc.3", optional = true }
6365
bitflags = "2.6.0"
64-
blsful = { version = "3.0.0-pre8", optional = true }
66+
blsful = { version = "3.0.0-pre6", optional = true }
6567
serde_repr = "0.1.19"
6668
strum = { version = "0.26", features = ["derive"] }
6769
lazy_static = "1.5.0"
6870
ed25519-dalek = { version = "2.1", features = ["rand_core"], optional = true }
71+
blake3 = "1.5"
72+
thiserror = "1"
73+
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", branch = "develop" }
6974

7075
[dev-dependencies]
7176
serde_json = "1.0.96"

dash/src/blockdata/script/owned.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#[cfg(doc)]
55
use core::ops::Deref;
66

7+
#[cfg(feature = "bincode")]
8+
use bincode::{Decode, Encode};
79
use hashes::hex;
810
use secp256k1::{Secp256k1, Verification};
911

@@ -26,6 +28,7 @@ use crate::taproot::TapNodeHash;
2628
///
2729
/// [deref coercions]: https://doc.rust-lang.org/std/ops/trait.Deref.html#more-on-deref-coercion
2830
#[derive(Default, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
31+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
2932
pub struct ScriptBuf(pub Vec<u8>);
3033

3134
impl ScriptBuf {

dash/src/blockdata/transaction/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ pub mod txout;
3434

3535
use core::default::Default;
3636

37+
#[cfg(feature = "bincode")]
38+
use bincode::{Decode, Encode};
3739
use hashes::{Hash, sha256d};
3840

3941
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
@@ -158,6 +160,7 @@ impl<E> EncodeSigningDataResult<E> {
158160
/// We therefore deviate from the spec by always using the Segwit witness encoding
159161
/// for 0-input transactions, which results in unambiguously parseable transactions.
160162
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
163+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
161164
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
162165
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
163166
pub struct Transaction {
@@ -911,6 +914,8 @@ mod tests {
911914
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
912915
use crate::consensus::encode::{deserialize, serialize};
913916
use crate::internal_macros::hex;
917+
use crate::network::message::{NetworkMessage, RawNetworkMessage};
918+
use crate::network::message_sml::MnListDiff;
914919

915920
#[test]
916921
fn test_is_coinbase() {
@@ -1253,6 +1258,18 @@ mod tests {
12531258
assert_eq!(data.len(), 20);
12541259
assert_eq!(&data, &pk_data.as_slice());
12551260
}
1261+
1262+
#[test]
1263+
fn deserialize_serialize_coinbase_transaction_in_dml() {
1264+
let block_hex = include_str!("../../../tests/data/test_DML_diffs/DML_0_2221605.hex");
1265+
let data = hex::decode(block_hex).expect("decode hex");
1266+
let mn_list_diff: RawNetworkMessage = deserialize(&data).expect("deserialize MnListDiff");
1267+
if let NetworkMessage::MnListDiff(diff) = mn_list_diff.payload {
1268+
let serialized = serialize(&diff.coinbase_tx);
1269+
let deserialized: Transaction =
1270+
deserialize(serialized.as_slice()).expect("expected to deserialize");
1271+
}
1272+
}
12561273
}
12571274

12581275
#[cfg(all(test, feature = "unstable"))]

dash/src/blockdata/transaction/outpoint.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use core::fmt;
2424
#[cfg(feature = "std")]
2525
use std::error;
2626

27+
#[cfg(feature = "bincode")]
28+
use bincode::{Decode, Encode};
2729
use hashes::{self, Hash};
2830

2931
use crate::consensus::{Decodable, Encodable, deserialize, encode};
@@ -32,6 +34,7 @@ use crate::io;
3234

3335
/// A reference to a transaction output.
3436
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
37+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
3538
pub struct OutPoint {
3639
/// The referenced transaction's txid.
3740
pub txid: Txid,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
//!
2323
//! The special transaction type used for AssetLockTx Transactions is 8.
2424
25+
#[cfg(feature = "bincode")]
26+
use bincode::{Decode, Encode};
27+
2528
use crate::consensus::{Decodable, Encodable, encode};
2629
use crate::prelude::*;
2730
use crate::transaction::txout::TxOut;
@@ -35,6 +38,7 @@ use crate::{VarInt, io};
3538
/// Each TxOut refers to a funding of an Identity.
3639
///
3740
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
41+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
3842
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
3943
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
4044
pub struct AssetLockPayload {

0 commit comments

Comments
 (0)