tortoise

package
v0.2.24-beta.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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)
	MaxExceptions int    `mapstructure:"tortoise-max-exceptions"` // if candidate for base ballot has more than max exceptions it will be ignored
	// 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"`

	LayerSize uint32
}

Config for protocol parameters.

func DefaultConfig added in v1.0.0

func DefaultConfig() Config

DefaultConfig for Tortoise.

type DecodedBallot added in v1.0.0

type DecodedBallot struct {
	*types.Ballot
	// 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 Opt added in v1.0.0

type Opt func(t *Tortoise)

Opt for configuring tortoise.

func WithConfig added in v1.0.0

func WithConfig(cfg Config) Opt

WithConfig defines protocol parameters.

func WithContext

func WithContext(ctx context.Context) Opt

WithContext defines context for tortoise.

func WithLogger added in v1.0.0

func WithLogger(logger log.Log) Opt

WithLogger defines logger for tortoise.

type Tortoise

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

Tortoise is a thread safe verifying tortoise wrapper, it just locks all actions.

func New added in v1.0.0

func New(cdb *datastore.CachedDB, beacons system.BeaconGetter, opts ...Opt) (*Tortoise, error)

New creates Tortoise instance.

func (*Tortoise) DecodeBallot added in v1.0.0

func (t *Tortoise) DecodeBallot(ballot *types.Ballot) (*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) LatestComplete

func (t *Tortoise) LatestComplete() types.LayerID

LatestComplete returns the latest verified layer.

func (*Tortoise) OnAtx added in v1.0.0

func (t *Tortoise) OnAtx(atx *types.ActivationTxHeader)

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.Ballot)

OnBallot should be called every time new ballot is received. BaseBallot and RefBallot must be always processed first. And ATX must be stored in the database.

func (*Tortoise) OnBlock added in v1.0.0

func (t *Tortoise) OnBlock(block *types.Block)

OnBlock should be called every time new block is received.

func (*Tortoise) OnHareOutput added in v1.0.0

func (t *Tortoise) OnHareOutput(lid types.LayerID, bid types.BlockID)

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) 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

func (t *Tortoise) TallyVotes(ctx context.Context, lid types.LayerID)

TallyVotes up to the specified layer.

func (*Tortoise) Updates added in v1.0.0

func (t *Tortoise) Updates() map[types.LayerID]map[types.BlockID]bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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