Skip to content

Commit

Permalink
a tad more debug options for Nethermind Eth2
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed May 8, 2024
1 parent a65f4a6 commit bea57e1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 25 deletions.
15 changes: 14 additions & 1 deletion docker/test_env/ethereum_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type EthereumNetworkBuilder struct {
addressesToFund []string
waitForFinalization bool
existingFromEnvVar bool
nodeLogLevel string
}

func NewEthereumNetworkBuilder() EthereumNetworkBuilder {
Expand Down Expand Up @@ -94,6 +95,11 @@ func (b *EthereumNetworkBuilder) WithDockerNetworks(networks []string) *Ethereum
return b
}

func (b *EthereumNetworkBuilder) WithNodeLogLevel(nodeLogLevel string) *EthereumNetworkBuilder {
b.nodeLogLevel = nodeLogLevel
return b
}

func (b *EthereumNetworkBuilder) WithExistingConfig(config config.EthereumNetworkConfig) *EthereumNetworkBuilder {
b.existingConfig = &config
return b
Expand Down Expand Up @@ -144,6 +150,7 @@ func (b *EthereumNetworkBuilder) buildNetworkConfig() EthereumNetwork {
n.WaitForFinalization = &b.waitForFinalization
n.EthereumNetworkConfig.EthereumChainConfig = b.ethereumChainConfig
n.EthereumNetworkConfig.CustomDockerImages = b.customDockerImages
n.NodeLogLevel = &b.nodeLogLevel
n.t = b.t
n.ls = b.ls

Expand Down Expand Up @@ -216,6 +223,12 @@ func (b *EthereumNetworkBuilder) importExistingConfig() bool {
b.ethereumChainConfig = b.existingConfig.EthereumChainConfig
b.customDockerImages = b.existingConfig.CustomDockerImages

if b.existingConfig.NodeLogLevel != nil {
b.nodeLogLevel = *b.existingConfig.NodeLogLevel
} else {
b.nodeLogLevel = config.DefaultNodeLogLevel
}

return true
}

Expand Down Expand Up @@ -417,7 +430,7 @@ func (en *EthereumNetwork) startEth2() (blockchain.EVMNetwork, RpcProvider, erro
case config.ExecutionLayer_Geth:
client, clientErr = NewGethEth2(dockerNetworks, en.EthereumChainConfig, generatedDataHostDir, config.ConsensusLayer_Prysm, opts...)
case config.ExecutionLayer_Nethermind:
client, clientErr = NewNethermindEth2(dockerNetworks, generatedDataHostDir, config.ConsensusLayer_Prysm, opts...)
client, clientErr = NewNethermindEth2(dockerNetworks, en.EthereumChainConfig, generatedDataHostDir, config.ConsensusLayer_Prysm, opts...)
case config.ExecutionLayer_Erigon:
client, clientErr = NewErigonEth2(dockerNetworks, en.EthereumChainConfig, generatedDataHostDir, config.ConsensusLayer_Prysm, opts...)
case config.ExecutionLayer_Besu:
Expand Down
58 changes: 34 additions & 24 deletions docker/test_env/nethermind_eth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

// NewNethermindEth2 starts a new Nethermin Eth2 node running in Docker
func NewNethermindEth2(networks []string, generatedDataHostDir string, consensusLayer config.ConsensusLayer, opts ...EnvComponentOption) (*Nethermind, error) {
func NewNethermindEth2(networks []string, chainConfig *config.EthereumChainConfig, generatedDataHostDir string, consensusLayer config.ConsensusLayer, opts ...EnvComponentOption) (*Nethermind, error) {
parts := strings.Split(defaultNethermindEth2Image, ":")
g := &Nethermind{
EnvComponent: EnvComponent{
Expand All @@ -28,6 +28,7 @@ func NewNethermindEth2(networks []string, generatedDataHostDir string, consensus
ContainerVersion: parts[1],
},
generatedDataHostDir: generatedDataHostDir,
chainConfig: chainConfig,
consensusLayer: consensusLayer,
l: logging.GetTestLogger(nil),
ethereumVersion: config.EthereumVersion_Eth2,
Expand Down Expand Up @@ -59,6 +60,37 @@ func (g *Nethermind) getEth2ContainerRequest() (*tc.ContainerRequest, error) {
return nil, err
}

command := []string{
"--datadir=/nethermind",
"--config=/none.cfg",
fmt.Sprintf("--Init.ChainSpecPath=%s/chainspec.json", GENERATED_DATA_DIR_INSIDE_CONTAINER),
"--Init.DiscoveryEnabled=false",
"--Init.WebSocketsEnabled=true",
fmt.Sprintf("--JsonRpc.WebSocketsPort=%s", DEFAULT_EVM_NODE_WS_PORT),
fmt.Sprintf("--Blocks.SecondsPerSlot=%d", g.chainConfig.SecondsPerSlot),
"--JsonRpc.Enabled=true",
"--JsonRpc.EnabledModules=net,eth,consensus,subscribe,web3,admin,txpool,debug,trace",
"--JsonRpc.Host=0.0.0.0",
fmt.Sprintf("--JsonRpc.Port=%s", DEFAULT_EVM_NODE_HTTP_PORT),
"--JsonRpc.EngineHost=0.0.0.0",
"--JsonRpc.EnginePort=" + ETH2_EXECUTION_PORT,
fmt.Sprintf("--JsonRpc.JwtSecretFile=%s", JWT_SECRET_FILE_LOCATION_INSIDE_CONTAINER),
fmt.Sprintf("--KeyStore.KeyStoreDirectory=%s", KEYSTORE_DIR_LOCATION_INSIDE_CONTAINER),
"--KeyStore.BlockAuthorAccount=0x123463a4b065722e99115d6c222f267d9cabb524",
"--KeyStore.UnlockAccounts=0x123463a4b065722e99115d6c222f267d9cabb524",
fmt.Sprintf("--KeyStore.PasswordFiles=%s", ACCOUNT_PASSWORD_FILE_INSIDE_CONTAINER),
"--Network.MaxActivePeers=0",
"--Network.OnlyStaticPeers=true",
"--HealthChecks.Enabled=true", // default slug /health
fmt.Sprintf("--log=%s", strings.ToUpper(g.LogLevel)),
}

if g.LogLevel == "trace" {
command = append(command, "--TraceStore.Enabled=true")
command = append(command, "--Network.DiagTracerEnabled=true")
command = append(command, "--TxPool.ReportMinutes=1")
}

return &tc.ContainerRequest{
Name: g.ContainerName,
Image: g.GetImageWithVersion(),
Expand All @@ -71,29 +103,7 @@ func (g *Nethermind) getEth2ContainerRequest() (*tc.ContainerRequest, error) {
WithStartupTimeout(120 * time.Second).
WithPollInterval(1 * time.Second),
),
Cmd: []string{
"--datadir=/nethermind",
"--config=/none.cfg",
fmt.Sprintf("--Init.ChainSpecPath=%s/chainspec.json", GENERATED_DATA_DIR_INSIDE_CONTAINER),
"--Init.DiscoveryEnabled=false",
"--Init.WebSocketsEnabled=true",
fmt.Sprintf("--JsonRpc.WebSocketsPort=%s", DEFAULT_EVM_NODE_WS_PORT),
"--JsonRpc.Enabled=true",
"--JsonRpc.EnabledModules=net,eth,consensus,subscribe,web3,admin,txpool,debug,trace",
"--JsonRpc.Host=0.0.0.0",
fmt.Sprintf("--JsonRpc.Port=%s", DEFAULT_EVM_NODE_HTTP_PORT),
"--JsonRpc.EngineHost=0.0.0.0",
"--JsonRpc.EnginePort=" + ETH2_EXECUTION_PORT,
fmt.Sprintf("--JsonRpc.JwtSecretFile=%s", JWT_SECRET_FILE_LOCATION_INSIDE_CONTAINER),
fmt.Sprintf("--KeyStore.KeyStoreDirectory=%s", KEYSTORE_DIR_LOCATION_INSIDE_CONTAINER),
"--KeyStore.BlockAuthorAccount=0x123463a4b065722e99115d6c222f267d9cabb524",
"--KeyStore.UnlockAccounts=0x123463a4b065722e99115d6c222f267d9cabb524",
fmt.Sprintf("--KeyStore.PasswordFiles=%s", ACCOUNT_PASSWORD_FILE_INSIDE_CONTAINER),
"--Network.MaxActivePeers=0",
"--Network.OnlyStaticPeers=true",
"--HealthChecks.Enabled=true", // default slug /health
fmt.Sprintf("--log=%s", strings.ToUpper(g.LogLevel)),
},
Cmd: command,
Files: []tc.ContainerFile{
{
HostFilePath: noneCfg.Name(),
Expand Down

0 comments on commit bea57e1

Please sign in to comment.