From 68e658122c9998607ae95d359b2137ab41bb10ec Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 24 Jan 2025 12:17:17 +0700 Subject: [PATCH 1/4] chore(platform): make bls sig compatibility an optional feature --- Cargo.lock | 6 +- Dockerfile | 3 +- packages/rs-drive-abci/Cargo.toml | 9 +-- .../platform_state/v0/old_structures/mod.rs | 16 +++++ .../signature_verification_quorum_set/mod.rs | 10 +++- .../v0/{for_saving.rs => for_saving_v0.rs} | 44 +++----------- .../v0/for_saving_v1.rs | 60 +++++++++++++++++-- .../v0/for_saving_v2.rs | 57 ++++++++++++++++++ .../v0/mod.rs | 4 +- .../v0/quorum_config_for_saving_v0.rs | 34 +++++++++++ 10 files changed, 191 insertions(+), 52 deletions(-) rename packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/{for_saving.rs => for_saving_v0.rs} (82%) create mode 100644 packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v2.rs create mode 100644 packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/quorum_config_for_saving_v0.rs diff --git a/Cargo.lock b/Cargo.lock index e8c68108b7..d7652ceda4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2401,11 +2401,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/Dockerfile b/Dockerfile index 27d92abbb0..783cd6e94a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index a082a59a8f..58de8a1dd9 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -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} [dev-dependencies] bs58 = { version = "0.5.0" } @@ -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"] diff --git a/packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs b/packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs index a110dad064..009c2de990 100644 --- a/packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs @@ -32,7 +32,13 @@ pub(super) struct OldStructureValidatorSetV0 { /// The list of masternodes pub members: BTreeMap, /// 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, } impl From for dpp::core_types::validator_set::v0::ValidatorSetV0 { @@ -42,7 +48,9 @@ impl From for dpp::core_types::validator_set::v0::Va quorum_index, core_height, members, + #[cfg(feature = "bls-signatures")] threshold_public_key, + .. } = value; Self { quorum_hash, @@ -52,8 +60,11 @@ impl From 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(), } } } @@ -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, /// The node address pub node_ip: String, @@ -83,6 +95,7 @@ impl From 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, @@ -93,7 +106,10 @@ impl From 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, diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs index a314829a7d..9e5e17b9e7 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs @@ -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, @@ -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 for SignatureVerificationQuorumSetForSaving { fn from(value: SignatureVerificationQuorumSet) -> Self { match value { SignatureVerificationQuorumSet::V0(v0) => { - SignatureVerificationQuorumSetForSaving::V1(v0.into()) + SignatureVerificationQuorumSetForSaving::V2(v0.into()) } } } @@ -142,6 +145,9 @@ impl From for SignatureVerificationQuor SignatureVerificationQuorumSetForSaving::V1(v1) => { SignatureVerificationQuorumSet::V0(v1.into()) } + SignatureVerificationQuorumSetForSaving::V2(v2) => { + SignatureVerificationQuorumSet::V0(v2.into()) + } } } } diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v0.rs similarity index 82% rename from packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs rename to packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v0.rs index de69aff56d..e35ea2a27d 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v0.rs @@ -1,15 +1,12 @@ -use crate::platform_types::signature_verification_quorum_set::v0::quorum_set::{ - PreviousPastQuorumsV0, QuorumConfig, -}; +use crate::platform_types::signature_verification_quorum_set::v0::quorum_config_for_saving_v0::QuorumConfigForSavingV0; +use crate::platform_types::signature_verification_quorum_set::v0::quorum_set::PreviousPastQuorumsV0; use crate::platform_types::signature_verification_quorum_set::{ Quorums, SignatureVerificationQuorumSetForSaving, SignatureVerificationQuorumSetV0, VerificationQuorum, }; +use bincode::{Decode, Encode}; use dashcore_rpc::dashcore::hashes::Hash; use dashcore_rpc::dashcore::QuorumHash; -use dashcore_rpc::json::QuorumType; -use dpp::identity::state_transition::asset_lock_proof::Encode; -use dpp::platform_serialization::de::Decode; use dpp::platform_value::Bytes32; #[derive(Debug, Clone, Encode, Decode)] @@ -57,36 +54,6 @@ impl From for SignatureVerificationQu } } -#[derive(Debug, Clone, Encode, Decode)] -pub struct QuorumConfigForSavingV0 { - quorum_type: QuorumType, - active_signers: u16, - rotation: bool, - window: u32, -} - -impl From for QuorumConfigForSavingV0 { - fn from(config: QuorumConfig) -> Self { - Self { - quorum_type: config.quorum_type, - active_signers: config.active_signers, - rotation: config.rotation, - window: config.window, - } - } -} - -impl From for QuorumConfig { - fn from(config: QuorumConfigForSavingV0) -> Self { - Self { - quorum_type: config.quorum_type, - active_signers: config.active_signers, - rotation: config.rotation, - window: config.window, - } - } -} - #[derive(Debug, Clone, Encode, Decode)] pub struct PreviousPastQuorumsForSavingV0 { quorums: Vec, @@ -134,6 +101,7 @@ impl From for PreviousPastQuorumsV0 { #[derive(Debug, Clone, Encode, Decode)] pub struct QuorumForSavingV0 { hash: Bytes32, + #[cfg(feature = "bls-signatures")] #[bincode(with_serde)] public_key: bls_signatures::PublicKey, index: Option, @@ -145,10 +113,13 @@ impl From> for Quorums { ( QuorumHash::from_byte_array(quorum.hash.to_buffer()), VerificationQuorum { + #[cfg(feature = "bls-signatures")] public_key: dpp::bls_signatures::PublicKey::try_from( quorum.public_key.to_bytes().as_slice(), ) .expect("expected to convert between BLS key libraries (from chia)"), + #[cfg(not(feature = "bls-signatures"))] + public_key: Default::default(), index: quorum.index, }, ) @@ -162,6 +133,7 @@ impl From> for Vec { .into_iter() .map(|(hash, quorum)| QuorumForSavingV0 { hash: Bytes32::from(hash.as_byte_array()), + #[cfg(feature = "bls-signatures")] public_key: bls_signatures::PublicKey::from_bytes( &quorum.public_key.0.to_compressed(), ) diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs index bfb596e451..588e40fcf9 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs @@ -1,21 +1,22 @@ -use crate::platform_types::signature_verification_quorum_set::v0::for_saving::{ - PreviousPastQuorumsForSavingV0, QuorumConfigForSavingV0, -}; +#[cfg(feature = "bls-signatures")] +use crate::platform_types::signature_verification_quorum_set::v0::for_saving_v0::PreviousPastQuorumsForSavingV0; +use crate::platform_types::signature_verification_quorum_set::v0::quorum_config_for_saving_v0::QuorumConfigForSavingV0; +use crate::platform_types::signature_verification_quorum_set::v0::quorum_set::PreviousPastQuorumsV0; use crate::platform_types::signature_verification_quorum_set::{ Quorums, SignatureVerificationQuorumSetForSaving, SignatureVerificationQuorumSetV0, ThresholdBlsPublicKey, VerificationQuorum, }; +use bincode::{Decode, Encode}; use dashcore_rpc::dashcore::hashes::Hash; use dashcore_rpc::dashcore::QuorumHash; use dpp::bls_signatures::Bls12381G2Impl; -use dpp::identity::state_transition::asset_lock_proof::Encode; -use dpp::platform_serialization::de::Decode; use dpp::platform_value::Bytes32; #[derive(Debug, Clone, Encode, Decode)] pub struct SignatureVerificationQuorumSetForSavingV1 { config: QuorumConfigForSavingV0, current_quorums: Vec, + #[cfg(feature = "bls-signatures")] previous_quorums: Option, } @@ -36,6 +37,7 @@ impl From for SignatureVerificationQuorumSetFo Self { config: config.into(), current_quorums: current_quorums.into(), + #[cfg(feature = "bls-signatures")] previous_quorums: previous.map(|previous| previous.into()), } } @@ -46,13 +48,17 @@ impl From for SignatureVerificationQu let SignatureVerificationQuorumSetForSavingV1 { config, current_quorums, + #[cfg(feature = "bls-signatures")] previous_quorums, } = value; Self { config: config.into(), current_quorums: current_quorums.into(), + #[cfg(feature = "bls-signatures")] previous: previous_quorums.map(|previous| previous.into()), + #[cfg(not(feature = "bls-signatures"))] + previous: None, } } } @@ -90,3 +96,47 @@ impl From> for Vec { .collect() } } + +#[derive(Debug, Clone, Encode, Decode)] +pub struct PreviousPastQuorumsForSavingV1 { + quorums: Vec, + last_active_core_height: u32, + updated_at_core_height: u32, + previous_change_height: Option, +} + +impl From for PreviousPastQuorumsForSavingV1 { + fn from(value: PreviousPastQuorumsV0) -> Self { + let PreviousPastQuorumsV0 { + quorums, + last_active_core_height, + updated_at_core_height, + previous_change_height, + } = value; + + Self { + quorums: quorums.into(), + last_active_core_height, + updated_at_core_height, + previous_change_height, + } + } +} + +impl From for PreviousPastQuorumsV0 { + fn from(value: PreviousPastQuorumsForSavingV1) -> Self { + let PreviousPastQuorumsForSavingV1 { + quorums, + last_active_core_height, + updated_at_core_height, + previous_change_height, + } = value; + + Self { + quorums: quorums.into(), + last_active_core_height, + updated_at_core_height, + previous_change_height, + } + } +} diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v2.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v2.rs new file mode 100644 index 0000000000..60f0b4d7b9 --- /dev/null +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v2.rs @@ -0,0 +1,57 @@ +use crate::platform_types::signature_verification_quorum_set::v0::for_saving_v1::{ + PreviousPastQuorumsForSavingV1, QuorumForSavingV1, +}; +use crate::platform_types::signature_verification_quorum_set::v0::quorum_config_for_saving_v0::QuorumConfigForSavingV0; +use crate::platform_types::signature_verification_quorum_set::{ + SignatureVerificationQuorumSetForSaving, SignatureVerificationQuorumSetV0, +}; +use bincode::{Decode, Encode}; + +// We needed to introduce this V2 because the PreviousPastQuorumsForSavingV1 were using a QuorumForSavingV0 +// This was an oversight in SignatureVerificationQuorumSetForSavingV1. +// This would cause the previous quorums to still use the old BLS sigs library for serialization/deserialization. + +#[derive(Debug, Clone, Encode, Decode)] +pub struct SignatureVerificationQuorumSetForSavingV2 { + config: QuorumConfigForSavingV0, + current_quorums: Vec, + previous_quorums: Option, +} + +impl From for SignatureVerificationQuorumSetForSaving { + fn from(value: SignatureVerificationQuorumSetForSavingV2) -> Self { + SignatureVerificationQuorumSetForSaving::V2(value) + } +} + +impl From for SignatureVerificationQuorumSetForSavingV2 { + fn from(value: SignatureVerificationQuorumSetV0) -> Self { + let SignatureVerificationQuorumSetV0 { + config, + current_quorums, + previous, + } = value; + + Self { + config: config.into(), + current_quorums: current_quorums.into(), + previous_quorums: previous.map(|previous| previous.into()), + } + } +} + +impl From for SignatureVerificationQuorumSetV0 { + fn from(value: SignatureVerificationQuorumSetForSavingV2) -> Self { + let SignatureVerificationQuorumSetForSavingV2 { + config, + current_quorums, + previous_quorums, + } = value; + + Self { + config: config.into(), + current_quorums: current_quorums.into(), + previous: previous_quorums.map(|previous| previous.into()), + } + } +} diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs index f38657c29c..2f9757fa4e 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs @@ -1,4 +1,6 @@ -pub mod for_saving; +pub mod for_saving_v0; pub mod for_saving_v1; +pub mod for_saving_v2; +mod quorum_config_for_saving_v0; pub mod quorum_set; pub mod quorums; diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/quorum_config_for_saving_v0.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/quorum_config_for_saving_v0.rs new file mode 100644 index 0000000000..bd5c9ee97b --- /dev/null +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/quorum_config_for_saving_v0.rs @@ -0,0 +1,34 @@ +use crate::platform_types::signature_verification_quorum_set::QuorumConfig; +use bincode::Encode; +use dashcore_rpc::dashcore_rpc_json::QuorumType; +use dpp::platform_serialization::de::Decode; + +#[derive(Debug, Clone, Encode, Decode)] +pub struct QuorumConfigForSavingV0 { + quorum_type: QuorumType, + active_signers: u16, + rotation: bool, + window: u32, +} + +impl From for QuorumConfigForSavingV0 { + fn from(config: QuorumConfig) -> Self { + Self { + quorum_type: config.quorum_type, + active_signers: config.active_signers, + rotation: config.rotation, + window: config.window, + } + } +} + +impl From for QuorumConfig { + fn from(config: QuorumConfigForSavingV0) -> Self { + Self { + quorum_type: config.quorum_type, + active_signers: config.active_signers, + rotation: config.rotation, + window: config.window, + } + } +} From e78494b7599afba61015a6e8eda7dd8238ae036d Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 24 Jan 2025 12:20:44 +0700 Subject: [PATCH 2/4] made something public --- .../platform_types/signature_verification_quorum_set/v0/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs index 2f9757fa4e..bc4511bd4c 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs @@ -1,6 +1,6 @@ pub mod for_saving_v0; pub mod for_saving_v1; pub mod for_saving_v2; -mod quorum_config_for_saving_v0; +pub mod quorum_config_for_saving_v0; pub mod quorum_set; pub mod quorums; From 3e776b6c16a4967a789991c8d3c0f909abdf3f25 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 24 Jan 2025 12:59:22 +0700 Subject: [PATCH 3/4] use newer ciborium --- Cargo.lock | 50 ++++--------------- packages/rs-dpp/Cargo.toml | 2 +- .../rs-dpp/src/util/cbor_value/canonical.rs | 4 +- packages/rs-drive-abci/Cargo.toml | 2 +- packages/rs-drive/Cargo.toml | 2 +- packages/rs-platform-value/Cargo.toml | 2 +- packages/rs-sdk/Cargo.toml | 2 +- 7 files changed, 16 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d7652ceda4..2f34533eff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -758,55 +758,31 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "ciborium" -version = "0.2.0" -source = "git+https://github.com/qrayven/ciborium?branch=feat-ser-null-as-undefined#5fbba76d132caf04cd1f271336d9daafdc747f10" -dependencies = [ - "ciborium-io 0.2.0", - "ciborium-ll 0.2.0", - "serde", -] - [[package]] name = "ciborium" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" dependencies = [ - "ciborium-io 0.2.2", - "ciborium-ll 0.2.2", + "ciborium-io", + "ciborium-ll", "serde", ] -[[package]] -name = "ciborium-io" -version = "0.2.0" -source = "git+https://github.com/qrayven/ciborium?branch=feat-ser-null-as-undefined#5fbba76d132caf04cd1f271336d9daafdc747f10" - [[package]] name = "ciborium-io" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" -[[package]] -name = "ciborium-ll" -version = "0.2.0" -source = "git+https://github.com/qrayven/ciborium?branch=feat-ser-null-as-undefined#5fbba76d132caf04cd1f271336d9daafdc747f10" -dependencies = [ - "ciborium-io 0.2.0", - "half 1.8.3", -] - [[package]] name = "ciborium-ll" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" dependencies = [ - "ciborium-io 0.2.2", - "half 2.4.1", + "ciborium-io", + "half", ] [[package]] @@ -1011,7 +987,7 @@ checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" dependencies = [ "anes", "cast", - "ciborium 0.2.2", + "ciborium", "clap", "criterion-plot", "is-terminal", @@ -1201,7 +1177,7 @@ dependencies = [ "base64 0.22.1", "bip37-bloom-filter", "chrono", - "ciborium 0.2.0", + "ciborium", "clap", "dapi-grpc", "dapi-grpc-macros", @@ -1453,7 +1429,7 @@ dependencies = [ "bs58", "byteorder", "chrono", - "ciborium 0.2.0", + "ciborium", "dashcore", "data-contracts", "derive_more", @@ -1502,7 +1478,7 @@ dependencies = [ "bs58", "byteorder", "chrono", - "ciborium 0.2.0", + "ciborium", "criterion", "derive_more", "dpp", @@ -1544,7 +1520,7 @@ dependencies = [ "bls-signatures", "bs58", "chrono", - "ciborium 0.2.0", + "ciborium", "clap", "console-subscriber", "dapi-grpc", @@ -2249,12 +2225,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "1.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" - [[package]] name = "half" version = "2.4.1" @@ -3564,7 +3534,7 @@ dependencies = [ "base64 0.22.1", "bincode", "bs58", - "ciborium 0.2.0", + "ciborium", "hex", "indexmap 2.7.0", "lazy_static", diff --git a/packages/rs-dpp/Cargo.toml b/packages/rs-dpp/Cargo.toml index ec555a11d1..ba29ece022 100644 --- a/packages/rs-dpp/Cargo.toml +++ b/packages/rs-dpp/Cargo.toml @@ -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", diff --git a/packages/rs-dpp/src/util/cbor_value/canonical.rs b/packages/rs-dpp/src/util/cbor_value/canonical.rs index 99ca93f0ab..05d3a61782 100644 --- a/packages/rs-dpp/src/util/cbor_value/canonical.rs +++ b/packages/rs-dpp/src/util/cbor_value/canonical.rs @@ -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) } diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index 58de8a1dd9..b2e79c4344 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -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"] } diff --git a/packages/rs-drive/Cargo.toml b/packages/rs-drive/Cargo.toml index 6bc0966342..42a8ab94d4 100644 --- a/packages/rs-drive/Cargo.toml +++ b/packages/rs-drive/Cargo.toml @@ -36,7 +36,7 @@ hex = { version = "0.4.3" } # optional dependencies parking_lot = { version = "0.12.1", optional = true } -ciborium = { git = "https://github.com/qrayven/ciborium", branch = "feat-ser-null-as-undefined", optional = true } +ciborium = { version = "0.2.2", optional = true } arc-swap = { version = "1.7.0", optional = true } serde = { version = "1.0.197", features = ["derive"], optional = true } rand = { version = "0.8.4", features = ["small_rng"], optional = true } diff --git a/packages/rs-platform-value/Cargo.toml b/packages/rs-platform-value/Cargo.toml index c8781a258f..dc182afe1a 100644 --- a/packages/rs-platform-value/Cargo.toml +++ b/packages/rs-platform-value/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" [dependencies] bincode = { version = "2.0.0-rc.3", features = ["serde"] } -ciborium = { git = "https://github.com/qrayven/ciborium", branch = "feat-ser-null-as-undefined", optional = true } +ciborium = { version = "0.2.2", optional = true } thiserror = "1.0.64" bs58 = "0.5.1" base64 = "0.22.1" diff --git a/packages/rs-sdk/Cargo.toml b/packages/rs-sdk/Cargo.toml index ca37b832e5..2cb6c5efc6 100644 --- a/packages/rs-sdk/Cargo.toml +++ b/packages/rs-sdk/Cargo.toml @@ -24,7 +24,7 @@ thiserror = "1.0.64" tokio = { version = "1.40", features = ["macros", "rt-multi-thread"] } tokio-util = { version = "0.7.12" } async-trait = { version = "0.1.83" } -ciborium = { git = "https://github.com/qrayven/ciborium", branch = "feat-ser-null-as-undefined" } +ciborium = { version = "0.2.2" } serde = { version = "1.0.197", default-features = false, features = [ "rc", ], optional = true } From e7d487c6d94bda4bc1823380d142f2567eb181ac Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 24 Jan 2025 17:35:43 +0700 Subject: [PATCH 4/4] refactor: remove mocks from default features --- Dockerfile | 19 +++++++++---------- packages/rs-drive-abci/Cargo.toml | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 783cd6e94a..b990d15b46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -158,7 +158,7 @@ ENV NODE_ENV=${NODE_ENV} # # This stage is used to install sccache and configure it. # Later on, one should source /root/env before building to use sccache. -# +# # Note that, due to security concerns, each stage needs to declare variables containing authentication secrets, like # ACTIONS_RUNTIME_TOKEN, AWS_SECRET_ACCESS_KEY. This is to prevent leaking secrets to the final image. The secrets are # loaded using docker buildx `--secret` flag and need to be explicitly mounted with `--mount=type=secret,id=SECRET_ID`. @@ -205,7 +205,7 @@ RUN --mount=type=secret,id=AWS <> /root/env # ACTIONS_RUNTIME_TOKEN is a secret so we quote it here, and it will be loaded when `source /root/env` is run echo 'export ACTIONS_RUNTIME_TOKEN="$(cat /run/secrets/GHA)"' >> /root/env - + ### AWS S3 ### elif [ -n "${SCCACHE_BUCKET}" ]; then echo "export SCCACHE_BUCKET='${SCCACHE_BUCKET}'" >> /root/env @@ -218,11 +218,11 @@ RUN --mount=type=secret,id=AWS <> /root/env - + # Check if AWS credentials file is mounted correctly, eg. --mount=type=secret,id=AWS - echo '[ -e "${AWS_SHARED_CREDENTIALS_FILE}" ] || { - echo "$(id -u): Cannot read ${AWS_SHARED_CREDENTIALS_FILE}; did you use RUN --mount=type=secret,id=AWS ?"; - exit 1; + echo '[ -e "${AWS_SHARED_CREDENTIALS_FILE}" ] || { + echo "$(id -u): Cannot read ${AWS_SHARED_CREDENTIALS_FILE}; did you use RUN --mount=type=secret,id=AWS ?"; + exit 1; }' >> /root/env ### memcached ### @@ -233,9 +233,9 @@ RUN --mount=type=secret,id=AWS <&2 exit 1 fi - + echo "export SCCACHE_SERVER_PORT=$((RANDOM+1025))" >> /root/env - + # Configure compilers to use sccache echo "export CXX='sccache clang++'" >> /root/env echo "export CC='sccache clang'" >> /root/env @@ -464,10 +464,9 @@ 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="--no-default-features --features=console,grovedbg" ; \ + export FEATURES_FLAG="--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 diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index b2e79c4344..368995d1f9 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -96,7 +96,7 @@ dpp = { path = "../rs-dpp", features = [ drive = { path = "../rs-drive", features = ["fixtures-and-mocks"] } strategy-tests = { path = "../strategy-tests" } assert_matches = "1.5.0" -drive-abci = { path = ".", features = ["testing-config"] } +drive-abci = { path = ".", features = ["testing-config", "mocks"] } bls-signatures = { git = "https://github.com/dashpay/bls-signatures", tag = "1.3.3"} mockall = { version = "0.13" } @@ -105,7 +105,7 @@ rocksdb = { version = "0.23.0" } integer-encoding = { version = "4.0.0" } [features] -default = ["mocks"] +default = [] mocks = ["mockall", "drive/fixtures-and-mocks", "bls-signatures"] console = ["console-subscriber", "tokio/tracing"] testing-config = []