llo

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 33 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// OCR protocol limits
	// NOTE: CAREFUL! If we ever accidentally exceed these e.g.
	// through too many channels/streams, the protocol will halt.
	//
	// TODO: How many channels/streams can we support given these constraints?
	// https://smartcontract-it.atlassian.net/browse/MERC-6468
	MaxReportCount       = ocr3types.MaxMaxReportCount
	MaxObservationLength = ocr3types.MaxMaxObservationLength
	MaxOutcomeLength     = ocr3types.MaxMaxOutcomeLength
	MaxReportLength      = ocr3types.MaxMaxReportLength

	// LLO-specific limits
	//
	// Maximum amount of channels that can be removed per round (if more than
	// this need to be removed, they will be removed in batches until
	// everything is up-to-date)
	MaxObservationRemoveChannelIDsLength = 5
	// Maximum amount of channels that can be added/updated per round (if more
	// than this need to be added, they will be added in batches until
	// everything is up-to-date)
	MaxObservationUpdateChannelDefinitionsLength = 5
	// Maximum number of streams that can be observed per round
	MaxObservationStreamValuesLength = 10_000
	// Maximum allowed number of streams per channel
	MaxStreamsPerChannel = 10_000
	// MaxOutcomeChannelDefinitionsLength is the maximum number of channels that
	// can be supported
	MaxOutcomeChannelDefinitionsLength = MaxReportCount
)

Additional limits so we can more effectively bound the size of observations NOTE: These are hardcoded because these exact values are relied upon as a property of coming to consensus, it's too dangerous to make these configurable on a per-node basis. It may be possible to add them to the OffchainConfig if they need to be changed dynamically and in a backwards-compatible way.

View Source
const (
	LifeCycleStageStaging    llotypes.LifeCycleStage = "staging"
	LifeCycleStageProduction llotypes.LifeCycleStage = "production"
	LifeCycleStageRetired    llotypes.LifeCycleStage = "retired"
)

Protocol instances start in either the staging or production stage. They may later be retired and "hand over" their work to another protocol instance that will move from the staging to the production stage.

Variables

View Source
var (
	LLOStreamValue_Type_name = map[int32]string{
		0: "Decimal",
		1: "Quote",
		2: "TimestampedStreamValue",
	}
	LLOStreamValue_Type_value = map[string]int32{
		"Decimal":                0,
		"Quote":                  1,
		"TimestampedStreamValue": 2,
	}
)

Enum value maps for LLOStreamValue_Type.

View Source
var (
	ErrNilStreamValue = errors.New("nil stream value")
)
View Source
var File_llo_offchain_config_proto protoreflect.FileDescriptor
View Source
var File_llo_plugin_telemetry_proto protoreflect.FileDescriptor
View Source
var File_plugin_codecs_proto protoreflect.FileDescriptor

Functions

func Abs added in v0.1.1

func Abs(x any) (decimal.Decimal, error)

Abs returns the absolute value of x

func Add added in v0.1.1

func Add(x, y any) (decimal.Decimal, error)

Add returns the sum of x and y

func Avg added in v0.1.1

func Avg(x ...any) (decimal.Decimal, error)

Avg returns the average of x elements

func Ceil added in v0.1.1

func Ceil(x any) (decimal.Decimal, error)

Ceil returns the ceiling of x

func Decode

func Decode(value StreamValue, data []byte) error

func Div added in v0.1.1

func Div(x, y any) (decimal.Decimal, error)

Div returns the quotient of x and y

func Duration added in v0.1.1

func Duration(x string) (time.Duration, error)

Duration parses a duration string into a time.Duration

func Equal added in v0.1.1

func Equal(x, y any) (bool, error)

Equal returns true if x and y are equal

func Floor added in v0.1.1

func Floor(x any) (decimal.Decimal, error)

Floor returns the floor of x

func GreaterThan added in v0.1.1

func GreaterThan(x, y any) (bool, error)

GreaterThan returns true if x is greater than y

func GreaterThanOrEqual added in v0.1.1

func GreaterThanOrEqual(x, y any) (bool, error)

GreaterThanOrEqual returns true if x is greater than or equal to y

func IsNegative added in v0.1.1

func IsNegative(x any) (bool, error)

IsNegative returns true if x is negative

func IsPositive added in v0.1.1

func IsPositive(x any) (bool, error)

IsPositive returns true if x is positive

func IsSecondsResolution added in v0.1.1

func IsSecondsResolution(reportFormat llotypes.ReportFormat) bool

func IsZero added in v0.1.1

func IsZero(x any) (bool, error)

IsZero returns true if x is zero

func LessThan added in v0.1.1

func LessThan(x, y any) (bool, error)

LessThan returns true if x is less than y

func LessThanOrEqual added in v0.1.1

func LessThanOrEqual(x, y any) (bool, error)

LessThanOrEqual returns true if x is less than or equal to y

func Max added in v0.1.1

func Max(x ...any) (decimal.Decimal, error)

Max returns the maximum of x elements

func Min added in v0.1.1

func Min(x ...any) (decimal.Decimal, error)

Min returns the minimum of x elements

func Mul added in v0.1.1

func Mul(x, y any) (decimal.Decimal, error)

Mul returns the product of x and y

func NewEnv added in v0.1.1

func NewEnv(outcome *Outcome) environment

NewEnv returns a new environment with the default functions

func Round added in v0.1.1

func Round(x any, precision int) (decimal.Decimal, error)

Round returns the rounded value of x to the given precision

func Sub added in v0.1.1

func Sub(x, y any) (decimal.Decimal, error)

Sub returns the difference of x and y

func VerifyChannelDefinitions

func VerifyChannelDefinitions(codecs map[llotypes.ReportFormat]ReportCodec, channelDefs llotypes.ChannelDefinitions) (merr error)

Types

type AggregatorFunc

type AggregatorFunc func(values []StreamValue, f int) (StreamValue, error)

func GetAggregatorFunc

func GetAggregatorFunc(a llotypes.Aggregator) AggregatorFunc

type ChannelDefinitionCache

type ChannelDefinitionCache interface {
	Definitions() llotypes.ChannelDefinitions
}

type ChannelDefinitionWithID

type ChannelDefinitionWithID struct {
	llotypes.ChannelDefinition
	ChannelID llotypes.ChannelID
}

type ChannelHash

type ChannelHash [32]byte

func MakeChannelHash

func MakeChannelHash(cd ChannelDefinitionWithID) ChannelHash

MakeChannelHash is used for mapping ChannelDefinitionWithIDs

type Config

type Config struct {
	// Enables additional logging that might be expensive, e.g. logging entire
	// channel definitions on every round or other very large structs
	VerboseLogging bool
}

type DSOpts

type DSOpts interface {
	VerboseLogging() bool
	SeqNr() uint64
	OutCtx() ocr3types.OutcomeContext
	ConfigDigest() ocr2types.ConfigDigest
	ObservationTimestamp() time.Time
	OutcomeCodec() OutcomeCodec
}

type DataSource

type DataSource interface {
	// For each known streamID, Observe should set the observed value in the
	// passed streamValues.
	// If an observation fails, or the stream is unknown, no value should be
	// set.
	Observe(ctx context.Context, streamValues StreamValues, opts DSOpts) error
}

type Decimal

type Decimal decimal.Decimal

func ToDecimal

func ToDecimal(d decimal.Decimal) *Decimal

func (*Decimal) Decimal

func (v *Decimal) Decimal() decimal.Decimal

func (*Decimal) MarshalBinary

func (v *Decimal) MarshalBinary() ([]byte, error)

func (*Decimal) MarshalText

func (v *Decimal) MarshalText() ([]byte, error)

func (*Decimal) String

func (v *Decimal) String() string

func (*Decimal) Type

func (v *Decimal) Type() LLOStreamValue_Type

func (*Decimal) UnmarshalBinary

func (v *Decimal) UnmarshalBinary(data []byte) error

func (*Decimal) UnmarshalText

