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

gateio: update rate limit definitions #1733

Merged
merged 6 commits into from
Dec 12, 2024

Conversation

shazbert
Copy link
Collaborator

@shazbert shazbert commented Nov 27, 2024

PR Description

  • Updates rate definitions for Gateio using docs
  • Removed func declaration func GetRateLimit() request.RateLimitDefinitions as this allocates a new rate limiting system for the package when SetDefaults is called. If using as a library service and multiple instances &gateio.Gateio{} are allocated and setup (for different key usage etc or other segregation management) then there can be an issue with getting 429'd.
  • Shared rate limits with websocket system for future trading integration. There are no websocket specific rate limits but you do get rate limited, see websocket/gateio: Add request functions for websocket multi-connection [SPOT] #1598 && committed change

Fixes # (issue)

Type of change

Please delete options that are not relevant and add an x in [] as item is complete.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and
also consider improving test coverage whilst working on a certain feature or package.

  • go test ./... -race
  • golangci-lint run
  • Test X

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally and on Github Actions with my changes
  • Any dependent changes have been merged and published in downstream modules

@shazbert shazbert added bug review me This pull request is ready for review labels Nov 27, 2024
@shazbert shazbert requested a review from a team November 27, 2024 23:42
@shazbert shazbert self-assigned this Nov 27, 2024
Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

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

Thanks for updating the limits!

)

// GetRateLimit returns the rate limiter for the exchange
func GetRateLimit() request.RateLimitDefinitions {
Copy link
Collaborator

@gloriousCode gloriousCode Nov 28, 2024

Choose a reason for hiding this comment

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

Hello friend, would you consider this?

Sharing requesters and thus ratelimits isn't a super complex proposition, so someone using multiple exchange structs are better served running their own thing at the moment because this only affects GateIO

We're approaching the same problem in a different manner though. I would really like to see something across exchanges done.

editeroo: If you don't want to dilute this PR, do you think this is worthwhile to make a separate PR for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I was considering that but wanted to go more in depth in another PR for a request.RegisterRateLimit(exchangeStructPointer any, map[request.EndpointLimit]*request.RateLimiter) func and maybe a protected type just for exchanges. That way any future exchange package implementations don't reintroduce the whoopsie again.

  1. I can add your changes to this PR for now or
  2. You can open up a PR against this and I can merge or
  3. You can open a PR against master once this is merged cause I am focused on other things at the moment.

let me know how you want to proceed?

Copy link
Collaborator

@gloriousCode gloriousCode Dec 11, 2024

Choose a reason for hiding this comment

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

I think its something to roll out separately in a different PR. Like I'm okay without it, as per my above second snippet. Can be revisited in future and per my first snippet, isn't crazy complex to implement

exchanges/gateio/ratelimiter.go Show resolved Hide resolved
walletSavedAddressesEPL: standardRateLimit(),
walletTradingFeeEPL: standardRateLimit(),
walletTotalBalanceEPL: personalAccountRateLimit(),
walletWithdrawEPL: request.NewRateLimitWithWeight(time.Second*3, 1, 1), // 1r/3s
Copy link
Collaborator

@gloriousCode gloriousCode Nov 28, 2024

Choose a reason for hiding this comment

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

Please make it a rate limit like the others. I initially thought this rate limit wasn't defined but was instead buried. This might just be on me as a reviewer and I will fold like paper to any argument

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was the only single one in docs for 1 request every 3 seconds only on withdrawal from wallet. 🤷

@shazbert shazbert added blocked and removed review me This pull request is ready for review labels Nov 29, 2024
shazbert added 2 commits December 5, 2024 15:53
… item to nil for systems that do not require rate limiting; add glorious nit
Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

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

tACK!

@gloriousCode gloriousCode added the gcrc GloriousCode Review Complete label Dec 12, 2024
@shazbert shazbert added the test(s) fix This is to denote the PR is fixing a build test issue label Dec 12, 2024
Copy link
Collaborator

@thrasher- thrasher- left a comment

Choose a reason for hiding this comment

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

utACK, rate limit EPLs match expected endpoints; nice work on this as that is always tedious

@thrasher- thrasher- merged commit 068a453 into thrasher-corp:master Dec 12, 2024
5 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug gcrc GloriousCode Review Complete high priority review me This pull request is ready for review test(s) fix This is to denote the PR is fixing a build test issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants