protocol

package
v0.0.0-...-fd3cab2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const ContractTransmitterTimeoutWarningGracePeriod = 50 * time.Millisecond
View Source
const ReportingPluginTimeoutWarningGracePeriod = 100 * time.Millisecond

Variables

This section is empty.

Functions

func Leader

func Leader(epoch uint32, n int, key [16]byte) (leader commontypes.OracleID)

Leader will produce an oracle id for the given epoch.

func RunOracle

func RunOracle(
	ctx context.Context,

	config ocr2config.SharedConfig,
	contractTransmitter types.ContractTransmitter,
	database types.Database,
	id commontypes.OracleID,
	localConfig types.LocalConfig,
	logger loghelper.LoggerWithContext,
	metricsRegisterer prometheus.Registerer,
	netEndpoint NetworkEndpoint,
	offchainKeyring types.OffchainKeyring,
	onchainKeyring types.OnchainKeyring,
	reportingPlugin types.ReportingPlugin,
	reportQuorum int,
	telemetrySender TelemetrySender,
)

RunOracle runs one oracle instance of the offchain reporting protocol and manages the lifecycle of all underlying goroutines.

RunOracle runs forever until ctx is cancelled. It will only shut down after all its sub-goroutines have exited.

func RunPacemaker

func RunPacemaker(
	ctx context.Context,
	subprocesses *subprocesses.Subprocesses,

	chNetToPacemaker <-chan MessageToPacemakerWithSender,
	chNetToReportGeneration <-chan MessageToReportGenerationWithSender,
	chPacemakerToOracle chan<- uint32,
	chReportGenerationToReportFinalization chan<- EventToReportFinalization,
	config ocr2config.SharedConfig,
	contractTransmitter types.ContractTransmitter,
	database types.Database,
	id commontypes.OracleID,
	localConfig types.LocalConfig,
	logger loghelper.LoggerWithContext,
	metricsRegisterer prometheus.Registerer,
	netSender NetworkSender,
	offchainKeyring types.OffchainKeyring,
	onchainKeyring types.OnchainKeyring,
	reportingPlugin types.ReportingPlugin,
	reportQuorum int,
	telemetrySender TelemetrySender,
)

Pacemaker keeps track of the state and message handling for an oracle participating in the off-chain reporting protocol

func RunReportFinalization

func RunReportFinalization(
	ctx context.Context,

	chNetToReportFinalization <-chan MessageToReportFinalizationWithSender,
	chReportFinalizationToTransmission chan<- EventToTransmission,
	chReportGenerationToReportFinalization <-chan EventToReportFinalization,
	config ocr2config.SharedConfig,
	contractSigner types.OnchainKeyring,
	logger loghelper.LoggerWithContext,
	netSender NetworkSender,
	reportQuorum int,
)

func RunReportGeneration

func RunReportGeneration(
	ctx context.Context,
	subprocesses *subprocesses.Subprocesses,

	chNetToReportGeneration <-chan MessageToReportGenerationWithSender,
	chReportGenerationToPacemaker chan<- EventToPacemaker,
	chReportGenerationToReportFinalization chan<- EventToReportFinalization,
	config ocr2config.SharedConfig,
	contractTransmitter types.ContractTransmitter,
	e uint32,
	id commontypes.OracleID,
	l commontypes.OracleID,
	localConfig types.LocalConfig,
	logger loghelper.LoggerWithContext,
	netSender NetworkSender,
	offchainKeyring types.OffchainKeyring,
	onchainKeyring types.OnchainKeyring,
	reportGenerationMetrics *reportGenerationMetrics,
	reportingPlugin types.ReportingPlugin,
	reportQuorum int,
	telemetrySender TelemetrySender,
)

Report Generation protocol corresponding to alg. 2 & 3.

func RunTransmission

func RunTransmission(
	ctx context.Context,
	subprocesses *subprocesses.Subprocesses,

	config ocr2config.SharedConfig,
	chReportFinalizationToTransmission <-chan EventToTransmission,
	database types.Database,
	id commontypes.OracleID,
	localConfig types.LocalConfig,
	logger loghelper.LoggerWithContext,
	reportingPlugin types.ReportingPlugin,
	transmitter types.ContractTransmitter,
)

TransmissionProtocol tracks the local oracle process's role in the transmission of a report to the on-chain oracle contract.

