Skip to content

Commit

Permalink
sim-merge: activate geth, commit ids as workflow env vars, simple txs…
Browse files Browse the repository at this point in the history
… scenario, dockerized geth based config for tests (#3460)

* activate geth and EL interop sim commits as workflow env vars

* simple tx scenario and dockerized geth configs for local run

* local dir cleanup
  • Loading branch information
g11tech authored Dec 6, 2021
1 parent 59bd4c7 commit 1bf5457
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 38 deletions.
33 changes: 19 additions & 14 deletions .github/workflows/test-sim-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Sim merge tests

on: [pull_request, push]

env:
GETH_COMMIT: 932939feb6735f4295911063c09b1100aee24cb1
NETHERMIND_COMMIT: 8e54f87ce2e36e20a73b73a0e470816b1edc9b92

jobs:
sim-merge-tests:
name: Sim merge tests
Expand Down Expand Up @@ -31,27 +35,28 @@ jobs:
if: steps.cache-deps.outputs.cache-hit == 'true'
# </common-build>

# Install Geth merge interop
# - uses: actions/setup-go@v2
# - name: Clone Geth merge interop branch
# run: git clone -b kintsugi-spec https://github.com/MariusVanDerWijden/go-ethereum.git && cd go-ethereum && git reset --hard b629e2560aae26059bf69ef19690385e078cbefd && git submodule update
# - name: Build Geth
# run: cd go-ethereum && make
#Install Geth merge interop
- uses: actions/setup-go@v2
- name: Clone Geth merge interop branch
run: git clone -b kintsugi-spec https://github.com/MariusVanDerWijden/go-ethereum.git && cd go-ethereum && git reset --hard $GETH_COMMIT && git submodule update --init --recursive
- name: Build Geth
run: cd go-ethereum && make

# - name: Test Lodestar <> Geth interop
# run: yarn test:sim:merge-interop
# working-directory: packages/lodestar
# env:
# EL_BINARY_DIR: ../../go-ethereum/build/bin
# EL_SCRIPT_DIR: geth
# EL_PORT: 8545
- name: Test Lodestar <> Geth interop
run: yarn test:sim:merge-interop
working-directory: packages/lodestar
env:
EL_BINARY_DIR: ../../go-ethereum/build/bin
EL_SCRIPT_DIR: geth
EL_PORT: 8545
TX_SCENARIOS: simple

# Install Nethermind merge interop
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
- name: Clone Nethermind merge interop branch
run: git clone -b themerge_kintsugi https://github.com/NethermindEth/nethermind --recursive && cd nethermind && git reset --hard 8e54f87ce2e36e20a73b73a0e470816b1edc9b92 && git submodule update
run: git clone -b themerge_kintsugi https://github.com/NethermindEth/nethermind --recursive && cd nethermind && git reset --hard $NETHERMIND_COMMIT && git submodule update --init --recursive
- name: Build Nethermind
run: cd nethermind/src/Nethermind && dotnet build Nethermind.sln -c Release

Expand Down
14 changes: 14 additions & 0 deletions kintsugi/geth/common-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -x

echo $TTD
echo $DATA_DIR
echo $scriptDir
echo $EL_BINARY_DIR

env TTD=$TTD envsubst < $scriptDir/genesisPre.tmpl > $DATA_DIR/genesis.json
echo "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8" > $DATA_DIR/sk.json
echo "12345678" > $DATA_DIR/password.txt
pubKey="0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"

$EL_BINARY_DIR/geth --catalyst --datadir $DATA_DIR init $DATA_DIR/genesis.json
$EL_BINARY_DIR/geth --catalyst --datadir $DATA_DIR account import $DATA_DIR/sk.json --password $DATA_DIR/password.txt
10 changes: 2 additions & 8 deletions kintsugi/geth/post-merge.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#!/bin/bash -x

scriptDir=$(dirname $0)
. $scriptDir/common-setup.sh

echo $TTD
echo $DATA_DIR
echo $scriptDir
echo $EL_BINARY_DIR

env TTD=$TTD envsubst < $scriptDir/genesisPost.tmpl > $DATA_DIR/genesis.json
$EL_BINARY_DIR/geth --catalyst --datadir $DATA_DIR init $DATA_DIR/genesis.json
$EL_BINARY_DIR/geth --catalyst --http --ws -http.api "engine,net,eth" --datadir $DATA_DIR
$EL_BINARY_DIR/geth --catalyst --http --ws -http.api "engine,net,eth" --datadir $DATA_DIR --allow-insecure-unlock --unlock $pubKey --password $DATA_DIR/password.txt
14 changes: 1 addition & 13 deletions kintsugi/geth/pre-merge.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
#!/bin/bash -x

scriptDir=$(dirname $0)
. $scriptDir/common-setup.sh

echo $TTD
echo $DATA_DIR
echo $scriptDir
echo $EL_BINARY_DIR


env TTD=$TTD envsubst < $scriptDir/genesisPre.tmpl > $DATA_DIR/genesis.json
echo "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8" > $DATA_DIR/sk.json
echo "12345678" > $DATA_DIR/password.txt
pubKey="0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"

$EL_BINARY_DIR/geth --catalyst --datadir $DATA_DIR init $DATA_DIR/genesis.json
$EL_BINARY_DIR/geth --catalyst --datadir $DATA_DIR account import $DATA_DIR/sk.json --password $DATA_DIR/password.txt
$EL_BINARY_DIR/geth --catalyst --http --ws -http.api "engine,net,eth,miner" --datadir $DATA_DIR --allow-insecure-unlock --unlock $pubKey --password $DATA_DIR/password.txt --nodiscover --mine
12 changes: 12 additions & 0 deletions kintsugi/gethdocker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Build Geth in a stock Go builder container
FROM golang:1.17-alpine as builder

RUN apk add --no-cache gcc musl-dev linux-headers git

RUN git clone --depth 1 -b kintsugi-spec https://github.com/MariusVanDerWijden/go-ethereum.git /go-ethereum
RUN cd /go-ethereum && go run build/ci.go install ./cmd/geth

FROM alpine:latest
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/

EXPOSE 8545 8546 30303 30303/udp
13 changes: 13 additions & 0 deletions kintsugi/gethdocker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Geth Docker setup for running the sim merge tests on local machine

###### Build geth docker image
```bash
cd kintsugi/gethdocker
docker build . --tag geth:kintsugi
```

###### Run test scripts
```bash
cd packages/lodestar
EL_BINARY_DIR=geth:kintsugi EL_SCRIPT_DIR=gethdocker EL_PORT=8545 TX_SCENARIOS=simple yarn mocha test/sim/merge-interop.test.ts
```
18 changes: 18 additions & 0 deletions kintsugi/gethdocker/common-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -x

echo $TTD
echo $DATA_DIR
echo $EL_BINARY_DIR

echo $scriptDir
echo $currentDir


env TTD=$TTD envsubst < $scriptDir/genesisPre.tmpl > $DATA_DIR/genesis.json
echo "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8" > $DATA_DIR/sk.json
echo "12345678" > $DATA_DIR/password.txt
pubKey="0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"


docker run --rm -u $(id -u ${USER}):$(id -g ${USER}) -v $currentDir/$DATA_DIR:/data $EL_BINARY_DIR geth --catalyst --datadir /data init /data/genesis.json
docker run --rm -u $(id -u ${USER}):$(id -g ${USER}) -v $currentDir/$DATA_DIR:/data $EL_BINARY_DIR geth --catalyst --datadir /data account import /data/sk.json --password /data/password.txt
36 changes: 36 additions & 0 deletions kintsugi/gethdocker/genesisPost.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"config":
{
"chainId":1,
"homesteadBlock":0,
"eip150Block":0,
"eip155Block":0,
"eip158Block":0,
"byzantiumBlock":0,
"constantinopleBlock":0,
"petersburgBlock":0,
"istanbulBlock":0,
"muirGlacierBlock":0,
"berlinBlock":0,
"londonBlock":0,
"clique": {
"period": 5,
"epoch": 30000
},
"terminalTotalDifficulty":${TTD}
},
"nonce":"0x42",
"timestamp":"0x0",
"extraData":"0x0000000000000000000000000000000000000000000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit":"0x1C9C380",
"difficulty":"0x400000000",
"mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase":"0x0000000000000000000000000000000000000000",
"alloc":{
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b":{"balance":"0x6d6172697573766477000000"}
},
"number":"0x0",
"gasUsed":"0x0",
"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas":"0x7"
}
36 changes: 36 additions & 0 deletions kintsugi/gethdocker/genesisPre.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"config": {
"chainId": 1,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"clique": {
"period": 5,
"epoch": 30000
},
"terminalTotalDifficulty": ${TTD}
},
"nonce": "0x42",
"timestamp": "0x0",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x1c9c380",
"difficulty": "0x0",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {"balance": "0x6d6172697573766477000000"}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas": "0x7"
}
8 changes: 8 additions & 0 deletions kintsugi/gethdocker/post-merge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -x

scriptDir=$(dirname $0)
currentDir=$(pwd)

. $scriptDir/common-setup.sh

docker run --rm -u $(id -u ${USER}):$(id -g ${USER}) --network host -v $currentDir/$DATA_DIR:/data $EL_BINARY_DIR geth --catalyst --http --ws -http.api "engine,net,eth" --allow-insecure-unlock --unlock $pubKey --password /data/password.txt --datadir /data
9 changes: 9 additions & 0 deletions kintsugi/gethdocker/pre-merge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -x

scriptDir=$(dirname $0)
currentDir=$(pwd)

. $scriptDir/common-setup.sh

# EL_BINARY_DIR refers to the local docker image build from kintsugi/gethdocker folder
docker run --rm -u $(id -u ${USER}):$(id -g ${USER}) --network host -v $currentDir/$DATA_DIR:/data $EL_BINARY_DIR geth --catalyst --http --ws -http.api "engine,net,eth,miner" --allow-insecure-unlock --unlock $pubKey --password /data/password.txt --datadir /data --nodiscover --mine
Loading

0 comments on commit 1bf5457

Please sign in to comment.