{"modulePath":"github.com/GoPlugin/libocr","version":"v0.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package protocol\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 config.SharedConfig,\n\tconfigOverrider types.ConfigOverrider,\n\tcontractTransmitter types.ContractTransmitter,\n\tdatabase types.Database,\n\tdatasource types.DataSource,\n\tid commontypes.OracleID,\n\tkeys types.PrivateKeys,\n\tlocalConfig types.LocalConfig,\n\tlogger loghelper.LoggerWithContext,\n\tnetEndpoint NetworkEndpoint,\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\tchReportGenerationToTransmission chan\u003c- EventToTransmission,\n\tconfig config.SharedConfig,\n\tconfigOverrider types.ConfigOverrider,\n\tcontractTransmitter types.ContractTransmitter,\n\tdatabase types.Database,\n\tdatasource types.DataSource,\n\tid commontypes.OracleID,\n\tlocalConfig types.LocalConfig,\n\tlogger loghelper.LoggerWithContext,\n\tnetSender NetworkSender,\n\tprivateKeys types.PrivateKeys,\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 RunReportGeneration(\n\tctx context.Context,\n\tsubprocesses *subprocesses.Subprocesses,\n\n\tchNetToReportGeneration \u003c-chan MessageToReportGenerationWithSender,\n\tchReportGenerationToPacemaker chan\u003c- EventToPacemaker,\n\tchReportGenerationToTransmission chan\u003c- EventToTransmission,\n\tconfig config.SharedConfig,\n\tconfigOverrider types.ConfigOverrider,\n\tcontractTransmitter types.ContractTransmitter,\n\tdatasource types.DataSource,\n\te uint32,\n\tid commontypes.OracleID,\n\tl commontypes.OracleID,\n\tlocalConfig types.LocalConfig,\n\tlogger loghelper.LoggerWithContext,\n\tnetSender NetworkSender,\n\tprivateKeys types.PrivateKeys,\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 config.SharedConfig,\n\tconfigOverrider types.ConfigOverrider,\n\tchReportGenerationToTransmission \u003c-chan EventToTransmission,\n\tdatabase types.Database,\n\tid commontypes.OracleID,\n\tlocalConfig types.LocalConfig,\n\tlogger loghelper.LoggerWithContext,\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\tAttributedObservations AttributedObservations\n\tSignatures             [][]byte\n}\n```\nAttestedReportMany consists of attributed observations with aggregated signatures from the oracles which have sent this report to the current epoch leader.\n\n```go\nfunc (rep AttestedReportMany) Equal(c2 AttestedReportMany) bool\n```\n\n```go\nfunc (rep *AttestedReportMany) TransmissionArgs(repctx ReportContext) (report []byte, rs,\n\tss [][32]byte, vs [32]byte, err error)\n```\n\n```go\nfunc (rep *AttestedReportMany) VerifySignatures(\n\trepctx ReportContext,\n\tas signature.EthAddresses,\n) error\n```\nVerifySignatures checks that all the signatures (c.Signatures) come from the addresses in the map \"as\", and returns a list of which oracles they came from.\n\n```go\ntype AttestedReportOne struct {\n\tAttributedObservations AttributedObservations\n\tSignature              []byte\n}\n```\nAttestedReportOne is the collated report oracles sign off on, after they've verified the individual signatures in a report-req sent by the current leader\n\n```go\nfunc MakeAttestedReportOne(\n\taos AttributedObservations,\n\trepctx ReportContext,\n\tsigner func([]byte) ([]byte, error),\n) (AttestedReportOne, error)\n```\n\n```go\nfunc (rep AttestedReportOne) Equal(rep2 AttestedReportOne) bool\n```\n\n```go\nfunc (c *AttestedReportOne) Verify(repctx ReportContext, a types.OnChainSigningAddress) (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 observation.Observation\n\tObserver    commontypes.OracleID\n}\n```\nAttributedObservation succinctly attributes a value reported to an oracle\n\n```go\nfunc (o AttributedObservation) Equal(o2 AttributedObservation) bool\n```\n\n```go\ntype AttributedObservations []AttributedObservation\n```\n\n```go\nfunc (aos AttributedObservations) Equal(aos2 AttributedObservations) bool\n```\n\n```go\nfunc (aos AttributedObservations) Median() (observation.Observation, error)\n```\n\n```go\nfunc (aos AttributedObservations) OnChainReport(repctx ReportContext) ([]byte, error)\n```\nOnChainReport returns the serialized report which is transmitted to the onchain contract, and signed by participating oracles using their onchain identities\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 DomainSeparationTag [32]byte\n```\nDomainSeparationTag consists of: 11-byte zero padding 16-byte configDigest 4-byte epoch 1-byte round It uniquely identifies a message to a particular group-epoch-round tuple. It is used in signature verification\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 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 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\tReport 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// contains filtered or unexported methods\n}\n```\nMessage is the interface used to pass an inter-oracle message to the local oracle process.\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\tReport 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) Equal(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) Equal(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\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) Equal(msg2 MessageObserve) bool\n```\n\n```go\ntype MessageObserveReq struct {\n\tEpoch uint32\n\tRound uint8\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\ntype MessageReport struct {\n\tEpoch  uint32\n\tRound  uint8\n\tReport 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) Equal(m2 MessageReport) bool\n```\n\n```go\ntype MessageReportReq struct {\n\tEpoch                        uint32\n\tRound                        uint8\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\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 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 ReportContext struct {\n\tConfigDigest types.ConfigDigest\n\tEpoch        uint32\n\tRound        uint8\n}\n```\n\n```go\nfunc (r ReportContext) DomainSeparationTag() (d DomainSeparationTag)\n```\n\n```go\nfunc (r ReportContext) Equal(r2 ReportContext) bool\n```\n\n```go\ntype SignedObservation struct {\n\tObservation observation.Observation\n\tSignature   []byte\n}\n```\n\n```go\nfunc MakeSignedObservation(\n\tobservation observation.Observation,\n\trepctx ReportContext,\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(repctx ReportContext, 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","path":"github.com/GoPlugin/libocr/offchainreporting/internal/protocol","name":"protocol","synopsis":"","isRedistributable":true}
