Documentation ¶
Overview ¶
This package implements a protocol for running a chain in a node. Its main responsibilities:
- Track, which branch is the latest/correct one.
- Maintain a set of committee logs (1 for each committee this node participates in).
- Maintain a set of consensus instances (one of them is the current one).
- Supervise the Mempool and StateMgr.
- Handle messages from the NodeConn (AO confirmed / rejected, Request received).
- Posting StateTX to NodeConn.
> VARIABLES: > LatestActiveCmt -- The latest committee, that was active. > This field will be nil if the node is not part of the committee. > On the resynchronization it will store the previous active committee. > LatestActiveAO -- The latest AO we are building upon. > Derived, equal to NeedConsensus.BaseAO. > LatestConfirmedAO -- The latest ConfirmedAO from L1. > This one usually follows the LatestAliasOutput, > but can be published from outside and override the LatestAliasOutput. > AccessNodes -- The set of access nodes for the current head. > Union of On-Chain access nodes and the nodes permitted by this node. > NeedConsensus -- A request to run consensus. > Always set based on output of the main CmtLog. > NeedPublishTX -- Requests to publish TX'es. > - Added upon reception of the Consensus Output, > if it is still in NeedConsensus at the time. > - Removed on PublishResult from the NodeConn. > > UPON Reception of ConfirmedAO: > Set LatestConfirmedAO <- ConfirmedAO > IF this node is in the committee THEN > Pass it to the corresponding CmtLog; HandleCmtLogOutput. > ELSE > IF LatestActiveCmt != nil THEN > Send Suspend to Last Active CmtLog; HandleCmtLogOutput > Set LatestActiveCmt <- NIL > Set NeedConsensus <- NIL > UPON Reception of PublishResult: > Clear the TX from the NeedPublishTX variable. > If result.confirmed = false THEN > Forward it to ChainMgr; HandleCmtLogOutput. > ELSE > NOP // AO has to be received as ConfirmedAO. > UPON Reception of Consensus Output/DONE: > IF ConsensusOutput.BaseAO == NeedConsensus THEN > Add ConsensusOutput.TX to NeedPublishTX > Forward the message to the corresponding CmtLog; HandleCmtLogOutput. > Update AccessNodes. > UPON Reception of Consensus Output/SKIP: > Forward the message to the corresponding CmtLog; HandleCmtLogOutput. > UPON Reception of Consensus Timeout: > Forward the message to the corresponding CmtLog; HandleCmtLogOutput. > UPON Reception of CmtLog.NextLI message: > Forward it to the corresponding CmtLog; HandleCmtLogOutput. > > PROCEDURE HandleCmtLogOutput(cmt): > Wrap out messages. > IF cmt == LatestActiveCmt || LatestActiveCmt == NIL THEN > Set LatestActiveCmt <- cmt > Set NeedConsensus <- output.NeedConsensus // Can be nil > ELSE > IF output.NeedConsensus == nil THEN > RETURN // No need to change the committee. > IF LatestActiveCmt != nil THEN > Suspend(LatestActiveCmt) > Set LatestActiveCmt <- cmt > Set NeedConsensus <- output.NeedConsensus
Index ¶
- Variables
- func NewInputAliasOutputConfirmed(aliasOutput *isc.AliasOutputWithID) gpa.Input
- func NewInputChainTxPublishResult(committeeAddr iotago.Ed25519Address, txID iotago.TransactionID, ...) gpa.Input
- func NewInputConsensusOutputDone(committeeAddr iotago.Ed25519Address, logIndex cmtLog.LogIndex, ...) gpa.Input
- func NewInputConsensusOutputSkip(committeeAddr iotago.Ed25519Address, logIndex cmtLog.LogIndex, ...) gpa.Input
- func NewInputConsensusTimeout(committeeAddr iotago.Ed25519Address, logIndex cmtLog.LogIndex) gpa.Input
- func NewMsgCmtLog(committeeAddr iotago.Ed25519Address, wrapped gpa.Message) gpa.Message
- type ChainMgr
- type NeedConsensus
- type NeedPublishTX
- type Output
- func (o *Output) ActiveAccessNodes() []*cryptolib.PublicKey
- func (o *Output) LatestActiveAliasOutput() *isc.AliasOutputWithID
- func (o *Output) LatestConfirmedAliasOutput() *isc.AliasOutputWithID
- func (o *Output) NeedConsensus() *NeedConsensus
- func (o *Output) NeedPublishTX() map[iotago.TransactionID]*NeedPublishTX
- func (o *Output) String() string
Constants ¶
This section is empty.
Variables ¶
var ErrNotInCommittee = errors.New("ErrNotInCommittee")
Functions ¶
func NewInputAliasOutputConfirmed ¶
func NewInputAliasOutputConfirmed(aliasOutput *isc.AliasOutputWithID) gpa.Input
func NewInputChainTxPublishResult ¶
func NewInputChainTxPublishResult(committeeAddr iotago.Ed25519Address, txID iotago.TransactionID, aliasOutput *isc.AliasOutputWithID, confirmed bool) gpa.Input
func NewInputConsensusOutputDone ¶
func NewInputConsensusOutputDone( committeeAddr iotago.Ed25519Address, logIndex cmtLog.LogIndex, baseAliasOutputID iotago.OutputID, nextAliasOutput *isc.AliasOutputWithID, nextState state.StateDraft, transaction *iotago.Transaction, ) gpa.Input
func NewMsgCmtLog ¶
Types ¶
type ChainMgr ¶
func New ¶
func New( me gpa.NodeID, chainID isc.ChainID, consensusStateRegistry cmtLog.ConsensusStateRegistry, dkShareRegistryProvider registry.DKShareRegistryProvider, nodeIDFromPubKey func(pubKey *cryptolib.PublicKey) gpa.NodeID, activeAccessNodesCB func([]*cryptolib.PublicKey), log *logger.Logger, ) (ChainMgr, error)
type NeedConsensus ¶
type NeedConsensus struct { CommitteeAddr iotago.Ed25519Address LogIndex cmtLog.LogIndex BaseAliasOutput *isc.AliasOutputWithID }
func (*NeedConsensus) String ¶
func (nc *NeedConsensus) String() string
type NeedPublishTX ¶
type NeedPublishTX struct { CommitteeAddr iotago.Ed25519Address TxID iotago.TransactionID Tx *iotago.Transaction BaseAliasOutputID iotago.OutputID // The consumed AliasOutput. NextAliasOutput *isc.AliasOutputWithID // The next one (produced by the TX.) }
type Output ¶
type Output struct {
// contains filtered or unexported fields
}
func (*Output) ActiveAccessNodes ¶
func (*Output) LatestActiveAliasOutput ¶
func (o *Output) LatestActiveAliasOutput() *isc.AliasOutputWithID
func (*Output) LatestConfirmedAliasOutput ¶
func (o *Output) LatestConfirmedAliasOutput() *isc.AliasOutputWithID
func (*Output) NeedConsensus ¶
func (o *Output) NeedConsensus() *NeedConsensus
func (*Output) NeedPublishTX ¶
func (o *Output) NeedPublishTX() map[iotago.TransactionID]*NeedPublishTX