platformvm

package
v1.22.35 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: BSD-3-Clause Imports: 75 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MinValidatorCount = 3

MinValidatorCount sets the minimum number of validators required

View Source
var RequireValidatorApproval = true

RequireValidatorApproval determines if multiple validators must approve

View Source
var SingleValidatorMode = false

SingleValidatorMode enables single validator operation without build tags

Functions

func ApplyNFTMultiplier added in v1.16.56

func ApplyNFTMultiplier(
	baseReward uint64,
	tokenID uint64,
	nftManager *NFTStakingManager,
) uint64

ApplyNFTMultiplier applies the NFT staking multiplier to rewards

func AwaitTxAccepted added in v0.1.1

func AwaitTxAccepted(
	c *Client,
	ctx context.Context,
	txID ids.ID,
	freq time.Duration,
	options ...rpc.Option,
) error

func GetDeactivationOwners added in v0.1.1

func GetDeactivationOwners(
	c *Client,
	ctx context.Context,
	validationIDs ...ids.ID,
) (map[ids.ID]fx.Owner, error)

GetDeactivationOwners returns a map of validation ID to deactivation owners

func GetNetOwners added in v1.16.56

func GetNetOwners(
	c *Client,
	ctx context.Context,
	subnetIDs ...ids.ID,
) (map[ids.ID]fx.Owner, error)

GetNetOwners returns a map of subnet ID to current subnet's owner

func GetOwners added in v0.1.1

func GetOwners(
	c *Client,
	ctx context.Context,
	subnetIDs []ids.ID,
	validationIDs []ids.ID,
) (map[ids.ID]fx.Owner, error)

GetOwners returns the union of GetNetOwners and GetDeactivationOwners.

func ValidateNFTStaking added in v1.16.56

func ValidateNFTStaking(
	ctx context.Context,
	staker *state.Staker,
	nftManager *NFTStakingManager,
) error

ValidateNFTStaking validates NFT staking for a staker

Types

type APIBlockchain

type APIBlockchain struct {
	// Blockchain's ID
	ID ids.ID `json:"id"`

	// Blockchain's (non-unique) human-readable name
	Name string `json:"name"`

	// Net that validates the blockchain
	NetID ids.ID `json:"netID"`

	// Virtual Machine the blockchain runs
	VMID ids.ID `json:"vmID"`
}

APIBlockchain is the representation of a blockchain used in API calls

type APINet added in v1.16.56

type APINet struct {
	// ID of the net
	ID ids.ID `json:"id"`

	// Each element of [ControlKeys] the address of a public key.
	// A transaction to add a validator to this net requires
	// signatures from [Threshold] of these keys to be valid.
	ControlKeys []string       `json:"controlKeys"`
	Threshold   avajson.Uint32 `json:"threshold"`
}

APINet is a representation of a net used in API calls

type Client added in v0.1.1

type Client struct {
	Requester rpc.EndpointRequester
	// contains filtered or unexported fields
}

func NewClient added in v0.1.1

func NewClient(uri string) *Client

func NewClientWithNetworkID added in v1.22.22

func NewClientWithNetworkID(uri string, networkID uint32) *Client

NewClientWithNetworkID returns a new platformvm.Client with the network ID set for proper bech32 address formatting

func (*Client) GetAtomicUTXOs added in v0.1.1

func (c *Client) GetAtomicUTXOs(
	ctx context.Context,
	addrs []ids.ShortID,
	sourceChain string,
	limit uint32,
	startAddress ids.ShortID,
	startUTXOID ids.ID,
	options ...rpc.Option,
) ([][]byte, ids.ShortID, ids.ID, error)

GetAtomicUTXOs returns the byte representation of the atomic UTXOs controlled by addrs from sourceChain.

func (*Client) GetBalance deprecated added in v0.1.1

func (c *Client) GetBalance(ctx context.Context, addrs []ids.ShortID, options ...rpc.Option) (*GetBalanceResponse, error)

GetBalance returns the balance of addrs.

Deprecated: GetUTXOs should be used instead.

func (*Client) GetBlock added in v0.1.1

func (c *Client) GetBlock(ctx context.Context, blockID ids.ID, options ...rpc.Option) ([]byte, error)

GetBlock returns blockID.

func (*Client) GetBlockByHeight added in v0.1.1

func (c *Client) GetBlockByHeight(ctx context.Context, height uint64, options ...rpc.Option) ([]byte, error)

GetBlockByHeight returns the block at the given height.

func (*Client) GetBlockchainStatus added in v0.1.1

func (c *Client) GetBlockchainStatus(ctx context.Context, blockchainID string, options ...rpc.Option) (status.BlockchainStatus, error)

GetBlockchainStatus returns the current status of blockchainID.

func (*Client) GetBlockchains deprecated added in v0.1.1

func (c *Client) GetBlockchains(ctx context.Context, options ...rpc.Option) ([]APIBlockchain, error)

GetBlockchains returns the list of all blockchains on the platform.

Deprecated: Blockchains should be fetched from a dedicated indexer.

func (*Client) GetCurrentSupply added in v0.1.1

