The NEAR development team has carried out perhaps one of the most technically complex yet invisible upgrades in blockchain history. In the midst of active mainnet operations, they completely replaced the smart contract execution engine — and the vast majority of users didn't even notice. This was not just a version change, but a deep engineering effort that included stress tests with "bomb" contracts and navigating the risk of a potential network split.

Why NearVM Became a "Tax"

For a long time, NEAR used its own virtual machine, NearVM, built on a fork of the Wasmer engine. As former NEAR core developer Vadim explained, this "private" compiler was a kind of tax on the team. Every Rust update, every new security feature fell solely on the internal team, which had to manually synchronize and patch the code. The project was even lucky once: it accidentally diverged from the original Wasmer just before a critical vulnerability was discovered in it.

Standardization and Fourfold Acceleration

The choice fell on Wasmtime — an industry standard supported by the Bytecode Alliance. To prove the safety of the transition, network nodes ran real traffic through both virtual machines in parallel, cross-checking every result. The outcomes were impressive: results matched by 99.998%, with a discrepancy in fees of less than 0.002%. At the same time, execution speed increased approximately fourfold.

The Forbidden Zone: The Consensus Problem

The main difficulty, however, lay not in performance but in consensus. In the NEAR network, contract compilation occurs within a block lasting only 600 milliseconds. An optimizing compiler has no upper time limit, which opened the door for an attack: a 128 KB contract that compiles for about 7 seconds could "miss" the block and slow down the entire network.

Seemingly, the obvious solution — setting a hard time limit on compilation — turned out to be forbidden. As Vadim explained, different validators spend different amounts of time on compilation. If a limit were set, some nodes would accept the contract while others would reject it, leading to a network split due solely to a compiler setting. Consensus requires complete predictability, even at the build time level.

An Elegant Solution: Winch

Instead of a hard limit, the team implemented Winch — a single-pass backend for Wasmtime. After refining the missing features, the "worst-case compilation" dropped from 7.6 seconds to 36 milliseconds. Working off-chain provided a "luxury unavailable to the protocol": compilation was moved to a separate type of handler, not tied to the execution nodes.

Analyst's opinion: This upgrade is a brilliant example of what mature infrastructure should look like. NEAR not only improved security and performance but also solved the fundamental problem of determinism under conditions of heterogeneous validator hardware. For the market, this is a signal: the team is capable of carrying out the most complex technical operations without compromising user experience, which strengthens trust in the protocol in the long term.