The NEAR Protocol development team has executed perhaps one of the most elegant and technically complex maneuvers in blockchain history: while the mainnet was running, they completely replaced the virtual machine responsible for executing all smart contracts. As planned, users noticed nothing.
For a long time, NEAR relied on NearVM — a fork of the Wasmer engine. This solution essentially imposed a private "tax" on development: every update to the Rust language, every new security feature fell solely on the shoulders of the protocol team. As one former core developer noted, the project was once incredibly lucky: they accidentally avoided a critical vulnerability in the original Wasmer simply because they hadn't synchronized with its update in time.
The new foundation became Wasmtime — an industry standard supported by the Bytecode Alliance. To prove the safety of the migration, network nodes ran real traffic through both virtual machines in parallel, cross-checking every result. The outcomes are impressive: the discrepancy in fees was less than 0.002%, and contract execution speed increased approximately fourfold.
Forbidden Solution and Compiler "Bombs"
The main challenge, however, lay not in execution itself, but in contract compilation. In the NEAR architecture, contract deployment is compiled directly within a block lasting only 600 milliseconds. The optimizing compiler has no upper time limit, which opened the door for an attack. Specialists created a 128 KB contract whose compilation took about 7 seconds — enough to miss the block and slow down the entire network.
The obvious solution — introducing a time limit on compilation — turned out to be forbidden. As engineers explained, different validators spend varying amounts of time on compilation, and a borderline contract would be accepted by some nodes but rejected by others. The result would be a network split (fork) due to a single compiler setting. Consensus requires absolute predictability, even at the build time level.
The team found another way out. They implemented Winch — a single-pass Wasmtime backend — and added the missing functions to it. As a result, the "worst-case compilation" dropped from 7.6 seconds to 36 milliseconds. Working outside the blockchain provided a luxury unavailable to the protocol: compilation was moved to a separate type of handler, unrelated to the executing nodes.
The Nearcore 2.12 release transitioned the NEAR execution environment from NearVM to Wasmtime. For developers and users, nothing changed, and that's the whole point: the team closed a critical technical debt without breaking anything.
Analyst's opinion: This case is a brilliant example of engineering culture, where network security and stability are prioritized over hype. Replacing the engine under load is open-heart surgery, and NEAR performed it without a single glitch. This significantly strengthens trust in the protocol from a technical perspective.