Skip to content

Commit

Permalink
misc: clarify and fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
iurii-ssv committed Oct 26, 2024
1 parent 3de919b commit 0cec880
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 33 deletions.
3 changes: 1 addition & 2 deletions beacon/goclient/goclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/rs/zerolog"
spectypes "github.com/ssvlabs/ssv-spec/types"
"go.uber.org/zap"

"github.com/ssvlabs/ssv/logging/fields"
operatordatastore "github.com/ssvlabs/ssv/operator/datastore"
"github.com/ssvlabs/ssv/operator/slotticker"
beaconprotocol "github.com/ssvlabs/ssv/protocol/v2/blockchain/beacon"
"github.com/ssvlabs/ssv/utils/casts"
"go.uber.org/zap"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions eth/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Execution layer communication is an important part of SSV, we are basing our sta

## :feet: Goals

- Alawys be up-top-date with synced-el-node that reads the contract events.
- Always be up-top-date with synced-el-node that reads the contract events.
- Stop the node if el-node is out of sync.
- Atomic event handling - support crash recovery, interlock actions on validators with live incoming events.
- Simple flow between history and ongiong sync.
Expand Down Expand Up @@ -75,7 +75,7 @@ for {
### EL sync

if the EL node is not synced, we should stop event processing and signal the node to crash becasue we can't resume.
a synecd EL node is a prerequisite to run SSV.
a synced EL node is a prerequisite to run SSV.

After crash the SSV node will launch and will wait and retry until it synced, so it won't be in a crash loop.

Expand Down
11 changes: 3 additions & 8 deletions eth/eventsyncer/event_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,15 @@ import (
"fmt"
"time"

"go.uber.org/zap"

"github.com/ssvlabs/ssv/eth/executionclient"
"github.com/ssvlabs/ssv/logging/fields"
nodestorage "github.com/ssvlabs/ssv/operator/storage"
"go.uber.org/zap"
)

// TODO: check if something from these PRs need to be ported:
// https://github.com/ssvlabs/ssv/pull/1053

var (
// ErrNodeNotReady is returned when node is not ready.
ErrNodeNotReady = fmt.Errorf("node not ready")
)

type ExecutionClient interface {
FetchHistoricalLogs(ctx context.Context, fromBlock uint64) (logs <-chan executionclient.BlockLogs, errors <-chan error, err error)
StreamLogs(ctx context.Context, fromBlock uint64) <-chan executionclient.BlockLogs
Expand Down Expand Up @@ -66,14 +60,15 @@ func New(nodeStorage nodestorage.Storage, executionClient ExecutionClient, event
}

// Healthy returns nil if the syncer is syncing ongoing events.
func (es *EventSyncer) Healthy(ctx context.Context) error {
func (es *EventSyncer) Healthy(_ context.Context) error {
lastProcessedBlock, found, err := es.nodeStorage.GetLastProcessedBlock(nil)
if err != nil {
return fmt.Errorf("failed to read last processed block: %w", err)
}
if !found || lastProcessedBlock == nil || lastProcessedBlock.Uint64() == 0 {
return fmt.Errorf("last processed block is not set")
}

if es.lastProcessedBlock != lastProcessedBlock.Uint64() {
es.lastProcessedBlock = lastProcessedBlock.Uint64()
es.lastProcessedBlockChange = time.Now()
Expand Down
5 changes: 2 additions & 3 deletions network/peers/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors"
"go.uber.org/zap"

"github.com/ssvlabs/ssv/network/records"
"go.uber.org/zap"
)

const (
Expand Down Expand Up @@ -114,7 +113,7 @@ type SubnetsIndex interface {

// GossipScoreIndex serves as an interface to get a peer's Gossip score
type GossipScoreIndex interface {
// AddScore adds a score for a peer
// SetScores sets a score for a peer
SetScores(scores map[peer.ID]float64)
// GetGossipScore returns the peer score and a boolean flag for whether it has such score or not
GetGossipScore(peerID peer.ID) (float64, bool)
Expand Down
3 changes: 1 addition & 2 deletions operator/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"context"
"fmt"

"go.uber.org/zap"

"github.com/ssvlabs/ssv/eth/executionclient"
"github.com/ssvlabs/ssv/exporter/api"
qbftstorage "github.com/ssvlabs/ssv/ibft/storage"
Expand All @@ -22,6 +20,7 @@ import (
beaconprotocol "github.com/ssvlabs/ssv/protocol/v2/blockchain/beacon"
storage2 "github.com/ssvlabs/ssv/registry/storage"
"github.com/ssvlabs/ssv/storage/basedb"
"go.uber.org/zap"
)

// Node represents the behavior of SSV node
Expand Down
7 changes: 3 additions & 4 deletions operator/validator/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
genesisspectypes "github.com/ssvlabs/ssv-spec-pre-cc/types"
specqbft "github.com/ssvlabs/ssv-spec/qbft"
spectypes "github.com/ssvlabs/ssv-spec/types"
"go.uber.org/zap"

"github.com/ssvlabs/ssv/exporter/convert"
"github.com/ssvlabs/ssv/ibft/genesisstorage"
"github.com/ssvlabs/ssv/ibft/storage"
Expand Down Expand Up @@ -59,6 +57,7 @@ import (
ssvtypes "github.com/ssvlabs/ssv/protocol/v2/types"
registrystorage "github.com/ssvlabs/ssv/registry/storage"
"github.com/ssvlabs/ssv/storage/basedb"
"go.uber.org/zap"
)

//go:generate mockgen -package=mocks -destination=./mocks/controller.go -source=./controller.go
Expand Down Expand Up @@ -506,13 +505,13 @@ func (c *controller) getNonCommitteeValidators(messageId spectypes.MessageID) *c
return nil
}

// StartValidators loads all persisted shares and setup the corresponding validators
// StartValidators loads all persisted shares and set up the corresponding validators
func (c *controller) StartValidators() {
// Load non-liquidated shares.
shares := c.sharesStorage.List(nil, registrystorage.ByNotLiquidated())
if len(shares) == 0 {
close(c.committeeValidatorSetup)
c.logger.Info("could not find validators")
c.logger.Info("found no validator shares in storage")
return
}

Expand Down
9 changes: 2 additions & 7 deletions protocol/v2/ssv/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import (
"github.com/pkg/errors"
specqbft "github.com/ssvlabs/ssv-spec/qbft"
spectypes "github.com/ssvlabs/ssv-spec/types"
"go.uber.org/zap"

"github.com/ssvlabs/ssv/protocol/v2/blockchain/beacon"
"github.com/ssvlabs/ssv/protocol/v2/qbft/controller"
"github.com/ssvlabs/ssv/protocol/v2/ssv"
ssvtypes "github.com/ssvlabs/ssv/protocol/v2/types"
"go.uber.org/zap"
)

type Getters interface {
Expand Down Expand Up @@ -292,11 +291,7 @@ func (b *BaseRunner) didDecideCorrectly(prevDecided bool, signedMessage *spectyp
return false, nil
}

if b.State.RunningInstance == nil {
return false, errors.New("decided wrong instance")
}

if decidedMessage.Height != b.State.RunningInstance.GetHeight() {
if b.State.RunningInstance == nil || decidedMessage.Height != b.State.RunningInstance.GetHeight() {
return false, errors.New("decided wrong instance")
}

Expand Down
2 changes: 1 addition & 1 deletion storage/basedb/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Reader interface {
GetAll(prefix []byte, handler func(int, Obj) error) error
}

// ReadWrite is a read-write accessor to the database.
// ReadWriter is a read-write accessor to the database.
type ReadWriter interface {
Reader
Set(prefix []byte, key []byte, value []byte) error
Expand Down
6 changes: 2 additions & 4 deletions storage/kv/badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import (
"sync"
"time"

"github.com/ssvlabs/ssv/logging/fields"

"github.com/dgraph-io/badger/v4"
"github.com/pkg/errors"
"go.uber.org/zap"

"github.com/ssvlabs/ssv/logging"
"github.com/ssvlabs/ssv/logging/fields"
"github.com/ssvlabs/ssv/storage/basedb"
"go.uber.org/zap"
)

// BadgerDB struct
Expand Down

0 comments on commit 0cec880

Please sign in to comment.