Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions networking/peer_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ type Stream interface {

var _ Stream = (ragep2pwrapper.Stream)(nil)

//sumtype:decl
//go-sumtype:decl NewStreamArgs

// NewStreamArgs must be a NewStreamArgs1 value. Anything else, including nil
// or a pointer to NewStreamArgs1, causes a panic.
type NewStreamArgs interface {
isNewStreamArgs()
}
Expand Down Expand Up @@ -224,7 +227,7 @@ func (f *peerGroup) NewStream(remotePeerID string, newStreamArgs NewStreamArgs)
}
return &managedStream, nil
default:
panic("unreachable")
panic(fmt.Sprintf("unexpected NewStreamArgs type %T", args))
}
}

Expand Down
54 changes: 27 additions & 27 deletions offchainreporting2/reportingplugin/median/median.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,34 +347,34 @@ func (fac NumericalMedianFactory) NewReportingPlugin(ctx context.Context, config
})

return &numericalMedian{
offchainConfig,
onchainConfig,
fac.ContractTransmitter,
fac.DataSource,
fac.JuelsPerFeeCoinDataSource,
fac.GasPriceSubunitsDataSource,
fac.IncludeGasPriceSubunitsInObservation,
logger,
fac.ReportCodec,
deviationFunc,
fac.AcceptAfterFullTransmissionScheduleElapsed || offchainConfig.AcceptAfterFullTransmissionScheduleElapsed,

configuration.ConfigDigest,
configuration.F,
configuration.DurationAllTransmissionStages,
epochRound{},
new(big.Int),
time.Now(),
maxReportLength,
}, types.ReportingPluginInfo{
"NumericalMedian",
false,
types.ReportingPluginLimits{
0,
maxObservationLength,
offchainConfig,
onchainConfig,
fac.ContractTransmitter,
fac.DataSource,
fac.JuelsPerFeeCoinDataSource,
fac.GasPriceSubunitsDataSource,
fac.IncludeGasPriceSubunitsInObservation,
logger,
fac.ReportCodec,
deviationFunc,
fac.AcceptAfterFullTransmissionScheduleElapsed || offchainConfig.AcceptAfterFullTransmissionScheduleElapsed,

configuration.ConfigDigest,
configuration.F,
configuration.DurationAllTransmissionStages,
epochRound{},
new(big.Int),
time.Now(),
maxReportLength,
},
}, nil
}, types.ReportingPluginInfo{
"NumericalMedian",
false,
types.ReportingPluginLimits{
0,
maxObservationLength,
maxReportLength,
},
}, nil
}

