executor

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: BSD-3-Clause Imports: 30 Imported by: 2

README

Package executor

This package deals with state management for P-Chain blocks.

*Block

The *Block type implements the snowman.Block interface. This is the type that the platformvm deals with when it uses snowman.Blocks. *Block wraps a blocks.Block and a manager. The *Block itself doesn't have any state. The state is all held by the manager, and the *Block acts upon the manager to get/set the state. Therefore, we don't need to worry about deduplicating *Block instances.

The platformvm uses the manager to create blocks and query block state because the manager.GetBlock returns a stateful block (*Block), whereas state.State's GetStatelessBlock returns a blocks.Block.

Visitors

This package contains three implementations of blocks.Visitor: verifier, acceptor and rejector. These implement the logic for verifying, accepting and rejecting blocks. Each implementation has a reference to a shared *backend, which maintains state, etc. (The manager has a reference to the shared *backend as well.)

Documentation

Index

Constants

View Source
const ActivationLog = `` /* 1014-byte string literal not displayed */

Variables

View Source
var (
	ErrChainNotSynced = errors.New("chain not synced")
)
View Source
var (
	ErrConflictingBlockTxs = errors.New("block contains conflicting transactions")
)
View Source
var EtnaActivationWasLogged = utils.NewAtomic(false)

TODO: Remove after Etna is activated

Functions

func VerifyWarpMessages added in v1.11.13

func VerifyWarpMessages(
	ctx context.Context,
	networkID uint32,
	validatorState validators.State,
	pChainHeight uint64,
	b block.Block,
) error

VerifyWarpMessages verifies all warp messages in the block. If any of the warp messages are invalid, an error is returned.

Types

type Block

type Block struct {
	block.Block
	// contains filtered or unexported fields
}

Exported for testing in platformvm package.

func (*Block) Accept

func (b *Block) Accept(context.Context) error

func (*Block) Options

func (b *Block) Options(context.Context) ([2]snowman.Block, error)

func (*Block) Reject

func (b *Block) Reject(context.Context) error

func (*Block) ShouldVerifyWithContext added in v1.11.11

func (*Block) ShouldVerifyWithContext(context.Context) (bool, error)

func (*Block) Timestamp

func (b *Block) Timestamp() time.Time

func (*Block) Verify

func (b *Block) Verify(ctx context.Context) error

func (*Block) VerifyWithContext added in v1.11.11

func (b *Block) VerifyWithContext(ctx context.Context, blockContext *smblock.Context) error

type Manager

type Manager interface {
	state.Versions

	// Returns the ID of the most recently accepted block.
	LastAccepted() ids.ID

	SetPreference(blkID ids.ID) (updated bool)
	Preferred() ids.ID

	GetBlock(blkID ids.ID) (snowman.Block, error)
	GetStatelessBlock(blkID ids.ID) (block.Block, error)
	NewBlock(block.Block) snowman.Block

	// VerifyTx verifies that the transaction can be issued based on the currently
	// preferred state. This should *not* be used to verify transactions in a block.
	VerifyTx(tx *txs.Tx) error

	// VerifyUniqueInputs verifies that the inputs are not duplicated in the
	// provided blk or any of its ancestors pinned in memory.
	VerifyUniqueInputs(blkID ids.ID, inputs set.Set[ids.ID]) error
}

func NewManager

func NewManager(
	mempool mempool.Mempool,
	metrics metrics.Metrics,
	s state.State,
	txExecutorBackend *executor.Backend,
	validatorManager validators.Manager,
) Manager

Directories

Path Synopsis
Package executormock is a generated GoMock package.
Package executormock is a generated GoMock package.

Jump to

Keyboard shortcuts

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