Skip to content

Commit

Permalink
Do not check minimal fees on read only without fees (#4675)
Browse files Browse the repository at this point in the history
* Do not check minimal fees on read only without fees

* Format
  • Loading branch information
AurelienFT authored Apr 10, 2024
1 parent 8b23f0a commit 07b8c52
Showing 1 changed file with 30 additions and 36 deletions.
66 changes: 30 additions & 36 deletions massa-api/src/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,24 +282,21 @@ impl MassaRpcServer for API<Public> {
};

// check if fee is enough
if fee
.unwrap_or_default()
.checked_sub(self.0.api_settings.minimal_fees)
.is_none()
{
let result = ExecuteReadOnlyResponse {
executed_at: Slot::new(0, 0),
result: ReadOnlyResult::Error(format!(
"fee is too low provided: {} , minimal_fees required: {}",
fee.unwrap_or_default(),
self.0.api_settings.minimal_fees
)),
gas_cost: 0,
output_events: Default::default(),
state_changes: Default::default(),
};
res.push(result);
continue;
if let Some(fee) = fee {
if fee.checked_sub(self.0.api_settings.minimal_fees).is_none() {
let result = ExecuteReadOnlyResponse {
executed_at: Slot::new(0, 0),
result: ReadOnlyResult::Error(format!(
"fee is too low provided: {} , minimal_fees required: {}",
fee, self.0.api_settings.minimal_fees
)),
gas_cost: 0,
output_events: Default::default(),
state_changes: Default::default(),
};
res.push(result);
continue;
}
}

// run
Expand Down Expand Up @@ -386,24 +383,21 @@ impl MassaRpcServer for API<Public> {
fee,
};

if fee
.unwrap_or_default()
.checked_sub(self.0.api_settings.minimal_fees)
.is_none()
{
let result = ExecuteReadOnlyResponse {
executed_at: Slot::new(0, 0),
result: ReadOnlyResult::Error(format!(
"fee is too low provided: {} , minimal_fees required: {}",
fee.unwrap_or_default(),
self.0.api_settings.minimal_fees
)),
gas_cost: 0,
output_events: Default::default(),
state_changes: Default::default(),
};
res.push(result);
continue;
if let Some(fee) = fee {
if fee.checked_sub(self.0.api_settings.minimal_fees).is_none() {
let result = ExecuteReadOnlyResponse {
executed_at: Slot::new(0, 0),
result: ReadOnlyResult::Error(format!(
"fee is too low provided: {} , minimal_fees required: {}",
fee, self.0.api_settings.minimal_fees
)),
gas_cost: 0,
output_events: Default::default(),
state_changes: Default::default(),
};
res.push(result);
continue;
}
}

// run
Expand Down

0 comments on commit 07b8c52

Please sign in to comment.