diff --git a/disperser/cmd/dataapi/main.go b/disperser/cmd/dataapi/main.go index 9a6dc5dd1d..589c847890 100644 --- a/disperser/cmd/dataapi/main.go +++ b/disperser/cmd/dataapi/main.go @@ -144,5 +144,5 @@ func RunDataApi(ctx *cli.Context) error { logger.Errorf("Failed to shutdown server: %v", err) } - return server.Start() + return err } diff --git a/disperser/dataapi/server.go b/disperser/dataapi/server.go index 3ff4e1533e..4464663cce 100644 --- a/disperser/dataapi/server.go +++ b/disperser/dataapi/server.go @@ -270,7 +270,7 @@ func (s *server) Start() error { Handler: router, ReadTimeout: 5 * time.Second, ReadHeaderTimeout: 5 * time.Second, - WriteTimeout: 10 * time.Second, + WriteTimeout: 20 * time.Second, IdleTimeout: 120 * time.Second, } @@ -570,6 +570,7 @@ func (s *server) FetchDeregisteredOperators(c *gin.Context) { operatorMetadatas, err := s.getDeregisteredOperatorForDays(c.Request.Context(), int32(daysInt)) if err != nil { + s.logger.Error("Failed to fetch deregistered operators", "error", err) s.metrics.IncrementFailedRequestNum("FetchDeregisteredOperators") errorResponse(c, err) return diff --git a/disperser/dataapi/subgraph/api.go b/disperser/dataapi/subgraph/api.go index 900a9f1e9c..8e5aab5236 100644 --- a/disperser/dataapi/subgraph/api.go +++ b/disperser/dataapi/subgraph/api.go @@ -2,12 +2,10 @@ package subgraph import ( "context" - "encoding/hex" "fmt" "sync" "time" - "github.com/Layr-Labs/eigenda/core" "github.com/shurcooL/graphql" ) @@ -26,7 +24,7 @@ type ( QueryBatchNonSigningInfo(ctx context.Context, startTime, endTime int64) ([]*BatchNonSigningInfo, error) QueryDeregisteredOperatorsGreaterThanBlockTimestamp(ctx context.Context, blockTimestamp uint64) ([]*Operator, error) QueryRegisteredOperatorsGreaterThanBlockTimestamp(ctx context.Context, blockTimestamp uint64) ([]*Operator, error) - QueryOperatorInfoByOperatorIdAtBlockNumber(ctx context.Context, operatorId core.OperatorID, blockNumber uint32) (*IndexedOperatorInfo, error) + QueryOperatorInfoByOperatorIdAtBlockNumber(ctx context.Context, operatorId string, blockNumber uint32) (*IndexedOperatorInfo, error) QueryOperatorAddedToQuorum(ctx context.Context, startBlock, endBlock uint32) ([]*OperatorQuorum, error) QueryOperatorRemovedFromQuorum(ctx context.Context, startBlock, endBlock uint32) ([]*OperatorQuorum, error) } @@ -196,11 +194,13 @@ func (a *api) QueryDeregisteredOperatorsGreaterThanBlockTimestamp(ctx context.Co return query.OperatorDeregistereds, nil } -func (a *api) QueryOperatorInfoByOperatorIdAtBlockNumber(ctx context.Context, operatorId core.OperatorID, blockNumber uint32) (*IndexedOperatorInfo, error) { +func (a *api) QueryOperatorInfoByOperatorIdAtBlockNumber(ctx context.Context, operatorId string, blockNumber uint32) (*IndexedOperatorInfo, error) { + fmt.Printf("==QueryOperatorInfoByOperatorIdAtBlockNumber ==== operatorId: %v\n", operatorId) + var ( query queryOperatorById variables = map[string]any{ - "id": graphql.String(fmt.Sprintf("0x%s", hex.EncodeToString(operatorId[:]))), + "id": graphql.String(fmt.Sprintf("0x%s", operatorId)), } ) err := a.operatorStateGql.Query(context.Background(), &query, variables) diff --git a/disperser/dataapi/subgraph/mock/api.go b/disperser/dataapi/subgraph/mock/api.go index 7bb152335d..465c198ef1 100644 --- a/disperser/dataapi/subgraph/mock/api.go +++ b/disperser/dataapi/subgraph/mock/api.go @@ -5,7 +5,6 @@ import ( "context" "slices" - "github.com/Layr-Labs/eigenda/core" "github.com/Layr-Labs/eigenda/disperser/dataapi/subgraph" "github.com/stretchr/testify/mock" ) @@ -115,7 +114,7 @@ func (m *MockSubgraphApi) QueryDeregisteredOperatorsGreaterThanBlockTimestamp(ct return value, args.Error(1) } -func (m *MockSubgraphApi) QueryOperatorInfoByOperatorIdAtBlockNumber(ctx context.Context, operatorId core.OperatorID, blockNumber uint32) (*subgraph.IndexedOperatorInfo, error) { +func (m *MockSubgraphApi) QueryOperatorInfoByOperatorIdAtBlockNumber(ctx context.Context, operatorId string, blockNumber uint32) (*subgraph.IndexedOperatorInfo, error) { args := m.Called() var value *subgraph.IndexedOperatorInfo diff --git a/disperser/dataapi/subgraph_client.go b/disperser/dataapi/subgraph_client.go index 749dc44b37..40d966feec 100644 --- a/disperser/dataapi/subgraph_client.go +++ b/disperser/dataapi/subgraph_client.go @@ -44,12 +44,12 @@ type ( TxFee uint64 } Operator struct { - Id []byte - OperatorId []byte - Operator []byte + Id string + OperatorId string + Operator string BlockTimestamp uint64 BlockNumber uint64 - TransactionHash []byte + TransactionHash string } OperatorQuorum struct { Operator string @@ -239,7 +239,7 @@ func (sc *subgraphClient) QueryIndexedDeregisteredOperatorsForTimeWindow(ctx con // Copy the operator id to a 32 byte array. copy(operatorId[:], operator.OperatorId) - operatorInfo, err := sc.api.QueryOperatorInfoByOperatorIdAtBlockNumber(ctx, operatorId, uint32(operator.BlockNumber)) + operatorInfo, err := sc.api.QueryOperatorInfoByOperatorIdAtBlockNumber(ctx, operator.OperatorId, uint32(operator.BlockNumber)) if err != nil { operatorIdString := "0x" + hex.EncodeToString(operatorId[:]) errorMessage := fmt.Sprintf("query operator info by operator id at block number failed: %d for operator %s", uint32(operator.BlockNumber), operatorIdString) @@ -334,12 +334,12 @@ func convertOperator(operator *subgraph.Operator) (*Operator, error) { } return &Operator{ - Id: []byte(operator.Id), - OperatorId: []byte(operator.OperatorId), - Operator: []byte(operator.Operator), + Id: string(operator.Id), + OperatorId: string(operator.OperatorId), + Operator: string(operator.Operator), BlockTimestamp: timestamp, BlockNumber: blockNum, - TransactionHash: []byte(operator.TransactionHash), + TransactionHash: string(operator.TransactionHash), }, nil } diff --git a/disperser/dataapi/subgraph_client_test.go b/disperser/dataapi/subgraph_client_test.go index d4b2bd5be4..039f5e5537 100644 --- a/disperser/dataapi/subgraph_client_test.go +++ b/disperser/dataapi/subgraph_client_test.go @@ -440,20 +440,20 @@ func TestQueryOperators(t *testing.T) { assert.Equal(t, 2, len(operators)) assert.NotNil(t, operators[0]) - assert.Equal(t, []byte("0x000763fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f211"), operators[0].Id) - assert.Equal(t, []byte("0x000563fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f211"), operators[0].Operator) - assert.Equal(t, []byte("0xe1cdae12a0074f20b8fc96a0489376db34075e545ef60c4845d264a732568311"), operators[0].OperatorId) + assert.Equal(t, "0x000763fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f211", operators[0].Id) + assert.Equal(t, "0x000563fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f211", operators[0].Operator) + assert.Equal(t, "0xe1cdae12a0074f20b8fc96a0489376db34075e545ef60c4845d264a732568311", operators[0].OperatorId) assert.Equal(t, uint64(1696975449), operators[0].BlockTimestamp) assert.Equal(t, uint64(87), operators[0].BlockNumber) - assert.Equal(t, []byte("0x000163fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f211"), operators[0].TransactionHash) + assert.Equal(t, "0x000163fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f211", operators[0].TransactionHash) assert.NotNil(t, operators[1]) - assert.Equal(t, []byte("0x000763fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f212"), operators[1].Id) - assert.Equal(t, []byte("0x000563fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f212"), operators[1].Operator) - assert.Equal(t, []byte("0xe1cdae12a0074f20b8fc96a0489376db34075e545ef60c4845d264a732568310"), operators[1].OperatorId) + assert.Equal(t, "0x000763fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f212", operators[1].Id) + assert.Equal(t, "0x000563fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f212", operators[1].Operator) + assert.Equal(t, "0xe1cdae12a0074f20b8fc96a0489376db34075e545ef60c4845d264a732568310", operators[1].OperatorId) assert.Equal(t, uint64(1696975459), operators[1].BlockTimestamp) assert.Equal(t, uint64(88), operators[1].BlockNumber) - assert.Equal(t, []byte("0x000163fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f212"), operators[1].TransactionHash) + assert.Equal(t, "0x000163fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f212", operators[1].TransactionHash) } func TestQueryIndexedDeregisteredOperatorsForTimeWindow(t *testing.T) { @@ -480,8 +480,8 @@ func TestQueryIndexedDeregisteredOperatorsForTimeWindow(t *testing.T) { assert.Equal(t, expectedIndexedOperatorInfo.PubkeyG2, operator.IndexedOperatorInfo.PubkeyG2) assert.Equal(t, "localhost:32006;32007", operator.IndexedOperatorInfo.Socket) assert.Equal(t, uint64(22), uint64(operator.BlockNumber)) - assert.Equal(t, []byte("0xe22dae12a0074f20b8fc96a0489376db34075e545ef60c4845d264a732568311"), operator.Metadata.OperatorId) - assert.Equal(t, []byte("0x000223fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f211"), operator.Metadata.TransactionHash) + assert.Equal(t, "0xe22dae12a0074f20b8fc96a0489376db34075e545ef60c4845d264a732568311", operator.Metadata.OperatorId) + assert.Equal(t, "0x000223fb86a79eda47c891d8826474d80b6a935ad2a2b5de921933e05c67f320f211", operator.Metadata.TransactionHash) assert.Equal(t, uint64(22), uint64(operator.Metadata.BlockNumber)) }