From d8efd5f44298621dfca694a0beefa2d6a5549577 Mon Sep 17 00:00:00 2001 From: kaleofduty <59616916+kaleofduty@users.noreply.github.com> Date: Tue, 24 Nov 2026 10:18:09 +0100 Subject: [PATCH] Improvements: - Fix race in Outcome Generation epoch initialization - Fix zero-value blob handle validation and propagate blob fetch errors correctly - Panic with a clear message on unexpected ReportingPluginInfo sum types - Documentation improvements - Typo and grammar fixes Based on f64fd6280dce4b8873a06dcc0ebe811a02a43691 Co-authored-by: kaleofduty <59616916+kaleofduty@users.noreply.github.com> Co-authored-by: Kostis Karantias Co-authored-by: stchrysa --- networking/peer_group.go | 7 +- .../reportingplugin/median/median.go | 54 +++++------ .../titlerequest/titlerequest.go | 36 ++++---- .../config/ocr2config/public_config.go | 4 +- .../config/ocr3_1config/public_config.go | 4 +- .../config/ocr3config/public_config.go | 4 +- .../internal/managed/managed_ocr3_1_oracle.go | 9 ++ .../managed/run_with_contract_config.go | 8 +- .../protocol/report_generation_follower.go | 6 +- .../internal/ocr2/protocol/transmission.go | 2 +- .../ocr2/serialization/serialization.go | 24 ++--- .../ocr3/protocol/outcome_generation.go | 18 ++-- .../ocr3/serialization/serialization.go | 38 ++++---- .../internal/ocr3_1/protocol/blob_endpoint.go | 92 ++++++++++--------- .../internal/ocr3_1/protocol/blob_exchange.go | 2 +- .../ocr3_1/protocol/outcome_generation.go | 22 +++-- .../ocr3_1/serialization/serialization.go | 78 ++++++++-------- offchainreporting2plus/ocr3_1types/blob.go | 3 + 18 files changed, 222 insertions(+), 189 deletions(-) diff --git a/networking/peer_group.go b/networking/peer_group.go index 1ed05bac..bf78fa49 100644 --- a/networking/peer_group.go +++ b/networking/peer_group.go @@ -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() } @@ -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)) } } diff --git a/offchainreporting2/reportingplugin/median/median.go b/offchainreporting2/reportingplugin/median/median.go index 43abf94f..473f00a6 100644 --- a/offchainreporting2/reportingplugin/median/median.go +++ b/offchainreporting2/reportingplugin/median/median.go @@ -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) { diff --git a/offchainreporting2/reportingplugin/titlerequest/titlerequest.go b/offchainreporting2/reportingplugin/titlerequest/titlerequest.go index 967285a4..d85799fe 100644 --- a/offchainreporting2/reportingplugin/titlerequest/titlerequest.go +++ b/offchainreporting2/reportingplugin/titlerequest/titlerequest.go @@ -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) diff --git a/offchainreporting2plus/internal/config/ocr2config/public_config.go b/offchainreporting2plus/internal/config/ocr2config/public_config.go index 4bb5aa74..a2b07e4f 100644 --- a/offchainreporting2plus/internal/config/ocr2config/public_config.go +++ b/offchainreporting2plus/internal/config/ocr2config/public_config.go @@ -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 } @@ -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) diff --git a/offchainreporting2plus/internal/config/ocr3_1config/public_config.go b/offchainreporting2plus/internal/config/ocr3_1config/public_config.go index b4473711..2c0740d5 100644 --- a/offchainreporting2plus/internal/config/ocr3_1config/public_config.go +++ b/offchainreporting2plus/internal/config/ocr3_1config/public_config.go @@ -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 } @@ -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) diff --git a/offchainreporting2plus/internal/config/ocr3config/public_config.go b/offchainreporting2plus/internal/config/ocr3config/public_config.go index 15ddc0d1..20707390 100644 --- a/offchainreporting2plus/internal/config/ocr3config/public_config.go +++ b/offchainreporting2plus/internal/config/ocr3config/public_config.go @@ -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 } @@ -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) diff --git a/offchainreporting2plus/internal/managed/managed_ocr3_1_oracle.go b/offchainreporting2plus/internal/managed/managed_ocr3_1_oracle.go index 8a0591a0..b18eed2d 100644 --- a/offchainreporting2plus/internal/managed/managed_ocr3_1_oracle.go +++ b/offchainreporting2plus/internal/managed/managed_ocr3_1_oracle.go @@ -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 { diff --git a/offchainreporting2plus/internal/managed/run_with_contract_config.go b/offchainreporting2plus/internal/managed/run_with_contract_config.go index 6f1a1e0b..855315fe 100644 --- a/offchainreporting2plus/internal/managed/run_with_contract_config.go +++ b/offchainreporting2plus/internal/managed/run_with_contract_config.go @@ -182,16 +182,16 @@ 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(), }) @@ -199,7 +199,7 @@ func retryOnError(ctx context.Context, logger loghelper.LoggerWithContext, retry 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 } diff --git a/offchainreporting2plus/internal/ocr2/protocol/report_generation_follower.go b/offchainreporting2plus/internal/ocr2/protocol/report_generation_follower.go index 6b3c0b86..969412a3 100644 --- a/offchainreporting2plus/internal/ocr2/protocol/report_generation_follower.go +++ b/offchainreporting2plus/internal/ocr2/protocol/report_generation_follower.go @@ -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, @@ -149,7 +149,7 @@ 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, }) @@ -157,7 +157,7 @@ func (repgen *reportGenerationState) messageObserveReq(msg MessageObserveReq, se } 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, }) diff --git a/offchainreporting2plus/internal/ocr2/protocol/transmission.go b/offchainreporting2plus/internal/ocr2/protocol/transmission.go index 6a0eb43d..70b9f8db 100644 --- a/offchainreporting2plus/internal/ocr2/protocol/transmission.go +++ b/offchainreporting2plus/internal/ocr2/protocol/transmission.go @@ -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, }) diff --git a/offchainreporting2plus/internal/ocr2/serialization/serialization.go b/offchainreporting2plus/internal/ocr2/serialization/serialization.go index 16999bc6..d0771c56 100644 --- a/offchainreporting2plus/internal/ocr2/serialization/serialization.go +++ b/offchainreporting2plus/internal/ocr2/serialization/serialization.go @@ -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), @@ -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), @@ -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 { @@ -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 { @@ -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{ @@ -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) @@ -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, @@ -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 { @@ -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 { @@ -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) @@ -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{ diff --git a/offchainreporting2plus/internal/ocr3/protocol/outcome_generation.go b/offchainreporting2plus/internal/ocr3/protocol/outcome_generation.go index 69c0f02d..85bd8d18 100644 --- a/offchainreporting2plus/internal/ocr3/protocol/outcome_generation.go +++ b/offchainreporting2plus/internal/ocr3/protocol/outcome_generation.go @@ -167,20 +167,21 @@ func (outgen *outcomeGenerationState[RI]) run(restoredCert CertifiedPrepareOrCom false, nil, nil, - nil, + + pool.NewPool[SignedObservation](0), nil, } outgen.followerState = followerState[RI]{ outgenFollowerPhaseUnknown, nil, + pool.NewPool[MessageRoundStart[RI]](0), nil, - nil, - nil, + pool.NewPool[MessageProposal[RI]](0), outcomeAndDigests{}, restoredCert, - nil, - nil, + pool.NewPool[PrepareSignature](0), + pool.NewPool[CommitSignature](0), } outgen.sharedState = sharedState{ @@ -233,7 +234,12 @@ func (outgen *outcomeGenerationState[RI]) run(restoredCert CertifiedPrepareOrCom func (outgen *outcomeGenerationState[RI]) messageToOutcomeGeneration(msg MessageToOutcomeGenerationWithSender[RI]) { msgEpoch := msg.msg.epoch() - if msgEpoch < outgen.sharedState.e { + if msgEpoch == 0 { + + outgen.logger.Warn("dropping message for epoch 0", commontypes.LogFields{ + "sender": msg.sender, + }) + } else if msgEpoch < outgen.sharedState.e { // drop outgen.logger.Debug("dropping message for past epoch", commontypes.LogFields{ "epoch": outgen.sharedState.e, diff --git a/offchainreporting2plus/internal/ocr3/serialization/serialization.go b/offchainreporting2plus/internal/ocr3/serialization/serialization.go index 31400e7e..559b3eb2 100644 --- a/offchainreporting2plus/internal/ocr3/serialization/serialization.go +++ b/offchainreporting2plus/internal/ocr3/serialization/serialization.go @@ -472,7 +472,7 @@ func (fpm *fromProtoMessage[RI]) messageWrapper(wrapper *MessageWrapper) (protoc func (fpm *fromProtoMessage[RI]) messageNewEpochWish(m *MessageNewEpochWish) (protocol.MessageNewEpochWish[RI], error) { if m == nil { - return protocol.MessageNewEpochWish[RI]{}, fmt.Errorf("unable to extract a MessageNewEpochWish value") + return protocol.MessageNewEpochWish[RI]{}, fmt.Errorf("unable to extract MessageNewEpochWish value") } return protocol.MessageNewEpochWish[RI]{ m.Epoch, @@ -481,7 +481,7 @@ func (fpm *fromProtoMessage[RI]) messageNewEpochWish(m *MessageNewEpochWish) (pr func (fpm *fromProtoMessage[RI]) messageEpochStartRequest(m *MessageEpochStartRequest) (protocol.MessageEpochStartRequest[RI], error) { if m == nil { - return protocol.MessageEpochStartRequest[RI]{}, fmt.Errorf("unable to extract a MessageEpochStartRequest value") + return protocol.MessageEpochStartRequest[RI]{}, fmt.Errorf("unable to extract MessageEpochStartRequest value") } hc, err := fpm.certifiedPrepareOrCommit(m.HighestCertified) if err != nil { @@ -500,7 +500,7 @@ func (fpm *fromProtoMessage[RI]) messageEpochStartRequest(m *MessageEpochStartRe func (fpm *fromProtoMessage[RI]) messageEpochStart(m *MessageEpochStart) (protocol.MessageEpochStart[RI], error) { if m == nil { - return protocol.MessageEpochStart[RI]{}, fmt.Errorf("unable to extract a MessageEpochStart value") + return protocol.MessageEpochStart[RI]{}, fmt.Errorf("unable to extract MessageEpochStart value") } srqc, err := fpm.epochStartProof(m.EpochStartProof) if err != nil { @@ -515,7 +515,7 @@ func (fpm *fromProtoMessage[RI]) messageEpochStart(m *MessageEpochStart) (protoc func (fpm *fromProtoMessage[RI]) messageProposal(m *MessageProposal) (protocol.MessageProposal[RI], error) { if m == nil { - return protocol.MessageProposal[RI]{}, fmt.Errorf("unable to extract a MessageProposal value") + return protocol.MessageProposal[RI]{}, fmt.Errorf("unable to extract MessageProposal value") } asos, err := fpm.attributedSignedObservations(m.AttributedSignedObservations) if err != nil { @@ -531,7 +531,7 @@ func (fpm *fromProtoMessage[RI]) messageProposal(m *MessageProposal) (protocol.M func (fpm *fromProtoMessage[RI]) messagePrepare(m *MessagePrepare) (protocol.MessagePrepare[RI], error) { if m == nil { - return protocol.MessagePrepare[RI]{}, fmt.Errorf("unable to extract a MessagePrepare value") + return protocol.MessagePrepare[RI]{}, fmt.Errorf("unable to extract MessagePrepare value") } return protocol.MessagePrepare[RI]{ m.Epoch, @@ -542,7 +542,7 @@ func (fpm *fromProtoMessage[RI]) messagePrepare(m *MessagePrepare) (protocol.Mes func (fpm *fromProtoMessage[RI]) messageCommit(m *MessageCommit) (protocol.MessageCommit[RI], error) { if m == nil { - return protocol.MessageCommit[RI]{}, fmt.Errorf("unable to extract a MessageCommit value") + return protocol.MessageCommit[RI]{}, fmt.Errorf("unable to extract MessageCommit value") } return protocol.MessageCommit[RI]{ m.Epoch, @@ -553,7 +553,7 @@ func (fpm *fromProtoMessage[RI]) messageCommit(m *MessageCommit) (protocol.Messa func (fpm *fromProtoMessage[RI]) certifiedPrepareOrCommit(m *CertifiedPrepareOrCommit) (protocol.CertifiedPrepareOrCommit, error) { if m == nil { - return nil, fmt.Errorf("unable to extract a CertifiedPrepareOrCommit value") + return nil, fmt.Errorf("unable to extract CertifiedPrepareOrCommit value") } switch poc := m.PrepareOrCommit.(type) { case *CertifiedPrepareOrCommit_Prepare: @@ -575,7 +575,7 @@ func (fpm *fromProtoMessage[RI]) certifiedPrepareOrCommit(m *CertifiedPrepareOrC func (fpm *fromProtoMessage[RI]) certifiedPrepare(m *CertifiedPrepare) (protocol.CertifiedPrepare, error) { if m == nil { - return protocol.CertifiedPrepare{}, fmt.Errorf("unable to extract a CertifiedPrepare value") + return protocol.CertifiedPrepare{}, fmt.Errorf("unable to extract CertifiedPrepare value") } var outcomeInputsDigest protocol.OutcomeInputsDigest copy(outcomeInputsDigest[:], m.OutcomeInputsDigest) @@ -602,7 +602,7 @@ func (fpm *fromProtoMessage[RI]) certifiedPrepare(m *CertifiedPrepare) (protocol func (fpm *fromProtoMessage[RI]) certifiedCommit(m *CertifiedCommit) (protocol.CertifiedCommit, error) { if m == nil { - return protocol.CertifiedCommit{}, fmt.Errorf("unable to extract a CertifiedCommit value") + return protocol.CertifiedCommit{}, fmt.Errorf("unable to extract CertifiedCommit value") } commitQuorumCertificate := make([]protocol.AttributedCommitSignature, 0, len(m.CommitQuorumCertificate)) for _, aps := range m.CommitQuorumCertificate { @@ -625,7 +625,7 @@ func (fpm *fromProtoMessage[RI]) certifiedCommit(m *CertifiedCommit) (protocol.C func (fpm *fromProtoMessage[RI]) signedHighestCertifiedTimestamp(m *SignedHighestCertifiedTimestamp) (protocol.SignedHighestCertifiedTimestamp, error) { if m == nil { - return protocol.SignedHighestCertifiedTimestamp{}, fmt.Errorf("unable to extract a SignedHighestCertifiedTimestamp value") + return protocol.SignedHighestCertifiedTimestamp{}, fmt.Errorf("unable to extract SignedHighestCertifiedTimestamp value") } hct, err := fpm.highestCertifiedTimestamp(m.HighestCertifiedTimestamp) if err != nil { @@ -640,7 +640,7 @@ func (fpm *fromProtoMessage[RI]) signedHighestCertifiedTimestamp(m *SignedHighes func (fpm *fromProtoMessage[RI]) highestCertifiedTimestamp(m *HighestCertifiedTimestamp) (protocol.HighestCertifiedTimestamp, error) { if m == nil { - return protocol.HighestCertifiedTimestamp{}, fmt.Errorf("unable to extract a HighestCertifiedTimestamp value") + return protocol.HighestCertifiedTimestamp{}, fmt.Errorf("unable to extract HighestCertifiedTimestamp value") } return protocol.HighestCertifiedTimestamp{ m.SeqNr, @@ -651,7 +651,7 @@ func (fpm *fromProtoMessage[RI]) highestCertifiedTimestamp(m *HighestCertifiedTi func (fpm *fromProtoMessage[RI]) epochStartProof(m *EpochStartProof) (protocol.EpochStartProof, error) { if m == nil { - return protocol.EpochStartProof{}, fmt.Errorf("unable to extract a EpochStartProof value") + return protocol.EpochStartProof{}, fmt.Errorf("unable to extract EpochStartProof value") } hc, err := fpm.certifiedPrepareOrCommit(m.HighestCertified) if err != nil { @@ -685,7 +685,7 @@ func (fpm *fromProtoMessage[RI]) epochStartProof(m *EpochStartProof) (protocol.E func (fpm *fromProtoMessage[RI]) messageRoundStart(m *MessageRoundStart) (protocol.MessageRoundStart[RI], error) { if m == nil { - return protocol.MessageRoundStart[RI]{}, fmt.Errorf("unable to extract a MessageRoundStart value") + return protocol.MessageRoundStart[RI]{}, fmt.Errorf("unable to extract MessageRoundStart value") } return protocol.MessageRoundStart[RI]{ m.Epoch, @@ -697,7 +697,7 @@ func (fpm *fromProtoMessage[RI]) messageRoundStart(m *MessageRoundStart) (protoc func (fpm *fromProtoMessage[RI]) messageObservation(m *MessageObservation) (protocol.MessageObservation[RI], error) { if m == nil { - return protocol.MessageObservation[RI]{}, fmt.Errorf("unable to extract a MessageObservation value") + return protocol.MessageObservation[RI]{}, fmt.Errorf("unable to extract MessageObservation value") } so, err := fpm.signedObservation(m.SignedObservation) if err != nil { @@ -712,7 +712,7 @@ func (fpm *fromProtoMessage[RI]) messageObservation(m *MessageObservation) (prot func (fpm *fromProtoMessage[RI]) messageReportSignatures(m *MessageReportSignatures) (protocol.MessageReportSignatures[RI], error) { if m == nil { - return protocol.MessageReportSignatures[RI]{}, fmt.Errorf("unable to extract a MessageReportSignatures value") + return protocol.MessageReportSignatures[RI]{}, fmt.Errorf("unable to extract MessageReportSignatures value") } return protocol.MessageReportSignatures[RI]{ m.SeqNr, @@ -722,7 +722,7 @@ func (fpm *fromProtoMessage[RI]) messageReportSignatures(m *MessageReportSignatu func (fpm *fromProtoMessage[RI]) messageCertifiedCommitRequest(m *MessageCertifiedCommitRequest) (protocol.MessageCertifiedCommitRequest[RI], error) { if m == nil { - return protocol.MessageCertifiedCommitRequest[RI]{}, fmt.Errorf("unable to extract a MessageCertifiedCommitRequest value") + return protocol.MessageCertifiedCommitRequest[RI]{}, fmt.Errorf("unable to extract MessageCertifiedCommitRequest value") } return protocol.MessageCertifiedCommitRequest[RI]{ m.SeqNr, @@ -731,7 +731,7 @@ func (fpm *fromProtoMessage[RI]) messageCertifiedCommitRequest(m *MessageCertifi func (fpm *fromProtoMessage[RI]) messageCertifiedCommit(m *MessageCertifiedCommit) (protocol.MessageCertifiedCommit[RI], error) { if m == nil { - return protocol.MessageCertifiedCommit[RI]{}, fmt.Errorf("unable to extract a MessageCertifiedCommit value") + return protocol.MessageCertifiedCommit[RI]{}, fmt.Errorf("unable to extract MessageCertifiedCommit value") } cpocc, err := fpm.certifiedCommit(m.CertifiedCommit) if err != nil { @@ -756,7 +756,7 @@ func (fpm *fromProtoMessage[RI]) attributedSignedObservations(pbasos []*Attribut func (fpm *fromProtoMessage[RI]) attributedSignedObservation(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 := fpm.signedObservation(m.SignedObservation) @@ -777,7 +777,7 @@ func (fpm *fromProtoMessage[RI]) attributedSignedObservation(m *AttributedSigned func (fpm *fromProtoMessage[RI]) signedObservation(m *SignedObservation) (protocol.SignedObservation, error) { if m == nil { - return protocol.SignedObservation{}, fmt.Errorf("unable to extract a SignedObservation value") + return protocol.SignedObservation{}, fmt.Errorf("unable to extract SignedObservation value") } return protocol.SignedObservation{ diff --git a/offchainreporting2plus/internal/ocr3_1/protocol/blob_endpoint.go b/offchainreporting2plus/internal/ocr3_1/protocol/blob_endpoint.go index cc1d7c94..fdd91377 100644 --- a/offchainreporting2plus/internal/ocr3_1/protocol/blob_endpoint.go +++ b/offchainreporting2plus/internal/ocr3_1/protocol/blob_endpoint.go @@ -62,7 +62,24 @@ type BlobEndpoint struct { chBlobFetchRequest chan<- blobFetchRequest } -var errBlobEndpointUnavailable = fmt.Errorf("blob endpoint unavailable") +var ( + errBlobEndpointUnavailable = fmt.Errorf("blob endpoint unavailable") + errZeroValueBlobHandle = fmt.Errorf("zero value blob handle provided") + errBlobExpired = fmt.Errorf("blob expired") +) + +func lightCertifiedBlobFromHandle(handle ocr3_1types.BlobHandle) (*LightCertifiedBlob, error) { + switch cert := blobtypes.ExtractBlobHandleSumType(handle).(type) { + case nil: + case *LightCertifiedBlob: + if cert != nil { + return cert, nil + } + default: + panic(fmt.Sprintf("unexpected blob handle type %T", cert)) + } + return nil, errZeroValueBlobHandle +} func expirySeqNr(expirationHint ocr3_1types.BlobExpirationHint) uint64 { switch beh := expirationHint.(type) { @@ -111,6 +128,11 @@ func (be *BlobEndpoint) BroadcastBlob(ctx context.Context, payload []byte, expir var _ ocr3_1types.BlobBroadcaster = &BlobEndpoint{} func (be *BlobEndpoint) FetchBlob(ctx context.Context, handle ocr3_1types.BlobHandle) ([]byte, error) { + cert, err := lightCertifiedBlobFromHandle(handle) + if err != nil { + return nil, err + } + chRequestDone := ctx.Done() chEndpointDone := be.ctx.Done() @@ -118,43 +140,29 @@ func (be *BlobEndpoint) FetchBlob(ctx context.Context, handle ocr3_1types.BlobHa chDone := make(chan struct{}) defer close(chDone) - blobHandleSumType := blobtypes.ExtractBlobHandleSumType(handle) - if blobHandleSumType == nil { - return nil, fmt.Errorf("zero value blob handle provided") + request := blobFetchRequest{ + *cert, + chResponse, + chDone, } - switch handle := blobHandleSumType.(type) { - case *LightCertifiedBlob: - if handle == nil { - return nil, fmt.Errorf("zero value blob handle provided") - } - - request := blobFetchRequest{ - *handle, - chResponse, - chDone, - } - + select { + case be.chBlobFetchRequest <- request: select { - case be.chBlobFetchRequest <- request: - select { - case response := <-chResponse: - if response.err != nil { - return nil, response.err - } - return response.payload, nil - case <-chEndpointDone: - return nil, be.ctx.Err() - case <-chRequestDone: - return nil, ctx.Err() + case response := <-chResponse: + if response.err != nil { + return nil, response.err } + return response.payload, nil case <-chEndpointDone: return nil, be.ctx.Err() case <-chRequestDone: return nil, ctx.Err() } - default: - panic(fmt.Sprintf("unexpected blob handle type %T", handle)) + case <-chEndpointDone: + return nil, be.ctx.Err() + case <-chRequestDone: + return nil, ctx.Err() } } @@ -179,19 +187,17 @@ func (r *RoundBlobBroadcastFetcher) BroadcastBlob(ctx context.Context, payload [ } func (r *RoundBlobBroadcastFetcher) FetchBlob(ctx context.Context, handle ocr3_1types.BlobHandle) ([]byte, error) { - blobHandleSumType := blobtypes.ExtractBlobHandleSumType(handle) - switch cert := blobHandleSumType.(type) { - case *blobtypes.LightCertifiedBlob: - // This expiry comparison differs with blobExchangeState.hasBlobExpired - // (< here vs <= there) because the latter checks against an - // already-committed sequence number, while here we check against the - // sequence number that we might commit at the end of the round, but - // which we have not already committed. - if cert != nil && cert.ExpirySeqNr < r.seqNr { - return nil, fmt.Errorf("blob expired") - } - return r.blobBroadcastFetcher.FetchBlob(ctx, handle) - default: - panic(fmt.Sprintf("unexpected blob handle type %T", handle)) + cert, err := lightCertifiedBlobFromHandle(handle) + if err != nil { + return nil, err + } + // This expiry comparison differs with blobExchangeState.hasBlobExpired + // (< here vs <= there) because the latter checks against an + // already-committed sequence number, while here we check against the + // sequence number that we might commit at the end of the round, but + // which we have not already committed. + if cert.ExpirySeqNr < r.seqNr { + return nil, errBlobExpired } + return r.blobBroadcastFetcher.FetchBlob(ctx, handle) } diff --git a/offchainreporting2plus/internal/ocr3_1/protocol/blob_exchange.go b/offchainreporting2plus/internal/ocr3_1/protocol/blob_exchange.go index 9fc33216..b8cab1e7 100644 --- a/offchainreporting2plus/internal/ocr3_1/protocol/blob_exchange.go +++ b/offchainreporting2plus/internal/ocr3_1/protocol/blob_exchange.go @@ -1711,7 +1711,7 @@ func (bex *blobExchangeState[RI]) processBlobFetchRequest(req blobFetchRequest) } if bex.hasBlobExpired(cert.ExpirySeqNr) { - req.respond(bex.ctx, blobFetchResponse{nil, fmt.Errorf("blob expired")}) + req.respond(bex.ctx, blobFetchResponse{nil, errBlobExpired}) return } diff --git a/offchainreporting2plus/internal/ocr3_1/protocol/outcome_generation.go b/offchainreporting2plus/internal/ocr3_1/protocol/outcome_generation.go index 230db35c..05abf7f7 100644 --- a/offchainreporting2plus/internal/ocr3_1/protocol/outcome_generation.go +++ b/offchainreporting2plus/internal/ocr3_1/protocol/outcome_generation.go @@ -233,7 +233,8 @@ func (outgen *outcomeGenerationState[RI]) run(restoredCert CertifiedPrepareOrCom false, nil, nil, - nil, + + pool.NewPool[SignedObservation](0), nil, } @@ -241,14 +242,14 @@ func (outgen *outcomeGenerationState[RI]) run(restoredCert CertifiedPrepareOrCom outgenFollowerPhaseUnknown, nil, false, + pool.NewPool[MessageRoundStart[RI]](0), nil, - nil, - nil, + pool.NewPool[MessageProposal[RI]](0), stateTransitionInfoDigests{}, nil, restoredCert, - nil, - nil, + pool.NewPool[PrepareSignature](0), + pool.NewPool[CommitSignature](0), } outgen.sharedState = sharedState{ @@ -312,7 +313,12 @@ func (outgen *outcomeGenerationState[RI]) run(restoredCert CertifiedPrepareOrCom func (outgen *outcomeGenerationState[RI]) messageToOutcomeGeneration(msg MessageToOutcomeGenerationWithSender[RI]) { msgEpoch := msg.msg.epoch() - if msgEpoch < outgen.sharedState.e { + if msgEpoch == 0 { + + outgen.logger.Warn("dropping message for epoch 0", commontypes.LogFields{ + "sender": msg.sender, + }) + } else if msgEpoch < outgen.sharedState.e { // drop outgen.logger.Debug("dropping message for past epoch", commontypes.LogFields{ "epoch": outgen.sharedState.e, @@ -519,7 +525,7 @@ func (outgen *outcomeGenerationState[RI]) tryToMoveCertAndKVStateToCommitQC(comm return } if committedKVSeqNr+1 != commitQC.CommitSeqNr { - outgen.logger.Debug("commit qc seq nr quite ahead from committed kv seq nr, can't do anything", commontypes.LogFields{ + outgen.logger.Debug("commit qc seq nr too far ahead of committed kv seq nr, can't do anything", commontypes.LogFields{ "committedKVSeqNr": committedKVSeqNr, "commitQCSeqNr": commitQC.CommitSeqNr, }) @@ -554,7 +560,7 @@ func (outgen *outcomeGenerationState[RI]) tryToMoveCertAndKVStateToCommitQC(comm } if commitQC.CommitSeqNr != committedKVSeqNr+1 { - outgen.logger.Debug("commit qc seq nr quite ahead from committed kv seq nr, can't do anything", commontypes.LogFields{ + outgen.logger.Debug("commit qc seq nr too far ahead of committed kv seq nr, can't do anything", commontypes.LogFields{ "committedKVSeqNr": committedKVSeqNr, "commitQCSeqNr": commitQC.CommitSeqNr, }) diff --git a/offchainreporting2plus/internal/ocr3_1/serialization/serialization.go b/offchainreporting2plus/internal/ocr3_1/serialization/serialization.go index bc1531a4..4667d960 100644 --- a/offchainreporting2plus/internal/ocr3_1/serialization/serialization.go +++ b/offchainreporting2plus/internal/ocr3_1/serialization/serialization.go @@ -980,7 +980,7 @@ func (fpm *fromProtoMessage[RI]) messageWrapper(wrapper *MessageWrapper) (protoc func (fpm *fromProtoMessage[RI]) messageNewEpochWish(m *MessageNewEpochWish) (protocol.MessageNewEpochWish[RI], error) { if m == nil { - return protocol.MessageNewEpochWish[RI]{}, fmt.Errorf("unable to extract a MessageNewEpochWish value") + return protocol.MessageNewEpochWish[RI]{}, fmt.Errorf("unable to extract MessageNewEpochWish value") } return protocol.MessageNewEpochWish[RI]{ m.Epoch, @@ -989,7 +989,7 @@ func (fpm *fromProtoMessage[RI]) messageNewEpochWish(m *MessageNewEpochWish) (pr func (fpm *fromProtoMessage[RI]) messageEpochStartRequest(m *MessageEpochStartRequest) (protocol.MessageEpochStartRequest[RI], error) { if m == nil { - return protocol.MessageEpochStartRequest[RI]{}, fmt.Errorf("unable to extract a MessageEpochStartRequest value") + return protocol.MessageEpochStartRequest[RI]{}, fmt.Errorf("unable to extract MessageEpochStartRequest value") } hc, err := fpm.certifiedPrepareOrCommit(m.HighestCertified) if err != nil { @@ -1008,7 +1008,7 @@ func (fpm *fromProtoMessage[RI]) messageEpochStartRequest(m *MessageEpochStartRe func (fpm *fromProtoMessage[RI]) messageEpochStart(m *MessageEpochStart) (protocol.MessageEpochStart[RI], error) { if m == nil { - return protocol.MessageEpochStart[RI]{}, fmt.Errorf("unable to extract a MessageEpochStart value") + return protocol.MessageEpochStart[RI]{}, fmt.Errorf("unable to extract MessageEpochStart value") } srqc, err := fpm.epochStartProof(m.EpochStartProof) if err != nil { @@ -1023,7 +1023,7 @@ func (fpm *fromProtoMessage[RI]) messageEpochStart(m *MessageEpochStart) (protoc func (fpm *fromProtoMessage[RI]) messageProposal(m *MessageProposal) (protocol.MessageProposal[RI], error) { if m == nil { - return protocol.MessageProposal[RI]{}, fmt.Errorf("unable to extract a MessageProposal value") + return protocol.MessageProposal[RI]{}, fmt.Errorf("unable to extract MessageProposal value") } asos, err := fpm.attributedSignedObservations(m.AttributedSignedObservations) if err != nil { @@ -1038,7 +1038,7 @@ func (fpm *fromProtoMessage[RI]) messageProposal(m *MessageProposal) (protocol.M func (fpm *fromProtoMessage[RI]) messagePrepare(m *MessagePrepare) (protocol.MessagePrepare[RI], error) { if m == nil { - return protocol.MessagePrepare[RI]{}, fmt.Errorf("unable to extract a MessagePrepare value") + return protocol.MessagePrepare[RI]{}, fmt.Errorf("unable to extract MessagePrepare value") } return protocol.MessagePrepare[RI]{ m.Epoch, @@ -1049,7 +1049,7 @@ func (fpm *fromProtoMessage[RI]) messagePrepare(m *MessagePrepare) (protocol.Mes func (fpm *fromProtoMessage[RI]) messageCommit(m *MessageCommit) (protocol.MessageCommit[RI], error) { if m == nil { - return protocol.MessageCommit[RI]{}, fmt.Errorf("unable to extract a MessageCommit value") + return protocol.MessageCommit[RI]{}, fmt.Errorf("unable to extract MessageCommit value") } return protocol.MessageCommit[RI]{ m.Epoch, @@ -1060,7 +1060,7 @@ func (fpm *fromProtoMessage[RI]) messageCommit(m *MessageCommit) (protocol.Messa func (fpm *fromProtoMessage[RI]) certifiedPrepareOrCommit(m *CertifiedPrepareOrCommit) (protocol.CertifiedPrepareOrCommit, error) { if m == nil { - return nil, fmt.Errorf("unable to extract a CertifiedPrepareOrCommit value") + return nil, fmt.Errorf("unable to extract CertifiedPrepareOrCommit value") } switch poc := m.PrepareOrCommit.(type) { case *CertifiedPrepareOrCommit_Prepare: @@ -1090,7 +1090,7 @@ func (fpm *fromProtoMessage[RI]) certifiedPrepareOrCommit(m *CertifiedPrepareOrC func (fpm *fromProtoMessage[RI]) genesisFromPrevInstance(m *GenesisFromPrevInstance) (protocol.GenesisFromPrevInstance, error) { if m == nil { - return protocol.GenesisFromPrevInstance{}, fmt.Errorf("unable to extract a GenesisFromPrevInstance value") + return protocol.GenesisFromPrevInstance{}, fmt.Errorf("unable to extract GenesisFromPrevInstance value") } var prevHistoryDigest protocol.HistoryDigest copy(prevHistoryDigest[:], m.PrevHistoryDigest) @@ -1102,7 +1102,7 @@ func (fpm *fromProtoMessage[RI]) genesisFromPrevInstance(m *GenesisFromPrevInsta func (fpm *fromProtoMessage[RI]) certifiedPrepare(m *CertifiedPrepare) (protocol.CertifiedPrepare, error) { if m == nil { - return protocol.CertifiedPrepare{}, fmt.Errorf("unable to extract a CertifiedPrepare value") + return protocol.CertifiedPrepare{}, fmt.Errorf("unable to extract CertifiedPrepare value") } var prevHistoryDigest protocol.HistoryDigest copy(prevHistoryDigest[:], m.PrevHistoryDigest) @@ -1141,7 +1141,7 @@ func (fpm *fromProtoMessage[RI]) certifiedPrepare(m *CertifiedPrepare) (protocol func (fpm *fromProtoMessage[RI]) certifiedCommit(m *CertifiedCommit) (protocol.CertifiedCommit, error) { if m == nil { - return protocol.CertifiedCommit{}, fmt.Errorf("unable to extract a CertifiedCommit value") + return protocol.CertifiedCommit{}, fmt.Errorf("unable to extract CertifiedCommit value") } var prevHistoryDigest protocol.HistoryDigest copy(prevHistoryDigest[:], m.PrevHistoryDigest) @@ -1179,7 +1179,7 @@ func (fpm *fromProtoMessage[RI]) certifiedCommit(m *CertifiedCommit) (protocol.C func (fpm *fromProtoMessage[RI]) signedHighestCertifiedTimestamp(m *SignedHighestCertifiedTimestamp) (protocol.SignedHighestCertifiedTimestamp, error) { if m == nil { - return protocol.SignedHighestCertifiedTimestamp{}, fmt.Errorf("unable to extract a SignedHighestCertifiedTimestamp value") + return protocol.SignedHighestCertifiedTimestamp{}, fmt.Errorf("unable to extract SignedHighestCertifiedTimestamp value") } hct, err := fpm.highestCertifiedTimestamp(m.HighestCertifiedTimestamp) if err != nil { @@ -1193,7 +1193,7 @@ func (fpm *fromProtoMessage[RI]) signedHighestCertifiedTimestamp(m *SignedHighes func (fpm *fromProtoMessage[RI]) highestCertifiedTimestamp(m *HighestCertifiedTimestamp) (protocol.HighestCertifiedTimestamp, error) { if m == nil { - return protocol.HighestCertifiedTimestamp{}, fmt.Errorf("unable to extract a HighestCertifiedTimestamp value") + return protocol.HighestCertifiedTimestamp{}, fmt.Errorf("unable to extract HighestCertifiedTimestamp value") } return protocol.HighestCertifiedTimestamp{ m.SeqNr, @@ -1204,7 +1204,7 @@ func (fpm *fromProtoMessage[RI]) highestCertifiedTimestamp(m *HighestCertifiedTi func (fpm *fromProtoMessage[RI]) epochStartProof(m *EpochStartProof) (protocol.EpochStartProof, error) { if m == nil { - return protocol.EpochStartProof{}, fmt.Errorf("unable to extract a EpochStartProof value") + return protocol.EpochStartProof{}, fmt.Errorf("unable to extract EpochStartProof value") } hc, err := fpm.certifiedPrepareOrCommit(m.HighestCertified) if err != nil { @@ -1237,7 +1237,7 @@ func (fpm *fromProtoMessage[RI]) epochStartProof(m *EpochStartProof) (protocol.E func (fpm *fromProtoMessage[RI]) messageRoundStart(m *MessageRoundStart) (protocol.MessageRoundStart[RI], error) { if m == nil { - return protocol.MessageRoundStart[RI]{}, fmt.Errorf("unable to extract a MessageRoundStart value") + return protocol.MessageRoundStart[RI]{}, fmt.Errorf("unable to extract MessageRoundStart value") } return protocol.MessageRoundStart[RI]{ fpm.requestHandle, @@ -1249,7 +1249,7 @@ func (fpm *fromProtoMessage[RI]) messageRoundStart(m *MessageRoundStart) (protoc func (fpm *fromProtoMessage[RI]) messageObservation(m *MessageObservation) (protocol.MessageObservation[RI], error) { if m == nil { - return protocol.MessageObservation[RI]{}, fmt.Errorf("unable to extract a MessageObservation value") + return protocol.MessageObservation[RI]{}, fmt.Errorf("unable to extract MessageObservation value") } so, err := fpm.signedObservation(m.SignedObservation) if err != nil { @@ -1265,7 +1265,7 @@ func (fpm *fromProtoMessage[RI]) messageObservation(m *MessageObservation) (prot func (fpm *fromProtoMessage[RI]) messageReportSignatures(m *MessageReportSignatures) (protocol.MessageReportSignatures[RI], error) { if m == nil { - return protocol.MessageReportSignatures[RI]{}, fmt.Errorf("unable to extract a MessageReportSignatures value") + return protocol.MessageReportSignatures[RI]{}, fmt.Errorf("unable to extract MessageReportSignatures value") } var reportsPlusPrecursorDigest protocol.ReportsPlusPrecursorDigest @@ -1280,7 +1280,7 @@ func (fpm *fromProtoMessage[RI]) messageReportSignatures(m *MessageReportSignatu func (fpm *fromProtoMessage[RI]) messageReportsPlusPrecursorRequest(m *MessageReportsPlusPrecursorRequest) (protocol.MessageReportsPlusPrecursorRequest[RI], error) { if m == nil { - return protocol.MessageReportsPlusPrecursorRequest[RI]{}, fmt.Errorf("unable to extract a MessageReportsPlusPrecursorRequest value") + return protocol.MessageReportsPlusPrecursorRequest[RI]{}, fmt.Errorf("unable to extract MessageReportsPlusPrecursorRequest value") } return protocol.MessageReportsPlusPrecursorRequest[RI]{ fpm.requestHandle, @@ -1290,7 +1290,7 @@ func (fpm *fromProtoMessage[RI]) messageReportsPlusPrecursorRequest(m *MessageRe func (fpm *fromProtoMessage[RI]) messageReportsPlusPrecursor(m *MessageReportsPlusPrecursor) (protocol.MessageReportsPlusPrecursor[RI], error) { if m == nil { - return protocol.MessageReportsPlusPrecursor[RI]{}, fmt.Errorf("unable to extract a MessageReportsPlusPrecursor value") + return protocol.MessageReportsPlusPrecursor[RI]{}, fmt.Errorf("unable to extract MessageReportsPlusPrecursor value") } return protocol.MessageReportsPlusPrecursor[RI]{ fpm.requestHandle, @@ -1313,7 +1313,7 @@ func (fpm *fromProtoMessage[RI]) attributedSignedObservations(pbasos []*Attribut func (fpm *fromProtoMessage[RI]) attributedSignedObservation(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 := fpm.signedObservation(m.SignedObservation) @@ -1334,7 +1334,7 @@ func (fpm *fromProtoMessage[RI]) attributedSignedObservation(m *AttributedSigned func (fpm *fromProtoMessage[RI]) signedObservation(m *SignedObservation) (protocol.SignedObservation, error) { if m == nil { - return protocol.SignedObservation{}, fmt.Errorf("unable to extract a SignedObservation value") + return protocol.SignedObservation{}, fmt.Errorf("unable to extract SignedObservation value") } return protocol.SignedObservation{ @@ -1353,7 +1353,7 @@ func (fpm *fromProtoMessage[RI]) oracleID(m uint32) (commontypes.OracleID, error func (fpm *fromProtoMessage[RI]) messageBlockSyncRequest(m *MessageBlockSyncRequest) (protocol.MessageBlockSyncRequest[RI], error) { if m == nil { - return protocol.MessageBlockSyncRequest[RI]{}, fmt.Errorf("unable to extract a MessageBlockSyncRequest value") + return protocol.MessageBlockSyncRequest[RI]{}, fmt.Errorf("unable to extract MessageBlockSyncRequest value") } return protocol.MessageBlockSyncRequest[RI]{ fpm.requestHandle, @@ -1366,7 +1366,7 @@ func (fpm *fromProtoMessage[RI]) messageBlockSyncRequest(m *MessageBlockSyncRequ func (fpm *fromProtoMessage[RI]) messageBlockSyncResponse(m *MessageBlockSyncResponse) (protocol.MessageBlockSyncResponse[RI], error) { if m == nil { - return protocol.MessageBlockSyncResponse[RI]{}, fmt.Errorf("unable to extract a MessageBlockSyncResponse value") + return protocol.MessageBlockSyncResponse[RI]{}, fmt.Errorf("unable to extract MessageBlockSyncResponse value") } astbs, err := fpm.attestedStateTransitionBlocks(m.AttestedStateTransitionBlocks) if err != nil { @@ -1387,7 +1387,7 @@ func (fpm *fromProtoMessage[RI]) messageBlockSyncResponse(m *MessageBlockSyncRes func (fpm *fromProtoMessage[RI]) messageStateSyncSummary(m *MessageStateSyncSummary) (protocol.MessageStateSyncSummary[RI], error) { if m == nil { - return protocol.MessageStateSyncSummary[RI]{}, fmt.Errorf("unable to extract a MessageStateSyncSummary value") + return protocol.MessageStateSyncSummary[RI]{}, fmt.Errorf("unable to extract MessageStateSyncSummary value") } return protocol.MessageStateSyncSummary[RI]{ m.LowestPersistedSeqNr, @@ -1408,7 +1408,7 @@ func (fpm *fromProtoMessage[RI]) attestedStateTransitionBlocks(pbastbs []*Attest func (fpm *fromProtoMessage[RI]) attestedStateTransitionBlock(m *AttestedStateTransitionBlock) (protocol.AttestedStateTransitionBlock, error) { if m == nil { - return protocol.AttestedStateTransitionBlock{}, fmt.Errorf("unable to extract a AttestedStateTransitionBlock value") + return protocol.AttestedStateTransitionBlock{}, fmt.Errorf("unable to extract AttestedStateTransitionBlock value") } stb, err := fpm.stateTransitionBlock(m.StateTransitionBlock) if err != nil { @@ -1426,7 +1426,7 @@ func (fpm *fromProtoMessage[RI]) attestedStateTransitionBlock(m *AttestedStateTr func (fpm *fromProtoMessage[RI]) stateTransitionBlock(m *StateTransitionBlock) (protocol.StateTransitionBlock, error) { if m == nil { - return protocol.StateTransitionBlock{}, fmt.Errorf("unable to extract a StateTransitionBlock value") + return protocol.StateTransitionBlock{}, fmt.Errorf("unable to extract StateTransitionBlock value") } var prevHistoryDigest protocol.HistoryDigest copy(prevHistoryDigest[:], m.PrevHistoryDigest) @@ -1489,7 +1489,7 @@ func (fpm *fromProtoMessage[RI]) attributedCommitSignatures(pbasigs []*Attribute func (fpm *fromProtoMessage[RI]) attributedCommitSignature(m *AttributedCommitSignature) (protocol.AttributedCommitSignature, error) { if m == nil { - return protocol.AttributedCommitSignature{}, fmt.Errorf("unable to extract an AttributedCommitSignature value") + return protocol.AttributedCommitSignature{}, fmt.Errorf("unable to extract AttributedCommitSignature value") } signer, err := fpm.oracleID(m.GetSigner()) if err != nil { @@ -1503,7 +1503,7 @@ func (fpm *fromProtoMessage[RI]) attributedCommitSignature(m *AttributedCommitSi func (fpm *fromProtoMessage[RI]) keyValuePairWithDeletions(pbkvmod *KeyValueModification) (protocol.KeyValuePairWithDeletions, error) { if pbkvmod == nil { - return protocol.KeyValuePairWithDeletions{}, fmt.Errorf("unable to extract a KeyValuePairWithDeletions value") + return protocol.KeyValuePairWithDeletions{}, fmt.Errorf("unable to extract KeyValuePairWithDeletions value") } return protocol.KeyValuePairWithDeletions{ @@ -1515,7 +1515,7 @@ func (fpm *fromProtoMessage[RI]) keyValuePairWithDeletions(pbkvmod *KeyValueModi func (fpm *fromProtoMessage[RI]) stateWriteSet(m *StateWriteSet) (protocol.StateWriteSet, error) { if m == nil { - return protocol.StateWriteSet{}, fmt.Errorf("unable to extract an StateWriteSet value") + return protocol.StateWriteSet{}, fmt.Errorf("unable to extract StateWriteSet value") } writeSet := make([]protocol.KeyValuePairWithDeletions, 0, len(m.Entries)) @@ -1532,7 +1532,7 @@ func (fpm *fromProtoMessage[RI]) stateWriteSet(m *StateWriteSet) (protocol.State func (fpm *fromProtoMessage[RI]) messageBlobOffer(m *MessageBlobOffer) (protocol.MessageBlobOffer[RI], error) { if m == nil { - return protocol.MessageBlobOffer[RI]{}, fmt.Errorf("unable to extract a MessageBlobOffer value") + return protocol.MessageBlobOffer[RI]{}, fmt.Errorf("unable to extract MessageBlobOffer value") } var chunkDigestsRoot mt.Digest copy(chunkDigestsRoot[:], m.ChunkDigestsRoot) @@ -1558,7 +1558,7 @@ func (fpm *fromProtoMessage[RI]) chunkDigests(pbcds [][]byte) ([]protocol.BlobCh func (fpm *fromProtoMessage[RI]) messageBlobOfferResponse(m *MessageBlobOfferResponse) (protocol.MessageBlobOfferResponse[RI], error) { if m == nil { - return protocol.MessageBlobOfferResponse[RI]{}, fmt.Errorf("unable to extract a MessageBlobOfferResponse value") + return protocol.MessageBlobOfferResponse[RI]{}, fmt.Errorf("unable to extract MessageBlobOfferResponse value") } var blobDigest protocol.BlobDigest @@ -1574,7 +1574,7 @@ func (fpm *fromProtoMessage[RI]) messageBlobOfferResponse(m *MessageBlobOfferRes func (fpm *fromProtoMessage[RI]) messageBlobChunkRequest(m *MessageBlobChunkRequest) (protocol.MessageBlobChunkRequest[RI], error) { if m == nil { - return protocol.MessageBlobChunkRequest[RI]{}, fmt.Errorf("unable to extract a MessageBlobChunkRequest value") + return protocol.MessageBlobChunkRequest[RI]{}, fmt.Errorf("unable to extract MessageBlobChunkRequest value") } var blobDigest protocol.BlobDigest @@ -1590,7 +1590,7 @@ func (fpm *fromProtoMessage[RI]) messageBlobChunkRequest(m *MessageBlobChunkRequ func (fpm *fromProtoMessage[RI]) messageBlobChunkResponse(m *MessageBlobChunkResponse) (protocol.MessageBlobChunkResponse[RI], error) { if m == nil { - return protocol.MessageBlobChunkResponse[RI]{}, fmt.Errorf("unable to extract a MessageBlobChunkResponse value") + return protocol.MessageBlobChunkResponse[RI]{}, fmt.Errorf("unable to extract MessageBlobChunkResponse value") } var blobDigest protocol.BlobDigest @@ -1615,7 +1615,7 @@ func (fpm *fromProtoMessage[RI]) messageBlobChunkResponse(m *MessageBlobChunkRes func (fpm *fromProtoMessage[RI]) messageTreeSyncChunkRequest(m *MessageTreeSyncChunkRequest) (protocol.MessageTreeSyncChunkRequest[RI], error) { if m == nil { - return protocol.MessageTreeSyncChunkRequest[RI]{}, fmt.Errorf("unable to extract an MessageTreeSyncRequest value") + return protocol.MessageTreeSyncChunkRequest[RI]{}, fmt.Errorf("unable to extract MessageTreeSyncRequest value") } startIndex, err := fpm.digest(m.StartIndex) if err != nil { @@ -1640,7 +1640,7 @@ func (fpm *fromProtoMessage[RI]) treeSyncChunkProof(pbpns [][]byte) ([]jmt.Diges for _, pbpn := range pbpns { var pn jmt.Digest if len(pbpn) != len(pn) { - return proof, fmt.Errorf("invalid proof node length, expected %d, got %d ", len(pn), len(pbpn)) + return proof, fmt.Errorf("invalid proof node length, expected %d, got %d", len(pn), len(pbpn)) } copy(pn[:], pbpn) proof = append(proof, pn) @@ -1650,7 +1650,7 @@ func (fpm *fromProtoMessage[RI]) treeSyncChunkProof(pbpns [][]byte) ([]jmt.Diges func (fpm *fromProtoMessage[RI]) keyValuePair(pbkvp *KeyValuePair) (protocol.KeyValuePair, error) { if pbkvp == nil { - return protocol.KeyValuePair{}, fmt.Errorf("unable to extract a KeyValuePair value") + return protocol.KeyValuePair{}, fmt.Errorf("unable to extract KeyValuePair value") } return protocol.KeyValuePair{ @@ -1682,7 +1682,7 @@ func (fpm *fromProtoMessage[RI]) digest(pbdigest []byte) (jmt.Digest, error) { func (fpm *fromProtoMessage[RI]) leafKeyAndValueDigests(pblkd *LeafKeyAndValueDigests) (jmt.LeafKeyAndValueDigests, error) { if pblkd == nil { - return jmt.LeafKeyAndValueDigests{}, fmt.Errorf("unable to extract a LeafKeyAndValueDigests value") + return jmt.LeafKeyAndValueDigests{}, fmt.Errorf("unable to extract LeafKeyAndValueDigests value") } keyDigest, err := fpm.digest(pblkd.KeyDigest) if err != nil { @@ -1700,7 +1700,7 @@ func (fpm *fromProtoMessage[RI]) leafKeyAndValueDigests(pblkd *LeafKeyAndValueDi func (fpm *fromProtoMessage[RI]) boundingLeaf(pbbl *BoundingLeaf) (jmt.BoundingLeaf, error) { if pbbl == nil { - return jmt.BoundingLeaf{}, fmt.Errorf("unable to extract a BoundingLeaf value") + return jmt.BoundingLeaf{}, fmt.Errorf("unable to extract BoundingLeaf value") } leafKeyAndValueDigests, err := fpm.leafKeyAndValueDigests(pbbl.Leaf) if err != nil { @@ -1730,7 +1730,7 @@ func (fpm *fromProtoMessage[RI]) treeSyncChunkBoundingLeaves(pbbls []*BoundingLe func (fpm *fromProtoMessage[RI]) messageTreeSyncChunkResponse(m *MessageTreeSyncChunkResponse) (protocol.MessageTreeSyncChunkResponse[RI], error) { if m == nil { - return protocol.MessageTreeSyncChunkResponse[RI]{}, fmt.Errorf("unable to extract an MessageTreeSyncChunk value") + return protocol.MessageTreeSyncChunkResponse[RI]{}, fmt.Errorf("unable to extract MessageTreeSyncChunk value") } startIndex, err := fpm.digest(m.StartIndex) if err != nil { @@ -1766,7 +1766,7 @@ func (fpm *fromProtoMessage[RI]) messageTreeSyncChunkResponse(m *MessageTreeSync func (fpm *fromProtoMessage[RI]) keyDigestRange(pbr *KeyDigestRange) (protocol.KeyDigestRange, error) { if pbr == nil { - return protocol.KeyDigestRange{}, fmt.Errorf("unable to extract a KeyDigestRange value") + return protocol.KeyDigestRange{}, fmt.Errorf("unable to extract KeyDigestRange value") } startIndex, err := fpm.digest(pbr.StartIndex) if err != nil { diff --git a/offchainreporting2plus/ocr3_1types/blob.go b/offchainreporting2plus/ocr3_1types/blob.go index a7e8f680..34668206 100644 --- a/offchainreporting2plus/ocr3_1types/blob.go +++ b/offchainreporting2plus/ocr3_1types/blob.go @@ -10,6 +10,9 @@ type BlobHandle = blobtypes.BlobHandle //go-sumtype:decl BlobExpirationHint +// BlobExpirationHint must be a BlobExpirationHintSequenceNumber value. +// Anything else, including nil or a pointer to +// BlobExpirationHintSequenceNumber, causes a panic. type BlobExpirationHint interface { isBlobExpirationHint() }