This article analyzes the feasibility of upgrading Xinfin network's EVM to Ethereum latest EVM. There are three types of potential upgrades:
- feature upgrade,
- bug fix,
- other small PRs.
We will analyze separately. Then in each section, we provide a conclusion of whether we should apply the upgrade or not, and if yes, how.
Version Comparison
Since Xinfin's last EVM upgrade (commit link), there are the following new EVM-related hard forks (reverse chronologically ordered):
The Merge, which changes Ethereum consensus to the Beacon Chain proof-of-stake system. Xinfin works with XDPoS consensus, thus this hard fork is unnecessary.
The London hard fork contains two EVM-related EIPs: EIP-3198: BASEFEE opcode and EIP-3529: Reduction in refunds. As the EIP title suggests, the former enables BASEFEE opcode and the latter changes the gas calculating rule.
-
The Berlin hard fork contains these EIP:
- EIP-2929: Gas cost increases for state access opcodes. As the EIP title suggests, it changes the gas calculating rule.
- EIP-2930: Optional access lists. This EIP introduces a new type of transaction which contains an access list.
- EIP-2718: Typed Transaction Envelope, required by EIP-2930.
As illustrated above, the Merge hard fork is unnecessary for Xinfin. On the contrary, the London hard fork and the Berlin hard fork is crucial for Xinfin as they are necessary to make Xinfin's EVM compatible with latest DApps. These two hard forks include a new opcode and a new type of transaction, which is necessary to upgrade the EVM funcionality, and two modifications to the gas rule, which give a more accurate estimation of the time needed to process EVM opcodes.
In short, it is recommended to adopt the new EVM feature in the London and Berlin hard fork, which includes a new opcode, two modification to gas rule, and a new type of transaction.
In addition, there is an opcode push0
which is not in final status yet, but it's in Ethereum's codebase now. It can be put onto the pending list of EVM upgrade.
Bug fix
Looking through a few recent PRs on Ethereum (with search filter "EVM") Pull requests · ethereum/go-ethereum), there is no bug fix PR. However, labeling is not often used for PRs. So it will take some effort to study them and understand their goals and changes to the code. For instance, to understand whether they are small improvement, or bug fix, or a major feature. It will take some effort to pick the major PRs (such as EIPs) among the small ones and to skim through more PRs.
Other Small PRs
The majority of Ethereum PRs (with filter "EVM") are small ones, each of which contains few lines of codes and are easy to port to Xinfin codebase.
By looking through the recent PRs, we found that they only provide minor improvements, such as renaming SUICIDE
to SELFDESTRUCT
, use uint256
rather than big.Int
, etc. No bug fix PR is in recent PRs so they are unnecessary for Xinfin.
A short summary of unique features of Xinfin
Precompiled contracts
Xinfin has the following unique precompiled contracts (and Ethereum does not have them), core/vm/contracts.go
:
ringSignatureVerifier{},
bulletproofVerifier{},
XDCxLastPrice{},
XDCxEpochPrice{},
XDCx trading
The XDCx trading logic is inside evm. core/vm/evm.go
.
How to do the upgrade
After illustrating the current status of Xinfin and Ethereum EVM and their comparisons, we come to the following conclusion on how to do the upgrade:
Overriding Xinfin code by Ethereum code is infeasible, since there are unique features of Xinfin and Ethereum does not have them.
Merging the whole Ethereum EVM is cumbersome, as there will be a huge amount of code conflicts and a dedicated team is needed to handle them. Even if the merge is handled for PRs separately, the huge number of PRs still make it difficult.
-
Specific hard-fork feature upgrade is necessary: features such as new opcodes and new gas rules are necessary to make Xinfin EVM compatible to the latest DApps and reduce the vulnerability of gas-fee related attacks. There needs to be a dedicated upgrading team to port the aforementioned EIPs. And the workload of the EIPs are:
- EIP-2929: this PR, 28 changed files with 980 additions and 73 deletions (lines of code).
- EIP-2930: this PR, 69 changed files with 2,446 additions and 909 deletions.
- EIP-2718: this PR again, 69 changed files with 2,446 additions and 909 deletions.
- EIP-3198: this PR, along with EIP-1559,47 changed files with 1,099 additions and 909 deletions. Or refer to the squashed PR.
- EIP-3529: this PR, 7 changed files with 166 additions and 114 deletions.
Given the workload and its complexity, it will take about 2 months for a small EVM expert team (3-5 people) to properly apply the upgrades, followed by sufficient testing on XDC dev-net and test-net.
- Reactive upgrade is recommended for the future: for the long term EVM upgrade, we recommend reactive upgrade, that is, when there is a request of feature or bug fix, we port the corresponding Ethereum PR to Xinfin codebase.
Discussion (4)
I can think of no reason to delay this ... XDC Network is on a voyage to be #1 and upgrades done earlier than later are part of the trip
RIGHT!
totally agree
Please make the crucial and necessary upgrades as soon as possible to provide a better infrastructure for the dapp developers