Skip to content

Commit

Permalink
Merge pull request #17 from gnosischain/feat/add-erigon
Browse files Browse the repository at this point in the history
Add Erigon to gnosis tests
  • Loading branch information
stdevMac committed Aug 16, 2023
2 parents 11f8671 + 9a6af04 commit 77506a8
Show file tree
Hide file tree
Showing 14 changed files with 1,443 additions and 480 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/dashboard_erigon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Daily Run Erigon

on:
schedule:
- cron: '0 0 * * *' # Run every day at midnight UTC
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- master
types: [ closed ]

jobs:
hive-run:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: stable

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Install Linux packages
run: |
sudo apt-get update
sudo apt-get install libsnappy-dev libc6-dev libc6 build-essential
- name: Checkout code
uses: actions/checkout@v2

- name: Download dependencies
run: go get -v ./...

- name: Build hive
run: go build -v -o hive hive.go

- name: Run Nethermind tests
continue-on-error: true
run: |
./hive --sim ethereum/engine --sim.limit="withdrawals" --client erigon --results-root=${{ github.workspace }}/runs --loglevel=5 --client.checktimelimit=10m --docker.output
- name: Send file over SSH
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
source: ${{ github.workspace }}/runs/*
target: ${{ secrets.DIR }}/
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
name: Daily Command
name: Daily Run Nethermind

on:
schedule:
- cron: '0 0 * * *' # Run every day at midnight UTC
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- master
types: [ closed ]

jobs:
run-command:
hive-run:
runs-on: ubuntu-latest
steps:
- name: Set up Go
Expand Down
6 changes: 1 addition & 5 deletions clients/erigon/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ FROM thorax/erigon:$branch
USER root

# Install script tools.
RUN apk add --update bash curl jq

# Add genesis mapper script.
ADD genesis.json /genesis.json
ADD mapper.jq /mapper.jq
RUN apk add --update bash curl

# Add the startup script.
ADD erigon.sh /erigon.sh
Expand Down
10 changes: 3 additions & 7 deletions clients/erigon/erigon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fi

if [ "$HIVE_BOOTNODE" != "" ]; then
# Somehow the bootnodes flag is not working for erigon, only staticpeers is working for sync tests
FLAGS="$FLAGS --staticpeers $HIVE_BOOTNODE --nodiscover"
FLAGS="$FLAGS --staticpeers $HIVE_BOOTNODE"
fi

if [ "$HIVE_SKIP_POW" != "" ]; then
Expand All @@ -53,7 +53,7 @@ fi

# Create the data directory.
mkdir /erigon-hive-datadir
FLAGS="$FLAGS --datadir /erigon-hive-datadir"
FLAGS="$FLAGS --datadir /erigon-hive-datadir --nodiscover"

# If a specific network ID is requested, use that
if [ "$HIVE_NETWORK_ID" != "" ]; then
Expand All @@ -62,10 +62,6 @@ else
FLAGS="$FLAGS --networkid 1337"
fi

# Configure the chain.
mv /genesis.json /genesis-input.json
jq -f /mapper.jq /genesis-input.json > /genesis.json

# Dump genesis
echo "Supplied genesis state:"
cat /genesis.json
Expand Down Expand Up @@ -135,6 +131,6 @@ if [ "$HIVE_TERMINAL_TOTAL_DIFFICULTY" != "" ]; then
fi

# Launch the main client.
FLAGS="$FLAGS --nat=none --externalcl"
FLAGS="$FLAGS --nat=none"
echo "Running erigon with flags $FLAGS"
$erigon $FLAGS
15 changes: 0 additions & 15 deletions clients/erigon/genesis.json

This file was deleted.

2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ require (
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
Expand Down Expand Up @@ -569,6 +571,8 @@ github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
Expand Down
179 changes: 177 additions & 2 deletions simulators/ethereum/engine/helper/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ func (a Account) Balance() *big.Int {
if !ok {
return common.Big0
}
hexStr := hexBalance.(string)
hexStr := hexBalance.(common.Hash)
balance := common.Big0
_ = balance.FillBytes(common.Hex2Bytes(hexStr))
_ = balance.FillBytes(common.Hex2Bytes(hexStr.String()))
return balance
}

Expand Down Expand Up @@ -335,3 +335,178 @@ func (n *NethermindChainSpec) ToBlock() *types.Block {
//TODO implement me
panic("implement me")
}

type ErigonAura struct {
StepDuration int `json:"stepDuration"`
BlockReward int `json:"blockReward"`
MaximumUncleCountTransition int `json:"maximumUncleCountTransition"`
MaximumUncleCount int `json:"maximumUncleCount"`
Validators struct {
Multi map[string]map[string][]string `json:"multi,omitempty"`
} `json:"validators"`
BlockRewardContractAddress string `json:"blockRewardContractAddress"`
BlockRewardContractTransition int `json:"blockRewardContractTransition"`
RandomnessContractAddress map[string]string `json:"randomnessContractAddress"`
PosdaoTransition int `json:"posdaoTransition"`
BlockGasLimitContractTransitions map[string]string `json:"blockGasLimitContractTransitions"`
Registrar string `json:"registrar"`
WithdrawalContractAddress string `json:"withdrawalContractAddress"`
}

type ErigonConfig struct {
ChainName string `json:"ChainName"`
ChainID int `json:"chainId"`
Consensus string `json:"consensus"`
HomesteadBlock int `json:"homesteadBlock"`
Eip150Block int `json:"eip150Block"`
Eip155Block int `json:"eip155Block"`
ByzantiumBlock int `json:"byzantiumBlock"`
ConstantinopleBlock int `json:"constantinopleBlock"`
PetersburgBlock int `json:"petersburgBlock"`
IstanbulBlock int `json:"istanbulBlock"`
BerlinBlock int `json:"berlinBlock"`
LondonBlock int `json:"londonBlock"`
Eip1559FeeCollectorTransition int `json:"eip1559FeeCollectorTransition"`
Eip1559FeeCollector string `json:"eip1559FeeCollector"`
TerminalTotalDifficulty *big.Int `json:"terminalTotalDifficulty"`
TerminalTotalDifficultyPassed bool `json:"terminalTotalDifficultyPassed"`
ShanghaiTimestamp *big.Int `json:"shanghaiTime"`
Aura ErigonAura `json:"aura"`
}

type ErigonAccount struct {
Balance string `json:"balance"`
Constructor string `json:"constructor,omitempty"`
}

type ErigonGenesis struct {
ErigonConfig ErigonConfig `json:"config"`
AuRaSeal string `json:"auRaSeal"`
ErigonGasLimit string `json:"gasLimit"`
ErigonDifficulty string `json:"difficulty"`
ErigonAlloc map[string]ErigonAccount `json:"alloc"`
}

func (v *ErigonGenesis) Config() *params.ChainConfig {
chainID := big.NewInt(int64(v.ErigonConfig.ChainID))
ttd := big.NewInt(0).SetBytes(common.Hex2Bytes(v.ErigonDifficulty))
shangai := v.ErigonConfig.ShanghaiTimestamp.Uint64() //big.NewInt(v.ErigonConfig.ShanghaiTimestamp
return &params.ChainConfig{
ChainID: chainID,
TerminalTotalDifficulty: ttd,
ShanghaiTime: &shangai,
}
}

func (v *ErigonGenesis) SetConfig(config *params.ChainConfig) {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) Nonce() uint64 {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) SetNonce(nonce uint64) {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) Timestamp() uint64 {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) SetTimestamp(timestamp int64) {
v.ErigonConfig.ShanghaiTimestamp = big.NewInt(timestamp)
}

func (v *ErigonGenesis) ExtraData() []byte {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) SetExtraData(data []byte) {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) GasLimit() uint64 {
return common.HexToHash(v.ErigonGasLimit).Big().Uint64()
}

func (v *ErigonGenesis) SetGasLimit(limit uint64) {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) Difficulty() *big.Int {
return big.NewInt(0).SetBytes(common.Hex2Bytes(v.ErigonDifficulty))
}

func (v *ErigonGenesis) SetDifficulty(difficulty *big.Int) {
v.ErigonDifficulty = common.BigToHash(difficulty).Hex()
}

func (v *ErigonGenesis) MixHash() common.Hash {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) SetMixHash(hash common.Hash) {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) Coinbase() common.Address {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) SetCoinbase(address common.Address) {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) Alloc() GenesisAlloc {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) AllocGenesis(address common.Address, account Account) {
v.ErigonAlloc[address.Hex()] = ErigonAccount{
Balance: account.Balance().String(),
Constructor: account.Constructor(),
}
}

func (v *ErigonGenesis) UpdateTimestamp(timestamp string) {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) Number() uint64 {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) GasUsed() uint64 {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) ParentHash() common.Hash {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) BaseFee() *big.Int {
//TODO implement me
panic("implement me")
}

func (v *ErigonGenesis) ToBlock() *types.Block {
//TODO implement me
panic("implement me")
}
Loading

0 comments on commit 77506a8

Please sign in to comment.