Documentation ¶
Index ¶
- Constants
- Variables
- func AdvanceTimeTo(backend *Backend, parentState state.Chain, newChainTime time.Time) (bool, error)
- func AtomicTx(backend *Backend, feeCalculator fee.Calculator, parentID ids.ID, ...) (state.Diff, set.Set[ids.ID], map[ids.ID]*atomic.Requests, error)
- func GetMaxWeight(chainState state.Chain, validator *state.Staker, startTime time.Time, ...) (uint64, error)
- func GetRewardsCalculator(backend *Backend, parentState state.Chain, subnetID ids.ID) (reward.Calculator, error)
- func GetTransformSubnetTx(chain state.Chain, subnetID ids.ID) (*txs.TransformSubnetTx, error)
- func GetValidator(state state.Chain, subnetID ids.ID, nodeID ids.NodeID) (*state.Staker, error)
- func ProposalTx(backend *Backend, feeCalculator fee.Calculator, tx *txs.Tx, ...) error
- func StandardTx(backend *Backend, feeCalculator fee.Calculator, tx *txs.Tx, state state.Diff) (set.Set[ids.ID], map[ids.ID]*atomic.Requests, func(), error)
- func VerifyNewChainTime(config fee.Config, newChainTime time.Time, now time.Time, ...) error
- func VerifyWarpMessages(ctx context.Context, networkID uint32, validatorState validators.State, ...) error
- type Backend
Constants ¶
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 )
const ( WarpQuorumNumerator = 67 WarpQuorumDenominator = 100 )
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 ¶
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") )
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") )
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 GetTransformSubnetTx ¶ added in v1.10.13
func GetValidator ¶
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.