Skip to content

Commit

Permalink
conflict resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed Jul 12, 2024
1 parent ae90169 commit a079258
Show file tree
Hide file tree
Showing 27 changed files with 94 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ where
platform_ref.state.last_block_info(),
None,
platform_version,
platform_state.previous_fee_versions(),
platform_ref.state.previous_fee_versions(),
)?;

let (estimated_fee_result, errors) = validation_result.into_data_and_errors()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ where
block_info,
Some(transaction),
platform_version,
Some(previous_fee_versions),
)
.map_err(Error::Drive)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ where
true,
transaction,
platform_version,
None,
)?;
Ok(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl ValidationOperation {
.processing_fee
.checked_add(
platform_version.fee_version.hashing.single_sha256_base
+ platform_version.fee_version.hashing.single_sha256_per_block
+ platform_version.fee_version.hashing.sha256_per_block
* (*block_count as u64),
)
.ok_or(ExecutionError::Overflow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub(crate) fn fetch_contender(
&block_info.epoch,
drive.config.epochs_per_era,
platform_version,
None,
)?;
match result.contenders.pop() {
None => Ok((None, fee)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ mod tests {

assert_eq!(processing_result.valid_count(), 1);

assert_eq!(processing_result.aggregated_fees().processing_fee, 2591600); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
assert_eq!(processing_result.aggregated_fees().processing_fee, 2658800); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised

platform
.drive
Expand All @@ -321,7 +321,7 @@ mod tests {
.expect("expected to get identity balance")
.expect("expected there to be an identity balance for this identity");

assert_eq!(identity_balance, 99916138400); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
assert_eq!(identity_balance, 99916071200); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
}

#[test]
Expand Down Expand Up @@ -524,7 +524,7 @@ mod tests {

assert_eq!(processing_result.valid_count(), 1);

assert_eq!(processing_result.aggregated_fees().processing_fee, 3196400); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
assert_eq!(processing_result.aggregated_fees().processing_fee, 3263600); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised

platform
.drive
Expand All @@ -539,7 +539,7 @@ mod tests {
.expect("expected to get identity balance")
.expect("expected there to be an identity balance for this identity");

assert_eq!(identity_balance, 99911271600); // The identity balance is smaller than if there hadn't been any issue // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
assert_eq!(identity_balance, 99911204400); // The identity balance is smaller than if there hadn't been any issue // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
}

#[test]
Expand Down Expand Up @@ -1214,7 +1214,7 @@ mod tests {

assert_eq!(processing_result.valid_count(), 1);

assert_eq!(processing_result.aggregated_fees().processing_fee, 3196400); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
assert_eq!(processing_result.aggregated_fees().processing_fee, 3263600); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised

platform
.drive
Expand All @@ -1229,6 +1229,6 @@ mod tests {
.expect("expected to get identity balance")
.expect("expected there to be an identity balance for this identity");

assert_eq!(identity_balance, 99911271600); // The identity balance is smaller than if there hadn't been any issue // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
assert_eq!(identity_balance, 99911204400); // The identity balance is smaller than if there hadn't been any issue // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ mod tests {

assert_eq!(processing_result.valid_count(), 1);

assert_eq!(processing_result.aggregated_fees().processing_fee, 1152700); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
assert_eq!(processing_result.aggregated_fees().processing_fee, 1219900); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised

platform
.drive
Expand All @@ -244,6 +244,6 @@ mod tests {
.expect("expected to get identity balance")
.expect("expected there to be an identity balance for this identity");

assert_eq!(identity_balance, 149993042300); // about 0.5 Dash starting balance + 1 Dash asset lock top up // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
assert_eq!(identity_balance, 149992975100); // about 0.5 Dash starting balance + 1 Dash asset lock top up // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ impl PlatformStateV0Methods for PlatformStateV0 {
/// Returns a mutable reference to the previous feeversions
fn previous_fee_versions_mut(&mut self) -> &mut CachedEpochIndexFeeVersions {
&mut self.previous_fee_versions
}

fn full_masternode_list_changes(&self, previous: &PlatformStateV0) -> MasternodeListChanges {
let mut new_masternodes = Vec::new();
Expand Down
8 changes: 4 additions & 4 deletions packages/rs-drive-abci/tests/strategy_tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ mod tests {
.expect("expected to fetch balances")
.expect("expected to have an identity to get balance from");

assert_eq!(balance, 99864783600) // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
assert_eq!(balance, 99864716400) // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
}

#[test]
Expand Down Expand Up @@ -1193,7 +1193,7 @@ mod tests {
.unwrap()
.unwrap()
),
"00b8bd1457467c08672b399a007f6d68102386413c5cbae53424a1c6cf3cb4ab".to_string()
"8183eede440c002da02009166bef1e624afdb796852c755fa9abb7c22526c6bf".to_string()
)
}

Expand Down Expand Up @@ -1914,7 +1914,7 @@ mod tests {
.unwrap()
.unwrap()
),
"75e4622f3c99e1f1efdd3bbd913587bb238791e967244a5e17fe942ec9cf6cb5".to_string()
"10aa07e5e7c2fbe521a8ddd937be9cb68e9abe0f69bac4fef1442d447a1b7c6a".to_string()
)
}

Expand Down Expand Up @@ -2049,7 +2049,7 @@ mod tests {
.unwrap()
.unwrap()
),
"539fc39067fcf0f7cb0e4fa3589d71376393e24c7046f51bd6410e2c2e3b7944".to_string()
"2ca45a7e73e8f7126b2192bb738c619746acdbef84ef3c3e1a1131be69e44f40".to_string()
)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/rs-drive/src/drive/document/delete/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,6 @@ mod tests {

assert!(fee_result.fee_refunds.0.is_empty());
assert_eq!(fee_result.storage_fee, 0);
assert_eq!(fee_result.processing_fee, 145553200); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
assert_eq!(fee_result.processing_fee, 145463600); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
}
}
6 changes: 1 addition & 5 deletions packages/rs-drive/src/drive/document/insert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,8 @@ mod tests {
use crate::drive::flags::StorageFlags;
use crate::drive::object_size_info::{DocumentAndContractInfo, OwnedDocumentInfo};
use crate::fee::op::LowLevelDriveOperation;
use dpp::block::block_info::BlockInfo;
use once_cell::sync::Lazy;
use rand::{random, Rng};
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::option::Option::None;

use dpp::block::epoch::Epoch;
use dpp::data_contract::accessors::v0::DataContractV0Getters;
Expand Down Expand Up @@ -482,7 +478,7 @@ mod tests {
StorageDiskUsageCreditPerByte,
);
assert_eq!(1305, added_bytes);
assert_eq!(143011600, processing_fee); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
assert_eq!(144859600, processing_fee); // TODO: Readjust this test when FeeHashingVersion blake3_base, sha256_ripe_md160_base, blake3_per_block values are finalised
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl Drive {
&block_info.epoch,
self.config.epochs_per_era,
platform_version,
None,
)?;
Ok(fees)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl Drive {
&block_info.epoch,
self.config.epochs_per_era,
platform_version,
None,
)?;
Ok(fees)
}
Expand Down
2 changes: 2 additions & 0 deletions packages/rs-drive/src/drive/document/insert_contested/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ mod tests {
true,
None,
platform_version,
None,
)
.expect("expected to insert a document successfully");

Expand All @@ -125,6 +126,7 @@ mod tests {
true,
None,
platform_version,
None,
)
.expect_err(
"expected not to be able to insert document with already existing unique index",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl Drive {
epoch,
self.config.epochs_per_era,
platform_version,
None,
)?;
fee_result.processing_fee
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl Drive {
&block_info.epoch,
self.config.epochs_per_era,
platform_version,
None,
)?;
Ok((value, fees))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl Drive {
epoch,
self.config.epochs_per_era,
platform_version,
None,
)
})
.transpose()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl Drive {
&block_info.epoch,
self.config.epochs_per_era,
platform_version,
None,
)?;
Ok(fees)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl ContestedResourceVotesGivenByIdentityQuery {
&block_info.epoch,
drive.config.epochs_per_era,
platform_version,
None,
)?;
fee_result.processing_fee
} else {
Expand Down Expand Up @@ -113,6 +114,7 @@ impl ContestedResourceVotesGivenByIdentityQuery {
&block_info.epoch,
drive.config.epochs_per_era,
platform_version,
None,
)?;
fee_result.processing_fee
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ impl ContestedDocumentVotePollVotesDriveQuery {
&block_info.epoch,
drive.config.epochs_per_era,
platform_version,
None,
)?;
fee_result.processing_fee
} else {
Expand Down Expand Up @@ -183,6 +184,7 @@ impl ContestedDocumentVotePollVotesDriveQuery {
&block_info.epoch,
drive.config.epochs_per_era,
platform_version,
None,
)?;
fee_result.processing_fee
} else {
Expand Down
2 changes: 2 additions & 0 deletions packages/rs-drive/src/query/vote_poll_vote_state_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ impl ContestedDocumentVotePollDriveQuery {
&block_info.epoch,
drive.config.epochs_per_era,
platform_version,
None,
)?;
fee_result.processing_fee
} else {
Expand Down Expand Up @@ -338,6 +339,7 @@ impl ContestedDocumentVotePollDriveQuery {
&block_info.epoch,
drive.config.epochs_per_era,
platform_version,
None,
)?;
fee_result.processing_fee
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ impl VotePollsByDocumentTypeQuery {
&block_info.epoch,
drive.config.epochs_per_era,
platform_version,
None,
)?;
fee_result.processing_fee
} else {
Expand Down
2 changes: 2 additions & 0 deletions packages/rs-drive/src/query/vote_polls_by_end_date_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ impl VotePollsByEndDateDriveQuery {
&block_info.epoch,
drive.config.epochs_per_era,
platform_version,
None,
)?;
fee_result.processing_fee
} else {
Expand Down Expand Up @@ -249,6 +250,7 @@ impl VotePollsByEndDateDriveQuery {
&block_info.epoch,
drive.config.epochs_per_era,
platform_version,
None,
)?;
fee_result.processing_fee
} else {
Expand Down
19 changes: 17 additions & 2 deletions packages/rs-platform-version/src/version/fee/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mod tests {
use crate::version::fee::signature::FeeSignatureVersion;
use crate::version::fee::state_transition_min_fees::StateTransitionMinFees;
use crate::version::fee::storage::FeeStorageVersion;
use crate::version::fee::vote_resolution_fund_fees::VoteResolutionFundFees;
use super::FeeVersion;

#[test]
Expand Down Expand Up @@ -81,6 +82,7 @@ mod tests {
fetch_identity_cost_per_look_up_key_by_id: 4,
fetch_single_identity_key_processing_cost: 5,
validate_key_structure: 6,
fetch_prefunded_specialized_balance_processing_cost: 7,
},
data_contract: FeeDataContractValidationVersion {
document_type_base_fee: 1,
Expand All @@ -98,7 +100,13 @@ mod tests {
document_batch_sub_transition: 4,
contract_create: 5,
contract_update: 6,
}
masternode_vote: 7,
},
vote_resolution_fund_fees: VoteResolutionFundFees {
contested_document_vote_resolution_fund_required_amount: 1,
contested_document_vote_resolution_unlock_fund_required_amount: 2,
contested_document_single_vote_cost: 3,
},
};

let version2 = FeeVersion {
Expand Down Expand Up @@ -130,6 +138,7 @@ mod tests {
fetch_identity_cost_per_look_up_key_by_id: 4,
fetch_single_identity_key_processing_cost: 5,
validate_key_structure: 6,
fetch_prefunded_specialized_balance_processing_cost: 7,
},
data_contract: FeeDataContractValidationVersion {
document_type_base_fee: 1,
Expand All @@ -147,7 +156,13 @@ mod tests {
document_batch_sub_transition: 4,
contract_create: 5,
contract_update: 6,
}
masternode_vote: 7,
},
vote_resolution_fund_fees: VoteResolutionFundFees {
contested_document_vote_resolution_fund_required_amount: 1,
contested_document_vote_resolution_unlock_fund_required_amount: 2,
contested_document_single_vote_cost: 3,
},
};

// This assertion will check if all fields are considered in the equality comparison
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mod tests {
fetch_identity_cost_per_look_up_key_by_id: 4,
fetch_single_identity_key_processing_cost: 5,
validate_key_structure: 6,
fetch_prefunded_specialized_balance_processing_cost: 7,
};

let version2 = FeeProcessingVersion {
Expand All @@ -51,6 +52,7 @@ mod tests {
fetch_identity_cost_per_look_up_key_by_id: 4,
fetch_single_identity_key_processing_cost: 5,
validate_key_structure: 6,
fetch_prefunded_specialized_balance_processing_cost: 7,
};

// This assertion will check if all fields are considered in the equality comparison
Expand Down
Loading

0 comments on commit a079258

Please sign in to comment.