func (v *Decimal) UnmarshalText(data []byte) error

type EVMOnchainConfigCodec added in v0.1.1

type EVMOnchainConfigCodec struct{}

EVMOnchainConfigCodec provides a llo-specific implementation of OnchainConfigCodec.

An encoded onchain config is expected to be in the format <version><predecessorConfigDigest> where version is a uint8 and min and max are in the format returned by EncodeValueInt192.

func (EVMOnchainConfigCodec) Decode added in v0.1.1

func (EVMOnchainConfigCodec) Encode added in v0.1.1

type JSONReportCodec

type JSONReportCodec struct{}

func (JSONReportCodec) Decode

func (cdc JSONReportCodec) Decode(b []byte) (r Report, err error)

func (JSONReportCodec) Encode

func (JSONReportCodec) Pack added in v0.1.1

func (cdc JSONReportCodec) Pack(digest types.ConfigDigest, seqNr uint64, report ocr2types.Report, sigs []types.AttributedOnchainSignature) ([]byte, error)

func (JSONReportCodec) Unpack added in v0.1.1

func (cdc JSONReportCodec) Unpack(b []byte) (digest types.ConfigDigest, seqNr uint64, report ocr2types.Report, sigs []types.AttributedOnchainSignature, err error)

func (JSONReportCodec) UnpackDecode added in v0.1.1

func (cdc JSONReportCodec) UnpackDecode(b []byte) (digest types.ConfigDigest, seqNr uint64, report Report, sigs []types.AttributedOnchainSignature, err error)

func (JSONReportCodec) Verify added in v0.1.1

type LLOAggregatorStreamValue added in v0.1.1

type LLOAggregatorStreamValue struct {
	AggregatorValues map[uint32]*LLOStreamValue `` /* 184-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*LLOAggregatorStreamValue) Descriptor deprecated added in v0.1.1

func (*LLOAggregatorStreamValue) Descriptor() ([]byte, []int)

Deprecated: Use LLOAggregatorStreamValue.ProtoReflect.Descriptor instead.

func (*LLOAggregatorStreamValue) GetAggregatorValues added in v0.1.1

func (x *LLOAggregatorStreamValue) GetAggregatorValues() map[uint32]*LLOStreamValue

func (*LLOAggregatorStreamValue) ProtoMessage added in v0.1.1

func (*LLOAggregatorStreamValue) ProtoMessage()

func (*LLOAggregatorStreamValue) ProtoReflect added in v0.1.1

func (x *LLOAggregatorStreamValue) ProtoReflect() protoreflect.Message

func (*LLOAggregatorStreamValue) Reset added in v0.1.1

func (x *LLOAggregatorStreamValue) Reset()

func (*LLOAggregatorStreamValue) String added in v0.1.1

func (x *LLOAggregatorStreamValue) String() string

type LLOChannelDefinitionProto

type LLOChannelDefinitionProto struct {
	ReportFormat uint32                 `protobuf:"varint,1,opt,name=reportFormat,proto3" json:"reportFormat,omitempty"`
	Streams      []*LLOStreamDefinition `protobuf:"bytes,2,rep,name=streams,proto3" json:"streams,omitempty"`
	Opts         []byte                 `protobuf:"bytes,3,opt,name=opts,proto3" json:"opts,omitempty"`
	// contains filtered or unexported fields
}

func (*LLOChannelDefinitionProto) Descriptor deprecated

func (*LLOChannelDefinitionProto) Descriptor() ([]byte, []int)

Deprecated: Use LLOChannelDefinitionProto.ProtoReflect.Descriptor instead.

func (*LLOChannelDefinitionProto) GetOpts

func (x *LLOChannelDefinitionProto) GetOpts() []byte

func (*LLOChannelDefinitionProto) GetReportFormat

func (x *LLOChannelDefinitionProto) GetReportFormat() uint32

func (*LLOChannelDefinitionProto) GetStreams

func (*LLOChannelDefinitionProto) ProtoMessage

func (*LLOChannelDefinitionProto) ProtoMessage()

func (*LLOChannelDefinitionProto) ProtoReflect

func (*LLOChannelDefinitionProto) Reset

func (x *LLOChannelDefinitionProto) Reset()

func (*LLOChannelDefinitionProto) String

func (x *LLOChannelDefinitionProto) String() string

type LLOChannelIDAndDefinitionProto

type LLOChannelIDAndDefinitionProto struct {
	ChannelID         uint32                     `protobuf:"varint,1,opt,name=channelID,proto3" json:"channelID,omitempty"`
	ChannelDefinition *LLOChannelDefinitionProto `protobuf:"bytes,2,opt,name=channelDefinition,proto3" json:"channelDefinition,omitempty"`
	// contains filtered or unexported fields
}

func (*LLOChannelIDAndDefinitionProto) Descriptor deprecated

func (*LLOChannelIDAndDefinitionProto) Descriptor() ([]byte, []int)

Deprecated: Use LLOChannelIDAndDefinitionProto.ProtoReflect.Descriptor instead.

func (*LLOChannelIDAndDefinitionProto) GetChannelDefinition

func (x *LLOChannelIDAndDefinitionProto) GetChannelDefinition() *LLOChannelDefinitionProto

func (*LLOChannelIDAndDefinitionProto) GetChannelID

func (x *LLOChannelIDAndDefinitionProto) GetChannelID() uint32

func (*LLOChannelIDAndDefinitionProto) ProtoMessage

func (*LLOChannelIDAndDefinitionProto) ProtoMessage()

func (*LLOChannelIDAndDefinitionProto) ProtoReflect

func (*LLOChannelIDAndDefinitionProto) Reset

func (x *LLOChannelIDAndDefinitionProto) Reset()

func (*LLOChannelIDAndDefinitionProto) String

type LLOChannelIDAndValidAfterNanosecondsProto added in v0.1.1

type LLOChannelIDAndValidAfterNanosecondsProto struct {
	ChannelID             uint32 `protobuf:"varint,1,opt,name=channelID,proto3" json:"channelID,omitempty"`
	ValidAfterNanoseconds uint64 `protobuf:"varint,2,opt,name=validAfterNanoseconds,proto3" json:"validAfterNanoseconds,omitempty"`
	// contains filtered or unexported fields
}

func (*LLOChannelIDAndValidAfterNanosecondsProto) Descriptor deprecated added in v0.1.1

func (*LLOChannelIDAndValidAfterNanosecondsProto) Descriptor() ([]byte, []int)

Deprecated: Use LLOChannelIDAndValidAfterNanosecondsProto.ProtoReflect.Descriptor instead.

func (*LLOChannelIDAndValidAfterNanosecondsProto) GetChannelID added in v0.1.1

func (*LLOChannelIDAndValidAfterNanosecondsProto) GetValidAfterNanoseconds added in v0.1.1

func (x *LLOChannelIDAndValidAfterNanosecondsProto) GetValidAfterNanoseconds() uint64

func (*LLOChannelIDAndValidAfterNanosecondsProto) ProtoMessage added in v0.1.1

func (*LLOChannelIDAndValidAfterNanosecondsProto) ProtoReflect added in v0.1.1

func (*LLOChannelIDAndValidAfterNanosecondsProto) Reset added in v0.1.1

func (*LLOChannelIDAndValidAfterNanosecondsProto) String added in v0.1.1

type LLOChannelIDAndValidAfterSecondsProto

type LLOChannelIDAndValidAfterSecondsProto struct {
	ChannelID         uint32 `protobuf:"varint,1,opt,name=channelID,proto3" json:"channelID,omitempty"`
	ValidAfterSeconds uint32 `protobuf:"varint,2,opt,name=validAfterSeconds,proto3" json:"validAfterSeconds,omitempty"`
	// contains filtered or unexported fields
}

func (*LLOChannelIDAndValidAfterSecondsProto) Descriptor deprecated

func (*LLOChannelIDAndValidAfterSecondsProto) Descriptor() ([]byte, []int)

Deprecated: Use LLOChannelIDAndValidAfterSecondsProto.ProtoReflect.Descriptor instead.

func (*LLOChannelIDAndValidAfterSecondsProto) GetChannelID

func (*LLOChannelIDAndValidAfterSecondsProto) GetValidAfterSeconds

func (x *LLOChannelIDAndValidAfterSecondsProto) GetValidAfterSeconds() uint32

func (*LLOChannelIDAndValidAfterSecondsProto) ProtoMessage

func (*LLOChannelIDAndValidAfterSecondsProto) ProtoMessage()

func (*LLOChannelIDAndValidAfterSecondsProto) ProtoReflect

func (*LLOChannelIDAndValidAfterSecondsProto) Reset

func (*LLOChannelIDAndValidAfterSecondsProto) String

type LLOObservationProto

type LLOObservationProto struct {
	AttestedPredecessorRetirement []byte `protobuf:"bytes,1,opt,name=attestedPredecessorRetirement,proto3" json:"attestedPredecessorRetirement,omitempty"`
	ShouldRetire                  bool   `protobuf:"varint,2,opt,name=shouldRetire,proto3" json:"shouldRetire,omitempty"`
	// TODO: unixTimestampNanosecondsLegacy can be removed after this version
	// is rolled out everywhere
	UnixTimestampNanosecondsLegacy int64    `protobuf:"varint,3,opt,name=unixTimestampNanosecondsLegacy,proto3" json:"unixTimestampNanosecondsLegacy,omitempty"`
	UnixTimestampNanoseconds       uint64   `protobuf:"varint,7,opt,name=unixTimestampNanoseconds,proto3" json:"unixTimestampNanoseconds,omitempty"`
	RemoveChannelIDs               []uint32 `protobuf:"varint,4,rep,packed,name=removeChannelIDs,proto3" json:"removeChannelIDs,omitempty"`
	// Maps are safe to use here because Observation serialization does not
	// need to be deterministic. Non-deterministic map serialization is
	// marginally more efficient than converting to tuples and guarantees
	// uniqueness.
	UpdateChannelDefinitions map[uint32]*LLOChannelDefinitionProto `` /* 176-byte string literal not displayed */
	StreamValues             map[uint32]*LLOStreamValue            `` /* 152-byte string literal not displayed */
	// contains filtered or unexported fields
}

