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

executor

package
v1.16.18 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: BSD-3-Clause Imports: 27 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 (
	WarpQuorumNumerator   = 67
	WarpQuorumDenominator = 100
)

Variables

View Source
var (
	ErrRemoveStakerTooEarly          = errors.New("attempting to remove staker before their end time")
	ErrRemoveWrongStaker             = errors.New("attempting to remove wrong staker")
	ErrChildBlockNotAfterParent      = errors.New("proposed timestamp not after current chain time")
	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")
	ErrProposedAddStakerTxAfterBanff = errors.New("staker transaction proposed after Banff")
	ErrAdvanceTimeTxIssuedAfterBanff = errors.New("AdvanceTimeTx issued after Banff")
)
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 dependant staking period")
	ErrOverDelegated                   = errors.New("validator would be over delegated")
	ErrIsNotTransformNetTx             = 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")
	ErrDurangoUpgradeNotActive         = errors.New("attempting to use a Durango-upgrade feature prior to activation")
	ErrAddValidatorTxPostDurango       = errors.New("AddValidatorTx is not permitted post-Durango")
	ErrAddDelegatorTxPostDurango       = errors.New("AddDelegatorTx is not permitted post-Durango")
)
View Source
var (
	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")
)

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

func GetTransformNetTx(chain state.Chain, netID ids.ID) (*txs.TransformNetTx, 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 VerifyNewChainTime

func VerifyNewChainTime(
	newChainTime,
	nextStakerChangeTime,
	now time.Time,
) error

VerifyNewChainTime returns nil if the [newChainTime] is a valid chain time given the wall clock time ([now]) and when the next staking set change occurs ([nextStakerChangeTime]). Requires:

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

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

type AtomicTxExecutor struct {
	// inputs, to be filled before visitor methods are called
	*Backend
	ParentID      ids.ID
	StateVersions state.Versions
	Tx            *txs.Tx

	// outputs of visitor execution
	OnAccept       state.Diff
	Inputs         set.Set[ids.ID]
	AtomicRequests map[ids.ID]*atomic.Requests
}

atomicTxExecutor is used to execute atomic transactions pre-AP5. After AP5 the execution was moved to be performed inside of the standardTxExecutor.

func (*AtomicTxExecutor) AddDelegatorTx added in v1.1.11

func (*AtomicTxExecutor) AddDelegatorTx(*txs.AddDelegatorTx) error

func (*AtomicTxExecutor) AddNetValidatorTx added in v1.16.16

func (*AtomicTxExecutor) AddNetValidatorTx(*txs.AddNetValidatorTx) error

func (*AtomicTxExecutor) AddPermissionlessDelegatorTx added in v1.1.11

func (*AtomicTxExecutor) AddPermissionlessDelegatorTx(*txs.AddPermissionlessDelegatorTx) error

func (*AtomicTxExecutor) AddPermissionlessValidatorTx added in v1.1.11

func (*AtomicTxExecutor) AddPermissionlessValidatorTx(*txs.AddPermissionlessValidatorTx) error

func (*AtomicTxExecutor) AddValidatorTx added in v1.1.11

func (*AtomicTxExecutor) AddValidatorTx(*txs.AddValidatorTx) error

func (*AtomicTxExecutor) AdvanceTimeTx added in v1.1.11

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

func (*AtomicTxExecutor) BaseTx added in v1.1.11

func (*AtomicTxExecutor) BaseTx(*txs.BaseTx) error

func (*AtomicTxExecutor) ConvertNetToL1Tx added in v1.16.16

func (e *AtomicTxExecutor) ConvertNetToL1Tx(tx *txs.ConvertNetToL1Tx) error

ConvertNetToL1Tx handles converting a net to L1

func (*AtomicTxExecutor) CreateChainTx added in v1.1.11

func (*AtomicTxExecutor) CreateChainTx(*txs.CreateChainTx) error

func (*AtomicTxExecutor) CreateNetTx added in v1.16.16

func (*AtomicTxExecutor) CreateNetTx(*txs.CreateNetTx) error

func (*AtomicTxExecutor) DisableL1ValidatorTx added in v1.11.14

func (e *AtomicTxExecutor) DisableL1ValidatorTx(tx *txs.DisableL1ValidatorTx) error

DisableL1ValidatorTx handles L1 validator disabling

func (*AtomicTxExecutor) ExportTx added in v1.1.11

func (e *AtomicTxExecutor) ExportTx(tx *txs.ExportTx) error

func (*AtomicTxExecutor) ImportTx added in v1.1.11

func (e *AtomicTxExecutor) ImportTx(tx *txs.ImportTx) error

func (*AtomicTxExecutor) IncreaseL1ValidatorBalanceTx added in v1.11.14

func (e *AtomicTxExecutor) IncreaseL1ValidatorBalanceTx(tx *txs.IncreaseL1ValidatorBalanceTx) error

IncreaseL1ValidatorBalanceTx handles L1 validator balance increase

func (*AtomicTxExecutor) RegisterL1ValidatorTx added in v1.11.14

func (e *AtomicTxExecutor) RegisterL1ValidatorTx(tx *txs.RegisterL1ValidatorTx) error

RegisterL1ValidatorTx handles L1 validator registration

func (*AtomicTxExecutor) RemoveNetValidatorTx added in v1.16.16

func (*AtomicTxExecutor) RemoveNetValidatorTx(*txs.RemoveNetValidatorTx) error

func (*AtomicTxExecutor) RewardValidatorTx added in v1.1.11

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

func (*AtomicTxExecutor) SetL1ValidatorWeightTx added in v1.11.14

func (e *AtomicTxExecutor) SetL1ValidatorWeightTx(tx *txs.SetL1ValidatorWeightTx) error

SetL1ValidatorWeightTx handles L1 validator weight setting

func (*AtomicTxExecutor) TransferNetOwnershipTx added in v1.16.16

func (*AtomicTxExecutor) TransferNetOwnershipTx(*txs.TransferNetOwnershipTx) error

func (*AtomicTxExecutor) TransformNetTx added in v1.16.16

func (*AtomicTxExecutor) TransformNetTx(*txs.TransformNetTx) error

type Backend

type Backend struct {
	Config       *config.Config
	Ctx          context.Context
	LUXAssetID   ids.ID
	NodeID       ids.NodeID
	SharedMemory SharedMemory
	Lock         sync.Locker
	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) AddDelegatorTx added in v1.1.11

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

func (*MempoolTxVerifier) AddNetValidatorTx added in v1.16.16

func (v *MempoolTxVerifier) AddNetValidatorTx(tx *txs.AddNetValidatorTx) 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) ConvertNetToL1Tx added in v1.16.16

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

