{"modulePath":"github.com/GoPlugin/libocr","version":"v0.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package protocol\n\n## Constants\n\n```go\nconst ContractTransmitterTimeoutWarningGracePeriod = 50 * time.Millisecond\n```\n\n```go\nconst ReportingPluginTimeoutWarningGracePeriod = 100 * time.Millisecond\n```\n\n## Functions\n\n```go\nfunc Leader(epoch uint32, n int, key [16]byte) (leader commontypes.OracleID)\n```\nLeader will produce an oracle id for the given epoch.\n\n```go\nfunc RunOracle(\n\tctx context.Context,\n\n\tconfig ocr2config.SharedConfig,\n\tcontractTransmitter types.ContractTransmitter,\n\tdatabase types.Database,\n\tid commontypes.OracleID,\n\tlocalConfig types.LocalConfig,\n\tlogger loghelper.LoggerWithContext,\n\tnetEndpoint NetworkEndpoint,\n\toffchainKeyring types.OffchainKeyring,\n\tonchainKeyring types.OnchainKeyring,\n\treportingPlugin types.ReportingPlugin,\n\treportQuorum int,\n\ttelemetrySender TelemetrySender,\n)\n```\nRunOracle runs one oracle instance of the offchain reporting protocol and manages the lifecycle of all underlying goroutines.\n\nRunOracle runs forever until ctx is cancelled. It will only shut down after all its sub-goroutines have exited.\n\n```go\nfunc RunPacemaker(\n\tctx context.Context,\n\tsubprocesses *subprocesses.Subprocesses,\n\n\tchNetToPacemaker \u003c-chan MessageToPacemakerWithSender,\n\tchNetToReportGeneration \u003c-chan MessageToReportGenerationWithSender,\n\tchPacemakerToOracle chan\u003c- uint32,\n\tchReportGenerationToReportFinalization chan\u003c- EventToReportFinalization,\n\tconfig ocr2config.SharedConfig,\n\tcontractTransmitter types.ContractTransmitter,\n\tdatabase types.Database,\n\tid commontypes.OracleID,\n\tlocalConfig types.LocalConfig,\n\tlogger loghelper.LoggerWithContext,\n\tnetSender NetworkSender,\n\toffchainKeyring types.OffchainKeyring,\n\tonchainKeyring types.OnchainKeyring,\n\treportingPlugin types.ReportingPlugin,\n\treportQuorum int,\n\ttelemetrySender TelemetrySender,\n)\n```\nPacemaker keeps track of the state and message handling for an oracle participating in the off-chain reporting protocol\n\n```go\nfunc RunReportFinalization(\n\tctx context.Context,\n\n\tchNetToReportFinalization \u003c-chan MessageToReportFinalizationWithSender,\n\tchReportFinalizationToTransmission chan\u003c- EventToTransmission,\n\tchReportGenerationToReportFinalization \u003c-chan EventToReportFinalization,\n\tconfig ocr2config.SharedConfig,\n\tcontractSigner types.OnchainKeyring,\n\tlogger loghelper.LoggerWithContext,\n\tnetSender NetworkSender,\n\treportQuorum int,\n)\n```\n\n```go\nfunc RunReportGeneration(\n\tctx context.Context,\n\tsubprocesses *subprocesses.Subprocesses,\n\n\tchNetToReportGeneration \u003c-chan MessageToReportGenerationWithSender,\n\tchReportGenerationToPacemaker chan\u003c- EventToPacemaker,\n\tchReportGenerationToReportFinalization chan\u003c- EventToReportFinalization,\n\tconfig ocr2config.SharedConfig,\n\tcontractTransmitter types.ContractTransmitter,\n\te uint32,\n\tid commontypes.OracleID,\n\tl commontypes.OracleID,\n\tlocalConfig types.LocalConfig,\n\tlogger loghelper.LoggerWithContext,\n\tnetSender NetworkSender,\n\toffchainKeyring types.OffchainKeyring,\n\tonchainKeyring types.OnchainKeyring,\n\treportingPlugin types.ReportingPlugin,\n\treportQuorum int,\n\ttelemetrySender TelemetrySender,\n)\n```\nReport Generation protocol corresponding to alg. 2 \u0026 3.\n\n```go\nfunc RunTransmission(\n\tctx context.Context,\n\tsubprocesses *subprocesses.Subprocesses,\n\n\tconfig ocr2config.SharedConfig,\n\tchReportFinalizationToTransmission \u003c-chan EventToTransmission,\n\tdatabase types.Database,\n\tid commontypes.OracleID,\n\tlocalConfig types.LocalConfig,\n\tlogger loghelper.LoggerWithContext,\n\treportingPlugin types.ReportingPlugin,\n\ttransmitter types.ContractTransmitter,\n)\n```\nTransmissionProtocol tracks the local oracle process's role in the transmission of a report to the on-chain oracle contract.\n\nNote: 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.\n\n## Types\n\n```go\ntype AttestedReportMany struct {\n\tReport               types.Report\n\tAttributedSignatures []types.AttributedOnchainSignature\n}\n```\n\n```go\nfunc (rep AttestedReportMany) TestEqual(c2 AttestedReportMany) bool\n```\n\n```go\nfunc (rep *AttestedReportMany) VerifySignatures(\n\tnumSignatures int,\n\tonchainKeyring types.OnchainKeyring,\n\toracleIdentities []config.OracleIdentity,\n\trepctx types.ReportContext,\n) error\n```\n\n```go\ntype AttestedReportOne struct {\n\tSkip      bool\n\tReport    types.Report\n\tSignature []byte\n}\n```\n\n```go\nfunc MakeAttestedReportOneNoskip(\n\trepctx types.ReportContext,\n\treport types.Report,\n\tsigner func(types.ReportContext, types.Report) ([]byte, error),\n) (AttestedReportOne, error)\n```\n\n```go\nfunc MakeAttestedReportOneSkip() AttestedReportOne\n```\n\n```go\nfunc (rep AttestedReportOne) EqualExceptSignature(rep2 AttestedReportOne) bool\n```\n\n```go\nfunc (rep AttestedReportOne) TestEqual(rep2 AttestedReportOne) bool\n```\n\n```go\nfunc (aro *AttestedReportOne) Verify(contractSigner types.OnchainKeyring, publicKey types.OnchainPublicKey, repctx types.ReportContext) (err error)\n```\nVerify is used by the leader to check the signature a process attaches to its report message (the c.Sig value.)\n\n```go\ntype AttributedObservation struct {\n\tObservation types.Observation\n\tObserver    commontypes.OracleID\n}\n```\n\n```go\ntype AttributedSignedObservation struct {\n\tSignedObservation SignedObservation\n\tObserver          commontypes.OracleID\n}\n```\n\n```go\nfunc (aso AttributedSignedObservation) Equal(aso2 AttributedSignedObservation) bool\n```\n\n```go\ntype EpochRound struct {\n\tEpoch uint32\n\tRound uint8\n}\n```\n\n```go\nfunc (x EpochRound) Less(y EpochRound) bool\n```\n\n```go\ntype EventChangeLeader struct{}\n```\nEventChangeLeader is used to process the \"change-leader\" event passed by the local oracle from its the reporting protocol to the leader-election protocol\n\n```go\ntype EventFinal struct {\n\tMessageFinal\n}\n```\n\n```go\ntype EventProgress struct{}\n```\nEventProgress 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.\n\n```go\ntype EventToPacemaker interface {\n\t// contains filtered or unexported methods\n}\n```\nEventToPacemaker is the interface used to pass in-process events to the leader-election protocol.\n\n```go\ntype EventToReportFinalization interface {\n\t// contains filtered or unexported methods\n}\n```\n\n```go\ntype EventToTransmission interface {\n\t// contains filtered or unexported methods\n}\n```\nEventToTransmission is the interface used to pass a completed report to the protocol which will transmit it to the on-chain smart contract.\n\n```go\ntype EventTransmit struct {\n\tEpoch          uint32\n\tRound          uint8\n\tH              [32]byte\n\tAttestedReport AttestedReportMany\n}\n```\nEventTransmit is used to process the \"transmit\" event passed by the local reporting protocol to to the local transmit-to-the-onchain-smart-contract protocol.\n\n```go\ntype Message interface {\n\t// CheckSize checks whether the given message conforms to the limits imposed by\n\t// reportingPluginLimits\n\tCheckSize(reportingPluginLimits types.ReportingPluginLimits) bool\n\t// contains filtered or unexported methods\n}\n```\n\n```go\ntype MessageBuffer struct {\n\t// contains filtered or unexported fields\n}\n```\nMessageBuffer implements a fixed capacity ringbuffer for items of type MessageToReportGeneration\n\n```go\nfunc NewMessageBuffer(cap int) *MessageBuffer\n```\n\n```go\nfunc (rb *MessageBuffer) Peek() *MessageToReportGeneration\n```\nPeek at the front item\n\n```go\nfunc (rb *MessageBuffer) Pop() *MessageToReportGeneration\n```\nPop front item\n\n```go\nfunc (rb *MessageBuffer) Push(msg MessageToReportGeneration)\n```\nPush new item to back. If the additional item would lead to the capacity being exceeded, remove the front item first\n\n```go\ntype MessageFinal struct {\n\tEpoch          uint32\n\tRound          uint8\n\tH              [32]byte\n\tAttestedReport AttestedReportMany\n}\n```\nMessageFinal 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.\n\n```go\nfunc (msg MessageFinal) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool\n```\n\n```go\nfunc (msg MessageFinal) TestEqual(m2 MessageFinal) bool\n```\n\n```go\ntype MessageFinalEcho struct {\n\tMessageFinal\n}\n```\nMessageFinalEcho 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.\n\n```go\nfunc (msg MessageFinalEcho) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool\n```\n\n```go\nfunc (msg MessageFinalEcho) TestEqual(m2 MessageFinalEcho) bool\n```\n\n```go\ntype MessageNewEpoch struct {\n\tEpoch uint32\n}\n```\nMessageNewEpoch corresponds to the \"newepoch(epoch\\_number)\" message from alg. 1. It indicates that the node believes the protocol should move to the specified epoch.\n\n```go\nfunc (msg MessageNewEpoch) CheckSize(types.ReportingPluginLimits) bool\n```\n\n```go\ntype MessageObserve struct {\n\tEpoch             uint32\n\tRound             uint8\n\tSignedObservation SignedObservation\n}\n```\nMessageObserve corresponds to the \"observe\" message from alg. 2. Participating oracles send this back to the leader in response to MessageObserveReq's.\n\n```go\nfunc (msg MessageObserve) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool\n```\n\n```go\nfunc (msg MessageObserve) TestEqual(msg2 MessageObserve) bool\n```\n\n```go\ntype MessageObserveReq struct {\n\tEpoch uint32\n\tRound uint8\n\tQuery types.Query\n}\n```\nMessageObserveReq 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.\n\n```go\nfunc (msg MessageObserveReq) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool\n```\n\n```go\nfunc (msg MessageObserveReq) TestEqual(msg2 MessageObserveReq) bool\n```\n\n```go\ntype MessageReport struct {\n\tEpoch          uint32\n\tRound          uint8\n\tAttestedReport AttestedReportOne\n}\n```\nMessageReport 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.\n\n```go\nfunc (msg MessageReport) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool\n```\n\n```go\nfunc (msg MessageReport) TestEqual(m2 MessageReport) bool\n```\n\n```go\ntype MessageReportReq struct {\n\tEpoch                        uint32\n\tRound                        uint8\n\tQuery                        types.Query\n\tAttributedSignedObservations []AttributedSignedObservation\n}\n```\nMessageReportReq 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.\n\n```go\nfunc (msg MessageReportReq) CheckSize(reportingPluginLimits types.ReportingPluginLimits) bool\n```\n\n```go\nfunc (msg MessageReportReq) TestEqual(msg2 MessageReportReq) bool\n```\n\n```go\ntype MessageToPacemaker interface {\n\tMessage\n\t// contains filtered or unexported methods\n}\n```\nMessageToPacemaker is the interface used to pass a message to the local leader-election protocol\n\n```go\ntype MessageToPacemakerWithSender struct {\n\t// contains filtered or unexported fields\n}\n```\nMessageToPacemakerWithSender records a msg with the idx of the sender oracle\n\n```go\ntype MessageToReportFinalization interface {\n\tMessage\n\t// contains filtered or unexported methods\n}\n```\n\n```go\ntype MessageToReportFinalizationWithSender struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype MessageToReportGeneration interface {\n\tMessage\n\t// contains filtered or unexported methods\n}\n```\nMessageToReportGeneration is the interface used to pass an inter-oracle message to the local oracle reporting process.\n\n```go\ntype MessageToReportGenerationWithSender struct {\n\t// contains filtered or unexported fields\n}\n```\nMessageToReportGenerationWithSender records a message destined for the oracle reporting\n\n```go\ntype MessageWithSender struct {\n\tMsg    Message\n\tSender commontypes.OracleID\n}\n```\nMessageWithSender records a msg with the index of the sender oracle\n\n```go\ntype MinHeapTimeToPendingTransmission struct {\n\t// contains filtered or unexported fields\n}\n```\nType safe wrapper around MinHeapTimeToContractReportInternal\n\n```go\nfunc (h *MinHeapTimeToPendingTransmission) Len() int\n```\n\n```go\nfunc (h *MinHeapTimeToPendingTransmission) Peek() MinHeapTimeToPendingTransmissionItem\n```\n\n```go\nfunc (h *MinHeapTimeToPendingTransmission) Pop() MinHeapTimeToPendingTransmissionItem\n```\n\n```go\nfunc (h *MinHeapTimeToPendingTransmission) Push(item MinHeapTimeToPendingTransmissionItem)\n```\n\n```go\ntype MinHeapTimeToPendingTransmissionInternal []MinHeapTimeToPendingTransmissionItem\n```\nImplements heap.Interface and uses interface{} all over the place.\n\n```go\nfunc (pq MinHeapTimeToPendingTransmissionInternal) Len() int\n```\n\n```go\nfunc (pq MinHeapTimeToPendingTransmissionInternal) Less(i, j int) bool\n```\n\n```go\nfunc (pq *MinHeapTimeToPendingTransmissionInternal) Pop() interface{}\n```\n\n```go\nfunc (pq *MinHeapTimeToPendingTransmissionInternal) Push(x interface{})\n```\n\n```go\nfunc (pq MinHeapTimeToPendingTransmissionInternal) Swap(i, j int)\n```\n\n```go\ntype MinHeapTimeToPendingTransmissionItem struct {\n\ttypes.ReportTimestamp\n\ttypes.PendingTransmission\n}\n```\n\n```go\ntype NetworkEndpoint interface {\n\tNetworkSender\n\t// Receive returns channel which carries all messages sent to this oracle\n\tReceive() \u003c-chan MessageWithSender\n\n\t// Start must be called before Receive. Calling Start more than once causes\n\t// panic.\n\tStart() error\n\n\t// Close must be called before receive. Close can be called multiple times.\n\t// Close can be called even on an unstarted NetworkEndpoint.\n\tClose() error\n}\n```\nNetworkEndpoint sends \u0026 receives messages to/from other oracles\n\n```go\ntype NetworkSender interface {\n\t// SendTo(msg, to) sends msg to \"to\"\n\tSendTo(msg Message, to commontypes.OracleID)\n\t// Broadcast(msg) sends msg to all oracles\n\tBroadcast(msg Message)\n}\n```\nNetworkSender sends messages to other oracles\n\n```go\ntype SignedObservation struct {\n\tObservation types.Observation\n\tSignature   []byte\n}\n```\n\n```go\nfunc MakeSignedObservation(\n\trepts types.ReportTimestamp,\n\tquery types.Query,\n\tobservation types.Observation,\n\tsigner func(msg []byte) (sig []byte, err error),\n) (\n\tSignedObservation,\n\terror,\n)\n```\n\n```go\nfunc (so SignedObservation) Equal(so2 SignedObservation) bool\n```\n\n```go\nfunc (so SignedObservation) Verify(repts types.ReportTimestamp, query types.Query, publicKey types.OffchainPublicKey) error\n```\n\n```go\ntype SimpleNetwork struct {\n\t// contains filtered or unexported fields\n}\n```\nSimpleNetwork is a strawman (in-memory) implementation of the Network interface. Network channels are buffered and can queue up to 100 messages before blocking.\n\n```go\nfunc NewSimpleNetwork(n int) *SimpleNetwork\n```\nNewSimpleNetwork returns a SimpleNetwork for n oracles\n\n```go\nfunc (net *SimpleNetwork) Endpoint(id commontypes.OracleID) (NetworkEndpoint, error)\n```\nEndpoint returns the interface for oracle id's networking facilities\n\n```go\ntype SimpleNetworkEndpoint struct {\n\t// contains filtered or unexported fields\n}\n```\nSimpleNetworkEndpoint is a strawman (in-memory) implementation of NetworkEndpoint, used by SimpleNetwork\n\n```go\nfunc (end SimpleNetworkEndpoint) Broadcast(msg Message)\n```\nBroadcast sends msg to all participating oracles\n\n```go\nfunc (SimpleNetworkEndpoint) Close() error\n```\nClose satisfies the interface\n\n```go\nfunc (end SimpleNetworkEndpoint) Receive() \u003c-chan MessageWithSender\n```\nReceive returns a channel which carries all messages sent to the oracle\n\n```go\nfunc (end SimpleNetworkEndpoint) SendTo(msg Message, to commontypes.OracleID)\n```\nSendTo sends msg to oracle \"to\"\n\n```go\nfunc (SimpleNetworkEndpoint) Start() error\n```\nStart satisfies the interface\n\n```go\ntype TelemetrySender interface {\n\tRoundStarted(\n\t\tconfigDigest types.ConfigDigest,\n\t\tepoch uint32,\n\t\tround uint8,\n\t\tleader commontypes.OracleID,\n\t)\n}\n```\n\n```go\ntype XXXUnknownMessageType struct{}\n```\nUsed only for testing\n\n```go\nfunc (XXXUnknownMessageType) CheckSize(types.ReportingPluginLimits) bool\n```\nConform to protocol.Message interface\n\n","path":"github.com/GoPlugin/libocr/offchainreporting2plus/internal/ocr2/protocol","name":"protocol","synopsis":"","isRedistributable":true}
