A technical update for parachain teams, runtime engineers, and governance voters regarding the Polkadot Hub. This post is the successor to “Solidity smart contracts: Striking a balance between innovating and traction” post.
After preparation, and a review by Parity, the Web 3 Foundation, BD teams and other ecosystem partners (thank you for all the input in the forum), the decision was made to prioritize ASAP growing an ecosystem of 3rd party providers (e.g. indexers, oracles, AML providers, and similar) that the unblock the
- porting across top tier Eth dapps, and
- enable greater functionality, e.g. economic possibilities in larger markets, for existing Polkadot rollups, and make Polkadot attractive for a greater set of new potential Polkadot rollups (through exposing these 3rd party providers via Polkadot Hub to the entire Polkadot).
Most of these 3rd party providers, as well as the top opportunities in the BD pipeline, require unmodified Solidity contracts, i.e. a 100% EVM compatible solution on Polkadot Hub, and similarly, versions of Solidity earlier than 0.8 are often required. (the Solidity to PVM compiler resolv only works with Solidity >=0.8 and even though it is Ethereum compatible, it isn’t 100% EVM compatible.)
Accordingly, Parity has basically deprioritized all other technical work at Parity (except for Asset Hub migration) so that we can deliver a 100% EVM compatible solution before the Dec holidays.
PVM is the future, but 3rd party provider traction is now
We originally pursued an Ethereum compatible stack that would execute in a PVM implementation rather than an EVM one. Because of its architecture, PVM offers several advantages like the ability to target it with many languages (e.g. Rust, C++, etc.) rather than Ethereum-specific languages like Solidity and Vyper. The PVM will also offer more powerful and less expensive on-chain compute that will unlock use cases that cannot be done on-chain now.
But we had to concede that the tooling stack around PVM was not strong enough to offer a compelling alternative to Ethereum solutions… yet. As an example, the resolc compiler, which compiles Solidity code to PVM bytecode, only works with Solidity versions 0.8 and greater. Many popular contracts (e.g. Circle’s CCTP) use older Solidity versions and the upgrade path can be non-trivial. While this does not affect new projects deploying, many new projects depend on older contracts like CCTP, so we have to make sure to support older versions of the Ethereum stack as well.
Parity will continue working on the PVM tooling stack to address issues like this to lower the barriers of accessing the power of PVM.
Pallet-revive shared stack
Pallet-revive’s ability to handle multiple VM backends allows us to create a shared stack (ETH-RPC + pallet-revive + EVM/PVM) which brings us a lot of advantages, e.g.:
- We can maintain the momentum of in-house expertise and experience we’ve built on ETH-RPC and pallet-revive (as well as take advantage of the audits already done).
- All improvements to ETH-RPC and pallet-revive will benefit both EVM and PVM.
- E.g., precompiles are available to both EVM and PVM on launch, e.g., the XCM precompiles, which will be part of the launch, will be accessible to both.
- Implementing cross-calling of contracts between PVM and EVM will be trivial, and the cross-calling will execute faster.
- Lots of tooling innovation can be shared between PVM and EVM, e.g., we are building an Anvil test node (part of Foundry) that will allow testing smart contracts against our actual implementation (rather than a reference Ethereum/EVM implementation).
- Smaller maintenance/tech debt footprint, i.e., we can allocate more people to innovating in the future.
We evaluated Frontier. While it serves the ecosystem well in specific contexts, it isn’t suitable for our needs on Polkadot Hub for several reasons:
- Not compatible with PVM - making long-term migration and interoperability with PVM difficult.
- Designed for a single VM backend, i.e., forces a double stack solution, instead of a shared stack.
- Doesn’t address key issues - such as the resolution difference of DOT-based currency denominations and robust gas mapping.
REVM
As a 100% EVM-compatible solution, we choose REVM. REVM is:
- Proven in production (e.g. used by Foundry, Hardhat, Optimism, Coinbase, Risc0, and many more).
- Well-maintained.
- Fast.
- Actively audited.
In short: Combining REVM with pallet-revive and our ETH-RPC node is how we get to a high quality 100% EVM compatible solution quickest, and so enable the growth of an ecosystem of top tier 3rd party providers ASAP. And this solution is aligned with Polkadot’s future direction.
Timeline
- Today: PVM preview part 1 on Kusama
- Sep: PVM preview part 2 on Kusama: ERC20 support, basic XCM precompile.
- Late Oct: 100% EVM-compatible REVM on Kusama Hub
- Mid Dec: 100% EVM-compatible REVM on Polkadot Hub, along with PVM preview
Addendum
A note on developer experience
Key to our success in this regard will be a great developer experience, including:
- All existing Solidity contracts deploy unchanged via Foundry or Hardhat, by having their compilation target EVM. This is ideal for the BD pipeline where top tier projects are ported from other blockchains.
- Many can also target PVM unchanged.
- New contracts can easily opt to be compiled via Foundry or Hardhat targeting PVM for lower gas cost and, once we release the JIT, more compute.
- Tooling parity: Anvil-compatible dev node will ship with both VM backends enabled.
A note on gas mapping
Ethereum gas and Polkadot weight are not isomorphic. While simply emulating the EVM gas model might seem like an option, it isn’t a practical one, because:
- It would completely shut the door on throughout optimizations as we wouldn’t be able to account for the faster execution speed when using the PVM JIT.
- We won’t be able to make use of different gas models for different VM backends as this will make interop between them practically impossible.
[UPDATE]
- Changed PolkaVM to PVM.
- Improved wording on “PVM is the future…”.
- Ethreum gas priced is not fixed; hence point removed.