ConvertNetToL1Tx handles converting a net to L1

func (*MempoolTxVerifier) CreateChainTx added in v1.1.11

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

func (*MempoolTxVerifier) CreateNetTx added in v1.16.16

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

func (*MempoolTxVerifier) DisableL1ValidatorTx added in v1.11.14

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

DisableL1ValidatorTx handles L1 validator disabling

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

IncreaseL1ValidatorBalanceTx handles L1 validator balance increase

func (*MempoolTxVerifier) RegisterL1ValidatorTx added in v1.11.14

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

RegisterL1ValidatorTx handles L1 validator registration

func (*MempoolTxVerifier) RemoveNetValidatorTx added in v1.16.16

func (v *MempoolTxVerifier) RemoveNetValidatorTx(tx *txs.RemoveNetValidatorTx) 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

SetL1ValidatorWeightTx handles L1 validator weight setting

func (*MempoolTxVerifier) TransferNetOwnershipTx added in v1.16.16

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

func (*MempoolTxVerifier) TransformNetTx added in v1.16.16

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

type ProposalTxExecutor added in v1.1.11

type ProposalTxExecutor struct {
	// inputs, to be filled before visitor methods are called
	*Backend
	Tx *txs.Tx
	// [OnCommitState] is the state used for validation.
	// [OnCommitState] is modified by this struct's methods to
	// reflect changes made to the state if the proposal is committed.
	//
	// Invariant: Both [OnCommitState] and [OnAbortState] represent the same
	//            state when provided to this struct.
	OnCommitState state.Diff
	// [OnAbortState] is modified by this struct's methods to
	// reflect changes made to the state if the proposal is aborted.
	OnAbortState state.Diff
}

func (*ProposalTxExecutor) AddDelegatorTx added in v1.1.11

func (e *ProposalTxExecutor) AddDelegatorTx(tx *txs.AddDelegatorTx) error

func (*ProposalTxExecutor) AddNetValidatorTx added in v1.16.16

func (e *ProposalTxExecutor) AddNetValidatorTx(tx *txs.AddNetValidatorTx) error

