Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
75 changes: 36 additions & 39 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion packages/rs-dpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ strum = { version = "0.26", features = ["derive"] }
json-schema-compatibility-validator = { path = '../rs-json-schema-compatibility-validator', optional = true }
once_cell = "1.19.0"
tracing = { version = "0.1.41" }
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "8f25b20d04bfc0e8bdfb3870676d647a0d74918b", optional = true }
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "dbd83dce59fbcf2866e9dd06be4ce6c320e37908", optional = true }

[dev-dependencies]
tokio = { version = "1.40", features = ["full"] }
Expand Down
21 changes: 19 additions & 2 deletions packages/rs-dpp/src/balances/total_credits_balance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub struct TotalCreditsBalance {
pub total_specialized_balances: SignedCredits,
/// all the credits in addresses
pub total_in_addresses: SignedCredits,
/// all the credits inside shielded credit pools
pub total_in_shielded_balances: SignedCredits,
}

impl fmt::Display for TotalCreditsBalance {
Expand All @@ -34,14 +36,19 @@ impl fmt::Display for TotalCreditsBalance {
)?;
writeln!(
f,
" total_specialized_balances: {}",
" total_specialized_balances: {},",
self.total_specialized_balances
)?;
writeln!(
f,
" total_addresses_balances: {}",
" total_addresses_balances: {},",
self.total_in_addresses
)?;
writeln!(
f,
" total_in_shielded_balances: {}",
self.total_in_shielded_balances
)?;
write!(f, "}}")
}
}
Expand All @@ -56,6 +63,7 @@ impl TotalCreditsBalance {
total_identity_balances,
total_specialized_balances,
total_in_addresses,
total_in_shielded_balances,
} = *self;

if total_in_pools < 0 {
Expand All @@ -82,6 +90,12 @@ impl TotalCreditsBalance {
));
}

if total_in_shielded_balances < 0 {
return Err(ProtocolError::CriticalCorruptedCreditsCodeExecution(
"Credits inside shielded balances are less than 0".to_string(),
));
}

if total_credits_in_platform > MAX_CREDITS {
return Err(ProtocolError::CriticalCorruptedCreditsCodeExecution(
"Total credits in platform more than max credits size".to_string(),
Expand All @@ -92,6 +106,7 @@ impl TotalCreditsBalance {
.checked_add(total_identity_balances)
.and_then(|partial_sum| partial_sum.checked_add(total_specialized_balances))
.and_then(|partial_sum| partial_sum.checked_add(total_in_addresses))
.and_then(|partial_sum| partial_sum.checked_add(total_in_shielded_balances))
.ok_or(ProtocolError::CriticalCorruptedCreditsCodeExecution(
"Overflow of total credits".to_string(),
))?;
Expand All @@ -106,13 +121,15 @@ impl TotalCreditsBalance {
total_identity_balances,
total_specialized_balances,
total_in_addresses,
total_in_shielded_balances,
..
} = *self;

let total_in_trees = total_in_pools
.checked_add(total_identity_balances)
.and_then(|partial_sum| partial_sum.checked_add(total_specialized_balances))
.and_then(|partial_sum| partial_sum.checked_add(total_in_addresses))
.and_then(|partial_sum| partial_sum.checked_add(total_in_shielded_balances))
.ok_or(ProtocolError::CriticalCorruptedCreditsCodeExecution(
"Overflow of total credits".to_string(),
))?;
Expand Down
4 changes: 2 additions & 2 deletions packages/rs-drive-abci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,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", rev = "0842b17583888e8f46c252a4ee84cdfd58e0546f", optional = true }
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "8f25b20d04bfc0e8bdfb3870676d647a0d74918b" }
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "dbd83dce59fbcf2866e9dd06be4ce6c320e37908" }
nonempty = "0.11"

[dev-dependencies]
Expand All @@ -103,7 +103,7 @@ dpp = { path = "../rs-dpp", default-features = false, features = [
drive = { path = "../rs-drive", features = ["fixtures-and-mocks"] }
drive-proof-verifier = { path = "../rs-drive-proof-verifier" }
strategy-tests = { path = "../strategy-tests" }
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "8f25b20d04bfc0e8bdfb3870676d647a0d74918b", features = ["client"] }
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "dbd83dce59fbcf2866e9dd06be4ce6c320e37908", features = ["client"] }
assert_matches = "1.5.0"
drive-abci = { path = ".", features = ["testing-config", "mocks"] }
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "0842b17583888e8f46c252a4ee84cdfd58e0546f" }
Expand Down
Loading
Loading