@@ -2,6 +2,7 @@ package node
2
2
3
3
import (
4
4
"context"
5
+ "crypto/tls"
5
6
"errors"
6
7
"fmt"
7
8
"time"
@@ -12,6 +13,7 @@ import (
12
13
"github.com/Layr-Labs/eigenda/core"
13
14
"github.com/ethereum/go-ethereum/crypto"
14
15
"google.golang.org/grpc"
16
+ "google.golang.org/grpc/credentials"
15
17
"google.golang.org/grpc/credentials/insecure"
16
18
)
17
19
@@ -24,7 +26,7 @@ type Operator struct {
24
26
}
25
27
26
28
// 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 {
28
30
registeredQuorumIds , err := transactor .GetRegisteredQuorumIdsForOperator (ctx , operator .OperatorId )
29
31
if err != nil {
30
32
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
72
74
73
75
// if we should call the churner, call it
74
76
if shouldCallChurner {
75
- churnReply , err := requestChurnApproval (ctx , operator , churnerUrl , logger )
77
+ churnReply , err := requestChurnApproval (ctx , operator , churnerUrl , useSecureGrpc , logger )
76
78
if err != nil {
77
79
return fmt .Errorf ("failed to request churn approval: %w" , err )
78
80
}
@@ -93,12 +95,18 @@ func DeregisterOperator(ctx context.Context, KeyPair *core.KeyPair, transactor c
93
95
return transactor .DeregisterOperator (ctx , KeyPair .GetPubKeyG1 (), blockNumber )
94
96
}
95
97
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 ) {
97
99
logger .Info ("churner url" , "url" , churnerUrl )
98
100
101
+ var credential = insecure .NewCredentials ()
102
+ if useSecureGrpc {
103
+ config := & tls.Config {}
104
+ credential = credentials .NewTLS (config )
105
+ }
106
+
99
107
conn , err := grpc .Dial (
100
108
churnerUrl ,
101
- grpc .WithTransportCredentials (insecure . NewCredentials ()), // TODO: still need this?
109
+ grpc .WithTransportCredentials (credential ),
102
110
)
103
111
if err != nil {
104
112
logger .Error ("Node cannot connect to churner" , "err" , err )
0 commit comments