Skip to content

Commit b107e32

Browse files
ian-shimjianoaix
authored andcommitted
[node] Churner TLS (#46)
1 parent cd6a7b3 commit b107e32

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

node/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ type Config struct {
6666
ChurnerUrl string
6767
NumBatchValidators int
6868
ClientIPHeader string
69+
UseSecureGrpc bool
6970

7071
EthClientConfig geth.EthClientConfig
7172
LoggingConfig logging.Config
@@ -164,5 +165,6 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
164165
ChurnerUrl: ctx.GlobalString(flags.ChurnerUrlFlag.Name),
165166
NumBatchValidators: ctx.GlobalInt(flags.NumBatchValidatorsFlag.Name),
166167
ClientIPHeader: ctx.GlobalString(flags.ClientIPHeaderFlag.Name),
168+
UseSecureGrpc: !testMode,
167169
}, nil
168170
}

node/flags/flags.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ var (
218218
Required: false,
219219
EnvVar: common.PrefixEnvVar(EnvVarPrefix, "TEST_PRIVATE_BLS"),
220220
}
221-
222221
ClientIPHeaderFlag = cli.StringFlag{
223222
Name: common.PrefixFlag(FlagPrefix, "client-ip-header"),
224223
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.",

node/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (n *Node) Start(ctx context.Context) error {
176176
OperatorId: n.Config.ID,
177177
QuorumIDs: n.Config.QuorumIDList,
178178
}
179-
err := RegisterOperator(ctx, operator, n.Transactor, n.Config.ChurnerUrl, n.Logger)
179+
err := RegisterOperator(ctx, operator, n.Transactor, n.Config.ChurnerUrl, n.Config.UseSecureGrpc, n.Logger)
180180
if err != nil {
181181
return fmt.Errorf("failed to register the operator: %w", err)
182182
}

node/operator.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package node
22

33
import (
44
"context"
5+
"crypto/tls"
56
"errors"
67
"fmt"
78
"time"
@@ -12,6 +13,7 @@ import (
1213
"github.com/Layr-Labs/eigenda/core"
1314
"github.com/ethereum/go-ethereum/crypto"
1415
"google.golang.org/grpc"
16+
"google.golang.org/grpc/credentials"
1517
"google.golang.org/grpc/credentials/insecure"
1618
)
1719

@@ -24,7 +26,7 @@ type Operator struct {
2426
}
2527

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

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

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

101+
var credential = insecure.NewCredentials()
102+
if useSecureGrpc {
103+
config := &tls.Config{}
104+
credential = credentials.NewTLS(config)
105+
}
106+
99107
conn, err := grpc.Dial(
100108
churnerUrl,
101-
grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO: still need this?
109+
grpc.WithTransportCredentials(credential),
102110
)
103111
if err != nil {
104112
logger.Error("Node cannot connect to churner", "err", err)

node/plugin/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func pluginOps(ctx *cli.Context) {
121121
}
122122
if config.Operation == "opt-in" {
123123
log.Printf("Info: Operator with Operator Address: %x is opting in to EigenDA", sk.Address)
124-
err = node.RegisterOperator(context.Background(), operator, tx, config.ChurnerUrl, logger)
124+
err = node.RegisterOperator(context.Background(), operator, tx, config.ChurnerUrl, true, logger)
125125
if err != nil {
126126
log.Printf("Error: failed to opt-in EigenDA Node Network for operator ID: %x, operator address: %x, error: %v", operatorID, sk.Address, err)
127127
return

0 commit comments

Comments
 (0)