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

feat: added rate limiting to Escrow #274

Merged
merged 43 commits into from
Feb 11, 2025
Merged

feat: added rate limiting to Escrow #274

merged 43 commits into from
Feb 11, 2025

Conversation

srdtrk
Copy link
Member

@srdtrk srdtrk commented Feb 11, 2025

Description

closes: #271


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Wrote unit and integration tests.
  • Added relevant natspec and godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.84%. Comparing base (bc6640a) to head (e928bd7).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #274   +/-   ##
=======================================
  Coverage   99.83%   99.84%           
=======================================
  Files          13       14    +1     
  Lines         621      650   +29     
=======================================
+ Hits          620      649   +29     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@srdtrk srdtrk marked this pull request as ready for review February 11, 2025 17:16
Copy link
Contributor

@gjermundgaraba gjermundgaraba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some naming comments and one change to avoid state changes when rate limit is zero.

But we also need a better story around upgrading, so we wait to merge this until we have solved that.

contracts/errors/IRateLimitErrors.sol Outdated Show resolved Hide resolved
contracts/interfaces/IRateLimit.sol Outdated Show resolved Hide resolved
contracts/interfaces/IRateLimit.sol Outdated Show resolved Hide resolved
contracts/interfaces/IRateLimit.sol Outdated Show resolved Hide resolved
/// @notice Checks the rate limit for a token and updates the daily usage
/// @param token The token address
/// @param amount The amount to check against the rate limit
function _checkRateLimit(address token, uint256 amount) internal {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a better name, because it is not clear from the name that it also updates the daily usage. The check implies that it just checks it. Either something a bit more verbose like verifyAndUpdateDailyRate or if we want something shorter maybe applyRateLimit.

test/solidity-ibc/IntegrationTest.t.sol Outdated Show resolved Hide resolved
test/solidity-ibc/IntegrationTest.t.sol Outdated Show resolved Hide resolved
Comment on lines 62 to 64
if (rateLimit != 0) {
require(usage <= rateLimit, RateLimitExceeded(rateLimit, usage));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (rateLimit != 0) {
require(usage <= rateLimit, RateLimitExceeded(rateLimit, usage));
}
if (rateLimit == 0) {
return
}
require(usage <= rateLimit, RateLimitExceeded(rateLimit, usage));

@srdtrk srdtrk merged commit a6f6183 into main Feb 11, 2025
61 checks passed
@srdtrk srdtrk deleted the serdar/271-rate-limit branch February 11, 2025 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add rate limiting
2 participants