Lux SDKGoPackages

validatormanager

Package validatormanager provides L1 validator lifecycle management.

import "github.com/luxfi/sdk/validatormanager"

Package validatormanager provides L1 validator lifecycle management.

Functions

AddPoAValidatorManagerV1_0_0ContractToAllocations

func AddPoAValidatorManagerV1_0_0ContractToAllocations(
	allocs types.GenesisAlloc,
)

AddRewardCalculatorV2_0_0ToAllocations

func AddRewardCalculatorV2_0_0ToAllocations(
	allocs types.GenesisAlloc,
	rewardBasisPoints uint64,
)

AddSpecializationTransparentProxyContractToAllocations

func AddSpecializationTransparentProxyContractToAllocations(
	allocs types.GenesisAlloc,
	proxyManager string,
)

AddValidatorManagerV2_0_0ContractToAllocations

func AddValidatorManagerV2_0_0ContractToAllocations(
	allocs types.GenesisAlloc,
)

AddValidatorMessagesV2_0_0ContractToAllocations

func AddValidatorMessagesV2_0_0ContractToAllocations(
	allocs types.GenesisAlloc,
)

AddValidatorTransparentProxyContractToAllocations

func AddValidatorTransparentProxyContractToAllocations(
	allocs types.GenesisAlloc,
	proxyManager string,
)

CompleteValidatorRegistration

func CompleteValidatorRegistration(
	rpcURL string,
	managerAddress crypto.Address,
	generateRawTxOnly bool,
	ownerAddress crypto.Address,
	privateKey string,
	l1ValidatorRegistrationSignedMessage *warp.Message,
) (*types.Transaction, *types.Receipt, error)

CompleteValidatorRegistration is the last step of flow for adding a new validator.

CompleteValidatorRemoval

func CompleteValidatorRemoval(
	rpcURL string,
	managerAddress crypto.Address,
	generateRawTxOnly bool,
	ownerAddress crypto.Address,
	privateKey string,
	chainValidatorRegistrationSignedMessage *warp.Message,
	useACP99 bool,
) (*types.Transaction, *types.Receipt, error)

CompleteValidatorWeightChange

func CompleteValidatorWeightChange(
	rpcURL string,
	managerAddress crypto.Address,
	generateRawTxOnly bool,
	ownerAddress crypto.Address,
	privateKey string,
	pchainL1ValidatorRegistrationSignedMessage *warp.Message,
) (*types.Transaction, *types.Receipt, error)

DeployAndRegisterPoSValidatorManagerV1_0_0Contract

func DeployAndRegisterPoSValidatorManagerV1_0_0Contract(
	rpcURL string,
	privateKey string,
	proxyOwnerPrivateKey string,
) (luxcrypto.Address, error)

DeployAndRegisterPoSValidatorManagerV2_0_0Contract

func DeployAndRegisterPoSValidatorManagerV2_0_0Contract(
	rpcURL string,
	privateKey string,
	proxyOwnerPrivateKey string,
) (luxcrypto.Address, error)

DeployAndRegisterValidatorManagerV2_0_0Contract

func DeployAndRegisterValidatorManagerV2_0_0Contract(
	rpcURL string,
	privateKey string,
	proxyOwnerPrivateKey string,
) (luxcrypto.Address, error)

DeployPoSValidatorManagerV1_0_0Contract

func DeployPoSValidatorManagerV1_0_0Contract(
	rpcURL string,
	privateKey string,
) (luxcrypto.Address, error)

DeployPoSValidatorManagerV2_0_0Contract

func DeployPoSValidatorManagerV2_0_0Contract(
	rpcURL string,
	privateKey string,
) (luxcrypto.Address, error)

DeployValidatorManagerV2_0_0Contract

func DeployValidatorManagerV2_0_0Contract(
	rpcURL string,
	privateKey string,
) (luxcrypto.Address, error)

FinishValidatorRegistration

func FinishValidatorRegistration(
	ctx context.Context,
	app *application.Lux,
	network models.Network,
	rpcURL string,
	chainSpec contract.ChainSpec,
	generateRawTxOnly bool,
	ownerAddressStr string,
	privateKey string,
	validationID ids.ID,
	aggregatorLogger luxlog.Logger,
	validatorManagerAddressStr string,
	signatureAggregatorEndpoint string,
) (*types.Transaction, error)

FinishValidatorRemoval