Observation CAN be changed as long as it doesn't break decode for legacy versions.

i.e. adding new fields is ok

func (*LLOObservationProto) Descriptor deprecated

func (*LLOObservationProto) Descriptor() ([]byte, []int)

Deprecated: Use LLOObservationProto.ProtoReflect.Descriptor instead.

func (*LLOObservationProto) GetAttestedPredecessorRetirement

func (x *LLOObservationProto) GetAttestedPredecessorRetirement() []byte

func (*LLOObservationProto) GetRemoveChannelIDs

func (x *LLOObservationProto) GetRemoveChannelIDs() []uint32

func (*LLOObservationProto) GetShouldRetire

func (x *LLOObservationProto) GetShouldRetire() bool

func (*LLOObservationProto) GetStreamValues

func (x *LLOObservationProto) GetStreamValues() map[uint32]*LLOStreamValue

func (*LLOObservationProto) GetUnixTimestampNanoseconds

func (x *LLOObservationProto) GetUnixTimestampNanoseconds() uint64

func (*LLOObservationProto) GetUnixTimestampNanosecondsLegacy added in v0.1.1

func (x *LLOObservationProto) GetUnixTimestampNanosecondsLegacy() int64

func (*LLOObservationProto) GetUpdateChannelDefinitions

func (x *LLOObservationProto) GetUpdateChannelDefinitions() map[uint32]*LLOChannelDefinitionProto

func (*LLOObservationProto) ProtoMessage

func (*LLOObservationProto) ProtoMessage()

func (*LLOObservationProto) ProtoReflect

func (x *LLOObservationProto) ProtoReflect() protoreflect.Message

func (*LLOObservationProto) Reset

func (x *LLOObservationProto) Reset()

func (*LLOObservationProto) String

func (x *LLOObservationProto) String() string

type LLOOffchainConfigProto

type LLOOffchainConfigProto struct {
	ProtocolVersion                     uint32 `protobuf:"varint,1,opt,name=protocolVersion,proto3" json:"protocolVersion,omitempty"`
	DefaultMinReportIntervalNanoseconds uint64 `protobuf:"varint,2,opt,name=defaultMinReportIntervalNanoseconds,proto3" json:"defaultMinReportIntervalNanoseconds,omitempty"`
	EnableObservationCompression        bool   `protobuf:"varint,3,opt,name=enableObservationCompression,proto3" json:"enableObservationCompression,omitempty"`
	// contains filtered or unexported fields
}

func (*LLOOffchainConfigProto) Descriptor deprecated

func (*LLOOffchainConfigProto) Descriptor() ([]byte, []int)

Deprecated: Use LLOOffchainConfigProto.ProtoReflect.Descriptor instead.

func (*LLOOffchainConfigProto) GetDefaultMinReportIntervalNanoseconds added in v0.1.1

func (x *LLOOffchainConfigProto) GetDefaultMinReportIntervalNanoseconds() uint64

func (*LLOOffchainConfigProto) GetEnableObservationCompression added in v0.1.1

func (x *LLOOffchainConfigProto) GetEnableObservationCompression() bool

func (*LLOOffchainConfigProto) GetProtocolVersion added in v0.1.1

func (x *LLOOffchainConfigProto) GetProtocolVersion() uint32

func (*LLOOffchainConfigProto) ProtoMessage

func (*LLOOffchainConfigProto) ProtoMessage()

func (*LLOOffchainConfigProto) ProtoReflect

func (x *LLOOffchainConfigProto) ProtoReflect() protoreflect.Message

func (*LLOOffchainConfigProto) Reset

func (x *LLOOffchainConfigProto) Reset()

func (*LLOOffchainConfigProto) String

func (x *LLOOffchainConfigProto) String() string

type LLOOutcomeProtoV0 added in v0.1.1

type LLOOutcomeProtoV0 struct {
	LifeCycleStage                  string                                   `protobuf:"bytes,1,opt,name=lifeCycleStage,proto3" json:"lifeCycleStage,omitempty"`
	ObservationTimestampNanoseconds int64                                    `protobuf:"varint,2,opt,name=observationTimestampNanoseconds,proto3" json:"observationTimestampNanoseconds,omitempty"`
	ChannelDefinitions              []*LLOChannelIDAndDefinitionProto        `protobuf:"bytes,3,rep,name=channelDefinitions,proto3" json:"channelDefinitions,omitempty"`
	ValidAfterSeconds               []*LLOChannelIDAndValidAfterSecondsProto `protobuf:"bytes,4,rep,name=validAfterSeconds,proto3" json:"validAfterSeconds,omitempty"`
	StreamAggregates                []*LLOStreamAggregate                    `protobuf:"bytes,5,rep,name=streamAggregates,proto3" json:"streamAggregates,omitempty"`
	// contains filtered or unexported fields
}

NOTE: Outcome must serialize deterministically, hence use of repeated tuple instead of maps

func (*LLOOutcomeProtoV0) Descriptor deprecated added in v0.1.1

func (*LLOOutcomeProtoV0) Descriptor() ([]byte, []int)

Deprecated: Use LLOOutcomeProtoV0.ProtoReflect.Descriptor instead.

func (*LLOOutcomeProtoV0) GetChannelDefinitions added in v0.1.1

func (x *LLOOutcomeProtoV0) GetChannelDefinitions() []*LLOChannelIDAndDefinitionProto

func (*LLOOutcomeProtoV0) GetLifeCycleStage added in v0.1.1

func (x *LLOOutcomeProtoV0) GetLifeCycleStage() string

func (*LLOOutcomeProtoV0) GetObservationTimestampNanoseconds added in v0.1.1

func (x *LLOOutcomeProtoV0) GetObservationTimestampNanoseconds() int64

