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

Decrease SDK size / introduce submodules #9235

Closed
ruXlab opened this issue Jan 29, 2024 · 2 comments
Closed

Decrease SDK size / introduce submodules #9235

ruXlab opened this issue Jan 29, 2024 · 2 comments

Comments

@ruXlab
Copy link

ruXlab commented Jan 29, 2024

Hello OP team

Is your feature request related to a problem? Please describe.
I found that the SDK size is beyond expected. However, only fraction of the components can be used for the everyday "userspace" tasks.

Describe the solution you'd like
It'd be great to introduce modules so user can choose what functionality needed. For some use cases it'd be just a gas price computation, for other - full blown testing dependencies with FaultDisputeGame.

Describe alternatives you've considered
When building the prod image one of the options is prune test-related contracts using plain rm -rf, releasing about 80Mb of disk space but it's a band-aid solution.

Current version
3.1.8

Steps to reproduce
(in the new folder, no deps installed)

$ npm install @eth-optimism/sdk

$ du -sh node_modules/
451M node_modules/

$ du -h -d1 node_modules/ | sort -hr
451M	node_modules/
414M	node_modules/@eth-optimism <------------ [!!!!!!!!!!]
11M	node_modules/ethers
8.2M	node_modules/@ethersproject
5.0M	node_modules/lodash
2.8M	node_modules/@noble
2.4M	node_modules/aes-js


$ du -h -d3 node_modules/\@eth-optimism/ | sort -hr
414M	node_modules/@eth-optimism/
410M	node_modules/@eth-optimism/contracts-bedrock
393M	node_modules/@eth-optimism/contracts-bedrock/forge-artifacts <----------- [!!!!!!!!!!!!!!]
69M	node_modules/@eth-optimism/contracts-bedrock/forge-artifacts/FaultDisputeGame.t.sol
52M	node_modules/@eth-optimism/contracts-bedrock/forge-artifacts/L1StandardBridge.t.sol
25M	node_modules/@eth-optimism/contracts-bedrock/forge-artifacts/CommonTest.t.sol
17M	node_modules/@eth-optimism/contracts-bedrock/deployments
16M	node_modules/@eth-optimism/contracts-bedrock/forge-artifacts/OptimismPortal.t.sol
14M	node_modules/@eth-optimism/contracts-bedrock/forge-artifacts/console2.sol
14M	node_modules/@eth-optimism/contracts-bedrock/forge-artifacts/console.sol
14M	node_modules/@eth-optimism/contracts-bedrock/forge-artifacts/L2StandardBridge.t.sol
7.9M	node_modules/@eth-optimism/contracts-bedrock/forge-artifacts/StdCheats.sol
7.0M	node_modules/@eth-optimism/contracts-bedrock/forge-artifacts/L2OutputOracle.t.so

....

@roninjin10
Copy link
Contributor

The SDK is extremely large! This is a huge issue for those who are cognizant about bundle size.

Most of the SDK size comes from contract artifacts that are consumed by the SDK in a way such that treeshaking cannot occur. It's not because the sdk itself is very large, it's mostly just one single file. So breaking it up into modules actually won't fix the issue unless the underlying contracts artifacts issue is also fixed. And even then treeshaking for ethers v5 and our class based sdk makes it better but still not great.

For context we created op-viem to address this issue. Op-viem has all the functionality of the SDK in it at a much smaller bundle size hit that gets even better if you only use some of op-viem both viem and op-viem are tree shakable.

Depending on your use case you might not even need op-viem because viem supports the op stack natively

We have no plans to update the @eth-optimism/sdk and suggest everybody consider migrating to viem or op-viem

@roninjin10 roninjin10 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2024
@roninjin10
Copy link
Contributor

roninjin10 commented Jan 29, 2024

Thanks for the issue and if you either

  • Need the sdk updated and want guidance on how to do it
  • Need help migrating to viem
  • Feel like this issue shouldn't have been closed

Just let me know and I'm happy to help :)

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

No branches or pull requests

2 participants