func FinishValidatorRemoval(
	ctx context.Context,
	app *application.Lux,
	network models.Network,
	rpcURL string,
	chainSpec contract.ChainSpec,
	generateRawTxOnly bool,
	ownerAddressStr string,
	privateKey string,
	validationID ids.ID,
	aggregatorLogger luxlog.Logger,
	validatorManagerAddressStr string,
	useACP99 bool,
	signatureAggregatorEndpoint string,
) (*types.Transaction, error)

FinishValidatorWeightChange

func FinishValidatorWeightChange(
	ctx context.Context,
	app *application.Lux,
	network models.Network,
	rpcURL string,
	chainSpec contract.ChainSpec,
	generateRawTxOnly bool,
	ownerAddressStr string,
	privateKey string,
	validationID ids.ID,
	aggregatorLogger luxlog.Logger,
	validatorManagerAddressStr string,
	l1ValidatorRegistrationSignedMessage *warp.Message,
	weight uint64,
	signatureAggregatorEndpoint string,
) (*types.Transaction, error)

GetL1ValidatorUptimeSeconds

func GetL1ValidatorUptimeSeconds(rpcURL string, nodeID ids.NodeID) (uint64, error)

GetL1ValidatorUptimeSeconds returns the uptime of the L1 validator

GetL1ValidatorWeightMessage

func GetL1ValidatorWeightMessage(
	network models.Network,
	aggregatorLogger luxlog.Logger,

	unsignedMessage *warp.UnsignedMessage,
	chainID ids.ID,
	blockchainID ids.ID,
	managerAddress crypto.Address,
	validationID ids.ID,
	nonce uint64,
	weight uint64,
	signatureAggregatorEndpoint string,
) (*warp.Message, error)

GetL1ValidatorWeightMessageFromTx

func GetL1ValidatorWeightMessageFromTx(
	rpcURL string,
	validationID ids.ID,
	weight uint64,
	txHash string,
) (*warp.UnsignedMessage, error)

GetPChainChainToL1ConversionUnsignedMessage

func GetPChainChainToL1ConversionUnsignedMessage(
	net models.Network,
	chainID ids.ID,
	managerBlockchainID ids.ID,
	managerAddress crypto.Address,
	convertChainValidators []*txs.ConvertNetworkToL1Validator,
) (*warp.UnsignedMessage, error)

GetPChainL1ValidatorRegistrationMessage

func GetPChainL1ValidatorRegistrationMessage(
	ctx context.Context,
	network models.Network,
	rpcURL string,
	aggregatorLogger luxlog.Logger,
	aggregatorQuorumPercentage uint64,
	chainID ids.ID,
	validationID ids.ID,
	registered bool,
	signatureAggregatorEndpoint string,
) (*warp.Message, error)

GetPChainL1ValidatorWeightMessage

func GetPChainL1ValidatorWeightMessage(
	network models.Network,
	aggregatorLogger luxlog.Logger,
	aggregatorQuorumPercentage uint64,
	chainID ids.ID,

	l1SignedMessage *warp.Message,

	validationID ids.ID,
	nonce uint64,
	weight uint64,
	signatureAggregatorEndpoint string,
) (*warp.Message, error)

GetRegisterL1ValidatorMessage

func GetRegisterL1ValidatorMessage(
	ctx context.Context,
	rpcURL string,
	network models.Network,
	aggregatorLogger luxlog.Logger,
	aggregatorQuorumPercentage uint64,
	chainID ids.ID,
	blockchainID ids.ID,
	managerAddress crypto.Address,
	nodeID ids.NodeID,
	blsPublicKey [48]byte,
	expiry uint64,
	balanceOwners warpMessage.PChainOwner,
	disableOwners warpMessage.PChainOwner,
	weight uint64,
	alreadyInitialized bool,
	initiateTxHash string,
	registerChainValidatorUnsignedMessage *warp.UnsignedMessage,
	signatureAggregatorEndpoint string,
) (*warp.Message, ids.ID, error)

GetRegisterL1ValidatorMessageFromTx

func GetRegisterL1ValidatorMessageFromTx(
	rpcURL string,
	validationID ids.ID,
	txHash string,
) (*warp.UnsignedMessage, error)

GetRegistrationJustification

func GetRegistrationJustification(
	ctx context.Context,
	rpcURL string,
	validationID ids.ID,
	chainID ids.ID,
) ([]byte, error)

GetSpecializedValidatorProxyImplementation

func GetSpecializedValidatorProxyImplementation(
	rpcURL string,
) (crypto.Address, error)

GetUptimeProofMessage

func GetUptimeProofMessage(
	network models.Network,
	aggregatorLogger luxlog.Logger,
	aggregatorQuorumPercentage uint64,
	chainID ids.ID,
	blockchainID ids.ID,
	validationID ids.ID,
	uptime uint64,
	signatureAggregatorEndpoint string,
) (*warp.Message, error)

