isaac

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package isaac is the core library for mitum.

Index

Constants

This section is empty.

Variables

View Source
var (
	// NOTE default threshold ratio assumes only one node exists, it means the network is just booted.
	DefaultPolicyThresholdRatio                        = base.ThresholdRatio(100)
	DefaultPolicyNumberOfActingSuffrageNodes           = uint(1)
	DefaultPolicyMaxOperationsInSeal              uint = 100
	DefaultPolicyMaxOperationsInProposal          uint = 100
	DefaultPolicyTimeoutWaitingProposal                = time.Second * 5
	DefaultPolicyIntervalBroadcastingINITBallot        = time.Second * 1
	DefaultPolicyIntervalBroadcastingProposal          = time.Second * 1
	DefaultPolicyWaitBroadcastingACCEPTBallot          = time.Second * 1
	DefaultPolicyIntervalBroadcastingACCEPTBallot      = time.Second * 1
	DefaultPolicyTimespanValidBallot                   = time.Minute * 1
	DefaultPolicyNetworkConnectionTimeout              = time.Second * 3
)
View Source
var KnownSealError = util.NewError("seal is known")

Functions

func CheckBallotSigningNode

func CheckBallotSigningNode(fs base.BallotFactSign, nodepool *network.Nodepool) error

func CheckNodeIsProposer

func CheckNodeIsProposer(n base.Address, suffrage base.Suffrage, height base.Height, round base.Round) error

func NewACCEPTBallot

func NewACCEPTBallot(
	n base.Address,
	newBlock block.Block,
	voteproof base.Voteproof,
	pk key.Privatekey,
	networkID base.NetworkID,
) (base.ACCEPTBallot, error)

func NewDefaultProcessorNewFunc

func NewDefaultProcessorNewFunc(
	db storage.Database,
	bd blockdata.Blockdata,
	nodepool *network.Nodepool,
	suffrage base.Suffrage,
	oprHintset *hint.Hintmap,
) prprocessor.ProcessorNewFunc

func NewINITBallotRound0

func NewINITBallotRound0(
	n base.Address,
	db storage.Database,
	pk key.Privatekey,
	networkID base.NetworkID,
) (base.INITBallot, error)

func NewINITBallotWithVoteproof

func NewINITBallotWithVoteproof(
	n base.Address,
	db storage.Database,
	voteproof base.Voteproof,
	pk key.Privatekey,
	networkID base.NetworkID,
) (base.INITBallot, error)

Types

type BallotChecker

type BallotChecker struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewBallotChecker

func NewBallotChecker(
	blt base.Ballot,
	db storage.Database,
	policy *LocalPolicy,
	suffrage base.Suffrage,
	nodepool *network.Nodepool,
	lastVoteproof base.Voteproof,
) *BallotChecker

func (*BallotChecker) CheckProposalInACCEPTBallot

func (bc *BallotChecker) CheckProposalInACCEPTBallot() (bool, error)

CheckProposalInACCEPTBallot checks ACCEPT ballot should have valid proposal.

func (*BallotChecker) CheckSigning

func (bc *BallotChecker) CheckSigning() (bool, error)

CheckSigning checks node signed by it's valid key.

func (*BallotChecker) CheckVoteproof

func (bc *BallotChecker) CheckVoteproof() (bool, error)

func (*BallotChecker) CheckWithLastVoteproof

func (bc *BallotChecker) CheckWithLastVoteproof() (bool, error)

CheckWithLastVoteproof checks Ballot.Height() and Ballot.Round() with last Block. - If Height is same or lower than last, Ballot will be ignored.

func (*BallotChecker) InSuffrage

func (bc *BallotChecker) InSuffrage() (bool, error)

InSuffrage checks BallotFactSign.Node() is inside suffrage

func (*BallotChecker) InTimespan

func (bc *BallotChecker) InTimespan() (bool, error)

InTimespan checks whether ballot is signed at a given interval, policy.TimespanValidBallot().

func (*BallotChecker) IsFromAliveNode

func (bc *BallotChecker) IsFromAliveNode() (bool, error)

func (*BallotChecker) IsFromLocal

func (bc *BallotChecker) IsFromLocal() (bool, error)

IsFromLocal filters ballots from local thru network; whether it is from the other node, which has same node address

type Ballotbox

type Ballotbox struct {
	sync.RWMutex
	*logging.Logging
	// contains filtered or unexported fields
}

Ballotbox collects ballots and keeps track of majority.

func NewBallotbox

func NewBallotbox(suffragesFunc func() []base.Address, thresholdFunc func() base.Threshold) *Ballotbox

func (*Ballotbox) Clean

func (bb *Ballotbox) Clean(height base.Height) error

func (*Ballotbox) LatestBallot

func (bb *Ballotbox) LatestBallot() base.Ballot

func (*Ballotbox) Vote

