protocol

package
v1.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 77 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DatabaseVersion defines the current version of the database.
	DatabaseVersion byte = 1
)

Variables

View Source
var (
	ErrBlockTimeTooFarAheadInFuture = ierrors.New("a block cannot be too far ahead in the future")
	ErrUnsolidifiableCommitment     = ierrors.New("block referencing unsolidifiable commitment is not allowed")
	ErrFailToUpdateDropBuffer       = ierrors.New("failed to update dropped blocks buffer")
)
View Source
var (
	// ErrorCommitmentNotFound is returned for requests for commitments that are not available yet.
	ErrorCommitmentNotFound = ierrors.New("commitment not found")

	// ErrorSlotEvicted is returned for requests for commitments that belong to evicted slots.
	ErrorSlotEvicted = ierrors.New("slot evicted")
)

Functions

func WithAttestationProvider

func WithAttestationProvider(optsAttestationProvider module.Provider[*engine.Engine, attestation.Attestations]) options.Option[Protocol]

WithAttestationProvider is an option for the Protocol that allows to set the AttestationProvider.

func WithBaseDirectory

func WithBaseDirectory(baseDirectory string) options.Option[Protocol]

WithBaseDirectory is an option for the Protocol that allows to set the base directory.

func WithBlockDAGProvider

func WithBlockDAGProvider(optsBlockDAGProvider module.Provider[*engine.Engine, blockdag.BlockDAG]) options.Option[Protocol]

WithBlockDAGProvider is an option for the Protocol that allows to set the BlockDAGProvider.

func WithBlockGadgetProvider

func WithBlockGadgetProvider(optsBlockGadgetProvider module.Provider[*engine.Engine, blockgadget.Gadget]) options.Option[Protocol]

WithBlockGadgetProvider is an option for the Protocol that allows to set the BlockGadgetProvider.

func WithBlockRetainerProvider

func WithBlockRetainerProvider(optsBlockRetainerProvider module.Provider[*engine.Engine, retainer.BlockRetainer]) options.Option[Protocol]

WithBlockRetainerProvider is an option for the Protocol that allows to set the BlockRetainerProvider.

func WithBookerProvider

func WithBookerProvider(optsBookerProvider module.Provider[*engine.Engine, booker.Booker]) options.Option[Protocol]

WithBookerProvider is an option for the Protocol that allows to set the BookerProvider.

func WithClockProvider

func WithClockProvider(optsClockProvider module.Provider[*engine.Engine, clock.Clock]) options.Option[Protocol]

WithClockProvider is an option for the Protocol that allows to set the ClockProvider.

func WithCommitmentCheck

func WithCommitmentCheck(commitmentCheck bool) options.Option[Protocol]

WithCommitmentCheck is an option for the Protocol that allows to check the commitment and ledger state upon startup.

func WithEngineOptions

func WithEngineOptions(opts ...options.Option[engine.Engine]) options.Option[Protocol]

WithEngineOptions is an option for the Protocol that allows to set the EngineOptions.

func WithLedgerProvider

func WithLedgerProvider(optsLedgerProvider module.Provider[*engine.Engine, ledger.Ledger]) options.Option[Protocol]

WithLedgerProvider is an option for the Protocol that allows to set the LedgerProvider.

func WithMaxAllowedWallClockDrift

func WithMaxAllowedWallClockDrift(d time.Duration) options.Option[Protocol]

WithMaxAllowedWallClockDrift specifies how far in the future are blocks allowed to be ahead of our own wall clock (defaults to 0 seconds).

func WithNotarizationProvider

func WithNotarizationProvider(optsNotarizationProvider module.Provider[*engine.Engine, notarization.Notarization]) options.Option[Protocol]

WithNotarizationProvider is an option for the Protocol that allows to set the NotarizationProvider.

func WithPostSolidFilterProvider

func WithPostSolidFilterProvider(optsCommitmentFilterProvider module.Provider[*engine.Engine, postsolidfilter.PostSolidFilter]) options.Option[Protocol]

WithPostSolidFilterProvider is an option for the Protocol that allows to set the PostSolidFilterProvider.

func WithPreSolidFilterProvider

func WithPreSolidFilterProvider(optsFilterProvider module.Provider[*engine.Engine, presolidfilter.PreSolidFilter]) options.Option[Protocol]

