From bea57e1d76a75166e14a72830e6e9c519663d06c Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Wed, 8 May 2024 11:09:44 +0200 Subject: [PATCH] a tad more debug options for Nethermind Eth2 --- docker/test_env/ethereum_env.go | 15 +++++++- docker/test_env/nethermind_eth2.go | 58 +++++++++++++++++------------- 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/docker/test_env/ethereum_env.go b/docker/test_env/ethereum_env.go index 9e00ff7f0..2e7396cdf 100644 --- a/docker/test_env/ethereum_env.go +++ b/docker/test_env/ethereum_env.go @@ -44,6 +44,7 @@ type EthereumNetworkBuilder struct { addressesToFund []string waitForFinalization bool existingFromEnvVar bool + nodeLogLevel string } func NewEthereumNetworkBuilder() EthereumNetworkBuilder { @@ -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 @@ -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 @@ -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 } @@ -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: diff --git a/docker/test_env/nethermind_eth2.go b/docker/test_env/nethermind_eth2.go index ee3b99fbb..bb13005a9 100644 --- a/docker/test_env/nethermind_eth2.go +++ b/docker/test_env/nethermind_eth2.go @@ -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{ @@ -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, @@ -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(), @@ -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(),