executor

package
v1.11.13-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: BSD-3-Clause Imports: 35 Imported by: 4

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
)
View Source
const (
	RegisterL1ValidatorTxExpiryWindow = day
)

TODO: Before Etna, ensure that the maximum number of expiries to track is limited to a reasonable number by this window.

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")
	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")
	ErrIsNotTransformSubnetTx          = errors.New("is not a transform subnet 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 (
	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")
)

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,
	subnetID ids.ID,
) (reward.Calculator, error)

func GetTransformSubnetTx added in v1.10.13

func GetTransformSubnetTx(chain state.Chain, subnetID ids.ID) (*txs.TransformSubnetTx, error)

func GetValidator

func GetValidator(state state.Chain, subnetID 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
	Ctx          *snow.Context
	Clk          *mockable.Clock
	Fx           fx.Fx
	FlowChecker  utxo.Verifier
	Uptimes      uptime.Calculator
	Rewards      reward.Calculator
	Bootstrapped *utils.Atomic[bool]
}

Jump to

Keyboard shortcuts

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