func (bb *Ballotbox) Vote(blt base.Ballot) (base.Voteproof, error)

Vote receives Ballot and returns VoteRecords, which has VoteRecords.Result() and VoteRecords.Majority().

type BlockIntegrityError

type BlockIntegrityError struct {
	*util.NError
	From block.Manifest
	Err  error
}

func NewBlockIntegrityError

func NewBlockIntegrityError(from block.Manifest, err error) *BlockIntegrityError

type DefaultProcessor

type DefaultProcessor struct {
	sync.RWMutex
	*logging.Logging
	// contains filtered or unexported fields
}

func NewDefaultProcessor

func NewDefaultProcessor(
	db storage.Database,
	bd blockdata.Blockdata,
	nodepool *network.Nodepool,
	suffrage base.Suffrage,
	oprHintset *hint.Hintmap,
	sfs base.SignedBallotFact,
	initVoteproof base.Voteproof,
) (*DefaultProcessor, error)

func (*DefaultProcessor) BaseManifest

func (pp *DefaultProcessor) BaseManifest() block.Manifest

func (*DefaultProcessor) Block

func (pp *DefaultProcessor) Block() block.Block

func (*DefaultProcessor) Cancel

func (pp *DefaultProcessor) Cancel() error

func (*DefaultProcessor) Fact

func (pp *DefaultProcessor) Fact() base.ProposalFact

func (*DefaultProcessor) Prepare

func (pp *DefaultProcessor) Prepare(ctx context.Context) (block.Block, error)

func (*DefaultProcessor) Save

func (pp *DefaultProcessor) Save(ctx context.Context) error

func (*DefaultProcessor) SetACCEPTVoteproof

func (pp *DefaultProcessor) SetACCEPTVoteproof(acceptVoteproof base.Voteproof) error

func (*DefaultProcessor) SignedFact

func (pp *DefaultProcessor) SignedFact() base.SignedBallotFact

func (*DefaultProcessor) State

func (pp *DefaultProcessor) State() prprocessor.State

func (*DefaultProcessor) Statics

func (pp *DefaultProcessor) Statics() map[string]interface{}

func (*DefaultProcessor) SuffrageInfo

func (pp *DefaultProcessor) SuffrageInfo() block.SuffrageInfoV0

type GeneralSyncer

type GeneralSyncer struct {
	sync.RWMutex
	*logging.Logging
	// contains filtered or unexported fields
}

GeneralSyncer will sync for the closed network.

> The closed network means that the network does not allowed the anonymous node to enter the network.

GeneralSyncer has the managed suffrage members, so there are the specific sources to fetch the blocks.

Before starting GeneralSyncer, these sources should be specified.

1. GeneralSyncer will try to fetch the manifest from all of them. 1. and then will compare the fetched manifests. 1. if some nodes does not respond, that node will be ignored. 1. the fetched data from nodes should be over threshold(2/3).

> 'from' and 'to' is not index number. If from=1 and to=5, GeneralSyncer will sync [1,2,3,4,5].

func NewGeneralSyncer

func NewGeneralSyncer(
	odb storage.Database,
	bd blockdata.Blockdata,
	policy *LocalPolicy,
	sourceChannelsFunc func() map[string]network.Channel,
	baseManifest block.Manifest,
	to base.Height,
) (*GeneralSyncer, error)

func (*GeneralSyncer) Close

func (cs *GeneralSyncer) Close() error

func (*GeneralSyncer) HeightFrom

func (cs *GeneralSyncer) HeightFrom() base.Height

func (*GeneralSyncer) HeightTo

func (cs *GeneralSyncer) HeightTo() base.Height

func (*GeneralSyncer) ID

func (cs *GeneralSyncer) ID() string

func (*GeneralSyncer) Prepare

func (cs *GeneralSyncer) Prepare() error

func (*GeneralSyncer) SetLogging

func (cs *GeneralSyncer) SetLogging(l *logging.Logging) *logging.Logging

func (*GeneralSyncer) SetStateChan

func (cs *GeneralSyncer) SetStateChan(stateChan chan<- SyncerStateChangedContext) *GeneralSyncer

func (*GeneralSyncer) State

func (cs *GeneralSyncer) State() SyncerState

func (*GeneralSyncer) TailManifest

func (cs *GeneralSyncer) TailManifest() block.Manifest

type GenesisBlockV0Generator

type GenesisBlockV0Generator struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewGenesisBlockV0Generator

func NewGenesisBlockV0Generator(
	local node.Local,
	db storage.Database,
	bd blockdata.Blockdata,
	policy *LocalPolicy,
	ops []operation.Operation,
) (*GenesisBlockV0Generator, error)

func (*GenesisBlockV0Generator) Generate

func (gg *GenesisBlockV0Generator) Generate() (block.Block, error)

type LocalPolicy

