engine

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxRoundWindow                 = 10
	DefaultProcessingBlocks               = 500
	DefaultMaxProposalWaitTime            = 5 * time.Second
	DefaultReplicationRequestTimeout      = 5 * time.Second
	DefaultEmptyVoteRebroadcastTimeout    = 5 * time.Second
	DefaultFinalizeVoteRebroadcastTimeout = 6 * time.Second
	EmptyVoteTimeoutID                    = "rebroadcast_empty_vote"

	// DefaultMaxReplicationResponseSize is the max size of a replication response. the host node rejects messages larger
	// than 2 MiB. we cap at 80% (4/5) same as the host node (see utils/constants/networking.go)
	DefaultMaxReplicationResponseSize = host.MaxContainersLen
)

Variables

View Source
var (
	ErrAlreadyStarted = errors.New("epoch already started")
)

Functions

func BatchSequences

func BatchSequences(seqs []uint64, numNodes uint64, maxSize uint64) [][]uint64

BatchSequences distributes [seqs] as evenly as possible among [numNodes] nodes, returning one batch per node share. Every batch contains at most [maxSize] sequences. a share exceeding [maxSize] is emitted as multiple batches. [seqs] does not need to be sorted or contiguous, it is sorted in place, and the returned batches are sub-slices of it, ordered from lowest to highest sequence.

func GetLatestVerifiedQuorumRound

func GetLatestVerifiedQuorumRound(round *Round, emptyNotarization *common.EmptyNotarization) *common.VerifiedQuorumRound

GetLatestVerifiedQuorumRound returns the latest verified quorum round given a round and empty notarization. If both are nil, it returns nil.

func LeaderForRound

func LeaderForRound(nodes []common.NodeID, r uint64) common.NodeID

func NewRandomSource

func NewRandomSource() (*rand.Rand, error)

func NodeIDsFromVotes

func NodeIDsFromVotes[VS voteSigner](votes []VS) []common.NodeID

func RetrieveLastIndexFromStorage

func RetrieveLastIndexFromStorage(s common.Storage) (*common.VerifiedFinalizedBlock, error)

RetrieveLastIndexFromStorage retrieves the latest block and finalization from storage. Returns an error if it cannot be retrieved but the storage has some block. Returns (nil, nil) if the storage is empty.

func VerifyQC

func VerifyQC(qc common.QuorumCertificate, isQuorum func(signers []common.NodeID) bool, eligibleSigners map[string][]byte, messageToVerify verifiableMessage, nodes common.Nodes) error

Types

type EmptyVoteSet

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

type Epoch

type Epoch struct {
	EpochConfig
	// contains filtered or unexported fields
}

func NewEpoch

func NewEpoch(conf EpochConfig) (*Epoch, error)

func (*Epoch) AdvanceTime

func (e *Epoch) AdvanceTime(t time.Time)

AdvanceTime hints the engine that the given amount of time has passed.

func (*Epoch) HandleMessage

func (e *Epoch) HandleMessage(msg *common.Message, from common.NodeID) error

HandleMessage notifies the engine about a reception of a message.

func (*Epoch) Metadata

func (e *Epoch) Metadata() common.ProtocolMetadata

Metadata returns the metadata of the next expected block of the epoch.

func (*Epoch) Start

func (e *Epoch) Start() error

func (*Epoch) Stop

func (e *Epoch) Stop()

func (*Epoch) VerifyBlockMessageVote

func (e *Epoch) VerifyBlockMessageVote(from common.NodeID, md common.BlockHeader, vote common.Vote) error

VerifyBlockMessageVote checks if we have the block in the future messages map. If so, it means we have already verified the vote associated with this proposal. If not, it verifies that the vote corresponds to the block proposed, and that the vote is properly signed.

type EpochConfig

type EpochConfig struct {
	MaxProposalWait            time.Duration
	MaxRoundWindow             uint64
	MaxReplicationResponseSize int
	MaxRebroadcastWait         time.Duration
	FinalizeRebroadcastTimeout time.Duration
	QCDeserializer             common.QCDeserializer
	Logger                     common.Logger
	ID                         common.NodeID
	Signer                     common.Signer
	Verifier                   common.SignatureVerifier
	BlockDeserializer          common.BlockDeserializer
	SignatureAggregatorCreator common.SignatureAggregatorCreator
	Comm                       common.Communication
	Storage                    common.Storage
	WAL                        common.WriteAheadLog
	BlockBuilder               common.BlockBuilder
	Epoch                      uint64
	StartTime                  time.Time
	ReplicationEnabled         bool
	RandomSource               *rand.Rand
}

