Skip to content

Commit

Permalink
Resolved merge conflicts with upstream/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sugh01 committed Sep 13, 2024
2 parents db2eee2 + ea6586f commit 1b861b4
Show file tree
Hide file tree
Showing 47 changed files with 5,104 additions and 253 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Teku and Lighthouse import keys container error on Windows.

## [v1.5.0] - 2024-09-06

### Added
- Add support for Optimism and Base, using Nethermind Client on Mainnet and Sepolia.

### Changed
- Update client images to latest versions.

#### Fixed
- Remove Peer upper limit of peers on CL

## [v1.4.0] - 2024-07-10

### Fixed
Expand Down Expand Up @@ -41,7 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Update client images to Dencun-ready versions.
- Update client images to Dencun-ready versions.

## [v1.3.1] - 2024-02-14

Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ run-cli: compile ## run cli
@./build/sedge cli --config ./config.yaml

generate: ## generate go files
@go generate ./...
@abigen --abi ./internal/lido/contracts/csmodule/CSModule.abi --bin ./internal/lido/contracts/csmodule/CSModule.bin --pkg csmodule --out ./internal/lido/contracts/csmodule/CSModule.go
@abigen --abi ./internal/lido/contracts/csfeedistributor/CSFeeDistributor.abi --bin ./internal/lido/contracts/csfeedistributor/CSFeeDistributor.bin --pkg csfeedistributor --out ./internal/lido/contracts/csfeedistributor/CSFeeDistributor.go
@abigen --abi ./internal/lido/contracts/csaccounting/CSAccounting.abi --bin ./internal/lido/contracts/csaccounting/CSAccounting.bin --pkg csaccounting --out ./internal/lido/contracts/csaccounting/CSAccounting.go
@abigen --abi ./internal/lido/contracts/mevboostrelaylist/MEVBoostRelayAllowedList.abi --bin ./internal/lido/contracts/mevboostrelaylist/MEVBoostRelayAllowedList.bin --pkg mevboostrelaylist --out ./internal/lido/contracts/mevboostrelaylist/MEVBoostRelayAllowedList.go

@go generate ./...

