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

Simplify SDRUC syntactic validation rules #1329

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
8 changes: 0 additions & 8 deletions bee-message/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ pub enum Error {
InsufficientStorageDepositAmount { amount: u64, required: u64 },
StorageDepositReturnExceedsOutputAmount { deposit: u64, amount: u64 },
InsufficientStorageDepositReturnAmount { deposit: u64, required: u64 },
UnnecessaryStorageDepositReturnCondition { logical_amount: u64, required: u64 },
InvalidEssenceKind(u8),
InvalidFeatureBlockCount(<FeatureBlockCount as TryFrom<usize>>::Error),
InvalidFeatureBlockKind(u8),
Expand Down Expand Up @@ -170,13 +169,6 @@ impl fmt::Display for Error {
f,
"storage deposit return of {deposit} exceeds the original output amount of {amount}"
),
Error::UnnecessaryStorageDepositReturnCondition {
logical_amount,
required,
} => write!(
f,
"no storage deposit return is needed, the logical output amount {logical_amount} already covers the required deposit {required}"
),
Error::InvalidEssenceKind(k) => write!(f, "invalid essence kind: {}", k),
Error::InvalidFeatureBlockCount(count) => write!(f, "invalid feature block count: {}", count),
Error::InvalidFeatureBlockKind(k) => write!(f, "invalid feature block kind: {}", k),
Expand Down
13 changes: 2 additions & 11 deletions bee-message/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl Output {
.and_then(UnlockConditions::storage_deposit_return)
{
// We can't return more tokens than were originally contained in the output.
// `0` ≤ `Amount` - `Return Amount`
// `Return Amount` ≤ `Amount`.
if return_condition.amount() > self.amount() {
return Err(Error::StorageDepositReturnExceedsOutputAmount {
deposit: return_condition.amount(),
Expand All @@ -244,22 +244,13 @@ impl Output {

let minimum_deposit = minimum_storage_deposit(config, return_condition.return_address());

// `Return Amount` must be ≥ than `Minimum Storage Deposit`
// `Minimum Storage Deposit` ≤ `Return Amount`
if return_condition.amount() < minimum_deposit {
return Err(Error::InsufficientStorageDepositReturnAmount {
deposit: return_condition.amount(),
required: minimum_deposit,
});
}

// Check if the storage deposit return was required in the first place.
// `Amount` - `Return Amount` ≤ `Required Storage Deposit of the Output`
if self.amount() - return_condition.amount() > required_output_amount {
return Err(Error::UnnecessaryStorageDepositReturnCondition {
logical_amount: self.amount() - return_condition.amount(),
required: required_output_amount,
});
}
}

Ok(())
Expand Down