Skip to content

Commit

Permalink
Merge branch 'develop' into tests/lido-mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
khalifaa55 authored Nov 14, 2024
2 parents 9305dd9 + a204f33 commit 70ca40a
Show file tree
Hide file tree
Showing 78 changed files with 3,441 additions and 5,338 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/dependency_review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 #v4.2.0
- name: 'Dependency Review'
uses: actions/dependency-review-action@4081bf99e2866ebe428fc0477b69eb4fcda7220a #v4.4.0
with:
fail-on-severity: high
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
token: ${{ steps.gh-app.outputs.token }}
commit-message: Update Homebrew to latest release
title: "[Release] Update Homebrew"
reviewers: AntiD2ta, cbermudez97, stdevMac, adriantpaez
reviewers: AntiD2ta, cbermudez97, adriantpaez
draft: false
path: homebrew-sedge
add-paths: |
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v1.7.1] - 2024-11-1

### Added
- Updates on support for `op-geth` and `op-reth` clients on Optimism and Base networks.

### Changed
- Updated Sedge's Docker commands internal functionality.
- Changed the `--op-execution-image` flag to `--op-execution` on the `generate op-full-node` command.

## [v1.7.0] - 2024-10-24

### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ The following roadmap covers the main features and ideas we want to implement bu
- [x] Support for Lido CSM
- [x] Support for Nimbus client as Consensus and Validator
- [x] Include monitoring tool for alerting, tracking validator balance, and tracking sync progress and status of nodes
- [x] Support for Optimism and Base.
- [ ] More tests!!!


Expand Down
4 changes: 4 additions & 0 deletions cli/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
package actions

import (
"github.com/NethermindEth/sedge/internal/compose"
"github.com/NethermindEth/sedge/internal/pkg/commands"
"github.com/NethermindEth/sedge/internal/pkg/generate"
"github.com/docker/docker/client"
Expand All @@ -39,19 +40,22 @@ type sedgeActions struct {
dockerClient client.APIClient
dockerServiceManager DockerServiceManager
commandRunner commands.CommandRunner
composeManager compose.ComposeManager
}

type SedgeActionsOptions struct {
DockerClient client.APIClient
DockerServiceManager DockerServiceManager
CommandRunner commands.CommandRunner
ComposeManager compose.ComposeManager
}

func NewSedgeActions(options SedgeActionsOptions) SedgeActions {
return &sedgeActions{
dockerClient: options.DockerClient,
dockerServiceManager: options.DockerServiceManager,
commandRunner: options.CommandRunner,
composeManager: options.ComposeManager,
}
}

Expand Down
14 changes: 5 additions & 9 deletions cli/actions/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/NethermindEth/sedge/configs"
"github.com/NethermindEth/sedge/internal/pkg/commands"
log "github.com/sirupsen/logrus"
)

