Documentation
¶
Index ¶
- Variables
- type BlockStore
- func (x *BlockStore) Add(block *rctypes.BlockData, verifier IRChangeReqVerifier) ([]byte, error)
- func (x *BlockStore) Block(round uint64) (*ExecutedBlock, error)
- func (x *BlockStore) GetCertificate(id types.PartitionID, shard types.ShardID) (*certification.CertificationResponse, error)
- func (x *BlockStore) GetCertificates() []*types.UnicityCertificate
- func (x *BlockStore) GetDB() PersistentStore
- func (x *BlockStore) GetHighQc() *rctypes.QuorumCert
- func (x *BlockStore) GetLastTC() (*rctypes.TimeoutCert, error)
- func (x *BlockStore) GetState() (*abdrc.StateMsg, error)
- func (x *BlockStore) IsChangeInProgress(partition types.PartitionID, shard types.ShardID) *types.InputRecord
- func (x *BlockStore) ProcessQc(qc *rctypes.QuorumCert) ([]*certification.CertificationResponse, error)
- func (x *BlockStore) ProcessTc(tc *rctypes.TimeoutCert) (rErr error)
- func (x *BlockStore) ReadLastVote() (any, error)
- func (x *BlockStore) ShardInfo(partition types.PartitionID, shard types.ShardID) *ShardInfo
- func (x *BlockStore) StoreLastVote(vote any) error
- type BlockTree
- func (bt *BlockTree) Add(block *ExecutedBlock) error
- func (bt *BlockTree) Commit(commitQc *abdrc.QuorumCert) ([]*certification.CertificationResponse, error)
- func (bt *BlockTree) CurrentState() (*rcnet.StateMsg, error)
- func (bt *BlockTree) FindBlock(round uint64) (*ExecutedBlock, error)
- func (bt *BlockTree) GetAllUncommittedNodes() []*ExecutedBlock
- func (bt *BlockTree) HighQc() *abdrc.QuorumCert
- func (bt *BlockTree) InsertQc(qc *abdrc.QuorumCert) error
- func (bt *BlockTree) RemoveLeaf(round uint64) error
- func (bt *BlockTree) Root() *ExecutedBlock
- type BoltDB
- func (db BoltDB) Close() error
- func (db BoltDB) GetHighestQcRound() (round uint64)
- func (db BoltDB) GetHighestVotedRound() (round uint64)
- func (db BoltDB) LoadBlocks() (blocks []*ExecutedBlock, err error)
- func (db BoltDB) ReadLastTC() (tc *rctypes.TimeoutCert, _ error)
- func (db BoltDB) ReadLastVote() (msg any, err error)
- func (db BoltDB) SetHighestQcRound(qcRound, votedRound uint64) error
- func (db BoltDB) SetHighestVotedRound(round uint64) error
- func (db BoltDB) WriteBlock(block *ExecutedBlock, root bool) error
- func (db BoltDB) WriteTC(tc *rctypes.TimeoutCert) error
- func (db BoltDB) WriteVote(vote any) (err error)
- type ExecutedBlock
- func (x *ExecutedBlock) Extend(newBlock *rctypes.BlockData, verifier IRChangeReqVerifier, ...) (*ExecutedBlock, error)
- func (x *ExecutedBlock) GenerateCertificates(commitQc *rctypes.QuorumCert) ([]*certification.CertificationResponse, error)
- func (x *ExecutedBlock) GetParentRound() uint64
- func (x *ExecutedBlock) GetRound() uint64
- type IRChangeReqVerifier
- type Orchestration
- type PersistentStore
- type ShardInfo
- type ShardSet
- type ShardStates
- type VoteStore
- type VoteType
Constants ¶
This section is empty.
Variables ¶
var (
ErrCommitFailed = errors.New("commit failed")
)
Functions ¶
This section is empty.
Types ¶
type BlockStore ¶
type BlockStore struct {
// contains filtered or unexported fields
}
func New ¶
func New(hashAlgo crypto.Hash, db PersistentStore, orchestration Orchestration, log *slog.Logger) (block *BlockStore, err error)
func NewFromState ¶
func NewFromState(hash crypto.Hash, block *abdrc.CommittedBlock, db PersistentStore, orchestration Orchestration, log *slog.Logger) (*BlockStore, error)
func (*BlockStore) Add ¶
func (x *BlockStore) Add(block *rctypes.BlockData, verifier IRChangeReqVerifier) ([]byte, error)
Add adds new round state to pipeline and returns the new state root hash a.k.a. execStateID
func (*BlockStore) Block ¶
func (x *BlockStore) Block(round uint64) (*ExecutedBlock, error)
Block returns block for given round. When store doesn't have block for the round it returns error.
func (*BlockStore) GetCertificate ¶
func (x *BlockStore) GetCertificate(id types.PartitionID, shard types.ShardID) (*certification.CertificationResponse, error)
func (*BlockStore) GetCertificates ¶
func (x *BlockStore) GetCertificates() []*types.UnicityCertificate
func (*BlockStore) GetDB ¶
func (x *BlockStore) GetDB() PersistentStore
func (*BlockStore) GetHighQc ¶
func (x *BlockStore) GetHighQc() *rctypes.QuorumCert
func (*BlockStore) GetLastTC ¶
func (x *BlockStore) GetLastTC() (*rctypes.TimeoutCert, error)
func (*BlockStore) IsChangeInProgress ¶
func (x *BlockStore) IsChangeInProgress(partition types.PartitionID, shard types.ShardID) *types.InputRecord
IsChangeInProgress - return input record if shard has a pending IR change in the pipeline or nil if no change is currently in the pipeline.
func (*BlockStore) ProcessQc ¶
func (x *BlockStore) ProcessQc(qc *rctypes.QuorumCert) ([]*certification.CertificationResponse, error)
func (*BlockStore) ProcessTc ¶
func (x *BlockStore) ProcessTc(tc *rctypes.TimeoutCert) (rErr error)
func (*BlockStore) ReadLastVote ¶
func (x *BlockStore) ReadLastVote() (any, error)
ReadLastVote returns last sent vote message by this node
func (*BlockStore) ShardInfo ¶
func (x *BlockStore) ShardInfo(partition types.PartitionID, shard types.ShardID) *ShardInfo
func (*BlockStore) StoreLastVote ¶
func (x *BlockStore) StoreLastVote(vote any) error
StoreLastVote stores last sent vote message by this node
type BlockTree ¶
type BlockTree struct {
// contains filtered or unexported fields
}
func NewBlockTree ¶
func NewBlockTree(bDB PersistentStore, orchestration Orchestration) (*BlockTree, error)
func NewBlockTreeWithRootBlock ¶
func NewBlockTreeWithRootBlock(block *ExecutedBlock, bDB PersistentStore) (*BlockTree, error)
NewBlockTreeWithRootBlock creates BlockTree with given block as root node.
Intended use-case is for recovery - acquire latest committed block and build on that state.
func (*BlockTree) Add ¶
func (bt *BlockTree) Add(block *ExecutedBlock) error
Add adds new leaf to the block tree
func (*BlockTree) Commit ¶
func (bt *BlockTree) Commit(commitQc *abdrc.QuorumCert) ([]*certification.CertificationResponse, error)
Commit commits block for round and prunes all preceding blocks from the tree, the committed block becomes the new root of the tree. It returns new certificates generated by the block (ie only for those shards which did have change in progress).
func (*BlockTree) GetAllUncommittedNodes ¶
func (bt *BlockTree) GetAllUncommittedNodes() []*ExecutedBlock
func (*BlockTree) HighQc ¶
func (bt *BlockTree) HighQc() *abdrc.QuorumCert
func (*BlockTree) RemoveLeaf ¶
RemoveLeaf removes leaf node if it is not root node
func (*BlockTree) Root ¶
func (bt *BlockTree) Root() *ExecutedBlock
type BoltDB ¶
type BoltDB struct {
// contains filtered or unexported fields
}
Implementation of persistent storage for the BlockTree and SafetyModule using bbolt database.
func NewBoltStorage ¶
func (BoltDB) GetHighestQcRound ¶
func (BoltDB) GetHighestVotedRound ¶
func (BoltDB) LoadBlocks ¶
func (db BoltDB) LoadBlocks() (blocks []*ExecutedBlock, err error)
LoadBlocks returns all the blocks in the database. The list is sorted in descending order of round number.
func (BoltDB) ReadLastTC ¶
func (db BoltDB) ReadLastTC() (tc *rctypes.TimeoutCert, _ error)
func (BoltDB) ReadLastVote ¶
func (BoltDB) SetHighestQcRound ¶
func (BoltDB) SetHighestVotedRound ¶
func (BoltDB) WriteBlock ¶
func (db BoltDB) WriteBlock(block *ExecutedBlock, root bool) error
WriteBlock stores "block" into database. If "root" is "true" older blocks (based on round number) will be deleted.
type ExecutedBlock ¶
type ExecutedBlock struct {
BlockData *rctypes.BlockData // proposed block
HashAlgo crypto.Hash // hash algorithm for the block
RootHash hex.Bytes // resulting root hash
Qc *rctypes.QuorumCert // block's quorum certificate (from next view)
CommitQc *rctypes.QuorumCert // block's commit certificate
ShardState ShardStates
// contains filtered or unexported fields
}
func NewGenesisBlock ¶
func NewRootBlock ¶
func NewRootBlock(block *abdrc.CommittedBlock, hash crypto.Hash, orchestration Orchestration) (*ExecutedBlock, error)
func (*ExecutedBlock) Extend ¶
func (x *ExecutedBlock) Extend(newBlock *rctypes.BlockData, verifier IRChangeReqVerifier, orchestration Orchestration, hash crypto.Hash, log *slog.Logger) (*ExecutedBlock, error)
func (*ExecutedBlock) GenerateCertificates ¶
func (x *ExecutedBlock) GenerateCertificates(commitQc *rctypes.QuorumCert) ([]*certification.CertificationResponse, error)
func (*ExecutedBlock) GetParentRound ¶
func (x *ExecutedBlock) GetParentRound() uint64
func (*ExecutedBlock) GetRound ¶
func (x *ExecutedBlock) GetRound() uint64
type IRChangeReqVerifier ¶
type IRChangeReqVerifier interface {
VerifyIRChangeReq(round uint64, irChReq *rctypes.IRChangeReq) (*types.InputRecord, error)
}
type Orchestration ¶
type Orchestration interface {
NetworkID() types.NetworkID
ShardConfig(partition types.PartitionID, shard types.ShardID, rootRound uint64) (*types.PartitionDescriptionRecord, error)
ShardConfigs(rootRound uint64) (map[types.PartitionShardID]*types.PartitionDescriptionRecord, error)
}
type PersistentStore ¶
type PersistentStore interface {
LoadBlocks() ([]*ExecutedBlock, error)
WriteBlock(block *ExecutedBlock, root bool) error
WriteVote(vote any) error
ReadLastVote() (msg any, err error)
WriteTC(tc *rctypes.TimeoutCert) error
ReadLastTC() (*rctypes.TimeoutCert, error)
}
type ShardInfo ¶
type ShardInfo struct {
PartitionID types.PartitionID
ShardID types.ShardID
T2Timeout time.Duration
ShardConfHash []byte
RootHash []byte // last certified root hash
// statistical record of the previous epoch. As we only need
// it for hashing we keep it in serialized representation
PrevEpochStat types.RawCBOR
// statistical record of the current epoch
Stat certification.StatisticalRecord
// per validator total, invariant fees of the previous epoch
// but as with statistical record of the previous epoch we need it
// for hashing so we keep it in serialized representation
PrevEpochFees types.RawCBOR
Fees map[string]uint64 // per validator summary fees of the current epoch
LastCR *certification.CertificationResponse // last response sent to shard
// latest change request data for creating next certificate
IR *types.InputRecord
TR certification.TechnicalRecord
// contains filtered or unexported fields
}
func NewShardInfo ¶
func (*ShardInfo) GetTotalNodes ¶
func (*ShardInfo) ValidRequest ¶
func (si *ShardInfo) ValidRequest(req *certification.BlockCertificationRequest) error
type ShardSet ¶
type ShardSet map[types.PartitionShardID]struct{}
func (ShardSet) MarshalCBOR ¶
func (*ShardSet) UnmarshalCBOR ¶
type ShardStates ¶
type ShardStates struct {
States map[types.PartitionShardID]*ShardInfo
Changed ShardSet // shards whose state has changed
// contains filtered or unexported fields
}
func (ShardStates) MarshalCBOR ¶
func (ss ShardStates) MarshalCBOR() ([]byte, error)
func (ShardStates) UnicityTree ¶
func (ss ShardStates) UnicityTree(algo crypto.Hash) (*types.UnicityTree, map[types.PartitionID]types.ShardTree, error)
UnicityTree builds the unicity tree based on the shard states.
func (*ShardStates) UnmarshalCBOR ¶
func (ss *ShardStates) UnmarshalCBOR(data []byte) error