Skip to content

feat: basic ferment integration #60

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

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
76b2750
feat: ferment transactions
pankcuf Jan 21, 2025
b070b55
chore: include hashes, make public
pankcuf Jan 21, 2025
7d12f2a
chore: refine TxOut import
pankcuf Jan 21, 2025
dc50bc0
chore: refine txout
pankcuf Jan 21, 2025
be8759c
chore: export instantlock
pankcuf Jan 21, 2025
7dd0282
chore: import vec
pankcuf Jan 21, 2025
eb173d2
chore: remove vec import
pankcuf Jan 21, 2025
4128656
chore: refine islock imports
pankcuf Jan 21, 2025
6f7c7af
chore: hash_newtype + ferment
pankcuf Jan 21, 2025
d16e862
chore: direct fermentation
pankcuf Jan 23, 2025
49dbc11
chore: reset pub hashes
pankcuf Jan 23, 2025
55476ce
chore: reset Hash pub
pankcuf Jan 23, 2025
cd13a23
Merge branch 'master' into feat/ferment
pankcuf Feb 25, 2025
6d62218
chore: update with latest master
pankcuf Feb 25, 2025
16ade0a
chore: llmqtype fermented
pankcuf Feb 25, 2025
26f19af
chore: switch ferment onto master branch
pankcuf Feb 25, 2025
94489ca
chore: tmp switch bls-signature to apple
pankcuf Feb 25, 2025
a28495f
chore: add some ferment exports for masternode lists
pankcuf Feb 25, 2025
fde599b
chore: cargo.lock
pankcuf Feb 25, 2025
6623623
chore: adjust imports for ferment
pankcuf Feb 25, 2025
9ae30cd
Merge branch 'master' into feat/ferment
pankcuf Feb 28, 2025
73b5df6
Merge branch 'master' into feat/ferment
pankcuf Feb 28, 2025
c8b35fd
cleanup of imports
QuantumExplorer Feb 28, 2025
b17e4a4
Merge branch 'master' into feat/ferment
QuantumExplorer Mar 3, 2025
0a7e342
wrapped apple
QuantumExplorer Mar 3, 2025
e6027b9
chore: convert entry_hash sha256d::Hash <-> Sha256dHash
pankcuf Mar 4, 2025
7efb245
fix: sha256d::hash
pankcuf Mar 4, 2025
00ee68c
chore: add find_quorum_public_key method
pankcuf Mar 5, 2025
ead6df7
chore: tmp ferment QuorumSnapshot
pankcuf Mar 5, 2025
beef9fd
chore: export quorum errors
pankcuf Mar 8, 2025
5df4261
chore: pub message_request_verification
pankcuf Mar 8, 2025
de0019c
chore: export chainlock
pankcuf Mar 8, 2025
f9f71da
chore: pub MessageVerificationError
pankcuf Mar 8, 2025
d72b6ef
chore: pub mod prelude
pankcuf Mar 9, 2025
80f14ca
chore: force bincode to 2.0.0-rc.3
pankcuf Mar 9, 2025
59f10e3
chore: bump up bincode to 2.0.0
pankcuf Mar 9, 2025
0a29b27
chore: back to bincode 2.0.0-rc.3
pankcuf Mar 10, 2025
ca6342a
chore: export llmq type helpers
pankcuf Mar 10, 2025
11865a4
chore: add clear method for engine
pankcuf Mar 10, 2025
6bd8705
chore: fix macro
pankcuf Mar 11, 2025
e1a4ebd
chore: change apply_diff return type
pankcuf Mar 11, 2025
841e189
chore: refine quorum entry
pankcuf Mar 11, 2025
4fcb9bc
Merge branch 'master' into feat/ferment
pankcuf Mar 13, 2025
8f2f79c
chore: delete Cargo.lock
pankcuf Mar 13, 2025
8562906
chore: pub dip9
pankcuf Mar 17, 2025
872dc7c
chore: helpers for operatorpublickey
pankcuf Mar 18, 2025
d6b81c7
chore: refine txout imports
pankcuf Mar 19, 2025
a385d58
chore: refine script imports
pankcuf Mar 19, 2025
1c80643
chore: refine typealias
pankcuf Mar 19, 2025
6351ba0
chore: refine txin imports
pankcuf Mar 19, 2025
37ce04e
chore: refine outpoint import
pankcuf Mar 19, 2025
e9590c2
Merge branch 'master' into feat/ferment
pankcuf Mar 25, 2025
1459f41
chore: fix merge
pankcuf Mar 25, 2025
6afc508
Merge branch 'master' into feat/ferment
pankcuf Mar 25, 2025
f748f6e
chore: remove unused constraint
pankcuf Mar 25, 2025
df893fb
chore: oops
pankcuf Mar 25, 2025
c051fcc
chore: export VerifyingChainLockSignaturesType
pankcuf Mar 25, 2025
3899a54
chore: export SMLError
pankcuf Mar 25, 2025
61d8ec5
chore: bls-signatures update
pankcuf Mar 29, 2025
f6c2837
chore: try one trick
pankcuf Apr 1, 2025
534ba33
chore: one more bls trick
pankcuf Apr 1, 2025
aa4e98a
chore: bls with lower ios target
pankcuf Apr 4, 2025
9cd29dd
chore: ferment 0.2
pankcuf Apr 6, 2025
729d5e1
Merge branch 'master' into feat/ferment
pankcuf Apr 8, 2025
f5213fe
chore: update bls-signatures version
pankcuf Apr 8, 2025
1aeeb4b
chore: update bls-signatures
pankcuf Apr 8, 2025
d7ef308
Merge branch 'master' into feat/ferment
pankcuf Apr 10, 2025
ff4a39c
Merge branch 'master' into feat/ferment
pankcuf Apr 14, 2025
eb511ff
chore: fix testnet genesis
pankcuf Apr 16, 2025
7d23770
chore: fix: message impl
pankcuf Apr 16, 2025
6b336b9
chore: add Vec<i32> consensus_encode impl
pankcuf Apr 16, 2025
6dd3799
Merge branch 'master' into feat/ferment
pankcuf Apr 16, 2025
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
8 changes: 5 additions & 3 deletions dash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ eddsa = ["ed25519-dalek"]
quorum_validation = ["bls", "bls-signatures"]
message_verification = ["bls"]
bincode = [ "dep:bincode", "dashcore_hashes/bincode" ]
apple = [ "ferment", "ferment-macro", "bls-signatures/legacy", "bls-signatures/bip32", "bls-signatures/apple", "bls-signatures/use_serde" ]

