Frontier: Support for EVM Weight V2

Sharing here the solution that was finally merged in the EVM + Frontier and currently live in Moonbeam networks:

We introduced a set of new StackState trait methods that are called before executing an opcode. StackState is implemented in the Substrate backend, where we define some constant costs associated to virtually any amount of metrics we want the EVM transaction to be bounded to - in the case of WeightV2 support, a metric would be pov_size, but we plan to also have pure support for ref_time instead doing a loose conversion between GasLimit and ref_time.

This has the benefit of being almost completely managed at Substrate level - with the exception of some EVM helpers -, leaving the original Gasometer design untouched.

The main idea is to OutOfGas an EVM transaction when any of the metric pools are exhausted, please refer to the original PR for details.

2 Likes