Note: The transmission protocol doesn't clean up pending transmissions when it is terminated. This is by design, but means that old pending transmissions may accumulate in the database. They should be garbage collected once in a while.

Types

type AttestedReportMany

type AttestedReportMany struct {
	Report               types.Report
	AttributedSignatures []types.AttributedOnchainSignature
}

func (AttestedReportMany) TestEqual

func (rep AttestedReportMany) TestEqual(c2 AttestedReportMany) bool

func (*AttestedReportMany) VerifySignatures

func (rep *AttestedReportMany) VerifySignatures(
	numSignatures int,
	onchainKeyring types.OnchainKeyring,
	oracleIdentities []config.OracleIdentity,
	repctx types.ReportContext,
) error

type AttestedReportOne

type AttestedReportOne struct {
	Skip      bool
	Report    types.Report
	Signature []byte
}

func MakeAttestedReportOneNoskip

func MakeAttestedReportOneNoskip(
	repctx types.ReportContext,
	report types.Report,
	signer func(types.ReportContext, types.Report) ([]byte, error),
) (AttestedReportOne, error)

func MakeAttestedReportOneSkip

func MakeAttestedReportOneSkip() AttestedReportOne

func (AttestedReportOne) EqualExceptSignature

func (rep AttestedReportOne) EqualExceptSignature(rep2 AttestedReportOne) bool

func (AttestedReportOne) TestEqual

func (rep AttestedReportOne) TestEqual(rep2 AttestedReportOne) bool

func (*AttestedReportOne) Verify

func (aro *AttestedReportOne) Verify(contractSigner types.OnchainKeyring, publicKey types.OnchainPublicKey, repctx types.ReportContext) (err error)

Verify is used by the leader to check the signature a process attaches to its report message (the c.Sig value.)

type AttributedObservation

type AttributedObservation struct {
	Observation types.Observation
	Observer    commontypes.OracleID
}

type AttributedSignedObservation

type AttributedSignedObservation struct {
	SignedObservation SignedObservation
	Observer          commontypes.OracleID
}

func (AttributedSignedObservation) Equal

type EpochRound

type EpochRound struct {
	Epoch uint32
	Round uint8
}

func (EpochRound) Less

func (x EpochRound) Less(y EpochRound) bool

type EventChangeLeader

type EventChangeLeader struct{}

EventChangeLeader is used to process the "change-leader" event passed by the local oracle from its the reporting protocol to the leader-election protocol

type EventFinal

type EventFinal struct {
	MessageFinal
}

type EventProgress

type EventProgress struct{}

EventProgress is used to process the "progress" event passed by the local oracle from its the reporting protocol to the leader-election protocol. It is sent by the reporting protocol when the leader has produced a valid new report.

type EventToPacemaker

type EventToPacemaker interface {
	// contains filtered or unexported methods
}

EventToPacemaker is the interface used to pass in-process events to the leader-election protocol.

type EventToReportFinalization

type EventToReportFinalization interface {
	// contains filtered or unexported methods
}

type EventToTransmission

type EventToTransmission interface {
	// contains filtered or unexported methods
}

EventToTransmission is the interface used to pass a completed report to the protocol which will transmit it to the on-chain smart contract.

type EventTransmit

type EventTransmit struct {
	Epoch          uint32
	Round          uint8
	H              [32]byte
	AttestedReport AttestedReportMany
}

EventTransmit is used to process the "transmit" event passed by the local reporting protocol to to the local transmit-to-the-onchain-smart-contract protocol.

type Message

type Message interface {
	// CheckSize checks whether the given message conforms to the limits imposed by
	// reportingPluginLimits
	CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool
	// contains filtered or unexported methods
}

type MessageBuffer

type MessageBuffer struct {
	// contains filtered or unexported fields
}

MessageBuffer implements a fixed capacity ringbuffer for items of type MessageToReportGeneration

func NewMessageBuffer

func NewMessageBuffer(cap int) *MessageBuffer

func (*MessageBuffer) Peek

Peek at the front item

func (*MessageBuffer) Pop

Pop front item

func (*MessageBuffer) Push

Push new item to back. If the additional item would lead to the capacity being exceeded, remove the front item first

type MessageFinal

type MessageFinal struct {
	Epoch          uint32
	Round          uint8
	H              [32]byte
	AttestedReport AttestedReportMany
}

MessageFinal corresponds to the "final" message in alg. 2. It is sent by the current leader with the aggregated signature(s) to all participating oracles, for them to participate in the subsequent transmission of the report to the on-chain contract.

