Skip to content

Commit

Permalink
MEV support (ssvlabs#918)
Browse files Browse the repository at this point in the history
* mev support

---------
Co-authored-by: nkryuchkov <[email protected]>
Co-authored-by: nivBlox <[email protected]>
Co-authored-by: aaron <[email protected]>
Co-authored-by: moshe-blox <[email protected]>
Co-authored-by: y0sher <[email protected]>
  • Loading branch information
nkryuchkov authored May 15, 2023
1 parent 4079b1e commit 3b42a81
Show file tree
Hide file tree
Showing 57 changed files with 1,049 additions and 490 deletions.
2 changes: 2 additions & 0 deletions .k8/yamls-stage-v1/ssv-node-v2-1-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ spec:
value: "152834"
- name: CLEAN_REGISTRY_DATA
value: "false"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v2-1
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-stage/ssv-node-10-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ spec:
value: 'false'
- name: GENESIS_EPOCH
value: "152834"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-10
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-stage/ssv-node-11-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ spec:
value: 'false'
- name: GENESIS_EPOCH
value: "152834"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-11
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-stage/ssv-node-12-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ spec:
value: 'false'
- name: GENESIS_EPOCH
value: "152834"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-12
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-stage/ssv-node-9-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ spec:
value: 'false'
- name: GENESIS_EPOCH
value: "152834"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-9
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-stage/ssv-node-v2-2-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ spec:
value: 'false'
- name: GENESIS_EPOCH
value: "152834"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v2-2
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-stage/ssv-node-v2-3-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ spec:
value: "152834"
- name: CLEAN_REGISTRY_DATA
value: "false"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v2-3
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-stage/ssv-node-v2-4-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ spec:
value: "152834"
- name: CLEAN_REGISTRY_DATA
value: "false"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v2-4
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-stage/ssv-node-v2-5-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ spec:
value: "152834"
- name: CLEAN_REGISTRY_DATA
value: "false"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v2-5
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-stage/ssv-node-v2-6-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ spec:
value: "152834"
- name: CLEAN_REGISTRY_DATA
value: "false"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v2-6
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-stage/ssv-node-v2-7-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ spec:
value: 'false'
- name: GENESIS_EPOCH
value: "152834"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v2-7
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-stage/ssv-node-v2-8-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ spec:
value: 'false'
- name: GENESIS_EPOCH
value: "152834"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v2-8
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-v3-stage/ssv-node-v3-1-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ spec:
value: "16301"
- name: FULLNODE
value: "true"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v3-1
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-v3-stage/ssv-node-v3-2-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ spec:
value: "true"
- name: GENESIS_EPOCH
value: "152834"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v3-2
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-v3-stage/ssv-node-v3-3-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ spec:
value: "16303"
- name: FULLNODE
value: "true"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v3-3
Expand Down
2 changes: 2 additions & 0 deletions .k8/yamls-v3-stage/ssv-node-v3-4-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ spec:
value: "true"
- name: GENESIS_EPOCH
value: "152834"
- name: BUILDER_PROPOSALS
value: "true"
volumeMounts:
- mountPath: /data
name: ssv-node-v3-4
Expand Down
47 changes: 33 additions & 14 deletions beacon/goclient/goclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ import (
"time"

eth2client "github.com/attestantio/go-eth2-client"
"github.com/attestantio/go-eth2-client/api"
"github.com/attestantio/go-eth2-client/http"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/eth2-key-manager/core"
spectypes "github.com/bloxapp/ssv-spec/types"
"github.com/bloxapp/ssv/logging/fields"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/rs/zerolog"
"go.uber.org/zap"

"github.com/bloxapp/ssv/logging/fields"
"github.com/bloxapp/ssv/monitoring/metrics"
"github.com/bloxapp/ssv/operator/slot_ticker"
beaconprotocol "github.com/bloxapp/ssv/protocol/v2/blockchain/beacon"
)

Expand Down Expand Up @@ -99,22 +101,30 @@ type Client interface {
eth2client.ValidatorsProvider
eth2client.ProposalPreparationsSubmitter
eth2client.EventsProvider
eth2client.BlindedBeaconBlockProposalProvider
eth2client.BlindedBeaconBlockSubmitter
eth2client.ValidatorRegistrationsSubmitter
}

// goClient implementing Beacon struct
type goClient struct {
ctx context.Context
network beaconprotocol.Network
client Client
indicesMapLock sync.Mutex
graffiti []byte
log *zap.Logger
ctx context.Context
network beaconprotocol.Network
client Client
graffiti []byte
gasLimit uint64
operatorID spectypes.OperatorID
registrationMu sync.Mutex
registrationLastSlot phase0.Slot
registrationCache map[phase0.BLSPubKey]*api.VersionedSignedValidatorRegistration
}

// verifies that the client implements HealthCheckAgent
var _ metrics.HealthCheckAgent = &goClient{}

// New init new client and go-client instance
func New(logger *zap.Logger, opt beaconprotocol.Options) (beaconprotocol.Beacon, error) {
func New(logger *zap.Logger, opt beaconprotocol.Options, operatorID spectypes.OperatorID, slotTicker slot_ticker.Ticker) (beaconprotocol.Beacon, error) {
logger.Info("consensus client: connecting", fields.Address(opt.BeaconNodeAddr), fields.Network(opt.Network))

httpClient, err := http.New(opt.Context,
Expand All @@ -131,15 +141,24 @@ func New(logger *zap.Logger, opt beaconprotocol.Options) (beaconprotocol.Beacon,
logger.Info("consensus client: connected", fields.Name(httpClient.Name()), fields.Address(httpClient.Address()))

network := beaconprotocol.NewNetwork(core.NetworkFromString(opt.Network), opt.MinGenesisTime)
_client := &goClient{
ctx: opt.Context,
network: network,
client: httpClient.(*http.Service),
indicesMapLock: sync.Mutex{},
graffiti: opt.Graffiti,

tickerChan := make(chan phase0.Slot, 32)
slotTicker.Subscribe(tickerChan)

client := &goClient{
log: logger,
ctx: opt.Context,
network: network,
client: httpClient.(*http.Service),
graffiti: opt.Graffiti,
gasLimit: opt.GasLimit,
operatorID: operatorID,
registrationCache: map[phase0.BLSPubKey]*api.VersionedSignedValidatorRegistration{},
}

return _client, nil
go client.registrationSubmitter(tickerChan)

return client, nil
}

// HealthCheck provides health status of beacon node
Expand Down
Loading

0 comments on commit 3b42a81

Please sign in to comment.