Skip to content

Commit

Permalink
Support Erigon in Gnosis (#299)
Browse files Browse the repository at this point in the history
* feat: add erigon to gnosis templates

* fix: broken tests

* fix: specific gnosis network tests checks

* fix: gnosis network tests checks

* fix: wrong network in test case
  • Loading branch information
cbermudez97 authored Jul 26, 2023
1 parent be74da0 commit 1df8b8a
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 10 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [Unreleased]

### Added

- Support for Erigon in Gnosis

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/clients/clients_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestSupportedClients(t *testing.T) {
want []string
isErr bool
}{
{"execution", "gnosis", []string{"nethermind"}, false},
{"execution", "gnosis", []string{"nethermind", "erigon"}, false},
{"consensus", "gnosis", utils.Filter(AllClients["consensus"], func(c string) bool { return c != "prysm" }), false},
{"execution", "mainnet", AllClients["execution"], false},
{"consensus", "mainnet", AllClients["consensus"], false},
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestClients(t *testing.T) {
map[string][]string{
"validator": {"lighthouse", "teku", "lodestar"},
"consensus": {"lighthouse", "teku", "lodestar"},
"execution": {"nethermind"},
"execution": {"nethermind", "erigon"},
},
[]string{"consensus", "execution", "validator"},
"gnosis",
Expand Down
21 changes: 20 additions & 1 deletion internal/pkg/generate/envs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,26 @@ func TestGenerateEnvFile(t *testing.T) {
"KEYSTORE_DIR": "./keystore",
},
},
{
name: "Check Erigon for Gnosis network",
data: &GenData{
ExecutionClient: &clients.Client{Name: "erigon"},
Network: "gnosis",
},
fieldsToCheck: map[string]string{
"EL_NETWORK": "gnosis",
},
},
{
name: "Check Nethermind for Gnosis network",
data: &GenData{
ExecutionClient: &clients.Client{Name: "nethermind"},
Network: "gnosis",
},
fieldsToCheck: map[string]string{
"EL_NETWORK": "xdai",
},
},
{
name: "Check wrong network",
data: &GenData{
Expand All @@ -203,7 +223,6 @@ func TestGenerateEnvFile(t *testing.T) {
ConsensusClient: &clients.Client{Name: "teku"},
},
fieldsToCheck: map[string]string{
"EL_NETWORK": "xdai",
"CL_NETWORK": "gnosis",
},
},
Expand Down
17 changes: 12 additions & 5 deletions internal/pkg/generate/generate_scripts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,19 @@ func defaultFunc(t *testing.T, data *GenData, compose, env io.Reader) error {
envData := retrieveEnvData(t, env)
if data.Network == "gnosis" {
// Check that the right network is set
assert.Contains(t, envData, "EL_NETWORK")
assert.Equal(t, "xdai", clean(envData["EL_NETWORK"]))

assert.Contains(t, envData, "CL_NETWORK")
assert.Equal(t, "gnosis", clean(envData["CL_NETWORK"]))
if data.ExecutionClient != nil {
assert.Contains(t, envData, "EL_NETWORK")
if data.ExecutionClient.Name == "nethermind" {
assert.Equal(t, "xdai", clean(envData["EL_NETWORK"]))
} else {
assert.Equal(t, "gnosis", clean(envData["EL_NETWORK"]))
}
}

if data.ConsensusClient != nil {
assert.Contains(t, envData, "CL_NETWORK")
assert.Equal(t, "gnosis", clean(envData["CL_NETWORK"]))
}
} else {
// Check that the right network is set
assert.Contains(t, envData, "NETWORK")
Expand Down
2 changes: 1 addition & 1 deletion templates/envs/gnosis/env_base.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/* docker-compose_base.tmpl */}}
{{ define "env" }}
# --- Global configuration ---
EL_NETWORK=xdai
EL_NETWORK=gnosis
CL_NETWORK=gnosis
{{if .FeeRecipient}}
FEE_RECIPIENT={{.FeeRecipient}}{{end}}
Expand Down
7 changes: 7 additions & 0 deletions templates/envs/gnosis/execution/erigon.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{/* erigon.tmpl */}}
{{ define "execution" }}
# --- Execution Layer - Execution Node - configuration ---
EC_IMAGE_VERSION={{.ElImage}}
EC_DATA_DIR={{.ElDataDir}}
EC_JWT_SECRET_PATH={{.JWTSecretPath}}
{{ end }}
2 changes: 2 additions & 0 deletions templates/envs/gnosis/execution/nethermind.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{/* nethermind.tmpl */}}
{{ define "execution" }}
EL_NETWORK=xdai

# --- Execution Layer - Execution Node - configuration ---
EC_IMAGE_VERSION={{.ElImage}}
NETHERMIND_LOG_LEVEL=INFO
Expand Down

0 comments on commit 1df8b8a

Please sign in to comment.