type Monitor

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

func NewMonitor

func NewMonitor(startTime time.Time, logger common.Logger) *Monitor

func (*Monitor) AdvanceTime

func (m *Monitor) AdvanceTime(t time.Time)

func (*Monitor) CancelFutureTask

func (m *Monitor) CancelFutureTask()

func (*Monitor) CancelTask

func (m *Monitor) CancelTask()

func (*Monitor) Close

func (m *Monitor) Close()

func (*Monitor) FutureTask

func (m *Monitor) FutureTask(timeout time.Duration, f func())

func (*Monitor) RunTask

func (m *Monitor) RunTask(f func()) bool

type NotarizationTime

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

func NewNotarizationTime

func NewNotarizationTime(
	finalizeVoteRebroadcastTimeout time.Duration,
	haveUnFinalizedNotarization func() (uint64, bool),
	rebroadcastFinalizationVotes func(),
	getRound func() uint64,
) NotarizationTime

func (*NotarizationTime) CheckForNotFinalizedNotarizedBlocks

func (nt *NotarizationTime) CheckForNotFinalizedNotarizedBlocks(now time.Time)

type OneTimeVerifier

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

func NewOneTimeVerifier

func NewOneTimeVerifier(logger common.Logger) *OneTimeVerifier

func (*OneTimeVerifier) Wrap

func (otv *OneTimeVerifier) Wrap(block common.Block) common.Block

type ReplicationState

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

func NewReplicationState

func NewReplicationState(logger common.Logger, comm Sender, myNodeID common.NodeID, maxRoundWindow uint64, enabled bool, start time.Time, lock *sync.Mutex, rng *rand.Rand) *ReplicationState

func (*ReplicationState) AdvanceTime

func (r *ReplicationState) AdvanceTime(now time.Time)

func (*ReplicationState) Close

func (r *ReplicationState) Close()

func (*ReplicationState) CreateDependencyTasks

func (r *ReplicationState) CreateDependencyTasks(parent *common.Digest, parentSeq uint64, emptyRounds []uint64)

CreateDependencyTasks creates tasks to refetch the given parent digest and empty rounds. If there are no dependencies, no tasks are created.

func (*ReplicationState) DeleteRound

func (r *ReplicationState) DeleteRound(round uint64)

func (*ReplicationState) DeleteSeq

func (r *ReplicationState) DeleteSeq(seq uint64)

func (*ReplicationState) GetBlockWithSeq

func (r *ReplicationState) GetBlockWithSeq(seq uint64) common.Block

func (*ReplicationState) GetFinalizedBlockForSequence

func (r *ReplicationState) GetFinalizedBlockForSequence(seq uint64) (common.Block, *common.Finalization, bool)

func (*ReplicationState) GetHighestRound

func (r *ReplicationState) GetHighestRound() uint64

GetHighestRound returns the highest round known to the replicator.

func (*ReplicationState) GetLowestRound

func (r *ReplicationState) GetLowestRound() *common.QuorumRound

func (*ReplicationState) MaybeAdvanceState

func (r *ReplicationState) MaybeAdvanceState(nextSequenceToCommit uint64, currentRound uint64, lastCommittedRound uint64)

MaybeAdvanceState attempts to collect future sequences if there are more to be collected and the round has caught up for us to send the request.

func (*ReplicationState) ReceivedFutureFinalization

func (r *ReplicationState) ReceivedFutureFinalization(finalization *common.Finalization, nextSeqToCommit uint64)

receivedFutureFinalization notifies the replication state a finalization was created in a future round.

func (*ReplicationState) ReceivedFutureRound

func (r *ReplicationState) ReceivedFutureRound(round, seq, currentRound uint64, signers []common.NodeID)

receivedFutureRound notifies the replication state of a future round.

func (*ReplicationState) ResendFinalizationRequest

func (r *ReplicationState) ResendFinalizationRequest(seq uint64, signers []common.NodeID)

ResendFinalizationRequest notifies the replication state that `seq` should be re-requested.

func (*ReplicationState) StoreQuorumRound

func (r *ReplicationState) StoreQuorumRound(round *common.QuorumRound)

StoreQuorumRound stores the quorum round into the replication state.

type Round

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

func NewRound

func NewRound(block common.VerifiedBlock) *Round

func SetRound

func SetRound(block common.VerifiedBlock, notarization *common.Notarization, finalization *common.Finalization) *Round

SetRound is a helper function that is used for tests to create a round.

type Sender

type Sender interface {
	// Send sends a message to the given destination node
	Send(msg *common.Message, destination common.NodeID)
}

Jump to

Keyboard shortcuts

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