func (c *Client) GetCurrentSupply(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (uint64, uint64, error)

GetCurrentSupply returns an upper bound on the supply of LUX in the system along with the chain height.

func (*Client) GetCurrentValidators added in v0.1.1

func (c *Client) GetCurrentValidators(
	ctx context.Context,
	netID ids.ID,
	nodeIDs []ids.NodeID,
	options ...rpc.Option,
) ([]ClientPermissionlessValidator, error)

GetCurrentValidators returns the list of current validators for subnetID.

func (*Client) GetFeeConfig added in v0.1.1

func (c *Client) GetFeeConfig(ctx context.Context, options ...rpc.Option) (*gas.Config, error)

GetFeeConfig returns the dynamic fee config.

func (*Client) GetFeeState added in v0.1.1

func (c *Client) GetFeeState(ctx context.Context, options ...rpc.Option) (
	gas.State,
	gas.Price,
	time.Time,
	error,
)

GetFeeState returns the current fee state.

func (*Client) GetHeight added in v0.1.1

func (c *Client) GetHeight(ctx context.Context, options ...rpc.Option) (uint64, error)

GetHeight returns the current block height.

func (*Client) GetL1Validator added in v0.1.1

func (c *Client) GetL1Validator(
	ctx context.Context,
	validationID ids.ID,
	options ...rpc.Option,
) (L1Validator, uint64, error)

GetL1Validator returns the requested L1 validator with validationID and the height at which it was calculated.

func (*Client) GetMinStake added in v0.1.1

func (c *Client) GetMinStake(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (uint64, uint64, error)

GetMinStake returns the minimum staking amount in nLUX for validators and delegators respectively.

func (*Client) GetNet added in v1.16.56

func (c *Client) GetNet(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (GetNetClientResponse, error)

GetNet returns information about the specified subnet.

func (*Client) GetNets deprecated added in v1.16.56

func (c *Client) GetNets(ctx context.Context, ids []ids.ID, options ...rpc.Option) ([]ClientNet, error)

GetNets returns information about the specified subnets

Deprecated: Nets should be fetched from a dedicated indexer.

func (*Client) GetProposedHeight added in v0.1.1

func (c *Client) GetProposedHeight(ctx context.Context, options ...rpc.Option) (uint64, error)

GetProposedHeight returns the current height of this node's proposer VM.

func (*Client) GetRewardUTXOs deprecated added in v0.1.1

func (c *Client) GetRewardUTXOs(ctx context.Context, args *api.GetTxArgs, options ...rpc.Option) ([][]byte, error)

GetRewardUTXOs returns the reward UTXOs for a transaction.

Deprecated: GetRewardUTXOs should be fetched from a dedicated indexer.

func (*Client) GetStake deprecated added in v0.1.1

func (c *Client) GetStake(
	ctx context.Context,
	addrs []ids.ShortID,
	validatorsOnly bool,
	options ...rpc.Option,
) (map[ids.ID]uint64, [][]byte, error)

GetStake returns the amount of nLUX that addrs have cumulatively staked on the Primary Network.

Deprecated: Stake should be calculated using GetTx and GetCurrentValidators.

func (*Client) GetStakingAssetID added in v0.1.1

func (c *Client) GetStakingAssetID(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (ids.ID, error)

GetStakingAssetID returns the assetID of the asset used for staking on the subnet corresponding to subnetID.

func (*Client) GetTimestamp added in v0.1.1

func (c *Client) GetTimestamp(ctx context.Context, options ...rpc.Option) (time.Time, error)

GetTimestamp returns the current chain timestamp.

func (*Client) GetTotalStake added in v0.1.1

func (c *Client) GetTotalStake(ctx context.Context, netID ids.ID, options ...rpc.Option) (uint64, error)

GetTotalStake returns the total amount (in nLUX) staked on the network.

func (*Client) GetTx added in v0.1.1

func (c *Client) GetTx(ctx context.Context, txID ids.ID, options ...rpc.Option) ([]byte, error)

GetTx returns the byte representation of txID.

func (*Client) GetTxStatus added in v0.1.1

func (c *Client) GetTxStatus(ctx context.Context, txID ids.ID, options ...rpc.Option) (*GetTxStatusResponse, error)

GetTxStatus returns the status of txID.

func (*Client) GetUTXOs added in v0.1.1

func (c *Client) GetUTXOs(
	ctx context.Context,
	addrs []ids.ShortID,
	limit uint32,
	startAddress ids.ShortID,
	startUTXOID ids.ID,
	options ...rpc.Option,
) ([][]byte, ids.ShortID, ids.ID, error)

GetUTXOs returns the byte representation of the UTXOs controlled by addrs.

func (*Client) GetValidatorFeeConfig added in v0.1.1

func (c *Client) GetValidatorFeeConfig(ctx context.Context, options ...rpc.Option) (*fee.Config, error)

GetValidatorFeeConfig returns the validator fee config.

func (*Client) GetValidatorFeeState added in v0.1.1

func (c *Client) GetValidatorFeeState(ctx context.Context, options ...rpc.Option) (
	gas.Gas,
	gas.Price,
	time.Time,
	error,
)

GetValidatorFeeState returns the current validator fee state.

func (*Client) GetValidatorsAt added in v0.1.1

func (c *Client) GetValidatorsAt(
	ctx context.Context,
	subnetID ids.ID,
	height platformapi.Height,
	options ...rpc.Option,
) (map[ids.NodeID]*validators.GetValidatorOutput, error)

GetValidatorsAt returns the weights of the validator set of a provided subnet at the specified height or at proposerVM height if set to platformapi.ProposedHeight.

func (*Client) IssueTx added in v0.1.1

func (c *Client) IssueTx(ctx context.Context, txBytes []byte, options ...rpc.Option) (ids.ID, error)

IssueTx issues the transaction and returns its txID.

func (*Client) SampleValidators added in v0.1.1

func (c *Client) SampleValidators(ctx context.Context, subnetID ids.ID, sampleSize uint16, options ...rpc.Option) ([]ids.NodeID, error)

SampleValidators returns the nodeIDs of a sample of sampleSize validators from the current validator set for subnetID.

func (*Client) SetNetworkID added in v1.22.22

func (c *Client) SetNetworkID(networkID uint32)

SetNetworkID sets the network ID for address formatting

func (*Client) ValidatedBy added in v0.1.1

func (c *Client) ValidatedBy(ctx context.Context, blockchainID ids.ID, options ...rpc.Option) (ids.ID, error)

ValidatedBy returns the subnetID that validates blockchainID.

func (*Client) Validates added in v0.1.1

func (c *Client) Validates(ctx context.Context, subnetID ids.ID, options ...rpc.Option) ([]ids.ID, error)

Validates returns the list of blockchains that are validated by subnetID.

type ClientDelegator added in v0.1.1

type ClientDelegator struct {
	ClientStaker
	RewardOwner     *ClientOwner
	PotentialReward *uint64
}

ClientDelegator is the repr. of a delegator sent over client

type ClientL1Validator added in v0.1.1

type ClientL1Validator struct {
	ValidationID          *ids.ID
	RemainingBalanceOwner *ClientOwner
	DeactivationOwner     *ClientOwner
	MinNonce              *uint64
	Balance               *uint64
}

type ClientNet added in v1.16.56

type ClientNet struct {
	// ID of the subnet
	ID ids.ID
	// Each element of [ControlKeys] the address of a public key.
	// A transaction to add a validator to this net requires
	// signatures from [Threshold] of these keys to be valid.
	ControlKeys []ids.ShortID
	Threshold   uint32
}

ClientNet is a representation of a net used in client methods

type ClientOwner added in v0.1.1

type ClientOwner struct {
	Locktime  uint64
	Threshold uint32
	Addresses []ids.ShortID
}

ClientOwner is the repr. of a reward owner sent over client

type ClientPermissionlessValidator added in v0.1.1

type ClientPermissionlessValidator struct {
	ClientStaker
	ClientL1Validator
	ValidationRewardOwner  *ClientOwner
	DelegationRewardOwner  *ClientOwner
	PotentialReward        *uint64
	AccruedDelegateeReward *uint64
	DelegationFee          float32
	// Uptime is deprecated for Net Validators.
	// It will be available only for Primary Network Validators.
	Uptime *float32
	// Connected is deprecated for Net Validators.
	// It will be available only for Primary Network Validators.
	Connected *bool
	Signer    *signer.ProofOfPossession
	// The delegators delegating to this validator
	DelegatorCount  *uint64
	DelegatorWeight *uint64
	Delegators      []ClientDelegator
}

ClientPermissionlessValidator is the repr. of a permissionless validator sent over client

type ClientStaker added in v0.1.1

type ClientStaker struct {
	// the txID of the transaction that added this staker.
	TxID ids.ID
	// the Unix time when they start staking
	StartTime uint64
	// the Unix time when they are done staking
	EndTime uint64
	// the validator weight when sampling validators
	Weight uint64
	// the node ID of the staker
	NodeID ids.NodeID
}

ClientStaker is the representation of a staker sent via client.

type Factory

type Factory struct {
	config.Internal
}

Factory can create new instances of the Platform Chain

func (*Factory) New

func (f *Factory) New(log.Logger) (interface{}, error)

New returns a new instance of the Platform Chain

type GetAllValidatorsAtArgs added in v1.16.56

type GetAllValidatorsAtArgs struct {
	Height platformapi.Height `json:"height"`
}

GetAllValidatorsAtArgs are the arguments to GetAllValidatorsAt

type GetAllValidatorsAtReply added in v1.16.56

type GetAllValidatorsAtReply struct {
	// Map of NetID -> ValidatorSet
	ValidatorSets map[ids.ID]map[ids.NodeID]*validators.GetValidatorOutput `json:"validatorSets"`
}

GetAllValidatorsAtReply is the response from GetAllValidatorsAt

type GetBalanceRequest added in v0.1.1

type GetBalanceRequest struct {
	Addresses []string `json:"addresses"`
}

type GetBalanceResponse added in v0.1.1

type GetBalanceResponse struct {
	// Balance, in nLUX, of the address
	Balance             avajson.Uint64            `json:"balance"`
	Unlocked            avajson.Uint64            `json:"unlocked"`
	LockedStakeable     avajson.Uint64            `json:"lockedStakeable"`
	LockedNotStakeable  avajson.Uint64            `json:"lockedNotStakeable"`
	Balances            map[ids.ID]avajson.Uint64 `json:"balances"`
	Unlockeds           map[ids.ID]avajson.Uint64 `json:"unlockeds"`
	LockedStakeables    map[ids.ID]avajson.Uint64 `json:"lockedStakeables"`
	LockedNotStakeables map[ids.ID]avajson.Uint64 `json:"lockedNotStakeables"`
	UTXOIDs             []*lux.UTXOID             `json:"utxoIDs"`
}

Note: We explicitly duplicate LUX out of the maps to ensure backwards compatibility.

type GetBlockchainStatusArgs

type GetBlockchainStatusArgs struct {
	BlockchainID string `json:"blockchainID"`
}

GetBlockchainStatusArgs is the arguments for calling GetBlockchainStatus [BlockchainID] is the ID of or an alias of the blockchain to get the status of.

type GetBlockchainStatusReply

type GetBlockchainStatusReply struct {
	Status status.BlockchainStatus `json:"status"`
}

GetBlockchainStatusReply is the reply from calling GetBlockchainStatus [Status] is the blockchain's status.

type GetBlockchainsResponse

type GetBlockchainsResponse struct {
	// blockchains that exist
	Blockchains []APIBlockchain `json:"blockchains"`
}

GetBlockchainsResponse is the response from a call to GetBlockchains

type GetCurrentSupplyArgs added in v0.1.1

type GetCurrentSupplyArgs struct {
	NetID ids.ID `json:"netID"`
}

GetCurrentSupplyArgs are the arguments for calling GetCurrentSupply

type GetCurrentSupplyReply added in v0.1.1

type GetCurrentSupplyReply struct {
	Supply avajson.Uint64 `json:"supply"`
	Height avajson.Uint64 `json:"height"`
}

GetCurrentSupplyReply are the results from calling GetCurrentSupply

type GetCurrentValidatorsArgs

type GetCurrentValidatorsArgs struct {
	// Net we're listing the validators of
	// If omitted, defaults to primary network
	NetID ids.ID `json:"netID"`
	// NodeIDs of validators to request. If [NodeIDs]
	// is empty, it fetches all current validators. If
	// some nodeIDs are not currently validators, they
	// will be omitted from the response.
	NodeIDs []ids.NodeID `json:"nodeIDs"`
}

GetCurrentValidatorsArgs are the arguments for calling GetCurrentValidators

type GetCurrentValidatorsReply

type GetCurrentValidatorsReply struct {
	Validators []any `json:"validators"`
}

GetCurrentValidatorsReply are the results from calling GetCurrentValidators. Each validator contains a list of delegators to itself.

type GetFeeStateReply added in v0.1.1

type GetFeeStateReply struct {
	gas.State
	Price gas.Price `json:"price"`
	Time  time.Time `json:"timestamp"`
}

type GetL1ValidatorArgs added in v0.1.1

type GetL1ValidatorArgs struct {
	ValidationID ids.ID `json:"validationID"`
}

type GetL1ValidatorReply added in v0.1.1

type GetL1ValidatorReply struct {
	platformapi.APIL1Validator
	NetID ids.ID `json:"netID"`
	// Height is the height of the last accepted block
	Height avajson.Uint64 `json:"height"`
}

type GetMinStakeArgs added in v0.1.1

type GetMinStakeArgs struct {
	NetID ids.ID `json:"netID"`
}

GetMinStakeArgs are the arguments for calling GetMinStake.

type GetMinStakeReply added in v0.1.1

type GetMinStakeReply struct {
	//  The minimum amount of tokens one must bond to be a validator
	MinValidatorStake avajson.Uint64 `json:"minValidatorStake"`
	// Minimum stake, in nLUX, that can be delegated on the primary network
	MinDelegatorStake avajson.Uint64 `json:"minDelegatorStake"`
}

GetMinStakeReply is the response from calling GetMinStake.

type GetNetArgs added in v1.16.56

type GetNetArgs struct {
	// ID of the net to retrieve information about
	NetID ids.ID `json:"netID"`
}

GetNetArgs are the arguments to GetNet

type GetNetClientResponse added in v1.16.56

type GetNetClientResponse struct {
	// whether it is permissioned or not
	IsPermissioned bool
	// net auth information for a permissioned subnet
	ControlKeys []ids.ShortID
	Threshold   uint32
	Locktime    uint64
	// net transformation tx ID for a permissionless subnet
	NetTransformationTxID ids.ID
	// subnet conversion information for an L1
	ConversionID   ids.ID
	ManagerChainID ids.ID
	ManagerAddress []byte
}

GetNetClientResponse is the response from calling GetNet on the client

type GetNetResponse added in v1.16.56

type GetNetResponse struct {
	// whether it is permissioned or not
	IsPermissioned bool `json:"isPermissioned"`
	// net auth information for a permissioned net
	ControlKeys []string       `json:"controlKeys"`
	Threshold   avajson.Uint32 `json:"threshold"`
	Locktime    avajson.Uint64 `json:"locktime"`
	// net transformation tx ID for an elastic net
	NetTransformationTxID ids.ID `json:"netTransformationTxID"`
	// net conversion information for an L1
	ConversionID   ids.ID              `json:"conversionID"`
	ManagerChainID ids.ID              `json:"managerChainID"`
	ManagerAddress types.JSONByteSlice `json:"managerAddress"`
}

GetNetResponse is the response from calling GetNet

type GetNetsArgs added in v1.16.56

type GetNetsArgs struct {
	// IDs of the nets to retrieve information about
	// If omitted, gets all nets
	IDs []ids.ID `json:"ids"`
}

GetNetsArgs are the arguments to GetNets

type GetNetsResponse added in v1.16.56

type GetNetsResponse struct {
	// Each element is a net that exists
	// Null if there are no nets other than the primary network
	Nets []APINet `json:"nets"`
}

GetNetsResponse is the response from calling GetNets

type GetRewardUTXOsReply added in v0.1.1

type GetRewardUTXOsReply struct {
	// Number of UTXOs returned
	NumFetched avajson.Uint64 `json:"numFetched"`
	// The UTXOs
	UTXOs []string `json:"utxos"`
	// Encoding specifies the encoding format the UTXOs are returned in
	Encoding formatting.Encoding `json:"encoding"`
}

GetRewardUTXOsReply defines the GetRewardUTXOs replies returned from the API

type GetStakeArgs added in v0.1.1

type GetStakeArgs struct {
	api.JSONAddresses
	ValidatorsOnly bool                `json:"validatorsOnly"`
	Encoding       formatting.Encoding `json:"encoding"`
}

type GetStakeReply added in v0.1.1

type GetStakeReply struct {
	Staked  avajson.Uint64            `json:"staked"`
	Stakeds map[ids.ID]avajson.Uint64 `json:"stakeds"`
	// String representation of staked outputs
	// Each is of type lux.TransferableOutput
	Outputs []string `json:"stakedOutputs"`
	// Encoding of [Outputs]
	Encoding formatting.Encoding `json:"encoding"`
}

GetStakeReply is the response from calling GetStake.

type GetStakingAssetIDArgs added in v0.1.1

type GetStakingAssetIDArgs struct {
	NetID ids.ID `json:"netID"`
}

GetStakingAssetIDArgs are the arguments to GetStakingAssetID

type GetStakingAssetIDResponse added in v0.1.1

type GetStakingAssetIDResponse struct {
	AssetID ids.ID `json:"assetID"`
}

GetStakingAssetIDResponse is the response from calling GetStakingAssetID

type GetTimestampReply added in v0.1.1

type GetTimestampReply struct {
	// Current timestamp
	Timestamp time.Time `json:"timestamp"`
}

GetTimestampReply is the response from GetTimestamp

type GetTotalStakeArgs added in v0.1.1

type GetTotalStakeArgs struct {
	// Net we're getting the total stake
	// If omitted returns Primary network weight
	NetID ids.ID `json:"netID"`
}

GetTotalStakeArgs are the arguments for calling GetTotalStake

type GetTotalStakeReply added in v0.1.1

type GetTotalStakeReply struct {
	// Deprecated: Use Weight instead.
	Stake avajson.Uint64 `json:"stake"`

	Weight avajson.Uint64 `json:"weight"`
}

GetTotalStakeReply is the response from calling GetTotalStake.

type GetTxStatusArgs added in v0.1.1

type GetTxStatusArgs struct {
	TxID ids.ID `json:"txID"`
}

type GetTxStatusResponse added in v0.1.1

type GetTxStatusResponse struct {
	Status status.Status `json:"status"`
	// Reason this tx was dropped.
	// Only non-empty if Status is dropped
	Reason string `json:"reason,omitempty"`
}

type GetValidatorFeeStateReply added in v0.1.1

type GetValidatorFeeStateReply struct {
	Excess gas.Gas   `json:"excess"`
	Price  gas.Price `json:"price"`
	Time   time.Time `json:"timestamp"`
}

type GetValidatorsAtArgs added in v0.1.1

type GetValidatorsAtArgs struct {
	Height platformapi.Height `json:"height"`
	NetID  ids.ID             `json:"netID"`
}

GetValidatorsAtArgs is the response from GetValidatorsAt

type GetValidatorsAtReply added in v0.1.1

type GetValidatorsAtReply struct {
	Validators map[ids.NodeID]*validators.GetValidatorOutput
}

GetValidatorsAtReply is the response from GetValidatorsAt

func (*GetValidatorsAtReply) MarshalJSON added in v0.1.1

func (v *GetValidatorsAtReply) MarshalJSON() ([]byte, error)

func (*GetValidatorsAtReply) UnmarshalJSON added in v0.1.1

func (v *GetValidatorsAtReply) UnmarshalJSON(b []byte) error

type Index added in v0.1.1

type Index struct {
	Address string `json:"address"` // The address as a string
	UTXO    string `json:"utxo"`    // The UTXO ID as a string
}

Index is an address and an associated UTXO. Marks a starting or stopping point when fetching UTXOs. Used for pagination.

type L1Validator added in v0.1.1

type L1Validator struct {
	NetID                 ids.ID
	NodeID                ids.NodeID
	PublicKey             *bls.PublicKey
	RemainingBalanceOwner *secp256k1fx.OutputOwners
	DeactivationOwner     *secp256k1fx.OutputOwners
	StartTime             uint64
	Weight                uint64
	MinNonce              uint64
	// Balance is the remaining amount of LUX this L1 validator has for paying
	// the continuous fee.
	Balance uint64
}

L1Validator is the response from calling GetL1Validator on the API client.

type NFTStakingConfig added in v1.16.56

type NFTStakingConfig struct {
	Enabled         bool
	ContractAddress common.Address
	RequiredBalance uint64
	ValidatorTiers  []ValidatorTier
	EthRPCEndpoint  string
}

NFTStakingConfig contains configuration for NFT staking

type NFTStakingManager added in v1.16.56

type NFTStakingManager struct {
	// contains filtered or unexported fields
}

NFTStakingManager manages NFT-based validator staking

func NewNFTStakingManager added in v1.16.56

func NewNFTStakingManager(config *NFTStakingConfig, log log.Logger) (*NFTStakingManager, error)

NewNFTStakingManager creates a new NFT staking manager

func (*NFTStakingManager) GetStakedNFTs added in v1.16.56

func (m *NFTStakingManager) GetStakedNFTs() map[uint64]ids.NodeID

GetStakedNFTs returns all currently staked NFTs

func (*NFTStakingManager) GetStakingMultiplier added in v1.16.56

func (m *NFTStakingManager) GetStakingMultiplier(tokenID uint64) uint32

GetStakingMultiplier returns the staking multiplier for a given NFT

func (*NFTStakingManager) ReleaseNFT added in v1.16.56

func (m *NFTStakingManager) ReleaseNFT(nodeID ids.NodeID, tokenID uint64) error

ReleaseNFT releases an NFT from staking

func (*NFTStakingManager) ValidateNFTOwnership added in v1.16.56

func (m *NFTStakingManager) ValidateNFTOwnership(
	ctx context.Context,
	nodeID ids.NodeID,
	ethAddress common.Address,
	tokenID uint64,
) error

ValidateNFTOwnership checks if a node owns a valid NFT for staking

type SampleValidatorsArgs

type SampleValidatorsArgs struct {
	// Number of validators in the sample
	Size avajson.Uint16 `json:"size"`

	// ID of net to sample validators from
	// If omitted, defaults to the primary network
	NetID ids.ID `json:"netID"`
}

SampleValidatorsArgs are the arguments for calling SampleValidators

type SampleValidatorsReply

type SampleValidatorsReply struct {
	Validators []ids.NodeID `json:"validators"`
}

SampleValidatorsReply are the results from calling Sample

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service defines the API calls that can be made to the platform chain

func (*Service) GetAllValidatorsAt added in v1.16.56

func (s *Service) GetAllValidatorsAt(r *http.Request, args *GetAllValidatorsAtArgs, reply *GetAllValidatorsAtReply) error

GetAllValidatorsAt returns the validator sets of all nets (including primary network) at the specified height.

func (*Service) GetBalance added in v0.1.1

func (s *Service) GetBalance(_ *http.Request, args *GetBalanceRequest, response *GetBalanceResponse) error

GetBalance gets the balance of an address

func (*Service) GetBlock added in v0.1.1

func (s *Service) GetBlock(_ *http.Request, args *api.GetBlockArgs, response *api.GetBlockResponse) error

func (*Service) GetBlockByHeight added in v0.1.1

func (s *Service) GetBlockByHeight(_ *http.Request, args *api.GetBlockByHeightArgs, response *api.GetBlockResponse) error

GetBlockByHeight returns the block at the given height.

func (*Service) GetBlockchainStatus

func (s *Service) GetBlockchainStatus(r *http.Request, args *GetBlockchainStatusArgs, reply *GetBlockchainStatusReply) error

GetBlockchainStatus gets the status of a blockchain with the ID [args.BlockchainID].

func (*Service) GetBlockchains

func (s *Service) GetBlockchains(_ *http.Request, _ *struct{}, response *GetBlockchainsResponse) error

GetBlockchains returns all of the blockchains that exist

func (*Service) GetCurrentSupply added in v0.1.1

func (s *Service) GetCurrentSupply(r *http.Request, args *GetCurrentSupplyArgs, reply *GetCurrentSupplyReply) error

GetCurrentSupply returns an upper bound on the supply of LUX in the system

func (*Service) GetCurrentValidators

func (s *Service) GetCurrentValidators(request *http.Request, args *GetCurrentValidatorsArgs, reply *GetCurrentValidatorsReply) error

GetCurrentValidators returns the current validators. If a single nodeID is provided, full delegators information is also returned. Otherwise only delegators' number and total weight is returned.

func (*Service) GetFeeConfig added in v0.1.1

func (s *Service) GetFeeConfig(_ *http.Request, _ *struct{}, reply *gas.Config) error

GetFeeConfig returns the dynamic fee config of the chain.

func (*Service) GetFeeState added in v0.1.1

func (s *Service) GetFeeState(_ *http.Request, _ *struct{}, reply *GetFeeStateReply) error

GetFeeState returns the current fee state of the chain.

func (*Service) GetHeight added in v0.1.1

func (s *Service) GetHeight(r *http.Request, _ *struct{}, response *api.GetHeightResponse) error

GetHeight returns the height of the last accepted block

func (*Service) GetL1Validator added in v0.1.1

func (s *Service) GetL1Validator(r *http.Request, args *GetL1ValidatorArgs, reply *GetL1ValidatorReply) error

GetL1Validator returns the L1 validator if it exists

func (*Service) GetMinStake added in v0.1.1

func (s *Service) GetMinStake(_ *http.Request, args *GetMinStakeArgs, reply *GetMinStakeReply) error

GetMinStake returns the minimum staking amount in nLUX.

func (*Service) GetNet added in v1.16.56

func (s *Service) GetNet(_ *http.Request, args *GetNetArgs, response *GetNetResponse) error

func (*Service) GetNets added in v1.16.56

func (s *Service) GetNets(_ *http.Request, args *GetNetsArgs, response *GetNetsResponse) error

GetNets returns the nets whose ID are in [args.IDs] The response will include the primary network

func (*Service) GetProposedHeight added in v0.1.1

func (s *Service) GetProposedHeight(r *http.Request, _ *struct{}, reply *api.GetHeightResponse) error

GetProposedHeight returns the current ProposerVM height

func (*Service) GetRewardUTXOs added in v0.1.1

func (s *Service) GetRewardUTXOs(_ *http.Request, args *api.GetTxArgs, reply *GetRewardUTXOsReply) error

GetRewardUTXOs returns the UTXOs that were rewarded after the provided transaction's staking period ended.

func (*Service) GetStake added in v0.1.1

func (s *Service) GetStake(_ *http.Request, args *GetStakeArgs, response *GetStakeReply) error

GetStake returns the amount of nLUX that [args.Addresses] have cumulatively staked on the Primary Network.

This method assumes that each stake output has only owner This method assumes only LUX can be staked This method only concerns itself with the Primary Network, not nets in a data structure rather than re-calculating it by iterating over stakers

func (*Service) GetStakingAssetID added in v0.1.1

func (s *Service) GetStakingAssetID(_ *http.Request, args *GetStakingAssetIDArgs, response *GetStakingAssetIDResponse) error

GetStakingAssetID returns the assetID of the token used to stake on the provided net

func (*Service) GetTimestamp added in v0.1.1

func (s *Service) GetTimestamp(_ *http.Request, _ *struct{}, reply *GetTimestampReply) error

GetTimestamp returns the current timestamp on chain.

func (*Service) GetTotalStake added in v0.1.1

func (s *Service) GetTotalStake(_ *http.Request, args *GetTotalStakeArgs, reply *GetTotalStakeReply) error

GetTotalStake returns the total amount staked on the Primary Network

func (*Service) GetTx added in v0.1.1

func (s *Service) GetTx(_ *http.Request, args *api.GetTxArgs, response *api.GetTxReply) error

func (*Service) GetTxStatus added in v0.1.1

func (s *Service) GetTxStatus(_ *http.Request, args *GetTxStatusArgs, response *GetTxStatusResponse) error

GetTxStatus gets a tx's status

func (*Service) GetUTXOs added in v0.1.1

func (s *Service) GetUTXOs(_ *http.Request, args *api.GetUTXOsArgs, response *api.GetUTXOsReply) error

GetUTXOs returns the UTXOs controlled by the given addresses

func (*Service) GetValidatorFeeConfig added in v0.1.1

func (s *Service) GetValidatorFeeConfig(_ *http.Request, _ *struct{}, reply *fee.Config) error

GetValidatorFeeConfig returns the validator fee config of the chain.

func (*Service) GetValidatorFeeState added in v0.1.1

func (s *Service) GetValidatorFeeState(_ *http.Request, _ *struct{}, reply *GetValidatorFeeStateReply) error

GetValidatorFeeState returns the current validator fee state of the chain.

func (*Service) GetValidatorsAt added in v0.1.1

func (s *Service) GetValidatorsAt(r *http.Request, args *GetValidatorsAtArgs, reply *GetValidatorsAtReply) error

GetValidatorsAt returns the weights of the validator set of a provided net at the specified height.

func (*Service) IssueTx

func (s *Service) IssueTx(_ *http.Request, args *api.FormattedTx, response *api.JSONTxID) error

func (*Service) SampleValidators

func (s *Service) SampleValidators(_ *http.Request, args *SampleValidatorsArgs, reply *SampleValidatorsReply) error

SampleValidators returns a sampling of the list of current validators

func (*Service) ValidatedBy

func (s *Service) ValidatedBy(r *http.Request, args *ValidatedByArgs, response *ValidatedByResponse) error

ValidatedBy returns the ID of the Net that validates [args.BlockchainID]

func (*Service) Validates

func (s *Service) Validates(_ *http.Request, args *ValidatesArgs, response *ValidatesResponse) error

Validates returns the IDs of the blockchains validated by [args.NetID]

type TestAppSender added in v1.16.56

type TestAppSender struct{}

TestAppSender is a test implementation of warp.Sender (p2p.Sender) for platformvm tests

func (*TestAppSender) SendError added in v1.16.56

func (t *TestAppSender) SendError(ctx context.Context, nodeID ids.NodeID, requestID uint32, errorCode int32, errorMessage string) error

SendError sends an error response to a previous request (no-op for tests)

func (*TestAppSender) SendGossip added in v1.16.56

func (t *TestAppSender) SendGossip(ctx context.Context, config p2p.SendConfig, msg []byte) error

SendGossip sends a gossip message (no-op for tests)

func (*TestAppSender) SendRequest added in v1.16.56

func (t *TestAppSender) SendRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, request []byte) error

SendRequest sends a request to the specified nodes (no-op for tests)

func (*TestAppSender) SendResponse added in v1.16.56

func (t *TestAppSender) SendResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error

SendResponse sends a response to a previous request (no-op for tests)

type VM

type VM struct {
	config.Internal
	blockbuilder.Builder
	*network.Network
	validators.State
	// contains filtered or unexported fields
}

func (*VM) Clock

func (vm *VM) Clock() *mockable.Clock

func (*VM) CodecRegistry added in v0.1.1

func (vm *VM) CodecRegistry() codec.Registry

func (*VM) Connected added in v0.1.1

func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion interface{}) error

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error)

CreateHandlers returns a map where: * keys are API endpoint extensions * values are API handlers This now uses lazy initialization to avoid race conditions during VM startup

func (*VM) Disconnected added in v0.1.1

func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error

func (*VM) GetBlock

func (vm *VM) GetBlock(_ context.Context, blkID ids.ID) (consensusmanblock.Block, error)

func (*VM) GetBlockIDAtHeight added in v0.1.1

func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, error)

