While everyone looked on in amazement on December 1 at 12 p.m. However, being very close to the good old Eth 1.0 chain, we are very excited about this as well. 😀
Some backstory: the EthereumJS ecosystem around the virtual machine it consists of a very modular set of libraries (vm, blockchain, merkle-patricia-tree, tx,…), each of which encapsulates its own dedicated set of functionality. While this is great for the user, it turned out to be not so great for development, as you often need to make changes to multiple libraries at once, which is difficult and time consuming to act on in order to maintain consistency. . in different repositories. So earlier this year we decided to update our setup and combine the VM related libraries into one. monorepo. This is a single repository where it is possible to target changes to multiple libraries within a single pull request and run all the different library test suites together to ensure consistency. At the same time, the benefits of having multiple packs all released individually are maintained.
Since the switch to monorepo, our development activity literally exploded. 😋 We discovered so many things we wanted to improve that we just couldn’t stop, especially since one change often triggered another that was now “so obvious to do”. 😜
So we develop. And developed. And developed. Basically throughout the year. That’s the main reason why you heard relatively little from us over the last few months, we were so busy with all of this.
While late in the process we sometimes wondered if we’d ever put things back together (check out our extensive release notes for an idea of what I mean), today I’m very proud to finally be able to announce: did. 😋 Thanks to an amazing team for all the great and dedicated work on this. 🎉
This is not one but six major releases in our core libraries with our virtual machine at the forefront:
In this post we won’t go too much into the technical details and will rather give a high level overview. For a fuller picture check out the release notes linked above, we really care to make them understandable and readable and give a good overview of all relevant (breaking) changes.
Maybe just an important note: we switched to a new naming scheme throughout these releases and you need to use the new names to get the new versions. previous ethereumjs-vm package, for example, is now installed as follows:
npm install @ethereumjs/vm
It’s okay. What is really in it? Let’s take a quick look.
all forks
EthereumJS Virtual Machine v5 now supports all forks back to genesis. This is an introduction to the history of Ethereum JavaScript and we hope it opens up some new and potentially exciting use cases. We have our own, more on that below.
A virtual machine on a specific HF can be started with:
import VM from '@ethereumjs/vm'; import Common from '@ethereumjs/common'; const common = new Common({ chain: 'mainnet', hardfork: 'spuriousDragon' }); const vm = new VM({ common });
An EIP-centric virtual machine
While hardforks are great for bundling together an agreed set of changes, a hardfork-focused virtual machine has turned out not to be flexible enough to allow for future-driven development where it’s not finalized for quite some time which EIP will become a new one. hardfork (the Sedan hardfork seems to be the best example of this so far).
With the new version of VM, the internal functional modularization layer has been reworked. This allows EIPs to now become native citizens within the virtual machine. A virtual machine can be instantiated with a special set of EIPs as follows:
import Common from '@ethereumjs/common'; import VM from '@ethereumjs/vm'; const common = new Common({ chain: 'mainnet', eips: (2537) }); const vm = new VM({ common });
To get started, we support the following new EIPs (mainly intended for Sedan fork) with virtual machine v5launching:
Typescript
In this EthereumJS release cycle, we can confidently say that we brought our libraries comprehensively into a modern technology stack. A big part of it: With the new releases, we are nearing our long planned and executed TypeScript transition and all of our core libraries as well as internal dependencies are now written in TypeScript.
Just a summary of what makes TypeScript so great and helps make our libraries more robust and secure: TypeScript is a superset of JavaScript and allows developers to know the data types for each variable and each object that is used. In the code. the variable is called address a string or a binary Buffer object? While you don’t get explicit hints about this in JavaScript, which greatly increases the risk of follow-through developer errors, in TypeScript you’ll know for sure.
It also becomes a lot more fun to work on our libraries directly or use the libraries within a 3rd party project, because as a developer you can now get hints like this in the IDE across the entire codebase:
Your development environment with proper TypeScript typing now only knows that a block chain the variable is a @ethereumjs/blockchain object (wait with your comments, Go and Rust developers 😅) and not just “something”. So our own code gets respectively your code (TypeScript) will become much more readable using the new versions of the library.
promises
If you’re not too into JavaScript, you can skip this section, but if you’re a JavaScript developer, you’ll probably sigh with relief at this news, so we’ll at least give it a brief mention:
Another transition complete, all library APIs now work with JavaScript Promises. So no more callbacks anywhere in our entire stack.
The use of the library changes from:
blockchain.getBlock(blockId, block => { console.log(block); });
New API example:
const block = await blockchain.getBlock(blockId); console.log(block);
The small notch in this first example may not seem like it means much at first glance. However, in several of these old-style calls nested together, it gets deeper and deeper, and at some point, the code becomes unreadable. Just google “hell callback” if you’re interested in what this looks like. 🙂 Promises allow you to write significantly more readable code.
Library Refactorings
Sometimes it’s a little hard to imagine needing an engine swap if the car is still running, however at some point it becomes a necessity if you want to safely go the next 10,000 miles. With refactoring in software, it’s often a bit similar. 😀 With this series of releases, we rework the fundamentals of some of our most core libraries and our to blockour tx and partly ours block chain library received a significant rewrite.
These libraries should now be much easier to work with and they should be well poised to provide a solid and secure foundation to build on within the Ethereum JavaScript ecosystem for years to come.
panorama
We hope you like our new releases. This post can only provide a sneak peek of the major changes and things are covered in much more detail in the release notes linked at the beginning of this post. We are happy to hear your comments about our Discord server or our new @EFJavaScript twitter account.
For us, these releases provide a solid foundation to move into a more future-oriented development cycle and we can’t wait to see this come into play. With the VM with all the forks implemented, it is now possible to integrate the VM into our revamped EthereumJS Client Project. We won’t be joining mainnet with this client any time soon. However, we will be able to do our part to help improve customer diversity. The new client in its early stages will allow us to join development testnets like Yolo v2 (and following) and actively help discover and protect against cross-client consensus errors. We will also be able to more actively contribute to future protocol research and participate in subsequent research implementations. You’ll hear more about this once we have a first usable version of our client ready (aimed at full sync on Yolo v2), this will be early next year.
For now, we wish everyone a contemplative end of the year that is complemented by an exciting launch day (week) for Beaconchain! 🚀
The EF JavaScript Team