From 1fb5b7e4f5fc7cf4b8a7f1c363b63ce1cd6e18b7 Mon Sep 17 00:00:00 2001 From: Andy Golay Date: Sun, 30 Nov 2025 15:54:56 -0500 Subject: [PATCH 1/3] change min(timestamp - rate_limit.last_update, rate_limit.window_seconds) to timestamp - rate_limit.last_update --- .../sources/shared_oft/oft_impl_config.move | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move b/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move index e16406822a..cccba6f4f8 100644 --- a/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move +++ b/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move @@ -216,7 +216,9 @@ module oft::oft_impl_config { public(friend) fun checkpoint_rate_limit_in_flight(eid: u32, timestamp: u64) acquires Config { let inflight = in_flight_at_time(eid, timestamp); let rate_limit = table::borrow_mut(&mut store_mut().rate_limit_by_eid, eid); - rate_limit.in_flight_on_last_update = inflight; + // Cap in_flight_on_last_update to the current limit to prevent it from exceeding the limit + // when the limit is lowered + rate_limit.in_flight_on_last_update = min(inflight, rate_limit.limit); rate_limit.last_update = timestamp; } @@ -250,7 +252,8 @@ module oft::oft_impl_config { let rate_limit = *table::borrow(&store().rate_limit_by_eid, eid); if (timestamp > rate_limit.last_update) { // If the timestamp is greater than the last update, calculate the decayed in-flight amount - let elapsed = min(timestamp - rate_limit.last_update, rate_limit.window_seconds); + // Remove min() cap to allow decay beyond one window when needed + let elapsed = timestamp - rate_limit.last_update; let decay = ((((elapsed as u128) * (rate_limit.limit as u128)) / (rate_limit.window_seconds as u128)) as u64); // Ensure the decayed in-flight amount is not negative From 4f52b7001b960f2d6f576ff5d0279babdb0569be Mon Sep 17 00:00:00 2001 From: Andy Golay Date: Sun, 30 Nov 2025 15:59:50 -0500 Subject: [PATCH 2/3] change min(timestamp - rate_limit.last_update, rate_limit.window_seconds) to timestamp - rate_limit.last_update --- .../sources/shared_oft/oft_impl_config.move | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move b/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move index cccba6f4f8..2706d5b797 100644 --- a/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move +++ b/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move @@ -216,9 +216,7 @@ module oft::oft_impl_config { public(friend) fun checkpoint_rate_limit_in_flight(eid: u32, timestamp: u64) acquires Config { let inflight = in_flight_at_time(eid, timestamp); let rate_limit = table::borrow_mut(&mut store_mut().rate_limit_by_eid, eid); - // Cap in_flight_on_last_update to the current limit to prevent it from exceeding the limit - // when the limit is lowered - rate_limit.in_flight_on_last_update = min(inflight, rate_limit.limit); + rate_limit.in_flight_on_last_update = inflight; rate_limit.last_update = timestamp; } From 420bc912f88b56df1d0d678d2b37e757803942eb Mon Sep 17 00:00:00 2001 From: Andy Golay Date: Sun, 30 Nov 2025 16:07:57 -0500 Subject: [PATCH 3/3] clean up Move warnings --- .../sources/shared_oft/oft_impl_config.move | 1 - .../implementations/move_oft_adapter_tests.move | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move b/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move index 2706d5b797..259066e5a6 100644 --- a/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move +++ b/examples/oft-evm-move-adapters/sources/shared_oft/oft_impl_config.move @@ -1,6 +1,5 @@ module oft::oft_impl_config { use std::event::emit; - use std::math64::min; use std::string::utf8; use std::table::{Self, Table}; use std::timestamp; diff --git a/examples/oft-evm-move-adapters/tests/implementations/move_oft_adapter_tests.move b/examples/oft-evm-move-adapters/tests/implementations/move_oft_adapter_tests.move index a79dd9bdba..caac04e1c5 100644 --- a/examples/oft-evm-move-adapters/tests/implementations/move_oft_adapter_tests.move +++ b/examples/oft-evm-move-adapters/tests/implementations/move_oft_adapter_tests.move @@ -33,6 +33,8 @@ module oft::move_oft_adapter_tests { remove_pauser, set_fee_bps, set_fee_deposit_address, + EPAUSED, + EUNAUTHORIZED, }; use oft::oft_impl_config; use oft::oft_store; @@ -85,7 +87,7 @@ module oft::move_oft_adapter_tests { } #[test] - #[expected_failure(abort_code = 5)] // EUNAUTHORIZED + #[expected_failure(abort_code = EUNAUTHORIZED, location = move_oft_adapter)] fun test_only_pauser_or_admin_can_toggle() { setup(); @@ -97,7 +99,7 @@ module oft::move_oft_adapter_tests { } #[test] - #[expected_failure(abort_code = 4)] // EPAUSED + #[expected_failure(abort_code = EPAUSED, location = move_oft_adapter)] fun test_paused_blocks_debit() { let mint_ref = setup(); let admin = &create_signer_for_test(@oft_admin); @@ -149,7 +151,7 @@ module oft::move_oft_adapter_tests { } #[test] - #[expected_failure(abort_code = 5)] // EUNAUTHORIZED + #[expected_failure(abort_code = EUNAUTHORIZED, location = move_oft_adapter)] fun test_non_pauser_still_unauthorized() { setup(); let admin = &create_signer_for_test(@oft_admin); @@ -160,7 +162,7 @@ module oft::move_oft_adapter_tests { } #[test] - #[expected_failure(abort_code = 4)] // EPAUSED + #[expected_failure(abort_code = EPAUSED, location = move_oft_adapter)] fun test_credit_blocked_when_paused() { let mint_ref = setup(); let amount_ld = 500u64; @@ -181,7 +183,7 @@ module oft::move_oft_adapter_tests { } #[test] - #[expected_failure(abort_code = 5)] // EUNAUTHORIZED + #[expected_failure(abort_code = EUNAUTHORIZED, location = move_oft_adapter)] fun test_removed_pauser_loses_ability() { setup();