matter-labs / block-explorer

zkSync Era Block Explorer
Apache License 2.0
127 stars 113 forks source link

feature request: Add initial EVM emulation support #318

Open 0xVolosnikov opened 2 weeks ago

0xVolosnikov commented 2 weeks ago

🌟 Feature Request

Support EVM-like contracts and transactions in block explorer.

📝 Description

The EVM emulator adds the ability to deploy and execute EVM bytecode on top of EraVM. For this reason, we would like to support the EVM contracts in the block explorer.

Deployment of EVM contracts differs from deployment of EraVM contracts. For deployment of EVM contracts, a transaction without the to field is used. The data field of this transaction is used as initCode in constructor of the contract being created.

Basic compatibility (allowed transactions without field to in DB schema, small changes in UI) is implemented there: https://github.com/0xVolosnikov/block-explorer/tree/evm-emulator-support This branch is a PoC and requires some work.

At the first step we would like to have the following result:

  1. For EVM-contract deploy transactions, display that this is a contract deploy to address X
  2. For EVM contracts, display in the frontend that it is an EVM contract. In calls to EVM contracts, also display that this is a EVM contract.

📋 Additional Context

How to determine if a smart contract is a EVM contract or not

In AccountCodeStorage system contract isAccountEVM function can be used to check if the contract is EVM smart-contract.

How to launch chain with EVM emulator locally. Install deps and prepare:

git clone https://github.com/matter-labs/zksync-era
cd zksync-era
git checkout evm-emulator/testing
git submodule update --init
export ZKSYNC_HOME=$(pwd) && export PATH=$ZKSYNC_HOME/bin:$PATH
zk

Init chain:

zk init --skip-submodules-checkout --allow-evm-emulator

Run server:

zk server