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

Bump web3protocol-go: Better graceful handling of 429, group processing of identical requests. #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nand2
Copy link
Contributor

@nand2 nand2 commented Dec 13, 2024

Hi!

This is a big one :

  • Now handling RPC 429 Too Many connections by waiting for them to be available again, with a timeout of 30s.
  • A maximum number of concurrent requests are enforced per RPC
  • There is the possibility to specify a "System RPC" per chain, different than the same one. This one is used for system worker (such as the ERC-7774 cache event checking), so that when the main RPC breaks, the one used by the workers still run. Much better, because if the ERC-7774 worker fails too long to make RPC calls, it clear all cache and desactivate itself.
  • Multiple request for the same URL / specific HTTP headers are now grouped : if X person calls for the same thing, it will be processed only once.
  • Fix an issue where, when the RPC was failing during resolve mode determination, it would determine that a website was auto mode even though it was not. (Due to the code previously not differentiating an "execution revert" error from a RPC failure)

On the config side, 2 new fields after RPC:

    [chainConfigs.1]
    "ChainID" = 1
    "RPC" = "https://mainnet.infura.io/v3/************"
    # The maximum number of concurrent requests to the RPC. Default is 5, tuning this may
    # help to prevent too much 429 Too Many Connection errors.
    "RPCMaxConcurrentRequests" = 5
    # System RPC is the RPC used by system workers (such as ERC-7774 cache event tracking)
    # It should be different of the main RPC. If empty, will use the main RPC.
    "SystemRPC" = "https://another.rpc"

When updating web3gateway.dev, could you:

  • Add a "SystemRPC" field for Optimism, and use the current Optimsl Infura RPC,
  • Replace the "RPC" field for Optimism, put "https://mainnet.optimism.io" (much more efficient)

Thanks a lot!

@qzhodl qzhodl requested a review from syntrust December 14, 2024 01:15
@nand2
Copy link
Contributor Author

nand2 commented Dec 14, 2024

The diff on web3protocol-go can be seen here :
web3-protocol/web3protocol-go@v0.2.11...v0.2.13

And regarding the new options : they are optional ; but please update the one for Optimism as described above.
Thanks!

@syntrust
Copy link
Collaborator

Hi nand, that's quite a bit of hardcore work!
Although I need some time to review the changes, I have deployed it (duplicated local branch nand2/202412_check_events2) to web3gateway for your testing and demo first.

@nand2
Copy link
Contributor Author

nand2 commented Dec 17, 2024

Thanks for the deploy!

Additional infos on the changes :

  • The changes on ens.go are mostly refactoring to use the common callContract function -- this file was the last one I did not rework after the web3protocol-go extraction of web3url-gateway. There still remains one function I need to get rid off.
  • client.go : Mostly a wrapper around protocol.go ; which add requests regrouping, and also global maximum number of concurrent request (but this part is commented for now)
  • Also, this is still one RPC per chain, but I have prepared the code to add support for multiple RPCs per chain. (The idea will be, a single web3:// request will only use one specific RPC per chain, there will NOT be a mix of RPC, because RPCs are sometimes not synchronized (one RPC is at block n, the other at block n+1))

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.

2 participants