web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

web3 lib optimizations

Open jdevcs opened this issue 1 year ago • 5 comments

According to https://github.com/web3/web3.js/issues/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 avatar Apr 16 '24 16:04 jdevcs

other optimizations from https://github.com/web3/web3.js/issues/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.

EDIT by @krzysu: did you mean https://paulmillr.com/noble/ ?

jdevcs avatar Apr 29 '24 13:04 jdevcs

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 avatar Apr 29 '24 13:04 jdevcs

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

jdevcs avatar Apr 29 '24 13:04 jdevcs

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Jun 29 '24 00:06 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Aug 31 '24 00:08 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Dec 16 '24 00:12 github-actions[bot]