func (*LLOOutcomeProtoV0) GetStreamAggregates added in v0.1.1

func (x *LLOOutcomeProtoV0) GetStreamAggregates() []*LLOStreamAggregate

func (*LLOOutcomeProtoV0) GetValidAfterSeconds added in v0.1.1

func (x *LLOOutcomeProtoV0) GetValidAfterSeconds() []*LLOChannelIDAndValidAfterSecondsProto

func (*LLOOutcomeProtoV0) ProtoMessage added in v0.1.1

func (*LLOOutcomeProtoV0) ProtoMessage()

func (*LLOOutcomeProtoV0) ProtoReflect added in v0.1.1

func (x *LLOOutcomeProtoV0) ProtoReflect() protoreflect.Message

func (*LLOOutcomeProtoV0) Reset added in v0.1.1

func (x *LLOOutcomeProtoV0) Reset()

func (*LLOOutcomeProtoV0) String added in v0.1.1

func (x *LLOOutcomeProtoV0) String() string

type LLOOutcomeProtoV1 added in v0.1.1

type LLOOutcomeProtoV1 struct {
	LifeCycleStage                  string                                       `protobuf:"bytes,1,opt,name=lifeCycleStage,proto3" json:"lifeCycleStage,omitempty"`
	ObservationTimestampNanoseconds uint64                                       `protobuf:"varint,2,opt,name=observationTimestampNanoseconds,proto3" json:"observationTimestampNanoseconds,omitempty"`
	ChannelDefinitions              []*LLOChannelIDAndDefinitionProto            `protobuf:"bytes,3,rep,name=channelDefinitions,proto3" json:"channelDefinitions,omitempty"`
	ValidAfterNanoseconds           []*LLOChannelIDAndValidAfterNanosecondsProto `protobuf:"bytes,4,rep,name=validAfterNanoseconds,proto3" json:"validAfterNanoseconds,omitempty"`
	StreamAggregates                []*LLOStreamAggregate                        `protobuf:"bytes,5,rep,name=streamAggregates,proto3" json:"streamAggregates,omitempty"`
	// contains filtered or unexported fields
}

NOTE: Outcome must serialize deterministically, hence use of repeated tuple instead of maps

func (*LLOOutcomeProtoV1) Descriptor deprecated added in v0.1.1

func (*LLOOutcomeProtoV1) Descriptor() ([]byte, []int)

Deprecated: Use LLOOutcomeProtoV1.ProtoReflect.Descriptor instead.

func (*LLOOutcomeProtoV1) GetChannelDefinitions added in v0.1.1

func (x *LLOOutcomeProtoV1) GetChannelDefinitions() []*LLOChannelIDAndDefinitionProto

func (*LLOOutcomeProtoV1) GetLifeCycleStage added in v0.1.1

func (x *LLOOutcomeProtoV1) GetLifeCycleStage() string

func (*LLOOutcomeProtoV1) GetObservationTimestampNanoseconds added in v0.1.1

func (x *LLOOutcomeProtoV1) GetObservationTimestampNanoseconds() uint64

func (*LLOOutcomeProtoV1) GetStreamAggregates added in v0.1.1

func (x *LLOOutcomeProtoV1) GetStreamAggregates() []*LLOStreamAggregate

func (*LLOOutcomeProtoV1) GetValidAfterNanoseconds added in v0.1.1

func (x *LLOOutcomeProtoV1) GetValidAfterNanoseconds() []*LLOChannelIDAndValidAfterNanosecondsProto

func (*LLOOutcomeProtoV1) ProtoMessage added in v0.1.1

func (*LLOOutcomeProtoV1) ProtoMessage()

func (*LLOOutcomeProtoV1) ProtoReflect added in v0.1.1

func (x *LLOOutcomeProtoV1) ProtoReflect() protoreflect.Message

func (*LLOOutcomeProtoV1) Reset added in v0.1.1

func (x *LLOOutcomeProtoV1) Reset()

func (*LLOOutcomeProtoV1) String added in v0.1.1

func (x *LLOOutcomeProtoV1) String() string

type LLOOutcomeTelemetry added in v0.1.1

type LLOOutcomeTelemetry struct {
	LifeCycleStage                  string `protobuf:"bytes,1,opt,name=life_cycle_stage,json=lifeCycleStage,proto3" json:"life_cycle_stage,omitempty"`
	ObservationTimestampNanoseconds uint64 `` /* 157-byte string literal not displayed */
	// channel id => channel definition
	ChannelDefinitions map[uint32]*LLOChannelDefinitionProto `` /* 190-byte string literal not displayed */
	// channel id => valid after nanoseconds
	ValidAfterNanoseconds map[uint32]uint64 `` /* 202-byte string literal not displayed */
	// stream id => aggregator => value
	StreamAggregates map[uint32]*LLOAggregatorStreamValue `` /* 184-byte string literal not displayed */
	SeqNr            uint64                               `protobuf:"varint,9,opt,name=seq_nr,json=seqNr,proto3" json:"seq_nr,omitempty"`
	ConfigDigest     []byte                               `protobuf:"bytes,10,opt,name=config_digest,json=configDigest,proto3" json:"config_digest,omitempty"`
	DonId            uint32                               `protobuf:"varint,11,opt,name=don_id,json=donId,proto3" json:"don_id,omitempty"`
	// contains filtered or unexported fields
}

LLOOutcomeTelemetry sent on every call to Outcome (once per round)

func (*LLOOutcomeTelemetry) Descriptor deprecated added in v0.1.1

func (*LLOOutcomeTelemetry) Descriptor() ([]byte, []int)

Deprecated: Use LLOOutcomeTelemetry.ProtoReflect.Descriptor instead.

func (*LLOOutcomeTelemetry) GetChannelDefinitions added in v0.1.1

func (x *LLOOutcomeTelemetry) GetChannelDefinitions() map[uint32]*LLOChannelDefinitionProto

func (*LLOOutcomeTelemetry) GetConfigDigest added in v0.1.1

func (x *LLOOutcomeTelemetry) GetConfigDigest() []byte

func (*LLOOutcomeTelemetry) GetDonId added in v0.1.1

func (x *LLOOutcomeTelemetry) GetDonId() uint32

func (*LLOOutcomeTelemetry) GetLifeCycleStage added in v0.1.1

func (x *LLOOutcomeTelemetry) GetLifeCycleStage() string

func (*LLOOutcomeTelemetry) GetObservationTimestampNanoseconds added in v0.1.1

func (x *LLOOutcomeTelemetry) GetObservationTimestampNanoseconds() uint64

func (*LLOOutcomeTelemetry) GetSeqNr added in v0.1.1

func (x *LLOOutcomeTelemetry) GetSeqNr() uint64

func (*LLOOutcomeTelemetry) GetStreamAggregates added in v0.1.1

func (x *LLOOutcomeTelemetry) GetStreamAggregates() map[uint32]*LLOAggregatorStreamValue

func (*LLOOutcomeTelemetry) GetValidAfterNanoseconds added in v0.1.1

func (x *LLOOutcomeTelemetry) GetValidAfterNanoseconds() map[uint32]uint64

func (*LLOOutcomeTelemetry) ProtoMessage added in v0.1.1

func (*LLOOutcomeTelemetry) ProtoMessage()

func (*LLOOutcomeTelemetry) ProtoReflect added in v0.1.1

func (x *LLOOutcomeTelemetry) ProtoReflect() protoreflect.Message

func (*LLOOutcomeTelemetry) Reset added in v0.1.1

func (x *LLOOutcomeTelemetry) Reset()

func (*LLOOutcomeTelemetry) String added in v0.1.1

func (x *LLOOutcomeTelemetry) String() string

type LLOReportTelemetry added in v0.1.1