type LocalPolicy struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewLocalPolicy

func NewLocalPolicy(networkID base.NetworkID) *LocalPolicy

func (*LocalPolicy) Config

func (lp *LocalPolicy) Config() map[string]interface{}

func (*LocalPolicy) IntervalBroadcastingACCEPTBallot

func (lp *LocalPolicy) IntervalBroadcastingACCEPTBallot() time.Duration

func (*LocalPolicy) IntervalBroadcastingINITBallot

func (lp *LocalPolicy) IntervalBroadcastingINITBallot() time.Duration

func (*LocalPolicy) IntervalBroadcastingProposal

func (lp *LocalPolicy) IntervalBroadcastingProposal() time.Duration

func (*LocalPolicy) MarshalJSON

func (lp *LocalPolicy) MarshalJSON() ([]byte, error)

func (*LocalPolicy) MaxOperationsInProposal

func (lp *LocalPolicy) MaxOperationsInProposal() uint

func (*LocalPolicy) MaxOperationsInSeal

func (lp *LocalPolicy) MaxOperationsInSeal() uint

func (*LocalPolicy) NetworkConnectionTimeout

func (lp *LocalPolicy) NetworkConnectionTimeout() time.Duration

func (*LocalPolicy) NetworkID

func (lp *LocalPolicy) NetworkID() base.NetworkID

func (*LocalPolicy) SetIntervalBroadcastingACCEPTBallot

func (lp *LocalPolicy) SetIntervalBroadcastingACCEPTBallot(d time.Duration) (*LocalPolicy, error)

func (*LocalPolicy) SetIntervalBroadcastingINITBallot

func (lp *LocalPolicy) SetIntervalBroadcastingINITBallot(d time.Duration) (*LocalPolicy, error)

func (*LocalPolicy) SetIntervalBroadcastingProposal

func (lp *LocalPolicy) SetIntervalBroadcastingProposal(d time.Duration) (*LocalPolicy, error)

func (*LocalPolicy) SetMaxOperationsInProposal

func (lp *LocalPolicy) SetMaxOperationsInProposal(m uint) (*LocalPolicy, error)

func (*LocalPolicy) SetMaxOperationsInSeal

func (lp *LocalPolicy) SetMaxOperationsInSeal(m uint) (*LocalPolicy, error)

func (*LocalPolicy) SetNetworkConnectionTimeout

func (lp *LocalPolicy) SetNetworkConnectionTimeout(d time.Duration) (*LocalPolicy, error)

func (*LocalPolicy) SetThresholdRatio

func (lp *LocalPolicy) SetThresholdRatio(ratio base.ThresholdRatio) *LocalPolicy

func (*LocalPolicy) SetTimeoutWaitingProposal

func (lp *LocalPolicy) SetTimeoutWaitingProposal(d time.Duration) (*LocalPolicy, error)

func (*LocalPolicy) SetTimespanValidBallot

func (lp *LocalPolicy) SetTimespanValidBallot(d time.Duration) (*LocalPolicy, error)

func (*LocalPolicy) SetWaitBroadcastingACCEPTBallot

func (lp *LocalPolicy) SetWaitBroadcastingACCEPTBallot(d time.Duration) (*LocalPolicy, error)

func (*LocalPolicy) ThresholdRatio

func (lp *LocalPolicy) ThresholdRatio() base.ThresholdRatio

func (*LocalPolicy) TimeoutWaitingProposal

func (lp *LocalPolicy) TimeoutWaitingProposal() time.Duration

func (*LocalPolicy) TimespanValidBallot

func (lp *LocalPolicy) TimespanValidBallot() time.Duration

func (*LocalPolicy) WaitBroadcastingACCEPTBallot

func (lp *LocalPolicy) WaitBroadcastingACCEPTBallot() time.Duration

type ManifestsValidationChecker

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

func NewManifestsValidationChecker

func NewManifestsValidationChecker(
	networkID base.NetworkID,
	manifests []block.Manifest,
) *ManifestsValidationChecker

func (*ManifestsValidationChecker) CheckSerialized

func (bc *ManifestsValidationChecker) CheckSerialized() (bool, error)

type OperationsExtractor

type OperationsExtractor struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewOperationsExtractor

func NewOperationsExtractor(
	local base.Address,
	proposer base.Address,
	db storage.Database,
	nodepool *network.Nodepool,
	opsh []valuehash.Hash,
) *OperationsExtractor

func (*OperationsExtractor) Extract

type ProposalChecker

type ProposalChecker struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewProposalValidationChecker

func NewProposalValidationChecker(
	db storage.Database,
	suffrage base.Suffrage,
	nodepool *network.Nodepool,
	proposal base.Proposal,
	lastINITVoteproof base.Voteproof,
) (*ProposalChecker, error)

func (*ProposalChecker) CheckSigning

