Skip to content

Commit

Permalink
feat: Add Lido Flow (#389)
Browse files Browse the repository at this point in the history
* feat: add method GetRelaysURI and adjust mevboostrelaylist package

* feat: add lido flow for cli.go

* refactor: adjust prompts for lido flow

* feat: add non-interactive lido flow

* style: adjust formatting

* fix: adjust formatting

* test: add e2e test for non-interactive setup

* fix: adjust e2e test

* style: adjust formatting

* test: Add mocks test for non-interactive setup in cli/generate_test.go

* doc: documentation for lido csm on sedge

* test: adjust e2e tests for lido flow

* fix: update go.mod

* fix: Adjust generate_test.go

* feat: Add --lido to sedge keys

* feat: Overwrite WithdrawalAddress in prompts setup

* refactor: error messages

* refactor: adjust tests and naming

* test: adjust keys for holesky

* doc: Update Sedge with Lido guide (#390)

* feat: MEV prompt with lido

* refactor: Validate lido supported networks

* refactor: NodeOptionsFactory interface for cli

* refactor: NodeOptionsFactory interface for sedge generate

* fix: Holesky fork version

* refac: New pkg options for Sedge setup type logic

* feat(keys): Log keystore path after generation

* doc: Add --network holesky to sedge keys --lido example

* chore: Update go.mod

* fix documentation for update on commands

* doc: Update CHANGELOG

---------

Co-authored-by: Marcos Maceo <[email protected]>
Co-authored-by: Miguel Tenorio <[email protected]>
Co-authored-by: AntiD2ta <[email protected]>
  • Loading branch information
4 people authored Jul 9, 2024
1 parent 4bb728e commit ee821a8
Show file tree
Hide file tree
Showing 44 changed files with 1,868 additions and 118 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add support for MEV-boost on Holesky.
- New flag `--lido` to `generate` command for Lido CSM setup.
- New Sedge setup flow with `sedge cli` command for Lido CSM setup.
- Support for `sedge keys` to generate 0x01 withdrawal credentials.

### Changed

- Update client images to Dencun-ready versions.
- Renamed `--eth1-withdrawal-address` flag from `sedge keys` to `--eth-withdrawal-address`.
- Update client images to latest versions.

### Removed

- Removed support for Goerli.

## [v1.3.1] - 2024-02-14
Expand Down
54 changes: 51 additions & 3 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/NethermindEth/sedge/internal/pkg/clients"
"github.com/NethermindEth/sedge/internal/pkg/dependencies"
"github.com/NethermindEth/sedge/internal/pkg/generate"
sedgeOpts "github.com/NethermindEth/sedge/internal/pkg/options"
"github.com/NethermindEth/sedge/internal/ui"

"github.com/NethermindEth/sedge/cli/actions"
Expand Down Expand Up @@ -79,6 +80,7 @@ type CliCmdOptions struct {
keystorePassphrasePath string
keystorePassphrase string
withdrawalAddress string
nodeSetup string
numberOfValidators int64
existingValidators int64
installDependencies bool
Expand All @@ -96,13 +98,15 @@ func CliCmd(p ui.Prompter, actions actions.SedgeActions, depsMgr dependencies.De
- Execution Node
- Consensus Node
- Validator Node
- Lido CSM Node
Follow the prompts to select the options you want for your node. At the end of the process, you will
be asked to run the generated setup or not. If you chose to run the setup, it will be executed for you
using docker compose command behind the scenes.
`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := runPromptActions(p, o,
selectNodeSetup,
selectNetwork,
selectNodeType,
inputGenerationPath,
Expand Down Expand Up @@ -614,8 +618,20 @@ func runPromptActions(p ui.Prompter, o *CliCmdOptions, actions ...promptAction)
return nil
}

func selectNodeSetup(p ui.Prompter, o *CliCmdOptions) (err error) {
options := []string{sedgeOpts.EthereumNode, sedgeOpts.LidoNode}
index, err := p.Select("Select node setup", "", options)
if err != nil {
return err
}
o.nodeSetup = options[index]
return
}

func selectNetwork(p ui.Prompter, o *CliCmdOptions) error {
options := []string{NetworkMainnet, NetworkSepolia, NetworkGnosis, NetworkChiado, NetworkHolesky}
opts := sedgeOpts.CreateSedgeOptions(o.nodeSetup)
options := opts.SupportedNetworks()

index, err := p.Select("Select network", "", options)
if err != nil {
return err
Expand Down Expand Up @@ -792,6 +808,12 @@ func confirmInstallDependencies(p ui.Prompter, o *CliCmdOptions) (err error) {
}

func confirmEnableMEVBoost(p ui.Prompter, o *CliCmdOptions) (err error) {
opts := sedgeOpts.CreateSedgeOptions(o.nodeSetup)
enableMev := opts.MEVBoostEnabled(o.genData.Network)
if opts.OverwriteSettings().MevBoost {
o.withMevBoost = enableMev
return
}
o.withMevBoost, err = p.Confirm("Enable MEV Boost?", true)
return
}
Expand Down Expand Up @@ -847,8 +869,16 @@ func inputMevBoostEndpoint(p ui.Prompter, o *CliCmdOptions) (err error) {
}

func inputRelayURL(p ui.Prompter, o *CliCmdOptions) (err error) {
var defaultValue []string = configs.NetworksConfigs()[o.genData.Network].RelayURLs
relayURLs, err := p.InputList("Insert relay URLs if you don't want to use the default values listed below", defaultValue, func(list []string) error {
opts := sedgeOpts.CreateSedgeOptions(o.nodeSetup)
relayURLs, err := opts.RelayURLs(o.genData.Network)
if err != nil {
return err
}
if relayURLs != nil && opts.OverwriteSettings().RelayURLs {
o.genData.RelayURLs = relayURLs
return
}
relayURLs, err = p.InputList("Insert relay URLs if you don't want to use the default values listed below", relayURLs, func(list []string) error {
badUri, ok := utils.UriValidator(list)
if !ok {
return fmt.Errorf(configs.InvalidUrlFlagError, "relay", badUri)
Expand All @@ -870,11 +900,23 @@ func inputCheckpointSyncURL(p ui.Prompter, o *CliCmdOptions) (err error) {
}

func inputFeeRecipient(p ui.Prompter, o *CliCmdOptions) (err error) {
opts := sedgeOpts.CreateSedgeOptions(o.nodeSetup)
feeRecipient := opts.FeeRecipient(o.genData.Network)
if opts.OverwriteSettings().FeeRecipient {
o.genData.FeeRecipient = feeRecipient
return
}
o.genData.FeeRecipient, err = p.EthAddress("Please enter the Fee Recipient address", "", true)
return
}

func inputFeeRecipientNoValidator(p ui.Prompter, o *CliCmdOptions) (err error) {
opts := sedgeOpts.CreateSedgeOptions(o.nodeSetup)
feeRecipient := opts.FeeRecipient(o.genData.Network)
if opts.OverwriteSettings().FeeRecipient {
o.genData.FeeRecipient = feeRecipient
return
}
o.genData.FeeRecipient, err = p.EthAddress("Please enter the Fee Recipient address (press enter to skip it)", "", false)
return
}
Expand Down Expand Up @@ -929,6 +971,12 @@ func inputKeystorePassphrase(p ui.Prompter, o *CliCmdOptions) (err error) {
}

func inputWithdrawalAddress(p ui.Prompter, o *CliCmdOptions) (err error) {
opts := sedgeOpts.CreateSedgeOptions(o.nodeSetup)
withdrawalAddress := opts.WithdrawalAddress(o.genData.Network)
if opts.OverwriteSettings().WithdrawalAddress {
o.withdrawalAddress = withdrawalAddress
return
}
o.withdrawalAddress, err = p.Input("Withdrawal address", "", false, func(s string) error { return ui.EthAddressValidator(s, true) })
return
}
Expand Down
Loading

0 comments on commit ee821a8

Please sign in to comment.