func (*ProposalTxExecutor) AddPermissionlessDelegatorTx added in v1.1.11

func (*ProposalTxExecutor) AddPermissionlessDelegatorTx(*txs.AddPermissionlessDelegatorTx) error

func (*ProposalTxExecutor) AddPermissionlessValidatorTx added in v1.1.11

func (*ProposalTxExecutor) AddPermissionlessValidatorTx(*txs.AddPermissionlessValidatorTx) error

func (*ProposalTxExecutor) AddValidatorTx added in v1.1.11

func (e *ProposalTxExecutor) AddValidatorTx(tx *txs.AddValidatorTx) error

func (*ProposalTxExecutor) AdvanceTimeTx added in v1.1.11

func (e *ProposalTxExecutor) AdvanceTimeTx(tx *txs.AdvanceTimeTx) error

func (*ProposalTxExecutor) BaseTx added in v1.1.11

func (*ProposalTxExecutor) BaseTx(*txs.BaseTx) error

func (*ProposalTxExecutor) ConvertNetToL1Tx added in v1.16.16

func (e *ProposalTxExecutor) ConvertNetToL1Tx(tx *txs.ConvertNetToL1Tx) error

ConvertNetToL1Tx handles converting a net to L1

func (*ProposalTxExecutor) CreateChainTx added in v1.1.11

func (*ProposalTxExecutor) CreateChainTx(*txs.CreateChainTx) error

func (*ProposalTxExecutor) CreateNetTx added in v1.16.16

func (*ProposalTxExecutor) CreateNetTx(*txs.CreateNetTx) error

func (*ProposalTxExecutor) DisableL1ValidatorTx added in v1.11.14

func (e *ProposalTxExecutor) DisableL1ValidatorTx(tx *txs.DisableL1ValidatorTx) error

DisableL1ValidatorTx handles L1 validator disabling

func (*ProposalTxExecutor) ExportTx added in v1.1.11

func (*ProposalTxExecutor) ExportTx(*txs.ExportTx) error

func (*ProposalTxExecutor) ImportTx added in v1.1.11

func (*ProposalTxExecutor) ImportTx(*txs.ImportTx) error

func (*ProposalTxExecutor) IncreaseL1ValidatorBalanceTx added in v1.11.14

func (e *ProposalTxExecutor) IncreaseL1ValidatorBalanceTx(tx *txs.IncreaseL1ValidatorBalanceTx) error

IncreaseL1ValidatorBalanceTx handles L1 validator balance increase

func (*ProposalTxExecutor) RegisterL1ValidatorTx added in v1.11.14

func (e *ProposalTxExecutor) RegisterL1ValidatorTx(tx *txs.RegisterL1ValidatorTx) error

RegisterL1ValidatorTx handles L1 validator registration

func (*ProposalTxExecutor) RemoveNetValidatorTx added in v1.16.16

func (*ProposalTxExecutor) RemoveNetValidatorTx(*txs.RemoveNetValidatorTx) error

func (*ProposalTxExecutor) RewardValidatorTx added in v1.1.11

func (e *ProposalTxExecutor) RewardValidatorTx(tx *txs.RewardValidatorTx) error

func (*ProposalTxExecutor) SetL1ValidatorWeightTx added in v1.11.14

func (e *ProposalTxExecutor) SetL1ValidatorWeightTx(tx *txs.SetL1ValidatorWeightTx) error

SetL1ValidatorWeightTx handles L1 validator weight setting

func (*ProposalTxExecutor) TransferNetOwnershipTx added in v1.16.16

func (*ProposalTxExecutor) TransferNetOwnershipTx(*txs.TransferNetOwnershipTx) error

func (*ProposalTxExecutor) TransformNetTx added in v1.16.16

func (*ProposalTxExecutor) TransformNetTx(*txs.TransformNetTx) 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

type StandardTxExecutor added in v1.1.11

type StandardTxExecutor struct {
	// inputs, to be filled before visitor methods are called
	*Backend
	State state.Diff // state is expected to be modified
	Tx    *txs.Tx

	// outputs of visitor execution
	OnAccept       func() // may be nil
	Inputs         set.Set[ids.ID]
	AtomicRequests map[ids.ID]*atomic.Requests // may be nil
}

func (*StandardTxExecutor) AddDelegatorTx added in v1.1.11

func (e *StandardTxExecutor) AddDelegatorTx(tx *txs.AddDelegatorTx) error