GetValidatorManagerType

func GetValidatorManagerType(
	rpcURL string,
	managerAddress crypto.Address,
) validatormanagertypes.ValidatorManagementType

GetValidatorManagerType returns validatormanagertypes.ProofOfAuthority if validator manager is verified to be Proof of Authority If validator manager is verified to be Proof of Stake, returns validatormanagertypes.ProofOfStake In other cases, returns validatormanagertypes.UndefinedValidatorManagement

GetValidatorNonce

func GetValidatorNonce(
	ctx context.Context,
	rpcURL string,
	validationID ids.ID,
) (uint64, error)

GetValidatorProxyImplementation

func GetValidatorProxyImplementation(
	rpcURL string,
) (crypto.Address, error)

InitValidatorRegistration

func InitValidatorRegistration(
	ctx context.Context,
	app *application.Lux,
	network models.Network,
	rpcURL string,
	chainSpec contract.ChainSpec,
	generateRawTxOnly bool,
	ownerAddressStr string,
	ownerPrivateKey string,
	nodeID ids.NodeID,
	blsPublicKey []byte,
	expiry uint64,
	balanceOwners warpMessage.PChainOwner,
	disableOwners warpMessage.PChainOwner,
	weight uint64,
	aggregatorLogger luxlog.Logger,
	isPos bool,
	delegationFee uint16,
	stakeDuration time.Duration,
	rewardRecipient crypto.Address,
	validatorManagerAddressStr string,
	useACP99 bool,
	initiateTxHash string,
	signatureAggregatorEndpoint string,
) (*warp.Message, ids.ID, *types.Transaction, error)

InitValidatorRemoval

func InitValidatorRemoval(
	ctx context.Context,
	app *application.Lux,
	network models.Network,
	rpcURL string,
	chainSpec contract.ChainSpec,
	generateRawTxOnly bool,
	ownerAddressStr string,
	ownerPrivateKey string,
	nodeID ids.NodeID,
	aggregatorLogger luxlog.Logger,
	isPoS bool,
	uptimeSec uint64,
	force bool,
	validatorManagerAddressStr string,
	useACP99 bool,
	initiateTxHash string,
	signatureAggregatorEndpoint string,
) (*warp.Message, ids.ID, *types.Transaction, error)

InitValidatorWeightChange

func InitValidatorWeightChange(
	ctx context.Context,
	printFunc func(msg string, args ...interface{}),
	app *application.Lux,
	network models.Network,
	rpcURL string,
	chainSpec contract.ChainSpec,
	generateRawTxOnly bool,
	ownerAddressStr string,
	ownerPrivateKey string,
	nodeID ids.NodeID,
	aggregatorLogger luxlog.Logger,
	validatorManagerAddressStr string,
	weight uint64,
	initiateTxHash string,
	signatureAggregatorEndpoint string,
) (*warp.Message, ids.ID, *types.Transaction, error)

InitializeValidatorRegistrationPoA

func InitializeValidatorRegistrationPoA(
	rpcURL string,
	managerAddress crypto.Address,
	generateRawTxOnly bool,
	managerOwnerAddress crypto.Address,
	managerOwnerPrivateKey string,
	nodeID ids.NodeID,
	blsPublicKey []byte,
	expiry uint64,
	balanceOwners warpMessage.PChainOwner,
	disableOwners warpMessage.PChainOwner,
	weight uint64,
	useACP99 bool,
) (*types.Transaction, *types.Receipt, error)

InitializeValidatorRegistrationPoA is step 1 of flow for adding a new validator.

InitializeValidatorRegistrationPoSNative

func InitializeValidatorRegistrationPoSNative(
	rpcURL string,
	managerAddress crypto.Address,
	managerOwnerPrivateKey string,
	nodeID ids.NodeID,
	blsPublicKey []byte,
	expiry uint64,
	balanceOwners warpMessage.PChainOwner,
	disableOwners warpMessage.PChainOwner,
	delegationFeeBips uint16,
	minStakeDuration time.Duration,
	stakeAmount *big.Int,
	rewardRecipient crypto.Address,
	useACP99 bool,
) (*types.Transaction, *types.Receipt, error)

InitializeValidatorRemoval

func InitializeValidatorRemoval(
	rpcURL string,
	managerAddress crypto.Address,
	generateRawTxOnly bool,
	managerOwnerAddress crypto.Address,
	privateKey string,
	validationID ids.ID,
	isPoS bool,
	uptimeProofSignedMessage *warp.Message,
	force bool,
	useACP99 bool,
) (*types.Transaction, *types.Receipt, error)

