Help us shape the future of Go! Take the 2026 Go Developer Survey

executor

package
v1.30.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: BSD-3-Clause Imports: 36 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// Maximum future start time for staking/delegating
	MaxFutureStartTime = 24 * 7 * 2 * time.Hour

	// SyncBound is the synchrony bound used for safe decision making
	SyncBound = 10 * time.Second

	MaxValidatorWeightFactor = 5
)
View Source
const (
	DoubleVoteSlashPercent = 100_000 // 10% of reward.PercentDenominator (1_000_000)
	DoubleSignSlashPercent = 500_000 // 50%
)

Default slash percentages per evidence type.

View Source
const (
	WarpQuorumNumerator   = 67
	WarpQuorumDenominator = 100
)
View Source
const (
	RegisterL1ValidatorTxExpiryWindow = day
)

RegisterL1ValidatorTxExpiryWindow bounds the maximum number of tracked expiries. The window is 1 day, which limits expiry set size.

Variables

View Source
var (
	ErrRemoveStakerTooEarly            = errors.New("attempting to remove staker before their end time")
	ErrRemoveWrongStaker               = errors.New("attempting to remove wrong staker")
	ErrInvalidState                    = errors.New("generated output isn't valid state")
	ErrShouldBePermissionlessStaker    = errors.New("expected permissionless staker")
	ErrWrongTxType                     = errors.New("wrong transaction type")
	ErrInvalidID                       = errors.New("invalid ID")
	ErrProposedAddStakerTxNotPermitted = errors.New("staker transaction not permitted")
	ErrAdvanceTimeTxNotPermitted       = errors.New("AdvanceTimeTx not permitted")
)
View Source
var (
	ErrWeightTooSmall                  = errors.New("weight of this validator is too low")
	ErrWeightTooLarge                  = errors.New("weight of this validator is too large")
	ErrInsufficientDelegationFee       = errors.New("staker charges an insufficient delegation fee")
	ErrStakeTooShort                   = errors.New("staking period is too short")
	ErrStakeTooLong                    = errors.New("staking period is too long")
	ErrFlowCheckFailed                 = errors.New("flow check failed")
	ErrNotValidator                    = errors.New("isn't a current or pending validator")
	ErrRemovePermissionlessValidator   = errors.New("attempting to remove permissionless validator")
	ErrStakeOverflow                   = errors.New("validator stake exceeds limit")
	ErrPeriodMismatch                  = errors.New("proposed staking period is not inside dependent staking period")
	ErrOverDelegated                   = errors.New("validator would be over delegated")
	ErrIsNotTransformChainTx           = errors.New("is not a transform net tx")
	ErrTimestampNotBeforeStartTime     = errors.New("chain timestamp not before start time")
	ErrAlreadyValidator                = errors.New("already a validator")
	ErrDuplicateValidator              = errors.New("duplicate validator")
	ErrDelegateToPermissionedValidator = errors.New("delegation to permissioned validator")
	ErrWrongStakedAssetID              = errors.New("incorrect staked assetID")
	ErrLegacyUpgradeNotActive          = errors.New("legacy upgrade feature not active")
	ErrAddValidatorTxNotPermitted      = errors.New("AddValidatorTx is not permitted")
	ErrAddDelegatorTxNotPermitted      = errors.New("AddDelegatorTx is not permitted")
)
View Source
var (
	ErrChildBlockEarlierThanParent     = errors.New("proposed timestamp before current chain time")
	ErrChildBlockAfterStakerChangeTime = errors.New("proposed timestamp later than next staker change time")
	ErrChildBlockBeyondSyncBound       = errors.New("proposed timestamp is too far in the future relative to local time")
)
View Source
var (
	ErrFutureStakeTime = errors.New("staker starts in the future")
)

Functions

func AdvanceTimeTo

func AdvanceTimeTo(
	backend *Backend,
	parentState state.Chain,
	newChainTime time.Time,
) (bool, error)

AdvanceTimeTo applies all state changes to [parentState] resulting from advancing the chain time to [newChainTime].

Returns true iff the validator set changed.

func AtomicTx

func AtomicTx(
	backend *Backend,
	feeCalculator fee.Calculator,
	parentID ids.ID,
	stateVersions state.Versions,
	tx *txs.Tx,
) (state.Diff, set.Set[ids.ID], map[ids.ID]*atomic.Requests, error)

