executor

package
v1.24.22 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: BSD-3-Clause Imports: 34 Imported by: 2

README

Package executor

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

*Block

The *Block type implements the linear.Block interface. This is the type that the platformvm deals with when it uses linear.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

Overview

Package executor is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChainNotSynced              = errors.New("chain not synced")
	ErrImportTxWhilePartialSyncing = errors.New("issuing an import tx is not allowed while partial syncing")
)
View Source
var (
	ErrConflictingBlockTxs         = errors.New("block contains conflicting transactions")
	ErrStandardBlockWithoutChanges = errors.New("BanffStandardBlock performs no state changes")
)
View Source
var (
	ErrNotOracle = errors.New("block doesn't have options")
)

Functions

func VerifyWarpMessages

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.

When GPU acceleration is available and the block contains multiple BLS warp signatures, verification is batched through the GPU for throughput. Otherwise falls back to sequential CPU verification.

Types

type Block

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

Exported for testing in platformvm package.

func (*Block) Accept

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

func (*Block) EpochBit added in v1.11.14

func (b *Block) EpochBit() bool

EpochBit implements the chain.Block interface Returns the epoch fence bit for FPC

func (*Block) FPCVotes added in v1.11.14

func (b *Block) FPCVotes() [][]byte

FPCVotes implements the chain.Block interface Returns embedded fast-path consensus vote references

func (*Block) Options

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

func (*Block) ParentID added in v1.16.56

func (b *Block) ParentID() ids.ID

ParentID implements chain.Block interface by delegating to Parent()

func (*Block) Reject

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

func (*Block) ShouldVerifyWithRuntime added in v1.22.87

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

func (*Block) Status added in v1.1.11

func (b *Block) Status() uint8

Status implements chain.Block interface. Block status is tracked by the block state manager; this returns the default (processing) status since blocks reaching this code path have not yet been accepted or rejected.

func (*Block) Timestamp

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

func (*Block) Verify

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

func (*Block) VerifyWithRuntime added in v1.22.87

func (b *Block) VerifyWithRuntime(ctx context.Context, blockContext *runtime.Runtime) error

type Manager

type Manager interface {
	state.Versions

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

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

	GetBlock(blkID ids.ID) (chain.Block, error)
	GetStatelessBlock(blkID ids.ID) (platformblock.Block, error)
	NewBlock(platformblock.Block) chain.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 chain.
	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[*txs.Tx],
	metrics metrics.Metrics,
	s state.State,
	txExecutorBackend *executor.Backend,
	validatorManager validators.Manager,
) Manager

type MockManager added in v1.1.11

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

MockManager is a mock of Manager interface.

func NewMockManager added in v1.1.11

func NewMockManager(ctrl *gomock.Controller) *MockManager

NewMockManager creates a new mock instance.

func (*MockManager) EXPECT added in v1.1.11

func (m *MockManager) EXPECT() *MockManagerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockManager) GetBlock added in v1.1.11

func (m *MockManager) GetBlock(blkID ids.ID) (chain.Block, error)

GetBlock mocks base method.

func (*MockManager) GetState added in v1.1.11

func (m *MockManager) GetState(blkID ids.ID) (state.Chain, bool)

GetState mocks base method.

func (*MockManager) GetStatelessBlock added in v1.1.11

func (m *MockManager) GetStatelessBlock(blkID ids.ID) (block.Block, error)

GetStatelessBlock mocks base method.

func (*MockManager) LastAccepted added in v1.1.11

func (m *MockManager) LastAccepted() ids.ID

LastAccepted mocks base method.

func (*MockManager) NewBlock added in v1.1.11

func (m *MockManager) NewBlock(arg0 block.Block) chain.Block

NewBlock mocks base method.

func (*MockManager) Preferred added in v1.1.11

func (m *MockManager) Preferred() ids.ID

Preferred mocks base method.

func (*MockManager) SetPreference added in v1.1.11

func (m *MockManager) SetPreference(blkID ids.ID) bool

SetPreference mocks base method.

func (*MockManager) VerifyTx added in v1.1.11

func (m *MockManager) VerifyTx(tx *txs.Tx) error

VerifyTx mocks base method.

func (*MockManager) VerifyUniqueInputs added in v1.1.11

func (m *MockManager) VerifyUniqueInputs(blkID ids.ID, inputs set.Set[ids.ID]) error

VerifyUniqueInputs mocks base method.

type MockManagerMockRecorder added in v1.1.11

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

MockManagerMockRecorder is the mock recorder for MockManager.

func (*MockManagerMockRecorder) GetBlock added in v1.1.11

func (mr *MockManagerMockRecorder) GetBlock(blkID any) *gomock.Call

GetBlock indicates an expected call of GetBlock.

func (*MockManagerMockRecorder) GetState added in v1.1.11

func (mr *MockManagerMockRecorder) GetState(blkID any) *gomock.Call

GetState indicates an expected call of GetState.

func (*MockManagerMockRecorder) GetStatelessBlock added in v1.1.11

func (mr *MockManagerMockRecorder) GetStatelessBlock(blkID any) *gomock.Call

GetStatelessBlock indicates an expected call of GetStatelessBlock.

func (*MockManagerMockRecorder) LastAccepted added in v1.1.11

func (mr *MockManagerMockRecorder) LastAccepted() *gomock.Call

LastAccepted indicates an expected call of LastAccepted.

func (*MockManagerMockRecorder) NewBlock added in v1.1.11

func (mr *MockManagerMockRecorder) NewBlock(arg0 any) *gomock.Call

NewBlock indicates an expected call of NewBlock.

func (*MockManagerMockRecorder) Preferred added in v1.1.11

func (mr *MockManagerMockRecorder) Preferred() *gomock.Call

Preferred indicates an expected call of Preferred.

func (*MockManagerMockRecorder) SetPreference added in v1.1.11

func (mr *MockManagerMockRecorder) SetPreference(blkID any) *gomock.Call

SetPreference indicates an expected call of SetPreference.

func (*MockManagerMockRecorder) VerifyTx added in v1.1.11

func (mr *MockManagerMockRecorder) VerifyTx(tx any) *gomock.Call

VerifyTx indicates an expected call of VerifyTx.

func (*MockManagerMockRecorder) VerifyUniqueInputs added in v1.1.11

func (mr *MockManagerMockRecorder) VerifyUniqueInputs(blkID, inputs any) *gomock.Call

VerifyUniqueInputs indicates an expected call of VerifyUniqueInputs.

type SharedMemory added in v1.11.14

type SharedMemory interface {
	Get(peerChainID ids.ID, keys [][]byte) ([][]byte, error)
	Apply(requests map[ids.ID]interface{}, batch ...interface{}) error
}

SharedMemory provides cross-chain atomic operations

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