WithPreSolidFilterProvider is an option for the Protocol that allows to set the PreSolidFilterProvider.

func WithSchedulerProvider

func WithSchedulerProvider(optsSchedulerProvider module.Provider[*engine.Engine, scheduler.Scheduler]) options.Option[Protocol]

WithSchedulerProvider is an option for the Protocol that allows to set the SchedulerProvider.

func WithSlotGadgetProvider

func WithSlotGadgetProvider(optsSlotGadgetProvider module.Provider[*engine.Engine, slotgadget.Gadget]) options.Option[Protocol]

WithSlotGadgetProvider is an option for the Protocol that allows to set the SlotGadgetProvider.

func WithSnapshotPath

func WithSnapshotPath(snapshot string) options.Option[Protocol]

WithSnapshotPath is an option for the Protocol that allows to set the snapshot path.

func WithStorageOptions

func WithStorageOptions(opts ...options.Option[storage.Storage]) options.Option[Protocol]

WithStorageOptions is an option for the Protocol that allows to set the StorageOptions.

func WithSybilProtectionProvider

func WithSybilProtectionProvider(optsSybilProtectionProvider module.Provider[*engine.Engine, sybilprotection.SybilProtection]) options.Option[Protocol]

WithSybilProtectionProvider is an option for the Protocol that allows to set the SybilProtectionProvider.

func WithSyncManagerProvider

func WithSyncManagerProvider(optsSyncManagerProvider module.Provider[*engine.Engine, syncmanager.SyncManager]) options.Option[Protocol]

WithSyncManagerProvider is an option for the Protocol that allows to set the SyncManagerProvider.

func WithTipManagerProvider

func WithTipManagerProvider(optsTipManagerProvider module.Provider[*engine.Engine, tipmanager.TipManager]) options.Option[Protocol]

WithTipManagerProvider is an option for the Protocol that allows to set the TipManagerProvider.

func WithTipSelectionProvider

func WithTipSelectionProvider(optsTipSelectionProvider module.Provider[*engine.Engine, tipselection.TipSelection]) options.Option[Protocol]

WithTipSelectionProvider is an option for the Protocol that allows to set the TipSelectionProvider.

func WithTransactionRetainerProvider

func WithTransactionRetainerProvider(optsTransactionRetainerProvider module.Provider[*engine.Engine, retainer.TransactionRetainer]) options.Option[Protocol]

WithTransactionRetainerProvider is an option for the Protocol that allows to set the TransactionRetainerProvider.

func WithUpgradeOrchestratorProvider

func WithUpgradeOrchestratorProvider(optsUpgradeOrchestratorProvider module.Provider[*engine.Engine, upgrade.Orchestrator]) options.Option[Protocol]

WithUpgradeOrchestratorProvider is an option for the Protocol that allows to set the UpgradeOrchestratorProvider.

Types

type Attestations

type Attestations struct {

	// Logger embeds a logger that can be used to log messages emitted by this component.
	log.Logger
	// contains filtered or unexported fields
}

Attestations is a subcomponent of the protocol that is responsible for handling attestation requests and responses.

func (*Attestations) Get

func (a *Attestations) Get(commitmentID iotago.CommitmentID) (commitment *model.Commitment, attestations []*iotago.Attestation, merkleProof *merklehasher.Proof[iotago.Identifier], err error)

Get returns the commitment, and its attestations (including the corresponding merkle proof).

type BlockFilteredEvent

type BlockFilteredEvent struct {
	Block  *model.Block
	Reason error
	Source peer.ID
}

type Blocks

type Blocks struct {

	// Logger embeds a logger that can be used to log messages emitted by this chain.
	log.Logger
	// contains filtered or unexported fields
}

Blocks is a subcomponent of the protocol that is responsible for handling block requests and responses.

func (*Blocks) ProcessRequest

func (b *Blocks) ProcessRequest(blockID iotago.BlockID, from peer.ID)

ProcessRequest processes the given block request.

func (*Blocks) ProcessResponse

func (b *Blocks) ProcessResponse(block *model.Block, from peer.ID)

ProcessResponse processes the given block response.

func (*Blocks) SendRequest

func (b *Blocks) SendRequest(blockID iotago.BlockID)

SendRequest sends a request for the given block to all peers.

func (*Blocks) SendResponse

