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

feat: Dynamic rpc handler #183

Closed
wants to merge 52 commits into from

Conversation

Keyrxng
Copy link
Member

@Keyrxng Keyrxng commented Feb 29, 2024

Resolves ubiquity/rpc-handler#3

  • Implemented a successful RPC cache
  • Included a 5-visit refresh (for cases where only 2 or 3 RPCs make it through the first time it might be a good idea to give them another try later)
  • Uses the cancelToken feature of axios to cancel any calls upwards of 500ms (this does log a (cancelled) failure reason but that can be a hit and a miss with one rpc being really quick from one call to the next) and the original flickering issue the "blacklist" resolved has been resolved included in this pr
  • merged main into this which is based off the current sync-erc-permits pr and validated everything is working

In the RPC video I'm using mainnet as an example as that has far more failed calls

claiming.mp4
rpc_dynamic_handling.mp4

@ubiquity-os-deployer
Copy link

@Keyrxng
Copy link
Member Author

Keyrxng commented Feb 29, 2024

Seems to be working well

Gnosis permit for Anvil
https://eee30fb3.pay-ubq-fi-bxp.pages.dev/?claim=W3sidHlwZSI6ImVyYzIwLXBlcm1pdCIsInBlcm1pdCI6eyJwZXJtaXR0ZWQiOnsidG9rZW4iOiIweGU5MUQxNTNFMGI0MTUxOEEyQ2U4RGQzRDc5NDRGYTg2MzQ2M2E5N2QiLCJhbW91bnQiOiIxMDAwMDAwMDAwMDAwMDAwMDAwIn0sIm5vbmNlIjoiNTIxNDg5OTMxOTcyNDE0NDI4ODMzMDM1NTYwMTQyOTUzMzIxOTcwMTc1OTU0MjQ0NTIyNDc0NzY1NjA5MzY2OTQwNTExODIyMDY4ODEiLCJkZWFkbGluZSI6IjExNTc5MjA4OTIzNzMxNjE5NTQyMzU3MDk4NTAwODY4NzkwNzg1MzI2OTk4NDY2NTY0MDU2NDAzOTQ1NzU4NDAwNzkxMzEyOTYzOTkzNSJ9LCJ0cmFuc2ZlckRldGFpbHMiOnsidG8iOiIweGYzOUZkNmU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iiwic2lnbmF0dXJlIjoiMHhkYWIyOTE1Y2M0OTM4ZDdkNDg0ZDVmNDQxYWNmYjJmYmMyNGJjNTFkYzJkMmYwOTUwZjY5MzM1ZGQ4ZGYxZTBhMzY0YmIxNmE5Y2MxNDkyMjQyZjI4ODkyMzRlZGFlNDYyODFjMDhiYWQ3MzM0ZGQzZmFlNmE3NjRlMzAwZGMwYjFjIiwibmV0d29ya0lkIjoxMDB9XQ==

@0x4007
Copy link
Member

0x4007 commented Feb 29, 2024

Please rebase to a later commit. It makes it more difficult than it needs to be when we see commits that are already merged in.


const PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3"; // same on all chains
Copy link
Member

@molecula451 molecula451 Feb 29, 2024

Choose a reason for hiding this comment

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

if it's going to be removed i think we can leave it as a comment or add it to the readme for others dev to be aware

@molecula451 molecula451 changed the title Dynamic rpc handler feat: Dynamic rpc handler Feb 29, 2024
@Keyrxng
Copy link
Member Author

Keyrxng commented Mar 1, 2024

I'm going to close this PR and open a fresh one

  • I've built the npm module which is in it's own repo ofc so where should I PR against, will someone make a repo for it? Currently working in the browser and via jest (node) at least locally, going to publish and then use the package in the UI code

  • I assume that I'll build the package but it will be hosted under @ubiquity? So for QA I'll just import my own package and then once the ubq package is published it can be swapped

@molecula451
Copy link
Member

I've built the npm module which is in it's own repo ofc

what is your repo's link

@Keyrxng
Copy link
Member Author

Keyrxng commented Mar 1, 2024

