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

chore(platform): make bls sig compatibility an optional feature #2440

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
56 changes: 13 additions & 43 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,10 @@ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOM
source /root/env && \
if [[ "${CARGO_BUILD_PROFILE}" == "release" ]] ; then \
mv .cargo/config-release.toml .cargo/config.toml && \
export FEATURES_FLAG="--no-default-features" ; \
export OUT_DIRECTORY=release ; \
else \
export FEATURES_FLAG="--features=console,grovedbg" ; \
export FEATURES_FLAG="--no-default-features --features=console,grovedbg" ; \
export OUT_DIRECTORY=debug ; \
fi && \
# Workaround: as we cache dapi-grpc, its build.rs is not rerun, so we need to touch it
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-dpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ chrono = { version = "0.4.35", default-features = false, features = [
"wasmbind",
"clock",
] }
ciborium = { git = "https://github.com/qrayven/ciborium", branch = "feat-ser-null-as-undefined", optional = true }
ciborium = { version = "0.2.2", optional = true }
dashcore = { git = "https://github.com/dashpay/rust-dashcore", features = [
"std",
"secp-recovery",
Expand Down
4 changes: 1 addition & 3 deletions packages/rs-dpp/src/util/cbor_value/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ impl CborCanonicalMap {

let map = CborValue::Map(self.inner);

ciborium::ser::SerializerOptions::default()
.serialize_null_as_undefined(true)
.into_writer(&map, &mut bytes)?;
ciborium::ser::into_writer(&map, &mut bytes)?;

Ok(bytes)
}
Expand Down
11 changes: 6 additions & 5 deletions packages/rs-drive-abci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ license = "MIT"
[dependencies]
arc-swap = "1.7.0"
bincode = { version = "2.0.0-rc.3", features = ["serde"] }
ciborium = { git = "https://github.com/qrayven/ciborium", branch = "feat-ser-null-as-undefined" }
ciborium = { version = "0.2.2" }
chrono = "0.4.35"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
Expand Down Expand Up @@ -73,7 +73,7 @@ tokio-util = { version = "0.7" }
derive_more = { version = "1.0", features = ["from", "deref", "deref_mut"] }
async-trait = "0.1.77"
console-subscriber = { version = "0.4", optional = true }
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", tag = "1.3.3" }
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", tag = "1.3.3", optional = true}
QuantumExplorer marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
bs58 = { version = "0.5.0" }
Expand All @@ -93,19 +93,20 @@ dpp = { path = "../rs-dpp", features = [
"data-contract-json-conversion",
"data-contract-cbor-conversion",
] }
drive = { path = "../rs-drive" }
drive = { path = "../rs-drive", features = ["fixtures-and-mocks"] }
strategy-tests = { path = "../strategy-tests" }
assert_matches = "1.5.0"
drive-abci = { path = ".", features = ["testing-config"] }
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", tag = "1.3.3"}
mockall = { version = "0.13" }

# For tests of grovedb verify
rocksdb = { version = "0.23.0" }
integer-encoding = { version = "4.0.0" }

[features]

default = ["mocks"]
mocks = ["mockall", "drive/fixtures-and-mocks"]
mocks = ["mockall", "drive/fixtures-and-mocks", "bls-signatures"]
console = ["console-subscriber", "tokio/tracing"]
testing-config = []
grovedbg = ["drive/grovedbg"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ pub(super) struct OldStructureValidatorSetV0 {
/// The list of masternodes
pub members: BTreeMap<ProTxHash, ValidatorV0>,
/// The threshold quorum public key
#[cfg(feature = "bls-signatures")]
pub threshold_public_key: bls_signatures::PublicKey,

/// Extra fields for forward compatibility.
#[cfg(not(feature = "bls-signatures"))]
#[serde(flatten)]
pub extra_fields: std::collections::HashMap<String, serde_json::Value>,
}

impl From<OldStructureValidatorSetV0> for dpp::core_types::validator_set::v0::ValidatorSetV0 {
Expand All @@ -42,7 +48,9 @@ impl From<OldStructureValidatorSetV0> for dpp::core_types::validator_set::v0::Va
quorum_index,
core_height,
members,
#[cfg(feature = "bls-signatures")]
threshold_public_key,
..
} = value;
Self {
quorum_hash,
Expand All @@ -52,8 +60,11 @@ impl From<OldStructureValidatorSetV0> for dpp::core_types::validator_set::v0::Va
.into_iter()
.map(|(pro_tx_hash, validator)| (pro_tx_hash, validator.into()))
.collect(),
#[cfg(feature = "bls-signatures")]
threshold_public_key: PublicKey::try_from(threshold_public_key.to_bytes().as_slice())
.expect("this should not be possible to error as the threshold_public_key was already verified on disk"),
#[cfg(not(feature = "bls-signatures"))]
threshold_public_key: Default::default(),
}
}
}
Expand All @@ -64,6 +75,7 @@ pub(super) struct ValidatorV0 {
/// The proTxHash
pub pro_tx_hash: ProTxHash,
/// The public key share of this validator for this quorum
#[cfg(feature = "bls-signatures")]
pub public_key: Option<bls_signatures::PublicKey>,
/// The node address
pub node_ip: String,
Expand All @@ -83,6 +95,7 @@ impl From<ValidatorV0> for dpp::core_types::validator::v0::ValidatorV0 {
fn from(value: ValidatorV0) -> Self {
let ValidatorV0 {
pro_tx_hash,
#[cfg(feature = "bls-signatures")]
public_key,
node_ip,
node_id,
Expand All @@ -93,7 +106,10 @@ impl From<ValidatorV0> for dpp::core_types::validator::v0::ValidatorV0 {
} = value;
Self {
pro_tx_hash,
#[cfg(feature = "bls-signatures")]
public_key: public_key.map(|pk| PublicKey::try_from(pk.to_bytes().as_slice()).expect("this should not be possible to error as the public_key was already verified on disk")),
#[cfg(not(feature = "bls-signatures"))]
public_key: None,
node_ip,
node_id,
core_port,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ mod v0;
use crate::config::QuorumLikeConfig;
use crate::error::execution::ExecutionError;
use crate::error::Error;
use crate::platform_types::signature_verification_quorum_set::v0::for_saving::SignatureVerificationQuorumSetForSavingV0;
use crate::platform_types::signature_verification_quorum_set::v0::for_saving_v0::SignatureVerificationQuorumSetForSavingV0;
use crate::platform_types::signature_verification_quorum_set::v0::for_saving_v1::SignatureVerificationQuorumSetForSavingV1;
use crate::platform_types::signature_verification_quorum_set::v0::for_saving_v2::SignatureVerificationQuorumSetForSavingV2;
pub use crate::platform_types::signature_verification_quorum_set::v0::quorum_set::{
QuorumConfig, QuorumsWithConfig, SelectedQuorumSetIterator, SignatureVerificationQuorumSetV0,
SignatureVerificationQuorumSetV0Methods, SIGN_OFFSET,
Expand Down Expand Up @@ -121,13 +122,15 @@ pub enum SignatureVerificationQuorumSetForSaving {
V0(SignatureVerificationQuorumSetForSavingV0),
/// Version 1 of the signature verification quorums
V1(SignatureVerificationQuorumSetForSavingV1),
/// Version 2 of the signature verification quorums
V2(SignatureVerificationQuorumSetForSavingV2),
}

impl From<SignatureVerificationQuorumSet> for SignatureVerificationQuorumSetForSaving {
fn from(value: SignatureVerificationQuorumSet) -> Self {
match value {
SignatureVerificationQuorumSet::V0(v0) => {
SignatureVerificationQuorumSetForSaving::V1(v0.into())
SignatureVerificationQuorumSetForSaving::V2(v0.into())
}
}
}
Expand All @@ -142,6 +145,9 @@ impl From<SignatureVerificationQuorumSetForSaving> for SignatureVerificationQuor
SignatureVerificationQuorumSetForSaving::V1(v1) => {
SignatureVerificationQuorumSet::V0(v1.into())
}
SignatureVerificationQuorumSetForSaving::V2(v2) => {
SignatureVerificationQuorumSet::V0(v2.into())
}
}
}
}
Loading
Loading