test: generate ## run tests
@mkdir -p coverage
Expand Down
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func setupJWT(p ui.Prompter, o *CliCmdOptions, skip bool) error {
}
switch o.jwtSourceType {
case SourceTypeCreate:
jwtPath, err := handleJWTSecret(o.generationPath)
jwtPath, err := handleJWTSecret(o.generationPath, "jwtsecret")
o.genData.JWTSecretPath = jwtPath
if err != nil {
return err
Expand Down
99 changes: 91 additions & 8 deletions cli/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ var (
)

const (
execution, consensus, validator, distributedValidator, mevBoost = "execution", "consensus", "validator", "distributedValidator", "mev-boost"
execution, consensus, validator, distributedValidator, mevBoost, optimism = "execution", "consensus", "validator", "distributedValidator", "mev-boost", "optimism"
jwtPathName = "jwtsecret"
)

type CustomFlags struct {
Expand All @@ -57,9 +58,18 @@ type CustomFlags struct {
customDeployBlock string
}

type OptimismFlags struct {
optimismName string
optimismExecutionName string
elOpExtraFlags []string
opExtraFlags []string
isBase bool
}

// GenCmdFlags is a struct that holds the flags of the generate command
type GenCmdFlags struct {
CustomFlags
OptimismFlags
executionName string
consensusName string
validatorName string
Expand Down Expand Up @@ -101,6 +111,7 @@ It will create a 'docker-compose.yml' and a '.env', which you will need later to
You can generate:
- Full Node (execution + consensus + validator)
- Full Node without Validator (execution + consensus)
- Optimism Full Node
- Execution Node
- Consensus Node
- Validator Node
Expand All @@ -115,6 +126,7 @@ You can generate:
cmd.AddCommand(ConsensusSubCmd(sedgeAction))
cmd.AddCommand(ValidatorSubCmd(sedgeAction))
cmd.AddCommand(MevBoostSubCmd(sedgeAction))
cmd.AddCommand(OpFullNodeSubCmd(sedgeAction))

cmd.PersistentFlags().BoolVar(&lidoNode, "lido", false, "generate Lido CSM node")
cmd.PersistentFlags().StringVarP(&generationPath, "path", "p", configs.DefaultAbsSedgeDataPath, "generation path for sedge data. Default is sedge-data")
Expand Down Expand Up @@ -253,7 +265,7 @@ func runGenCmd(out io.Writer, flags *GenCmdFlags, sedgeAction actions.SedgeActio

// Generate jwt secrets if needed
if flags.jwtPath == "" {
flags.jwtPath, err = handleJWTSecret(generationPath)
flags.jwtPath, err = handleJWTSecret(generationPath, jwtPathName)
if err != nil {
return err
}
Expand All @@ -263,6 +275,14 @@ func runGenCmd(out io.Writer, flags *GenCmdFlags, sedgeAction actions.SedgeActio
return err
}
}
var jwtSecretOP string
// If optimism is included in the services, generate the jwt secret for it
if utils.Contains(services, optimism) {
jwtSecretOP, err = handleJWTSecret(generationPath, jwtPathName+"-op")
if err != nil {
return err
}
}

// Overwrite feeRecipient and relayURLs for Lido Node
if lidoNode {
Expand All @@ -278,13 +298,27 @@ func runGenCmd(out io.Writer, flags *GenCmdFlags, sedgeAction actions.SedgeActio

vlStartGracePeriod := configs.NetworkEpochTime(network) * time.Duration(flags.waitEpoch)

var consensusApiUrl string
var executionApiUrl string
var executionAuthUrl string
if combinedClients.Consensus == nil {
consensusApiUrl = flags.consensusApiUrl
}

if combinedClients.Execution == nil {
executionApiUrl = flags.executionApiUrl
executionAuthUrl = flags.executionAuthUrl
}

// Generate docker-compose scripts
gd := generate.GenData{
ExecutionClient: combinedClients.Execution,
ConsensusClient: combinedClients.Consensus,
ValidatorClient: combinedClients.Validator,
Distributed: flags.distributed,
DistributedValidatorClient: combinedClients.DistributedValidator,
ExecutionOPClient: combinedClients.ExecutionOP,
OptimismClient: combinedClients.Optimism,
Network: network,
CheckpointSyncUrl: flags.checkpointSyncUrl,
FeeRecipient: flags.feeRecipient,
Expand All @@ -295,6 +329,9 @@ func runGenCmd(out io.Writer, flags *GenCmdFlags, sedgeAction actions.SedgeActio
ClExtraFlags: flags.clExtraFlags,
VlExtraFlags: flags.vlExtraFlags,
DvExtraFlags: flags.dvExtraFlags,
ElOpExtraFlags: flags.elOpExtraFlags,
OpExtraFlags: flags.opExtraFlags,
IsBase: flags.isBase,
MapAllPorts: flags.mapAllPorts,
Mev: !flags.noMev && utils.Contains(services, validator) && utils.Contains(services, consensus) && !flags.noValidator,
MevImage: flags.mevImage,
Expand All @@ -304,9 +341,9 @@ func runGenCmd(out io.Writer, flags *GenCmdFlags, sedgeAction actions.SedgeActio
MevBoostEndpoint: flags.mevBoostUrl,
Services: services,
VLStartGracePeriod: uint(vlStartGracePeriod.Seconds()),
ExecutionApiUrl: flags.executionApiUrl,
ExecutionAuthUrl: flags.executionAuthUrl,
ConsensusApiUrl: flags.consensusApiUrl,
ExecutionApiUrl: executionApiUrl,
ExecutionAuthUrl: executionAuthUrl,
ConsensusApiUrl: consensusApiUrl,
ECBootnodes: flags.customEnodes,
CCBootnodes: flags.customEnrs,
CustomChainSpecPath: flags.CustomFlags.customChainSpec,
Expand All @@ -317,6 +354,7 @@ func runGenCmd(out io.Writer, flags *GenCmdFlags, sedgeAction actions.SedgeActio
MevBoostOnValidator: flags.mevBoostOnVal,
ContainerTag: containerTag,
LatestVersion: flags.latestVersion,
JWTSecretOP: jwtSecretOP,
}
_, err = sedgeAction.Generate(actions.GenerateOptions{
GenerationData: gd,
Expand Down Expand Up @@ -344,7 +382,7 @@ func runGenCmd(out io.Writer, flags *GenCmdFlags, sedgeAction actions.SedgeActio
}

func valClients(allClients clients.OrderedClients, flags *GenCmdFlags, services []string) (*clients.Clients, error) {
var executionClient, consensusClient, validatorClient *clients.Client
var executionClient, consensusClient, validatorClient, executionOpClient, opClient *clients.Client
var distributedValidatorClient *clients.Client
var err error

Expand All @@ -360,6 +398,7 @@ func valClients(allClients clients.OrderedClients, flags *GenCmdFlags, services
if len(executionParts) > 1 {
log.Warn(configs.CustomExecutionImagesWarning)
executionClient.Image = strings.Join(executionParts[1:], ":")
flags.latestVersion = false
}
}
executionClient.SetImageOrDefault(strings.Join(executionParts[1:], ":"))
Expand All @@ -381,6 +420,7 @@ func valClients(allClients clients.OrderedClients, flags *GenCmdFlags, services
if len(consensusParts) > 1 {
log.Warn(configs.CustomConsensusImagesWarning)
consensusClient.Image = strings.Join(consensusParts[1:], ":")
flags.latestVersion = false
}
}
consensusClient.SetImageOrDefault(strings.Join(consensusParts[1:], ":"))
Expand All @@ -402,6 +442,7 @@ func valClients(allClients clients.OrderedClients, flags *GenCmdFlags, services
if len(validatorParts) > 1 {
log.Warn(configs.CustomValidatorImagesWarning)
validatorClient.Image = strings.Join(validatorParts[1:], ":")
flags.latestVersion = false

}
}
Expand All @@ -412,6 +453,46 @@ func valClients(allClients clients.OrderedClients, flags *GenCmdFlags, services
} else {
validatorClient = nil
}
// optimism client
if utils.Contains(services, optimism) {
optimismParts := strings.Split(flags.optimismName, ":")
opClient, err = clients.RandomChoice(allClients[optimism])
if err != nil {
return nil, err
}
if flags.optimismName != "" {
opClient.Name = "optimism"
if len(optimismParts) > 1 {
opClient.Image = strings.Join(optimismParts[1:], ":")
}
}
opClient.SetImageOrDefault(strings.Join(optimismParts[1:], ":"))
if err = clients.ValidateClient(opClient, optimism); err != nil {
return nil, err
}

optimismExecutionParts := strings.Split(flags.optimismExecutionName, ":")
executionOpClient = allClients[execution]["nethermind"]
if flags.optimismExecutionName != "" {
executionOpClient.Name = optimismExecutionParts[0]
if len(optimismExecutionParts) > 1 {
executionOpClient.Image = strings.Join(optimismExecutionParts[1:], ":")
}
}
executionOpClient.SetImageOrDefault(strings.Join(optimismExecutionParts[1:], ":"))
if err = clients.ValidateClient(executionOpClient, optimism); err != nil {
return nil, err
}

// If set execution-api-url, set execution and beacon to nil
if flags.executionApiUrl != "" {
executionClient = nil
consensusClient = nil
}
} else {
opClient = nil
executionOpClient = nil
}

// distributed validator client
if utils.Contains(services, distributedValidator) {
Expand All @@ -437,6 +518,8 @@ func valClients(allClients clients.OrderedClients, flags *GenCmdFlags, services
Consensus: consensusClient,
Validator: validatorClient,
DistributedValidator: distributedValidatorClient,
ExecutionOP: executionOpClient,
Optimism: opClient,
}, err
}

Expand All @@ -461,7 +544,7 @@ func initGenPath(path string) error {
return nil
}

func handleJWTSecret(generationPath string) (string, error) {
func handleJWTSecret(generationPath, name string) (string, error) {
log.Info(configs.GeneratingJWTSecret)
if !filepath.IsAbs(generationPath) {
return "", fmt.Errorf(configs.GenerateJWTSecretError, fmt.Errorf("generation path must be absolute"))
Expand All @@ -472,7 +555,7 @@ func handleJWTSecret(generationPath string) (string, error) {
return "", fmt.Errorf(configs.GenerateJWTSecretError, err)
}

jwtPath, err := filepath.Abs(filepath.Join(generationPath, "jwtsecret"))
jwtPath, err := filepath.Abs(filepath.Join(generationPath, name))
if err != nil {
return "", fmt.Errorf(configs.GenerateJWTSecretError, err)
}
Expand Down
48 changes: 47 additions & 1 deletion cli/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ func TestGenerateCmd(t *testing.T) {
errors.New("invalid consensus client"),
},
{
"Validator missing consensus-api",
"Validator missing consensus-url",
subCmd{
name: "validator",
args: []string{},
Expand Down Expand Up @@ -1358,6 +1358,52 @@ func TestGenerateCmd(t *testing.T) {
},
nil,
},
{
"Optimism full node",
subCmd{
name: "op-full-node",
},
GenCmdFlags{},
globalFlags{},
nil,
},
{
"Optimism full node with api url",
subCmd{
name: "op-full-node",
},
GenCmdFlags{
executionApiUrl: "https://localhost:8545",
consensusApiUrl: "https://localhost:8000/api/endpoint",
},
globalFlags{},
nil,
},
{
"Optimism full node with only consensus api url",
subCmd{
name: "op-full-node",
},
GenCmdFlags{
consensusApiUrl: "https://localhost:8000/api/endpoint",
},
globalFlags{},
nil,
},
{
"Lido Full-node - Holesky without MEV",
subCmd{
name: "full-node",
},
GenCmdFlags{
noMev: true,
},
globalFlags{
network: NetworkHolesky,
lidoNode: true,
},
nil,
},
{
"Lido Full-node - Holesky without MEV",
subCmd{
Expand Down
Loading

0 comments on commit 1b861b4

Please sign in to comment.