func (MessageFinal) CheckSize

func (msg MessageFinal) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool

func (MessageFinal) TestEqual

func (msg MessageFinal) TestEqual(m2 MessageFinal) bool

type MessageFinalEcho

type MessageFinalEcho struct {
	MessageFinal
}

MessageFinalEcho corresponds to the "final-echo" message in alg. 2. It is broadcast by all oracles to all other oracles, to ensure that all can play their role in transmitting the report to the on-chain contract.

func (MessageFinalEcho) CheckSize

func (msg MessageFinalEcho) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool

func (MessageFinalEcho) TestEqual

func (msg MessageFinalEcho) TestEqual(m2 MessageFinalEcho) bool

type MessageNewEpoch

type MessageNewEpoch struct {
	Epoch uint32
}

MessageNewEpoch corresponds to the "newepoch(epoch_number)" message from alg. 1. It indicates that the node believes the protocol should move to the specified epoch.

func (MessageNewEpoch) CheckSize

type MessageObserve

type MessageObserve struct {
	Epoch             uint32
	Round             uint8
	SignedObservation SignedObservation
}

MessageObserve corresponds to the "observe" message from alg. 2. Participating oracles send this back to the leader in response to MessageObserveReq's.

func (MessageObserve) CheckSize

func (msg MessageObserve) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool

func (MessageObserve) TestEqual

func (msg MessageObserve) TestEqual(msg2 MessageObserve) bool

type MessageObserveReq

type MessageObserveReq struct {
	Epoch uint32
	Round uint8
	Query types.Query
}

MessageObserveReq corresponds to the "observe-req" message from alg. 2. The leader transmits this to request observations from participating oracles, so that it can collate them into a report.

func (MessageObserveReq) CheckSize

func (msg MessageObserveReq) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool

func (MessageObserveReq) TestEqual

func (msg MessageObserveReq) TestEqual(msg2 MessageObserveReq) bool

type MessageReport

type MessageReport struct {
	Epoch          uint32
	Round          uint8
	AttestedReport AttestedReportOne
}

MessageReport corresponds to the "report" message from alg. 2. It is sent by participating oracles in response to a MessageReportReq, and contains the final form of the report, based on the collated observations, and the sending oracle's signature.

func (MessageReport) CheckSize

func (msg MessageReport) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool

func (MessageReport) TestEqual

func (msg MessageReport) TestEqual(m2 MessageReport) bool

type MessageReportReq

type MessageReportReq struct {
	Epoch                        uint32
	Round                        uint8
	Query                        types.Query
	AttributedSignedObservations []AttributedSignedObservation
}

MessageReportReq corresponds to the "report-req" message from alg. 2. It is sent by the epoch leader with collated observations for the participating oracles to sign.

func (MessageReportReq) CheckSize

func (msg MessageReportReq) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool

func (MessageReportReq) TestEqual

func (msg MessageReportReq) TestEqual(msg2 MessageReportReq) bool

type MessageToPacemaker

type MessageToPacemaker interface {
	Message
	// contains filtered or unexported methods
}

MessageToPacemaker is the interface used to pass a message to the local leader-election protocol

type MessageToPacemakerWithSender

type MessageToPacemakerWithSender struct {
	// contains filtered or unexported fields
}

MessageToPacemakerWithSender records a msg with the idx of the sender oracle

type MessageToReportFinalization

type MessageToReportFinalization interface {
	Message
	// contains filtered or unexported methods
}

type MessageToReportFinalizationWithSender

type MessageToReportFinalizationWithSender struct {
	// contains filtered or unexported fields
}

type MessageToReportGeneration

type MessageToReportGeneration interface {
	Message
	// contains filtered or unexported methods
}

MessageToReportGeneration is the interface used to pass an inter-oracle message to the local oracle reporting process.

type MessageToReportGenerationWithSender

type MessageToReportGenerationWithSender struct {
	// contains filtered or unexported fields
}

MessageToReportGenerationWithSender records a message destined for the oracle reporting

type MessageWithSender

type MessageWithSender struct {
	Msg    Message
	Sender commontypes.OracleID
}

MessageWithSender records a msg with the index of the sender oracle

type MinHeapTimeToPendingTransmission

type MinHeapTimeToPendingTransmission struct {
	// contains filtered or unexported fields
}

Type safe wrapper around MinHeapTimeToContractReportInternal

