Skip to content

Commit

Permalink
chore: initial EVM Execution Client Implementation (#10)
Browse files Browse the repository at this point in the history
* feat: evm client implementation

* chore: add docker setup for reth

* chore: gitignore jwt token

* feat: support json-rpc proxy client

* refactor: separate proxy client from engine api client

* chore: naming changes

* chore: address initial PR review comments

* chore: address initial PR review comments batch II

* refactor: remove redundant abstraction in the proxy layer

* chore: rm rollkit as a dependency

* chore: refine client implementation and tests

* chore: update execution api interface name

* chore: renaming go-execution types import path

* refactor: move mocks to its own pkg

* test: SetFinal unit test passing

* chore: add ctx in executor methods

* feat: upgrade to engine api cancun

* spin up local network for tests

* init reth db for the local test network

* add integration tests

* merge changes - upgrade to cancun api

* merge base: upgrade to cancun api

* programatically setup docker dependencies for integration tests

* fix integration test cleanup

* add integration test for GetTxs

* fix getTxs integration test to assert the tx in mempool

* Add integration tests for evm api's

* fix mandatory field validation for payload creation

* send signed transaction to execution layer client

* feat: add proper jwt auth in engine api calls

* refactor: use more concrete types for building engine api payloads

* fix blockhash for block proposal

* upgrade reth version for integration tests

* merge jay/execution-api

* fix initChain unit tests

* fix executeTxs api unit tests

* fix initChain api integration tests

* fix reth setup for integration tests

* fix genproto module dependency

* downgrade go-ethereum

* fix: block hash mismatch when executing txs

* test: fix ExecuteTxs

* chore: remove redundant debug prints

---------

Co-authored-by: Janani Anbarasan <[email protected]>
  • Loading branch information
jim380 and ProgramCpp authored Nov 20, 2024
1 parent 86bb3fb commit 1403e27
Show file tree
Hide file tree
Showing 11 changed files with 1,710 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker/jwttoken/*
!docker/jwttoken/.gitkeep
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
## Architecture

```mermaid
graph LR
subgraph Test Environment
TestClient[Test Client]
MockExecutor[Mock Executor]
end
subgraph Execution Client
EngineAPIExecutionClient
subgraph Client Components
EthClient[Eth Client]
JsonRpcClient[JSON-RPC Client]
end
end
subgraph Execution Layer
Reth[Reth Node]
subgraph Reth APIs
EngineAPI[Engine API]
JsonRPC[JSON-RPC API]
end
end
%% Test Environment Connections
TestClient -->|uses| EngineAPIExecutionClient
JsonRpcClient -->|test mode| MockExecutor
%% Execution Client Connections
EngineAPIExecutionClient -->|eth calls| EthClient
EngineAPIExecutionClient -->|engine calls| JsonRpcClient
EthClient -->|eth/net/web3| JsonRPC
JsonRpcClient -->|engine api| EngineAPI
%% Reth Internal Connections
JsonRPC -->|internal| Reth
EngineAPI -->|internal| Reth
%% Styling
classDef primary fill:#f9f,stroke:#333,stroke-width:2px
classDef secondary fill:#bbf,stroke:#333,stroke-width:1px
class EngineAPIExecutionClient primary
class EthClient,JsonRpcClient,MockExecutor,EngineAPI,JsonRPC secondary
```

The architecture consists of several key components:

1. **Execution Client**

- `EngineAPIExecutionClient`: Main client interface that implements the Execute interface
- `EthClient`: Handles standard Ethereum JSON-RPC calls
- `JsonRpcClient`: Handles Engine API calls

2. **Execution Layer**

- `Reth Node`: Ethereum execution client
- Exposes Engine API and standard JSON-RPC endpoints

3. **Test Environment**
- `Test Client`: Integration tests
- `Mock Executor`: Simulates execution behavior for unit tests

## Development

```bash
$ cd docker
$ docker compose up -d
$ docker compose down
```
33 changes: 33 additions & 0 deletions docker/chain/genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"config": {
"chainId": 1234,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"shanghaiTime": 1677557088,
"cancunTime": 1710338100
},
"alloc": {
"0xd143C405751162d0F96bEE2eB5eb9C61882a736E": {
"balance": "0x4a47e3c12448f4ad000000"
},
"0x944fDcD1c868E3cC566C78023CcB38A32cDA836E": {
"balance": "0x4a47e3c12448f4ad000000"
}
},
"coinbase": "0x0000000000000000000000000000000000000000",
"difficulty": "0x20000",
"extraData": "",
"gasLimit": "0xf4240",
"nonce": "0x0000000000000042",
"mixhash": "0x2c85bcbce56429100b2108254bb56906257582aeafcbd682bc9af67a9f5aee46",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x00"
}
66 changes: 66 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: "reth"

services:
jwt-init:
container_name: jwt-init
image: alpine:3.19
volumes:
- ./jwttoken:/jwt
healthcheck:
test: ["CMD", "test", "-f", "/jwt/jwt.hex"]
interval: 5s
timeout: 5s
retries: 3
command: >
/bin/sh -c "mkdir -p /jwt &&

Check failure on line 15 in docker/docker-compose.yml

View workflow job for this annotation

GitHub Actions / lint / yamllint

15:35 [trailing-spaces] trailing spaces
if [ ! -f /jwt/jwt.hex ]; then

Check failure on line 16 in docker/docker-compose.yml

View workflow job for this annotation

GitHub Actions / lint / yamllint

16:37 [trailing-spaces] trailing spaces
apk add --no-cache openssl &&
openssl rand -hex 32 | tr -d '\n' > /jwt/jwt.hex;

Check failure on line 18 in docker/docker-compose.yml

View workflow job for this annotation

GitHub Actions / lint / yamllint

18:58 [trailing-spaces] trailing spaces
fi"
reth:
container_name: reth
restart: unless-stopped
image: ghcr.io/paradigmxyz/reth:v1.1.1
depends_on:
jwt-init:
condition: service_completed_successfully
ports:
- "9001:9001" # metrics
- "30303:30303" # eth/66 peering
- "8545:8545" # rpc
- "8551:8551" # engine
volumes:
- mainnet_data:/root/.local/share/reth/mainnet
- sepolia_data:/root/.local/share/reth/sepolia
- holesky_data:/root/.local/share/reth/holesky
- logs:/root/logs
- ./jwttoken:/root/jwt:ro
- ./chain:/root/chain:ro
pid: host
entrypoint: /bin/sh -c

Check failure on line 41 in docker/docker-compose.yml

View workflow job for this annotation

GitHub Actions / lint / yamllint

41:27 [trailing-spaces] trailing spaces
command:

Check failure on line 42 in docker/docker-compose.yml

View workflow job for this annotation

GitHub Actions / lint / yamllint

42:13 [trailing-spaces] trailing spaces
- |
reth init --chain /root/chain/genesis.json
reth node \
--chain /root/chain/genesis.json \
--metrics 0.0.0.0:9001 \
--log.file.directory /root/logs \
--authrpc.addr 0.0.0.0 \
--authrpc.port 8551 \
--authrpc.jwtsecret /root/jwt/jwt.hex \
--http --http.addr 0.0.0.0 --http.port 8545 \
--http.api "eth,net,web3,txpool" \
--disable-discovery \
--debug.tip 0x8bf225d50da44f60dee1c4ee6f810fe5b44723c76ac765654b6692d50459f216 \

Check failure on line 55 in docker/docker-compose.yml

View workflow job for this annotation

GitHub Actions / lint / yamllint

55:81 [line-length] line too long (90 > 80 characters)
-vvvvv
volumes:
mainnet_data:
driver: local
sepolia_data:
driver: local
holesky_data:
driver: local
logs:
driver: local
Loading

0 comments on commit 1403e27

Please sign in to comment.