AtomicTx executes the atomic transaction [tx] and returns the resulting state modifications.

This is only used to execute atomic transactions pre-AP5. After AP5 the execution was moved to StandardTx.

func GetMaxWeight

func GetMaxWeight(
	chainState state.Chain,
	validator *state.Staker,
	startTime time.Time,
	endTime time.Time,
) (uint64, error)

GetMaxWeight returns the maximum total weight of the [validator], including its own weight, between [startTime] and [endTime]. The weight changes are applied in the order they will be applied as chain time advances. Invariant: - [validator.StartTime] <= [startTime] < [endTime] <= [validator.EndTime]

func GetRewardsCalculator

func GetRewardsCalculator(
	backend *Backend,
	parentState state.Chain,
	netID ids.ID,
) (reward.Calculator, error)

func GetTransformChainTx added in v1.22.22

func GetTransformChainTx(chain state.Chain, netID ids.ID) (*txs.TransformChainTx, error)

func GetValidator

func GetValidator(state state.Chain, netID ids.ID, nodeID ids.NodeID) (*state.Staker, error)

GetValidator returns information about the given validator, which may be a current validator or pending validator.

func ProposalTx

func ProposalTx(
	backend *Backend,
	feeCalculator fee.Calculator,
	tx *txs.Tx,
	onCommitState state.Diff,
	onAbortState state.Diff,
) error

ProposalTx executes the proposal transaction [tx].

[onCommitState] will be modified to reflect the changes made to the state if the proposal is committed.

[onAbortState] will be modified to reflect the changes made to the state if the proposal is aborted.

Invariant: It is assumed that [onCommitState] and [onAbortState] represent the same state when passed into this function.

func StandardTx

func StandardTx(
	backend *Backend,
	feeCalculator fee.Calculator,
	tx *txs.Tx,
	state state.Diff,
) (set.Set[ids.ID], map[ids.ID]*atomic.Requests, func(), error)

StandardTx executes the standard transaction [tx].

state is modified to represent the state of the chain after the execution of [tx].

Returns:

  • The IDs of any import UTXOs consumed.
  • The, potentially nil, atomic requests that should be performed against shared memory when this transaction is accepted.
  • A, potentially nil, function that should be called when this transaction is accepted.

func VerifyNewChainTime

func VerifyNewChainTime(
	config fee.Config,
	newChainTime time.Time,
	now time.Time,
	currentState state.Chain,
) error

VerifyNewChainTime returns nil if the [newChainTime] is a valid chain time. Requires:

  • [newChainTime] >= [currentChainTime]: to ensure chain time advances monotonically.
  • [newChainTime] <= [now] + SyncBound: to ensure chain time approximates "real" time.
  • [newChainTime] <= [nextStakerChangeTime]: so that no staking set changes are skipped.

func VerifyWarpMessages

func VerifyWarpMessages(
	ctx context.Context,
	networkID uint32,
	validatorState validators.State,
	pChainHeight uint64,
	tx txs.UnsignedTx,
) error

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

Types

type Backend

type Backend struct {
	Config       *config.Internal
	Runtime      *runtime.Runtime
	Clk          *mockable.Clock
	Fx           fx.Fx
	FlowChecker  utxo.Verifier
	Uptimes      uptime.Calculator
	Rewards      reward.Calculator
	Bootstrapped *utils.Atomic[bool]
	Log          log.Logger
}

type MempoolTxVerifier added in v1.1.11

type MempoolTxVerifier struct {
	*Backend
	ParentID      ids.ID
	StateVersions state.Versions
	Tx            *txs.Tx
}

func (*MempoolTxVerifier) AddChainValidatorTx added in v1.22.22

func (v *MempoolTxVerifier) AddChainValidatorTx(tx *txs.AddChainValidatorTx) error

func (*MempoolTxVerifier) AddDelegatorTx added in v1.1.11

func (v *MempoolTxVerifier) AddDelegatorTx(tx *txs.AddDelegatorTx) error

func (*MempoolTxVerifier) AddPermissionlessDelegatorTx added in v1.1.11