func (*VM) GetChainID added in v1.16.56

func (vm *VM) GetChainID(context.Context) (ids.ID, error)

GetChainID returns the chain ID of this VM

func (*VM) HealthCheck added in v0.1.1

func (vm *VM) HealthCheck(context.Context) (interface{}, error)

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	chainCtxIntf interface{},
	dbManagerIntf interface{},
	genesisBytes []byte,
	upgradeBytes []byte,
	configBytes []byte,
	toEngineIntf interface{},
	fxsIntf []interface{},
	appSenderIntf interface{},
) error

Initialize this blockchain. [vm.ChainManager] and [vm.vdrMgr] must be set before this function is called.

func (*VM) LastAccepted added in v0.1.1

func (vm *VM) LastAccepted(context.Context) (ids.ID, error)

LastAccepted returns the block most recently accepted

func (*VM) Logger

func (vm *VM) Logger() log.Logger

func (*VM) NewHTTPHandler added in v0.1.1

func (vm *VM) NewHTTPHandler(context.Context) (interface{}, error)

NewHTTPHandler returns a new HTTP handler that can handle API calls This is required by the consensusmanblock.ChainVM interface

func (*VM) ParseBlock

func (vm *VM) ParseBlock(_ context.Context, b []byte) (consensusmanblock.Block, error)

