-
Notifications
You must be signed in to change notification settings - Fork 189
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
Component updates for M2 mainnet contracts #196
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import ( | |
|
||
"github.com/Layr-Labs/eigenda/common/pubip" | ||
gethcommon "github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/crypto" | ||
"github.com/prometheus/client_golang/prometheus" | ||
|
||
"github.com/Layr-Labs/eigenda/api/grpc/node" | ||
"github.com/Layr-Labs/eigenda/common" | ||
|
@@ -21,6 +23,7 @@ import ( | |
"github.com/Layr-Labs/eigenda/core/eth" | ||
"github.com/Layr-Labs/eigenda/core/indexer" | ||
"github.com/Layr-Labs/eigensdk-go/chainio/constructor" | ||
"github.com/Layr-Labs/eigensdk-go/metrics" | ||
"github.com/Layr-Labs/eigensdk-go/metrics/collectors/economic" | ||
rpccalls "github.com/Layr-Labs/eigensdk-go/metrics/collectors/rpc_calls" | ||
"github.com/Layr-Labs/eigensdk-go/nodeapi" | ||
|
@@ -62,12 +65,16 @@ type Node struct { | |
// NewNode creates a new Node with the provided config. | ||
func NewNode(config *Config, pubIPProvider pubip.Provider, logger common.Logger) (*Node, error) { | ||
// Setup metrics | ||
sdkClients, err := buildSdkClients(config, logger) | ||
if err != nil { | ||
return nil, err | ||
} | ||
metrics := NewMetrics(sdkClients.Metrics, sdkClients.PrometheusRegistry, logger, ":"+config.MetricsPort) | ||
rpcCallsCollector := rpccalls.NewCollector(AppName, sdkClients.PrometheusRegistry) | ||
// sdkClients, err := buildSdkClients(config, logger) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why was this commented out? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the time, the SDK hadn't been updated to reflect the new contracts. Since the client from the SDK was only being used for metrics, I created the metrics separately. I'm not sure if it makes sense to build all of the SDK clients if we aren't using them. My preference here would be to remove this commented code and create a ticket to track further integration with the SDK. |
||
// if err != nil { | ||
// return nil, err | ||
// } | ||
|
||
promReg := prometheus.NewRegistry() | ||
eigenMetrics := metrics.NewEigenMetrics(AppName, ":"+config.MetricsPort, promReg, logger) | ||
|
||
metrics := NewMetrics(eigenMetrics, promReg, logger, ":"+config.MetricsPort) | ||
rpcCallsCollector := rpccalls.NewCollector(AppName, promReg) | ||
|
||
// Generate BLS keys | ||
keyPair, err := core.MakeKeyPairFromString(config.PrivateBls) | ||
|
@@ -183,14 +190,19 @@ func (n *Node) Start(ctx context.Context) error { | |
n.Config.ID, "hostname", n.Config.Hostname, "dispersalPort", n.Config.DispersalPort, | ||
"retrievalPort", n.Config.RetrievalPort, "churnerUrl", n.Config.ChurnerUrl, "quorumIds", n.Config.QuorumIDList) | ||
socket := string(core.MakeOperatorSocket(n.Config.Hostname, n.Config.DispersalPort, n.Config.RetrievalPort)) | ||
privateKey, err := crypto.HexToECDSA(n.Config.EthClientConfig.PrivateKeyString) | ||
if err != nil { | ||
return fmt.Errorf("NewClient: cannot parse private key: %w", err) | ||
} | ||
operator := &Operator{ | ||
Socket: socket, | ||
Timeout: 10 * time.Second, | ||
PrivKey: privateKey, | ||
KeyPair: n.KeyPair, | ||
OperatorId: n.Config.ID, | ||
QuorumIDs: n.Config.QuorumIDList, | ||
} | ||
err := RegisterOperator(ctx, operator, n.Transactor, n.Config.ChurnerUrl, n.Config.UseSecureGrpc, 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) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,11 @@ package node | |
|
||
import ( | ||
"context" | ||
"crypto/ecdsa" | ||
"crypto/tls" | ||
"errors" | ||
"fmt" | ||
"math/big" | ||
"time" | ||
|
||
grpcchurner "github.com/Layr-Labs/eigenda/api/grpc/churner" | ||
|
@@ -20,6 +22,7 @@ import ( | |
type Operator struct { | ||
Socket string | ||
Timeout time.Duration | ||
PrivKey *ecdsa.PrivateKey | ||
KeyPair *core.KeyPair | ||
OperatorId core.OperatorID | ||
QuorumIDs []core.QuorumID | ||
|
@@ -37,12 +40,6 @@ func RegisterOperator(ctx context.Context, operator *Operator, transactor core.T | |
return nil | ||
} | ||
|
||
// if the operator is not registered, we may need to register the BLSPublicKey | ||
err = transactor.RegisterBLSPublicKey(ctx, operator.KeyPair) | ||
if err != nil { | ||
return fmt.Errorf("failed to register the nodes bls public key: %w", err) | ||
} | ||
|
||
logger.Info("Quorums to register for", "quorums", operator.QuorumIDs) | ||
|
||
if len(operator.QuorumIDs) == 0 { | ||
|
@@ -72,17 +69,26 @@ func RegisterOperator(ctx context.Context, operator *Operator, transactor core.T | |
|
||
logger.Info("Should call churner", "shouldCallChurner", shouldCallChurner) | ||
|
||
// Generate salt and expiry | ||
|
||
privateKeyBytes := []byte(operator.KeyPair.PrivKey.String()) | ||
salt := [32]byte{} | ||
copy(salt[:], crypto.Keccak256([]byte("churn"), []byte(time.Now().String()), operator.QuorumIDs[:], privateKeyBytes)) | ||
|
||
// Get the current block number | ||
expiry := big.NewInt((time.Now().Add(10 * time.Minute)).Unix()) | ||
|
||
// if we should call the churner, call it | ||
if shouldCallChurner { | ||
churnReply, err := requestChurnApproval(ctx, operator, churnerUrl, useSecureGrpc, logger) | ||
if err != nil { | ||
return fmt.Errorf("failed to request churn approval: %w", err) | ||
} | ||
|
||
return transactor.RegisterOperatorWithChurn(ctx, operator.KeyPair.PubKey, operator.Socket, operator.QuorumIDs, churnReply) | ||
return transactor.RegisterOperatorWithChurn(ctx, operator.KeyPair, operator.Socket, operator.QuorumIDs, operator.PrivKey, salt, expiry, churnReply) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to update the nodeplugin path to have this private key as well: https://github.com/Layr-Labs/eigenda/blob/master/node/plugin/cmd/main.go#L118 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Updated! |
||
} else { | ||
// other wise just register normally | ||
return transactor.RegisterOperator(ctx, operator.KeyPair.PubKey, operator.Socket, operator.QuorumIDs) | ||
return transactor.RegisterOperator(ctx, operator.KeyPair, operator.Socket, operator.QuorumIDs, operator.PrivKey, salt, expiry) | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The max of uint8 is 255, so it can have 256 quorums, and uint8 cannot represent 256.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The onchain quorumCount was changed to a uint8 (https://github.com/Layr-Labs/eigenlayer-middleware/blob/98f884454d9e9de1e344bb6fba9a2cd3915e5b57/src/RegistryCoordinator.sol#L71), so it looks like we would only support up to 255 quorums.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so the range of quorum ID is [0, 254] (not [0, 255]).