func (*StandardTxExecutor) AddNetValidatorTx added in v1.16.16

func (e *StandardTxExecutor) AddNetValidatorTx(tx *txs.AddNetValidatorTx) error

func (*StandardTxExecutor) AddPermissionlessDelegatorTx added in v1.1.11

func (e *StandardTxExecutor) AddPermissionlessDelegatorTx(tx *txs.AddPermissionlessDelegatorTx) error

func (*StandardTxExecutor) AddPermissionlessValidatorTx added in v1.1.11

func (e *StandardTxExecutor) AddPermissionlessValidatorTx(tx *txs.AddPermissionlessValidatorTx) error

func (*StandardTxExecutor) AddValidatorTx added in v1.1.11

func (e *StandardTxExecutor) AddValidatorTx(tx *txs.AddValidatorTx) error

func (*StandardTxExecutor) AdvanceTimeTx added in v1.1.11

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

func (*StandardTxExecutor) BaseTx added in v1.1.11

func (e *StandardTxExecutor) BaseTx(tx *txs.BaseTx) error

func (*StandardTxExecutor) ConvertNetToL1Tx added in v1.16.16

func (e *StandardTxExecutor) ConvertNetToL1Tx(tx *txs.ConvertNetToL1Tx) error

ConvertNetToL1Tx handles converting a net to L1

func (*StandardTxExecutor) CreateChainTx added in v1.1.11

func (e *StandardTxExecutor) CreateChainTx(tx *txs.CreateChainTx) error

func (*StandardTxExecutor) CreateNetTx added in v1.16.16

func (e *StandardTxExecutor) CreateNetTx(tx *txs.CreateNetTx) error

func (*StandardTxExecutor) DisableL1ValidatorTx added in v1.11.14

func (e *StandardTxExecutor) DisableL1ValidatorTx(tx *txs.DisableL1ValidatorTx) error

DisableL1ValidatorTx handles L1 validator disabling

func (*StandardTxExecutor) ExportTx added in v1.1.11

func (e *StandardTxExecutor) ExportTx(tx *txs.ExportTx) error

func (*StandardTxExecutor) ImportTx added in v1.1.11

func (e *StandardTxExecutor) ImportTx(tx *txs.ImportTx) error

func (*StandardTxExecutor) IncreaseL1ValidatorBalanceTx added in v1.11.14

func (e *StandardTxExecutor) IncreaseL1ValidatorBalanceTx(tx *txs.IncreaseL1ValidatorBalanceTx) error

IncreaseL1ValidatorBalanceTx handles L1 validator balance increase

func (*StandardTxExecutor) RegisterL1ValidatorTx added in v1.11.14

func (e *StandardTxExecutor) RegisterL1ValidatorTx(tx *txs.RegisterL1ValidatorTx) error

RegisterL1ValidatorTx handles L1 validator registration

func (*StandardTxExecutor) RemoveNetValidatorTx added in v1.16.16

func (e *StandardTxExecutor) RemoveNetValidatorTx(tx *txs.RemoveNetValidatorTx) error

Verifies a *txs.RemoveNetValidatorTx and, if it passes, executes it on [e.State]. For verification rules, see [verifyRemoveNetValidatorTx]. This transaction will result in [tx.NodeID] being removed as a validator of [tx.NetID]. Note: [tx.NodeID] may be either a current or pending validator.

func (*StandardTxExecutor) RewardValidatorTx added in v1.1.11

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

func (*StandardTxExecutor) SetL1ValidatorWeightTx added in v1.11.14

func (e *StandardTxExecutor) SetL1ValidatorWeightTx(tx *txs.SetL1ValidatorWeightTx) error

SetL1ValidatorWeightTx handles L1 validator weight setting

func (*StandardTxExecutor) TransferNetOwnershipTx added in v1.16.16

func (e *StandardTxExecutor) TransferNetOwnershipTx(tx *txs.TransferNetOwnershipTx) error

Verifies a *txs.TransferNetOwnershipTx and, if it passes, executes it on [e.State]. For verification rules, see [verifyTransferNetOwnershipTx]. This transaction will result in the ownership of [tx.Net] being transferred to [tx.Owner].

func (*StandardTxExecutor) TransformNetTx added in v1.16.16

func (e *StandardTxExecutor) TransformNetTx(tx *txs.TransformNetTx) error

Jump to

Keyboard shortcuts

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