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: 29 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 uint64, n int, key [16]byte) (leader commontypes.OracleID)

Leader will produce an oracle id for the given epoch.

func RunOracle

func RunOracle[RI any](
	ctx context.Context,

	config ocr3config.SharedConfig,
	contractTransmitter ocr3types.ContractTransmitter[RI],
	database Database,
	id commontypes.OracleID,
	localConfig types.LocalConfig,
	logger loghelper.LoggerWithContext,
	metricsRegisterer prometheus.Registerer,
	netEndpoint NetworkEndpoint[RI],
	offchainKeyring types.OffchainKeyring,
	onchainKeyring ocr3types.OnchainKeyring[RI],
	reportingPlugin ocr3types.ReportingPlugin[RI],
	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 RunOutcomeGeneration

func RunOutcomeGeneration[RI any](
	ctx context.Context,

	chNetToOutcomeGeneration <-chan MessageToOutcomeGenerationWithSender[RI],
	chPacemakerToOutcomeGeneration <-chan EventToOutcomeGeneration[RI],
	chOutcomeGenerationToPacemaker chan<- EventToPacemaker[RI],
	chOutcomeGenerationToReportAttestation chan<- EventToReportAttestation[RI],
	config ocr3config.SharedConfig,
	database Database,
	id commontypes.OracleID,
	localConfig types.LocalConfig,
	logger loghelper.LoggerWithContext,
	metricsRegisterer prometheus.Registerer,
	netSender NetworkSender[RI],
	offchainKeyring types.OffchainKeyring,
	reportingPlugin ocr3types.ReportingPlugin[RI],
	telemetrySender TelemetrySender,

	restoredCert CertifiedPrepareOrCommit,
)

func RunPacemaker

func RunPacemaker[RI any](
	ctx context.Context,

	chNetToPacemaker <-chan MessageToPacemakerWithSender[RI],
	chPacemakerToOutcomeGeneration chan<- EventToOutcomeGeneration[RI],
	chOutcomeGenerationToPacemaker <-chan EventToPacemaker[RI],
	config ocr3config.SharedConfig,
	database Database,
	id commontypes.OracleID,
	localConfig types.LocalConfig,
	logger loghelper.LoggerWithContext,
	metricsRegisterer prometheus.Registerer,
	netSender NetworkSender[RI],
	offchainKeyring types.OffchainKeyring,
	telemetrySender TelemetrySender,

	restoredState PacemakerState,
)

func RunReportAttestation

func RunReportAttestation[RI any](
	ctx context.Context,

	chNetToReportAttestation <-chan MessageToReportAttestationWithSender[RI],
	chOutcomeGenerationToReportAttestation <-chan EventToReportAttestation[RI],
	chReportAttestationToTransmission chan<- EventToTransmission[RI],
	config ocr3config.SharedConfig,
	contractTransmitter ocr3types.ContractTransmitter[RI],
	logger loghelper.LoggerWithContext,
	netSender NetworkSender[RI],
	onchainKeyring ocr3types.OnchainKeyring[RI],
	reportingPlugin ocr3types.ReportingPlugin[RI],
)

func RunTransmission

func RunTransmission[RI any](
	ctx context.Context,
	subprocesses *subprocesses.Subprocesses,

	chReportAttestationToTransmission <-chan EventToTransmission[RI],
	config ocr3config.SharedConfig,
	contractTransmitter ocr3types.ContractTransmitter[RI],
	id commontypes.OracleID,
	localConfig types.LocalConfig,
	logger loghelper.LoggerWithContext,
	reportingPlugin ocr3types.ReportingPlugin[RI],
)

Types

type AttestedReportMany

type AttestedReportMany[RI any] struct {
	ReportWithInfo       ocr3types.ReportWithInfo[RI]
	AttributedSignatures []types.AttributedOnchainSignature
}

type AttributedCommitSignature

type AttributedCommitSignature struct {
	Signature CommitSignature
	Signer    commontypes.OracleID
}

type AttributedPrepareSignature

type AttributedPrepareSignature struct {
	Signature PrepareSignature
	Signer    commontypes.OracleID
}

type AttributedSignedHighestCertifiedTimestamp

type AttributedSignedHighestCertifiedTimestamp struct {
	SignedHighestCertifiedTimestamp SignedHighestCertifiedTimestamp
	Signer                          commontypes.OracleID
}

type AttributedSignedObservation

type AttributedSignedObservation struct {
	SignedObservation SignedObservation
	Observer          commontypes.OracleID
}

type CertifiedCommit

type CertifiedCommit struct {
	CommitEpoch             uint64
	SeqNr                   uint64
	Outcome                 ocr3types.Outcome
	CommitQuorumCertificate []AttributedCommitSignature
}

The empty CertifiedCommit{} is the genesis value

func (*CertifiedCommit) CheckSize

func (hc *CertifiedCommit) CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

func (*CertifiedCommit) Epoch

func (hc *CertifiedCommit) Epoch() uint64

func (*CertifiedCommit) IsGenesis

func (hc *CertifiedCommit) IsGenesis() bool

func (*CertifiedCommit) Timestamp

func (*CertifiedCommit) Verify

func (hc *CertifiedCommit) Verify(
	configDigest types.ConfigDigest,
	oracleIdentities []config.OracleIdentity,
	byzQuorumSize int,
) error

type CertifiedPrepare

type CertifiedPrepare struct {
	PrepareEpoch             uint64
	SeqNr                    uint64
	OutcomeInputsDigest      OutcomeInputsDigest
	Outcome                  ocr3types.Outcome
	PrepareQuorumCertificate []AttributedPrepareSignature
}

func (*CertifiedPrepare) CheckSize

func (hc *CertifiedPrepare) CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

func (*CertifiedPrepare) Epoch

func (hc *CertifiedPrepare) Epoch() uint64

func (*CertifiedPrepare) IsGenesis

func (hc *CertifiedPrepare) IsGenesis() bool

func (*CertifiedPrepare) Timestamp

func (*CertifiedPrepare) Verify

func (hc *CertifiedPrepare) Verify(
	configDigest types.ConfigDigest,
	oracleIdentities []config.OracleIdentity,
	byzQuorumSize int,
) error

type CertifiedPrepareOrCommit

type CertifiedPrepareOrCommit interface {
	Epoch() uint64
	Timestamp() HighestCertifiedTimestamp
	IsGenesis() bool
	Verify(
		_ types.ConfigDigest,
		_ []config.OracleIdentity,
		byzQuorumSize int,
	) error
	CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool
	// contains filtered or unexported methods
}

type CommitSignature

type CommitSignature []byte

func MakeCommitSignature

func MakeCommitSignature(
	ogid OutcomeGenerationID,
	seqNr uint64,
	outcomeDigest OutcomeDigest,
	signer func(msg []byte) ([]byte, error),
) (CommitSignature, error)

func (CommitSignature) Verify

func (sig CommitSignature) Verify(
	ogid OutcomeGenerationID,
	seqNr uint64,
	outcomeDigest OutcomeDigest,
	publicKey types.OffchainPublicKey,
) error

type Database

type Database interface {
	types.ConfigDatabase

	ReadPacemakerState(ctx context.Context, configDigest types.ConfigDigest) (PacemakerState, error)
	WritePacemakerState(ctx context.Context, configDigest types.ConfigDigest, state PacemakerState) error

	ReadCert(ctx context.Context, configDigest types.ConfigDigest) (CertifiedPrepareOrCommit, error)
	WriteCert(ctx context.Context, configDigest types.ConfigDigest, cert CertifiedPrepareOrCommit) error
}

type EpochStartProof

type EpochStartProof struct {
	HighestCertified      CertifiedPrepareOrCommit
	HighestCertifiedProof []AttributedSignedHighestCertifiedTimestamp
}

func (*EpochStartProof) Verify

func (qc *EpochStartProof) Verify(
	ogid OutcomeGenerationID,
	oracleIdentities []config.OracleIdentity,
	byzQuorumSize int,
) error

type EventAttestedReport

type EventAttestedReport[RI any] struct {
	SeqNr          uint64
	Index          int
	AttestedReport AttestedReportMany[RI]
}

type EventCommittedOutcome

type EventCommittedOutcome[RI any] struct {
	CertifiedCommit CertifiedCommit
}

type EventMissingOutcome

type EventMissingOutcome[RI any] struct {
	SeqNr uint64
}

type EventNewEpochRequest

type EventNewEpochRequest[RI any] struct{}

type EventNewEpochStart

type EventNewEpochStart[RI any] struct {
	Epoch uint64
}

type EventProgress

type EventProgress[RI any] struct{}

type EventToOutcomeGeneration

type EventToOutcomeGeneration[RI any] interface {
	// contains filtered or unexported methods
}

type EventToPacemaker

type EventToPacemaker[RI any] interface {
	// contains filtered or unexported methods
}

type EventToReportAttestation

type EventToReportAttestation[RI any] interface {
	// contains filtered or unexported methods
}

type EventToTransmission

type EventToTransmission[RI any] interface {
	// contains filtered or unexported methods
}

type HighestCertifiedTimestamp

type HighestCertifiedTimestamp struct {
	SeqNr                 uint64
	CommittedElsePrepared bool
}

func (HighestCertifiedTimestamp) Less

type Message

type Message[RI any] interface {
	// CheckSize checks whether the given message conforms to the limits imposed by
	// reportingPluginLimits
	CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool
	// contains filtered or unexported methods
}

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

type MessageBuffer

type MessageBuffer[RI any] ringbuffer.RingBuffer[MessageToOutcomeGeneration[RI]]

We have this wrapper to deal with what appears to be a bug in the Go compiler that prevents us from using ringbuffer.RingBuffer in the outcome generation protocol: offchainreporting2plus/internal/ocr3/protocol/outcome_generation.go:241:21: internal compiler error: (*ringbuffer.RingBuffer[go.shape.interface { github.com/smartcontractkit/offchain-reporting/lib/offchainreporting2plus/internal/ocr3/protocol.epoch() uint64; github.com/smartcontractkit/offchain-reporting/lib/offchainreporting2plus/internal/ocr3/protocol.processOutcomeGeneration(*github.com/smartcontractkit/offchain-reporting/lib/offchainreporting2plus/internal/ocr3/protocol.outcomeGenerationState[go.shape.struct {}], github.com/smartcontractkit/offchain-reporting/lib/commontypes.OracleID) }]).Peek(buffer, (*[9]uintptr)(.dict[3])) (type go.shape.interface { github.com/smartcontractkit/offchain-reporting/lib/offchainreporting2plus/internal/ocr3/protocol.epoch() uint64; github.com/smartcontractkit/offchain-reporting/lib/offchainreporting2plus/internal/ocr3/protocol.processOutcomeGeneration(*github.com/smartcontractkit/offchain-reporting/lib/offchainreporting2plus/internal/ocr3/protocol.outcomeGenerationState[go.shape.struct {}], github.com/smartcontractkit/offchain-reporting/lib/commontypes.OracleID) }) is not shape-identical to MessageToOutcomeGeneration[go.shape.struct {}] Consider removing it in a future release.

func NewMessageBuffer

func NewMessageBuffer[RI any](cap int) *MessageBuffer[RI]

func (*MessageBuffer[RI]) Length

func (rb *MessageBuffer[RI]) Length() int

func (*MessageBuffer[RI]) Peek

func (rb *MessageBuffer[RI]) Peek() MessageToOutcomeGeneration[RI]

func (*MessageBuffer[RI]) Pop

func (rb *MessageBuffer[RI]) Pop() MessageToOutcomeGeneration[RI]

func (*MessageBuffer[RI]) Push

func (rb *MessageBuffer[RI]) Push(msg MessageToOutcomeGeneration[RI])

type MessageCertifiedCommit

type MessageCertifiedCommit[RI any] struct {
	CertifiedCommit CertifiedCommit
}

func (MessageCertifiedCommit[RI]) CheckSize

func (msg MessageCertifiedCommit[RI]) CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

type MessageCertifiedCommitRequest

type MessageCertifiedCommitRequest[RI any] struct {
	SeqNr uint64
}

func (MessageCertifiedCommitRequest[RI]) CheckSize

func (msg MessageCertifiedCommitRequest[RI]) CheckSize(n int, f int, _ ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

type MessageCommit

type MessageCommit[RI any] struct {
	Epoch     uint64
	SeqNr     uint64
	Signature CommitSignature
}

func (MessageCommit[RI]) CheckSize

func (msg MessageCommit[RI]) CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

type MessageEpochStart

type MessageEpochStart[RI any] struct {
	Epoch           uint64
	EpochStartProof EpochStartProof
}

func (MessageEpochStart[RI]) CheckSize

func (msg MessageEpochStart[RI]) CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

type MessageEpochStartRequest

type MessageEpochStartRequest[RI any] struct {
	Epoch                           uint64
	HighestCertified                CertifiedPrepareOrCommit
	SignedHighestCertifiedTimestamp SignedHighestCertifiedTimestamp
}

func (MessageEpochStartRequest[RI]) CheckSize

func (msg MessageEpochStartRequest[RI]) CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

type MessageNewEpochWish

type MessageNewEpochWish[RI any] struct {
	Epoch uint64
}

func (MessageNewEpochWish[RI]) CheckSize

func (msg MessageNewEpochWish[RI]) CheckSize(n int, f int, _ ocr3types.ReportingPluginLimits, _ int) bool

type MessageObservation

type MessageObservation[RI any] struct {
	Epoch             uint64
	SeqNr             uint64
	SignedObservation SignedObservation
}

func (MessageObservation[RI]) CheckSize

func (msg MessageObservation[RI]) CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

type MessagePrepare

type MessagePrepare[RI any] struct {
	Epoch     uint64
	SeqNr     uint64
	Signature PrepareSignature
}

func (MessagePrepare[RI]) CheckSize

func (msg MessagePrepare[RI]) CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

type MessageProposal

type MessageProposal[RI any] struct {
	Epoch                        uint64
	SeqNr                        uint64
	AttributedSignedObservations []AttributedSignedObservation
}

func (MessageProposal[RI]) CheckSize

func (msg MessageProposal[RI]) CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

type MessageReportSignatures

type MessageReportSignatures[RI any] struct {
	SeqNr            uint64
	ReportSignatures [][]byte
}

func (MessageReportSignatures[RI]) CheckSize

func (msg MessageReportSignatures[RI]) CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

type MessageRoundStart

type MessageRoundStart[RI any] struct {
	Epoch uint64
	SeqNr uint64
	Query types.Query
}

func (MessageRoundStart[RI]) CheckSize

func (msg MessageRoundStart[RI]) CheckSize(n int, f int, limits ocr3types.ReportingPluginLimits, maxReportSigLen int) bool

type MessageToOutcomeGeneration

type MessageToOutcomeGeneration[RI any] interface {
	Message[RI]
	// contains filtered or unexported methods
}

type MessageToOutcomeGenerationWithSender

type MessageToOutcomeGenerationWithSender[RI any] struct {
	// contains filtered or unexported fields
}

type MessageToPacemaker

type MessageToPacemaker[RI any] interface {
	Message[RI]
	// contains filtered or unexported methods
}

type MessageToPacemakerWithSender

type MessageToPacemakerWithSender[RI any] struct {
	// contains filtered or unexported fields
}

type MessageToReportAttestation

type MessageToReportAttestation[RI any] interface {
	Message[RI]
	// contains filtered or unexported methods
}

type MessageToReportAttestationWithSender

type MessageToReportAttestationWithSender[RI any] struct {
	// contains filtered or unexported fields
}

type MessageWithSender

type MessageWithSender[RI any] struct {
	Msg    Message[RI]
	Sender commontypes.OracleID
}

MessageWithSender records a msg with the index of the sender oracle

type NetworkEndpoint

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

	// 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[RI any] interface {
	// SendTo(msg, to) sends msg to "to"
	SendTo(msg Message[RI], to commontypes.OracleID)
	// Broadcast(msg) sends msg to all oracles
	Broadcast(msg Message[RI])
}

NetworkSender sends messages to other oracles

type OutcomeDigest

type OutcomeDigest [32]byte

func MakeOutcomeDigest

func MakeOutcomeDigest(outcome ocr3types.Outcome) OutcomeDigest

type OutcomeGenerationID

type OutcomeGenerationID struct {
	ConfigDigest types.ConfigDigest
	Epoch        uint64
}

Identifies an instance of the outcome generation protocol

type OutcomeInputsDigest

type OutcomeInputsDigest [32]byte

func MakeOutcomeInputsDigest

func MakeOutcomeInputsDigest(
	ogid OutcomeGenerationID,
	previousOutcome ocr3types.Outcome,
	seqNr uint64,
	query types.Query,
	attributedObservations []types.AttributedObservation,
) OutcomeInputsDigest

type PacemakerState

type PacemakerState struct {
	Epoch                   uint64
	HighestSentNewEpochWish uint64
}

type PrepareSignature

type PrepareSignature []byte

func MakePrepareSignature

func MakePrepareSignature(
	ogid OutcomeGenerationID,
	seqNr uint64,
	outcomeInputsDigest OutcomeInputsDigest,
	outcomeDigest OutcomeDigest,
	signer func(msg []byte) ([]byte, error),
) (PrepareSignature, error)

func (PrepareSignature) Verify

func (sig PrepareSignature) Verify(
	ogid OutcomeGenerationID,
	seqNr uint64,
	outcomeInputsDigest OutcomeInputsDigest,
	outcomeDigest OutcomeDigest,
	publicKey types.OffchainPublicKey,
) error

type SignedHighestCertifiedTimestamp

type SignedHighestCertifiedTimestamp struct {
	HighestCertifiedTimestamp HighestCertifiedTimestamp
	Signature                 []byte
}

func MakeSignedHighestCertifiedTimestamp

func MakeSignedHighestCertifiedTimestamp(
	ogid OutcomeGenerationID,
	highestCertifiedTimestamp HighestCertifiedTimestamp,
	signer func(msg []byte) ([]byte, error),
) (SignedHighestCertifiedTimestamp, error)

func (*SignedHighestCertifiedTimestamp) Verify

type SignedObservation

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

func MakeSignedObservation

func MakeSignedObservation(
	ogid OutcomeGenerationID,
	seqNr uint64,
	query types.Query,
	observation types.Observation,
	signer func(msg []byte) (sig []byte, err error),
) (
	SignedObservation,
	error,
)

func (SignedObservation) Verify

func (so SignedObservation) Verify(ogid OutcomeGenerationID, seqNr uint64, query types.Query, publicKey types.OffchainPublicKey) error

type SimpleNetwork

type SimpleNetwork[RI any] 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[RI any](n int) *SimpleNetwork[RI]

NewSimpleNetwork returns a SimpleNetwork for n oracles

func (*SimpleNetwork[RI]) Endpoint

func (net *SimpleNetwork[RI]) Endpoint(id commontypes.OracleID) (NetworkEndpoint[RI], error)

Endpoint returns the interface for oracle id's networking facilities

type SimpleNetworkEndpoint

type SimpleNetworkEndpoint[RI any] struct {
	// contains filtered or unexported fields
}

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

func (SimpleNetworkEndpoint[RI]) Broadcast

func (end SimpleNetworkEndpoint[RI]) Broadcast(msg Message[RI])

Broadcast sends msg to all participating oracles

func (SimpleNetworkEndpoint[RI]) Close

func (SimpleNetworkEndpoint[RI]) Close() error

Close satisfies the interface

func (SimpleNetworkEndpoint[RI]) Receive

func (end SimpleNetworkEndpoint[RI]) Receive() <-chan MessageWithSender[RI]

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

func (SimpleNetworkEndpoint[RI]) SendTo

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

SendTo sends msg to oracle "to"

func (SimpleNetworkEndpoint[RI]) Start

func (SimpleNetworkEndpoint[RI]) Start() error

Start satisfies the interface

type TelemetrySender

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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