From 889d1e788257b46786a2081dc5644d866b758e2a Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Mon, 16 Dec 2024 22:49:35 +0200 Subject: [PATCH 1/9] Update config.go Signed-off-by: VolodymyrBg --- testing/e2e/config/config.go | 67 +++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/testing/e2e/config/config.go b/testing/e2e/config/config.go index 51cf4011ea..7286e3b4b9 100644 --- a/testing/e2e/config/config.go +++ b/testing/e2e/config/config.go @@ -13,7 +13,7 @@ // LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). // // TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, // EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND // TITLE. @@ -83,13 +83,14 @@ type NodeSettings struct { ExecutionSettings ExecutionSettings `json:"execution_settings"` } -// ExecutionSettings holds the configuration for the execution layer -// clients. +// ExecutionSettings holds the configuration for the execution layer clients. type ExecutionSettings struct { // Specs holds the node specs for all nodes in the execution layer. Specs NodeSpecs `json:"specs"` // Images specifies the images available for the execution layer. Images map[string]string `json:"images"` + // NethermindConfig holds specific configuration for Nethermind client + NethermindConfig *NethermindConfig `json:"nethermind_config,omitempty"` } // ConsensusSettings holds the configuration for the consensus layer @@ -156,12 +157,70 @@ type AdditionalService struct { Replicas int `json:"replicas"` } +// NethermindConfig holds specific configuration for Nethermind client +type NethermindConfig struct { + // Specific settings for Nethermind + SyncConfig struct { + FastSync bool `json:"FastSync"` + DownloadBodiesInFastSync bool `json:"DownloadBodiesInFastSync"` + DownloadReceiptsInFastSync bool `json:"DownloadReceiptsInFastSync"` + } `json:"SyncConfig"` + + // Settings to improve finalization + ConsensusConfig struct { + ForceSealing bool `json:"ForceSealing"` + TargetBlockGasLimit int64 `json:"TargetBlockGasLimit"` + } `json:"ConsensusConfig"` +} + +// DefaultNethermindConfig returns the default configuration for Nethermind +func DefaultNethermindConfig() *NethermindConfig { + return &NethermindConfig{ + SyncConfig: struct { + FastSync bool + DownloadBodiesInFastSync bool + DownloadReceiptsInFastSync bool + }{ + FastSync: true, + DownloadBodiesInFastSync: true, + DownloadReceiptsInFastSync: true, + }, + ConsensusConfig: struct { + ForceSealing bool + TargetBlockGasLimit int64 + }{ + ForceSealing: true, + TargetBlockGasLimit: 30000000, + }, + } +} + // MustMarshalJSON marshals the E2ETestConfig to JSON, panicking if an error. func (c *E2ETestConfig) MustMarshalJSON() []byte { + // Check if we're using Nethermind and need to set default configuration + for _, nodeSet := range []NodeSet{ + c.NetworkConfiguration.Validators, + c.NetworkConfiguration.FullNodes, + c.NetworkConfiguration.SeedNodes, + } { + for _, node := range nodeSet.Nodes { + if node.ElType == "nethermind" && node.Replicas > 0 { + if c.NodeSettings.ExecutionSettings.NethermindConfig == nil { + c.NodeSettings.ExecutionSettings.NethermindConfig = DefaultNethermindConfig() + } + break + } + } + } + jsonBytes, err := json.Marshal(c) if err != nil { panic(err) } - return jsonBytes } + +// ValidateNethermindConfig validates the Nethermind configuration +func (c *E2ETestConfig) ValidateNethermindConfig() error { + return nil +} From 5c1d23bbd2d58f46ed83d00668c42cb71d875085 Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Tue, 17 Dec 2024 12:23:20 +0200 Subject: [PATCH 2/9] Update config.go Signed-off-by: VolodymyrBg --- testing/e2e/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/e2e/config/config.go b/testing/e2e/config/config.go index 7286e3b4b9..d5d482ef39 100644 --- a/testing/e2e/config/config.go +++ b/testing/e2e/config/config.go @@ -13,7 +13,7 @@ // LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). // // TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// AN “AS IS“ BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, // EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND // TITLE. From 73cbaa4439f52355c47980851e201d3e2f59e54a Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Tue, 17 Dec 2024 12:24:01 +0200 Subject: [PATCH 3/9] Update config.go Signed-off-by: VolodymyrBg --- testing/e2e/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/e2e/config/config.go b/testing/e2e/config/config.go index d5d482ef39..ce45e65c04 100644 --- a/testing/e2e/config/config.go +++ b/testing/e2e/config/config.go @@ -13,7 +13,7 @@ // LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). // // TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS“ BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, // EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND // TITLE. From c2a8c02bc4a52f668d9b79ea016aa396fedeeea3 Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Tue, 17 Dec 2024 12:53:44 +0200 Subject: [PATCH 4/9] Update config.go Signed-off-by: VolodymyrBg --- testing/e2e/config/config.go | 45 +++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/testing/e2e/config/config.go b/testing/e2e/config/config.go index ce45e65c04..b6e0b567b5 100644 --- a/testing/e2e/config/config.go +++ b/testing/e2e/config/config.go @@ -22,6 +22,7 @@ package config import ( + "fmt" "github.com/berachain/beacon-kit/primitives/encoding/json" ) @@ -222,5 +223,47 @@ func (c *E2ETestConfig) MustMarshalJSON() []byte { // ValidateNethermindConfig validates the Nethermind configuration func (c *E2ETestConfig) ValidateNethermindConfig() error { - return nil + // Check if Nethermind config exists + if c.NodeSettings.ExecutionSettings.NethermindConfig == nil { + return fmt.Errorf("nethermind configuration is missing") + } + + config := c.NodeSettings.ExecutionSettings.NethermindConfig + + // Validate SyncConfig + if !config.SyncConfig.FastSync { + // Check if other sync options are consistent + if config.SyncConfig.DownloadBodiesInFastSync || config.SyncConfig.DownloadReceiptsInFastSync { + return fmt.Errorf("sync options are inconsistent: FastSync is disabled but download options are enabled") + } + } + + // Validate ConsensusConfig + if config.ConsensusConfig.TargetBlockGasLimit <= 0 { + return fmt.Errorf("invalid TargetBlockGasLimit: must be greater than 0") + } + + // Validate if Nethermind is actually used in the configuration + nethermindUsed := false + for _, nodeSet := range []NodeSet{ + c.NetworkConfiguration.Validators, + c.NetworkConfiguration.FullNodes, + c.NetworkConfiguration.SeedNodes, + } { + for _, node := range nodeSet.Nodes { + if node.ElType == "nethermind" && node.Replicas > 0 { + nethermindUsed = true + break + } + } + if nethermindUsed { + break + } + } + + if !nethermindUsed { + return fmt.Errorf("nethermind configuration present but Nethermind is not used in the network") + } + + return nil } From 012c41479eaa071e74702e28e009c110b8ce92db Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Tue, 17 Dec 2024 13:02:46 +0200 Subject: [PATCH 5/9] Update config.go Signed-off-by: VolodymyrBg --- testing/e2e/config/config.go | 59 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/testing/e2e/config/config.go b/testing/e2e/config/config.go index b6e0b567b5..91838d853b 100644 --- a/testing/e2e/config/config.go +++ b/testing/e2e/config/config.go @@ -158,44 +158,43 @@ type AdditionalService struct { Replicas int `json:"replicas"` } +// NethermindConfig holds specific configuration for Nethermind client // NethermindConfig holds specific configuration for Nethermind client type NethermindConfig struct { - // Specific settings for Nethermind - SyncConfig struct { - FastSync bool `json:"FastSync"` - DownloadBodiesInFastSync bool `json:"DownloadBodiesInFastSync"` - DownloadReceiptsInFastSync bool `json:"DownloadReceiptsInFastSync"` - } `json:"SyncConfig"` - - // Settings to improve finalization - ConsensusConfig struct { - ForceSealing bool `json:"ForceSealing"` - TargetBlockGasLimit int64 `json:"TargetBlockGasLimit"` - } `json:"ConsensusConfig"` + // Specific settings for Nethermind + SyncConfig struct { + FastSync bool `json:"FastSync"` + DownloadBodiesInFastSync bool `json:"DownloadBodiesInFastSync"` + DownloadReceiptsInFastSync bool `json:"DownloadReceiptsInFastSync"` + } `json:"SyncConfig"` + + // Mining and block production settings + MiningConfig struct { + TargetBlockGasLimit int64 `json:"TargetBlockGasLimit"` + } `json:"MiningConfig"` } // DefaultNethermindConfig returns the default configuration for Nethermind func DefaultNethermindConfig() *NethermindConfig { - return &NethermindConfig{ - SyncConfig: struct { - FastSync bool - DownloadBodiesInFastSync bool - DownloadReceiptsInFastSync bool - }{ - FastSync: true, - DownloadBodiesInFastSync: true, - DownloadReceiptsInFastSync: true, - }, - ConsensusConfig: struct { - ForceSealing bool - TargetBlockGasLimit int64 - }{ - ForceSealing: true, - TargetBlockGasLimit: 30000000, - }, - } + return &NethermindConfig{ + SyncConfig: struct { + FastSync bool + DownloadBodiesInFastSync bool + DownloadReceiptsInFastSync bool + }{ + FastSync: true, + DownloadBodiesInFastSync: true, + DownloadReceiptsInFastSync: true, + }, + MiningConfig: struct { + TargetBlockGasLimit int64 + }{ + TargetBlockGasLimit: 30000000, + }, + } } + // MustMarshalJSON marshals the E2ETestConfig to JSON, panicking if an error. func (c *E2ETestConfig) MustMarshalJSON() []byte { // Check if we're using Nethermind and need to set default configuration From 18d25ec81df5a07a58d42695032ea035e747011c Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Tue, 17 Dec 2024 13:05:17 +0200 Subject: [PATCH 6/9] Update config.go Signed-off-by: VolodymyrBg --- testing/e2e/config/config.go | 41 ------------------------------------ 1 file changed, 41 deletions(-) diff --git a/testing/e2e/config/config.go b/testing/e2e/config/config.go index 91838d853b..c98aad5672 100644 --- a/testing/e2e/config/config.go +++ b/testing/e2e/config/config.go @@ -167,11 +167,6 @@ type NethermindConfig struct { DownloadBodiesInFastSync bool `json:"DownloadBodiesInFastSync"` DownloadReceiptsInFastSync bool `json:"DownloadReceiptsInFastSync"` } `json:"SyncConfig"` - - // Mining and block production settings - MiningConfig struct { - TargetBlockGasLimit int64 `json:"TargetBlockGasLimit"` - } `json:"MiningConfig"` } // DefaultNethermindConfig returns the default configuration for Nethermind @@ -186,40 +181,9 @@ func DefaultNethermindConfig() *NethermindConfig { DownloadBodiesInFastSync: true, DownloadReceiptsInFastSync: true, }, - MiningConfig: struct { - TargetBlockGasLimit int64 - }{ - TargetBlockGasLimit: 30000000, - }, } } - -// MustMarshalJSON marshals the E2ETestConfig to JSON, panicking if an error. -func (c *E2ETestConfig) MustMarshalJSON() []byte { - // Check if we're using Nethermind and need to set default configuration - for _, nodeSet := range []NodeSet{ - c.NetworkConfiguration.Validators, - c.NetworkConfiguration.FullNodes, - c.NetworkConfiguration.SeedNodes, - } { - for _, node := range nodeSet.Nodes { - if node.ElType == "nethermind" && node.Replicas > 0 { - if c.NodeSettings.ExecutionSettings.NethermindConfig == nil { - c.NodeSettings.ExecutionSettings.NethermindConfig = DefaultNethermindConfig() - } - break - } - } - } - - jsonBytes, err := json.Marshal(c) - if err != nil { - panic(err) - } - return jsonBytes -} - // ValidateNethermindConfig validates the Nethermind configuration func (c *E2ETestConfig) ValidateNethermindConfig() error { // Check if Nethermind config exists @@ -237,11 +201,6 @@ func (c *E2ETestConfig) ValidateNethermindConfig() error { } } - // Validate ConsensusConfig - if config.ConsensusConfig.TargetBlockGasLimit <= 0 { - return fmt.Errorf("invalid TargetBlockGasLimit: must be greater than 0") - } - // Validate if Nethermind is actually used in the configuration nethermindUsed := false for _, nodeSet := range []NodeSet{ From bfb87813383aed0c35f8aec687c90f3c357bc779 Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Tue, 17 Dec 2024 13:06:54 +0200 Subject: [PATCH 7/9] Update config.go Signed-off-by: VolodymyrBg --- testing/e2e/config/config.go | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/e2e/config/config.go b/testing/e2e/config/config.go index c98aad5672..2214d86d23 100644 --- a/testing/e2e/config/config.go +++ b/testing/e2e/config/config.go @@ -158,7 +158,6 @@ type AdditionalService struct { Replicas int `json:"replicas"` } -// NethermindConfig holds specific configuration for Nethermind client // NethermindConfig holds specific configuration for Nethermind client type NethermindConfig struct { // Specific settings for Nethermind From 8ce6883580eaaa61307878b93ce3751e362d9d82 Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Tue, 17 Dec 2024 14:16:51 +0200 Subject: [PATCH 8/9] Update config.go Signed-off-by: VolodymyrBg --- testing/e2e/config/config.go | 75 ++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/testing/e2e/config/config.go b/testing/e2e/config/config.go index 2214d86d23..c805514ba4 100644 --- a/testing/e2e/config/config.go +++ b/testing/e2e/config/config.go @@ -13,7 +13,7 @@ // LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). // // TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, // EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND // TITLE. @@ -86,12 +86,12 @@ type NodeSettings struct { // ExecutionSettings holds the configuration for the execution layer clients. type ExecutionSettings struct { - // Specs holds the node specs for all nodes in the execution layer. - Specs NodeSpecs `json:"specs"` - // Images specifies the images available for the execution layer. - Images map[string]string `json:"images"` - // NethermindConfig holds specific configuration for Nethermind client - NethermindConfig *NethermindConfig `json:"nethermind_config,omitempty"` + // Specs holds the node specs for all nodes in the execution layer. + Specs NodeSpecs `json:"specs"` + // Images specifies the images available for the execution layer. + Images map[string]string `json:"images"` + // ClientConfigs holds specific configurations for different execution clients + ClientConfigs map[string]interface{} `json:"client_configs,omitempty"` } // ConsensusSettings holds the configuration for the consensus layer @@ -183,24 +183,39 @@ func DefaultNethermindConfig() *NethermindConfig { } } -// ValidateNethermindConfig validates the Nethermind configuration -func (c *E2ETestConfig) ValidateNethermindConfig() error { - // Check if Nethermind config exists - if c.NodeSettings.ExecutionSettings.NethermindConfig == nil { - return fmt.Errorf("nethermind configuration is missing") +// MustMarshalJSON marshals the E2ETestConfig to JSON, panicking if an error. +func (c *E2ETestConfig) MustMarshalJSON() []byte { + // Initialize client configs map if needed + if c.NodeSettings.ExecutionSettings.ClientConfigs == nil { + c.NodeSettings.ExecutionSettings.ClientConfigs = make(map[string]interface{}) } - config := c.NodeSettings.ExecutionSettings.NethermindConfig - - // Validate SyncConfig - if !config.SyncConfig.FastSync { - // Check if other sync options are consistent - if config.SyncConfig.DownloadBodiesInFastSync || config.SyncConfig.DownloadReceiptsInFastSync { - return fmt.Errorf("sync options are inconsistent: FastSync is disabled but download options are enabled") + // Check for Nethermind nodes and add configuration + for _, nodeSet := range []NodeSet{ + c.NetworkConfiguration.Validators, + c.NetworkConfiguration.FullNodes, + c.NetworkConfiguration.SeedNodes, + } { + for _, node := range nodeSet.Nodes { + if node.ElType == "nethermind" && node.Replicas > 0 { + if _, exists := c.NodeSettings.ExecutionSettings.ClientConfigs["nethermind"]; !exists { + c.NodeSettings.ExecutionSettings.ClientConfigs["nethermind"] = DefaultNethermindConfig() + } + break + } } } - // Validate if Nethermind is actually used in the configuration + jsonBytes, err := json.Marshal(c) + if err != nil { + panic(err) + } + return jsonBytes +} + +// ValidateNethermindConfig validates the Nethermind configuration +func (c *E2ETestConfig) ValidateNethermindConfig() error { + // Check if we have any Nethermind nodes nethermindUsed := false for _, nodeSet := range []NodeSet{ c.NetworkConfiguration.Validators, @@ -219,7 +234,25 @@ func (c *E2ETestConfig) ValidateNethermindConfig() error { } if !nethermindUsed { - return fmt.Errorf("nethermind configuration present but Nethermind is not used in the network") + return nil // No validation needed if Nethermind is not used + } + + // Check if we have Nethermind configuration + nethermindConfig, exists := c.NodeSettings.ExecutionSettings.ClientConfigs["nethermind"] + if !exists { + return fmt.Errorf("nethermind configuration is missing") + } + + config, ok := nethermindConfig.(*NethermindConfig) + if !ok { + return fmt.Errorf("invalid nethermind configuration type") + } + + // Validate SyncConfig + if !config.SyncConfig.FastSync { + if config.SyncConfig.DownloadBodiesInFastSync || config.SyncConfig.DownloadReceiptsInFastSync { + return fmt.Errorf("sync options are inconsistent: FastSync is disabled but download options are enabled") + } } return nil From fb3487872c179a9a7b4b5cf24731e82bdaa4de66 Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Tue, 17 Dec 2024 14:17:58 +0200 Subject: [PATCH 9/9] Update config.go Signed-off-by: VolodymyrBg --- testing/e2e/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/e2e/config/config.go b/testing/e2e/config/config.go index c805514ba4..10b4befb0f 100644 --- a/testing/e2e/config/config.go +++ b/testing/e2e/config/config.go @@ -13,7 +13,7 @@ // LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). // // TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, // EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND // TITLE.