type LLOReportTelemetry struct {
	ChannelId                       uint32                 `protobuf:"varint,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
	ValidAfterNanoseconds           uint64                 `` /* 127-byte string literal not displayed */
	ObservationTimestampNanoseconds uint64                 `` /* 157-byte string literal not displayed */
	ReportFormat                    uint32                 `protobuf:"varint,4,opt,name=report_format,json=reportFormat,proto3" json:"report_format,omitempty"`
	Specimen                        bool                   `protobuf:"varint,5,opt,name=specimen,proto3" json:"specimen,omitempty"`
	StreamDefinitions               []*LLOStreamDefinition `protobuf:"bytes,6,rep,name=stream_definitions,json=streamDefinitions,proto3" json:"stream_definitions,omitempty"`
	StreamValues                    []*LLOStreamValue      `protobuf:"bytes,7,rep,name=stream_values,json=streamValues,proto3" json:"stream_values,omitempty"`
	ChannelOpts                     []byte                 `protobuf:"bytes,8,opt,name=channel_opts,json=channelOpts,proto3" json:"channel_opts,omitempty"`
	SeqNr                           uint64                 `protobuf:"varint,9,opt,name=seq_nr,json=seqNr,proto3" json:"seq_nr,omitempty"`
	ConfigDigest                    []byte                 `protobuf:"bytes,10,opt,name=config_digest,json=configDigest,proto3" json:"config_digest,omitempty"`
	DonId                           uint32                 `protobuf:"varint,11,opt,name=don_id,json=donId,proto3" json:"don_id,omitempty"`
	// contains filtered or unexported fields
}

LLOReportTelemetry sent for each report on every call to Reports

func (*LLOReportTelemetry) Descriptor deprecated added in v0.1.1

func (*LLOReportTelemetry) Descriptor() ([]byte, []int)

Deprecated: Use LLOReportTelemetry.ProtoReflect.Descriptor instead.

func (*LLOReportTelemetry) GetChannelId added in v0.1.1

func (x *LLOReportTelemetry) GetChannelId() uint32

func (*LLOReportTelemetry) GetChannelOpts added in v0.1.1

func (x *LLOReportTelemetry) GetChannelOpts() []byte

func (*LLOReportTelemetry) GetConfigDigest added in v0.1.1

func (x *LLOReportTelemetry) GetConfigDigest() []byte

func (*LLOReportTelemetry) GetDonId added in v0.1.1

func (x *LLOReportTelemetry) GetDonId() uint32

func (*LLOReportTelemetry) GetObservationTimestampNanoseconds added in v0.1.1

func (x *LLOReportTelemetry) GetObservationTimestampNanoseconds() uint64

func (*LLOReportTelemetry) GetReportFormat added in v0.1.1

func (x *LLOReportTelemetry) GetReportFormat() uint32

func (*LLOReportTelemetry) GetSeqNr added in v0.1.1

func (x *LLOReportTelemetry) GetSeqNr() uint64

func (*LLOReportTelemetry) GetSpecimen added in v0.1.1

func (x *LLOReportTelemetry) GetSpecimen() bool

func (*LLOReportTelemetry) GetStreamDefinitions added in v0.1.1

func (x *LLOReportTelemetry) GetStreamDefinitions() []*LLOStreamDefinition

func (*LLOReportTelemetry) GetStreamValues added in v0.1.1

func (x *LLOReportTelemetry) GetStreamValues() []*LLOStreamValue

func (*LLOReportTelemetry) GetValidAfterNanoseconds added in v0.1.1

func (x *LLOReportTelemetry) GetValidAfterNanoseconds() uint64

func (*LLOReportTelemetry) ProtoMessage added in v0.1.1

func (*LLOReportTelemetry) ProtoMessage()

func (*LLOReportTelemetry) ProtoReflect added in v0.1.1

func (x *LLOReportTelemetry) ProtoReflect() protoreflect.Message

func (*LLOReportTelemetry) Reset added in v0.1.1

func (x *LLOReportTelemetry) Reset()

func (*LLOReportTelemetry) String added in v0.1.1

func (x *LLOReportTelemetry) String() string

type LLOStreamAggregate

type LLOStreamAggregate struct {
	StreamID    uint32          `protobuf:"varint,1,opt,name=streamID,proto3" json:"streamID,omitempty"`
	StreamValue *LLOStreamValue `protobuf:"bytes,2,opt,name=streamValue,proto3" json:"streamValue,omitempty"`
	Aggregator  uint32          `protobuf:"varint,3,opt,name=aggregator,proto3" json:"aggregator,omitempty"`
	// contains filtered or unexported fields
}

func StreamAggregatesToProtoOutcome

func StreamAggregatesToProtoOutcome(in StreamAggregates) (out []*LLOStreamAggregate, err error)

func (*LLOStreamAggregate) Descriptor deprecated

func (*LLOStreamAggregate) Descriptor() ([]byte, []int)

Deprecated: Use LLOStreamAggregate.ProtoReflect.Descriptor instead.

func (*LLOStreamAggregate) GetAggregator

func (x *LLOStreamAggregate) GetAggregator() uint32

func (*LLOStreamAggregate) GetStreamID

func (x *LLOStreamAggregate) GetStreamID() uint32

func (*LLOStreamAggregate) GetStreamValue

func (x *LLOStreamAggregate) GetStreamValue() *LLOStreamValue

func (*LLOStreamAggregate) ProtoMessage

func (*LLOStreamAggregate) ProtoMessage()

func (*LLOStreamAggregate) ProtoReflect

func (x *LLOStreamAggregate) ProtoReflect() protoreflect.Message

func (*LLOStreamAggregate) Reset

func (x *LLOStreamAggregate) Reset()

func (*LLOStreamAggregate) String

func (x *LLOStreamAggregate) String() string

type LLOStreamDefinition

type LLOStreamDefinition struct {
	StreamID   uint32 `protobuf:"varint,1,opt,name=streamID,proto3" json:"streamID,omitempty"`
	Aggregator uint32 `protobuf:"varint,2,opt,name=aggregator,proto3" json:"aggregator,omitempty"`
	// contains filtered or unexported fields
}

func (*LLOStreamDefinition) Descriptor deprecated

func (*LLOStreamDefinition) Descriptor() ([]byte, []int)

Deprecated: Use LLOStreamDefinition.ProtoReflect.Descriptor instead.

func (*LLOStreamDefinition) GetAggregator

func (x *LLOStreamDefinition) GetAggregator() uint32

func (*LLOStreamDefinition) GetStreamID

func (x *LLOStreamDefinition) GetStreamID() uint32

func (*LLOStreamDefinition) ProtoMessage

func (*LLOStreamDefinition) ProtoMessage()

func (*LLOStreamDefinition) ProtoReflect

func (x *LLOStreamDefinition) ProtoReflect() protoreflect.Message

func (*LLOStreamDefinition) Reset

func (x *LLOStreamDefinition) Reset()

func (*LLOStreamDefinition) String

func (x *LLOStreamDefinition) String() string

type LLOStreamObservationProto

type LLOStreamObservationProto struct {
	Valid bool   `protobuf:"varint,1,opt,name=valid,proto3" json:"valid,omitempty"`
	Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*LLOStreamObservationProto) Descriptor deprecated

func (*LLOStreamObservationProto) Descriptor() ([]byte, []int)

Deprecated: Use LLOStreamObservationProto.ProtoReflect.Descriptor instead.

func (*LLOStreamObservationProto) GetValid

func (x *LLOStreamObservationProto) GetValid() bool

func (*LLOStreamObservationProto) GetValue

func (x *LLOStreamObservationProto) GetValue() []byte

func (*LLOStreamObservationProto) ProtoMessage

func (*LLOStreamObservationProto) ProtoMessage()

func (*LLOStreamObservationProto) ProtoReflect

func (*LLOStreamObservationProto) Reset

func (x *LLOStreamObservationProto) Reset()

func (*LLOStreamObservationProto) String

func (x *LLOStreamObservationProto) String() string

type LLOStreamValue

type LLOStreamValue struct {
	Type  LLOStreamValue_Type `protobuf:"varint,1,opt,name=type,proto3,enum=v1.LLOStreamValue_Type" json:"type,omitempty"`
	Value []byte              `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*LLOStreamValue) Descriptor deprecated