func (pvc *ProposalChecker) CheckSigning() (bool, error)

CheckSigning checks node signed by it's valid key.

func (*ProposalChecker) IsKnown

func (pvc *ProposalChecker) IsKnown() (bool, error)

IsKnown checks proposal is already received; if found, no nore checks.

func (*ProposalChecker) IsOlder

func (pvc *ProposalChecker) IsOlder() (bool, error)

func (*ProposalChecker) IsProposer

func (pvc *ProposalChecker) IsProposer() (bool, error)

func (*ProposalChecker) IsWaiting

func (pvc *ProposalChecker) IsWaiting() (bool, error)

func (*ProposalChecker) SaveProposal

func (pvc *ProposalChecker) SaveProposal() (bool, error)

type ProposalMaker

type ProposalMaker struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewProposalMaker

func NewProposalMaker(
	local node.Local,
	db storage.Database,
	policy *LocalPolicy,
) *ProposalMaker

func (*ProposalMaker) Proposal

func (pm *ProposalMaker) Proposal(
	height base.Height,
	round base.Round,
	voteproof base.Voteproof,
) (base.Proposal, error)

type SealChecker

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

func NewSealChecker

func NewSealChecker(
	sl seal.Seal,
	database storage.Database,
	policy *LocalPolicy,
	sealCache cache.Cache,
) SealChecker

func (SealChecker) IsKnown

func (svc SealChecker) IsKnown() (bool, error)

func (SealChecker) IsValid

func (svc SealChecker) IsValid() (bool, error)

func (SealChecker) IsValidOperationSeal

func (svc SealChecker) IsValidOperationSeal() (bool, error)

type Syncer

type Syncer interface {
	ID() string
	Prepare() error
	HeightFrom() base.Height
	HeightTo() base.Height
	State() SyncerState
	TailManifest() block.Manifest
	Close() error
}

type SyncerState

type SyncerState uint8
const (
	SyncerCreated SyncerState
	SyncerPreparing
	SyncerPrepared
	SyncerSaving
	SyncerSaved
)

func (SyncerState) String

func (ss SyncerState) String() string

type SyncerStateChangedContext

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

func NewSyncerStateChangedContext

func NewSyncerStateChangedContext(syncer Syncer, state SyncerState, blocks []block.Block) SyncerStateChangedContext

func (SyncerStateChangedContext) Blocks

func (ss SyncerStateChangedContext) Blocks() []block.Block

func (SyncerStateChangedContext) State

func (SyncerStateChangedContext) Syncer

func (ss SyncerStateChangedContext) Syncer() Syncer

type Syncers

type Syncers struct {
	sync.RWMutex
	*util.ContextDaemon
	*logging.Logging
	// contains filtered or unexported fields
}

func NewSyncers

func NewSyncers(
	db storage.Database,
	bd blockdata.Blockdata,
	policy *LocalPolicy,
	baseManifest block.Manifest,
	sourceChannelsFunc func() map[string]network.Channel,
) *Syncers

func (*Syncers) Add

func (sy *Syncers) Add(to base.Height, sourceNodes []base.Node) (bool, error)

Add adds new syncer with target height. If it returns true, it means Syncers not yet finished.

func (*Syncers) IsFinished

func (sy *Syncers) IsFinished() bool

func (*Syncers) SetLogging

func (sy *Syncers) SetLogging(l *logging.Logging) *logging.Logging

func (*Syncers) Stop

func (sy *Syncers) Stop() error

func (*Syncers) WhenBlockSaved

func (sy *Syncers) WhenBlockSaved(callback func([]block.Block))

func (*Syncers) WhenFinished

func (sy *Syncers) WhenFinished(callback func(base.Height))

type VoteProofChecker

type VoteProofChecker struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewVoteProofChecker

func NewVoteProofChecker(voteproof base.Voteproof, policy *LocalPolicy, suffrage base.Suffrage) *VoteProofChecker

func (*VoteProofChecker) CheckThreshold

func (vc *VoteProofChecker) CheckThreshold() (bool, error)

CheckThreshold checks Threshold only for new incoming Voteproof.

func (*VoteProofChecker) IsValid

func (vc *VoteProofChecker) IsValid() (bool, error)

func (*VoteProofChecker) NodeIsInSuffrage

func (vc *VoteProofChecker) NodeIsInSuffrage() (bool, error)

type VoteRecords

type VoteRecords struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewVoteRecords

func NewVoteRecords(
	height base.Height,
	round base.Round,
	stage base.Stage,
	suffrages []base.Address,
	threshold base.Threshold,
) *VoteRecords

func (*VoteRecords) Vote

func (vrs *VoteRecords) Vote(blt base.Ballot) base.Voteproof

Vote votes by Ballot and keep track the vote records. If getting result is done, Voteproof will not be updated.

Jump to

Keyboard shortcuts

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