func (v *MempoolTxVerifier) AddPermissionlessDelegatorTx(tx *txs.AddPermissionlessDelegatorTx) error

func (*MempoolTxVerifier) AddPermissionlessValidatorTx added in v1.1.11

func (v *MempoolTxVerifier) AddPermissionlessValidatorTx(tx *txs.AddPermissionlessValidatorTx) error

func (*MempoolTxVerifier) AddValidatorTx added in v1.1.11

func (v *MempoolTxVerifier) AddValidatorTx(tx *txs.AddValidatorTx) error

func (*MempoolTxVerifier) AdvanceTimeTx added in v1.1.11

func (*MempoolTxVerifier) AdvanceTimeTx(*txs.AdvanceTimeTx) error

func (*MempoolTxVerifier) BaseTx added in v1.1.11

func (v *MempoolTxVerifier) BaseTx(tx *txs.BaseTx) error

func (*MempoolTxVerifier) ConvertNetworkToL1Tx added in v1.24.27

func (v *MempoolTxVerifier) ConvertNetworkToL1Tx(tx *txs.ConvertNetworkToL1Tx) error

func (*MempoolTxVerifier) CreateAssetTx added in v1.26.25

func (v *MempoolTxVerifier) CreateAssetTx(tx *txs.CreateAssetTx) error

func (*MempoolTxVerifier) CreateChainTx added in v1.1.11

func (v *MempoolTxVerifier) CreateChainTx(tx *txs.CreateChainTx) error

func (*MempoolTxVerifier) CreateNetworkTx added in v1.22.84

func (v *MempoolTxVerifier) CreateNetworkTx(tx *txs.CreateNetworkTx) error

func (*MempoolTxVerifier) CreateSovereignL1Tx added in v1.27.22

func (v *MempoolTxVerifier) CreateSovereignL1Tx(tx *txs.CreateSovereignL1Tx) error

func (*MempoolTxVerifier) DisableL1ValidatorTx added in v1.11.14

func (v *MempoolTxVerifier) DisableL1ValidatorTx(tx *txs.DisableL1ValidatorTx) error

func (*MempoolTxVerifier) ExportTx added in v1.1.11

func (v *MempoolTxVerifier) ExportTx(tx *txs.ExportTx) error

func (*MempoolTxVerifier) ImportTx added in v1.1.11

func (v *MempoolTxVerifier) ImportTx(tx *txs.ImportTx) error

func (*MempoolTxVerifier) IncreaseL1ValidatorBalanceTx added in v1.11.14

func (v *MempoolTxVerifier) IncreaseL1ValidatorBalanceTx(tx *txs.IncreaseL1ValidatorBalanceTx) error

func (*MempoolTxVerifier) OperationTx added in v1.26.25

func (v *MempoolTxVerifier) OperationTx(tx *txs.OperationTx) error

func (*MempoolTxVerifier) RegisterL1ValidatorTx added in v1.11.14

func (v *MempoolTxVerifier) RegisterL1ValidatorTx(tx *txs.RegisterL1ValidatorTx) error

func (*MempoolTxVerifier) RemoveChainValidatorTx added in v1.22.22

func (v *MempoolTxVerifier) RemoveChainValidatorTx(tx *txs.RemoveChainValidatorTx) error

func (*MempoolTxVerifier) RewardValidatorTx added in v1.1.11

func (*MempoolTxVerifier) RewardValidatorTx(*txs.RewardValidatorTx) error

func (*MempoolTxVerifier) SetL1ValidatorWeightTx added in v1.11.14

func (v *MempoolTxVerifier) SetL1ValidatorWeightTx(tx *txs.SetL1ValidatorWeightTx) error

func (*MempoolTxVerifier) SlashValidatorTx added in v1.24.10

func (v *MempoolTxVerifier) SlashValidatorTx(tx *txs.SlashValidatorTx) error

func (*MempoolTxVerifier) TransferChainOwnershipTx added in v1.22.22

func (v *MempoolTxVerifier) TransferChainOwnershipTx(tx *txs.TransferChainOwnershipTx) error

func (*MempoolTxVerifier) TransformChainTx added in v1.22.22

func (v *MempoolTxVerifier) TransformChainTx(tx *txs.TransformChainTx) error

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

Jump to

Keyboard shortcuts

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