func (*LLOStreamValue) Descriptor() ([]byte, []int)

Deprecated: Use LLOStreamValue.ProtoReflect.Descriptor instead.

func (*LLOStreamValue) GetType

func (x *LLOStreamValue) GetType() LLOStreamValue_Type

func (*LLOStreamValue) GetValue

func (x *LLOStreamValue) GetValue() []byte

func (*LLOStreamValue) ProtoMessage

func (*LLOStreamValue) ProtoMessage()

func (*LLOStreamValue) ProtoReflect

func (x *LLOStreamValue) ProtoReflect() protoreflect.Message

func (*LLOStreamValue) Reset

func (x *LLOStreamValue) Reset()

func (*LLOStreamValue) String

func (x *LLOStreamValue) String() string

type LLOStreamValueQuote

type LLOStreamValueQuote struct {
	Bid       []byte `protobuf:"bytes,1,opt,name=bid,proto3" json:"bid,omitempty"`
	Benchmark []byte `protobuf:"bytes,2,opt,name=benchmark,proto3" json:"benchmark,omitempty"`
	Ask       []byte `protobuf:"bytes,3,opt,name=ask,proto3" json:"ask,omitempty"`
	// contains filtered or unexported fields
}

func (*LLOStreamValueQuote) Descriptor deprecated

func (*LLOStreamValueQuote) Descriptor() ([]byte, []int)

Deprecated: Use LLOStreamValueQuote.ProtoReflect.Descriptor instead.

func (*LLOStreamValueQuote) GetAsk

func (x *LLOStreamValueQuote) GetAsk() []byte

func (*LLOStreamValueQuote) GetBenchmark

func (x *LLOStreamValueQuote) GetBenchmark() []byte

func (*LLOStreamValueQuote) GetBid

func (x *LLOStreamValueQuote) GetBid() []byte

func (*LLOStreamValueQuote) ProtoMessage

func (*LLOStreamValueQuote) ProtoMessage()

func (*LLOStreamValueQuote) ProtoReflect

func (x *LLOStreamValueQuote) ProtoReflect() protoreflect.Message

func (*LLOStreamValueQuote) Reset

func (x *LLOStreamValueQuote) Reset()

func (*LLOStreamValueQuote) String

func (x *LLOStreamValueQuote) String() string

type LLOStreamValue_Type

type LLOStreamValue_Type int32
const (
	LLOStreamValue_Decimal                LLOStreamValue_Type = 0
	LLOStreamValue_Quote                  LLOStreamValue_Type = 1
	LLOStreamValue_TimestampedStreamValue LLOStreamValue_Type = 2
)

func (LLOStreamValue_Type) Descriptor

func (LLOStreamValue_Type) Enum

func (LLOStreamValue_Type) EnumDescriptor deprecated

func (LLOStreamValue_Type) EnumDescriptor() ([]byte, []int)

Deprecated: Use LLOStreamValue_Type.Descriptor instead.

func (LLOStreamValue_Type) Number

func (LLOStreamValue_Type) String

func (x LLOStreamValue_Type) String() string

func (LLOStreamValue_Type) Type

type LLOTimestampedStreamValue added in v0.1.1

type LLOTimestampedStreamValue struct {
	ObservedAtNanoseconds uint64          `protobuf:"varint,1,opt,name=observedAtNanoseconds,proto3" json:"observedAtNanoseconds,omitempty"`
	StreamValue           *LLOStreamValue `protobuf:"bytes,2,opt,name=streamValue,proto3" json:"streamValue,omitempty"`
	// contains filtered or unexported fields
}

func (*LLOTimestampedStreamValue) Descriptor deprecated added in v0.1.1

func (*LLOTimestampedStreamValue) Descriptor() ([]byte, []int)

Deprecated: Use LLOTimestampedStreamValue.ProtoReflect.Descriptor instead.

func (*LLOTimestampedStreamValue) GetObservedAtNanoseconds added in v0.1.1

func (x *LLOTimestampedStreamValue) GetObservedAtNanoseconds() uint64

func (*LLOTimestampedStreamValue) GetStreamValue added in v0.1.1

func (x *LLOTimestampedStreamValue) GetStreamValue() *LLOStreamValue

func (*LLOTimestampedStreamValue) ProtoMessage added in v0.1.1

func (*LLOTimestampedStreamValue) ProtoMessage()

func (*LLOTimestampedStreamValue) ProtoReflect added in v0.1.1

func (*LLOTimestampedStreamValue) Reset added in v0.1.1

func (x *LLOTimestampedStreamValue) Reset()

func (*LLOTimestampedStreamValue) String added in v0.1.1

func (x *LLOTimestampedStreamValue) String() string

type Observation

type Observation struct {
	// Attested (i.e. signed by f+1 oracles) retirement report from predecessor
	// protocol instance
	AttestedPredecessorRetirement []byte
	// Should this protocol instance be retired?
	ShouldRetire bool
	// Timestamp from when observation is made
	// Note that this is the timestamp immediately before we initiate any
	// observations
	UnixTimestampNanoseconds uint64
	// Votes to remove/add channels. Subject to MAX_OBSERVATION_*_LENGTH limits
	RemoveChannelIDs map[llotypes.ChannelID]struct{}
	// Votes to add or replace channel definitions
	UpdateChannelDefinitions llotypes.ChannelDefinitions
	// Observed (numeric) stream values. Subject to
	// MaxObservationStreamValuesLength limit
	StreamValues StreamValues
}

type ObservationCodec

type ObservationCodec interface {
	Encode(obs Observation) (types.Observation, error)
	Decode(encoded types.Observation) (obs Observation, err error)
}

func NewProtoObservationCodec added in v0.1.1

func NewProtoObservationCodec(lggr logger.Logger, enableCompression bool) (ObservationCodec, error)

type OffchainConfig

type OffchainConfig struct {
	ProtocolVersion uint32
	// DefaultMinReportIntervalNanoseconds is the default minimum report interval in nanoseconds.
	// It must be set to 0 for protocol version 0.
	// It must be set to 1 or greater for protocol version 1+.
	//
	// NOTE: This merely controls the _minimum_ interval between reports. It
	// does not guarantee a maximum interval. If you want reports to be
	// produced quickly, you are still limited by OCR3's DeltaRound and
	// DeltaGrace params, as well as networking latency.
	DefaultMinReportIntervalNanoseconds uint64
	// EnableObservationCompression enables observation compression.
	EnableObservationCompression bool
}

func DecodeOffchainConfig

func DecodeOffchainConfig(b []byte) (o OffchainConfig, err error)

func (OffchainConfig) Encode

func (c OffchainConfig) Encode() ([]byte, error)

func (OffchainConfig) GetOutcomeCodec added in v0.1.1

func (c OffchainConfig) GetOutcomeCodec() OutcomeCodec

func (OffchainConfig) Validate added in v0.1.1

func (c OffchainConfig) Validate() error

type OnchainConfig added in v0.1.1

type OnchainConfig struct {
	Version                 uint8
	PredecessorConfigDigest *types.ConfigDigest
}

type OnchainConfigCodec added in v0.1.1

type OnchainConfigCodec interface {
	Decode(b []byte) (OnchainConfig, error)
	Encode(OnchainConfig) ([]byte, error)
}

type Outcome

type Outcome struct {
	// LifeCycleStage the protocol is in
	LifeCycleStage llotypes.LifeCycleStage
	// ObservationTimestampNanoseconds is the median timestamp from the
	// latest set of observations
	ObservationTimestampNanoseconds uint64
	// ChannelDefinitions defines the set & structure of channels for which we
	// generate reports
	ChannelDefinitions llotypes.ChannelDefinitions
	// Latest ValidAfterNanoseconds value for each channel, reports for each channel
	// span from ValidAfterNanoseconds to ObservationTimestampNanoseconds
	ValidAfterNanoseconds map[llotypes.ChannelID]uint64
	// StreamAggregates contains stream IDs mapped to various aggregations.
	// Usually you will only have one aggregation type per stream but since
	// channels can define different aggregation methods, sometimes we will
	// need multiple.
	StreamAggregates StreamAggregates
}