# At least one of std, no-std must be enabled.
#
Expand Down Expand Up @@ -62,14 +63,15 @@ hex_lit = "0.1.1"
anyhow = { version= "1.0" }
hex = { version= "0.4" }
bincode = { version= "=2.0.0-rc.3", optional = true }
bincode_derive = { version= "=2.0.0-rc.3", optional = true }
bitflags = "2.9.0"
blsful = { version = "3.0.0-pre8", optional = true }
ed25519-dalek = { version = "2.1", features = ["rand_core"], optional = true }
blake3 = "1.8.1"
thiserror = "2"
# version 1.3.5 is 0bb5c5b03249c463debb5cef5f7e52ee66f3aaab
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "0bb5c5b03249c463debb5cef5f7e52ee66f3aaab", optional = true }

bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "a0fec2f4da2bdbb753e6287b0546ae0b08e74e02", optional = true }
ferment = { version = "0.2", package = "ferment", optional = true }
ferment-macro = { version = "0.2", package = "ferment-macro", optional = true }
[dev-dependencies]
serde_json = "1.0.140"
serde_test = "1.0.177"
Expand Down
2 changes: 1 addition & 1 deletion dash/src/bip158.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ mod test {
use serde_json::Value;

use super::*;
use crate::ScriptBuf;
use crate::blockdata::script::ScriptBuf;
use crate::consensus::encode::deserialize;
use crate::hash_types::BlockHash;
use crate::internal_macros::hex;
Expand Down
4 changes: 2 additions & 2 deletions dash/src/blockdata/script/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ use crate::{OutPoint, io};
mod borrowed;
mod builder;
mod instruction;
mod owned;
pub mod owned;
mod push_bytes;
#[cfg(test)]
mod tests;

pub use self::borrowed::*;
pub use self::builder::*;
pub use self::instruction::*;
pub use self::owned::*;
pub use self::owned::ScriptBuf;
pub use self::push_bytes::*;

/// Encodes an integer in script(minimal CScriptNum) format.
Expand Down
1 change: 1 addition & 0 deletions dash/src/blockdata/script/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::taproot::TapNodeHash;
/// [deref coercions]: https://doc.rust-lang.org/std/ops/trait.Deref.html#more-on-deref-coercion
#[derive(Default, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct ScriptBuf(pub Vec<u8>);

impl ScriptBuf {
Expand Down
7 changes: 4 additions & 3 deletions dash/src/blockdata/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use hashes::{Hash, sha256d};
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
#[cfg(feature = "bitcoinconsensus")]
use crate::blockdata::script;
use crate::blockdata::script::Script;
use crate::blockdata::script::{Script, ScriptBuf};
use crate::blockdata::transaction::hash_type::EcdsaSighashType;
use crate::blockdata::transaction::special_transaction::{TransactionPayload, TransactionType};
use crate::blockdata::transaction::txin::TxIn;
Expand All @@ -52,8 +52,8 @@ use crate::consensus::{Decodable, Encodable, encode};
use crate::hash_types::{InputsHash, Txid, Wtxid};
use crate::prelude::*;
use crate::sighash::LegacySighash;
pub use crate::transaction::outpoint::*;
use crate::{ScriptBuf, Weight, io};
pub use self::outpoint::OutPoint;
use crate::{Weight, io};

/// Used for signature hash for invalid use of SIGHASH_SINGLE.
const UINT256_ONE: [u8; 32] = [
Expand Down Expand Up @@ -165,6 +165,7 @@ impl<E> EncodeSigningDataResult<E> {
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct Transaction {
/// The protocol version, is currently expected to be 1 or 2 (BIP 68).
pub version: u16,
Expand Down
1 change: 1 addition & 0 deletions dash/src/blockdata/transaction/outpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use crate::io;
/// A reference to a transaction output.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct OutPoint {
/// The referenced transaction's txid.
pub txid: Txid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use bincode::{Decode, Encode};

use crate::consensus::{Decodable, Encodable, encode};
use crate::prelude::*;
use crate::transaction::txout::TxOut;
use crate::blockdata::transaction::txout::TxOut;
use crate::{VarInt, io};

/// An Asset Lock payload. This is contained as the payload of an asset lock special transaction.
Expand All @@ -41,6 +41,7 @@ use crate::{VarInt, io};
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct AssetLockPayload {
pub version: u8,
pub credit_outputs: Vec<TxOut>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub const ASSET_UNLOCK_TX_SIZE: usize = 190;
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct AssetUnlockPayload {
/// The base information about the asset unlock. This base information is the information that
/// should be put into a queue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use crate::prelude::*;
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct AssetUnlockRequestInfo {
/// The core request height of the transaction. This should match a period where the quorum_hash
/// is still active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@
#[cfg(feature = "bincode")]
use bincode::{Decode, Encode};

use crate::blockdata::script::ScriptBuf;
use crate::blockdata::transaction::special_transaction::TransactionType;
use crate::blockdata::transaction::special_transaction::TransactionType::AssetUnlock;
use crate::blockdata::transaction::txin::TxIn;
use crate::blockdata::transaction::txout::TxOut;
use crate::consensus::{Decodable, Encodable, encode};
use crate::hash_types::{PubkeyHash, ScriptHash};
use crate::prelude::*;
use crate::transaction::TxOut;
use crate::{ScriptBuf, TxIn, VarInt, io};
use crate::{VarInt, io};

/// An Asset Unlock Base payload. This is the base payload of the Asset Unlock. In order to make
/// it a full payload the request info should be added.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct AssetUnlockBasePayload {
/// The payload protocol version, is currently expected to be 0.
pub version: u8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use crate::io::{Error, ErrorKind};
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct CoinbasePayload {
pub version: u16,
pub height: u32,
Expand Down
1 change: 1 addition & 0 deletions dash/src/blockdata/transaction/special_transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub mod quorum_commitment;
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub enum TransactionPayload {
/// A wrapper for a Masternode Registration payload
ProviderRegistrationPayloadType(ProviderRegistrationPayload),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ use hashes::Hash;
use internals::hex::Case::Lower;

use crate::address::Payload;
use crate::blockdata::script::ScriptBuf;
use crate::blockdata::transaction::OutPoint;
use crate::blockdata::transaction::special_transaction::SpecialTransactionBasePayloadEncodable;
use crate::bls_sig_utils::BLSPublicKey;
use crate::consensus::{Decodable, Encodable, encode};
use crate::hash_types::{InputsHash, PubkeyHash, SpecialTransactionPayloadHash};
use crate::prelude::*;
use crate::{Address, Network, OutPoint, ScriptBuf, VarInt, io};
use crate::{Address, Network, VarInt, io};

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, Copy)]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
Expand Down Expand Up @@ -97,6 +99,7 @@ impl Decodable for ProviderMasternodeType {
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct ProviderRegistrationPayload {
pub version: u16,
pub masternode_type: ProviderMasternodeType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
#[cfg(feature = "bincode")]
use bincode::{Decode, Encode};
use hashes::Hash;

use crate::blockdata::script::ScriptBuf;
use crate::blockdata::transaction::special_transaction::SpecialTransactionBasePayloadEncodable;
use crate::bls_sig_utils::BLSPublicKey;
use crate::consensus::{Decodable, Encodable, encode};
use crate::hash_types::{InputsHash, PubkeyHash, SpecialTransactionPayloadHash, Txid};
use crate::prelude::*;
use crate::{ScriptBuf, VarInt, io};
use crate::{VarInt, io};

/// A Provider Update Registrar Payload used in a Provider Update Registrar Special Transaction.
/// This is used to update the base aspects a Masternode on the network.
Expand All @@ -47,6 +47,7 @@ use crate::{ScriptBuf, VarInt, io};
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct ProviderUpdateRegistrarPayload {
pub version: u16,
pub pro_tx_hash: Txid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ use crate::io;
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct ProviderUpdateRevocationPayload {
pub version: u16,
pub pro_tx_hash: Txid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
#[cfg(feature = "bincode")]
use bincode::{Decode, Encode};
use hashes::Hash;

use crate::blockdata::script::ScriptBuf;
use crate::blockdata::transaction::special_transaction::SpecialTransactionBasePayloadEncodable;
use crate::bls_sig_utils::BLSSignature;
use crate::consensus::{Decodable, Encodable, encode};
use crate::hash_types::{InputsHash, SpecialTransactionPayloadHash, Txid};
use crate::{ScriptBuf, VarInt, io};
use crate::{VarInt, io};

/// A Provider Update Service Payload used in a Provider Update Service Special Transaction.
/// This is used to update the operational aspects a Masternode on the network.
Expand All @@ -52,6 +52,7 @@ use crate::{ScriptBuf, VarInt, io};
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct ProviderUpdateServicePayload {
pub version: u16,
pub pro_tx_hash: Txid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use crate::sml::quorum_validation_error::QuorumValidationError;
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct QuorumEntry {
pub version: u16,
pub llmq_type: LLMQType,
Expand Down Expand Up @@ -183,10 +184,11 @@ impl Decodable for QuorumEntry {
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct QuorumCommitmentPayload {
version: u16,
height: u32,
finalization_commitment: QuorumEntry,
pub version: u16,
pub height: u32,
pub finalization_commitment: QuorumEntry,
}

impl QuorumCommitmentPayload {
Expand Down
8 changes: 5 additions & 3 deletions dash/src/blockdata/transaction/txin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
use bincode::{Decode, Encode};

use crate::blockdata::script::ScriptBuf;
use crate::consensus::{Decodable, Encodable, encode};
use crate::transaction::outpoint::OutPoint;
use crate::{Witness, io};
use crate::blockdata::transaction::outpoint::OutPoint;
use crate::blockdata::witness::Witness;
use crate::consensus::{encode, Decodable, Encodable};
use crate::io;

/// A transaction input, which defines old coins to be consumed
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct TxIn {
/// The reference to the previous output that is being used an an input.
pub previous_output: OutPoint,
Expand Down
5 changes: 4 additions & 1 deletion dash/src/blockdata/transaction/txout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
use bincode::{Decode, Encode};

use crate::internal_macros::impl_consensus_encoding;
use crate::{Address, PubkeyHash, ScriptBuf, ScriptHash, VarInt};
use crate::{Address, VarInt};
use crate::blockdata::script::ScriptBuf;
use crate::hash_types::{PubkeyHash, ScriptHash};

/// A transaction output, which defines new coins to be created from old ones.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct TxOut {
/// The value of the output, in satoshis.
pub value: u64,
Expand Down
7 changes: 4 additions & 3 deletions dash/src/blockdata/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,21 @@ use crate::{Script, VarInt};
/// [segwit upgrade]: <https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki>
#[derive(Clone, Default, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Attribution addition for ferment integration matches other similar changes.

The addition of the #[cfg_attr(feature = "apple", ferment_macro::export)] attribute aligns with the overall PR objective of integrating with ferment when the "apple" feature flag is enabled.

Looking at the previous review comment, there's a concern about testing the ferment serialization of the Witness struct. Let's verify if any tests have been added since that comment:


🏁 Script executed:

#!/bin/bash
# Search for tests that verify ferment serialization of Witness

echo "Looking for existing tests for ferment serialization of Witness"
rg -l "ferment.*Witness" --type rust

echo "Checking for test files that might contain ferment serialization tests"
rg -l "test.*ferment.*witness" --type rust -i

echo "Looking for ferment-related serialization tests"
rg -l "test.*serialize.*ferment" --type rust -i

Length of output: 529


Action Required: Add Tests for Ferment Serialization of the Witness Struct

The new attribute #[cfg_attr(feature = "apple", ferment_macro::export)] is in line with similar changes across the codebase, which is great. However, our current search did not uncover any tests verifying the ferment serialization of the Witness struct. To ensure that this integration behaves as expected when the "apple" feature is enabled, please add tests covering this functionality or point to where such tests exist if they’ve been added elsewhere.

  • File: dash/src/blockdata/witness.rs (line 35)

pub struct Witness {
/// Contains the witness `Vec<Vec<u8>>` serialization without the initial varint indicating the
/// number of elements (which is stored in `witness_elements`).
content: Vec<u8>,
pub content: Vec<u8>,

/// The number of elements in the witness.
///
/// Stored separately (instead of as a VarInt in the initial part of content) so that methods
/// like [`Witness::push`] don't have to shift the entire array.
witness_elements: usize,
pub witness_elements: usize,

/// This is the valid index pointing to the beginning of the index area. This area is 4 *
/// stack_size bytes at the end of the content vector which stores the indices of each item.
indices_start: usize,
pub indices_start: usize,
Comment on lines +35 to +49
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify serialization behavior with the ferment integration

The export attribute and field visibility changes suggest that this struct will be serialized/deserialized by ferment when the "apple" feature is enabled. Ensure that the serialized representation correctly handles the complex internal structure of the Witness struct.


🏁 Script executed:

#!/bin/bash
# Look for tests that verify the ferment serialization/deserialization of Witness

echo "Checking for tests related to ferment serialization of Witness"
rg -l "ferment.*Witness" --type rust

echo "Checking for ferment-related attributes in the codebase"
rg -A 2 -B 2 "#\[cfg_attr\(feature = \"apple\", ferment_macro::export\)\]" --type rust

echo "Checking for other structs with similar changes"
rg -l "pub content: Vec<u8>" --type rust

Length of output: 15635


Action Required: Add explicit tests for ferment serialization of Witness

After verifying the repository, we noticed that while multiple structs (e.g., those in instant_lock.rs, bls_sig_utils.rs, etc.) use the #[cfg_attr(feature = "apple", ferment_macro::export)] attribute, no dedicated tests were found confirming that the Witness struct’s serialized representation is correctly handled by the ferment integration. This could lead to potential issues with the complex serialization of fields like content, witness_elements, and indices_start.

Recommendations:

  • Add unit or integration tests specifically for the Witness struct (in dash/src/blockdata/witness.rs) to verify that serialization and deserialization by ferment handle the internal structure as expected.
  • Ensure that the tests cover edge cases involving modifications (such as pushing new elements) to confirm that the adjustments to field visibility and separate storage of witness details don’t break ferment’s behavior.

}

/// An iterator returning individual witness elements.
Expand Down
6 changes: 4 additions & 2 deletions dash/src/bls_sig_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ use crate::sml::quorum_validation_error::QuorumValidationError;
#[rustversion::attr(since(1.48), derive(PartialEq, Eq, Ord, PartialOrd, Hash))]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
pub struct BLSPublicKey([u8; 48]);
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct BLSPublicKey(pub [u8; 48]);

impl BLSPublicKey {
pub fn is_zeroed(&self) -> bool {
Expand Down Expand Up @@ -96,7 +97,8 @@ impl fmt::Display for BLSPublicKey {
#[rustversion::attr(since(1.48), derive(PartialEq, Eq, Ord, PartialOrd, Hash))]
#[derive(Clone, Copy)]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
pub struct BLSSignature([u8; 96]);
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct BLSSignature(pub [u8; 96]);

impl BLSSignature {
pub fn is_zeroed(&self) -> bool {
Expand Down
13 changes: 8 additions & 5 deletions dash/src/consensus/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use crate::hash_types::{
BlockHash, FilterHash, FilterHeader, MerkleRootMasternodeList, TxMerkleNode,
};
use crate::io::{self, Cursor, Read};
use crate::hash_types::ProTxHash;
use crate::network::message_qrinfo::QuorumSnapshot;
use crate::network::message_sml::{DeletedQuorum, MnListDiff, QuorumCLSigObject};
#[cfg(feature = "std")]
Expand All @@ -56,11 +57,13 @@ use crate::network::{
use crate::prelude::*;
use crate::sml::masternode_list_entry::MasternodeListEntry;
use crate::taproot::TapLeafHash;
use crate::transaction::special_transaction::TransactionType;
use crate::transaction::special_transaction::quorum_commitment::QuorumEntry;
use crate::transaction::txin::TxIn;
use crate::transaction::txout::TxOut;
use crate::{OutPoint, ProTxHash, ScriptBuf, address};
use crate::blockdata::script::ScriptBuf;
use crate::blockdata::transaction::OutPoint;
use crate::blockdata::transaction::special_transaction::TransactionType;
use crate::blockdata::transaction::special_transaction::quorum_commitment::QuorumEntry;
use crate::blockdata::transaction::txin::TxIn;
use crate::blockdata::transaction::txout::TxOut;
use crate::address;

/// Encoding error.
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion dash/src/crypto/sighash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::consensus::{Encodable, encode};
use crate::error::impl_std_error;
use crate::io;
use crate::prelude::*;
use crate::script::{Script, ScriptBuf};
use crate::blockdata::script::{Script, ScriptBuf};
use crate::taproot::{LeafVersion, TAPROOT_ANNEX_PREFIX, TapLeafHash};

/// Used for signature hash for invalid use of SIGHASH_SINGLE.
Expand Down
Loading
Loading