func (*VM) SetPreference

func (vm *VM) SetPreference(_ context.Context, blkID ids.ID) error

SetPreference sets the preferred block to be the one with ID [blkID]

func (*VM) SetState added in v0.1.1

func (vm *VM) SetState(_ context.Context, stateNum uint32) error

func (*VM) Shutdown

func (vm *VM) Shutdown(context.Context) error

Shutdown this blockchain

func (*VM) Version added in v0.1.1

func (*VM) Version(context.Context) (string, error)

func (*VM) WaitForEvent added in v1.1.11

func (vm *VM) WaitForEvent(ctx context.Context) (interface{}, error)

WaitForEvent blocks until either the given context is cancelled, or a message is returned This is required by the linearblock.ChainVM interface

type ValidatedByArgs

type ValidatedByArgs struct {
	// ValidatedBy returns the ID of the Net validating the blockchain with this ID
	BlockchainID ids.ID `json:"blockchainID"`
}

ValidatedByArgs is the arguments for calling ValidatedBy

type ValidatedByResponse

type ValidatedByResponse struct {
	// ID of the Net validating the specified blockchain
	NetID ids.ID `json:"netID"`
}

ValidatedByResponse is the reply from calling ValidatedBy

type ValidatesArgs

type ValidatesArgs struct {
	NetID ids.ID `json:"netID"`
}

