snowman

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BootstrapConfig

type BootstrapConfig struct {
	common.Config

	// Blocked tracks operations that are blocked on blocks
	Blocked *queue.Jobs

	VM ChainVM

	Bootstrapped func()
}

BootstrapConfig ...

type ChainVM

type ChainVM interface {
	common.VM

	// Attempt to create a new block from data contained in the VM.
	//
	// If the VM doesn't want to issue a new block, an error should be
	// returned.
	BuildBlock() (snowman.Block, error)

	// Attempt to create a block from a stream of bytes.
	//
	// The block should be represented by the full byte array, without extra
	// bytes.
	ParseBlock([]byte) (snowman.Block, error)

	// Attempt to load a block.
	//
	// If the block does not exist, then an error should be returned.
	GetBlock(ids.ID) (snowman.Block, error)

	// Notify the VM of the currently preferred block.
	//
	// This should always be a block that has no children known to consensus.
	SetPreference(ids.ID)

	// LastAccepted returns the ID of the last accepted block.
	//
	// If no blocks have been accepted by consensus yet, it is assumed there is
	// a definitionally accepted block, the Genesis block, that will be
	// returned.
	LastAccepted() ids.ID
}

ChainVM defines the required functionality of a Snowman VM.

A Snowman VM is responsible for defining the representation of state, the representation of operations on that state, the application of operations on that state, and the creation of the operations. Consensus will decide on if the operation is executed and the order operations are executed in.

For example, suppose we have a VM that tracks an increasing number that is agreed upon by the network. The state is a single number. The operation is setting the number to a new, larger value. Applying the operation will save to the database the new value. The VM can attempt to issue a new number, of larger value, at any time. Consensus will ensure the network agrees on the number at every block height.

type Config

type Config struct {
	BootstrapConfig

	Params    snowball.Parameters
	Consensus snowman.Consensus
}

Config wraps all the parameters needed for a snowman engine

type Engine

type Engine interface {
	common.Engine

	// Initialize this engine.
	Initialize(Config)
}

Engine describes the events that can occur to a Snowman instance.

The engine is used to fetch, order, and decide on the fate of blocks. This engine runs the leaderless version of the Snowman consensus protocol. Therefore, the liveness of this protocol tolerant to O(sqrt(n)) Byzantine Nodes where n is the number of nodes in the network. Therefore, this protocol should only be run in a Crash Fault Tolerant environment, or in an environment where lose of liveness and manual intervention is tolerable.

type OracleBlock

type OracleBlock interface {
	snowman.Block

	// Options returns the possible children of this block in the order this
	// validator prefers the blocks.
	Options() [2]snowman.Block
}

OracleBlock is a block that only has two valid children. The children should be returned in preferential order.

This ordering does not need to be deterministically created from the chain state.

type Transitive

type Transitive struct {
	Config
	// contains filtered or unexported fields
}

Transitive implements the Engine interface by attempting to fetch all transitive dependencies.

func (*Transitive) Chits

func (t *Transitive) Chits(vdr ids.ShortID, requestID uint32, votes ids.Set)

Chits implements the Engine interface

func (*Transitive) Context

func (t *Transitive) Context() *snow.Context

Context implements the Engine interface

func (*Transitive) CurrentAcceptedFrontier

func (b *Transitive) CurrentAcceptedFrontier() ids.Set

CurrentAcceptedFrontier ...

func (*Transitive) FilterAccepted

func (b *Transitive) FilterAccepted(containerIDs ids.Set) ids.Set

FilterAccepted ...

func (*Transitive) ForceAccepted

func (b *Transitive) ForceAccepted(acceptedContainerIDs ids.Set)

ForceAccepted ...

func (*Transitive) Get

func (t *Transitive) Get(vdr ids.ShortID, requestID uint32, blkID ids.ID)

Get implements the Engine interface

func (*Transitive) GetFailed

func (t *Transitive) GetFailed(vdr ids.ShortID, requestID uint32, blkID ids.ID)

GetFailed implements the Engine interface

func (*Transitive) Initialize

func (t *Transitive) Initialize(config Config)

Initialize implements the Engine interface

func (*Transitive) Notify

func (t *Transitive) Notify(msg common.Message)

Notify implements the Engine interface

func (*Transitive) PullQuery

func (t *Transitive) PullQuery(vdr ids.ShortID, requestID uint32, blkID ids.ID)

PullQuery implements the Engine interface

func (*Transitive) PushQuery

func (t *Transitive) PushQuery(vdr ids.ShortID, requestID uint32, blkID ids.ID, blk []byte)

PushQuery implements the Engine interface

func (*Transitive) Put

func (t *Transitive) Put(vdr ids.ShortID, requestID uint32, blkID ids.ID, blkBytes []byte)

Put implements the Engine interface

func (*Transitive) QueryFailed

func (t *Transitive) QueryFailed(vdr ids.ShortID, requestID uint32)

QueryFailed implements the Engine interface

func (*Transitive) Shutdown

func (t *Transitive) Shutdown()

Shutdown implements the Engine interface

type VMTest

type VMTest struct {
	common.VMTest

	CantBuildBlock,
	CantParseBlock,
	CantGetBlock,
	CantSetPreference,
	CantLastAccepted bool

	BuildBlockF    func() (snowman.Block, error)
	ParseBlockF    func([]byte) (snowman.Block, error)
	GetBlockF      func(ids.ID) (snowman.Block, error)
	SetPreferenceF func(ids.ID)
	LastAcceptedF  func() ids.ID
}

VMTest ...

func (*VMTest) BuildBlock

func (vm *VMTest) BuildBlock() (snowman.Block, error)

BuildBlock ...

func (*VMTest) Default

func (vm *VMTest) Default(cant bool)

Default ...

func (*VMTest) GetBlock

func (vm *VMTest) GetBlock(id ids.ID) (snowman.Block, error)

GetBlock ...

func (*VMTest) LastAccepted

func (vm *VMTest) LastAccepted() ids.ID

LastAccepted ...

func (*VMTest) ParseBlock

func (vm *VMTest) ParseBlock(b []byte) (snowman.Block, error)

ParseBlock ...

func (*VMTest) SetPreference

func (vm *VMTest) SetPreference(id ids.ID)

SetPreference ...

Jump to

Keyboard shortcuts

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