Documentation ¶
Index ¶
- Constants
- Variables
- func RecoverLayer(ctx context.Context, trtl *Tortoise, db sql.Executor, atxdata *atxsdata.Data, ...) error
- func RunTrace(path string, breakpoint func(), opts ...Opt) error
- type AppliedTrace
- type AtxTrace
- type BallotData
- type BallotTrace
- type BeaconTrace
- type BlockTrace
- type Config
- type ConfigTrace
- type DecodeBallotTrace
- type DecodedBallot
- type EncodeVotesOpts
- type EncodeVotesTrace
- type HareTrace
- type MalfeasanceTrace
- type Mode
- type Opt
- type RecoveredBlocksTrace
- type StoreBallotTrace
- type TallyTrace
- type Tortoise
- func (t *Tortoise) DecodeBallot(ballot *types.BallotTortoiseData) (*DecodedBallot, error)
- func (t *Tortoise) EncodeVotes(ctx context.Context, opts ...EncodeVotesOpts) (*types.Opinion, error)
- func (t *Tortoise) GetBallot(id types.BallotID) *BallotData
- func (t *Tortoise) GetMissingActiveSet(target types.EpochID, atxs []types.ATXID) []types.ATXID
- func (t *Tortoise) LatestComplete() types.LayerID
- func (t *Tortoise) Mode() Mode
- func (t *Tortoise) OnApplied(lid types.LayerID, opinion types.Hash32) bool
- func (t *Tortoise) OnAtx(header *types.AtxTortoiseData)
- func (t *Tortoise) OnBallot(ballot *types.BallotTortoiseData)
- func (t *Tortoise) OnBeacon(eid types.EpochID, beacon types.Beacon)
- func (t *Tortoise) OnBlock(header types.BlockHeader)
- func (t *Tortoise) OnHareOutput(lid types.LayerID, bid types.BlockID)
- func (t *Tortoise) OnMalfeasance(id types.NodeID)
- func (t *Tortoise) OnRecoveredBallot(ballot *types.BallotTortoiseData)
- func (t *Tortoise) OnRecoveredBlocks(lid types.LayerID, validity map[types.BlockHeader]bool, hare *types.BlockID)
- func (t *Tortoise) OnWeakCoin(lid types.LayerID, coin bool)
- func (t *Tortoise) RecoverFrom(lid types.LayerID, opinion, prev types.Hash32)
- func (t *Tortoise) StoreBallot(decoded *DecodedBallot) error
- func (t *Tortoise) TallyVotes(ctx context.Context, lid types.LayerID)
- func (t *Tortoise) UpdateLastLayer(last types.LayerID)
- func (t *Tortoise) UpdateVerified(verified types.LayerID)
- func (t *Tortoise) Updates() []result.Layer
- func (t *Tortoise) WithinHdist(lid types.LayerID) bool
- type TraceOpt
- type UpdatesTrace
- type WeakCoinTrace
Constants ¶
const ( Verifying = 0 Full = 1 )
Variables ¶
var (
ErrBallotExists = errors.New("tortoise: ballot exists")
)
Functions ¶
func RecoverLayer ¶ added in v1.0.0
Types ¶
type AppliedTrace ¶ added in v1.2.2
type AppliedTrace struct { Layer types.LayerID `json:"layer"` Opinion types.Hash32 `json:"opinion"` Result bool `json:"rst"` }
func (*AppliedTrace) New ¶ added in v1.2.2
func (a *AppliedTrace) New() traceEvent
func (*AppliedTrace) Run ¶ added in v1.2.2
func (a *AppliedTrace) Run(r *traceRunner) error
func (*AppliedTrace) Type ¶ added in v1.2.2
func (a *AppliedTrace) Type() eventType
type AtxTrace ¶ added in v1.0.0
type AtxTrace struct {
Header *types.AtxTortoiseData `json:",inline"`
}
type BallotData ¶ added in v1.1.4
type BallotTrace ¶ added in v1.0.0
type BallotTrace struct {
Ballot *types.BallotTortoiseData `json:",inline"`
}
func (*BallotTrace) New ¶ added in v1.0.0
func (b *BallotTrace) New() traceEvent
func (*BallotTrace) Run ¶ added in v1.0.0
func (b *BallotTrace) Run(r *traceRunner) error
func (*BallotTrace) Type ¶ added in v1.0.0
func (b *BallotTrace) Type() eventType
type BeaconTrace ¶ added in v1.0.0
func (*BeaconTrace) New ¶ added in v1.0.0
func (b *BeaconTrace) New() traceEvent
func (*BeaconTrace) Run ¶ added in v1.0.0
func (b *BeaconTrace) Run(r *traceRunner) error
func (*BeaconTrace) Type ¶ added in v1.0.0
func (b *BeaconTrace) Type() eventType
type BlockTrace ¶ added in v1.0.0
type BlockTrace struct {
Header types.BlockHeader `json:",inline"`
}
func (*BlockTrace) New ¶ added in v1.0.0
func (b *BlockTrace) New() traceEvent
func (*BlockTrace) Run ¶ added in v1.0.0
func (b *BlockTrace) Run(r *traceRunner) error
func (*BlockTrace) Type ¶ added in v1.0.0
func (b *BlockTrace) Type() eventType
type Config ¶ added in v1.0.0
type Config struct { Hdist uint32 `mapstructure:"tortoise-hdist"` // hare output lookback distance Zdist uint32 `mapstructure:"tortoise-zdist"` // hare result wait distance // how long we are waiting for a switch from verifying to full. relevant during rerun. WindowSize uint32 `mapstructure:"tortoise-window-size"` // size of the tortoise sliding window (in layers) // ignored if candidate for base ballot has more than max exceptions MaxExceptions int `mapstructure:"tortoise-max-exceptions"` // number of layers to delay votes for blocks with bad beacon values during self-healing. ideally a full epoch. BadBeaconVoteDelayLayers uint32 `mapstructure:"tortoise-delay-layers"` // EnableTracer will write tortoise traces to the stderr. EnableTracer bool `mapstructure:"tortoise-enable-tracer"` // MinimalActiveSetWeight is a weight that will replace weight // recorded in the first ballot, if that weight is less than minimal // for purposes of eligibility computation. MinimalActiveSetWeight []types.EpochMinimalActiveWeight // CollectDetails sets numbers of layers to collect details. // Must be less than WindowSize. CollectDetails uint32 `mapstructure:"tortoise-collect-details"` LayerSize uint32 }
Config for protocol parameters.
type ConfigTrace ¶ added in v1.0.0
type ConfigTrace struct { Hdist uint32 `json:"hdist"` Zdist uint32 `json:"zdist"` WindowSize uint32 `json:"window"` MaxExceptions uint32 `json:"exceptions"` BadBeaconVoteDelayLayers uint32 `json:"delay"` LayerSize uint32 `json:"layer-size"` EpochSize uint32 `json:"epoch-size"` // this field is not set in the original config EffectiveGenesis uint32 `json:"effective-genesis"` }
func (*ConfigTrace) New ¶ added in v1.0.0
func (c *ConfigTrace) New() traceEvent
func (*ConfigTrace) Run ¶ added in v1.0.0
func (c *ConfigTrace) Run(r *traceRunner) error
func (*ConfigTrace) Type ¶ added in v1.0.0
func (c *ConfigTrace) Type() eventType
type DecodeBallotTrace ¶ added in v1.0.0
type DecodeBallotTrace struct { Ballot *types.BallotTortoiseData `json:",inline"` Error string `json:"e"` }
func (*DecodeBallotTrace) New ¶ added in v1.0.0
func (d *DecodeBallotTrace) New() traceEvent
func (*DecodeBallotTrace) Run ¶ added in v1.0.0
func (b *DecodeBallotTrace) Run(r *traceRunner) error
func (*DecodeBallotTrace) Type ¶ added in v1.0.0
func (d *DecodeBallotTrace) Type() eventType
type DecodedBallot ¶ added in v1.0.0
type DecodedBallot struct { *types.BallotTortoiseData // contains filtered or unexported fields }
DecodedBallot created after unwrapping exceptions list and computing internal opinion.
type EncodeVotesOpts ¶ added in v1.0.0
type EncodeVotesOpts func(*encodeConf)
EncodeVotesOpts is for configuring EncodeVotes options.
func EncodeVotesWithCurrent ¶ added in v1.0.0
func EncodeVotesWithCurrent(current types.LayerID) EncodeVotesOpts
EncodeVotesWithCurrent changes last known layer that will be used for encoding votes.
NOTE(dshulyak) why do we need this? tortoise computes threshold from last non-verified till the last known layer, since we dont download atxs before starting tortoise we won't be able to compute threshold based on the last clock layer (see https://github.com/spacemeshos/go-spacemesh/issues/3003)
type EncodeVotesTrace ¶ added in v1.0.0
type EncodeVotesTrace struct { Layer types.LayerID `json:"lid"` Opinion *types.Opinion `json:"opinion"` Error string `json:"e"` }
func (*EncodeVotesTrace) New ¶ added in v1.0.0
func (e *EncodeVotesTrace) New() traceEvent
func (*EncodeVotesTrace) Run ¶ added in v1.0.0
func (e *EncodeVotesTrace) Run(r *traceRunner) error
func (*EncodeVotesTrace) Type ¶ added in v1.0.0
func (e *EncodeVotesTrace) Type() eventType
type MalfeasanceTrace ¶ added in v1.0.0
func (*MalfeasanceTrace) New ¶ added in v1.0.0
func (m *MalfeasanceTrace) New() traceEvent
func (*MalfeasanceTrace) Run ¶ added in v1.0.0
func (m *MalfeasanceTrace) Run(r *traceRunner) error
func (*MalfeasanceTrace) Type ¶ added in v1.0.0
func (m *MalfeasanceTrace) Type() eventType
type Opt ¶ added in v1.0.0
type Opt func(t *Tortoise)
Opt for configuring tortoise.
func WithConfig ¶ added in v1.0.0
WithConfig defines protocol parameters.
func WithLogger ¶ added in v1.0.0
WithLogger defines logger for tortoise.
func WithTracer ¶ added in v1.0.0
WithTracer enables tracing of every call to the tortoise.
type RecoveredBlocksTrace ¶ added in v1.4.0
type RecoveredBlocksTrace struct { Layer types.LayerID `json:"layer"` Blocks []headerWithValidity `json:"blocks"` Hare *types.BlockID `json:"hare"` }
func (*RecoveredBlocksTrace) New ¶ added in v1.4.0
func (r *RecoveredBlocksTrace) New() traceEvent
func (*RecoveredBlocksTrace) Run ¶ added in v1.4.0
func (r *RecoveredBlocksTrace) Run(tr *traceRunner) error
func (*RecoveredBlocksTrace) Type ¶ added in v1.4.0
func (r *RecoveredBlocksTrace) Type() eventType
type StoreBallotTrace ¶ added in v1.0.0
type StoreBallotTrace struct { ID types.BallotID `json:"id"` Malicious bool `json:"mal"` Error string `json:"e,omitempty"` }
func (*StoreBallotTrace) New ¶ added in v1.0.0
func (s *StoreBallotTrace) New() traceEvent
func (*StoreBallotTrace) Run ¶ added in v1.0.0
func (s *StoreBallotTrace) Run(r *traceRunner) error
func (*StoreBallotTrace) Type ¶ added in v1.0.0
func (s *StoreBallotTrace) Type() eventType
type TallyTrace ¶ added in v1.0.0
func (*TallyTrace) New ¶ added in v1.0.0
func (t *TallyTrace) New() traceEvent
func (*TallyTrace) Run ¶ added in v1.0.0
func (t *TallyTrace) Run(r *traceRunner) error
func (*TallyTrace) Type ¶ added in v1.0.0
func (t *TallyTrace) Type() eventType
type Tortoise ¶
type Tortoise struct {
// contains filtered or unexported fields
}
Tortoise is a thread safe verifying tortoise wrapper, it just locks all actions.
func Recover ¶ added in v1.0.0
func Recover( ctx context.Context, db sql.Executor, atxdata *atxsdata.Data, current types.LayerID, opts ...Opt, ) (*Tortoise, error)
Recover tortoise state from database.
func (*Tortoise) DecodeBallot ¶ added in v1.0.0
func (t *Tortoise) DecodeBallot(ballot *types.BallotTortoiseData) (*DecodedBallot, error)
DecodeBallot decodes ballot if it wasn't processed earlier.
func (*Tortoise) EncodeVotes ¶ added in v1.0.0
func (t *Tortoise) EncodeVotes( ctx context.Context, opts ...EncodeVotesOpts, ) (*types.Opinion, error)
EncodeVotes chooses a base ballot and creates a differences list. needs the hare results for latest layers.
func (*Tortoise) GetBallot ¶ added in v1.1.4
func (t *Tortoise) GetBallot(id types.BallotID) *BallotData
func (*Tortoise) GetMissingActiveSet ¶ added in v1.0.0
GetMissingActiveSet returns unknown atxs from the original list. It is done for a specific epoch as active set atxs never cross epoch boundary.
func (*Tortoise) LatestComplete ¶
LatestComplete returns the latest verified layer.
func (*Tortoise) OnApplied ¶ added in v1.2.2
OnApplied compares stored opinion with computed opinion and sets pending layer to the layer above equal layer. this method is meant to be used only in recovery from disk codepath.
func (*Tortoise) OnAtx ¶ added in v1.0.0
func (t *Tortoise) OnAtx(header *types.AtxTortoiseData)
OnAtx is expected to be called before ballots that use this atx.
func (*Tortoise) OnBallot ¶ added in v1.0.0
func (t *Tortoise) OnBallot(ballot *types.BallotTortoiseData)
OnBallot should be called every time new ballot is received. Dependencies (base ballot, ref ballot, active set and its own atx) must be processed before ballot.
func (*Tortoise) OnBlock ¶ added in v1.0.0
func (t *Tortoise) OnBlock(header types.BlockHeader)
OnBlock updates tortoise with information that data is available locally.
func (*Tortoise) OnHareOutput ¶ added in v1.0.0
OnHareOutput should be called when hare terminated or certificate for a block was synced from a peer. This method is expected to be called any number of times, with layers in any order.
This method should be called with EmptyBlockID if node received proof of malicious behavior, such as signing same block id by members of the same committee.
func (*Tortoise) OnMalfeasance ¶ added in v1.0.0
OnMalfeasance registers node id as malfeasent. - ballots from this id will have zero weight - atxs - will not be counted towards global/local threhsolds If node registers equivocating ballot/atx it should call OnMalfeasance before storing ballot/atx.
func (*Tortoise) OnRecoveredBallot ¶ added in v1.2.2
func (t *Tortoise) OnRecoveredBallot(ballot *types.BallotTortoiseData)
OnRecoveredBallot is called for ballots recovered from database.
For recovered ballots base ballot is not required to be in state therefore opinion is not recomputed, but instead recovered from database state.
func (*Tortoise) OnRecoveredBlocks ¶ added in v1.4.0
func (t *Tortoise) OnRecoveredBlocks(lid types.LayerID, validity map[types.BlockHeader]bool, hare *types.BlockID)
OnRecoveredBlocks uploads blocks to the state with all metadata.
Implementation assumes that they will be uploaded in order.
func (*Tortoise) OnWeakCoin ¶ added in v1.0.0
func (*Tortoise) RecoverFrom ¶ added in v1.2.2
func (*Tortoise) StoreBallot ¶ added in v1.0.0
func (t *Tortoise) StoreBallot(decoded *DecodedBallot) error
StoreBallot stores previously decoded ballot.
func (*Tortoise) TallyVotes ¶ added in v1.0.0
TallyVotes up to the specified layer.
func (*Tortoise) UpdateLastLayer ¶ added in v1.4.0
UpdateLastLayer updates last layer which is used for determining weight thresholds.
func (*Tortoise) UpdateVerified ¶ added in v1.4.0
UpdateVerified layers based on the previously known verified layer.
type TraceOpt ¶ added in v1.0.0
func WithOutput ¶ added in v1.0.0
type UpdatesTrace ¶ added in v1.0.0
type UpdatesTrace struct { From types.LayerID `json:"from"` To types.LayerID `json:"to"` Error string `json:"e"` Results []result.Layer `json:"results"` }
func (*UpdatesTrace) New ¶ added in v1.0.0
func (u *UpdatesTrace) New() traceEvent
func (*UpdatesTrace) Run ¶ added in v1.0.0
func (u *UpdatesTrace) Run(r *traceRunner) error
func (*UpdatesTrace) Type ¶ added in v1.0.0
func (u *UpdatesTrace) Type() eventType
type WeakCoinTrace ¶ added in v1.0.0
func (*WeakCoinTrace) New ¶ added in v1.0.0
func (w *WeakCoinTrace) New() traceEvent
func (*WeakCoinTrace) Run ¶ added in v1.0.0
func (w *WeakCoinTrace) Run(r *traceRunner) error
func (*WeakCoinTrace) Type ¶ added in v1.0.0
func (w *WeakCoinTrace) Type() eventType