Skip to content

Commit

Permalink
Minor cleanups (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsondav authored Jul 17, 2023
1 parent b67d49a commit 61eb2c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/reportingplugins/mercury/mercury.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ func (fac Factory) NewMercuryPlugin(configuration ocr3types.MercuryPluginConfig)
configuration.ConfigDigest,
configuration.F,
epochRound{},
new(big.Int),
maxReportLength,
}

Expand All @@ -259,7 +258,6 @@ type reportingPlugin struct {
configDigest ocrtypes.ConfigDigest
f int
latestAcceptedEpochRound epochRound
latestAcceptedMedian *big.Int
maxReportLength int
}

Expand Down Expand Up @@ -306,10 +304,10 @@ func (rp *reportingPlugin) Observation(ctx context.Context, repts ocrtypes.Repor

if obs.Ask.Err != nil {
obsErrors = append(obsErrors, pkgerrors.Wrap(obs.Ask.Err, "failed to observe Ask"))
} else if bid, err := EncodeValueInt192(obs.Ask.Val); err != nil {
} else if ask, err := EncodeValueInt192(obs.Ask.Val); err != nil {
obsErrors = append(obsErrors, pkgerrors.Wrap(err, "failed to observe Ask; encoding failed"))
} else {
p.Ask = bid
p.Ask = ask
}

if obs.BenchmarkPrice.Err == nil && obs.Bid.Err == nil && obs.Ask.Err == nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/reportingplugins/mercury/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// NOTE: hardcoded for now, this may need to change if we support block range on chains other than eth
const evmHashLen = 32

// ValidateBenchmarkPrice checks that value is between min and max
func ValidateBenchmarkPrice(paos []ParsedAttributedObservation, f int, min, max *big.Int) error {
answer, err := GetConsensusBenchmarkPrice(paos, f)
if err != nil {
Expand All @@ -23,6 +24,7 @@ func ValidateBenchmarkPrice(paos []ParsedAttributedObservation, f int, min, max
return nil
}

// ValidateBid checks that value is between min and max
func ValidateBid(paos []ParsedAttributedObservation, f int, min, max *big.Int) error {
answer, err := GetConsensusBid(paos, f)
if err != nil {
Expand All @@ -36,6 +38,7 @@ func ValidateBid(paos []ParsedAttributedObservation, f int, min, max *big.Int) e
return nil
}

// ValidateAsk checks that value is between min and max
func ValidateAsk(paos []ParsedAttributedObservation, f int, min, max *big.Int) error {
answer, err := GetConsensusAsk(paos, f)
if err != nil {
Expand All @@ -49,6 +52,7 @@ func ValidateAsk(paos []ParsedAttributedObservation, f int, min, max *big.Int) e
return nil
}

// ValidateCurrentBlock sanity checks number and hash
func ValidateCurrentBlock(paos []ParsedAttributedObservation, f int, validFromBlockNum int64) error {
if validFromBlockNum < 0 {
return fmt.Errorf("validFromBlockNum must be >= 0 (got: %d)", validFromBlockNum)
Expand Down

0 comments on commit 61eb2c0

Please sign in to comment.