func (b *Blocks) SendResponse(block *model.Block)

SendResponse sends the given block to all peers.

func (*Blocks) Shutdown

func (b *Blocks) Shutdown()

Shutdown shuts down the blocks protocol and waits for all pending requests to be finished.

type Chain

type Chain struct {
	// ForkingPoint contains the first commitment of this chain.
	ForkingPoint reactive.Variable[*Commitment]

	// ParentChain contains the chain that this chain forked from.
	ParentChain reactive.Variable[*Chain]

	// DivergencePointVerified contains a flag that indicates whether the divergence point of this chain is verified.
	DivergencePointVerified reactive.Event

	// ChildChains contains the set of all chains that forked from this chain.
	ChildChains reactive.Set[*Chain]

	// LatestCommitment contains the latest commitment of this chain.
	LatestCommitment reactive.Variable[*Commitment]

	// LatestAttestedCommitment contains the latest commitment of this chain for which attestations were received.
	LatestAttestedCommitment reactive.Variable[*Commitment]

	// LatestProducedCommitment contains the latest commitment of this chain that we produced ourselves by booking the
	// corresponding blocks in the Engine.
	LatestProducedCommitment reactive.Variable[*Commitment]

	// WarpSyncMode contains a flag that indicates whether this chain is in warp sync mode.
	WarpSyncMode reactive.Variable[bool]

	// LatestSyncedSlot contains the latest commitment of this chain for which all blocks were booked.
	LatestSyncedSlot reactive.Variable[iotago.SlotIndex]

	// OutOfSyncThreshold contains the slot at which the chain will consider itself to be out of sync and switch to warp
	// sync mode. It is derived from the latest network slot minus two times the max committable age.
	OutOfSyncThreshold reactive.Variable[iotago.SlotIndex]

	// RequestAttestations contains a flag that indicates whether this chain should verify the claimed weight by
	// requesting attestations.
	RequestAttestations reactive.Variable[bool]

	// StartEngine contains a flag that indicates whether this chain should verify the state by processing blocks in an
	// engine.
	StartEngine reactive.Variable[bool]

	// Engine contains the engine instance that is used to process blocks for this chain.
	Engine reactive.Variable[*engine.Engine]

	// IsEvicted contains a flag that indicates whether this chain was evicted.
	IsEvicted reactive.Event

	// Logger embeds a logger that can be used to log messages emitted by this chain.
	log.Logger
	// contains filtered or unexported fields
}

Chain represents a chain of commitments.

func (*Chain) Commitment

func (c *Chain) Commitment(slot iotago.SlotIndex) (commitment *Commitment, exists bool)

Commitment returns the Commitment for the given slot from the perspective of this chain.

func (*Chain) CumulativeVerifiedWeightAt

func (c *Chain) CumulativeVerifiedWeightAt(slot iotago.SlotIndex) uint64

CumulativeVerifiedWeightAt returns the cumulative verified weight at the given slot for this chain.

func (*Chain) DispatchBlock

func (c *Chain) DispatchBlock(block *model.Block, src peer.ID) (dispatched bool)

DispatchBlock dispatches the given block to the chain and its children (it is allowed to call this method on a nil receiver, in which case it will be a no-op with a return value of false).

func (*Chain) Inspect

func (c *Chain) Inspect(session ...inspection.Session) inspection.InspectedObject

Inspect inspects the Chain and its subcomponents.

func (*Chain) LastCommonSlot

func (c *Chain) LastCommonSlot() iotago.SlotIndex

LastCommonSlot returns the slot of the last commitment that is common to this chain and its parent chain.

func (*Chain) LatestEngine

func (c *Chain) LatestEngine() *engine.Engine

LatestEngine returns the latest engine instance that was spawned by the chain itself or one of its ancestors.

func (*Chain) WithInitializedEngine

func (c *Chain) WithInitializedEngine(callback func(engineInstance *engine.Engine) (shutdown func())) (shutdown func())

WithInitializedEngine is a reactive selector that executes the given callback once an Engine for this chain was initialized.

type Chains

