Documentation ¶
Index ¶
- Constants
- func Leader(epoch uint32, n int, key [16]byte) (leader commontypes.OracleID)
- func RunOracle(ctx context.Context, config ocr2config.SharedConfig, ...)
- func RunPacemaker(ctx context.Context, subprocesses *subprocesses.Subprocesses, ...)
- func RunReportFinalization(ctx context.Context, ...)
- func RunReportGeneration(ctx context.Context, subprocesses *subprocesses.Subprocesses, ...)
- func RunTransmission(ctx context.Context, subprocesses *subprocesses.Subprocesses, ...)
- type AttestedReportMany
- type AttestedReportOne
- type AttributedObservation
- type AttributedSignedObservation
- type EpochRound
- type EventChangeLeader
- type EventFinal
- type EventProgress
- type EventToPacemaker
- type EventToReportFinalization
- type EventToTransmission
- type EventTransmit
- type Message
- type MessageBuffer
- type MessageFinal
- type MessageFinalEcho
- type MessageNewEpoch
- type MessageObserve
- type MessageObserveReq
- type MessageReport
- type MessageReportReq
- type MessageToPacemaker
- type MessageToPacemakerWithSender
- type MessageToReportFinalization
- type MessageToReportFinalizationWithSender
- type MessageToReportGeneration
- type MessageToReportGenerationWithSender
- type MessageWithSender
- type MinHeapTimeToPendingTransmission
- func (h *MinHeapTimeToPendingTransmission) Len() int
- func (h *MinHeapTimeToPendingTransmission) Peek() MinHeapTimeToPendingTransmissionItem
- func (h *MinHeapTimeToPendingTransmission) Pop() MinHeapTimeToPendingTransmissionItem
- func (h *MinHeapTimeToPendingTransmission) Push(item MinHeapTimeToPendingTransmissionItem)
- type MinHeapTimeToPendingTransmissionInternal
- func (pq MinHeapTimeToPendingTransmissionInternal) Len() int
- func (pq MinHeapTimeToPendingTransmissionInternal) Less(i, j int) bool
- func (pq *MinHeapTimeToPendingTransmissionInternal) Pop() interface{}
- func (pq *MinHeapTimeToPendingTransmissionInternal) Push(x interface{})
- func (pq MinHeapTimeToPendingTransmissionInternal) Swap(i, j int)
- type MinHeapTimeToPendingTransmissionItem
- type NetworkEndpoint
- type NetworkSender
- type SignedObservation
- type SimpleNetwork
- type SimpleNetworkEndpoint
- type TelemetrySender
- type XXXUnknownMessageType
Constants ¶
const ContractTransmitterTimeoutWarningGracePeriod = 50 * time.Millisecond
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 ¶
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 ¶
func (aso AttributedSignedObservation) Equal(aso2 AttributedSignedObservation) bool
type EpochRound ¶
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 ¶
func (rb *MessageBuffer) Peek() *MessageToReportGeneration
Peek at the front item
func (*MessageBuffer) Pop ¶
func (rb *MessageBuffer) Pop() *MessageToReportGeneration
Pop front item
func (*MessageBuffer) Push ¶
func (rb *MessageBuffer) Push(msg MessageToReportGeneration)
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 ¶
func (msg MessageNewEpoch) CheckSize(types.ReportingPluginLimits) bool
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 ¶
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 (h *MinHeapTimeToPendingTransmission) Len() int
func (*MinHeapTimeToPendingTransmission) Peek ¶
func (h *MinHeapTimeToPendingTransmission) Peek() MinHeapTimeToPendingTransmissionItem
func (*MinHeapTimeToPendingTransmission) Pop ¶
func (h *MinHeapTimeToPendingTransmission) Pop() MinHeapTimeToPendingTransmissionItem
func (*MinHeapTimeToPendingTransmission) Push ¶
func (h *MinHeapTimeToPendingTransmission) Push(item MinHeapTimeToPendingTransmissionItem)
type MinHeapTimeToPendingTransmissionInternal ¶
type MinHeapTimeToPendingTransmissionInternal []MinHeapTimeToPendingTransmissionItem
Implements heap.Interface and uses interface{} all over the place.
func (MinHeapTimeToPendingTransmissionInternal) Len ¶
func (pq MinHeapTimeToPendingTransmissionInternal) Len() int
func (MinHeapTimeToPendingTransmissionInternal) Less ¶
func (pq MinHeapTimeToPendingTransmissionInternal) Less(i, j int) bool
func (*MinHeapTimeToPendingTransmissionInternal) Pop ¶
func (pq *MinHeapTimeToPendingTransmissionInternal) Pop() interface{}
func (*MinHeapTimeToPendingTransmissionInternal) Push ¶
func (pq *MinHeapTimeToPendingTransmissionInternal) Push(x interface{})
func (MinHeapTimeToPendingTransmissionInternal) Swap ¶
func (pq MinHeapTimeToPendingTransmissionInternal) Swap(i, j int)
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 (so SignedObservation) Equal(so2 SignedObservation) bool
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 ¶
func (net *SimpleNetwork) Endpoint(id commontypes.OracleID) (NetworkEndpoint, error)
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 ¶
func (XXXUnknownMessageType) CheckSize(types.ReportingPluginLimits) bool
Conform to protocol.Message interface
Source Files ¶
- attested_report.go
- attested_report_test_equal.go
- common.go
- heap.go
- message.go
- message_test_equal.go
- messagebuffer.go
- metrics.go
- network.go
- observation.go
- oracle.go
- pacemaker.go
- report_finalization.go
- report_generation.go
- report_generation_follower.go
- report_generation_leader.go
- telemetry.go
- test_helpers.go
- transmission.go