Skip to content

Commit

Permalink
Fix unit test.
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Littley <[email protected]>
  • Loading branch information
cody-littley committed Dec 19, 2024
1 parent 52f2354 commit 7c5cc93
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 36 deletions.
2 changes: 1 addition & 1 deletion api/clients/v2/request_signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func setup(t *testing.T) {
deployLocalStack := !(os.Getenv("DEPLOY_LOCALSTACK") == "false")

_, b, _, _ := runtime.Caller(0)
rootPath := filepath.Join(filepath.Dir(b), "../..")
rootPath := filepath.Join(filepath.Dir(b), "../../..")
changeDirectory(filepath.Join(rootPath, "inabox"))

if deployLocalStack {
Expand Down
12 changes: 11 additions & 1 deletion node/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"github.com/Layr-Labs/eigenda/common/geth"
coreeth "github.com/Layr-Labs/eigenda/core/eth"
rpccalls "github.com/Layr-Labs/eigensdk-go/metrics/collectors/rpc_calls"
"log"
"os"
Expand Down Expand Up @@ -80,6 +81,15 @@ func NodeMain(ctx *cli.Context) error {
return fmt.Errorf("cannot create chain.Client: %w", err)
}

reader, err := coreeth.NewReader(
logger,
client,
config.BLSOperatorStateRetrieverAddr,
config.EigenDAServiceManagerAddr)
if err != nil {
return fmt.Errorf("cannot create eth.Reader: %w", err)
}

// Create the node.
node, err := node.NewNode(reg, config, pubIPProvider, client, logger)
if err != nil {
Expand All @@ -97,7 +107,7 @@ func NodeMain(ctx *cli.Context) error {
// TODO(cody-littley): the metrics server is currently started by eigenmetrics, which is in another repo.
// When we fully remove v1 support, we need to start the metrics server inside the v2 metrics code.
server := nodegrpc.NewServer(config, node, logger, ratelimiter)
serverV2, err := nodegrpc.NewServerV2(context.Background(), config, node, logger, ratelimiter, reg, client)
serverV2, err := nodegrpc.NewServerV2(context.Background(), config, node, logger, ratelimiter, reg, reader)
if err != nil {
return fmt.Errorf("failed to create server v2: %v", err)
}
Expand Down
12 changes: 1 addition & 11 deletions node/grpc/server_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/common/kvstore"
"github.com/Layr-Labs/eigenda/core"
coreeth "github.com/Layr-Labs/eigenda/core/eth"
corev2 "github.com/Layr-Labs/eigenda/core/v2"
"github.com/Layr-Labs/eigenda/node"
"github.com/Layr-Labs/eigenda/node/auth"
Expand Down Expand Up @@ -43,7 +42,7 @@ func NewServerV2(
logger logging.Logger,
ratelimiter common.RateLimiter,
registry *prometheus.Registry,
client common.EthClient) (*ServerV2, error) {
reader core.Reader) (*ServerV2, error) {

metrics, err := NewV2Metrics(logger, registry)
if err != nil {
Expand All @@ -52,15 +51,6 @@ func NewServerV2(

var authenticator auth.RequestAuthenticator
if !config.DisableDispersalAuthentication {
reader, err := coreeth.NewReader(
logger,
client,
config.BLSOperatorStateRetrieverAddr,
config.EigenDAServiceManagerAddr)
if err != nil {
return nil, fmt.Errorf("cannot create eth.Reader: %w", err)
}

authenticator, err = auth.NewRequestAuthenticator(
ctx,
reader,
Expand Down
7 changes: 5 additions & 2 deletions node/grpc/server_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package grpc_test
import (
"context"
"errors"
coreeth "github.com/Layr-Labs/eigenda/core/eth"
"os"
"sync/atomic"
"testing"
Expand Down Expand Up @@ -84,15 +85,17 @@ func newTestComponents(t *testing.T, config *node.Config) *testComponents {
node.BlobVersionParams.Store(v2.NewBlobVersionParameterMap(blobParamsMap))

// The eth client is only utilized for StoreChunks validation, which is disabled in these tests
var client common.EthClient
// TODO enable auth for these tests
var reader *coreeth.Reader

server, err := grpc.NewServerV2(
context.Background(),
config,
node,
logger,
ratelimiter,
prometheus.NewRegistry(),
client)
reader)

require.NoError(t, err)
return &testComponents{
Expand Down
46 changes: 25 additions & 21 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
clientsmock "github.com/Layr-Labs/eigenda/api/clients/mock"
commonaws "github.com/Layr-Labs/eigenda/common/aws"
"github.com/Layr-Labs/eigenda/core/meterer"
coremock "github.com/Layr-Labs/eigenda/core/mock"
"github.com/Layr-Labs/eigenda/disperser/apiserver"
dispatcher "github.com/Layr-Labs/eigenda/disperser/batcher/grpc"
"github.com/Layr-Labs/eigenda/disperser/encoder"
Expand All @@ -45,7 +46,6 @@ import (
"github.com/Layr-Labs/eigenda/common"
commonmock "github.com/Layr-Labs/eigenda/common/mock"
"github.com/Layr-Labs/eigenda/core"
coremock "github.com/Layr-Labs/eigenda/core/mock"
"github.com/Layr-Labs/eigenda/disperser"
"github.com/Layr-Labs/eigenda/disperser/batcher"
batchermock "github.com/Layr-Labs/eigenda/disperser/batcher/mock"
Expand Down Expand Up @@ -351,20 +351,21 @@ func mustMakeOperators(t *testing.T, cst *coremock.ChainDataMock, logger logging
}

config := &node.Config{
Hostname: op.Host,
DispersalPort: op.DispersalPort,
RetrievalPort: op.RetrievalPort,
InternalRetrievalPort: op.RetrievalPort,
InternalDispersalPort: op.DispersalPort,
EnableMetrics: false,
Timeout: 10,
ExpirationPollIntervalSec: 10,
DbPath: dbPath,
LogPath: logPath,
PrivateBls: string(op.KeyPair.GetPubKeyG1().Serialize()),
ID: id,
QuorumIDList: registeredQuorums,
DisableDispersalAuthentication: false, // TODO things break when this is enabled
Hostname: op.Host,
DispersalPort: op.DispersalPort,
RetrievalPort: op.RetrievalPort,
InternalRetrievalPort: op.RetrievalPort,
InternalDispersalPort: op.DispersalPort,
EnableMetrics: false,
Timeout: 10,
ExpirationPollIntervalSec: 10,
DbPath: dbPath,
LogPath: logPath,
PrivateBls: string(op.KeyPair.GetPubKeyG1().Serialize()),
ID: id,
QuorumIDList: registeredQuorums,
DispersalAuthenticationKeyCacheSize: 1024,
DisableDispersalAuthentication: false,
}

// creating a new instance of encoder instead of sharing enc because enc is not thread safe
Expand Down Expand Up @@ -418,20 +419,23 @@ func mustMakeOperators(t *testing.T, cst *coremock.ChainDataMock, logger logging
OperatorSocketsFilterer: mockOperatorSocketsFilterer,
}

ratelimiter := &commonmock.NoopRatelimiter{}
rateLimiter := &commonmock.NoopRatelimiter{}

// TODO this needs to be non-null once we enable dispersal authentication
var client common.EthClient
// TODO(cody-littley): Once we switch this test to use the v2 disperser, we will need to properly set up
// the disperser's public/private keys for signing StoreChunks() requests
disperserAddress := gethcommon.Address{}
reader := &coremock.MockWriter{}
reader.On("GetDisperserAddress", uint32(0)).Return(disperserAddress, nil)

serverV1 := nodegrpc.NewServer(config, n, logger, ratelimiter)
serverV1 := nodegrpc.NewServer(config, n, logger, rateLimiter)
serverV2, err := nodegrpc.NewServerV2(
context.Background(),
config,
n,
logger,
ratelimiter,
rateLimiter,
prometheus.NewRegistry(),
client)
reader)
require.NoError(t, err)

ops[id] = TestOperator{
Expand Down

0 comments on commit 7c5cc93

Please sign in to comment.