statetransition

package
v1.22.5 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package statetransition implements consensus-spec state transition functions for Fulu+ beacon states.

The primary entry point is PrepareEpochPreState, which takes a post-block state (typically the last block of a parent epoch) and advances it to the pre-state of a target epoch by applying epoch transitions.

This produces the normally inaccessible pre-slot-1, post-epoch-transition state that the beacon API cannot serve directly.

Only needed for Fulu+ states. Pre-Fulu states already provide the correct epoch boundary values from the post-state of the parent epoch's last block.

Index

Constants

View Source
const (
	BuilderPaymentThresholdNumerator   = 6
	BuilderPaymentThresholdDenominator = 10
)

Gloas-specific spec constants for builder payment quorum.

View Source
const (
	TimelySourceFlagIndex = 0
	TimelyTargetFlagIndex = 1
	TimelyHeadFlagIndex   = 2

	TimelySourceWeight = 14
	TimelyTargetWeight = 26
	TimelyHeadWeight   = 14
	SyncRewardWeight   = 2
	ProposerWeight     = 8
	WeightDenominator  = 64

	ParticipationFlagCount = 3
	BaseRewardsPerEpoch    = 4
)

Altair constants.

View Source
const BuilderIndexFlag = uint64(1 << 40)

BuilderIndexFlag separates builder indices from validator indices.

View Source
const FarFutureEpoch = phase0.Epoch(math.MaxUint64)

FarFutureEpoch is the sentinel value for unset epochs.

Variables

Functions

This section is empty.

Types

type ApplyInfo

type ApplyInfo struct {
	// EpochTransitionDur is non-zero when the block's process_slots crossed an
	// epoch boundary, triggering process_epoch.
	EpochTransitionDur time.Duration
}

ApplyInfo collects optional timing information from block application. Pass a non-nil pointer to ApplyBlockWithInfo to receive this data.

type StateTransition

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

StateTransition holds the chain spec, dynamic SSZ encoder, and reusable caches for applying multiple blocks and epoch transitions to the same state. Create one per state replay session and reuse across ApplyBlock calls.

func NewStateTransition

func NewStateTransition(specs *consensus.ChainSpec, ds *dynssz.DynSsz) *StateTransition

NewStateTransition creates a new StateTransition with the given chain spec and dynssz encoder.

func (*StateTransition) ApplyBlock

ApplyBlock applies a beacon block to the state in-place.

func (*StateTransition) ApplyBlockWithInfo

func (st *StateTransition) ApplyBlockWithInfo(state *spec.VersionedBeaconState, block *spec.VersionedSignedBeaconBlock, parentStateRoot phase0.Root, info *ApplyInfo) error

ApplyBlockWithInfo is like ApplyBlockWithStateRoot but also populates info with timing details (e.g. epoch transition duration).

func (*StateTransition) ApplyBlockWithStateRoot

func (st *StateTransition) ApplyBlockWithStateRoot(state *spec.VersionedBeaconState, block *spec.VersionedSignedBeaconBlock, parentStateRoot phase0.Root) error

ApplyBlockWithStateRoot is like ApplyBlock but accepts the current state's hash tree root as a hint, skipping the expensive HTR computation in the first process_slot. The hint must match the HTR of the current state — typically sourced from the previously applied block's state_root field. Passing an incorrect hint will produce an inconsistent state and is undefined behavior.

func (*StateTransition) PrepareEpochPreState

func (st *StateTransition) PrepareEpochPreState(state *spec.VersionedBeaconState, epoch phase0.Epoch, info *TransitionInfo) error

PrepareEpochPreState advances a post-block state to the pre-state of the target epoch.

type TransitionInfo

type TransitionInfo struct {
	// DelayedBuilderPayments is the number of delayed builder payments appended
	// to BuilderPendingWithdrawals by the last epoch transition's
	// process_builder_pending_payments. This tells the state simulator how many
	// entries at the tail of the queue are delayed (vs direct payments from block payloads).
	DelayedBuilderPayments uint32
}

TransitionInfo collects metadata from the state transition that callers may need for downstream processing. Pass a non-nil pointer to PrepareEpochPreState to receive this information; pass nil if not needed.

Jump to

Keyboard shortcuts

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