I've built the npm module which is in it's own repo ofc

what is your repo's link

https://github.com/Keyrxng/web3-rpc-racer/tree/master

It'll be my first NPM package, esm and cjs builds for fe and be. Everything needed exported properly ( at least locally (i don't see why tht would change pulling it from npm but yet to test that))

@molecula451
Copy link
Member

molecula451 commented Mar 1, 2024

It'll be my first NPM package, esm and cjs builds for fe and be. Everything needed exported properly ( at least locally (i don't see why tht would change pulling it from npm but yet to test that))

but looks crude, at least at first sight, you are planning to add more changes on PR opening or is ready to just PR and review?

If it's a npm package i think a good move it's first upload to npm, as npm can also be remove, for then to test as a package itself

@Keyrxng
Copy link
Member Author

Keyrxng commented Mar 1, 2024

It'll be my first NPM package, esm and cjs builds for fe and be. Everything needed exported properly ( at least locally (i don't see why tht would change pulling it from npm but yet to test that))

but looks crude, at least at first sight, you are planning to add more changes on PR opening or is ready to just PR and review?

That's the plan once I test pulling from npm if everything works then refactor where needed

It's commonplace to have to import from the specific build dirs isn't it? So running jest I'm importing diretly from the cjs module and in the UI importing directly from the esm one

If it's a npm package i think a good move it's first upload to npm, as npm can also be remove, for then to test as a package itself

Exactly, so my PR to the UI code will be removing the logic and adding my test package which can be replaced when the UBQ one is hosted? or the pr will prove it works and the ubq can be published and I'll swap them before merge

@molecula451
Copy link
Member

That's the plan once I test pulling from npm if everything works then refactor where needed

It's commonplace to have to import from the specific build dirs isn't it? So running jest I'm importing diretly from the cjs module and in the UI importing directly from the esm one

I think you are in route, yes, perhaps first local testing with npm link

Context: https://chat.openai.com/share/92e44b12-cb21-42a1-a2cc-b3deb5c0909f

but if you going to close this PR then open an issue where you could add more context

@Keyrxng
Copy link
Member Author

Keyrxng commented Mar 1, 2024

That's the plan once I test pulling from npm if everything works then refactor where needed
It's commonplace to have to import from the specific build dirs isn't it? So running jest I'm importing diretly from the cjs module and in the UI importing directly from the esm one

I think you are in route, yes, perhaps first local testing with npm link

Context: https://chat.openai.com/share/92e44b12-cb21-42a1-a2cc-b3deb5c0909f

but if you going to close this PR then open an issue where you could add more context

everything working with local yarn link my friend yes

Pav changed the original spec of the issue, this is the correct place for it but there's no repo to push the code for the npm module to

@molecula451
Copy link
Member

That's the plan once I test pulling from npm if everything works then refactor where needed
It's commonplace to have to import from the specific build dirs isn't it? So running jest I'm importing diretly from the cjs module and in the UI importing directly from the esm one

I think you are in route, yes, perhaps first local testing with npm link
Context: https://chat.openai.com/share/92e44b12-cb21-42a1-a2cc-b3deb5c0909f
but if you going to close this PR then open an issue where you could add more context

everything working with local yarn link my friend yes

Pav changed the original spec of the issue, this is the correct place for it but there's no repo to push the code for the npm module to

so you're plan it's to PR a fresh ubq-repo for the npm package to then add more changes + submit to the npm repositories?

@Keyrxng
Copy link
Member Author

Keyrxng commented Mar 1, 2024

I'll test npm before I open the new PR but if you could create a repo for me to fork and port the code into that would be sweet

@molecula451
Copy link
Member

I'll test npm before I open the new PR but if you could create a repo for me to fork and port the code into that would be sweet

send the PR against this branch only https://github.com/ubiquity/web3-rpc-racer/tree/web3-rpc-racer-npm-branch and open an issue only to add more context

I'm going to close this PR and open a fresh one

closing now

@molecula451 molecula451 closed this Mar 1, 2024
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.

Implement Dynamic RPC pick handler
3 participants