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

add bls signer abstraction from eigensdk #985

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/codeql-scanning.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Install golang
uses: actions/setup-go@v3
with:
go-version: '1.21.1'
go-version: '1.21.13'

- name: Custom build using make
run: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG SEMVER=""
ARG GITCOMMIT=""
ARG GITDATE=""

FROM golang:1.21.1-alpine3.18 AS base-builder
FROM golang:1.21.13-alpine3.20 AS base-builder
RUN apk add --no-cache make musl-dev linux-headers gcc git jq bash

# Common build stage
Expand Down
2 changes: 1 addition & 1 deletion api/builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.12-bookworm
FROM golang:1.21.13-bookworm

# The URL where the protoc binary can be downloaded. Is different depending on architecture.
ARG PROTOC_URL
Expand Down
4 changes: 2 additions & 2 deletions api/clients/retrieval_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/Layr-Labs/eigenda/api/clients"
clientsmock "github.com/Layr-Labs/eigenda/api/clients/mock"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
coreindexer "github.com/Layr-Labs/eigenda/core/indexer"
coremock "github.com/Layr-Labs/eigenda/core/mock"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/Layr-Labs/eigenda/encoding/kzg/verifier"
"github.com/Layr-Labs/eigenda/encoding/utils/codec"
indexermock "github.com/Layr-Labs/eigenda/indexer/mock"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/consensys/gnark-crypto/ecc/bn254"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -96,7 +96,7 @@ func setup(t *testing.T) {
if err != nil {
t.Fatal(err)
}
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()
indexer = &indexermock.MockIndexer{}
indexer.On("Index").Return(nil).Once()

Expand Down
4 changes: 2 additions & 2 deletions common/geth/multihoming_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/Layr-Labs/eigenda/common/geth"
damock "github.com/Layr-Labs/eigenda/common/mock"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/ethereum/go-ethereum/rpc"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand All @@ -25,7 +25,7 @@ func (j *JsonError) Error() string { return "json error" }
func (j *JsonError) ErrorCode() int { return -32000 }

func makeTestMultihomingClient(numRetries int, designatedError error) (*geth.MultiHomingClient, error) {
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()

ethClientCfg := geth.EthClientConfig{
RPCURLs: rpcURLs,
Expand Down
4 changes: 2 additions & 2 deletions common/ratelimit/ratelimit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/common/ratelimit"
"github.com/Layr-Labs/eigenda/common/store"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
)
Expand All @@ -26,7 +26,7 @@ func makeTestRatelimiter() (common.RateLimiter, error) {
return nil, err
}

ratelimiter := ratelimit.NewRateLimiter(prometheus.NewRegistry(), globalParams, bucketStore, logging.NewNoopLogger())
ratelimiter := ratelimit.NewRateLimiter(prometheus.NewRegistry(), globalParams, bucketStore, testutils.GetLogger())

return ratelimiter, nil

Expand Down
4 changes: 2 additions & 2 deletions common/store/dynamo_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
"github.com/Layr-Labs/eigenda/common/aws/dynamodb"
test_utils "github.com/Layr-Labs/eigenda/common/aws/dynamodb/utils"
"github.com/Layr-Labs/eigenda/common/store"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/inabox/deploy"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/ory/dockertest/v3"
"github.com/stretchr/testify/assert"
)

var (
logger = logging.NewNoopLogger()
logger = testutils.GetLogger()

dockertestPool *dockertest.Pool
dockertestResource *dockertest.Resource
Expand Down
11 changes: 9 additions & 2 deletions common/testutils/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package testutils
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"golang.org/x/exp/rand"
"os"
"testing"
"time"

"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/stretchr/testify/assert"
"golang.org/x/exp/rand"
)

// InitializeRandom initializes the random number generator. If no arguments are provided, then the seed is randomly
Expand Down Expand Up @@ -112,3 +115,7 @@ func RandomString(length int) string {
}
return string(b)
}

func GetLogger() logging.Logger {
return logging.NewTextSLogger(os.Stdout, &logging.SLoggerOptions{})
}
4 changes: 2 additions & 2 deletions core/aggregation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"os"
"testing"

