This repository was archived by the owner on May 30, 2025. It is now read-only.
generated from evstack/template-da-repo
-
Notifications
You must be signed in to change notification settings - Fork 4
feat: restart repo with PureEngineClient #30
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
2f4675e
test: run common test suite
tzdybal cf0b8e1
wip
tzdybal 57990ab
feat: update TxInjector
tzdybal bbed286
build(deps): update go-execution dependency to latest version
tzdybal c5ed01e
feat: new Engine API approach
tzdybal 69a9f83
feat: engine API that kind of works...
tzdybal b91579e
THIS WORKS! IT WAS GENESIS FILE ALL THE TIME!
tzdybal de358c3
refactor: clean up test and engine code, improve block validation checks
tzdybal 0aa51fc
feat: enhance PureEngineClient with block retrieval and finalization
tzdybal f1271d1
refactor: clean up test and engine code, improve block validation checks
tzdybal 691bd93
refactor: consolidate code in eexecution*.go files
tzdybal da82f20
refactor: restructure execution code and enhance testing framework
tzdybal b3fb10b
chore: fix linter errors
tzdybal 80c017c
refactor: update execution tests and docker-compose configuration
tzdybal c6fb37e
docs: update README to reflect PureEngineClient implementation and usage
tzdybal ab9ef42
docs: enhance README with detailed genesis configuration for PureEngi…
tzdybal 8f09ce6
fix: update transaction timestamp handling in execution logic
tzdybal 19b1de2
feat: improve initial block handling, for rollkit compatibility
tzdybal 79ebf16
fix: handle rollkit restarts
tzdybal c04c697
test: add manual transaction submission test for Ethereum client
tzdybal 6987498
chore: fix CI
tzdybal b5deaaa
chore: Remove unused mock implementations in tests
tzdybal e4c0181
test: Fix loop condition in execution test to prevent overshooting
tzdybal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,91 +1,122 @@ | ||
| # Architecture | ||
| # Go Execution EVM | ||
|
|
||
| This repository implements the `execution.Executor` interface from `github.com/rollkit/rollkit/core/execution` (currently on feature branch `feature/exec_api`). It provides a pure Engine API-based execution client for Rollkit. | ||
|
|
||
| ## PureEngineClient Implementation | ||
|
|
||
| The `PureEngineClient` is a 100% Engine API compatible implementation of the `execution.Executor` interface. It connects to an Ethereum execution client (like Reth) and uses both the Engine API and standard Ethereum JSON-RPC API to execute transactions. | ||
|
|
||
| ### Genesis and initial height | ||
|
|
||
| In the context of the EVM, the genesis block is designated as a unique block with the block number `0`. | ||
| To ensure compatibility with both rollkit and the EVM, the only permissible initial height is `1`. | ||
| During `InitChain` EVM genesis block is acknowledged (at height 0), and empty block is created (at height 1). | ||
| This approach ensures that the block numbers between the EVM and rollkit remain consistent and synchronized. | ||
|
|
||
| ### Genesis Requirements | ||
|
|
||
| Since the `PureEngineClient` relies on the Engine API, the genesis configuration must properly enable it with the correct hardfork settings: | ||
|
|
||
| 1. The genesis file must include post-merge hardfork configurations | ||
| 2. `terminalTotalDifficulty` must be set to 0 | ||
| 3. `terminalTotalDifficultyPassed` must be set to true | ||
| 4. Hardforks like `mergeNetsplitBlock`, `shanghaiTime`, and `cancunTime` should be properly configured | ||
|
|
||
| Example of required genesis configuration: | ||
|
|
||
| ```json | ||
| { | ||
| "config": { | ||
| "chainId": 1234, | ||
| "homesteadBlock": 0, | ||
| "eip150Block": 0, | ||
| "eip155Block": 0, | ||
| "eip158Block": 0, | ||
| "byzantiumBlock": 0, | ||
| "constantinopleBlock": 0, | ||
| "petersburgBlock": 0, | ||
| "istanbulBlock": 0, | ||
| "berlinBlock": 0, | ||
| "londonBlock": 0, | ||
| "mergeNetsplitBlock": 0, | ||
| "terminalTotalDifficulty": 0, | ||
| "terminalTotalDifficultyPassed": true, | ||
| "shanghaiTime": 0, | ||
| "cancunTime": 0 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ```mermaid | ||
| graph LR | ||
| subgraph Test Environment | ||
| TestClient[Test Client] | ||
| MockExecutor[Mock Executor] | ||
| end | ||
| Without these settings, the Engine API will not be available, and the `PureEngineClient` will not function correctly. | ||
|
|
||
| subgraph Execution Client | ||
| EngineAPIExecutionClient | ||
| subgraph Client Components | ||
| EthClient[Eth Client] | ||
| JsonRpcClient[JSON-RPC Client] | ||
| end | ||
| end | ||
| ### PayloadID Storage | ||
|
|
||
| subgraph Execution Layer | ||
| Reth[Reth Node] | ||
| subgraph Reth APIs | ||
| EngineAPI[Engine API] | ||
| JsonRPC[JSON-RPC API] | ||
| end | ||
| end | ||
| The `PureEngineClient` maintains the `payloadID` between calls: | ||
|
|
||
| %% 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 | ||
| ``` | ||
| 1. During `InitChain`, a payload ID is obtained from the Engine API via `engine_forkchoiceUpdatedV3` | ||
| 2. This payload ID is stored in the client instance as `c.payloadID` | ||
| 3. The stored payload ID is used in subsequent calls to `GetTxs` to retrieve the current execution payload | ||
| 4. After each `ExecuteTxs` call, a new payload ID is obtained and stored for the next block | ||
|
|
||
| The architecture consists of several key components: | ||
| ### Payload as First Transaction | ||
|
|
||
| 1. **Execution Client** | ||
| The `PureEngineClient` implements a unique approach to transaction execution: | ||
|
|
||
| - `EngineAPIExecutionClient`: Main client interface that implements the Execute interface | ||
| - `EthClient`: Handles standard Ethereum JSON-RPC calls | ||
| - `JsonRpcClient`: Handles Engine API calls | ||
| 1. In `GetTxs`, the entire execution payload is serialized to JSON and returned as the first transaction | ||
| 2. In `ExecuteTxs`, this first transaction is deserialized back into an execution payload | ||
| 3. The remaining transactions are added to the payload's transaction list | ||
| 4. The complete payload is then submitted to the execution client via `engine_newPayloadV3` | ||
|
|
||
| 2. **Execution Layer** | ||
| This approach ensures that: | ||
|
|
||
| - `Reth Node`: Ethereum execution client | ||
| - Exposes Engine API and standard JSON-RPC endpoints | ||
| - The execution payload structure is preserved between calls | ||
| - All execution happens within the EVM | ||
| - It's not possible to create a payload outside of the EVM | ||
| - Transactions cannot be selected or ordered outside of the EVM | ||
|
|
||
| 3. **Test Environment** | ||
| - `Test Client`: Integration tests | ||
| - `Mock Executor`: Simulates execution behavior for unit tests | ||
| ### How Eth API is Used | ||
|
|
||
| ## Development | ||
| The `PureEngineClient` uses the standard Ethereum JSON-RPC API for: | ||
|
|
||
| Run RETH in docker: | ||
| 1. Retrieving block information (via `HeaderByNumber`) | ||
| 2. Reading the genesis block hash and state root | ||
| 3. Getting gas limits and other block parameters | ||
|
|
||
| ```bash | ||
| cd docker | ||
| docker compose up -d | ||
| ``` | ||
| This allows the client to interact with the execution layer for read operations while using the Engine API for write operations. | ||
|
|
||
| Compile `evm-middleware` binary: | ||
| ## Deployment Architecture | ||
|
|
||
| ```mermaid | ||
| graph LR | ||
| subgraph Rollkit Binary | ||
| RollkitCore[Rollkit Core] | ||
| PureEngineClient[PureEngineClient] | ||
| end | ||
|
|
||
| %% Connections | ||
| RollkitCore --> PureEngineClient | ||
| PureEngineClient -->|Engine API| Reth | ||
| PureEngineClient -->|Eth API| Reth | ||
|
|
||
| ```bash | ||
| make build | ||
| ``` | ||
|
|
||
| Run `evm-middleware` binary: | ||
| ## Development and Testing | ||
|
|
||
| ### Running Reth in Docker | ||
|
|
||
| ```bash | ||
| ./build/evm-middleware run --jwt-secret $(cat docker/jwttoken/jwt.hex) | ||
| cd docker | ||
| docker compose up -d | ||
| ``` | ||
|
|
||
| Compile rollkit from `feature/exec_api` branch and run it: | ||
| ### Reading Genesis Information | ||
|
|
||
| If you've modified the genesis file, you can read the genesis hash and state root using the Ethereum JSON-RPC API: | ||
|
|
||
| ```bash | ||
| git checkout feature/exec_api | ||
| go build ./cmd/rollkit | ||
| ./rollkit start | ||
| # Get genesis block hash | ||
| curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x0", false],"id":1}' http://localhost:8545 | jq -r '.result.hash' | ||
|
|
||
| # Get genesis state root | ||
| curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x0", false],"id":1}' http://localhost:8545 | jq -r '.result.stateRoot' | ||
| ``` | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.