Skip to content

[Refactor] Simplify RPC client map key usage in getRpcClient function #3805

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

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

jnsdls
Copy link
Member

@jnsdls jnsdls commented Jul 25, 2024

TL;DR

Fixes an issue with RPC client reuse to improve performance.

What changed?

The change replaces the use of chainId with rpcUrl as the key in the rpcClientMap to ensure the correct RPC client is reused.

How to test?

Test by running existing unit tests and functional tests for RPC client related functionality. Ensure that performance metrics show improvement in RPC client reuse scenarios.

Why make this change?

This change is motivated by the need to improve performance by ensuring the RPC client is correctly reused.



PR-Codex overview

The focus of this PR is to improve performance by fixing the reuse of RPC clients in the rpc.ts file.

Detailed summary

  • Updated variable name from chainId to rpcUrl for clarity
  • Improved RPC client reuse logic by using rpcUrl instead of options.chain.rpc

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Jul 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2024 1:51am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2024 1:51am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2024 1:51am

Copy link

changeset-bot bot commented Jul 25, 2024

🦋 Changeset detected

Latest commit: 5c9af85

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
thirdweb Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

graphite-app bot commented Jul 25, 2024

Your org requires the Graphite merge queue for merging into main

Add the label “merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@jnsdls jnsdls marked this pull request as ready for review July 25, 2024 01:15
@github-actions github-actions bot added the TS SDK Involves changes to the v5 TypeScript SDK. label Jul 25, 2024
Copy link
Member Author

jnsdls commented Jul 25, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @jnsdls and the rest of your teammates on Graphite Graphite

Copy link

codspeed-hq bot commented Jul 25, 2024

CodSpeed Performance Report

Merging #3805 will not alter performance

Comparing refactor/rpc-client-map-usage (5c9af85) with main (cb616f7)

Summary

✅ 9 untouched benchmarks

Copy link
Contributor

github-actions bot commented Jul 25, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 43.23 KB (+0.11% 🔺) 865 ms (+0.11% 🔺) 479 ms (-34.81% 🔽) 1.4 s
thirdweb (cjs) 91.19 KB (+0.04% 🔺) 1.9 s (+0.04% 🔺) 994 ms (+7.9% 🔺) 2.9 s
thirdweb (minimal + tree-shaking) 4.79 KB (-0.11% 🔽) 96 ms (-0.11% 🔽) 116 ms (+504.18% 🔺) 212 ms
thirdweb/chains (tree-shaking) 492 B (0%) 10 ms (0%) 8 ms (-24.04% 🔽) 18 ms
thirdweb/react (minimal + tree-shaking) 13.51 KB (-0.16% 🔽) 271 ms (-0.16% 🔽) 77 ms (+5.71% 🔺) 347 ms

Copy link

codecov bot commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.31%. Comparing base (cb616f7) to head (5c9af85).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3805      +/-   ##
==========================================
+ Coverage   62.14%   62.31%   +0.16%     
==========================================
  Files         964      963       -1     
  Lines       75083    74808     -275     
  Branches     3770     3768       -2     
==========================================
- Hits        46660    46615      -45     
+ Misses      27738    27510     -228     
+ Partials      685      683       -2     
Flag Coverage Δ *Carryforward flag
legacy_packages 65.69% <ø> (ø) Carriedforward from cb616f7
packages 61.73% <100.00%> (+0.19%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files Coverage Δ
packages/thirdweb/src/rpc/rpc.ts 78.36% <100.00%> (+1.84%) ⬆️

... and 2 files with indirect coverage changes

Copy link
Contributor

graphite-app bot commented Jul 25, 2024

Merge activity

…#3805)

### TL;DR
Fixes an issue with RPC client reuse to improve performance.

### What changed?
The change replaces the use of `chainId` with `rpcUrl` as the key in the `rpcClientMap` to ensure the correct RPC client is reused.

### How to test?
Test by running existing unit tests and functional tests for RPC client related functionality. Ensure that performance metrics show improvement in RPC client reuse scenarios.

### Why make this change?
This change is motivated by the need to improve performance by ensuring the RPC client is correctly reused.

---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TS SDK Involves changes to the v5 TypeScript SDK.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants