-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from crytic/plan-generation
Plan generation MVP
- Loading branch information
Showing
22 changed files
with
1,101 additions
and
654 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
participants: | ||
- el_client_type: geth | ||
el_client_image: ethereum/client-go:latest | ||
cl_client_type: lighthouse | ||
cl_client_image: sigp/lighthouse:latest | ||
el_min_cpu: 1000 | ||
el_max_cpu: 1000 | ||
el_min_mem: 2048 | ||
el_max_mem: 2048 | ||
bn_min_cpu: 1000 | ||
bn_max_cpu: 1000 | ||
bn_min_mem: 2048 | ||
bn_max_mem: 2048 | ||
v_min_cpu: 1000 | ||
v_max_cpu: 1000 | ||
v_min_mem: 1024 | ||
v_max_mem: 1024 | ||
count: 1 | ||
- el_client_type: reth | ||
el_client_image: ghcr.io/paradigmxyz/reth:v0.1.0-alpha.13 | ||
cl_client_type: teku | ||
cl_client_image: consensys/teku:23.12.0 | ||
el_min_cpu: 1000 | ||
el_max_cpu: 1000 | ||
el_min_mem: 2048 | ||
el_max_mem: 2048 | ||
bn_min_cpu: 1000 | ||
bn_max_cpu: 1000 | ||
bn_min_mem: 2048 | ||
bn_max_mem: 2048 | ||
count: 1 | ||
- el_client_type: reth | ||
el_client_image: ghcr.io/paradigmxyz/reth:v0.1.0-alpha.13 | ||
cl_client_type: lodestar | ||
cl_client_image: chainsafe/lodestar:v1.12.1 | ||
el_min_cpu: 1000 | ||
el_max_cpu: 1000 | ||
el_min_mem: 2048 | ||
el_max_mem: 2048 | ||
bn_min_cpu: 1000 | ||
bn_max_cpu: 1000 | ||
bn_min_mem: 2048 | ||
bn_max_mem: 2048 | ||
v_min_cpu: 1000 | ||
v_max_cpu: 1000 | ||
v_min_mem: 1024 | ||
v_max_mem: 1024 | ||
count: 1 | ||
- el_client_type: reth | ||
el_client_image: ghcr.io/paradigmxyz/reth:v0.1.0-alpha.13 | ||
cl_client_type: lighthouse | ||
cl_client_image: sigp/lighthouse:latest | ||
el_min_cpu: 1000 | ||
el_max_cpu: 1000 | ||
el_min_mem: 2048 | ||
el_max_mem: 2048 | ||
bn_min_cpu: 1000 | ||
bn_max_cpu: 1000 | ||
bn_min_mem: 2048 | ||
bn_max_mem: 2048 | ||
v_min_cpu: 1000 | ||
v_max_cpu: 1000 | ||
v_min_mem: 1024 | ||
v_max_mem: 1024 | ||
count: 1 | ||
- el_client_type: reth | ||
el_client_image: ghcr.io/paradigmxyz/reth:v0.1.0-alpha.13 | ||
cl_client_type: prysm | ||
cl_client_image: prysmaticlabs/prysm-beacon-chain:latest,prysmaticlabs/prysm-validator:latest | ||
el_min_cpu: 1000 | ||
el_max_cpu: 1000 | ||
el_min_mem: 2048 | ||
el_max_mem: 2048 | ||
bn_min_cpu: 1000 | ||
bn_max_cpu: 1000 | ||
bn_min_mem: 2048 | ||
bn_max_mem: 2048 | ||
v_min_cpu: 1000 | ||
v_max_cpu: 1000 | ||
v_min_mem: 1024 | ||
v_max_mem: 1024 | ||
count: 1 | ||
network_params: | ||
num_validator_keys_per_node: 32 | ||
additional_services: | ||
- prometheus_grafana | ||
- dora | ||
parallel_keystore_generation: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package plan | ||
|
||
import ( | ||
"fmt" | ||
"github.com/kurtosis-tech/stacktrace" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
func preparePaths(testName string) (netRefPath, netConfigPath, planConfigPath string, err error) { | ||
dir, err := os.Getwd() | ||
// initialize to empty string for error cases | ||
netConfigPath = "" | ||
planConfigPath = "" | ||
if err != nil { | ||
return | ||
} | ||
|
||
netRefPath = fmt.Sprintf("plan/%s.yaml", testName) | ||
networkConfigName := fmt.Sprintf("network-configs/%s", netRefPath) | ||
netConfigPath = filepath.Join(dir, networkConfigName) | ||
if _, err = os.Stat(netConfigPath); err == nil { | ||
// delete file | ||
err = os.Remove(netConfigPath) | ||
if err != nil { | ||
err = stacktrace.Propagate(err, "unable to remove file") | ||
return | ||
} | ||
} | ||
|
||
suiteName := fmt.Sprintf("test-suites/plan/%s.yaml", testName) | ||
planConfigPath = filepath.Join(dir, suiteName) | ||
if _, err = os.Stat(planConfigPath); err == nil { | ||
// delete file | ||
err = os.Remove(planConfigPath) | ||
if err != nil { | ||
err = stacktrace.Propagate(err, "unable to remove file") | ||
return | ||
} | ||
} | ||
err = nil | ||
return | ||
} | ||
|
||
func writePlans(netConfigPath, suiteConfigPath string, netConfig, suiteConfig []byte) error { | ||
f, err := os.Create(netConfigPath) | ||
if err != nil { | ||
return stacktrace.Propagate(err, "cannot open network types path %s", netConfigPath) | ||
} | ||
_, err = f.Write(netConfig) | ||
if err != nil { | ||
return stacktrace.Propagate(err, "could not write network types to file") | ||
} | ||
|
||
err = f.Close() | ||
if err != nil { | ||
return stacktrace.Propagate(err, "could not close network types file") | ||
} | ||
|
||
f, err = os.Create(suiteConfigPath) | ||
if err != nil { | ||
return stacktrace.Propagate(err, "cannot open suite types path %s", suiteConfigPath) | ||
} | ||
_, err = f.Write(suiteConfig) | ||
if err != nil { | ||
return stacktrace.Propagate(err, "could not write suite types to file") | ||
} | ||
|
||
err = f.Close() | ||
if err != nil { | ||
return stacktrace.Propagate(err, "could not close suite types file") | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,25 @@ | ||
package network | ||
|
||
import ( | ||
"attacknet/cmd/pkg/plan/types" | ||
"strings" | ||
"github.com/kurtosis-tech/stacktrace" | ||
) | ||
|
||
const default_el_cpu = 1000 | ||
const default_cl_cpu = 1000 | ||
const default_val_cpu = 1000 | ||
|
||
const default_el_mem = 1024 | ||
const default_cl_mem = 2048 | ||
const default_val_mem = 1024 | ||
|
||
func buildConsensusClient(config types.ClientVersion) *types.ConsensusClient { | ||
image := config.Image | ||
validatorImage := "" | ||
|
||
if strings.Contains(config.Image, ",") { | ||
images := strings.Split(config.Image, ",") | ||
image = images[0] | ||
validatorImage = images[1] | ||
} | ||
if config.HasSidecar { | ||
return &types.ConsensusClient{ | ||
Type: config.Name, | ||
Image: image, | ||
HasValidatorSidecar: true, | ||
ValidatorImage: validatorImage, | ||
ExtraLabels: make(map[string]string), | ||
CpuRequired: default_cl_cpu, | ||
MemoryRequired: default_cl_mem, | ||
SidecarCpuRequired: default_val_cpu, | ||
SidecarMemoryRequired: default_val_mem, | ||
} | ||
} else { | ||
return &types.ConsensusClient{ | ||
Type: config.Name, | ||
Image: image, | ||
HasValidatorSidecar: false, | ||
ValidatorImage: validatorImage, | ||
ExtraLabels: make(map[string]string), | ||
CpuRequired: default_cl_cpu, | ||
MemoryRequired: default_cl_mem, | ||
SidecarCpuRequired: 0, | ||
SidecarMemoryRequired: 0, | ||
} | ||
func buildNode(index int, execConf, consensusConf ClientVersion) *Node { | ||
return &Node{ | ||
Index: index, | ||
Execution: composeExecutionClient(execConf), | ||
Consensus: composeConsensusClient(consensusConf), | ||
} | ||
} | ||
|
||
func buildExecutionClient(config types.ClientVersion) *types.ExecutionClient { | ||
return &types.ExecutionClient{ | ||
Type: config.Name, | ||
Image: config.Image, | ||
ExtraLabels: make(map[string]string), | ||
CpuRequired: default_cl_cpu, | ||
MemoryRequired: default_cl_mem, | ||
func composeBootnode(execClients, consensusClients map[string]ClientVersion) (*Node, error) { | ||
execConf, ok := execClients["geth"] | ||
if !ok { | ||
return nil, stacktrace.NewError("unable to load configuration for exec client geth") | ||
} | ||
} | ||
|
||
func buildNode(index int, execConf, consensusConf types.ClientVersion) *types.Node { | ||
return &types.Node{ | ||
Index: index, | ||
Execution: buildExecutionClient(execConf), | ||
Consensus: buildConsensusClient(consensusConf), | ||
consConf, ok := consensusClients["lighthouse"] | ||
if !ok { | ||
return nil, stacktrace.NewError("unable to load configuration for exec client lighthouse") | ||
} | ||
return buildNode(0, execConf, consConf), nil | ||
} |
Oops, something went wrong.