func DefaultDeviationFunc(_ context.Context, thresholdPPB uint64, old *big.Int, new *big.Int) (bool, error) {
Expand Down
36 changes: 18 additions & 18 deletions offchainreporting2/reportingplugin/titlerequest/titlerequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ type TitleRequestPluginFactory struct {

func (fac *TitleRequestPluginFactory) NewReportingPlugin(_ context.Context, config types.ReportingPluginConfig) (types.ReportingPlugin, types.ReportingPluginInfo, error) {
return &TitleRequestPlugin{
config.F,
fac.Client,
fac.Contract,
map[[32]byte]bool{},
map[[32]byte]time.Time{},
}, types.ReportingPluginInfo{
"Title Request ReportingPlugin",
false,
types.ReportingPluginLimits{
// queries are empty
0,
// observations are at most 32 (request id) + 32 (title offset) + 32
// (title len) + maxTitleLen chars, let's generously round to 1000
1_000,
// reports follow the same format as observations
1_000,
},
}, nil
config.F,
fac.Client,
fac.Contract,
map[[32]byte]bool{},
map[[32]byte]time.Time{},
}, types.ReportingPluginInfo{
"Title Request ReportingPlugin",
false,
types.ReportingPluginLimits{
// queries are empty
0,
// observations are at most 32 (request id) + 32 (title offset) + 32
// (title len) + maxTitleLen chars, let's generously round to 1000
1_000,
// reports follow the same format as observations
1_000,
},
}, nil
}

var _ types.ReportingPlugin = (*TitleRequestPlugin)(nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (c *PublicConfig) DurationAllTransmissionStages() time.Duration {

func (c *PublicConfig) CheckParameterBounds() error {
if c.F < 0 || c.F > math.MaxUint8 {
return errors.Errorf("number of potentially faulty oracles must fit in 8 bits.")
return errors.Errorf("number of potentially faulty oracles must fit in 8 bits")
}
return nil
}
Expand All @@ -131,7 +131,7 @@ func PublicConfigFromContractConfig(skipResourceExhaustionChecks bool, change ty

func publicConfigFromContractConfig(skipResourceExhaustionChecks bool, change types.ContractConfig) (PublicConfig, config.SharedSecretEncryptions, error) {
if change.OffchainConfigVersion != config.OCR2OffchainConfigVersion {
return PublicConfig{}, config.SharedSecretEncryptions{}, fmt.Errorf("unsuppported OffchainConfigVersion %v, supported OffchainConfigVersion is %v", change.OffchainConfigVersion, config.OCR2OffchainConfigVersion)
return PublicConfig{}, config.SharedSecretEncryptions{}, fmt.Errorf("unsupported OffchainConfigVersion %v, supported OffchainConfigVersion is %v", change.OffchainConfigVersion, config.OCR2OffchainConfigVersion)
}

oc, err := deserializeOffchainConfig(change.OffchainConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func (c *PublicConfig) MinRoundInterval() time.Duration {

func (c *PublicConfig) CheckParameterBounds() error {
if c.F < 0 || c.F > math.MaxUint8 {
return errors.Errorf("number of potentially faulty oracles must fit in 8 bits.")
return errors.Errorf("number of potentially faulty oracles must fit in 8 bits")
}
return nil
}
Expand All @@ -384,7 +384,7 @@ func PublicConfigFromContractConfig(skipInsaneForProductionChecks bool, change t

func publicConfigFromContractConfig(skipInsaneForProductionChecks bool, change types.ContractConfig) (PublicConfig, config.SharedSecretEncryptions, error) {
if change.OffchainConfigVersion != config.OCR3_1OffchainConfigVersion {
return PublicConfig{}, config.SharedSecretEncryptions{}, fmt.Errorf("unsuppported OffchainConfigVersion %v, supported OffchainConfigVersion is %v", change.OffchainConfigVersion, config.OCR3_1OffchainConfigVersion)
return PublicConfig{}, config.SharedSecretEncryptions{}, fmt.Errorf("unsupported OffchainConfigVersion %v, supported OffchainConfigVersion is %v", change.OffchainConfigVersion, config.OCR3_1OffchainConfigVersion)
}

oc, err := deserializeOffchainConfig(change.OffchainConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (c *PublicConfig) MinRoundInterval() time.Duration {

func (c *PublicConfig) CheckParameterBounds() error {
if c.F < 0 || c.F > math.MaxUint8 {
return errors.Errorf("number of potentially faulty oracles must fit in 8 bits.")
return errors.Errorf("number of potentially faulty oracles must fit in 8 bits")
}
return nil
}
Expand All @@ -141,7 +141,7 @@ func PublicConfigFromContractConfig(skipResourceExhaustionChecks bool, change ty

func publicConfigFromContractConfig(skipResourceExhaustionChecks bool, change types.ContractConfig) (PublicConfig, config.SharedSecretEncryptions, error) {
if change.OffchainConfigVersion != config.OCR3OffchainConfigVersion {
return PublicConfig{}, config.SharedSecretEncryptions{}, fmt.Errorf("unsuppported OffchainConfigVersion %v, supported OffchainConfigVersion is %v", change.OffchainConfigVersion, config.OCR3OffchainConfigVersion)
return PublicConfig{}, config.SharedSecretEncryptions{}, fmt.Errorf("unsupported OffchainConfigVersion %v, supported OffchainConfigVersion is %v", change.OffchainConfigVersion, config.OCR3OffchainConfigVersion)
}

oc, err := deserializeOffchainConfig(change.OffchainConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ func RunManagedOCR3_1Oracle[RI any](
switch rpi := reportingPluginInfo_.(type) {
case ocr3_1types.ReportingPluginInfo1:
reportingPluginInfo = rpi
case *ocr3_1types.ReportingPluginInfo1:
if rpi == nil {
return fmt.Errorf("ManagedOCR3_1Oracle: NewReportingPlugin() returned nil *ReportingPluginInfo1"), false
}
reportingPluginInfo = *rpi
case nil:
return fmt.Errorf("ManagedOCR3_1Oracle: NewReportingPlugin() returned nil ReportingPluginInfo"), false
default:
panic(fmt.Sprintf("unexpected ReportingPluginInfo type %T", rpi))
}

if err := reportingPluginInfo.Validate(); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,24 @@ func retryOnError(ctx context.Context, logger loghelper.LoggerWithContext, retry
// in every log line logged from fn.
err, retry := fn(ctx, logger, contractConfig)
if err == nil {
retryLogger.Info("runWithContractConfig: function exited without error. not retrying", nil)
retryLogger.Info("runWithContractConfig: function exited without error, not retrying", nil)
return
}
if !retry {
retryLogger.ErrorIfNotCanceled("runWithContractConfig: function exited with non-retriable error. not retrying", ctx, commontypes.LogFields{
retryLogger.ErrorIfNotCanceled("runWithContractConfig: function exited with non-retryable error, not retrying", ctx, commontypes.LogFields{
"error": err,
})
return
}
retryLogger.ErrorIfNotCanceled("runWithContractConfig: function returned error. sleeping before retrying", ctx, commontypes.LogFields{
retryLogger.ErrorIfNotCanceled("runWithContractConfig: function returned error, sleeping before retrying", ctx, commontypes.LogFields{
"error": err,
"sleep": sleep.String(),
})

select {
case <-time.After(sleep):
case <-ctx.Done():
retryLogger.Info("runWithContractConfig: context expired while sleeping before retrying. not retrying", nil)
retryLogger.Info("runWithContractConfig: context expired while sleeping before retrying, not retrying", nil)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (repgen *reportGenerationState) messageObserveReq(msg MessageObserveReq, se
// thus ensures that at most RMax rounds are possible for the current leader.
if repgen.followerState.r > repgen.config.RMax {
repgen.logger.Debug(
"messageReportReq: leader sent MessageObserveReq past its expiration "+
"messageObserveReq: leader sent MessageObserveReq past its expiration "+
"round. Time to change leader",
commontypes.LogFields{
"round": repgen.followerState.r,
Expand Down Expand Up @@ -149,15 +149,15 @@ func (repgen *reportGenerationState) messageObserveReq(msg MessageObserveReq, se

so, err := MakeSignedObservation(repgen.followerReportTimestamp(), msg.Query, o, repgen.offchainKeyring.OffchainSign)
if err != nil {
repgen.logger.Error("messageObserveReq: could not make SignedObservation observation", commontypes.LogFields{
repgen.logger.Error("messageObserveReq: could not make SignedObservation", commontypes.LogFields{
"round": repgen.followerState.r,
"error": err,
})
return
}

if err := so.Verify(repgen.followerReportTimestamp(), msg.Query, repgen.offchainKeyring.OffchainPublicKey()); err != nil {
repgen.logger.Error("MakeSignedObservation produced invalid signature:", commontypes.LogFields{
repgen.logger.Error("MakeSignedObservation produced invalid signature", commontypes.LogFields{
"round": repgen.followerState.r,
"error": err,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func (t *transmissionState) eventTTransmitTimeout() {

}

t.logger.Info("eventTTransmitTimeout:❗️successfully called Transmit", commontypes.LogFields{
t.logger.Info("eventTTransmitTimeout: 🚀 successfully called Transmit", commontypes.LogFields{
"epoch": item.Epoch,
"round": item.Round,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func messageWrapperFromProtoMessage(wrapper *MessageWrapper) (protocol.Message,

func messageNewEpochFromProtoMessage(m *MessageNewEpoch) (protocol.MessageNewEpoch, error) {
if m == nil {
return protocol.MessageNewEpoch{}, fmt.Errorf("unable to extract a MessageNewEpoch value")
return protocol.MessageNewEpoch{}, fmt.Errorf("unable to extract MessageNewEpoch value")
}
return protocol.MessageNewEpoch{
uint32(m.Epoch),
Expand All @@ -270,7 +270,7 @@ func messageNewEpochFromProtoMessage(m *MessageNewEpoch) (protocol.MessageNewEpo

func messageObserveReqFromProtoMessage(m *MessageObserveReq) (protocol.MessageObserveReq, error) {
if m == nil {
return protocol.MessageObserveReq{}, fmt.Errorf("unable to extract a MessageObserveReq value")
return protocol.MessageObserveReq{}, fmt.Errorf("unable to extract MessageObserveReq value")
}
return protocol.MessageObserveReq{
uint32(m.Epoch),
Expand All @@ -281,7 +281,7 @@ func messageObserveReqFromProtoMessage(m *MessageObserveReq) (protocol.MessageOb

func messageObserveFromProtoMessage(m *MessageObserve) (protocol.MessageObserve, error) {
if m == nil {
return protocol.MessageObserve{}, fmt.Errorf("unable to extract a MessageObserve value")
return protocol.MessageObserve{}, fmt.Errorf("unable to extract MessageObserve value")
}
so, err := signedObservationFromProtoMessage(m.SignedObservation)
if err != nil {
Expand All @@ -296,7 +296,7 @@ func messageObserveFromProtoMessage(m *MessageObserve) (protocol.MessageObserve,

func messageReportReqFromProtoMessage(m *MessageReportReq) (protocol.MessageReportReq, error) {
if m == nil {
return protocol.MessageReportReq{}, fmt.Errorf("unable to extract a MessageReportReq value")
return protocol.MessageReportReq{}, fmt.Errorf("unable to extract MessageReportReq value")
}
asos, err := attributedSignedObservationsFromProtoMessage(m.AttributedSignedObservations)
if err != nil {
Expand All @@ -312,7 +312,7 @@ func messageReportReqFromProtoMessage(m *MessageReportReq) (protocol.MessageRepo

func attestedReportOneFromProtoMessage(m *AttestedReportOne) (protocol.AttestedReportOne, error) {
if m == nil {
return protocol.AttestedReportOne{}, fmt.Errorf("unable to extract a AttestedReportOne value")
return protocol.AttestedReportOne{}, fmt.Errorf("unable to extract AttestedReportOne value")
}

return protocol.AttestedReportOne{
Expand All @@ -324,7 +324,7 @@ func attestedReportOneFromProtoMessage(m *AttestedReportOne) (protocol.AttestedR

func messageReportFromProtoMessage(m *MessageReport) (protocol.MessageReport, error) {
if m == nil {
return protocol.MessageReport{}, fmt.Errorf("unable to extract a MessageReport value")
return protocol.MessageReport{}, fmt.Errorf("unable to extract MessageReport value")
}

report, err := attestedReportOneFromProtoMessage(m.AttestedReport)
Expand All @@ -341,13 +341,13 @@ func messageReportFromProtoMessage(m *MessageReport) (protocol.MessageReport, er

func attestedReportManyFromProtoMessage(m *AttestedReportMany) (protocol.AttestedReportMany, error) {
if m == nil {
return protocol.AttestedReportMany{}, fmt.Errorf("unable to extract a AttestedReportMany value")
return protocol.AttestedReportMany{}, fmt.Errorf("unable to extract AttestedReportMany value")
}

ass := make([]types.AttributedOnchainSignature, 0, len(m.AttributedSignatures))
for i, as := range m.AttributedSignatures {
if as == nil {
return protocol.AttestedReportMany{}, fmt.Errorf("unable to extract a AttestedReportMany value because AttributedSignatures[%v] is nil", i)
return protocol.AttestedReportMany{}, fmt.Errorf("unable to extract AttestedReportMany value because AttributedSignatures[%v] is nil", i)
}
ass = append(ass, types.AttributedOnchainSignature{
as.Signature,
Expand All @@ -363,7 +363,7 @@ func attestedReportManyFromProtoMessage(m *AttestedReportMany) (protocol.Atteste

func messageFinalFromProtoMessage(m *MessageFinal) (protocol.MessageFinal, error) {
if m == nil {
return protocol.MessageFinal{}, fmt.Errorf("unable to extract a MessageFinal value")
return protocol.MessageFinal{}, fmt.Errorf("unable to extract MessageFinal value")
}
report, err := attestedReportManyFromProtoMessage(m.AttestedReport)
if err != nil {
Expand All @@ -384,7 +384,7 @@ func messageFinalFromProtoMessage(m *MessageFinal) (protocol.MessageFinal, error

func messageFinalEchoFromProtoMessage(m *MessageFinalEcho) (protocol.MessageFinalEcho, error) {
if m == nil {
return protocol.MessageFinalEcho{}, fmt.Errorf("unable to extract a MessageFinalEcho value")
return protocol.MessageFinalEcho{}, fmt.Errorf("unable to extract MessageFinalEcho value")
}
final, err := messageFinalFromProtoMessage(m.Final)
if err != nil {
Expand All @@ -407,7 +407,7 @@ func attributedSignedObservationsFromProtoMessage(pbasos []*AttributedSignedObse

func attributedSignedObservationFromProtoMessage(m *AttributedSignedObservation) (protocol.AttributedSignedObservation, error) {
if m == nil {
return protocol.AttributedSignedObservation{}, fmt.Errorf("unable to extract an AttributedSignedObservation value")
return protocol.AttributedSignedObservation{}, fmt.Errorf("unable to extract AttributedSignedObservation value")
}

signedObservation, err := signedObservationFromProtoMessage(m.SignedObservation)
Expand All @@ -423,7 +423,7 @@ func attributedSignedObservationFromProtoMessage(m *AttributedSignedObservation)

func signedObservationFromProtoMessage(m *SignedObservation) (protocol.SignedObservation, error) {
if m == nil {
return protocol.SignedObservation{}, fmt.Errorf("unable to extract an SignedObservation value")
return protocol.SignedObservation{}, fmt.Errorf("unable to extract SignedObservation value")
}

return protocol.SignedObservation{
Expand Down
Loading
Loading