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
API v2 improvements #7148
Merged
Merged
API v2 improvements #7148
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nikitosing
force-pushed
the
np-api-v2-improvements
branch
2 times, most recently
from
March 31, 2023 16:19
1b316b4
to
5f56073
Compare
vbaranov
reviewed
Apr 4, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create a corresponding PR in order to update list of supported env vars. I would suggest put new env vars to section https://docs.blockscout.com/for-developers/information-and-settings/env-variables#api-rate-limit-management and add prefix API_RATE_LIMIT_
to all of them.
apps/block_scout_web/lib/block_scout_web/views/access_helper.ex
Outdated
Show resolved
Hide resolved
apps/block_scout_web/lib/block_scout_web/views/access_helper.ex
Outdated
Show resolved
Hide resolved
vbaranov
reviewed
Apr 5, 2023
vbaranov
reviewed
Apr 5, 2023
apps/block_scout_web/lib/block_scout_web/controllers/api/v2/api_key_controller.ex
Outdated
Show resolved
Hide resolved
…ags to /addresses
nikitosing
force-pushed
the
np-api-v2-improvements
branch
from
April 5, 2023 11:58
3acb6fe
to
dfa5492
Compare
vbaranov
approved these changes
Apr 5, 2023
6 tasks
fx0x55
pushed a commit
to FunctionX/blockscout
that referenced
this pull request
May 10, 2023
* Add RateLimit plug; Add TupleEncoder; Move Logger plug to first position in pipelines * Forward address_with_info to read replica * Add message with hash for case when block(by number) lost consensus * Flat 1155 batches in preloaded transfers in transactions * Remove tags from address struct where unused * Add Redis backend for Hammer; Add rate limiting for UI 2.0 requests to API v2 * Avoid rate limiting in /api/v2/key * Add /tokens/{address_hash}/instances/{token_id}/holders; Add public tags to /addresses * Make field contract_name optional * Remove name check for vyper verification * Add user agent check to rate limiting * Add watchlist id to address info * Simplify get_user_agent/1 * Add HAMMER_REDIS_URL env * Refactoring * Fix credo * Add envs to Makefile and .env * Add API_RATE_LIMIT_UI_V2_TOKEN_TTL_IN_SECONDS * Put API_RATE_LIMIT_ prefixed env vars together in Makefile * Add ETS Hammer backend as fallback * Handle case when no recaptcha_response provided in /api/v2/key * Change encrypt/decrypt to sign/verify * Add missed check --------- Co-authored-by: Viktor Baranov <baranov.viktor.27@gmail.com> (cherry picked from commit 94cf98f)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close #6964
Close #6971
Changes
/tokens/{address_hash}/instances/{token_id}/holders
404 Not found
for cases when requested block (by number) lost consensuscontract_name
optional in contract verification/addresses/{address_hash}
)New/changes env variables:
API_RATE_LIMIT_HAMMER_REDIS_URL
API_RATE_LIMIT_BY_IP
API_RATE_LIMIT_IS_BLOCKSCOUT_BEHIND_PROXY
API_RATE_LIMIT_UI_V2_WITH_TOKEN
API_RATE_LIMIT_BY_IP
->API_RATE_LIMIT_BY_WHITELISTED_IP
API_RATE_LIMIT_TIME_INTERVAL
(1s default)API_RATE_LIMIT_BY_IP_TIME_INTERVAL
(5m default)blockscout/docs#132
Flow of rate limiting in UI 2.0:
/v2/key
and get token for (5 rps) to send with the request inapikey
parameter. This token will live 5 hoursChecklist for your Pull Request (PR)
CHANGELOG.md
with this PRmaster
in the Version column. Changes will be reflected in this table: https://docs.blockscout.com/for-developers/information-and-settings/env-variables.