ValidatesArgs are the arguments to Validates

type ValidatesResponse

type ValidatesResponse struct {
	BlockchainIDs []ids.ID `json:"blockchainIDs"`
}

ValidatesResponse is the response from calling Validates

type ValidatorNFTContract added in v1.16.56

type ValidatorNFTContract interface {
	OwnerOf(opts *bind.CallOpts, tokenId *big.Int) (common.Address, error)
	BalanceOf(opts *bind.CallOpts, owner common.Address) (*big.Int, error)
	TokenURI(opts *bind.CallOpts, tokenId *big.Int) (string, error)
}

ValidatorNFTContract interface for interacting with NFT contract

type ValidatorTier added in v1.16.56

type ValidatorTier struct {
	Name              string
	MinTokenID        uint64
	MaxTokenID        uint64
	StakingMultiplier uint32
}

ValidatorTier represents a tier of validator NFTs

Directories

Path Synopsis
Package block is a generated GoMock package.
Package block is a generated GoMock package.
executor
Package executor is a generated GoMock package.
Package executor is a generated GoMock package.
executor/executormock
Package executormock is a generated GoMock package.
Package executormock is a generated GoMock package.
fx
Package fx is a generated GoMock package.
Package fx is a generated GoMock package.
fxmock
Package fxmock is a generated GoMock package.
Package fxmock is a generated GoMock package.
signermock
Package signermock is a generated GoMock package.
Package signermock is a generated GoMock package.
Package state is a generated GoMock package.
Package state is a generated GoMock package.
Package testcontext provides a test context for platformvm tests
Package testcontext provides a test context for platformvm tests
txs
Package txs is a generated GoMock package.
Package txs is a generated GoMock package.
builder
Package builder is a generated GoMock package.
Package builder is a generated GoMock package.
fee
TODO: Before Etna, address all TODOs in this package and ensure LP-103 compliance.
TODO: Before Etna, address all TODOs in this package and ensure LP-103 compliance.
mempool
Package mempool is a generated GoMock package.
Package mempool is a generated GoMock package.
mempool/mempoolmock
Package mempoolmock is a generated GoMock package.
Package mempoolmock is a generated GoMock package.
txsmock
Package txsmock is a generated GoMock package.
Package txsmock is a generated GoMock package.
Package utxo is a generated GoMock package.
Package utxo is a generated GoMock package.
utxomock
Package utxomock is a generated GoMock package.
Package utxomock is a generated GoMock package.
fee

Jump to

Keyboard shortcuts

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