executor

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: BSD-3-Clause Imports: 22 Imported by: 0

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
)

Variables

This section is empty.

Functions

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 GetNextStakerChangeTime

func GetNextStakerChangeTime(state state.Chain) (time.Time, error)

GetNextStakerChangeTime returns the next time a staker will be either added or removed to/from the current validator set.

func GetRewardsCalculator

func GetRewardsCalculator(
	backend *Backend,
	parentState state.Chain,
	subnetID ids.ID,
) (reward.Calculator, 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 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.

Types

type AtomicTxExecutor

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

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

func (*AtomicTxExecutor) AddPermissionlessDelegatorTx

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

func (*AtomicTxExecutor) AddPermissionlessValidatorTx

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

func (*AtomicTxExecutor) AddSubnetValidatorTx

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

func (*AtomicTxExecutor) AddValidatorTx

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

func (*AtomicTxExecutor) AdvanceTimeTx

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

func (*AtomicTxExecutor) CreateChainTx

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

func (*AtomicTxExecutor) CreateSubnetTx

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

func (*AtomicTxExecutor) ExportTx

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

func (*AtomicTxExecutor) ImportTx

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

func (*AtomicTxExecutor) RemoveSubnetValidatorTx

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

func (*AtomicTxExecutor) RewardValidatorTx

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

func (*AtomicTxExecutor) TransformSubnetTx

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

type Backend

type Backend struct {
	Config       *config.Config
	Ctx          *snow.Context
	Clk          *mockable.Clock
	Fx           fx.Fx
	FlowChecker  utxo.Verifier
	Uptimes      uptime.Manager
	Rewards      reward.Calculator
	Bootstrapped *utils.AtomicBool
}

type MempoolTxVerifier

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

func (*MempoolTxVerifier) AddDelegatorTx

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

func (*MempoolTxVerifier) AddPermissionlessDelegatorTx

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

func (*MempoolTxVerifier) AddPermissionlessValidatorTx

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

func (*MempoolTxVerifier) AddSubnetValidatorTx

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

func (*MempoolTxVerifier) AddValidatorTx

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

func (*MempoolTxVerifier) AdvanceTimeTx

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

func (*MempoolTxVerifier) CreateChainTx

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

func (*MempoolTxVerifier) CreateSubnetTx

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

func (*MempoolTxVerifier) ExportTx

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

func (*MempoolTxVerifier) ImportTx

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

func (*MempoolTxVerifier) RemoveSubnetValidatorTx

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

func (*MempoolTxVerifier) RewardValidatorTx

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

func (*MempoolTxVerifier) TransformSubnetTx

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

type ProposalTxExecutor

type ProposalTxExecutor struct {
	// inputs, to be filled before visitor methods are called
	*Backend
	Tx *txs.Tx
	// [OnCommitState] is the state used for validation.
	// In practice, both [OnCommitState] and [onAbortState] are
	// identical when passed into this struct, so we could use either.
	// [OnCommitState] is modified by this struct's methods to
	// reflect changes made to the state if the proposal is committed.
	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

	// outputs populated by this struct's methods:
	//
	// [PrefersCommit] is true iff this node initially prefers to
	// commit this block transaction.
	PrefersCommit bool
}

func (*ProposalTxExecutor) AddDelegatorTx

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

func (*ProposalTxExecutor) AddPermissionlessDelegatorTx

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

func (*ProposalTxExecutor) AddPermissionlessValidatorTx

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

func (*ProposalTxExecutor) AddSubnetValidatorTx

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

func (*ProposalTxExecutor) AddValidatorTx

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

func (*ProposalTxExecutor) AdvanceTimeTx

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

func (*ProposalTxExecutor) CreateChainTx

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

func (*ProposalTxExecutor) CreateSubnetTx

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

func (*ProposalTxExecutor) ExportTx

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

func (*ProposalTxExecutor) ImportTx

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

func (*ProposalTxExecutor) RemoveSubnetValidatorTx

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

func (*ProposalTxExecutor) RewardValidatorTx

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

func (*ProposalTxExecutor) TransformSubnetTx

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

type StandardTxExecutor

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

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

func (*StandardTxExecutor) AddPermissionlessDelegatorTx

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

func (*StandardTxExecutor) AddPermissionlessValidatorTx

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

func (*StandardTxExecutor) AddSubnetValidatorTx

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

func (*StandardTxExecutor) AddValidatorTx

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

func (*StandardTxExecutor) AdvanceTimeTx

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

func (*StandardTxExecutor) CreateChainTx

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

func (*StandardTxExecutor) CreateSubnetTx

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

func (*StandardTxExecutor) ExportTx

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

func (*StandardTxExecutor) ImportTx

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

func (*StandardTxExecutor) RemoveSubnetValidatorTx

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

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

func (*StandardTxExecutor) RewardValidatorTx

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

func (*StandardTxExecutor) TransformSubnetTx

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

type StateChanges

type StateChanges interface {
	Apply(onAccept state.Diff)
	Len() int
}

func AdvanceTimeTo

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

AdvanceTimeTo does not modify [parentState]. Instead it returns all the StateChanges caused by advancing the chain time to the [newChainTime].

Jump to

Keyboard shortcuts

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