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

Implement Counterfactual Safes creation rate limit #1801

Merged
merged 3 commits into from
Aug 7, 2024

Conversation

hectorgomezv
Copy link
Member

@hectorgomezv hectorgomezv commented Aug 5, 2024

Summary

This PR introduces a rate limitation to creating Counterfactual Safes using the related CounterfactualSafesController endpoint. This rate limit is applied by taking the Account associated with the Counterfactual Safe to calculate the limit threshold.

Changes

  • Adds a rate limitation controlled by a cache key before proceeding with Counterfactual Safes creation.

@hectorgomezv hectorgomezv self-assigned this Aug 5, 2024
@coveralls
Copy link

coveralls commented Aug 5, 2024

Pull Request Test Coverage Report for Build 10281742208

Details

  • 2 of 9 (22.22%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.009%) to 46.917%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/datasources/accounts/counterfactual-safes/counterfactual-safes.datasource.ts 2 9 22.22%
Files with Coverage Reduction New Missed Lines %
src/datasources/accounts/counterfactual-safes/counterfactual-safes.datasource.ts 1 20.37%
Totals Coverage Status
Change from base Build 10280822327: -0.009%
Covered Lines: 4548
Relevant Lines: 7822

💛 - Coveralls

{ length: creationRateLimitCalls },
(_, i) =>
createCounterfactualSafeDtoBuilder()
.with('chainId', i.toString())
Copy link
Member Author

Choose a reason for hiding this comment

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

chainId is set as a discriminator to avoid the DTO properties collision edge case.

@hectorgomezv hectorgomezv marked this pull request as ready for review August 5, 2024 13:24
@hectorgomezv hectorgomezv requested a review from a team as a code owner August 5, 2024 13:24
Copy link
Member

@iamacook iamacook left a comment

Choose a reason for hiding this comment

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

As with the other implementation for accounts, this seems more guard-like behaviour? It might even allow us to reduce repetition if it was in a guard. What do you think?

@hectorgomezv
Copy link
Member Author

As with the other implementation for accounts, this seems more guard-like behaviour? It might even allow us to reduce repetition if it was in a guard. What do you think?

I've answered in #1800 (comment), we can follow the discussion there if you are happy with it.

iamacook
iamacook previously approved these changes Aug 7, 2024
Base automatically changed from add-accounts-creation-ip-rate-limit to main August 7, 2024 08:26
@hectorgomezv hectorgomezv dismissed iamacook’s stale review August 7, 2024 08:26

The base branch was changed.

@hectorgomezv hectorgomezv merged commit decf19e into main Aug 7, 2024
16 checks passed
@hectorgomezv hectorgomezv deleted the add-cf-safes-creation-rate-limit branch August 7, 2024 11:28
DenSmolonski pushed a commit to Zilliqa/safe-client-gateway that referenced this pull request Oct 24, 2024
Adds a rate limitation controlled by a cache key before proceeding with Counterfactual Safes creation
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.

3 participants