type Chains struct {
	// Set contains all non-evicted chains that are managed by the protocol.
	reactive.Set[*Chain]

	// Main contains the main chain.
	Main reactive.Variable[*Chain]

	// HeaviestClaimedCandidate contains the candidate chain with the heaviest claimed weight according to its latest commitment. The weight has neither been checked via attestations nor verified by downloading all data.
	HeaviestClaimedCandidate *ChainsCandidate

	// HeaviestAttestedCandidate contains the candidate chain with the heaviest weight as checked by attestations. The chain has not been instantiated into an engine yet.
	HeaviestAttestedCandidate *ChainsCandidate

	// HeaviestVerifiedCandidate contains the candidate chain with the heaviest verified weight, meaning the chain has been instantiated into an engine and the commitments have been produced by the engine itself.
	HeaviestVerifiedCandidate *ChainsCandidate

	// LatestSeenSlot contains the slot of the latest commitment of any received block.
	LatestSeenSlot reactive.Variable[iotago.SlotIndex]

	// Logger contains a reference to the logger that is used by this component.
	log.Logger
	// contains filtered or unexported fields
}

Chains is a subcomponent of the protocol that exposes the chains that are managed by the protocol and that implements the chain switching logic.

func (*Chains) Inspect

func (c *Chains) Inspect(session ...inspection.Session) inspection.InspectedObject

Inspect inspects the Chains and its subcomponents.

func (*Chains) WithInitializedEngines

func (c *Chains) WithInitializedEngines(callback func(chain *Chain, engine *engine.Engine) (shutdown func())) (shutdown func())

WithInitializedEngines is a reactive selector that executes the given callback for each managed chain that initialized its engine.

type ChainsCandidate

type ChainsCandidate struct {
	// Variable contains the heaviest chain candidate.
	reactive.Variable[*Chain]
	// contains filtered or unexported fields
}

ChainsCandidate implements a wrapper for the logic of tracking the heaviest candidate of all Chains in respect to some monitored weight variable.

type Commitment

type Commitment struct {
	// Commitment contains the underlying model.Commitment that is represented by this Commitment.
	*model.Commitment

	// Parent contains the Commitment that is referenced as a parent in this Commitment.
	Parent reactive.Variable[*Commitment]

	// Children contains the Commitments that reference this Commitment as a parent.
	Children reactive.Set[*Commitment]

	// MainChild contains the Commitment that is the main child of this Commitment (continues the chain).
	MainChild reactive.Variable[*Commitment]

	// Chain contains the Chain that this Commitment is part of.
	Chain reactive.Variable[*Chain]

	// RequestAttestations contains a flag indicating if the node should request attestations for this Commitment.
	RequestAttestations reactive.Variable[bool]

	// WarpSyncBlocks contains a flag indicating if the node should request the blocks of this Commitment using warp
	// sync.
	WarpSyncBlocks reactive.Variable[bool]

	// BlocksToWarpSync contains the set of blocks that should be requested using warp sync.
	BlocksToWarpSync reactive.Variable[ds.Set[iotago.BlockID]]

	// Weight contains the weight of this Commitment (the difference between the cumulative weight of this Commitment
	// and its parent).
	Weight reactive.Variable[uint64]

	// AttestedWeight contains the weight of the Commitment that was attested by other nodes.
	AttestedWeight reactive.Variable[uint64]

	// CumulativeWeight contains the cumulative weight of all Commitments up to this point.
	CumulativeWeight reactive.Variable[uint64]

	// CumulativeAttestedWeight contains the cumulative weight of all attested Commitments up to this point.
	CumulativeAttestedWeight reactive.Variable[uint64]

	// CumulativeVerifiedWeight contains the cumulative weight of all verified Commitments up to this point.
	CumulativeVerifiedWeight reactive.Variable[uint64]

	// IsRoot contains a flag indicating if this Commitment is the root of the Chain.
	IsRoot reactive.Event

	// IsAttested contains a flag indicating if we have received attestations for this Commitment.
	IsAttested reactive.Event

	// IsSynced contains a flag that indicates if a Commitment was fully downloaded and processed.
	IsSynced reactive.Event

	// IsCommittable contains a flag that indicates if a Commitment is ready to be committed by the warp sync process.
	IsCommittable reactive.Event

	// IsVerified contains a flag indicating if this Commitment is verified (we produced this Commitment ourselves by
	// booking all the contained blocks and transactions).
	IsVerified reactive.Event

	// IsAboveLatestVerifiedCommitment contains a flag indicating if this Commitment is above the latest verified
	// Commitment.
	IsAboveLatestVerifiedCommitment reactive.Variable[bool]

	// ReplayDroppedBlocks contains a flag indicating if we should replay the blocks that were dropped while the
	// Commitment was pending.
	ReplayDroppedBlocks reactive.Variable[bool]

	// IsEvicted contains a flag indicating if this Commitment was evicted from the Protocol.
	IsEvicted reactive.Event

	// Logger embeds a logger that can be used to log messages emitted by this Commitment.
	log.Logger
	// contains filtered or unexported fields
}

