Skip to content

Commit

Permalink
Log observations in report (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorwstein authored Jan 22, 2024
1 parent 853dd75 commit 59009f1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/services/ocr2/plugins/ccip/observations.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"encoding/json"
"math/big"

"github.com/smartcontractkit/libocr/commontypes"

"github.com/ethereum/go-ethereum/common"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"

Expand Down Expand Up @@ -71,19 +73,22 @@ func (o ExecutionObservation) Marshal() ([]byte, error) {
// malformed observations but never error.
func GetParsableObservations[O CommitObservation | ExecutionObservation](l logger.Logger, observations []types.AttributedObservation) []O {
var parseableObservations []O
var observers []commontypes.OracleID
for _, ao := range observations {
if len(ao.Observation) == 0 {
// Empty observation
l.Infow("Discarded empty observation %+v", ao)
l.Infow("Discarded empty observation", "observer", ao.Observer)
continue
}
var ob O
err := json.Unmarshal(ao.Observation, &ob)
if err != nil {
l.Errorw("Received unmarshallable observation", "err", err, "observation", string(ao.Observation))
l.Errorw("Received unmarshallable observation", "err", err, "observation", string(ao.Observation), "observer", ao.Observer)
continue
}
parseableObservations = append(parseableObservations, ob)
observers = append(observers, ao.Observer)
}
l.Infow("Parsed observations", "observers", observers, "observations", parseableObservations)
return parseableObservations
}

0 comments on commit 59009f1

Please sign in to comment.