Skip to content

Commit

Permalink
Add additional logs (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhailUshakoff authored Jun 14, 2024
1 parent 0161f9a commit 64465ef
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
8 changes: 5 additions & 3 deletions aggregator/message_blsagg.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import (

var (
MessageAlreadyInitializedErrorFn = func(messageDigest coretypes.MessageDigest) error {
return fmt.Errorf("message %x already initialized", messageDigest)
return fmt.Errorf("message 0x%x already initialized", messageDigest)
}
MessageExpiredError = fmt.Errorf("message expired")
MessageNotFoundErrorFn = func(messageDigest coretypes.MessageDigest) error {
return fmt.Errorf("message %x not initialized or already completed", messageDigest)
return fmt.Errorf("message 0x%x not initialized or already completed", messageDigest)
}
OperatorNotPartOfMessageQuorumErrorFn = func(operatorId eigentypes.OperatorId, messageDigest coretypes.MessageDigest) error {
return fmt.Errorf("operator %x not part of message %x's quorum", operatorId, messageDigest)
return fmt.Errorf("operator 0x%x not part of message 0x%x's quorum", operatorId, messageDigest)
}
SignatureVerificationError = func(err error) error {
return fmt.Errorf("Failed to verify signature: %w", err)
Expand Down Expand Up @@ -232,6 +232,7 @@ func (mbas *MessageBlsAggregatorService) handleSignedMessagePreThreshold(
return false
}
case <-messageExpiredTimer.C:
mbas.logger.Debug("Message expired", "messageDigest", messageDigest)
mbas.aggregatedResponsesC <- types.MessageBlsAggregationServiceResponse{
MessageBlsAggregation: messages.MessageBlsAggregation{
MessageDigest: messageDigest,
Expand Down Expand Up @@ -273,6 +274,7 @@ func (mbas *MessageBlsAggregatorService) handleSignedMessageThresholdReached(
return
}
case <-thresholdReachedTimer.C:
mbas.logger.Debug("Message expired", "messageDigest", messageDigest)
mbas.aggregatedResponsesC <- mbas.getMessageBlsAggregationResponse(messageDigest, validationInfo, true)
return
}
Expand Down
10 changes: 10 additions & 0 deletions aggregator/rest_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,28 @@ func (agg *Aggregator) handleGetStateRootUpdateAggregation(w http.ResponseWriter
params := r.URL.Query()
rollupId, err := strconv.ParseUint(params.Get("rollupId"), 10, 32)
if err != nil {
agg.logger.Error("Invalid rollupId", "params", params)
http.Error(w, "Invalid rollupId", http.StatusBadRequest)
return err
}

blockHeight, err := strconv.ParseUint(params.Get("blockHeight"), 10, 64)
if err != nil {
agg.logger.Error("Invalid blockHeight", "params", params)
http.Error(w, "Invalid blockHeight", http.StatusBadRequest)
return err
}

message, err := agg.msgDb.FetchStateRootUpdate(uint32(rollupId), blockHeight)
if err != nil {
agg.logger.Error("StateRootUpdate not found", "params", params)
http.Error(w, "StateRootUpdate not found", http.StatusNotFound)
return err
}

aggregation, err := agg.msgDb.FetchStateRootUpdateAggregation(uint32(rollupId), blockHeight)
if err != nil {
agg.logger.Error("StateRootUpdate aggregation not found", "params", params)
http.Error(w, "StateRootUpdate aggregation not found", http.StatusNotFound)
return err
}
Expand All @@ -83,18 +87,21 @@ func (agg *Aggregator) handleGetOperatorSetUpdateAggregation(w http.ResponseWrit
params := r.URL.Query()
id, err := strconv.ParseUint(params.Get("id"), 10, 64)
if err != nil {
agg.logger.Error("Invalid id", "params", params)
http.Error(w, "Invalid id", http.StatusBadRequest)
return err
}

message, err := agg.msgDb.FetchOperatorSetUpdate(id)
if err != nil {
agg.logger.Error("OperatorSetUpdate not found", "params", params)
http.Error(w, "OperatorSetUpdate not found", http.StatusNotFound)
return err
}

aggregation, err := agg.msgDb.FetchOperatorSetUpdateAggregation(id)
if err != nil {
agg.logger.Error("OperatorSetUpdate aggregation not found", "params", params)
http.Error(w, "OperatorSetUpdate aggregation not found", http.StatusNotFound)
return err
}
Expand All @@ -115,18 +122,21 @@ func (agg *Aggregator) handleGetCheckpointMessages(w http.ResponseWriter, r *htt

fromTimestamp, err := strconv.ParseUint(params.Get("fromTimestamp"), 10, 64)
if err != nil {
agg.logger.Error("Invalid fromTimestamp", "params", params)
http.Error(w, "Invalid fromTimestamp", http.StatusBadRequest)
return err
}

toTimestamp, err := strconv.ParseUint(params.Get("toTimestamp"), 10, 64)
if err != nil {
agg.logger.Error("Invalid toTimestamp", "params", params)
http.Error(w, "Invalid toTimestamp", http.StatusBadRequest)
return err
}

checkpointMessages, err := agg.msgDb.FetchCheckpointMessages(fromTimestamp, toTimestamp)
if err != nil {
agg.logger.Error("CheckpointMessages not found", "params", params)
http.Error(w, "CheckpointMessages not found", http.StatusNotFound)
return err
}
Expand Down
5 changes: 5 additions & 0 deletions operator/attestor/attestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ func NewAttestor(config *optypes.NodeConfig, blsKeypair *bls.KeyPair, operatorId

attestor.clients[rollupId] = client
attestor.rpcCallsCollectors[rollupId] = rpcCallsCollector

logger.Debug("New Attestor for rollup",
"rollupId", rollupId,
"rollupIdsToUrls", url,
)
}

return &attestor, nil
Expand Down
12 changes: 2 additions & 10 deletions operator/attestor/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ func subscribe(notifier *Notifier, blocks []consumer.BlockData, subscribedWg *sy

go func(block consumer.BlockData, notifier *Notifier) {
predicate := func(mqBlock consumer.BlockData) bool {
if block.Block.Header().Number.Cmp(mqBlock.Block.Header().Number) != 0 {
return false
}

return true
return block.Block.Header().Number.Cmp(mqBlock.Block.Header().Number) == 0
}

blocksC, id := notifier.Subscribe(block.RollupId, predicate)
Expand Down Expand Up @@ -107,11 +103,7 @@ func TestNotifierSubscribeAndUnsubscribe(t *testing.T) {
notifier := NewNotifier()

predicate := func(mqBlock consumer.BlockData) bool {
if block.Block.Header().Number.Cmp(mqBlock.Block.Header().Number) != 0 {
return false
}

return true
return block.Block.Header().Number.Cmp(mqBlock.Block.Header().Number) == 0
}
_, id := notifier.Subscribe(block.RollupId, predicate)
assert.Equal(t, notifier.rollupIdsToSubscribers[block.RollupId].Len(), 1)
Expand Down
2 changes: 2 additions & 0 deletions operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func NewOperatorFromConfig(c optypes.NodeConfig) (*Operator, error) {
return nil, err
}

logger.Debug("Creating operator from config", "config", c)

// Setup Node Api
nodeApi := nodeapi.NewNodeApi(AVS_NAME, SEM_VER, c.NodeApiIpPortAddress, logger)
blsKeyPassword, ok := os.LookupEnv("OPERATOR_BLS_KEY_PASSWORD")
Expand Down

0 comments on commit 64465ef

Please sign in to comment.