Skip to content

Commit

Permalink
update_lowest_tx_id limit to max iteractions
Browse files Browse the repository at this point in the history
  • Loading branch information
dragos-rebegea committed Oct 30, 2024
1 parent 9c6c0c8 commit d167953
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bridge-proxy/src/bridge-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const MAX_GAS_LIMIT_FOR_SC_CALL: u64 = 249999999;
const DEFAULT_GAS_LIMIT_FOR_REFUND_CALLBACK: u64 = 20_000_000; // 20 million
const DELAY_BEFORE_OWNER_CAN_CANCEL_TRANSACTION: u64 = 300;
const MIN_GAS_TO_SAVE_PROGRESS: u64 = 1_000_000;
const MAX_ITERATIONS: usize = 1000;

#[multiversx_sc::contract]
pub trait BridgeProxyContract:
Expand Down Expand Up @@ -203,8 +204,14 @@ pub trait BridgeProxyContract:
let mut new_lowest = self.lowest_tx_id().get();
let len = self.pending_transactions().len();

let capped_len = if len > new_lowest + MAX_ITERATIONS {
new_lowest + MAX_ITERATIONS
} else {
len
};

self.run_while_it_has_gas(MIN_GAS_TO_SAVE_PROGRESS, || {
if !self.empty_element(new_lowest, len) {
if !self.empty_element(new_lowest, capped_len) {
return STOP_OP;
}

Expand Down

0 comments on commit d167953

Please sign in to comment.