type RunContainersOptions struct {
Expand All @@ -31,24 +30,21 @@ type RunContainersOptions struct {
}

func (s *sedgeActions) RunContainers(options RunContainersOptions) error {
upCmd := s.commandRunner.BuildDockerComposeUpCMD(commands.DockerComposeUpOptions{
err := s.composeManager.Up(commands.DockerComposeUpOptions{
Path: filepath.Join(options.GenerationPath, configs.DefaultDockerComposeScriptName),
Services: options.Services,
})
log.Infof(configs.RunningCommand, upCmd.Cmd)
_, _, err := s.commandRunner.RunCMD(upCmd)
if err != nil {
return fmt.Errorf(configs.CommandError, upCmd.Cmd, err)
return fmt.Errorf(configs.RunContainersErr, err)
}
if !options.SkipDockerPs {
// Run docker compose ps --filter status=running to show script running containers
dcpsCMD := s.commandRunner.BuildDockerComposePSCMD(commands.DockerComposePsOptions{
_, err := s.composeManager.PS(commands.DockerComposePsOptions{
Path: filepath.Join(options.GenerationPath, configs.DefaultDockerComposeScriptName),
FilterRunning: true,
})
log.Infof(configs.RunningCommand, dcpsCMD.Cmd)
if _, _, err := s.commandRunner.RunCMD(dcpsCMD); err != nil {
return fmt.Errorf(configs.CommandError, dcpsCMD.Cmd, err)
if err != nil {
return fmt.Errorf(configs.RunContainersErr, err)
}
}
return nil
Expand Down
5 changes: 4 additions & 1 deletion cli/actions/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"

"github.com/NethermindEth/sedge/cli/actions"
"github.com/NethermindEth/sedge/internal/compose"
"github.com/NethermindEth/sedge/internal/pkg/commands"
"github.com/NethermindEth/sedge/test"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -66,8 +67,10 @@ func TestRunContainers(t *testing.T) {
return "", 0, nil
},
}
composeMgr := compose.NewComposeManager(commandRunner)
sedgeActions := actions.NewSedgeActions(actions.SedgeActionsOptions{
CommandRunner: commandRunner,
CommandRunner: commandRunner,
ComposeManager: *composeMgr,
})
sedgeActions.RunContainers(tc.options)
assert.Equal(t, 1, up)
Expand Down
22 changes: 10 additions & 12 deletions cli/actions/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
package actions

import (
"fmt"
"path/filepath"

"github.com/NethermindEth/sedge/configs"
Expand All @@ -31,33 +32,30 @@ type SetupContainersOptions struct {

func (s *sedgeActions) SetupContainers(options SetupContainersOptions) error {
log.Info("Setting up containers")
buildCmd := s.commandRunner.BuildDockerComposeBuildCMD(commands.DockerComposeBuildOptions{
err := s.composeManager.Build(commands.DockerComposeBuildOptions{
Path: filepath.Join(options.GenerationPath, configs.DefaultDockerComposeScriptName),
Services: options.Services,
})
log.Infof(configs.RunningCommand, buildCmd.Cmd)
if _, _, err := s.commandRunner.RunCMD(buildCmd); err != nil {
return err
if err != nil {
return fmt.Errorf(configs.SetUpContainersErr, err)
}
if !options.SkipPull {
pullCmd := s.commandRunner.BuildDockerComposePullCMD(commands.DockerComposePullOptions{
err := s.composeManager.Pull(commands.DockerComposePullOptions{
Path: filepath.Join(options.GenerationPath, configs.DefaultDockerComposeScriptName),
Services: options.Services,
})
log.Infof(configs.RunningCommand, pullCmd.Cmd)
if _, _, err := s.commandRunner.RunCMD(pullCmd); err != nil {
return err
if err != nil {
return fmt.Errorf(configs.SetUpContainersErr, err)
}
} else {
log.Warn("Skipping 'docker compose pull' step")
}
createCmd := s.commandRunner.BuildDockerComposeCreateCMD(commands.DockerComposeCreateOptions{
err = s.composeManager.Create(commands.DockerComposeCreateOptions{
Path: filepath.Join(options.GenerationPath, configs.DefaultDockerComposeScriptName),
Services: options.Services,
})
log.Infof(configs.RunningCommand, createCmd.Cmd)
if _, _, err := s.commandRunner.RunCMD(createCmd); err != nil {
return err
if err != nil {
return fmt.Errorf(configs.SetUpContainersErr, err)
}
return nil
}
5 changes: 4 additions & 1 deletion cli/actions/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"

"github.com/NethermindEth/sedge/cli/actions"
"github.com/NethermindEth/sedge/internal/compose"
"github.com/NethermindEth/sedge/internal/pkg/commands"
"github.com/NethermindEth/sedge/test"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -74,8 +75,10 @@ func TestSetupContainers(t *testing.T) {
return "", 0, nil
},
}
composeMgr := compose.NewComposeManager(commandRunner)
sedgeActions := actions.NewSedgeActions(actions.SedgeActionsOptions{
CommandRunner: commandRunner,
CommandRunner: commandRunner,
ComposeManager: *composeMgr,
})
sedgeActions.SetupContainers(tc.options)
})
Expand Down
11 changes: 5 additions & 6 deletions cli/down.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/NethermindEth/sedge/cli/actions"
"github.com/NethermindEth/sedge/configs"
"github.com/NethermindEth/sedge/internal/compose"
"github.com/NethermindEth/sedge/internal/pkg/commands"
"github.com/NethermindEth/sedge/internal/pkg/dependencies"
"github.com/NethermindEth/sedge/internal/utils"
Expand All @@ -29,7 +30,7 @@ import (
log "github.com/sirupsen/logrus"
)

func DownCmd(cmdRunner commands.CommandRunner, a actions.SedgeActions, depsMgr dependencies.DependenciesManager) *cobra.Command {
func DownCmd(composeManager compose.ComposeManager, cmdRunner commands.CommandRunner, a actions.SedgeActions, depsMgr dependencies.DependenciesManager) *cobra.Command {
// Flags
var generationPath string
// Build command
Expand All @@ -49,13 +50,11 @@ func DownCmd(cmdRunner commands.CommandRunner, a actions.SedgeActions, depsMgr d
return err
}

downCMD := cmdRunner.BuildDockerComposeDownCMD(commands.DockerComposeDownOptions{
err := composeManager.Down(commands.DockerComposeDownOptions{
Path: filepath.Join(generationPath, configs.DefaultDockerComposeScriptName),
})

log.Debugf(configs.RunningCommand, downCMD.Cmd)
if _, _, err := cmdRunner.RunCMD(downCMD); err != nil {
return fmt.Errorf(configs.CommandError, downCMD.Cmd, err)
if err != nil {
return fmt.Errorf("error shutting down contaiers %w", err)
}

return nil
Expand Down
8 changes: 6 additions & 2 deletions cli/down_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/NethermindEth/sedge/internal/compose"
"github.com/NethermindEth/sedge/internal/pkg/commands"
"github.com/NethermindEth/sedge/internal/pkg/dependencies"
"github.com/NethermindEth/sedge/test"
Expand All @@ -39,6 +40,7 @@ import (

type downCmdTestCase struct {
generationPath string
composeMgr compose.ComposeManager
runner commands.CommandRunner
depsMgr dependencies.DependenciesManager
sedgeActions actions.SedgeActions
Expand Down Expand Up @@ -78,6 +80,8 @@ func buildDownTestCase(t *testing.T, caseName string, isErr bool, path string) *
return "", nil
},
}
composeMgr := compose.NewComposeManager(tc.runner)
tc.composeMgr = *composeMgr

tc.generationPath = path
tc.fdOut = new(bytes.Buffer)
Expand All @@ -93,7 +97,7 @@ func TestDownCmd(t *testing.T) {

for _, tc := range tcs {
rootCmd := RootCmd()
rootCmd.AddCommand(DownCmd(tc.runner, tc.sedgeActions, tc.depsMgr))
rootCmd.AddCommand(DownCmd(tc.composeMgr, tc.runner, tc.sedgeActions, tc.depsMgr))
rootCmd.SetArgs([]string{"down", "--path", tc.generationPath})
rootCmd.SetOut(tc.fdOut)
log.SetOutput(tc.fdOut)
Expand Down Expand Up @@ -196,7 +200,7 @@ func TestDown_Error(t *testing.T) {
pathFlag = tc.customPath
}
tt := buildDownTestCase(t, "case_1", true, pathFlag)
downCmd := DownCmd(tc.runner, tt.sedgeActions, tt.depsMgr)
downCmd := DownCmd(tt.composeMgr, tc.runner, tt.sedgeActions, tt.depsMgr)
downCmd.SetArgs([]string{"--path", pathFlag})
downCmd.SetOut(io.Discard)
err := downCmd.Execute()
Expand Down
15 changes: 9 additions & 6 deletions cli/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ var (
)

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

type CustomFlags struct {
Expand Down Expand Up @@ -459,7 +459,7 @@ func valClients(allClients clients.OrderedClients, flags *GenCmdFlags, services
return nil, err
}
if flags.optimismName != "" {
opClient.Name = "optimism"
opClient.Name = "opnode"
if len(optimismParts) > 1 {
opClient.Image = strings.Join(optimismParts[1:], ":")
}
Expand All @@ -470,15 +470,18 @@ func valClients(allClients clients.OrderedClients, flags *GenCmdFlags, services
}

optimismExecutionParts := strings.Split(flags.optimismExecutionName, ":")
executionOpClient = allClients[execution]["nethermind"]
executionOpClient, err = clients.RandomChoice(allClients[opExecution])
if err != nil {
return nil, err
}
if flags.optimismExecutionName != "" {
executionOpClient.Name = optimismExecutionParts[0]
executionOpClient.Name = strings.ReplaceAll(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 {
if err = clients.ValidateClient(executionOpClient, opExecution); err != nil {
return nil, err
}

Expand Down
13 changes: 3 additions & 10 deletions cli/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/NethermindEth/sedge/cli/actions"
"github.com/NethermindEth/sedge/configs"
"github.com/NethermindEth/sedge/internal/compose"
"github.com/NethermindEth/sedge/internal/pkg/commands"
"github.com/NethermindEth/sedge/internal/pkg/dependencies"
"github.com/NethermindEth/sedge/internal/utils"
Expand All @@ -30,7 +31,7 @@ import (
log "github.com/sirupsen/logrus"
)

func LogsCmd(cmdRunner commands.CommandRunner, sedgeActions actions.SedgeActions, depsMgr dependencies.DependenciesManager) *cobra.Command {
func LogsCmd(composeManager compose.ComposeManager, cmdRunner commands.CommandRunner, sedgeActions actions.SedgeActions, depsMgr dependencies.DependenciesManager) *cobra.Command {
// Flags
var (
generationPath string
Expand Down Expand Up @@ -65,20 +66,12 @@ func LogsCmd(cmdRunner commands.CommandRunner, sedgeActions actions.SedgeActions
services = args
}

logsCMD := cmdRunner.BuildDockerComposeLogsCMD(commands.DockerComposeLogsOptions{
err = composeManager.Logs(commands.DockerComposeLogsOptions{
Path: file,
Services: services,
Follow: tail == 0,
Tail: tail,
})

log.Debugf(configs.RunningCommand, logsCMD.Cmd)
_, exitCode, err := cmdRunner.RunCMD(logsCMD)
if exitCode == 130 {
// A job with exit code 130 was terminated with signal 2 (SIGINT on most systems).
// Process interrupted by user (Ctrl+C)
return nil
}
if err != nil {
return fmt.Errorf(configs.GettingLogsError, strings.Join(services, " "), err)
}
Expand Down
Loading

0 comments on commit 70ca40a

Please sign in to comment.