func (*Outcome) GenRetirementReport added in v0.1.1

func (out *Outcome) GenRetirementReport(protocolVersion uint32) RetirementReport

func (*Outcome) IsReportable

func (out *Outcome) IsReportable(channelID llotypes.ChannelID, protocolVersion uint32, minReportInterval uint64) *UnreportableChannelError

Indicates whether a report can be generated for the given channel. Returns nil if channel is reportable NOTE: A channel is still reportable even if missing some or all stream values. The report codec is expected to handle nils and act accordingly (e.g. some values may be optional).

func (*Outcome) ReportableChannels

func (out *Outcome) ReportableChannels(protocolVersion uint32, defaultMinReportInterval uint64) (reportable []llotypes.ChannelID, unreportable []*UnreportableChannelError)

List of reportable channels (according to IsReportable), sorted according to a canonical ordering

type OutcomeCodec

type OutcomeCodec interface {
	Encode(outcome Outcome) (ocr3types.Outcome, error)
	Decode(encoded ocr3types.Outcome) (outcome Outcome, err error)
}

type Plugin

type Plugin struct {
	Config                           Config
	PredecessorConfigDigest          *types.ConfigDigest
	ConfigDigest                     types.ConfigDigest
	PredecessorRetirementReportCache PredecessorRetirementReportCache
	ShouldRetireCache                ShouldRetireCache
	ChannelDefinitionCache           ChannelDefinitionCache
	DataSource                       DataSource
	Logger                           logger.Logger
	N                                int
	F                                int
	ObservationCodec                 ObservationCodec
	OutcomeCodec                     OutcomeCodec
	RetirementReportCodec            RetirementReportCodec
	ReportCodecs                     map[llotypes.ReportFormat]ReportCodec
	OutcomeTelemetryCh               chan<- *LLOOutcomeTelemetry
	ReportTelemetryCh                chan<- *LLOReportTelemetry
	DonID                            uint32

	// From ReportingPluginConfig
	MaxDurationObservation time.Duration

	// From offchain config
	ProtocolVersion                     uint32
	DefaultMinReportIntervalNanoseconds uint64
}

func (*Plugin) Close

func (p *Plugin) Close() error

func (*Plugin) Observation

func (p *Plugin) Observation(ctx context.Context, outctx ocr3types.OutcomeContext, query types.Query) (types.Observation, error)

Observation gets an observation from the underlying data source. Returns a value or an error.

You may assume that the outctx.SeqNr is increasing monotonically (though *not* strictly) across the lifetime of a protocol instance and that outctx.previousOutcome contains the consensus outcome with sequence number (outctx.SeqNr-1).

Should return a serialized Observation struct.

func (*Plugin) ObservationQuorum

func (p *Plugin) ObservationQuorum(ctx context.Context, outctx ocr3types.OutcomeContext, query types.Query, aos []types.AttributedObservation) (bool, error)

ObservationQuorum returns the minimum number of valid (according to ValidateObservation) observations needed to construct an outcome.

This function should be pure. Don't do anything slow in here.

This is an advanced feature. The "default" approach (what OCR1 & OCR2 did) is to have an empty ValidateObservation function and return QuorumTwoFPlusOne from this function.

func (*Plugin) Outcome

Generates an outcome for a seqNr, typically based on the previous outcome, the current query, and the current set of attributed observations.

This function should be pure. Don't do anything slow in here.

You may assume that the outctx.SeqNr is increasing monotonically (though *not* strictly) across the lifetime of a protocol instance and that outctx.previousOutcome contains the consensus outcome with sequence number (outctx.SeqNr-1).

libocr guarantees that this will always be called with at least 2f+1 AttributedObservations

func (*Plugin) ProcessCalculatedStreams added in v0.1.1

func (p *Plugin) ProcessCalculatedStreams(outcome *Outcome)

ProcessCalculatedStreams evaluates expressions for each channel of the EncodeUnpackedExpr format and returns each result as a decimal.Decimal

func (*Plugin) ProcessCalculatedStreamsDryRun added in v0.1.1

func (p *Plugin) ProcessCalculatedStreamsDryRun(expression string) error

ProcessCalculatedStreamsDryRun processes the calculated streams for the given expressions and returns the outcome with the calculated streams, useful for testing.

func (*Plugin) Query

func (p *Plugin) Query(ctx context.Context, outctx ocr3types.OutcomeContext) (types.Query, error)

Query creates a Query that is sent from the leader to all follower nodes as part of the request for an observation. Be careful! A malicious leader could equivocate (i.e. send different queries to different followers.) Many applications will likely be better off always using an empty query if the oracles don't need to coordinate on what to observe (e.g. in case of a price feed) or the underlying data source offers an (eventually) consistent view to different oracles (e.g. in case of observing a blockchain).

You may assume that the outctx.SeqNr is increasing monotonically (though *not* strictly) across the lifetime of a protocol instance and that outctx.previousOutcome contains the consensus outcome with sequence number (outctx.SeqNr-1).

func (*Plugin) Reports

func (p *Plugin) Reports(ctx context.Context, seqNr uint64, rawOutcome ocr3types.Outcome) ([]ocr3types.ReportPlus[llotypes.ReportInfo], error)

Generates a (possibly empty) list of reports from an outcome. Each report will be signed and possibly be transmitted to the contract. (Depending on ShouldAcceptAttestedReport & ShouldTransmitAcceptedReport)

This function should be pure. Don't do anything slow in here.

This is likely to change in the future. It will likely be returning a list of report batches, where each batch goes into its own Merkle tree.

You may assume that the outctx.SeqNr is increasing monotonically (though *not* strictly) across the lifetime of a protocol instance and that outctx.previousOutcome contains the consensus outcome with sequence number (outctx.SeqNr-1).

func (*Plugin) ShouldAcceptAttestedReport

func (p *Plugin) ShouldAcceptAttestedReport(context.Context, uint64, ocr3types.ReportWithInfo[llotypes.ReportInfo]) (bool, error)

func (*Plugin) ShouldTransmitAcceptedReport

func (p *Plugin) ShouldTransmitAcceptedReport(context.Context, uint64, ocr3types.ReportWithInfo[llotypes.ReportInfo]) (bool, error)

func (*Plugin) ValidateObservation

func (p *Plugin) ValidateObservation(ctx context.Context, outctx ocr3types.OutcomeContext, query types.Query, ao types.AttributedObservation) error

Should return an error if an observation isn't well-formed. Non-well-formed observations will be discarded by the protocol. This is called for each observation, don't do anything slow in here.

You may assume that the outctx.SeqNr is increasing monotonically (though *not* strictly) across the lifetime of a protocol instance and that outctx.previousOutcome contains the consensus outcome with sequence number (outctx.SeqNr-1).

type PluginFactoryParams added in v0.1.1

type PluginFactoryParams struct {
	Config
	PredecessorRetirementReportCache
	ShouldRetireCache
	RetirementReportCodec
	ChannelDefinitionCache
	DataSource
	logger.Logger
	OnchainConfigCodec
	ReportCodecs map[llotypes.ReportFormat]ReportCodec
	// LLOOutcomeTelemetryCh if set will be used to send one telemetry struct per
	// round in the Outcome stage
	OutcomeTelemetryCh chan<- *LLOOutcomeTelemetry
	// ReportTelemetryCh if set will be used to send one telemetry struct per
	// transmissible report in the Report stage
	ReportTelemetryCh chan<- *LLOReportTelemetry
	// DonID is optional and used only for telemetry and logging
	DonID uint32
}

type PredecessorRetirementReportCache

