ceremonyclient/consensus/forks/state_container.go
Cassandra Heart c797d482f9
v2.1.0.5 (#457)
* wip: conversion of hotstuff from flow into Q-oriented model

* bulk of tests

* remaining non-integration tests

* add integration test, adjust log interface, small tweaks

* further adjustments, restore full pacemaker shape

* add component lifecycle management+supervisor

* further refinements

* resolve timeout hanging

* mostly finalized state for consensus

* bulk of engine swap out

* lifecycle-ify most types

* wiring nearly complete, missing needed hooks for proposals

* plugged in, vetting message validation paths

* global consensus, plugged in and verified

* app shard now wired in too

* do not decode empty keys.yml (#456)

* remove obsolete engine.maxFrames config parameter (#454)

* default to Info log level unless debug is enabled (#453)

* respect config's  "logging" section params, remove obsolete single-file logging (#452)

* Trivial code cleanup aiming to reduce Go compiler warnings (#451)

* simplify range traversal

* simplify channel read for single select case

* delete rand.Seed() deprecated in Go 1.20 and no-op as of Go 1.24

* simplify range traversal

* simplify channel read for single select case

* remove redundant type from array

* simplify range traversal

* simplify channel read for single select case

* RC slate

* finalize 2.1.0.5

* Update comments in StrictMonotonicCounter

Fix comment formatting and clarify description.

---------

Co-authored-by: Black Swan <3999712+blacks1ne@users.noreply.github.com>
2025-11-11 05:00:17 -06:00

78 lines
2.0 KiB
Go

package forks
import (
"source.quilibrium.com/quilibrium/monorepo/consensus/forest"
"source.quilibrium.com/quilibrium/monorepo/consensus/models"
)
// StateContainer wraps a state proposal to implement forest.Vertex
// so the proposal can be stored in forest.LevelledForest
type StateContainer[StateT models.Unique] models.State[StateT]
var _ forest.Vertex = (*StateContainer[*nilUnique])(nil)
func ToStateContainer2[StateT models.Unique](
state *models.State[StateT],
) *StateContainer[StateT] {
return (*StateContainer[StateT])(state)
}
func (b *StateContainer[StateT]) GetState() *models.State[StateT] {
return (*models.State[StateT])(b)
}
// Functions implementing forest.Vertex
func (b *StateContainer[StateT]) VertexID() models.Identity {
return b.Identifier
}
func (b *StateContainer[StateT]) Level() uint64 {
return b.Rank
}
func (b *StateContainer[StateT]) Parent() (models.Identity, uint64) {
// Caution: not all states have a QC for the parent, such as the spork root
// states. Per API contract, we are obliged to return a value to prevent
// panics during logging. (see vertex `forest.VertexToString` method).
if b.ParentQuorumCertificate == nil {
return "", 0
}
return b.ParentQuorumCertificate.Identity(),
b.ParentQuorumCertificate.GetRank()
}
// Type used to satisfy generic arguments in compiler time type assertion check
type nilUnique struct{}
// GetSignature implements models.Unique.
func (n *nilUnique) GetSignature() []byte {
panic("unimplemented")
}
// GetTimestamp implements models.Unique.
func (n *nilUnique) GetTimestamp() uint64 {
panic("unimplemented")
}
// Source implements models.Unique.
func (n *nilUnique) Source() models.Identity {
panic("unimplemented")
}
// Clone implements models.Unique.
func (n *nilUnique) Clone() models.Unique {
panic("unimplemented")
}
// GetRank implements models.Unique.
func (n *nilUnique) GetRank() uint64 {
panic("unimplemented")
}
// Identity implements models.Unique.
func (n *nilUnique) Identity() models.Identity {
panic("unimplemented")
}
var _ models.Unique = (*nilUnique)(nil)