Commitment represents a commitment to a specific ledger state at a specific point in time that is part of a chain of commitments produced by the nodes in the network.

func (*Commitment) Inspect

func (c *Commitment) Inspect(session ...inspection.Session) inspection.InspectedObject

Inspect inspects the Commitment and its subcomponents.

func (*Commitment) Less

func (c *Commitment) Less(other *Commitment) bool

Less is a function that is used to break ties between two Commitments that have the same cumulative weight by using the ID of their divergence points (the first commitment that is different between their chains).

func (*Commitment) TargetEngine

func (c *Commitment) TargetEngine() *engine.Engine

TargetEngine returns the engine that is responsible for booking the blocks of this Commitment.

type CommitmentVerifier

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

type Commitments

type Commitments struct {
	// Set contains all non-evicted commitments that are managed by the protocol.
	reactive.Set[*Commitment]

	// Root contains the root commitment.
	Root reactive.Variable[*Commitment]

	// Logger contains a reference to the logger that is used by this component.
	log.Logger
	// contains filtered or unexported fields
}

Commitments is a subcomponent of the protocol that exposes the commitments that are managed by the protocol and that are either published from the network or created by an engine of the node.

func (*Commitments) API

func (c *Commitments) API(commitmentID iotago.CommitmentID) (commitmentAPI *engine.CommitmentAPI, err error)

API returns the CommitmentAPI for the given commitmentID. If the Commitment is not available, it will return ErrorCommitmentNotFound.

func (*Commitments) Get

func (c *Commitments) Get(commitmentID iotago.CommitmentID, requestIfMissing ...bool) (commitment *Commitment, err error)

Get returns the Commitment for the given commitmentID. If the Commitment is not available yet, it will return an ErrorCommitmentNotFound. It is possible to trigger a request for the Commitment by passing true as the second argument.

func (*Commitments) Inspect

func (c *Commitments) Inspect(session ...inspection.Session) inspection.InspectedObject

Inspect inspects the Commitments and its subcomponents.

type Engines

type Engines struct {
	// Main contains the main engine.
	Main reactive.Variable[*engine.Engine]

	// ReactiveModule embeds a reactive module that provides default API for logging and lifecycle management.
	module.Module
	// contains filtered or unexported fields
}

Engines is a subcomponent of the protocol that exposes the engines that are managed by the protocol.

func (*Engines) ForkAtSlot

func (e *Engines) ForkAtSlot(slot iotago.SlotIndex) (*engine.Engine, error)

ForkAtSlot creates a new engine instance that forks from the main engine at the given slot.

func (*Engines) Inspect

func (e *Engines) Inspect(session ...inspection.Session) inspection.InspectedObject

Inspect inspects the Engines and its subcomponents.

type Events

type Events struct {
	Engine         *engine.Events
	ProtocolFilter *event.Event1[*BlockFilteredEvent]
}

Events exposes the Events of the main engine of the protocol at a single endpoint.

TODO: It should be replaced with reactive calls to the corresponding events and be deleted but we can do this in a later PR (to minimize the code changes to review).

func NewEvents

func NewEvents() *Events

NewEvents creates a new Events instance.

type Network

type Network struct {
	// Protocol contains the network endpoint of the protocol.
	*core.Protocol

	// Logger contains a reference to the logger that is used by this component.
	log.Logger
	// contains filtered or unexported fields
}

Network is a subcomponent of the protocol that is responsible for handling the network communication.

func (*Network) OnBlockReceived

func (n *Network) OnBlockReceived(callback func(block *model.Block, src peer.ID)) (unsubscribe func())

OnBlockReceived overwrites the OnBlockReceived method of the core protocol to filter out invalid blocks.

type Options