func (*MinHeapTimeToPendingTransmission) Len

func (*MinHeapTimeToPendingTransmission) Peek

func (*MinHeapTimeToPendingTransmission) Pop

func (*MinHeapTimeToPendingTransmission) Push

type MinHeapTimeToPendingTransmissionInternal

type MinHeapTimeToPendingTransmissionInternal []MinHeapTimeToPendingTransmissionItem

Implements heap.Interface and uses interface{} all over the place.

func (MinHeapTimeToPendingTransmissionInternal) Len

func (MinHeapTimeToPendingTransmissionInternal) Less

func (*MinHeapTimeToPendingTransmissionInternal) Pop

func (pq *MinHeapTimeToPendingTransmissionInternal) Pop() interface{}

func (*MinHeapTimeToPendingTransmissionInternal) Push

func (pq *MinHeapTimeToPendingTransmissionInternal) Push(x interface{})

func (MinHeapTimeToPendingTransmissionInternal) Swap

type MinHeapTimeToPendingTransmissionItem

type MinHeapTimeToPendingTransmissionItem struct {
	types.ReportTimestamp
	types.PendingTransmission
}

type NetworkEndpoint

type NetworkEndpoint interface {
	NetworkSender
	// Receive returns channel which carries all messages sent to this oracle
	Receive() <-chan MessageWithSender

	// Start must be called before Receive. Calling Start more than once causes
	// panic.
	Start() error

	// Close must be called before receive. Close can be called multiple times.
	// Close can be called even on an unstarted NetworkEndpoint.
	Close() error
}

NetworkEndpoint sends & receives messages to/from other oracles

type NetworkSender

type NetworkSender interface {
	// SendTo(msg, to) sends msg to "to"
	SendTo(msg Message, to commontypes.OracleID)
	// Broadcast(msg) sends msg to all oracles
	Broadcast(msg Message)
}

NetworkSender sends messages to other oracles

type SignedObservation

type SignedObservation struct {
	Observation types.Observation
	Signature   []byte
}

func MakeSignedObservation

func MakeSignedObservation(
	repts types.ReportTimestamp,
	query types.Query,
	observation types.Observation,
	signer func(msg []byte) (sig []byte, err error),
) (
	SignedObservation,
	error,
)

func (SignedObservation) Equal

func (SignedObservation) Verify

func (so SignedObservation) Verify(repts types.ReportTimestamp, query types.Query, publicKey types.OffchainPublicKey) error

type SimpleNetwork

type SimpleNetwork struct {
	// contains filtered or unexported fields
}

SimpleNetwork is a strawman (in-memory) implementation of the Network interface. Network channels are buffered and can queue up to 100 messages before blocking.

func NewSimpleNetwork

func NewSimpleNetwork(n int) *SimpleNetwork

NewSimpleNetwork returns a SimpleNetwork for n oracles

func (*SimpleNetwork) Endpoint

Endpoint returns the interface for oracle id's networking facilities

type SimpleNetworkEndpoint

type SimpleNetworkEndpoint struct {
	// contains filtered or unexported fields
}

SimpleNetworkEndpoint is a strawman (in-memory) implementation of NetworkEndpoint, used by SimpleNetwork

func (SimpleNetworkEndpoint) Broadcast

func (end SimpleNetworkEndpoint) Broadcast(msg Message)

Broadcast sends msg to all participating oracles

func (SimpleNetworkEndpoint) Close

func (SimpleNetworkEndpoint) Close() error

Close satisfies the interface

func (SimpleNetworkEndpoint) Receive

func (end SimpleNetworkEndpoint) Receive() <-chan MessageWithSender

Receive returns a channel which carries all messages sent to the oracle

func (SimpleNetworkEndpoint) SendTo

func (end SimpleNetworkEndpoint) SendTo(msg Message, to commontypes.OracleID)

SendTo sends msg to oracle "to"

func (SimpleNetworkEndpoint) Start

func (SimpleNetworkEndpoint) Start() error

Start satisfies the interface

type TelemetrySender

type TelemetrySender interface {
	RoundStarted(
		configDigest types.ConfigDigest,
		epoch uint32,
		round uint8,
		leader commontypes.OracleID,
	)
}

type XXXUnknownMessageType

type XXXUnknownMessageType struct{}

Used only for testing

func (XXXUnknownMessageType) CheckSize

Conform to protocol.Message interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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