Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/stable-spec-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Execution Spec Tests - Consume (stable)

on:
push:
branches: [master]
pull_request:
branches: [master, kaustinen-with-shapella]
workflow_dispatch:

env:
FIXTURES_TAG: "[email protected]"

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout go-ethereum
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12.4"

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.4

- name: Build geth evm
run: |
go build -v ./cmd/evm
mkdir -p ${{ github.workspace }}/bin
mv evm ${{ github.workspace }}/bin/evm
chmod +x ${{ github.workspace }}/bin/evm

- name: Archive built evm
uses: actions/upload-artifact@v4
with:
name: evm
path: ${{ github.workspace }}/bin/evm

consume:
runs-on: ubuntu-latest
needs: setup
strategy:
matrix:
filename:
[
fixtures_verkle-genesis.tar.gz,
]
steps:
- name: Download geth evm
uses: actions/download-artifact@v4
with:
name: evm
path: ./bin

- name: Make evm binary executable and add to PATH
run: |
chmod +x ./bin/evm
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH

- name: Download fixtures
uses: robinraju/release-downloader@v1
with:
repository: "ethereum/execution-spec-tests"
tag: "${{ env.FIXTURES_TAG }}"
fileName: "${{ matrix.filename }}"
extract: true
- name: Clone execution-spec-tests and consume tests
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
git clone https://github.com/ethereum/execution-spec-tests -b ${{ env.FIXTURES_TAG }} --depth 1
cd execution-spec-tests
uv run consume direct --evm-bin="${{ github.workspace }}/bin/evm" --input=../fixtures -n auto
shell: bash
46 changes: 35 additions & 11 deletions cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package t8ntool

import (
"fmt"
stdmath "math"
"math/big"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -44,8 +45,9 @@ import (
)

type Prestate struct {
Env stEnv `json:"env"`
Pre types.GenesisAlloc `json:"pre"`
Env stEnv `json:"env"`
Pre types.GenesisAlloc `json:"pre"`
VKT map[common.Hash]hexutil.Bytes `json:"vkt,omitempty"`
}

//go:generate go run github.com/fjl/gencodec -type ExecutionResult -field-override executionResultMarshaling -out gen_execresult.go
Expand Down Expand Up @@ -143,7 +145,8 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
return h
}
var (
statedb = MakePreState(rawdb.NewMemoryDatabase(), pre.Pre)
isEIP4762 = chainConfig.IsVerkle(big.NewInt(int64(pre.Env.Number)), pre.Env.Timestamp)
statedb = MakePreState(rawdb.NewMemoryDatabase(), chainConfig, pre, isEIP4762)
signer = types.MakeSigner(chainConfig, new(big.Int).SetUint64(pre.Env.Number), pre.Env.Timestamp)
gaspool = new(core.GasPool)
blockHash = common.Hash{0x13, 0x37}
Expand All @@ -165,6 +168,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
GasLimit: pre.Env.GasLimit,
GetHash: getHash,
}

// If currentBaseFee is defined, add it to the vmContext.
if pre.Env.BaseFee != nil {
vmContext.BaseFee = new(big.Int).Set(pre.Env.BaseFee)
Expand Down Expand Up @@ -315,7 +319,9 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
evm.Config.Tracer.OnTxEnd(receipt, nil)
}
}

if isEIP4762 {
statedb.AccessEvents().Merge(evm.AccessEvents)
}
txIndex++
}
statedb.IntermediateRoot(chainConfig.IsEIP158(vmContext.BlockNumber))
Expand Down Expand Up @@ -348,6 +354,10 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
// Amount is in gwei, turn into wei
amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei))
statedb.AddBalance(w.Address, uint256.MustFromBig(amount), tracing.BalanceIncreaseWithdrawal)

if isEIP4762 {
statedb.AccessEvents().AddAccount(w.Address, true, stdmath.MaxUint64)
}
}

// Gather the execution-layer triggered requests.
Expand Down Expand Up @@ -418,11 +428,16 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
return statedb, execRs, body, nil
}

func MakePreState(db ethdb.Database, accounts types.GenesisAlloc) *state.StateDB {
tdb := triedb.NewDatabase(db, &triedb.Config{Preimages: true})
func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prestate, verkle bool) *state.StateDB {
tdb := triedb.NewDatabase(db, &triedb.Config{Preimages: true, IsVerkle: verkle})
sdb := state.NewDatabase(tdb, nil)
statedb, _ := state.New(types.EmptyRootHash, sdb)
for addr, a := range accounts {

root := types.EmptyRootHash
if verkle {
root = types.EmptyVerkleHash
}
statedb, _ := state.New(root, sdb)
for addr, a := range pre.Pre {
statedb.SetCode(addr, a.Code)
statedb.SetNonce(addr, a.Nonce, tracing.NonceChangeGenesis)
statedb.SetBalance(addr, uint256.MustFromBig(a.Balance), tracing.BalanceIncreaseGenesisBalance)
Expand All @@ -431,12 +446,21 @@ func MakePreState(db ethdb.Database, accounts types.GenesisAlloc) *state.StateDB
}
}
// Commit and re-open to start with a clean state.
root, _ := statedb.Commit(0, false, false)
statedb, _ = state.New(root, sdb)
mptRoot, err := statedb.Commit(0, false, false)
if err != nil {
panic(err)
}
// If verkle mode started, establish the conversion
if verkle {
if _, ok := statedb.GetTrie().(*trie.VerkleTrie); ok {
return statedb
}
}
statedb, _ = state.New(mptRoot, sdb)
return statedb
}

func rlpHash(x interface{}) (h common.Hash) {
func rlpHash(x any) (h common.Hash) {
hw := sha3.NewLegacyKeccak256()
rlp.Encode(hw, x)
hw.Sum(h[:0])
Expand Down
20 changes: 20 additions & 0 deletions cmd/evm/internal/t8ntool/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ var (
"\t<file> - into the file <file> ",
Value: "block.json",
}
OutputVKTFlag = &cli.StringFlag{
Name: "output.vkt",
Usage: "Determines where to put the `VKT` of the post-state.\n" +
"\t`stdout` - into the stdout output\n" +
"\t`stderr` - into the stderr output\n" +
"\t<file> - into the file <file> ",
Value: "vkt.json",
}
OutputWitnessFlag = &cli.StringFlag{
Name: "output.witness",
Usage: "Determines where to put the `witness` of the post-state.\n" +
"\t`stdout` - into the stdout output\n" +
"\t`stderr` - into the stderr output\n" +
"\t<file> - into the file <file> ",
Value: "witness.json",
}
InputAllocFlag = &cli.StringFlag{
Name: "input.alloc",
Usage: "`stdin` or file name of where to find the prestate alloc to use.",
Expand Down Expand Up @@ -123,6 +139,10 @@ var (
Usage: "`stdin` or file name of where to find the transactions list in RLP form.",
Value: "txs.rlp",
}
InputVKTFlag = &cli.StringFlag{
Name: "input.vkt",
Usage: "`stdin` or file name of where to find the prestate VKT.",
}
SealCliqueFlag = &cli.StringFlag{
Name: "seal.clique",
Usage: "Seal block with Clique. `stdin` or file name of where to find the Clique sealing data.",
Expand Down
Loading
Loading