Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type Config struct {
ChurnerUrl string
NumBatchValidators int
ClientIPHeader string
UseSecureGrpc bool

EthClientConfig geth.EthClientConfig
LoggingConfig logging.Config
Expand Down Expand Up @@ -164,5 +165,6 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
ChurnerUrl: ctx.GlobalString(flags.ChurnerUrlFlag.Name),
NumBatchValidators: ctx.GlobalInt(flags.NumBatchValidatorsFlag.Name),
ClientIPHeader: ctx.GlobalString(flags.ClientIPHeaderFlag.Name),
UseSecureGrpc: !testMode,
}, nil
}
1 change: 0 additions & 1 deletion node/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ var (
Required: false,
EnvVar: common.PrefixEnvVar(EnvVarPrefix, "TEST_PRIVATE_BLS"),
}

ClientIPHeaderFlag = cli.StringFlag{
Name: common.PrefixFlag(FlagPrefix, "client-ip-header"),
Usage: "The name of the header used to get the client IP address. If set to empty string, the IP address will be taken from the connection. The rightmost value of the header will be used.",
Expand Down
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (n *Node) Start(ctx context.Context) error {
OperatorId: n.Config.ID,
QuorumIDs: n.Config.QuorumIDList,
}
err := RegisterOperator(ctx, operator, n.Transactor, n.Config.ChurnerUrl, n.Logger)
err := RegisterOperator(ctx, operator, n.Transactor, n.Config.ChurnerUrl, n.Config.UseSecureGrpc, n.Logger)
if err != nil {
return fmt.Errorf("failed to register the operator: %w", err)
}
Expand Down
16 changes: 12 additions & 4 deletions node/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package node

import (
"context"
"crypto/tls"
"errors"
"fmt"
"time"
Expand All @@ -12,6 +13,7 @@ import (
"github.com/Layr-Labs/eigenda/core"
"github.com/ethereum/go-ethereum/crypto"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

Expand All @@ -24,7 +26,7 @@ type Operator struct {
}

// Register operator registers the operator with the given public key for the given quorum IDs.
func RegisterOperator(ctx context.Context, operator *Operator, transactor core.Transactor, churnerUrl string, logger common.Logger) error {
func RegisterOperator(ctx context.Context, operator *Operator, transactor core.Transactor, churnerUrl string, useSecureGrpc bool, logger common.Logger) error {
registeredQuorumIds, err := transactor.GetRegisteredQuorumIdsForOperator(ctx, operator.OperatorId)
if err != nil {
return fmt.Errorf("failed to get registered quorum ids for an operator: %w", err)
Expand Down Expand Up @@ -72,7 +74,7 @@ func RegisterOperator(ctx context.Context, operator *Operator, transactor core.T

// if we should call the churner, call it
if shouldCallChurner {
churnReply, err := requestChurnApproval(ctx, operator, churnerUrl, logger)
churnReply, err := requestChurnApproval(ctx, operator, churnerUrl, useSecureGrpc, logger)
if err != nil {
return fmt.Errorf("failed to request churn approval: %w", err)
}
Expand All @@ -93,12 +95,18 @@ func DeregisterOperator(ctx context.Context, KeyPair *core.KeyPair, transactor c
return transactor.DeregisterOperator(ctx, KeyPair.GetPubKeyG1(), blockNumber)
}

func requestChurnApproval(ctx context.Context, operator *Operator, churnerUrl string, logger common.Logger) (*grpcchurner.ChurnReply, error) {
func requestChurnApproval(ctx context.Context, operator *Operator, churnerUrl string, useSecureGrpc bool, logger common.Logger) (*grpcchurner.ChurnReply, error) {
logger.Info("churner url", "url", churnerUrl)

var credential = insecure.NewCredentials()
if useSecureGrpc {
config := &tls.Config{}
credential = credentials.NewTLS(config)
}

conn, err := grpc.Dial(
churnerUrl,
grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO: still need this?
grpc.WithTransportCredentials(credential),
)
if err != nil {
logger.Error("Node cannot connect to churner", "err", err)
Expand Down
2 changes: 1 addition & 1 deletion node/plugin/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func pluginOps(ctx *cli.Context) {
}
if config.Operation == "opt-in" {
log.Printf("Info: Operator with Operator Address: %x is opting in to EigenDA", sk.Address)
err = node.RegisterOperator(context.Background(), operator, tx, config.ChurnerUrl, logger)
err = node.RegisterOperator(context.Background(), operator, tx, config.ChurnerUrl, true, logger)
if err != nil {
log.Printf("Error: failed to opt-in EigenDA Node Network for operator ID: %x, operator address: %x, error: %v", operatorID, sk.Address, err)
return
Expand Down