ethereumjs-monorepo
ethereumjs-monorepo copied to clipboard
Add bun to ethereumjs
Bun is a drop in JavaScript replacement that may be able to greatly improve the performance of ethereumjs. The downside is it is much less stable than Node. This is somewhat mitigated by the Bun team being relatively fast to fix bugs when given a minimal reproducable example.
Caveats
I do not recomend using bun for the package manager. I use Bun myself in evmts and though it works i have ran into a lot of issues related to using Bun install in a monorepo. It's not too bad but I would generally recomend this repo sticks with npm (or pnpm) for now.
I do not recomend using bun as test runner over vitest. It's useful as a test runner for simple packages but vitest is much more feature complete. You can however speed up vitest via running it with bun.
Example using bun
My EVMts currently is using the EVM package from ethereumjs and it is working great:
Tasks
These are the tasks I could do to contribute this feature in order:
- [ ] Add example usage of running ethereumjs with bun
- [ ] Add benchmark comparisons
- [ ] Add bun to root level package.json and migrate some of the developer scripts to use bun as runtime
- [ ] Add to CI. Run tests in a matrix vs both node and bun
It's definitely sounds interesting and we certainly be opened whatever ideas you have. We've done some internal experiments with running the ethjs client with bun that failed because bun does not support native TCP sockets from the NodeJS API yet. But, we've had some positive early tests running scripts from the lower level libraries.
Interesting! I see that bun supports a Bun native api for TCP sockets. https://bun.sh/docs/api/tcp Might be able to make an adapter class that uses bun sockets if it's not too hairy.
Yep, definitely open to ideas. It's not a big priority for us at the moment as we still have a fair amount of internal performance related house cleaning to do before trying to bolt on a still relatively unstable new runtime. That said, we're definitely keeping our eye on it so would be interested to hear what specific ideas you have
Hi there, yes, I did some testing here, funny as well, I already wanted to actually start with Bun integration last week but didn't make it due to other duties! 🤩
So my plan/idea here would be to have this on the sideline as a process over some weeks or months (likely: months) and go library by library and see how far we'll get here. It will likely get trickier on higher level libraries with dependencies e.g., but we'll see.
Will give this some additional thought over the next weeks what "support" actually means. Maybe we can start with trying to run the tests, adding simple additional instructions to libraries which work.
Regarding performance I was able to run the tests we have (vitest) with Bun for lower level libraries and this already worked impressively well (I guess I tested up to the Tx library?). Performance for this was the same though, doesn't mean a lot yet I guess (for us performance is a big topic atm, especially running the VM faster would be great).