-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue (#2177) #2276
base: main
Are you sure you want to change the base?
Fix issue (#2177) #2276
Changes from 8 commits
889d1e7
5c1d23b
73cbaa4
42b9932
c2a8c02
012c414
18d25ec
bfb8781
8ce6883
fb34878
832fa72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
package config | ||
|
||
import ( | ||
"fmt" | ||
"github.com/berachain/beacon-kit/primitives/encoding/json" | ||
) | ||
|
||
|
@@ -83,13 +84,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"` | ||
} | ||
VolodymyrBg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// ConsensusSettings holds the configuration for the consensus layer | ||
|
@@ -156,12 +158,69 @@ type AdditionalService struct { | |
Replicas int `json:"replicas"` | ||
} | ||
|
||
// MustMarshalJSON marshals the E2ETestConfig to JSON, panicking if an error. | ||
func (c *E2ETestConfig) MustMarshalJSON() []byte { | ||
jsonBytes, err := json.Marshal(c) | ||
if err != nil { | ||
panic(err) | ||
} | ||
// 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"` | ||
} | ||
|
||
// 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, | ||
}, | ||
} | ||
} | ||
|
||
return jsonBytes | ||
// ValidateNethermindConfig validates the Nethermind configuration | ||
func (c *E2ETestConfig) ValidateNethermindConfig() error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can't know for sure if this solves Nethermind issues unless we make use of it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, pls test the scenario mentioned in #2177 and share the results, that will help us in knowing if this fix really works. Thanks for your work! |
||
// 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 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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not really required