type Options struct {
	// BaseDirectory is the directory where the protocol will store its data.
	BaseDirectory string

	// SnapshotPath is the path to the snapshot file that should be used to initialize the protocol.
	SnapshotPath string

	// CommitmentCheck is an opt flag that allows engines check correctness of commitment and ledger state upon startup.
	CommitmentCheck bool

	// MaxAllowedWallClockDrift specifies how far in the future are blocks allowed to be ahead of our own wall clock (defaults to 0 seconds).
	MaxAllowedWallClockDrift time.Duration

	// EngineOptions contains the options for the Engines.
	EngineOptions []options.Option[engine.Engine]

	// StorageOptions contains the options for the Storage.
	StorageOptions []options.Option[storage.Storage]

	CommitmentRequesterOptions  []options.Option[eventticker.EventTicker[iotago.SlotIndex, iotago.CommitmentID]]
	AttestationRequesterOptions []options.Option[eventticker.EventTicker[iotago.SlotIndex, iotago.CommitmentID]]
	WarpSyncRequesterOptions    []options.Option[eventticker.EventTicker[iotago.SlotIndex, iotago.CommitmentID]]

	// PreSolidFilterProvider contains the provider for the PreSolidFilter engine modules.
	PreSolidFilterProvider module.Provider[*engine.Engine, presolidfilter.PreSolidFilter]

	// PostSolidFilterProvider contains the provider for the PostSolidFilter engine modules.
	PostSolidFilterProvider module.Provider[*engine.Engine, postsolidfilter.PostSolidFilter]

	// BlockDAGProvider contains the provider for the BlockDAG engine modules.
	BlockDAGProvider module.Provider[*engine.Engine, blockdag.BlockDAG]

	// TipManagerProvider contains the provider for the TipManager engine modules.
	TipManagerProvider module.Provider[*engine.Engine, tipmanager.TipManager]

	// TipSelectionProvider contains the provider for the TipSelection engine modules.
	TipSelectionProvider module.Provider[*engine.Engine, tipselection.TipSelection]

	// BookerProvider contains the provider for the Booker engine modules.
	BookerProvider module.Provider[*engine.Engine, booker.Booker]

	// ClockProvider contains the provider for the Clock engine modules.
	ClockProvider module.Provider[*engine.Engine, clock.Clock]

	// BlockGadgetProvider contains the provider for the BlockGadget engine modules.
	BlockGadgetProvider module.Provider[*engine.Engine, blockgadget.Gadget]

	// SlotGadgetProvider contains the provider for the SlotGadget engine modules.
	SlotGadgetProvider module.Provider[*engine.Engine, slotgadget.Gadget]

	// SybilProtectionProvider contains the provider for the SybilProtection engine modules.
	SybilProtectionProvider module.Provider[*engine.Engine, sybilprotection.SybilProtection]

	// NotarizationProvider contains the provider for the Notarization engine modules.
	NotarizationProvider module.Provider[*engine.Engine, notarization.Notarization]

	// SyncManagerProvider contains the provider for the SyncManager engine modules.
	SyncManagerProvider module.Provider[*engine.Engine, syncmanager.SyncManager]

	// AttestationProvider contains the provider for the Attestation engine modules.
	AttestationProvider module.Provider[*engine.Engine, attestation.Attestations]

	// LedgerProvider contains the provider for the Ledger engine modules.
	LedgerProvider module.Provider[*engine.Engine, ledger.Ledger]

	// BlockRetainerProvider contains the provider for the BlockRetainer engine modules.
	BlockRetainerProvider module.Provider[*engine.Engine, retainer.BlockRetainer]

	// TransactionRetainerProvider contains the provider for the TransactionRetainer engine modules.
	TransactionRetainerProvider module.Provider[*engine.Engine, retainer.TransactionRetainer]

	// SchedulerProvider contains the provider for the Scheduler engine modules.
	SchedulerProvider module.Provider[*engine.Engine, scheduler.Scheduler]

	// UpgradeOrchestratorProvider contains the provider for the UpgradeOrchestrator engine modules.
	UpgradeOrchestratorProvider module.Provider[*engine.Engine, upgrade.Orchestrator]
}

Options contains the options for the Protocol.

func NewDefaultOptions

func NewDefaultOptions() *Options

NewDefaultOptions creates new default options instance for the Protocol.

type Protocol

