Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support update-socket operation from node plugin #469

Merged
merged 1 commit into from
Apr 10, 2024
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
8 changes: 4 additions & 4 deletions node/plugin/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,31 +128,31 @@ func pluginOps(ctx *cli.Context) {
RegisterNodeAtStart: false,
}
churnerClient := node.NewChurnerClient(config.ChurnerUrl, true, operator.Timeout, logger)
if config.Operation == "opt-in" {
if config.Operation == plugin.OperationOptIn {
log.Printf("Info: Operator with Operator Address: %x is opting in to EigenDA", sk.Address)
err = node.RegisterOperator(context.Background(), operator, tx, churnerClient, logger.With("component", "NodeOperator"))
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
}
log.Printf("Info: successfully opt-in the EigenDA, for operator ID: %x, operator address: %x, socket: %s, and quorums: %v", operatorID, sk.Address, config.Socket, config.QuorumIDList)
} else if config.Operation == "opt-out" {
} else if config.Operation == plugin.OperationOptOut {
log.Printf("Info: Operator with Operator Address: %x and OperatorID: %x is opting out of EigenDA", sk.Address, operatorID)
err = node.DeregisterOperator(context.Background(), operator, keyPair, tx)
if err != nil {
log.Printf("Error: failed to opt-out EigenDA Node Network for operator ID: %x, operator address: %x, quorums: %v, error: %v", operatorID, sk.Address, config.QuorumIDList, err)
return
}
log.Printf("Info: successfully opt-out the EigenDA, for operator ID: %x, operator address: %x", operatorID, sk.Address)
} else if config.Operation == "update-socket" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh we had this before but didn't add it to OperationFlag

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep lol

} else if config.Operation == plugin.OperationUpdateSocket {
log.Printf("Info: Operator with Operator Address: %x is updating its socket: %s", sk.Address, config.Socket)
err = node.UpdateOperatorSocket(context.Background(), tx, config.Socket)
if err != nil {
log.Printf("Error: failed to update socket for operator ID: %x, operator address: %x, socket: %s, error: %v", operatorID, sk.Address, config.Socket, err)
return
}
log.Printf("Info: successfully updated socket, for operator ID: %x, operator address: %x, socket: %s", operatorID, sk.Address, config.Socket)
} else if config.Operation == "list-quorums" {
} else if config.Operation == plugin.OperationListQuorums {
quorumIds, err := tx.GetRegisteredQuorumIdsForOperator(context.Background(), operatorID)
if err != nil {
log.Printf("Error: failed to get quorum(s) for operatorID: %x, operator address: %x, error: %v", operatorID, sk.Address, err)
Expand Down
14 changes: 12 additions & 2 deletions node/plugin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import (
"github.com/urfave/cli"
)

const (
OperationOptIn = "opt-in"
OperationOptOut = "opt-out"
OperationUpdateSocket = "update-socket"
OperationListQuorums = "list-quorums"
)

var (
/* Required Flags */

Expand All @@ -25,7 +32,7 @@ var (
OperationFlag = cli.StringFlag{
Name: "operation",
Required: true,
Usage: "Supported operations: opt-in, opt-out, list-quorums",
Usage: "Supported operations: opt-in, opt-out, update-socket, list-quorums",
EnvVar: common.PrefixEnvVar(flags.EnvVarPrefix, "OPERATION"),
}

Expand Down Expand Up @@ -136,7 +143,10 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
}

op := ctx.GlobalString(OperationFlag.Name)
if op != "opt-in" && op != "opt-out" && op != "list-quorums" {
if len(op) == 0 {
return nil, errors.New("operation type not provided")
}
if op != OperationOptIn && op != OperationOptOut && op != OperationUpdateSocket && op != OperationListQuorums {
return nil, errors.New("unsupported operation type")
}

Expand Down
Loading