Documentation ¶
Overview ¶
Implementations of different state machines.
Index ¶
- type AbsCausalStateMachine
- func (spi *AbsCausalStateMachine) AbsDoneClear()
- func (spi *AbsCausalStateMachine) AbsDoneKeep()
- func (spi *AbsCausalStateMachine) AbsGetDependentItems() (childIndices []sig.ConsIDPub)
- func (spi *AbsCausalStateMachine) AbsGetInitialFirstIndex(initialState []byte) types.ConsensusID
- func (spi *AbsCausalStateMachine) AbsGetProposal(hdr messages.MsgHeader)
- func (spi *AbsCausalStateMachine) AbsHasDecided(proposer sig.Pub, index types.ConsensusIndex, decision []byte, ...)
- func (spi *AbsCausalStateMachine) AbsInit(index types.ConsensusIndex, gc *generalconfig.GeneralConfig, ...)
- func (spi *AbsCausalStateMachine) AbsStartIndex(consumedIndices []types.ConsensusID, ...)
- func (spi *AbsCausalStateMachine) CheckOK()
- func (spi *AbsCausalStateMachine) Collect()
- func (spi *AbsCausalStateMachine) EndTest()
- func (spi *AbsCausalStateMachine) FinishedLastRound() bool
- func (spi *AbsCausalStateMachine) GetDecided() bool
- func (spi *AbsCausalStateMachine) GetDone() types.DoneType
- func (spi *AbsCausalStateMachine) GetIndex() types.ConsensusIndex
- func (spi *AbsCausalStateMachine) IsDone() bool
- type AbsRandSM
- func (spi *AbsRandSM) AbsRandInit(gc *generalconfig.GeneralConfig)
- func (spi *AbsRandSM) GetRand() [32]byte
- func (spi *AbsRandSM) GetRndNumBytes() (n int)
- func (spi *AbsRandSM) RandCheckDecision(buf io.Reader) (err error)
- func (spi *AbsRandSM) RandGetProposal(buff io.Writer)
- func (spi *AbsRandSM) RandHasDecided(proposer sig.Pub, buf io.Reader, setBytes bool) (n int, err error)
- func (spi *AbsRandSM) RandStartIndex(prevRand [32]byte)
- type AbsRandSMNotSupported
- type AbsStateMachine
- func (spi *AbsStateMachine) AbsDoneClear()
- func (spi *AbsStateMachine) AbsDoneKeep()
- func (spi *AbsStateMachine) AbsGetProposal(hdr messages.MsgHeader)
- func (spi *AbsStateMachine) AbsHasDecided(nxt types.ConsensusInt, dec []byte) (shouldReturn bool)
- func (spi *AbsStateMachine) AbsInit(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, ...)
- func (spi *AbsStateMachine) AbsStartIndex(nxt types.ConsensusInt)
- func (spi *AbsStateMachine) CheckStartStatsRecording(index types.ConsensusInt)
- func (spi *AbsStateMachine) Collect()
- func (spi *AbsStateMachine) EndTest()
- func (spi *AbsStateMachine) FailAfter(end types.ConsensusInt)
- func (spi *AbsStateMachine) FinishedLastRound() bool
- func (spi *AbsStateMachine) GetDecided() bool
- func (spi *AbsStateMachine) GetDone() types.DoneType
- func (spi *AbsStateMachine) GetIndex() types.ConsensusIndex
- func (spi *AbsStateMachine) GetStartedRecordingStats() bool
- func (spi *AbsStateMachine) IsDone() bool
- type BinCons1ProposalInfo
- func (spi *BinCons1ProposalInfo) CheckDecisions(decs [][]byte) (outOforderErrors, errs []error)
- func (spi *BinCons1ProposalInfo) DoneClear()
- func (spi *BinCons1ProposalInfo) DoneKeep()
- func (spi *BinCons1ProposalInfo) EndTest()
- func (spi *BinCons1ProposalInfo) FinishedLastRound() bool
- func (spi *BinCons1ProposalInfo) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
- func (spi *BinCons1ProposalInfo) GetInitialState() []byte
- func (spi *BinCons1ProposalInfo) GetProposal()
- func (spi *BinCons1ProposalInfo) GetSMStats() consinterface.SMStats
- func (spi *BinCons1ProposalInfo) HasDecided(proposer sig.Pub, nxt types.ConsensusInt, decision []byte)
- func (spi *BinCons1ProposalInfo) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, ...)
- func (spi *BinCons1ProposalInfo) StartIndex(nxt types.ConsensusInt) consinterface.StateMachineInterface
- func (spi *BinCons1ProposalInfo) ValidateProposal(proposer sig.Pub, dec []byte) error
- type BinProposerStats
- type CausalCounterProposerInfo
- func (spi *CausalCounterProposerInfo) AbsDoneClear()
- func (spi *CausalCounterProposerInfo) AbsDoneKeep()
- func (spi *CausalCounterProposerInfo) AbsGetProposal(hdr messages.MsgHeader)
- func (spi *CausalCounterProposerInfo) CheckDecisions(root *utils.StringNode) (errs []error)
- func (spi *CausalCounterProposerInfo) Collect()
- func (spi *CausalCounterProposerInfo) DoneClear()
- func (spi *CausalCounterProposerInfo) DoneKeep()
- func (spi *CausalCounterProposerInfo) EndTest()
- func (spi *CausalCounterProposerInfo) FailAfter(end types.ConsensusInt)
- func (spi *CausalCounterProposerInfo) FinishedLastRound() bool
- func (spi *CausalCounterProposerInfo) GenerateNewSM(consumedIndices []types.ConsensusID, ...) consinterface.CausalStateMachineInterface
- func (spi *CausalCounterProposerInfo) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
- func (spi *CausalCounterProposerInfo) GetDecided() bool
- func (spi *CausalCounterProposerInfo) GetDependentItems() []sig.ConsIDPub
- func (spi *CausalCounterProposerInfo) GetDone() types.DoneType
- func (spi *CausalCounterProposerInfo) GetIndex() types.ConsensusIndex
- func (spi *CausalCounterProposerInfo) GetInitialFirstIndex() types.ConsensusID
- func (spi *CausalCounterProposerInfo) GetInitialState() []byte
- func (spi *CausalCounterProposerInfo) GetSMStats() consinterface.SMStats
- func (spi *CausalCounterProposerInfo) HasDecided(proposer sig.Pub, index types.ConsensusIndex, owners []sig.Pub, ...) ([]sig.ConsIDPub, []byte)
- func (spi *CausalCounterProposerInfo) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, ...)
- func (spi *CausalCounterProposerInfo) IsDone() bool
- func (spi *CausalCounterProposerInfo) StartInit(memberCheckerState consinterface.ConsStateInterface)
- func (spi *CausalCounterProposerInfo) ValidateProposal(proposer sig.Pub, dec []byte) error
- type CounterProposalInfo
- func (spi *CounterProposalInfo) CheckDecisions(decs [][]byte) (outOfOrderErrors, errs []error)
- func (spi *CounterProposalInfo) DoneClear()
- func (spi *CounterProposalInfo) DoneKeep()
- func (spi *CounterProposalInfo) EndTest()
- func (spi *CounterProposalInfo) FinishedLastRound() bool
- func (spi *CounterProposalInfo) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
- func (spi *CounterProposalInfo) GetInitialState() []byte
- func (spi *CounterProposalInfo) GetProposal()
- func (spi *CounterProposalInfo) GetSMStats() consinterface.SMStats
- func (spi *CounterProposalInfo) HasDecided(proposer sig.Pub, nxt types.ConsensusInt, decision []byte)
- func (spi *CounterProposalInfo) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, ...)
- func (spi *CounterProposalInfo) StartIndex(nxt types.ConsensusInt) consinterface.StateMachineInterface
- func (spi *CounterProposalInfo) ValidateProposal(proposer sig.Pub, dec []byte) error
- type CounterStats
- type MvCons1ProposalInfo
- func (spi *MvCons1ProposalInfo) CheckDecisions(decs [][]byte) (outOfOrderErrors, errs []error)
- func (spi *MvCons1ProposalInfo) DoneClear()
- func (spi *MvCons1ProposalInfo) DoneKeep()
- func (spi *MvCons1ProposalInfo) EndTest()
- func (spi *MvCons1ProposalInfo) FinishedLastRound() bool
- func (spi *MvCons1ProposalInfo) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
- func (spi *MvCons1ProposalInfo) GetInitialState() []byte
- func (spi *MvCons1ProposalInfo) GetProposal()
- func (spi *MvCons1ProposalInfo) GetSMStats() consinterface.SMStats
- func (spi *MvCons1ProposalInfo) HasDecided(proposer sig.Pub, nxt types.ConsensusInt, decision []byte)
- func (spi *MvCons1ProposalInfo) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, ...)
- func (spi *MvCons1ProposalInfo) StartIndex(nxt types.ConsensusInt) consinterface.StateMachineInterface
- func (spi *MvCons1ProposalInfo) ValidateProposal(proposer sig.Pub, dec []byte) error
- type MvPropserStats
- type SimpleProposalInfo
- func (spi *SimpleProposalInfo) CheckDecisions(decs [][]byte) (outOforderErrors, errs []error)
- func (spi *SimpleProposalInfo) DoneClear()
- func (spi *SimpleProposalInfo) DoneKeep()
- func (spi *SimpleProposalInfo) EndTest()
- func (spi *SimpleProposalInfo) FinishedLastRound() bool
- func (spi *SimpleProposalInfo) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
- func (spi *SimpleProposalInfo) GetInitialState() []byte
- func (spi *SimpleProposalInfo) GetProposal()
- func (spi *SimpleProposalInfo) GetSMStats() consinterface.SMStats
- func (spi *SimpleProposalInfo) HasDecided(proposer sig.Pub, nxt types.ConsensusInt, decision []byte)
- func (spi *SimpleProposalInfo) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, ...)
- func (spi *SimpleProposalInfo) StartIndex(nxt types.ConsensusInt) consinterface.StateMachineInterface
- func (spi *SimpleProposalInfo) ValidateProposal(proposer sig.Pub, dec []byte) error
- type SimpleStats
- type SimpleTxProposer
- func (spi *SimpleTxProposer) CheckDecisions(decs [][]byte) (outOforderErrors, errs []error)
- func (spi *SimpleTxProposer) Collect()
- func (spi *SimpleTxProposer) DoneClear()
- func (spi *SimpleTxProposer) DoneKeep()
- func (spi *SimpleTxProposer) EndTest()
- func (spi *SimpleTxProposer) FinishedLastRound() bool
- func (spi *SimpleTxProposer) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
- func (spi *SimpleTxProposer) GetInitialState() []byte
- func (spi *SimpleTxProposer) GetProposal()
- func (spi *SimpleTxProposer) GetSMStats() consinterface.SMStats
- func (spi *SimpleTxProposer) HasDecided(proposer sig.Pub, nxt types.ConsensusInt, dec []byte)
- func (spi *SimpleTxProposer) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, ...)
- func (spi *SimpleTxProposer) StartIndex(nxt types.ConsensusInt) consinterface.StateMachineInterface
- func (spi *SimpleTxProposer) StatsString(testDuration time.Duration) string
- func (spi *SimpleTxProposer) SubmitTransaction(txID int) error
- func (spi *SimpleTxProposer) ValidateProposal(proposer sig.Pub, dec []byte) error
- type SimpleTxStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbsCausalStateMachine ¶
type AbsCausalStateMachine struct {
// contains filtered or unexported fields
}
func (*AbsCausalStateMachine) AbsDoneClear ¶
func (spi *AbsCausalStateMachine) AbsDoneClear()
func (*AbsCausalStateMachine) AbsDoneKeep ¶
func (spi *AbsCausalStateMachine) AbsDoneKeep()
func (*AbsCausalStateMachine) AbsGetDependentItems ¶
func (spi *AbsCausalStateMachine) AbsGetDependentItems() (childIndices []sig.ConsIDPub)
func (*AbsCausalStateMachine) AbsGetInitialFirstIndex ¶
func (spi *AbsCausalStateMachine) AbsGetInitialFirstIndex(initialState []byte) types.ConsensusID
func (*AbsCausalStateMachine) AbsGetProposal ¶
AbsGetProposal is called when a consensus index is ready for a proposal.
func (*AbsCausalStateMachine) AbsHasDecided ¶
func (spi *AbsCausalStateMachine) AbsHasDecided(proposer sig.Pub, index types.ConsensusIndex, decision []byte, childIndices []sig.ConsIDPub, done bool)
func (*AbsCausalStateMachine) AbsInit ¶
func (spi *AbsCausalStateMachine) AbsInit(index types.ConsensusIndex, gc *generalconfig.GeneralConfig, childIndices []sig.ConsIDPub, mainChannel channelinterface.MainChannel, doneChan chan channelinterface.ChannelCloseType)
AbsInit initalizes the object.
func (*AbsCausalStateMachine) AbsStartIndex ¶
func (spi *AbsCausalStateMachine) AbsStartIndex(consumedIndices []types.ConsensusID, parentSMs []consinterface.CausalStateMachineInterface, startRecordingStats bool)
func (*AbsCausalStateMachine) CheckOK ¶
func (spi *AbsCausalStateMachine) CheckOK()
func (*AbsCausalStateMachine) Collect ¶
func (spi *AbsCausalStateMachine) Collect()
Collect is called when the item is about to be garbage collected and is used as a sanity check.
func (*AbsCausalStateMachine) EndTest ¶
func (spi *AbsCausalStateMachine) EndTest()
EndTest is called when the test is ending
func (*AbsCausalStateMachine) FinishedLastRound ¶
func (spi *AbsCausalStateMachine) FinishedLastRound() bool
FinishedLastRound returns true if the last test index has finished.
func (*AbsCausalStateMachine) GetDecided ¶
func (spi *AbsCausalStateMachine) GetDecided() bool
HasDecided returns true if the SM has decided.
func (*AbsCausalStateMachine) GetIndex ¶
func (spi *AbsCausalStateMachine) GetIndex() types.ConsensusIndex
GetIndex returns the current consensus index.
type AbsRandSM ¶
type AbsRandSM struct {
// contains filtered or unexported fields
}
AbsRandSM can be included as part of the state machine if it supports generating random bytes.
func NewAbsRandSM ¶
NewAbsRandSM allocates the internal object for a state machine that generates random bytes.
func (*AbsRandSM) AbsRandInit ¶
func (spi *AbsRandSM) AbsRandInit(gc *generalconfig.GeneralConfig)
AbsRandInit should be called by the Init function of the state machine.
func (*AbsRandSM) GetRand ¶
GetRand returns the 32 random bytes for this state machine. It should only be called after RandHasDecided.
func (*AbsRandSM) GetRndNumBytes ¶
GetRndNumBytes returns the number of bytes that would be added from RandGetProposal.
func (*AbsRandSM) RandCheckDecision ¶
RandCheckDecision should be called during CheckDecisions and return an error if the decided random bytes were not generated correctly. TODO actually verify the proof
func (*AbsRandSM) RandGetProposal ¶
RandGetProposal encodes random bytes using a VRF to the buffer. It uses the rand bytes input to NewAbsRandSM to generate the new bytes.
func (*AbsRandSM) RandHasDecided ¶
func (spi *AbsRandSM) RandHasDecided(proposer sig.Pub, buf io.Reader, setBytes bool) (n int, err error)
RandHasDecided should be called by the HasDecided function of the state machine with the encoded random bytes. If setBytes is true the state will be updated (false is just used for checking that the bytes were generated in a valid way). It returns an error if the bytes were not generated correctly.
func (*AbsRandSM) RandStartIndex ¶
RandStartIndex is called when the state machine is started with the previously decided random bytes.
type AbsRandSMNotSupported ¶
type AbsRandSMNotSupported int
AbsRandSMNotSupported should be included for state machines that do not support generating random bytes.
func (AbsRandSMNotSupported) GetRand ¶
func (spi AbsRandSMNotSupported) GetRand() (ret [32]byte)
type AbsStateMachine ¶
type AbsStateMachine struct {
// contains filtered or unexported fields
}
func (*AbsStateMachine) AbsDoneClear ¶
func (spi *AbsStateMachine) AbsDoneClear()
func (*AbsStateMachine) AbsDoneKeep ¶
func (spi *AbsStateMachine) AbsDoneKeep()
func (*AbsStateMachine) AbsGetProposal ¶
func (spi *AbsStateMachine) AbsGetProposal(hdr messages.MsgHeader)
AbsGetProposal is called when a consensus index is ready for a proposal.
func (*AbsStateMachine) AbsHasDecided ¶
func (spi *AbsStateMachine) AbsHasDecided(nxt types.ConsensusInt, dec []byte) (shouldReturn bool)
AbsHasDecided is called after the index nxt has decided, it sends the next proposal to the consensus.
func (*AbsStateMachine) AbsInit ¶
func (spi *AbsStateMachine) AbsInit(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, needsConcurrent types.ConsensusInt, mainChannel channelinterface.MainChannel, doneChan chan channelinterface.ChannelCloseType)
AbsInit initalizes the object.
func (*AbsStateMachine) AbsStartIndex ¶
func (spi *AbsStateMachine) AbsStartIndex(nxt types.ConsensusInt)
AbsStartIndex is called when the previous consensus index has finished.
func (*AbsStateMachine) CheckStartStatsRecording ¶
func (spi *AbsStateMachine) CheckStartStatsRecording(index types.ConsensusInt)
CheckStartStatsRecording is called before allocating an index to check if stats recording should start.
func (*AbsStateMachine) Collect ¶
func (spi *AbsStateMachine) Collect()
Collect is called when the item is about to be garbage collected and is used as a sanity check.
func (*AbsStateMachine) EndTest ¶
func (spi *AbsStateMachine) EndTest()
EndTest is called when the test is ending
func (*AbsStateMachine) FailAfter ¶
func (spi *AbsStateMachine) FailAfter(end types.ConsensusInt)
FailAfter sets the last consensus index to run.
func (*AbsStateMachine) FinishedLastRound ¶
func (spi *AbsStateMachine) FinishedLastRound() bool
FinishedLastRound returns true if the last test index has finished.
func (*AbsStateMachine) GetDecided ¶
func (spi *AbsStateMachine) GetDecided() bool
HasDecided returns true if the SM has decided.
func (*AbsStateMachine) GetDone ¶
func (spi *AbsStateMachine) GetDone() types.DoneType
GetDone returns the done status of this SM.
func (*AbsStateMachine) GetIndex ¶
func (spi *AbsStateMachine) GetIndex() types.ConsensusIndex
GetIndex returns the current consensus index.
func (*AbsStateMachine) GetStartedRecordingStats ¶
func (spi *AbsStateMachine) GetStartedRecordingStats() bool
func (*AbsStateMachine) IsDone ¶
func (spi *AbsStateMachine) IsDone() bool
IsDone returns true is the test has finished for the state machine.
type BinCons1ProposalInfo ¶
type BinCons1ProposalInfo struct { AbsStateMachine AbsRandSMNotSupported *BinProposerStats // contains filtered or unexported fields }
BinCons1ProposalInfo represents a state machine for binary consensus that randomly proposes 0 or 1 for each binary consensus.
func NewBinCons1ProposalInfo ¶
func NewBinCons1ProposalInfo(binConsPercentOnes int, seed int64, numParticipants int, numNodes int) *BinCons1ProposalInfo
NewBinCons1ProposalInfo generates a new BinCons1ProposalInfo object.
func (*BinCons1ProposalInfo) CheckDecisions ¶
func (spi *BinCons1ProposalInfo) CheckDecisions(decs [][]byte) (outOforderErrors, errs []error)
CheckDecisions ensures that only binary values were decided.
func (*BinCons1ProposalInfo) DoneClear ¶
func (spi *BinCons1ProposalInfo) DoneClear()
DoneClear should be called if the instance of the state machine will no longer be used (it should perform any cleanup).
func (*BinCons1ProposalInfo) DoneKeep ¶
func (spi *BinCons1ProposalInfo) DoneKeep()
DoneKeep should be called if the instance of the state machine will be kept.
func (*BinCons1ProposalInfo) EndTest ¶
func (spi *BinCons1ProposalInfo) EndTest()
EndTest is called when the test is ending
func (*BinCons1ProposalInfo) FinishedLastRound ¶
func (spi *BinCons1ProposalInfo) FinishedLastRound() bool
FinishedLastRound returns true if the last test index has finished.
func (*BinCons1ProposalInfo) GetByzProposal ¶
func (spi *BinCons1ProposalInfo) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
GetByzProposal should generate a byzantine proposal based on the configuration
func (*BinCons1ProposalInfo) GetInitialState ¶
func (spi *BinCons1ProposalInfo) GetInitialState() []byte
GetInitialState returns []byte{0}.
func (*BinCons1ProposalInfo) GetProposal ¶
func (spi *BinCons1ProposalInfo) GetProposal()
GetProposal is called when a consensus index is ready for a proposal. It should send the proposal for the consensus index by calling mainChannel.HasProposal().
func (*BinCons1ProposalInfo) GetSMStats ¶
func (spi *BinCons1ProposalInfo) GetSMStats() consinterface.SMStats
GetSMStats returns the statistics object for the SM.
func (*BinCons1ProposalInfo) HasDecided ¶
func (spi *BinCons1ProposalInfo) HasDecided(proposer sig.Pub, nxt types.ConsensusInt, decision []byte)
HasDecided is called after the index nxt has decided.
func (*BinCons1ProposalInfo) Init ¶
func (spi *BinCons1ProposalInfo) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, needsConcurrent types.ConsensusInt, mainChannel channelinterface.MainChannel, doneChan chan channelinterface.ChannelCloseType, basicInit bool)
Init initalizes the object.
func (*BinCons1ProposalInfo) StartIndex ¶
func (spi *BinCons1ProposalInfo) StartIndex(nxt types.ConsensusInt) consinterface.StateMachineInterface
StartIndex is called when the previous consensus index has finished.
func (*BinCons1ProposalInfo) ValidateProposal ¶
func (spi *BinCons1ProposalInfo) ValidateProposal(proposer sig.Pub, dec []byte) error
ValidateProposal should return true if the input proposal is valid.
type BinProposerStats ¶
type BinProposerStats struct {
Decided0, Decided1 uint64
}
func (*BinProposerStats) StatsString ¶
func (ps *BinProposerStats) StatsString(time.Duration) string
type CausalCounterProposerInfo ¶
type CausalCounterProposerInfo struct { AbsCausalStateMachine AbsRandSM *CounterStats // contains filtered or unexported fields }
CausalCounterProposerInfo represents a state machine for causal consensus that just creates a single output in sequential order.
func NewCausalCounterProposerInfo ¶
func NewCausalCounterProposerInfo(myPub, proposer sig.Pub, useRand bool, initRandBytes [32]byte) *CausalCounterProposerInfo
NewCausalCounterProposerInfo generates a new CausalCounterProposerInfo object.
func (*CausalCounterProposerInfo) AbsDoneClear ¶
func (spi *CausalCounterProposerInfo) AbsDoneClear()
func (*CausalCounterProposerInfo) AbsDoneKeep ¶
func (spi *CausalCounterProposerInfo) AbsDoneKeep()
func (*CausalCounterProposerInfo) AbsGetProposal ¶
AbsGetProposal is called when a consensus index is ready for a proposal.
func (*CausalCounterProposerInfo) CheckDecisions ¶
func (spi *CausalCounterProposerInfo) CheckDecisions(root *utils.StringNode) (errs []error)
CheckDecisions ensure each value decided incraments the value by 1 (except for nil decisions).
func (*CausalCounterProposerInfo) Collect ¶
func (spi *CausalCounterProposerInfo) Collect()
Collect is called when the item is about to be garbage collected and is used as a sanity check.
func (*CausalCounterProposerInfo) DoneClear ¶
func (spi *CausalCounterProposerInfo) DoneClear()
DoneClear should be called if the instance of the state machine will no longer be used (it should perform any cleanup).
func (*CausalCounterProposerInfo) DoneKeep ¶
func (spi *CausalCounterProposerInfo) DoneKeep()
DoneKeep should be called if the instance of the state machine will be kept.
func (*CausalCounterProposerInfo) EndTest ¶
func (spi *CausalCounterProposerInfo) EndTest()
EndTest is called when the test is ending
func (*CausalCounterProposerInfo) FailAfter ¶
func (spi *CausalCounterProposerInfo) FailAfter(end types.ConsensusInt)
FailAfter sets the last consensus index to run.
func (*CausalCounterProposerInfo) FinishedLastRound ¶
func (spi *CausalCounterProposerInfo) FinishedLastRound() bool
FinishedLastRound returns true if the last test index has finished.
func (*CausalCounterProposerInfo) GenerateNewSM ¶
func (spi *CausalCounterProposerInfo) GenerateNewSM(consumedIndices []types.ConsensusID, parentSMs []consinterface.CausalStateMachineInterface) consinterface.CausalStateMachineInterface
GenerateNewSM is called on this init SM to generate a new SM given the items to be consumed. It should just generate the item, it should not change the state of any of the parentSMs. This will be called on the initial CausalStateMachineInterface passed to the system
func (*CausalCounterProposerInfo) GetByzProposal ¶
func (spi *CausalCounterProposerInfo) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
GetByzProposal should generate a byzantine proposal based on the configuration
func (*CausalCounterProposerInfo) GetDecided ¶
func (spi *CausalCounterProposerInfo) GetDecided() bool
HasDecided returns true if the SM has decided.
func (*CausalCounterProposerInfo) GetDependentItems ¶
func (spi *CausalCounterProposerInfo) GetDependentItems() []sig.ConsIDPub
GetDependentItems returns a list of items dependent from this SM. This list must be the same as the list returned from HasDecided
func (*CausalCounterProposerInfo) GetIndex ¶
func (spi *CausalCounterProposerInfo) GetIndex() types.ConsensusIndex
GetIndex returns the current consensus index.
func (*CausalCounterProposerInfo) GetInitialFirstIndex ¶
func (spi *CausalCounterProposerInfo) GetInitialFirstIndex() types.ConsensusID
GetInitialFirstIndex returns the hash of some unique string for the first instance of the state machine.
func (*CausalCounterProposerInfo) GetInitialState ¶
func (spi *CausalCounterProposerInfo) GetInitialState() []byte
GetInitialState returns 0 encoded as a uvarint.
func (*CausalCounterProposerInfo) GetSMStats ¶
func (spi *CausalCounterProposerInfo) GetSMStats() consinterface.SMStats
GetSMStats returns the statistics object for the SM.
func (*CausalCounterProposerInfo) HasDecided ¶
func (spi *CausalCounterProposerInfo) HasDecided(proposer sig.Pub, index types.ConsensusIndex, owners []sig.Pub, decision []byte) ([]sig.ConsIDPub, []byte)
HasDecided is called each time a consensus decision takes place, given the index and the decided vaule. Proposer is the public key of the node that proposed the decision. It returns a list of causally dependent StateMachines that result from the decisions. It panics if the proposal is invalid (should have been checked in validate).
func (*CausalCounterProposerInfo) Init ¶
func (spi *CausalCounterProposerInfo) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, _ consinterface.ConsStateInterface, mainChannel channelinterface.MainChannel, doneChan chan channelinterface.ChannelCloseType, basicInit bool)
Init initalizes the object. Called once on just the very initial object.
func (*CausalCounterProposerInfo) IsDone ¶
func (spi *CausalCounterProposerInfo) IsDone() bool
IsDone returns true is the test has finished for the state machine.
func (*CausalCounterProposerInfo) StartInit ¶
func (spi *CausalCounterProposerInfo) StartInit(memberCheckerState consinterface.ConsStateInterface)
StartInit is called on the init state machine to start the program.
func (*CausalCounterProposerInfo) ValidateProposal ¶
func (spi *CausalCounterProposerInfo) ValidateProposal(proposer sig.Pub, dec []byte) error
ValidateProposal should return true if the input proposal is valid.
type CounterProposalInfo ¶
type CounterProposalInfo struct { AbsStateMachine AbsRandSM *CounterStats // contains filtered or unexported fields }
CounterProposalInfo represents a state machine for multi-value consensus where each consensus (that doesn't decided a nil value) proposes the next integer.
func NewCounterProposalInfo ¶
func NewCounterProposalInfo(useRand bool, initRandBytes [32]byte) *CounterProposalInfo
NewCounterProposalInfo generates a new CounterProposalInfo object.
func (*CounterProposalInfo) CheckDecisions ¶
func (spi *CounterProposalInfo) CheckDecisions(decs [][]byte) (outOfOrderErrors, errs []error)
CheckDecisions ensure each value decided incraments the value by 1 (except for nil decisions).
func (*CounterProposalInfo) DoneClear ¶
func (spi *CounterProposalInfo) DoneClear()
DoneClear should be called if the instance of the state machine will no longer be used (it should perform any cleanup).
func (*CounterProposalInfo) DoneKeep ¶
func (spi *CounterProposalInfo) DoneKeep()
DoneKeep should be called if the instance of the state machine will be kept.
func (*CounterProposalInfo) EndTest ¶
func (spi *CounterProposalInfo) EndTest()
EndTest is called when the test is ending
func (*CounterProposalInfo) FinishedLastRound ¶
func (spi *CounterProposalInfo) FinishedLastRound() bool
FinishedLastRound returns true if the last test index has finished.
func (*CounterProposalInfo) GetByzProposal ¶
func (spi *CounterProposalInfo) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
GetByzProposal should generate a byzantine proposal based on the configuration
func (*CounterProposalInfo) GetInitialState ¶
func (spi *CounterProposalInfo) GetInitialState() []byte
GetInitialState returns 0 encoded as a uvarint.
func (*CounterProposalInfo) GetProposal ¶
func (spi *CounterProposalInfo) GetProposal()
GetProposal is called when a consensus index is ready for a proposal. It should send the proposal for the consensus index by calling mainChannel.HasProposal().
func (*CounterProposalInfo) GetSMStats ¶
func (spi *CounterProposalInfo) GetSMStats() consinterface.SMStats
GetSMStats returns the statistics object for the SM.
func (*CounterProposalInfo) HasDecided ¶
func (spi *CounterProposalInfo) HasDecided(proposer sig.Pub, nxt types.ConsensusInt, decision []byte)
HasDecided is called after the index nxt has decided.
func (*CounterProposalInfo) Init ¶
func (spi *CounterProposalInfo) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, needsConcurrent types.ConsensusInt, mainChannel channelinterface.MainChannel, doneChan chan channelinterface.ChannelCloseType, basicInit bool)
Init initalizes the object.
func (*CounterProposalInfo) StartIndex ¶
func (spi *CounterProposalInfo) StartIndex(nxt types.ConsensusInt) consinterface.StateMachineInterface
StartIndex is called when the previous consensus index has finished.
func (*CounterProposalInfo) ValidateProposal ¶
func (spi *CounterProposalInfo) ValidateProposal(proposer sig.Pub, dec []byte) error
ValidateProposal should return true if the input proposal is valid.
type CounterStats ¶
func (*CounterStats) StatsString ¶
func (cs *CounterStats) StatsString(testDuration time.Duration) string
type MvCons1ProposalInfo ¶
type MvCons1ProposalInfo struct { AbsStateMachine AbsRandSM *MvPropserStats // contains filtered or unexported fields }
MvCons1ProposalInfo represents a state machine for multi-value consensus where each consensus proposes a random string.
func NewMvCons1ProposalInfo ¶
func NewMvCons1ProposalInfo(useRand bool, initRandBytes [32]byte, proposalSizeBytes int, seed int64) *MvCons1ProposalInfo
NewMvCons1ProposalInfo generates a new MvCons1ProposalInfo object.
func (*MvCons1ProposalInfo) CheckDecisions ¶
func (spi *MvCons1ProposalInfo) CheckDecisions(decs [][]byte) (outOfOrderErrors, errs []error)
CheckDecisions ensure each value decided is a string of length proposalSizeBytes
func (*MvCons1ProposalInfo) DoneClear ¶
func (spi *MvCons1ProposalInfo) DoneClear()
DoneClear should be called if the instance of the state machine will no longer be used (it should perform any cleanup).
func (*MvCons1ProposalInfo) DoneKeep ¶
func (spi *MvCons1ProposalInfo) DoneKeep()
DoneKeep should be called if the instance of the state machine will be kept.
func (*MvCons1ProposalInfo) EndTest ¶
func (spi *MvCons1ProposalInfo) EndTest()
EndTest is called when the test is ending
func (*MvCons1ProposalInfo) FinishedLastRound ¶
func (spi *MvCons1ProposalInfo) FinishedLastRound() bool
FinishedLastRound returns true if the last test index has finished.
func (*MvCons1ProposalInfo) GetByzProposal ¶
func (spi *MvCons1ProposalInfo) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
GetByzProposal should generate a byzantine proposal based on the configuration
func (*MvCons1ProposalInfo) GetInitialState ¶
func (spi *MvCons1ProposalInfo) GetInitialState() []byte
GetInitialState returns []byte("initial state").
func (*MvCons1ProposalInfo) GetProposal ¶
func (spi *MvCons1ProposalInfo) GetProposal()
GetProposal is called when a consensus index is ready for a proposal. It should send the proposal for the consensus index by calling mainChannel.HasProposal().
func (*MvCons1ProposalInfo) GetSMStats ¶
func (spi *MvCons1ProposalInfo) GetSMStats() consinterface.SMStats
GetSMStats returns the statistics object for the SM.
func (*MvCons1ProposalInfo) HasDecided ¶
func (spi *MvCons1ProposalInfo) HasDecided(proposer sig.Pub, nxt types.ConsensusInt, decision []byte)
HasDecided is called after the index nxt has decided.
func (*MvCons1ProposalInfo) Init ¶
func (spi *MvCons1ProposalInfo) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, needsConcurrent types.ConsensusInt, mainChannel channelinterface.MainChannel, doneChan chan channelinterface.ChannelCloseType, basicInit bool)
Init initializes the object.
func (*MvCons1ProposalInfo) StartIndex ¶
func (spi *MvCons1ProposalInfo) StartIndex(nxt types.ConsensusInt) consinterface.StateMachineInterface
StartIndex is called when the previous consensus index has finished.
func (*MvCons1ProposalInfo) ValidateProposal ¶
func (spi *MvCons1ProposalInfo) ValidateProposal(proposer sig.Pub, dec []byte) error
ValidateProposal should return true if the input proposal is valid.
type MvPropserStats ¶
func (*MvPropserStats) StatsString ¶
func (ps *MvPropserStats) StatsString(time.Duration) string
type SimpleProposalInfo ¶
type SimpleProposalInfo struct { AbsStateMachine AbsRandSMNotSupported SimpleStats }
SimpleProposalInfo represents the statemachine object for the SimpleCons protocol, only this state machine can be used when testing this object.
func NewSimpleProposalInfo ¶
func NewSimpleProposalInfo() *SimpleProposalInfo
NewSimpleProposalInfo creates an empty SimpleProposalInfo object.
func (*SimpleProposalInfo) CheckDecisions ¶
func (spi *SimpleProposalInfo) CheckDecisions(decs [][]byte) (outOforderErrors, errs []error)
CheckDecisions verifies that the decided values were valid.
func (*SimpleProposalInfo) DoneClear ¶
func (spi *SimpleProposalInfo) DoneClear()
DoneClear should be called if the instance of the state machine will no longer be used (it should perform any cleanup).
func (*SimpleProposalInfo) DoneKeep ¶
func (spi *SimpleProposalInfo) DoneKeep()
DoneKeep should be called if the instance of the state machine will be kept.
func (*SimpleProposalInfo) EndTest ¶
func (spi *SimpleProposalInfo) EndTest()
EndTest is called when the test is ending
func (*SimpleProposalInfo) FinishedLastRound ¶
func (spi *SimpleProposalInfo) FinishedLastRound() bool
FinishedLastRound returns true if the last test index has finished.
func (*SimpleProposalInfo) GetByzProposal ¶
func (spi *SimpleProposalInfo) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
GetByzProposal should generate a byzantine proposal based on the configuration
func (*SimpleProposalInfo) GetInitialState ¶
func (spi *SimpleProposalInfo) GetInitialState() []byte
GetInitialState returns []byte("initial state")
func (*SimpleProposalInfo) GetProposal ¶
func (spi *SimpleProposalInfo) GetProposal()
GetProposal is called when a consensus index is ready for a proposal. It should send the proposal for the consensus index by calling mainChannel.HasProposal().
func (*SimpleProposalInfo) GetSMStats ¶
func (spi *SimpleProposalInfo) GetSMStats() consinterface.SMStats
GetSMStats returns the statistics object for the SM.
func (*SimpleProposalInfo) HasDecided ¶
func (spi *SimpleProposalInfo) HasDecided(proposer sig.Pub, nxt types.ConsensusInt, decision []byte)
HasDecided is called after the index nxt has decided.
func (*SimpleProposalInfo) Init ¶
func (spi *SimpleProposalInfo) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, needsConcurrent types.ConsensusInt, mainChannel channelinterface.MainChannel, doneChan chan channelinterface.ChannelCloseType, basicInit bool)
Init initalizes the simple proposal object state.
func (*SimpleProposalInfo) StartIndex ¶
func (spi *SimpleProposalInfo) StartIndex(nxt types.ConsensusInt) consinterface.StateMachineInterface
StartIndex is called when the previous consensus index has finished.
func (*SimpleProposalInfo) ValidateProposal ¶
func (spi *SimpleProposalInfo) ValidateProposal(proposer sig.Pub, dec []byte) error
ValidateProposal should return true if the input proposal is valid.
type SimpleStats ¶
type SimpleStats struct{}
func (SimpleStats) StatsString ¶
func (sm SimpleStats) StatsString(testDuration time.Duration) string
type SimpleTxProposer ¶
type SimpleTxProposer struct { AbsStateMachine AbsRandSM // contains filtered or unexported fields }
SimpleTxProposer represents the statemachine object for the SimpleCons protocol, only this state machine can be used when testing this object.
func NewSimpleTxProposer ¶
func NewSimpleTxProposer(useRand bool, initRandBytes [32]byte, randSeed int64) *SimpleTxProposer
NewSimpleTxProposer creates an empty SimpleTxProposer object.
func (*SimpleTxProposer) CheckDecisions ¶
func (spi *SimpleTxProposer) CheckDecisions(decs [][]byte) (outOforderErrors, errs []error)
CheckDecisions verifies that the decided values were valid.
func (*SimpleTxProposer) Collect ¶
func (spi *SimpleTxProposer) Collect()
func (*SimpleTxProposer) DoneClear ¶
func (spi *SimpleTxProposer) DoneClear()
DoneClear should be called if the instance of the state machine will no longer be used (it should perform any cleanup).
func (*SimpleTxProposer) DoneKeep ¶
func (spi *SimpleTxProposer) DoneKeep()
DoneKeep should be called if the instance of the state machine will be kept.
func (*SimpleTxProposer) EndTest ¶
func (spi *SimpleTxProposer) EndTest()
func (*SimpleTxProposer) FinishedLastRound ¶
func (spi *SimpleTxProposer) FinishedLastRound() bool
FinishedLastRound returns true if the last test index has finished.
func (*SimpleTxProposer) GetByzProposal ¶
func (spi *SimpleTxProposer) GetByzProposal(originProposal []byte, _ *generalconfig.GeneralConfig) (byzProposal []byte)
GetByzProposal should generate a byzantine proposal based on the configuration
func (*SimpleTxProposer) GetInitialState ¶
func (spi *SimpleTxProposer) GetInitialState() []byte
GetInitialState returns []byte("initial state")
func (*SimpleTxProposer) GetProposal ¶
func (spi *SimpleTxProposer) GetProposal()
GetProposal is called when a consensus index is ready for a proposal. It should send the proposal for the consensus index by calling mainChannel.HasProposal().
func (*SimpleTxProposer) GetSMStats ¶
func (spi *SimpleTxProposer) GetSMStats() consinterface.SMStats
GetSMStats returns the statistics object for the SM.
func (*SimpleTxProposer) HasDecided ¶
func (spi *SimpleTxProposer) HasDecided(proposer sig.Pub, nxt types.ConsensusInt, dec []byte)
HasDecided is called after the index nxt has decided.
func (*SimpleTxProposer) Init ¶
func (spi *SimpleTxProposer) Init(gc *generalconfig.GeneralConfig, lastProposal types.ConsensusInt, needsConcurrent types.ConsensusInt, mainChannel channelinterface.MainChannel, doneChan chan channelinterface.ChannelCloseType, basicInit bool)
Init initalizes the simple proposal object state.
func (*SimpleTxProposer) StartIndex ¶
func (spi *SimpleTxProposer) StartIndex(nxt types.ConsensusInt) consinterface.StateMachineInterface
StartIndex is called when the previous consensus index has finished.
func (*SimpleTxProposer) StatsString ¶
func (spi *SimpleTxProposer) StatsString(testDuration time.Duration) string
func (*SimpleTxProposer) SubmitTransaction ¶
func (spi *SimpleTxProposer) SubmitTransaction(txID int) error
func (*SimpleTxProposer) ValidateProposal ¶
func (spi *SimpleTxProposer) ValidateProposal(proposer sig.Pub, dec []byte) error
ValidateProposal should return true if the input proposal is valid.
type SimpleTxStats ¶
type SimpleTxStats struct { MaxTxIDCommitted int ConsumedTx uint64 PoolStats transactionsm.PoolStats }
func (SimpleTxStats) StatsString ¶
func (spi SimpleTxStats) StatsString(testDuration time.Duration) string