type Protocol struct {
	// Events contains a centralized access point for all events that are triggered by the main engine of the protocol.
	Events *Events

	// Workers contains the worker pools that are used by the protocol.
	Workers *workerpool.Group

	// Network contains the network endpoint of the protocol.
	Network *Network

	// Commitments contains the commitments that are managed by the protocol.
	Commitments *Commitments

	// Chains contains the chains that are managed by the protocol.
	Chains *Chains

	// Blocks contains the subcomponent that is responsible for handling block requests and responses.
	Blocks *Blocks

	// Attestations contains the subcomponent that is responsible for handling attestation requests and responses.
	Attestations *Attestations

	// WarpSync contains the subcomponent that is responsible for handling warp sync requests and responses.
	WarpSync *WarpSync

	// Engines contains the engines that are managed by the protocol.
	Engines *Engines

	// Options contains the options that were used to create the protocol.
	Options *Options

	// EvictionState contains the eviction state of the protocol.
	reactive.EvictionState[iotago.SlotIndex]

	// ReactiveModule embeds the reactive module logic of the protocol.
	module.Module
}

Protocol is an implementation of the IOTA core protocol.

func New

func New(logger log.Logger, workers *workerpool.Group, networkEndpoint network.Endpoint, opts ...options.Option[Protocol]) *Protocol

New creates a new protocol instance from the given parameters.

func (*Protocol) APIForEpoch

func (p *Protocol) APIForEpoch(epoch iotago.EpochIndex) iotago.API

APIForEpoch returns the API for the given epoch.

func (*Protocol) APIForSlot

func (p *Protocol) APIForSlot(slot iotago.SlotIndex) iotago.API

APIForSlot returns the API for the given slot.

func (*Protocol) APIForTime

func (p *Protocol) APIForTime(t time.Time) iotago.API

APIForTime returns the API for the given time.

func (*Protocol) APIForVersion

func (p *Protocol) APIForVersion(version iotago.Version) (api iotago.API, err error)

APIForVersion returns the API for the given version.

func (*Protocol) CommittedAPI

func (p *Protocol) CommittedAPI() iotago.API

CommittedAPI returns the API for the committed state.

func (*Protocol) Inspect

func (p *Protocol) Inspect(session ...inspection.Session) inspection.InspectedObject

Inspect inspects the protocol and its subcomponents.

func (*Protocol) IssueBlock

func (p *Protocol) IssueBlock(block *model.Block) error

IssueBlock issues a block to the node.

func (*Protocol) LatestAPI

func (p *Protocol) LatestAPI() iotago.API

LatestAPI returns the latest API.

func (*Protocol) Run

func (p *Protocol) Run(ctx context.Context) error

Run starts the protocol.

type WarpSync

type WarpSync struct {

	// Logger embeds a logger that can be used to log messages emitted by this chain.
	log.Logger
	// contains filtered or unexported fields
}

WarpSync is a subcomponent of the protocol that is responsible for handling warp sync requests and responses.

func (*WarpSync) ProcessRequest

func (w *WarpSync) ProcessRequest(commitmentID iotago.CommitmentID, from peer.ID)

ProcessRequest processes the given warp sync request.

func (*WarpSync) ProcessResponse

func (w *WarpSync) ProcessResponse(commitmentID iotago.CommitmentID, blockIDsBySlotCommitment map[iotago.CommitmentID]iotago.BlockIDs, proof *merklehasher.Proof[iotago.Identifier], transactionIDs iotago.TransactionIDs, mutationProof *merklehasher.Proof[iotago.Identifier], from peer.ID)

ProcessResponse processes the given warp sync response.

func (*WarpSync) SendRequest

func (w *WarpSync) SendRequest(commitmentID iotago.CommitmentID)

SendRequest sends a warp sync request for the given commitment ID to all peers.

func (*WarpSync) SendResponse

func (w *WarpSync) SendResponse(commitment *Commitment, blockIDsBySlotCommitment map[iotago.CommitmentID]iotago.BlockIDs, roots *iotago.Roots, transactionIDs iotago.TransactionIDs, to peer.ID)

SendResponse sends a warp sync response for the given commitment ID to the given peer.

func (*WarpSync) Shutdown

func (w *WarpSync) Shutdown()

Shutdown shuts down the warp sync protocol.

Jump to

Keyboard shortcuts

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