InitializeValidatorWeightChange

func InitializeValidatorWeightChange(
	rpcURL string,
	managerAddress crypto.Address,
	generateRawTxOnly bool,
	managerOwnerAddress crypto.Address,
	privateKey string,
	validationID ids.ID,
	weight uint64,
) (*types.Transaction, *types.Receipt, error)

InitializeValidatorsSet

func InitializeValidatorsSet(
	rpcURL string,
	managerAddress crypto.Address,
	privateKey string,
	chainID ids.ID,
	managerBlockchainID ids.ID,
	convertChainValidators []*txs.ConvertNetworkToL1Validator,
	chainConversionSignedMessage *warp.Message,
) (*types.Transaction, *types.Receipt, error)

InitializeValidatorsSet calls poa manager validators set init method, passing to it the p-chain signed [chainConversionSignedMessage] to verify p-chain already processed the associated ConvertNetworkToL1Tx

PoAValidatorManagerInitialize

func PoAValidatorManagerInitialize(
	rpcURL string,
	managerAddress crypto.Address,
	privateKey string,
	chainID ids.ID,
	ownerAddress crypto.Address,
	useACP99 bool,
) (*types.Transaction, *types.Receipt, error)

PoAValidatorManagerInitialize initializes contract [managerAddress] at [rpcURL], to manage validators on [chainID], with owner given by [ownerAddress]

PoSValidatorManagerInitialize

func PoSValidatorManagerInitialize(
	rpcURL string,
	managerAddress crypto.Address,
	specializedManagerAddress crypto.Address,
	managerOwnerPrivateKey string,
	privateKey string,
	chainID [32]byte,
	posParams PoSParams,
	useACP99 bool,
) (*types.Transaction, *types.Receipt, error)

PoSValidatorManagerInitialize initializes contract [managerAddress] at [rpcURL], to manage validators on [chainID] using PoS specific settings.

PoSWeightToValue

func PoSWeightToValue(
	rpcURL string,
	managerAddress crypto.Address,
	weight uint64,
) (*big.Int, error)

SearchForL1ValidatorWeightMessage

func SearchForL1ValidatorWeightMessage(
	ctx context.Context,
	rpcURL string,
	validationID ids.ID,
	weight uint64,
) (*warp.UnsignedMessage, error)

SearchForRegisterL1ValidatorMessage

func SearchForRegisterL1ValidatorMessage(
	ctx context.Context,
	rpcURL string,
	validationID ids.ID,
) (*warp.UnsignedMessage, error)

SetupPoA

func SetupPoA(
	log luxlog.Logger,
	chain blockchainSDK.Net,
	network models.Network,
	privateKey string,
	aggregatorLogger luxlog.Logger,
	validatorManagerAddressStr string,
	v2_0_0 bool,
	signatureAggregatorEndpoint string,
) error

SetupPoA sets up PoA manager after a successful execution of ConvertNetworkToL1Tx on P-Chain. Needs the list of validators for that tx, [convertChainValidators], together with an evm [ownerAddress] to set as the owner of the PoA manager.

SetupPoS

func SetupPoS(
	log luxlog.Logger,
	chain blockchainSDK.Net,
	network models.Network,
	privateKey string,
	aggregatorLogger luxlog.Logger,
	posParams PoSParams,
	managerAddress string,
	specializedManagerAddress string,
	managerOwnerPrivateKey string,
	v2_0_0 bool,
	signatureAggregatorEndpoint string,
) error

SetupPoS sets up PoS manager after a successful execution of ConvertNetworkToL1Tx on P-Chain. Needs the list of validators for that tx, [convertChainValidators], together with an evm [ownerAddress] to set as the owner of the PoS manager.

SetupSpecializationProxyImplementation

func SetupSpecializationProxyImplementation(
	rpcURL string,
	proxyManagerPrivateKey string,
	validatorManager crypto.Address,
) (*types.Transaction, *types.Receipt, error)

SetupValidatorProxyImplementation

func SetupValidatorProxyImplementation(
	rpcURL string,
	proxyManagerPrivateKey string,
	validatorManager crypto.Address,
) (*types.Transaction, *types.Receipt, error)

ValidatorProxyHasImplementationSet

func ValidatorProxyHasImplementationSet(
	rpcURL string,
) (bool, error)

Types

ACP99ValidatorManagerSettings

NativeTokenValidatorManagerSettingsV1_0_0

NativeTokenValidatorManagerSettingsV2_0_0

PoSParams

func (p PoSParams) Verify() error

ValidatorManagerSettings