Documentation
¶
Index ¶
- Variables
- func DecodeValue(s []byte) (*big.Int, error)
- func Deviates(thresholdPPB uint64, old *big.Int, new *big.Int) bool
- func EncodeValue(i *big.Int) ([]byte, error)
- func MaxValue() *big.Int
- func MinValue() *big.Int
- type DataSource
- type MedianContract
- type NumericalMedianConfigProto
- func (*NumericalMedianConfigProto) Descriptor() ([]byte, []int)deprecated
- func (x *NumericalMedianConfigProto) GetAlphaAcceptInfinite() bool
- func (x *NumericalMedianConfigProto) GetAlphaAcceptPpb() uint64
- func (x *NumericalMedianConfigProto) GetAlphaReportInfinite() bool
- func (x *NumericalMedianConfigProto) GetAlphaReportPpb() uint64
- func (x *NumericalMedianConfigProto) GetDeltaCNanoseconds() uint64
- func (*NumericalMedianConfigProto) ProtoMessage()
- func (x *NumericalMedianConfigProto) ProtoReflect() protoreflect.Message
- func (x *NumericalMedianConfigProto) Reset()
- func (x *NumericalMedianConfigProto) String() string
- type NumericalMedianFactory
- type NumericalMedianObservationProto
- func (*NumericalMedianObservationProto) Descriptor() ([]byte, []int)deprecated
- func (x *NumericalMedianObservationProto) GetJuelsPerFeeCoin() []byte
- func (x *NumericalMedianObservationProto) GetTimestamp() uint32
- func (x *NumericalMedianObservationProto) GetValue() []byte
- func (*NumericalMedianObservationProto) ProtoMessage()
- func (x *NumericalMedianObservationProto) ProtoReflect() protoreflect.Message
- func (x *NumericalMedianObservationProto) Reset()
- func (x *NumericalMedianObservationProto) String() string
- type OffchainConfig
- type OnchainConfig
- type OnchainConfigCodec
- type ParsedAttributedObservation
- type ReportCodec
- type StandardOnchainConfigCodec
Constants ¶
This section is empty.
Variables ¶
var File_offchainreporting2_median_config_proto protoreflect.FileDescriptor
var File_offchainreporting2_median_observation_proto protoreflect.FileDescriptor
Functions ¶
func DecodeValue ¶
Decodes a value using 24-byte big endian two's complement representation. This function never panics.
func EncodeValue ¶
Encodes a value using 24-byte big endian two's complement representation. This function never panics.
Types ¶
type DataSource ¶
type DataSource interface {
// Observe queries the data source. Returns a value or an error. Once the
// context is expires, Observe may still do cheap computations and return a
// result, but should return as quickly as possible.
//
// More details: In the current implementation, the context passed to
// Observe will time out after MaxDurationObservation. However, Observe
// should *not* make any assumptions about context timeout behavior. Once
// the context times out, Observe should prioritize returning as quickly as
// possible, but may still perform fast computations to return a result
// rather than error. For example, if Observe medianizes a number of data
// sources, some of which already returned a result to Observe prior to the
// context's expiry, Observe might still compute their median, and return it
// instead of an error.
//
// Important: Observe should not perform any potentially time-consuming
// actions like database access, once the context passed has expired.
Observe(context.Context, types.ReportTimestamp) (*big.Int, error)
}
DataSource implementations must be thread-safe. Observe may be called by many different threads concurrently.
type MedianContract ¶
type MedianContract interface {
LatestTransmissionDetails(
ctx context.Context,
) (
configDigest types.ConfigDigest,
epoch uint32,
round uint8,
latestAnswer *big.Int,
latestTimestamp time.Time,
err error,
)
// LatestRoundRequested returns the configDigest, epoch, and round from the latest
// RoundRequested event emitted by the contract. LatestRoundRequested may or may not
// return a result if the latest such event was emitted in a block b such that
// b.timestamp < tip.timestamp - lookback.
//
// If no event is found, LatestRoundRequested should return zero values, not an error.
// An error should only be returned if an actual error occurred during execution,
// e.g. because there was an error querying the blockchain or the database.
//
// As an optimization, this function may also return zero values, if no
// RoundRequested event has been emitted after the latest NewTransmission event.
LatestRoundRequested(
ctx context.Context,
lookback time.Duration,
) (
configDigest types.ConfigDigest,
epoch uint32,
round uint8,
err error,
)
}
type NumericalMedianConfigProto ¶
type NumericalMedianConfigProto struct {
AlphaReportInfinite bool `protobuf:"varint,1,opt,name=alpha_report_infinite,json=alphaReportInfinite,proto3" json:"alpha_report_infinite,omitempty"`
AlphaReportPpb uint64 `protobuf:"varint,2,opt,name=alpha_report_ppb,json=alphaReportPpb,proto3" json:"alpha_report_ppb,omitempty"`
AlphaAcceptInfinite bool `protobuf:"varint,3,opt,name=alpha_accept_infinite,json=alphaAcceptInfinite,proto3" json:"alpha_accept_infinite,omitempty"`
AlphaAcceptPpb uint64 `protobuf:"varint,4,opt,name=alpha_accept_ppb,json=alphaAcceptPpb,proto3" json:"alpha_accept_ppb,omitempty"`
DeltaCNanoseconds uint64 `protobuf:"varint,5,opt,name=delta_c_nanoseconds,json=deltaCNanoseconds,proto3" json:"delta_c_nanoseconds,omitempty"`
// contains filtered or unexported fields
}
func (*NumericalMedianConfigProto) Descriptor
deprecated
func (*NumericalMedianConfigProto) Descriptor() ([]byte, []int)
Deprecated: Use NumericalMedianConfigProto.ProtoReflect.Descriptor instead.
func (*NumericalMedianConfigProto) GetAlphaAcceptInfinite ¶
func (x *NumericalMedianConfigProto) GetAlphaAcceptInfinite() bool
func (*NumericalMedianConfigProto) GetAlphaAcceptPpb ¶
func (x *NumericalMedianConfigProto) GetAlphaAcceptPpb() uint64
func (*NumericalMedianConfigProto) GetAlphaReportInfinite ¶
func (x *NumericalMedianConfigProto) GetAlphaReportInfinite() bool
func (*NumericalMedianConfigProto) GetAlphaReportPpb ¶
func (x *NumericalMedianConfigProto) GetAlphaReportPpb() uint64
func (*NumericalMedianConfigProto) GetDeltaCNanoseconds ¶
func (x *NumericalMedianConfigProto) GetDeltaCNanoseconds() uint64
func (*NumericalMedianConfigProto) ProtoMessage ¶
func (*NumericalMedianConfigProto) ProtoMessage()
func (*NumericalMedianConfigProto) ProtoReflect ¶
func (x *NumericalMedianConfigProto) ProtoReflect() protoreflect.Message
func (*NumericalMedianConfigProto) Reset ¶
func (x *NumericalMedianConfigProto) Reset()
func (*NumericalMedianConfigProto) String ¶
func (x *NumericalMedianConfigProto) String() string
type NumericalMedianFactory ¶
type NumericalMedianFactory struct {
ContractTransmitter MedianContract
DataSource DataSource
JuelsPerFeeCoinDataSource DataSource
Logger commontypes.Logger
OnchainConfigCodec OnchainConfigCodec
ReportCodec ReportCodec
}
func (NumericalMedianFactory) NewReportingPlugin ¶
func (fac NumericalMedianFactory) NewReportingPlugin(configuration types.ReportingPluginConfig) (types.ReportingPlugin, types.ReportingPluginInfo, error)
type NumericalMedianObservationProto ¶
type NumericalMedianObservationProto struct {
Timestamp uint32 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
JuelsPerFeeCoin []byte `protobuf:"bytes,3,opt,name=juelsPerFeeCoin,proto3" json:"juelsPerFeeCoin,omitempty"`
// contains filtered or unexported fields
}
func (*NumericalMedianObservationProto) Descriptor
deprecated
func (*NumericalMedianObservationProto) Descriptor() ([]byte, []int)
Deprecated: Use NumericalMedianObservationProto.ProtoReflect.Descriptor instead.
func (*NumericalMedianObservationProto) GetJuelsPerFeeCoin ¶
func (x *NumericalMedianObservationProto) GetJuelsPerFeeCoin() []byte
func (*NumericalMedianObservationProto) GetTimestamp ¶
func (x *NumericalMedianObservationProto) GetTimestamp() uint32
func (*NumericalMedianObservationProto) GetValue ¶
func (x *NumericalMedianObservationProto) GetValue() []byte
func (*NumericalMedianObservationProto) ProtoMessage ¶
func (*NumericalMedianObservationProto) ProtoMessage()
func (*NumericalMedianObservationProto) ProtoReflect ¶
func (x *NumericalMedianObservationProto) ProtoReflect() protoreflect.Message
func (*NumericalMedianObservationProto) Reset ¶
func (x *NumericalMedianObservationProto) Reset()
func (*NumericalMedianObservationProto) String ¶
func (x *NumericalMedianObservationProto) String() string
type OffchainConfig ¶
type OffchainConfig struct {
// If AlphaReportInfinite is true, the deviation check parametrized by
// AlphaReportPPB will never be satisfied.
AlphaReportInfinite bool
// AlphaReportPPB determines the relative deviation between the median (i.e.
// answer) in the contract and the current median of observations (offchain)
// at which a report should be issued. That is, a report is issued if
// abs((offchainMedian - contractMedian)/contractMedian) >= alphaReport.
AlphaReportPPB uint64 // PPB is parts-per-billion
// If AlphaAcceptInfinite is true, the deviation check parametrized by
// AlphaAcceptPPB will never be satisfied.
AlphaAcceptInfinite bool
// AlphaAcceptPPB determines the relative deviation between the median in a
// newly generated report considered for transmission and the median of the
// currently pending report. That is, a report is accepted for transmission
// if abs((newMedian - pendingMedian)/pendingMedian) >= alphaAccept. If no
// report is pending, this variable has no effect.
AlphaAcceptPPB uint64 // PPB is parts-per-billion
// DeltaC is the maximum age of the latest report in the contract. If the
// maximum age is exceeded, a new report will be created by the report
// generation protocol.
DeltaC time.Duration
}
func DecodeOffchainConfig ¶
func DecodeOffchainConfig(b []byte) (OffchainConfig, error)
func (OffchainConfig) Encode ¶
func (c OffchainConfig) Encode() []byte
type OnchainConfigCodec ¶
type OnchainConfigCodec interface {
Encode(OnchainConfig) ([]byte, error)
Decode([]byte) (OnchainConfig, error)
}
type ReportCodec ¶
type ReportCodec interface {
// Implementers may assume that there is at most one
// ParsedAttributedObservation per observer, and that all observers are
// valid. However, observation values, timestamps, etc... should all be
// treated as untrusted.
BuildReport([]ParsedAttributedObservation) (types.Report, error)
// Gets the "median" (the n//2-th ranked element to be more precise where n
// is the length of the list) observation from the report. The input to this
// function should be an output of BuildReport in the benign case.
// Nevertheless, make sure to treat the input to this function as untrusted.
MedianFromReport(types.Report) (*big.Int, error)
// Returns the maximum length of a report based on n, the number of oracles.
// The output of BuildReport must respect this maximum length.
MaxReportLength(n int) (int, error)
}
All functions on ReportCodec should be pure and thread-safe. Be careful validating and parsing any data passed.
type StandardOnchainConfigCodec ¶
type StandardOnchainConfigCodec struct{}
StandardOnchainConfigCodec provides a standard implementation of OnchainConfigCodec. This is the implementation used by the EVM and Solana integrations.
An encoded onchain config is expected to be in the format <version><min><max> where version is a uint8 and min and max are in the format returned by EncodeValue.
func (StandardOnchainConfigCodec) Decode ¶
func (StandardOnchainConfigCodec) Decode(b []byte) (OnchainConfig, error)
func (StandardOnchainConfigCodec) Encode ¶
func (StandardOnchainConfigCodec) Encode(c OnchainConfig) ([]byte, error)