type PredecessorRetirementReportCache interface {
	// AttestedRetirementReport returns the attested retirement report for the
	// given config digest from the local cache.
	//
	// This should return nil and not error in the case of a missing attested
	// retirement report.
	AttestedRetirementReport(predecessorConfigDigest ocr2types.ConfigDigest) ([]byte, error)
	// CheckAttestedRetirementReport verifies that an attested retirement
	// report, which may have come from another node, is valid (signed) with
	// signers corresponding to the given config digest
	CheckAttestedRetirementReport(predecessorConfigDigest ocr2types.ConfigDigest, attestedRetirementReport []byte) (RetirementReport, error)
}

The predecessor protocol instance stores its attested retirement report in this cache (locally, offchain), so it can be fetched by the successor protocol instance.

PredecessorRetirementReportCache is populated by the old protocol instance writing to it and the new protocol instance reading from it.

The sketch envisions it being implemented as a single object that is shared between different protocol instances.

type Quote

type Quote struct {
	Bid       decimal.Decimal
	Benchmark decimal.Decimal
	Ask       decimal.Decimal
}

func (*Quote) IsValid

func (v *Quote) IsValid() bool

func (*Quote) MarshalBinary

func (v *Quote) MarshalBinary() (b []byte, err error)

func (*Quote) MarshalText

func (v *Quote) MarshalText() ([]byte, error)

func (*Quote) Type

func (v *Quote) Type() LLOStreamValue_Type

func (*Quote) UnmarshalBinary

func (v *Quote) UnmarshalBinary(data []byte) error

func (*Quote) UnmarshalText

func (v *Quote) UnmarshalText(data []byte) error

type Report

type Report struct {
	ConfigDigest types.ConfigDigest
	// OCR sequence number of this report
	SeqNr uint64
	// Channel that is being reported on
	ChannelID llotypes.ChannelID
	// Report is only valid at t > ValidAfterNanoseconds
	// ValidAfterNanoseconds < ObservationTimestampNanoseconds always, by enforcement
	// in IsReportable
	ValidAfterNanoseconds uint64
	// ObservationTimestampNanoseconds is the median of all observation timestamps
	// (note that this timestamp is taken immediately before we initiate any
	// observations)
	ObservationTimestampNanoseconds uint64
	// Values for every stream in the channel
	Values []StreamValue
	// The contract onchain will only validate non-specimen reports. A staging
	// protocol instance will generate specimen reports so we can validate it
	// works properly without any risk of misreports landing on chain.
	Specimen bool
}

type ReportCodec

type ReportCodec interface {
	// Encode may be lossy, so no Decode function is expected
	// Encode should handle nil stream aggregate values without panicking (it
	// may return error instead)
	Encode(Report, llotypes.ChannelDefinition) ([]byte, error)
	// Verify may optionally verify a channel definition to ensure it is valid
	// for the given report codec. If a codec does not wish to implement
	// validation it may simply return nil here. If any definition fails
	// validation, the entire channel definitions file will be rejected.
	// This can be useful to ensure that e.g. options aren't changed
	// accidentally to something that would later break a report on encoding.
	Verify(llotypes.ChannelDefinition) error
}

type RetirementReport

type RetirementReport struct {
	// Retirement reports are not guaranteed to be compatible across different
	// protocol versions
	ProtocolVersion uint32
	// Carries validity time stamps between protocol instances to ensure there
	// are no gaps
	ValidAfterNanoseconds map[llotypes.ChannelID]uint64
}

type RetirementReportCodec added in v0.1.1

type RetirementReportCodec interface {
	Encode(RetirementReport) ([]byte, error)
	Decode([]byte) (RetirementReport, error)
}

type ShouldRetireCache

type ShouldRetireCache interface {
	// Should the protocol instance retire according to the configuration
	// contract?
	// See: https://github.com/smartcontractkit/mercury-v1-sketch/blob/main/onchain/src/ConfigurationStore.sol#L18
	ShouldRetire(digest ocr2types.ConfigDigest) (bool, error)
}

type StandardRetirementReportCodec added in v0.1.1

type StandardRetirementReportCodec struct{}

func (StandardRetirementReportCodec) Decode added in v0.1.1

func (StandardRetirementReportCodec) Encode added in v0.1.1

type StreamAggregates

type StreamAggregates map[llotypes.StreamID]map[llotypes.Aggregator]StreamValue

type StreamValue

type StreamValue interface {
	// Binary marshaler/unmarshaler used for protobufs
	// Unmarshal should NOT panic on nil receiver, but instead return ErrNilStreamValue
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
	// TextMarshaler needed for JSON serialization and logging
	// Unmarshal should NOT panic on nil receiver, but instead return ErrNilStreamValue
	encoding.TextMarshaler
	encoding.TextUnmarshaler
	// Type is needed for proto serialization so we know how to unserialize it
	Type() LLOStreamValue_Type
}

func MedianAggregator

func MedianAggregator(values []StreamValue, f int) (StreamValue, error)

func ModeAggregator

func ModeAggregator(values []StreamValue, f int) (StreamValue, error)

ModeAggregator works on arbitrary StreamValue types It picks the most common value There must be at least f+1 observations in agreement in order to produce a value nil observations are ignored

func QuoteAggregator

func QuoteAggregator(values []StreamValue, f int) (StreamValue, error)

func UnmarshalProtoStreamValue

func UnmarshalProtoStreamValue(enc *LLOStreamValue) (sv StreamValue, err error)

func UnmarshalTypedTextStreamValue added in v0.1.1

func UnmarshalTypedTextStreamValue(enc *TypedTextStreamValue) (StreamValue, error)

type StreamValues

type StreamValues map[llotypes.StreamID]StreamValue

Values for a set of streams, e.g. "eth-usd", "link-usd", "eur-chf" etc StreamIDs are uint32

type TimestampedStreamValue added in v0.1.1

type TimestampedStreamValue struct {
	ObservedAtNanoseconds uint64      `json:"observedAtNanoseconds"`
	StreamValue           StreamValue `json:"streamValue"`
}

TimestampedStreamValue is a StreamValue with an associated timestamp

func (*TimestampedStreamValue) MarshalBinary added in v0.1.1

func (v *TimestampedStreamValue) MarshalBinary() ([]byte, error)

func (*TimestampedStreamValue) MarshalText added in v0.1.1

func (v *TimestampedStreamValue) MarshalText() ([]byte, error)

func (*TimestampedStreamValue) Type added in v0.1.1

func (*TimestampedStreamValue) UnmarshalBinary added in v0.1.1

func (v *TimestampedStreamValue) UnmarshalBinary(data []byte) error

func (*TimestampedStreamValue) UnmarshalText added in v0.1.1

func (v *TimestampedStreamValue) UnmarshalText(data []byte) error

type Transmitter

type Transmitter interface {
	// NOTE: Mercury doesn't actually transmit on-chain, so there is no
	// "contract" involved with the transmitter.
	// - Transmit should be implemented and send to Mercury server
	// - FromAccount() should return CSA public key
	ocr3types.ContractTransmitter[llotypes.ReportInfo]
}

type TypedTextStreamValue added in v0.1.1

type TypedTextStreamValue struct {
	Type                  LLOStreamValue_Type `json:"t"`
	SerializedStreamValue string              `json:"v"`
}

func NewTypedTextStreamValue added in v0.1.1

func NewTypedTextStreamValue(sv StreamValue) (TypedTextStreamValue, error)

type UnreportableChannelError added in v0.1.1

type UnreportableChannelError struct {
	Inner     error `json:",omitempty"`
	Reason    string
	ChannelID llotypes.ChannelID
}

func (*UnreportableChannelError) Error added in v0.1.1

func (e *UnreportableChannelError) Error() string

func (*UnreportableChannelError) String added in v0.1.1

func (e *UnreportableChannelError) String() string

func (*UnreportableChannelError) Unwrap added in v0.1.1

func (e *UnreportableChannelError) Unwrap() error

Directories

Path Synopsis
reportcodecs
evm

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL