Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simulators/eth2/engine: Implement EL mock to test CLs #540

Merged
merged 4 commits into from
Jun 14, 2022
Merged
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
11 changes: 11 additions & 0 deletions simulators/eth2/engine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1-alpine AS builder
RUN apk --no-cache add gcc musl-dev linux-headers cmake make clang build-base clang-static clang-dev
ADD . /source
WORKDIR /source
RUN go build -o ./sim .

# Build the runner container.
FROM alpine:latest
ADD . /
COPY --from=builder /source/sim /
ENTRYPOINT ["./sim"]
97 changes: 97 additions & 0 deletions simulators/eth2/engine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Eth2 in Hive

This is *experimental*.

## Configuration

Chain configuration is provided via environment vars, for the clients to build configs in their format of preference.
The configuration (incl. formatting of values) matches the [Eth2 config spec](https://github.com/ethereum/consensus-specs/tree/dev/configs)).

**Each configuration var is prefixed with `HIVE_ETH2_CONFIG_`**.

And configuration variable is runtime-configurable, i.e. client docker images can adopt the Hive config without rebuild.

The `PRESET_BASE` config var refers to the chosen set of compile-time configuration.
By default this is set to `mainnet`, and clients support `minimal` for testing purposes.
Other presets (compile-time configuration) may be introduced over time if required for advanced testing.

## Container preparation

Note `{}` is used for variable substitution, not part of content.

### Validator Client

#### Files

Keystore files, encrypted. The `pubkey` is lowercase, hex with 0x prefix, of validator signing key.
Lower crypto parameters may be used to speed up tests.
See [eip-2335](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2335.md) for the keystore format.
```
/hive/input/keystores/{pubkey}/keystore.json
```

Secret for the matching keystore. The `pubkey` is lowercase, hex with 0x prefix, of validator signing key.
Secret files have mode `0600`. The secret file is raw and bytes can be loaded directly.
No special characters are used for ease with text processing.
```
/hive/input/secrets/{pubkey}
```

#### Env vars

Every standard eth2-config var prefixed with `HIVE_ETH2_CONFIG_`, and additionally:

```yaml
# HTTP API address, or can be assumed to be GRPC if using Prysm.
HIVE_ETH2_BN_API_IP: "{ip}"
HIVE_ETH2_BN_API_PORT: "{port}"

HIVE_ETH2_BN_VENDOR: "{vendor}" # lowercase name of BN type. E.g. "prysm"

HIVE_ETH2_GRAFFITI: "" # graffiti to put in blocks. Disabled if empty.

HIVE_ETH2_VC_API_PORT:
```

### Beacon Node

#### Files

An Eth2 genesis state, encoded with SSZ. Not present when genesis is being tested (requires `HIVE_ETH2_ETH1_RPC_ADDRS`)
```
/hive/input/genesis.ssz
```

#### Env vars

Every standard eth2-config var prefixed with `HIVE_ETH2_CONFIG_`, and additionally:

```yaml
HIVE_ETH2_DEPOSIT_DEPLOY_BLOCK_NUMBER: 0 # decimal number

HIVE_ETH2_BOOTNODE_ENRS: "" # comma separated list of ENRs

# IP address, required to set ENR correct from the start.
# If left empty, the node should attempt to discover its own IP with discv5.
HIVE_ETH2_P2P_IP_ADDRESS: ""
HIVE_ETH2_P2P_TCP_PORT: 9000 # Port to bind libp2p to, put into ENR
HIVE_ETH2_P2P_UDP_PORT: 9000 # Port to bind discv5 to, put into ENR

HIVE_ETH2_P2P_TARGET_PEERS: 10 # Target number of peers

# Some clients have a hard limit on slots that can be skipped without block.
HIVE_ETH2_MAX_SKIP_SLOTS: 1000

# Comma separated list of Eth1 nodes to communicate with.
# Clients should strip off everything after first comma if they do not load-balancing between them.
# If it is left empty, the beacon node should use a "dummy eth1" mode, where it fills Eth1 votes with mock data.
HIVE_ETH2_ETH1_RPC_ADDRS: ""

# Port to expose standard HTTP API on
HIVE_ETH2_BN_API_PORT: 4000
# Port to expose GRPC version of API on (Prysm has both)
HIVE_ETH2_BN_GRPC_PORT: 4001

# If not, metrics should be exposed on the given port
HIVE_ETH2_METRICS_PORT: 8080
```
67 changes: 67 additions & 0 deletions simulators/eth2/engine/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module github.com/ethereum/hive/simulators/eth2/engine

go 1.17

require (
github.com/ethereum/go-ethereum v1.10.17
github.com/ethereum/hive v0.0.0-20220202142700-64e211a795ba
github.com/google/uuid v1.3.0
github.com/herumi/bls-eth-go-binary v0.0.0-20210902234237-7763804ee078
github.com/pkg/errors v0.9.1
github.com/protolambda/eth2api v0.0.0-20220123235524-49a703ed9d94
github.com/protolambda/go-keystorev4 v0.0.0-20210914214957-cf12d9c28a52
github.com/protolambda/zrnt v0.25.0
github.com/protolambda/ztyp v0.2.1
github.com/rauljordan/engine-proxy v0.0.0-20220511134016-2e057ad9d277
github.com/tyler-smith/go-bip39 v1.1.0
github.com/wealdtech/go-eth2-util v1.6.5
)

require (
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5 // indirect
github.com/go-kit/kit v0.9.0 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/holiman/uint256 v1.2.0
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onsi/gomega v1.10.3 // indirect
github.com/prometheus/tsdb v0.10.0 // indirect
github.com/protolambda/bls12-381-util v0.0.0-20210812140640-b03868185758
github.com/shirou/gopsutil v3.21.8+incompatible // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.9 // indirect
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

require (
github.com/btcsuite/btcd/btcec/v2 v2.1.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/kilic/bls12-381 v0.1.0 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/tklauser/numcpus v0.3.0 // indirect
github.com/urfave/cli/v2 v2.5.1 // indirect
github.com/wealdtech/go-bytesutil v1.1.1 // indirect
github.com/wealdtech/go-eth2-types/v2 v2.5.6 // indirect
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
)
Loading