michaelhly / solana-py

Solana Python SDK
https://michaelhly.github.io/solana-py
MIT License
979 stars 252 forks source link

Adding proxies #424

Closed monkeyden closed 4 months ago

monkeyden commented 4 months ago

I'm going to take a stab at adding proxy support. Is it safe to start with master or should I use v0.34.0?

michaelhly commented 4 months ago

Master is safe. But what do you mean by proxy?

monkeyden commented 4 months ago

Requests are made through a rotating proxy service. Common method to get around overly stringent rate limits.

Solana mainnet allows 10 RPC calls per second. Each proxy IP is a multiplier of that.

michaelhly commented 4 months ago

Oh. Like fallback endpoints?

monkeyden commented 4 months ago

In this case, the client is passing requests through a proxy, in order to mask the original source.

Let's use ProxyMesh as an example. Solana itself restricts RPC calls to 10 per second. Using ProxyMesh, I could use something like xxxx.proxymesh.com:1234, passing all my requests through a proxy first, and in turn have access to 10|20|50|100 distinct IPs making the requests for me.

Other crypto libraries, like ccxt, have something similar. Consider chart data. Binance does the most volume of any CEX, therefore its price data is the best better barometer for the market. If your country isn't served by Binance but you still want to make REST calls, you can either use a VPN or pass the requests through something like ProxyMesh.

Note: Not an endorsement of ProxyMesh. It just happens to be the service I'm looking at right now.

michaelhly commented 4 months ago

I do not think that should be added to this library. Perhaps you can start your own package and wrap the Client or AsyncClient.

cc @kevinheavey, he may have thoughts.

monkeyden commented 4 months ago

I can absolutely appreciate that perspective.

kevinheavey commented 4 months ago

Yeah agreed with @michaelhly. But do let us know if something about solana-py's design makes it unnecessarily difficult to add proxy support in a new library