Skip to content

Commit

Permalink
update to new eigensdk
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Jan 8, 2025
1 parent 78eb151 commit 550d354
Show file tree
Hide file tree
Showing 19 changed files with 182 additions and 74 deletions.
3 changes: 3 additions & 0 deletions core/chainio.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math/big"

"github.com/Layr-Labs/eigenda/api/grpc/churner"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
Expand Down Expand Up @@ -143,6 +144,7 @@ type Writer interface {
RegisterOperator(
ctx context.Context,
keypair *KeyPair,
signer sdkSigner.Signer,
socket string,
quorumIds []QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
Expand All @@ -155,6 +157,7 @@ type Writer interface {
RegisterOperatorWithChurn(
ctx context.Context,
keypair *KeyPair,
signer sdkSigner.Signer,
socket string,
quorumIds []QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
Expand Down
40 changes: 37 additions & 3 deletions core/eth/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package eth
import (
"context"
"crypto/ecdsa"
"encoding/hex"
"math/big"
"strings"

Expand All @@ -27,6 +28,8 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/pingcap/errors"

sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
)

type ContractBindings struct {
Expand Down Expand Up @@ -269,6 +272,7 @@ func (t *Reader) GetRegisteredQuorumIdsForOperator(ctx context.Context, operator
func (t *Reader) getRegistrationParams(
ctx context.Context,
keypair *core.KeyPair,
sdkSigner sdkSigner.Signer,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
operatorToAvsRegistrationSigSalt [32]byte,
operatorToAvsRegistrationSigExpiry *big.Int,
Expand All @@ -283,20 +287,50 @@ func (t *Reader) getRegistrationParams(
return nil, nil, err
}


msgToSignG1 := core.NewG1Point(msgToSignG1_.X, msgToSignG1_.Y)
signature := keypair.SignHashedToCurveMessage(msgToSignG1)
sigBytes, err := sdkSigner.SignG1(ctx, msgToSignG1.Serialize())
if err != nil {
return nil, nil, err
}
sig := new(core.Signature)
signature, err := sig.Deserialize(sigBytes)
if err != nil {
return nil, nil, err
}

signedMessageHashParam := regcoordinator.BN254G1Point{
X: signature.X.BigInt(big.NewInt(0)),
Y: signature.Y.BigInt(big.NewInt(0)),
}

g1Point_ := pubKeyG1ToBN254G1Point(keypair.GetPubKeyG1())
g1KeyHex := sdkSigner.GetPublicKeyG1()
g1KeyBytes, err := hex.DecodeString(g1KeyHex)
if err != nil {
return nil, nil, err
}
g1point := new(core.G1Point)
_, err = g1point.Deserialize(g1KeyBytes)
if err != nil {
return nil, nil, err
}
g1Point_ := pubKeyG1ToBN254G1Point(g1point)
g1Point := regcoordinator.BN254G1Point{
X: g1Point_.X,
Y: g1Point_.Y,
}
g2Point_ := pubKeyG2ToBN254G2Point(keypair.GetPubKeyG2())

g2KeyHex := sdkSigner.GetPublicKeyG2()
g2KeyBytes, err := hex.DecodeString(g2KeyHex)
if err != nil {
return nil, nil, err
}
g2point := new(core.G2Point)
_, err = g2point.Deserialize(g2KeyBytes)
if err != nil {
return nil, nil, err
}
g2Point_ := pubKeyG2ToBN254G2Point(g2point)
g2Point := regcoordinator.BN254G2Point{
X: g2Point_.X,
Y: g2Point_.Y,
Expand Down
7 changes: 5 additions & 2 deletions core/eth/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
regcoordinator "github.com/Layr-Labs/eigenda/contracts/bindings/RegistryCoordinator"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigensdk-go/logging"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -59,14 +60,15 @@ func NewWriter(
func (t *Writer) RegisterOperator(
ctx context.Context,
keypair *core.KeyPair,
signer sdkSigner.Signer,
socket string,
quorumIds []core.QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
operatorToAvsRegistrationSigSalt [32]byte,
operatorToAvsRegistrationSigExpiry *big.Int,
) error {

params, operatorSignature, err := t.getRegistrationParams(ctx, keypair, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry)
params, operatorSignature, err := t.getRegistrationParams(ctx, keypair, signer, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry)
if err != nil {
t.logger.Error("Failed to get registration params", "err", err)
return err
Expand Down Expand Up @@ -99,6 +101,7 @@ func (t *Writer) RegisterOperator(
func (t *Writer) RegisterOperatorWithChurn(
ctx context.Context,
keypair *core.KeyPair,
signer sdkSigner.Signer,
socket string,
quorumIds []core.QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
Expand All @@ -107,7 +110,7 @@ func (t *Writer) RegisterOperatorWithChurn(
churnReply *churner.ChurnReply,
) error {

params, operatorSignature, err := t.getRegistrationParams(ctx, keypair, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry)
params, operatorSignature, err := t.getRegistrationParams(ctx, keypair, signer, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry)
if err != nil {
t.logger.Error("Failed to get registration params", "err", err)
return err
Expand Down
10 changes: 9 additions & 1 deletion core/indexer/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
sdkSignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rpc"
Expand All @@ -51,6 +53,12 @@ func mustRegisterOperators(env *deploy.Config, logger logging.Logger) {
for _, op := range env.Operators {
tx := mustMakeOperatorTransactor(env, op, logger)

signer, err := sdkSigner.NewSigner(sdkSignerTypes.SignerConfig{
PrivateKey: op.NODE_TEST_PRIVATE_BLS,
SignerType: sdkSignerTypes.PrivateKey,
})
Expect(err).To(BeNil())

keyPair, err := core.MakeKeyPairFromString(op.NODE_TEST_PRIVATE_BLS)
Expect(err).To(BeNil())

Expand All @@ -64,7 +72,7 @@ func mustRegisterOperators(env *deploy.Config, logger logging.Logger) {
privKey, err := crypto.HexToECDSA(op.NODE_PRIVATE_KEY)
Expect(err).To(BeNil())

err = tx.RegisterOperator(context.Background(), keyPair, socket, quorums, privKey, salt, expiry)
err = tx.RegisterOperator(context.Background(), keyPair, signer, socket, quorums, privKey, salt, expiry)
Expect(err).To(BeNil())
}
}
Expand Down
9 changes: 9 additions & 0 deletions core/mock/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"sort"

"github.com/Layr-Labs/eigenda/core"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
sdkSignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
"github.com/stretchr/testify/mock"
)

Expand All @@ -25,6 +27,7 @@ var _ core.IndexedChainState = (*ChainDataMock)(nil)
type PrivateOperatorInfo struct {
*core.IndexedOperatorInfo
KeyPair *core.KeyPair
Signer sdkSigner.Signer
Host string
DispersalPort string
RetrievalPort string
Expand Down Expand Up @@ -143,9 +146,15 @@ func (d *ChainDataMock) GetTotalOperatorStateWithQuorums(ctx context.Context, bl
PubkeyG2: d.KeyPairs[id].GetPubKeyG2(),
}

signer, _ := sdkSigner.NewSigner(sdkSignerTypes.SignerConfig{
PrivateKey: d.KeyPairs[id].PrivKey.String(),
SignerType: sdkSignerTypes.Local,
})

private := &PrivateOperatorInfo{
IndexedOperatorInfo: indexed,
KeyPair: d.KeyPairs[id],
Signer: signer,
Host: host,
DispersalPort: dispersalPort,
RetrievalPort: retrievalPort,
Expand Down
7 changes: 5 additions & 2 deletions core/mock/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/Layr-Labs/eigenda/api/grpc/churner"
"github.com/Layr-Labs/eigenda/core"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -39,26 +40,28 @@ func (t *MockWriter) GetRegisteredQuorumIdsForOperator(ctx context.Context, oper
func (t *MockWriter) RegisterOperator(
ctx context.Context,
keypair *core.KeyPair,
signer sdkSigner.Signer,
socket string,
quorumIds []core.QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
operatorToAvsRegistrationSigSalt [32]byte,
operatorToAvsRegistrationSigExpiry *big.Int,
) error {
args := t.Called(ctx, keypair, socket, quorumIds, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry)
args := t.Called(ctx, keypair, signer, socket, quorumIds, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry)
return args.Error(0)
}

func (t *MockWriter) RegisterOperatorWithChurn(
ctx context.Context,
keypair *core.KeyPair,
signer sdkSigner.Signer,
socket string,
quorumIds []core.QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
operatorToAvsRegistrationSigSalt [32]byte,
operatorToAvsRegistrationSigExpiry *big.Int,
churnReply *churner.ChurnReply) error {
args := t.Called(ctx, keypair, socket, quorumIds, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry, churnReply)
args := t.Called(ctx, keypair, signer, socket, quorumIds, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry, churnReply)
return args.Error(0)
}

Expand Down
2 changes: 1 addition & 1 deletion disperser/dataapi/v2/server_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var (
dockertestResource *dockertest.Resource
deployLocalStack bool

mockLogger = logging.NewNoopLogger()
mockLogger = testutils.GetLogger()
blobstore = inmem.NewBlobStore()
mockPrometheusApi = &prommock.MockPrometheusApi{}
prometheusClient = dataapi.NewPrometheusClient(mockPrometheusApi, "test-cluster")
Expand Down
10 changes: 4 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
module github.com/Layr-Labs/eigenda

go 1.21

toolchain go1.21.1
go 1.21.13

require (
github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241211213446-c5ffb53d14b0
github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20241211213446-c5ffb53d14b0
github.com/Layr-Labs/eigensdk-go v0.2.0-beta.1.0.20250108183217-59122e8557bc
github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20250108183217-59122e8557bc
github.com/aws/aws-sdk-go-v2 v1.26.1
github.com/aws/aws-sdk-go-v2/credentials v1.17.11
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.13.12
Expand Down Expand Up @@ -47,7 +45,7 @@ require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Layr-Labs/cerberus-api v0.0.1 // indirect
github.com/Layr-Labs/cerberus-api v0.0.2-0.20250108174619-d5e1eb03fbd5 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/Layr-Labs/cerberus-api v0.0.1 h1:MSLVdxtRS1qnwLks3COnnUw/M3tjLGtbSGaLde86HRg=
github.com/Layr-Labs/cerberus-api v0.0.1/go.mod h1:Lm4fhzy0S3P7GjerzuseGaBFVczsIKmEhIjcT52Hluo=
github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241211213446-c5ffb53d14b0 h1:w8JMZum+by34GhtswK19r2jkSaZb8Y9fOEijAv1wJAA=
github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241211213446-c5ffb53d14b0/go.mod h1:aYdNURUhaqeYOS+Cq12TfSdPbjFfiLaHkxPdR4Exq/s=
github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20241211213446-c5ffb53d14b0 h1:Zf/bwHZlX+4anEkPLz2l9WSYPxTfACxNulgSupqxTGk=
github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20241211213446-c5ffb53d14b0/go.mod h1:ibvhYLQhmBqj+MqI+gjY2nRw7+QcbbLhHOBageOA0zY=
github.com/Layr-Labs/cerberus-api v0.0.2-0.20250108174619-d5e1eb03fbd5 h1:s24M6HYObEuV9OSY36jUM09kp5fOhuz/g1ev2qWDPzU=
github.com/Layr-Labs/cerberus-api v0.0.2-0.20250108174619-d5e1eb03fbd5/go.mod h1:Lm4fhzy0S3P7GjerzuseGaBFVczsIKmEhIjcT52Hluo=
github.com/Layr-Labs/eigensdk-go v0.2.0-beta.1.0.20250108021201-9313acc6a60a h1:79C0Rti47GLaViqq6oS6cZKsyq/ccwVsyK0WIWZNSIM=
github.com/Layr-Labs/eigensdk-go v0.2.0-beta.1.0.20250108021201-9313acc6a60a/go.mod h1:G4yqiK+5NfUuEMVGGncOEm7QskuGRPmKA7bKxpPzPT4=
github.com/Layr-Labs/eigensdk-go v0.2.0-beta.1.0.20250108183217-59122e8557bc h1:NMM+LULjQu8vSbDtWSxWFDCEb16hCNILp+ZD1JLpc6U=
github.com/Layr-Labs/eigensdk-go v0.2.0-beta.1.0.20250108183217-59122e8557bc/go.mod h1:G4yqiK+5NfUuEMVGGncOEm7QskuGRPmKA7bKxpPzPT4=
github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20250108183217-59122e8557bc h1:dKLTQUvD4Bd+A7Yoj06Al+eWVSxlWk7x8/f/ZTKqYsQ=
github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20250108183217-59122e8557bc/go.mod h1:p/coyQpMG0aaF+JekxNoacPWP6FqSuWLI2YpiC+YVKs=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=
Expand Down
Loading

0 comments on commit 550d354

Please sign in to comment.