From ac0436b1de1c016f5e3efd598924c6eb7018594e Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 5 Apr 2022 12:46:50 +0200 Subject: [PATCH] Simplify SDRUC syntactic validation rules --- bee-message/src/error.rs | 8 -------- bee-message/src/output/mod.rs | 13 ++----------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/bee-message/src/error.rs b/bee-message/src/error.rs index 11af00cb70..0f3a40e424 100644 --- a/bee-message/src/error.rs +++ b/bee-message/src/error.rs @@ -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(>::Error), InvalidFeatureBlockKind(u8), @@ -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), diff --git a/bee-message/src/output/mod.rs b/bee-message/src/output/mod.rs index a958724135..460c660b8e 100644 --- a/bee-message/src/output/mod.rs +++ b/bee-message/src/output/mod.rs @@ -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(), @@ -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(())