Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed Jul 12, 2024
1 parent 86394d4 commit 3a9e940
Show file tree
Hide file tree
Showing 36 changed files with 64 additions and 65 deletions.
8 changes: 5 additions & 3 deletions packages/rs-dpp/src/fee/default_costs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
//! Fee costs for Known Platform operations
//!
use std::collections::BTreeMap;
use crate::block::epoch::{Epoch, EpochIndex};
use crate::fee::Credits;
use platform_version::version::fee::FeeVersion;
use platform_version::version::PlatformVersion;
use std::collections::BTreeMap;

pub mod constants;

Expand Down Expand Up @@ -104,10 +104,12 @@ impl KnownCostItem {
.fetch_single_identity_key_processing_cost
}
KnownCostItem::Blake3 => {
fee_version.hashing.blake3_base + fee_version.hashing.blake3_per_block * size.unwrap_or(0) as u64
fee_version.hashing.blake3_base
+ fee_version.hashing.blake3_per_block * size.unwrap_or(0) as u64
}
KnownCostItem::SingleSHA256 => {
fee_version.hashing.single_sha256_base + fee_version.hashing.sha256_per_block * size.unwrap_or(0) as u64
fee_version.hashing.single_sha256_base
+ fee_version.hashing.sha256_per_block * size.unwrap_or(0) as u64
}
KnownCostItem::VerifySignatureEcdsaSecp256k1 => {
fee_version.signature.verify_signature_ecdsa_secp256k1
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-dpp/src/fee/fee_result/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//!
use crate::block::epoch::{Epoch, EpochIndex};
use crate::fee::default_costs::{CachedEpochIndexFeeVersions, EpochCosts};
use crate::fee::default_costs::KnownCostItem::StorageDiskUsageCreditPerByte;
use crate::fee::default_costs::{CachedEpochIndexFeeVersions, EpochCosts};
use crate::fee::epoch::distribution::calculate_storage_fee_refund_amount_and_leftovers;
use crate::fee::epoch::{BytesPerEpoch, CreditsPerEpoch};
use crate::fee::Credits;
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-dpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub use async_trait;
pub use bls::*;

pub mod prelude {
use crate::block::epoch::EpochIndex;

pub use crate::data_contract::DataContract;
#[cfg(feature = "extended-document")]
pub use crate::document::ExtendedDocument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ use crate::execution::types::state_transition_container::v0::{
use crate::execution::validation::state_transition::processor::process_state_transition;
use crate::metrics::state_transition_execution_histogram;
use crate::platform_types::event_execution_result::EventExecutionResult;
use dpp::util::hash::hash_single;
use dpp::validation::ConsensusValidationResult;
use std::time::Instant;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use crate::platform_types::platform_state::v0::PlatformStateV0Methods;
use crate::platform_types::state_transitions_processing_result::{
StateTransitionExecutionResult, StateTransitionsProcessingResult,
};
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use dpp::util::hash::hash_single;
use dpp::validation::ConsensusValidationResult;
use dpp::version::PlatformVersion;
use drive::grovedb::Transaction;
use std::time::Instant;

#[derive(Debug)]
struct StateTransitionAwareError<'t> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use crate::config::PlatformConfig;
use crate::error::execution::ExecutionError;
use crate::platform_types::signature_verification_quorum_set::SignatureVerificationQuorumSet;
use dpp::block::block_info::BlockInfo;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use dpp::util::hash::hash_double;
use std::collections::BTreeMap;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;

/// Platform state
#[derive(Clone, Debug, From)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ use crate::config::PlatformConfig;
use crate::platform_types::signature_verification_quorum_set::{
SignatureVerificationQuorumSet, SignatureVerificationQuorumSetForSaving,
};
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use itertools::Itertools;
use std::collections::BTreeMap;
use std::fmt::{Debug, Formatter};
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;

/// Platform state
#[derive(Clone)]
Expand Down
12 changes: 6 additions & 6 deletions packages/rs-drive-proof-verifier/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use crate::from_request::TryFromRequest;
use crate::provider::DataContractProvider;
use crate::{types, types::*, ContextProvider, Error};
use dapi_grpc::platform::v0::get_identities_contract_keys_request::GetIdentitiesContractKeysRequestV0;
use dapi_grpc::platform::v0::get_identities_contract_keys_request::GetIdentitiesContractKeysRequestV0;
use dapi_grpc::platform::v0::get_path_elements_request::GetPathElementsRequestV0;
use dapi_grpc::platform::v0::get_path_elements_request::GetPathElementsRequestV0;
use dapi_grpc::platform::v0::get_protocol_version_upgrade_vote_status_request::{
self, GetProtocolVersionUpgradeVoteStatusRequestV0,
Expand All @@ -24,13 +26,17 @@ use dapi_grpc::platform::{
VersionedGrpcResponse,
};
use dpp::block::block_info::BlockInfo;
use dpp::block::block_info::BlockInfo;
use dpp::block::epoch::{EpochIndex, MAX_EPOCH};
use dpp::block::extended_epoch_info::ExtendedEpochInfo;
use dpp::dashcore::hashes::Hash;
use dpp::dashcore::ProTxHash;
use dpp::document::{Document, DocumentV0Getters};
use dpp::identity::identities_contract_keys::IdentitiesContractKeys;
use dpp::identity::identities_contract_keys::IdentitiesContractKeys;
use dpp::identity::Purpose;
use dpp::identity::Purpose;
use dpp::platform_value;
use dpp::platform_value::{self};
use dpp::prelude::{DataContract, Identifier, Identity};
use dpp::serialization::PlatformDeserializable;
Expand All @@ -41,12 +47,6 @@ use dpp::voting::votes::Vote;
use drive::drive::identity::key::fetch::{
IdentityKeysRequest, KeyKindRequestType, KeyRequestType, PurposeU8, SecurityLevelU8,
};
use dapi_grpc::platform::v0::get_identities_contract_keys_request::GetIdentitiesContractKeysRequestV0;
use dapi_grpc::platform::v0::get_path_elements_request::GetPathElementsRequestV0;
use dpp::block::block_info::BlockInfo;
use dpp::identity::identities_contract_keys::IdentitiesContractKeys;
use dpp::identity::Purpose;
use dpp::platform_value;
use drive::drive::Drive;
use drive::error::proof::ProofError;
use drive::query::contested_resource_votes_given_by_identity_query::ContestedResourceVotesGivenByIdentityQuery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use crate::error::{drive::DriveError, Error};

use dpp::block::block_info::BlockInfo;

use grovedb::TransactionArg;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use dpp::fee::fee_result::FeeResult;
use grovedb::TransactionArg;

use dpp::version::PlatformVersion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use grovedb::batch::KeyInfoPath;
use crate::drive::batch::drive_op_batch::finalize_task::{
DriveOperationFinalizationTasks, DriveOperationFinalizeTask,
};
use std::collections::HashMap;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use std::collections::HashMap;

impl Drive {
/// Applies a list of high level DriveOperations to the drive, and calculates the fee for them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use dpp::block::block_info::BlockInfo;
use dpp::data_contract::DataContract;
use dpp::fee::fee_result::FeeResult;

use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use dpp::version::PlatformVersion;
use grovedb::batch::KeyInfoPath;
use grovedb::{Element, EstimatedLayerInformation, TransactionArg};
use std::collections::HashMap;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;

impl Drive {
/// Updates a data contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use dpp::fee::fee_result::FeeResult;
use dpp::data_contract::document_type::methods::DocumentTypeV0Methods;
use dpp::serialization::PlatformSerializableWithPlatformVersion;

use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use dpp::version::PlatformVersion;
use grovedb::batch::KeyInfoPath;
use grovedb::{Element, EstimatedLayerInformation, TransactionArg};
use std::collections::{HashMap, HashSet};
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;

impl Drive {
/// Updates a data contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use dpp::fee::fee_result::FeeResult;

use dpp::version::PlatformVersion;

use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use dpp::identifier::Identifier;
use grovedb::TransactionArg;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;

impl Drive {
/// Deletes a document and returns the associated fee.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use dpp::block::block_info::BlockInfo;
use dpp::data_contract::DataContract;
use dpp::fee::fee_result::FeeResult;

use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use dpp::identifier::Identifier;
use dpp::version::PlatformVersion;
use grovedb::batch::KeyInfoPath;
use grovedb::{EstimatedLayerInformation, TransactionArg};
use std::collections::HashMap;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;

impl Drive {
/// Deletes a document and returns the associated fee.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ mod v0;

use grovedb::TransactionArg;

use crate::drive::Drive;
use dpp::block::block_info::BlockInfo;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use crate::drive::Drive;

use crate::error::drive::DriveError;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use grovedb::{EstimatedLayerInformation, TransactionArg};

use std::collections::HashMap;

use dpp::block::block_info::BlockInfo;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use crate::drive::Drive;
use crate::error::document::DocumentError;
use dpp::block::block_info::BlockInfo;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;

use crate::error::Error;
use crate::fee::op::LowLevelDriveOperation;
Expand Down
8 changes: 4 additions & 4 deletions packages/rs-drive/src/drive/document/delete/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ mod tests {
use dpp::data_contract::accessors::v0::DataContractV0Getters;
use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0;
use dpp::document::Document;
use dpp::fee::default_costs::{CachedEpochIndexFeeVersions, EpochCosts};
use dpp::fee::default_costs::KnownCostItem::StorageDiskUsageCreditPerByte;
use dpp::fee::default_costs::{CachedEpochIndexFeeVersions, EpochCosts};
use dpp::tests::json_document::{json_document_to_contract, json_document_to_document};

use crate::tests::helpers::setup::setup_drive_with_initial_state_structure;
Expand Down Expand Up @@ -829,7 +829,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);
// We added 1559 bytes
assert_eq!(added_bytes, 1559);
Expand Down Expand Up @@ -867,7 +867,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);

assert!(added_bytes > refund_equivalent_bytes);
Expand Down Expand Up @@ -931,7 +931,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);
// We added 1558 bytes
assert_eq!(added_bytes, 1559);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use crate::error::Error;
use dpp::block::block_info::BlockInfo;
use dpp::fee::fee_result::FeeResult;

use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use dpp::version::PlatformVersion;
use grovedb::TransactionArg;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;

impl Drive {
/// Adds a document to a contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::fee::op::LowLevelDriveOperation;
use dpp::block::block_info::BlockInfo;
use dpp::fee::fee_result::FeeResult;

use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use dpp::version::PlatformVersion;
use grovedb::TransactionArg;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;

impl Drive {
/// Adds a document to a contract.
Expand Down
4 changes: 2 additions & 2 deletions packages/rs-drive/src/drive/document/insert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ mod tests {

use crate::drive::object_size_info::DocumentInfo::DocumentRefInfo;
use crate::tests::helpers::setup::setup_drive_with_initial_state_structure;
use dpp::fee::default_costs::{CachedEpochIndexFeeVersions, EpochCosts};
use dpp::fee::default_costs::KnownCostItem::StorageDiskUsageCreditPerByte;
use dpp::fee::default_costs::{CachedEpochIndexFeeVersions, EpochCosts};
use dpp::fee::fee_result::FeeResult;
use dpp::tests::json_document::json_document_to_document;
use dpp::version::PlatformVersion;
Expand Down Expand Up @@ -475,7 +475,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);
assert_eq!(1305, added_bytes);
assert_eq!(144859600, processing_fee); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
Expand Down
18 changes: 9 additions & 9 deletions packages/rs-drive/src/drive/document/update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ mod tests {
};
use dpp::document::specialized_document_factory::SpecializedDocumentFactory;
use dpp::document::{Document, DocumentV0Getters, DocumentV0Setters};
use dpp::fee::default_costs::{CachedEpochIndexFeeVersions, EpochCosts};
use dpp::fee::default_costs::KnownCostItem::StorageDiskUsageCreditPerByte;
use dpp::fee::default_costs::{CachedEpochIndexFeeVersions, EpochCosts};
use dpp::fee::fee_result::FeeResult;
use dpp::platform_value;
use dpp::tests::json_document::json_document_to_document;
Expand Down Expand Up @@ -941,7 +941,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);
let expected_added_bytes = if using_history {
//Explanation for 1237
Expand Down Expand Up @@ -1110,7 +1110,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);

assert!(expected_added_bytes > refund_equivalent_bytes);
Expand All @@ -1131,7 +1131,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);

assert_eq!(original_bytes, expected_added_bytes);
Expand All @@ -1153,7 +1153,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);

let expected_added_bytes = if using_history { 313 } else { 1 };
Expand Down Expand Up @@ -1226,7 +1226,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);
let expected_added_bytes = if using_history { 1238 } else { 962 };
assert_eq!(original_bytes, expected_added_bytes);
Expand All @@ -1253,7 +1253,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);

assert!(expected_added_bytes > refund_equivalent_bytes);
Expand All @@ -1274,7 +1274,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);

assert_eq!(original_bytes, expected_added_bytes);
Expand All @@ -1296,7 +1296,7 @@ mod tests {
/ Epoch::new(0).unwrap().cost_for_known_cost_item(
&EPOCH_CHANGE_FEE_VERSION_TEST,
StorageDiskUsageCreditPerByte,
None
None,
);

let removed_credits = update_fees
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use dpp::fee::fee_result::FeeResult;

use dpp::version::PlatformVersion;

use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use grovedb::TransactionArg;
use std::borrow::Cow;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;

impl Drive {
/// Updates a document and returns the associated fee.
Expand Down
Loading

0 comments on commit 3a9e940

Please sign in to comment.