consensus

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0, MIT Imports: 50 Imported by: 30

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 added in v1.23.0

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 added in v1.23.0

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 added in v1.23.0

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

func IsValidEthTxForSending added in v1.27.1

func IsValidEthTxForSending(nv network.Version, smsg *types.SignedMessage) bool

func IsValidForSending added in v1.23.0

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

func IsValidSecpkSigType added in v1.23.0

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 added in v1.23.0

func NewActorRegistry() *vm.ActorRegistry

func RunAsyncChecks added in v1.23.0

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 added in v1.23.0

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)

	// IsEpochInConsensusRange returns true if the epoch is "in range" for consensus. That is:
	// - It's not before finality.
	// - It's not too far in the future.
	IsEpochInConsensusRange(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 added in v1.23.0

type FilecoinBlockMessages struct {
	store.BlockMessages

	WinCount int64
}

type RewardFunc added in v1.23.0

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 added in v1.23.0

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

func NewTipSetExecutor added in v1.23.0

func NewTipSetExecutor(r RewardFunc) *TipSetExecutor

func (*TipSetExecutor) ApplyBlocks added in v1.23.0

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

func (*TipSetExecutor) ExecuteTipSet added in v1.23.0

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 added in v1.23.0

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

func (*TipSetExecutor) StoreEventsAMT added in v1.23.0

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