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

web3 lib optimizations #6980

Open
jdevcs opened this issue Apr 16, 2024 · 3 comments
Open

web3 lib optimizations #6980

jdevcs opened this issue Apr 16, 2024 · 3 comments
Labels
5.x 5.0 related issues

Comments

@jdevcs
Copy link
Contributor

jdevcs commented Apr 16, 2024

According to #6861 two biggest packages are Accounts and Eth. Discussed in today's team call:
in next major version for main web3 package size reduction:

  1. Remove reexporting eth-accounts&wallet from main web3 package:
  • keep this as part of mono-repo & also on npm so it will be available for users to use, as most of time DApp users inject 3rd party wallet instead of web3-wallet functionality, and for common accounts functions these will be available in this package directly instead of reexported and using via\by main web3.

  • more good UX for using web3-wallet/accounts like when creating web3 instance users can explicitly set provider and wallet as two different objects , this should be documented

  • explore option of creating feature as well for allowing modification of accounts and wallet functions in web3 core via plugins ( like plugins can set providers and modify requests via middleware )

  1. Removing reexporting following packages:
    Eth-Personal, IBAN, NET, and see possibility of same for other non-frequently used packages that can contribute to size reduction.

  2. Remove redundant code from web3-eth rpc functions , and define one function that takes rpc function ( string, params, validation schema, .etc ) and generate RPC function

@jdevcs jdevcs changed the title web3 lib optimisations web3 lib optimizations Apr 16, 2024
@jdevcs jdevcs added the 5.x 5.0 related issues label Apr 16, 2024
@jdevcs
Copy link
Contributor Author

jdevcs commented Apr 29, 2024

other optimizations from #6861 :

common : 7.8 %

tx: 4.9%

common and tx adds 12.7% in lib so parts of these if not used should be removed and incase if it cannot be done then this functionality should be implemented in lib instead of as these were moved from ethjs/tx to web3.js. This will help to decrease around 12% size. If removing code that was moved from ethjs/tx is planned , use https://github.com/noble directly for signing in web3 lib.

@jdevcs
Copy link
Contributor Author

jdevcs commented Apr 29, 2024

2nd largest package is web3-eth, and

web3_eth.js is 5.4%

RPC method wrappers is 2.4% : this file should be removed and rpc methods should be used directly in web-eth class

@jdevcs
Copy link
Contributor Author

jdevcs commented Apr 29, 2024

web3-errors is 5.4% and in that errors is 4.4% , this should be optimised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.x 5.0 related issues
Projects
None yet
Development

No branches or pull requests

1 participant