consensus

package
v0.0.0-...-484cccf Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0, MIT Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTemporal = errors.New("temporal error")

Functions

func AggregateSignatures

func AggregateSignatures(sigs []crypto.Signature) (*crypto.Signature, error)

func AuthenticateMessage

func AuthenticateMessage(msg *types.SignedMessage, signer address.Address) error

AuthenticateMessage authenticates the message by verifying that the supplied SignedMessage was signed by the indicated Address, computing the correct signature payload depending on the signature type. The supplied Address type must be recognized by the registered verifier for the signature type.

func CommonBlkChecks

func CommonBlkChecks(ctx context.Context, sm *stmgr.StateManager, cs *store.ChainStore,
	b *types.FullBlock, baseTs *types.TipSet) []async.ErrorFuture

CommonBlkChecks performed by all consensus implementations.

func CreateBlockHeader

CreateBlockHeader generates the block header from the block template of the block being proposed.

func IsValidForSending

func IsValidForSending(nv network.Version, act *types.Actor) bool

func IsValidSecpkSigType

func IsValidSecpkSigType(nv network.Version, typ crypto.SigType) bool

IsValidSecpkSigType checks that a signature type is valid for the network version, for a "secpk" message.

func NewActorRegistry

func NewActorRegistry() *vm.ActorRegistry

func RunAsyncChecks

func RunAsyncChecks(ctx context.Context, await []async.ErrorFuture) error

RunAsyncChecks accepts a list of checks to perform in parallel.

Each consensus algorithm may choose to perform a set of different checks when a new blocks is received.

func ToMessagesArray

func ToMessagesArray(store blockadt.Store, cids []cid.Cid) (cid.Cid, error)

func ValidateBlockPubsub

func ValidateBlockPubsub(ctx context.Context, cns Consensus, self bool, msg *pubsub.Message) (pubsub.ValidationResult, string)

ValidateBlockPubsub implements the common checks performed by all consensus implementations when a block is received through the pubsub channel.

func VerifyBlsAggregate

func VerifyBlsAggregate(ctx context.Context, sig *crypto.Signature, msgs []cid.Cid, pubks [][]byte) error

Types

type Consensus

type Consensus interface {
	// ValidateBlockHeader is called by peers when they receive a new block through the network.
	//
	// This is a fast sanity-check validation performed by the PubSub protocol before delivering
	// it to the syncer. It checks that the block has the right format and it performs
	// other consensus-specific light verifications like ensuring that the block is signed by
	// a valid miner, or that it includes all the data required for a full verification.
	ValidateBlockHeader(ctx context.Context, b *types.BlockHeader) (rejectReason string, err error)

	// ValidateBlock is called by the syncer to determine if to accept a block or not.
	//
	// It performs all the checks needed by the syncer to accept
	// the block (signature verifications, VRF checks, message validity, etc.)
	ValidateBlock(ctx context.Context, b *types.FullBlock) (err error)

	// IsEpochBeyondCurrMax is used to configure the fork rules for longest-chain
	// consensus protocols.
	IsEpochBeyondCurrMax(epoch abi.ChainEpoch) bool

	// CreateBlock implements all the logic required to propose and assemble a new Filecoin block.
	//
	// This function encapsulate all the consensus-specific actions to propose a new block
	// such as the ordering of transactions, the inclusion of consensus proofs, the signature
	// of the block, etc.
	CreateBlock(ctx context.Context, w api.Wallet, bt *api.BlockTemplate) (*types.FullBlock, error)
}

type FilecoinBlockMessages

type FilecoinBlockMessages struct {
	store.BlockMessages

	WinCount int64
}

type RewardFunc

type RewardFunc func(ctx context.Context, vmi vm.Interface, em stmgr.ExecMonitor,
	epoch abi.ChainEpoch, ts *types.TipSet, params *reward.AwardBlockRewardParams) error

RewardFunc parametrizes the logic for rewards when a message is executed.

Each consensus implementation can set their own reward function.

type TipSetExecutor

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

func NewTipSetExecutor

func NewTipSetExecutor(r RewardFunc) *TipSetExecutor

func (*TipSetExecutor) ApplyBlocks

func (t *TipSetExecutor) ApplyBlocks(ctx context.Context,
	sm *stmgr.StateManager,
	parentEpoch abi.ChainEpoch,
	pstate cid.Cid,
	bms []FilecoinBlockMessages,
	epoch abi.ChainEpoch,
	r vm.Rand,
	em stmgr.ExecMonitor,
	vmTracing bool,
	baseFee abi.TokenAmount,
	ts *types.TipSet) (cid.Cid, cid.Cid, error)

func (*TipSetExecutor) ExecuteTipSet

func (t *TipSetExecutor) ExecuteTipSet(ctx context.Context,
	sm *stmgr.StateManager,
	ts *types.TipSet,
	em stmgr.ExecMonitor,
	vmTracing bool) (stateroot cid.Cid, rectsroot cid.Cid, err error)

func (*TipSetExecutor) NewActorRegistry

func (t *TipSetExecutor) NewActorRegistry() *vm.ActorRegistry

func (*TipSetExecutor) StoreEventsAMT

func (t *TipSetExecutor) StoreEventsAMT(ctx context.Context, cs *store.ChainStore, events []types.Event) (cid.Cid, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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