"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/core/mock"
"github.com/Layr-Labs/eigensdk-go/logging"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
)
Expand All @@ -30,7 +30,7 @@ func TestMain(m *testing.M) {
if err != nil {
panic(err)
}
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()
transactor := &mock.MockWriter{}
transactor.On("OperatorIDToAddress").Return(gethcommon.Address{}, nil)
agg, err = core.NewStdSignatureAggregator(logger, transactor)
Expand Down
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 @@ -146,6 +147,7 @@ type Writer interface {
RegisterOperator(
ctx context.Context,
keypair *KeyPair,
signer sdkSigner.Signer,
socket string,
quorumIds []QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
Expand All @@ -158,6 +160,7 @@ type Writer interface {
RegisterOperatorWithChurn(
ctx context.Context,
keypair *KeyPair,
signer sdkSigner.Signer,
socket string,
quorumIds []QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
Expand Down
44 changes: 39 additions & 5 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"
"fmt"
"math/big"
"strings"
Expand All @@ -29,6 +30,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 @@ -287,7 +290,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 @@ -303,24 +306,55 @@ func (t *Reader) getRegistrationParams(
}

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)
g, err := sig.Deserialize(sigBytes)
if err != nil {
return nil, nil, err
}
signature := &core.Signature{
G1Point: g,
}

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)
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)
g2point, err = g2point.Deserialize(g2KeyBytes)
if err != nil {
return nil, nil, err
}
g2Point_ := pubKeyG2ToBN254G2Point(g2point)
g2Point := regcoordinator.BN254G2Point{
X: g2Point_.X,
Y: g2Point_.Y,
}

params := regcoordinator.IBLSApkRegistryPubkeyRegistrationParams{
PubkeyRegistrationSignature: signedMessageHashParam,
PubkeyG1: g1Point,
Expand Down
12 changes: 8 additions & 4 deletions core/eth/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/Layr-Labs/eigenda/api"
dreg "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDADisperserRegistry"
"log"
"math/big"

"github.com/Layr-Labs/eigenda/api"
dreg "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDADisperserRegistry"

"github.com/Layr-Labs/eigenda/api/grpc/churner"
"github.com/Layr-Labs/eigenda/common"
eigendasrvmg "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDAServiceManager"
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 @@ -62,14 +64,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, signer, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry)
if err != nil {
t.logger.Error("Failed to get registration params", "err", err)
return err
Expand Down Expand Up @@ -102,6 +105,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 @@ -110,7 +114,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, signer, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry)
if err != nil {
t.logger.Error("Failed to get registration params", "err", err)
return err
Expand Down
13 changes: 11 additions & 2 deletions core/indexer/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/common/geth"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/core/eth"
indexedstate "github.com/Layr-Labs/eigenda/core/indexer"
Expand All @@ -26,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 @@ -50,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 @@ -63,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 Expand Up @@ -154,7 +163,7 @@ var _ = Describe("Indexer", func() {
Skip("No test path provided")
}

logger := logging.NewNoopLogger()
logger := testutils.GetLogger()
ctx, cancel := context.WithCancel(context.Background())
_ = cancel

Expand Down
5 changes: 2 additions & 3 deletions core/meterer/meterer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/Layr-Labs/eigenda/common"
commonaws "github.com/Layr-Labs/eigenda/common/aws"
commondynamodb "github.com/Layr-Labs/eigenda/common/aws/dynamodb"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/core/meterer"
"github.com/Layr-Labs/eigenda/core/mock"
Expand All @@ -22,8 +23,6 @@ import (
"github.com/ory/dockertest/v3"
"github.com/stretchr/testify/assert"
testifymock "github.com/stretchr/testify/mock"

"github.com/Layr-Labs/eigensdk-go/logging"
)

var (
Expand Down Expand Up @@ -108,7 +107,7 @@ func setup(_ *testing.M) {
panic("failed to generate private key")
}

logger = logging.NewNoopLogger()
logger = testutils.GetLogger()
config := meterer.Config{
ChainReadTimeout: 3 * time.Second,
UpdateInterval: 1 * time.Second,
Expand Down
Loading
Loading