Documentation
¶
Index ¶
- Constants
- Variables
- func AVAXAssetID(avmGenesisBytes []byte) (ids.ID, error)
- func Aliases(genesisBytes []byte) (map[string][]string, map[ids.ID][]string, error)
- func DepositOfferFromConfig(configDepositOffer DepositOffer) (*deposit.Offer, error)
- func FromConfig(config *Config) ([]byte, ids.ID, error)
- func FromFile(networkID uint32, filepath string, stakingCfg *StakingConfig) ([]byte, ids.ID, error)
- func FromFlag(networkID uint32, genesisContent string, stakingCfg *StakingConfig) ([]byte, ids.ID, error)
- func GenesisChainData(genesisBytes []byte, vmIDs []ids.ID) ([]*pchaintxs.Tx, bool, error)
- func GetCChainAliases() []string
- func GetGenesisBlocksIDs(genesisBytes []byte, genesis *genesis.Genesis) ([]ids.ID, error)
- func GetVMAliases() map[ids.ID][]string
- func GetXChainAliases() []string
- func MultisigAliasFromConfig(configMsigAlias MultisigAlias) (*multisig.Alias, error)
- func SampleBeacons(networkID uint32, count int) ([]string, []string)
- func VMGenesis(genesisBytes []byte, vmID ids.ID) (*pchaintxs.Tx, error)
- func ValidateConfig(config *Config, stakingCfg *StakingConfig) error
- type AddressStates
- type Allocation
- type Camino
- type CaminoAllocation
- type Config
- type DepositOffer
- type LockedAmount
- type MultisigAlias
- type Params
- type PlatformAllocation
- type Staker
- type StakingConfig
- type TxFeeConfig
- type UnparsedAllocation
- type UnparsedCamino
- type UnparsedCaminoAllocation
- type UnparsedConfig
- type UnparsedDepositOffer
- type UnparsedDepositOfferFlags
- type UnparsedMultisigAlias
- type UnparsedPlatformAllocation
- type UnparsedStaker
Constants ¶
const ( VMRQKeyStr = "vmRQiZeXEXYMyJhEiqdC2z5JhuDbxL8ix9UVvjgMu2Er1NepE" VMRQKeyFormattedStr = secp256k1.PrivateKeyPrefix + VMRQKeyStr EWOQKeyStr = "ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN" EWOQKeyFormattedStr = secp256k1.PrivateKeyPrefix + EWOQKeyStr )
Variables ¶
var ( VMRQKey *secp256k1.PrivateKey EWOQKey *secp256k1.PrivateKey // LocalParams are the params used for local networks LocalParams = Params{ TxFeeConfig: TxFeeConfig{ TxFee: units.MilliAvax, CreateAssetTxFee: units.MilliAvax, CreateSubnetTxFee: 100 * units.MilliAvax, TransformSubnetTxFee: 100 * units.MilliAvax, CreateBlockchainTxFee: 100 * units.MilliAvax, AddPrimaryNetworkValidatorFee: 0, AddPrimaryNetworkDelegatorFee: 0, AddSubnetValidatorFee: units.MilliAvax, AddSubnetDelegatorFee: units.MilliAvax, }, StakingConfig: StakingConfig{ UptimeRequirement: .8, MinValidatorStake: 2 * units.KiloAvax, MaxValidatorStake: 3 * units.MegaAvax, MinDelegatorStake: 25 * units.Avax, MinDelegationFee: 20000, MinStakeDuration: 24 * time.Hour, MaxStakeDuration: 365 * 24 * time.Hour, RewardConfig: reward.Config{ MaxConsumptionRate: .12 * reward.PercentDenominator, MinConsumptionRate: .10 * reward.PercentDenominator, MintingPeriod: 365 * 24 * time.Hour, SupplyCap: 720 * units.MegaAvax, }, CaminoConfig: caminoconfig.Config{ DACProposalBondAmount: 100 * units.Avax, FeeDistribution: [dac.FeeDistributionFractionsCount]uint64{30, 30, 40}, }, }, } )
var ( // CaminoParams are the params used for camino main network CaminoParams = Params{ TxFeeConfig: TxFeeConfig{ TxFee: units.MilliAvax, CreateAssetTxFee: units.MilliAvax, CreateSubnetTxFee: 100 * units.MilliAvax, CreateBlockchainTxFee: 100 * units.MilliAvax, }, StakingConfig: StakingConfig{ UptimeRequirement: .8, MinValidatorStake: 100 * units.KiloAvax, MaxValidatorStake: 100 * units.KiloAvax, MinDelegatorStake: 0, MinDelegationFee: 0, MinStakeDuration: 182 * 24 * time.Hour, MaxStakeDuration: 5 * 365 * 24 * time.Hour, RewardConfig: reward.Config{ MaxConsumptionRate: 0, MinConsumptionRate: 0, MintingPeriod: 5 * 365 * 24 * time.Hour, SupplyCap: 1000 * units.MegaAvax, }, CaminoConfig: caminoconfig.Config{ DACProposalBondAmount: 1 * units.KiloAvax, FeeDistribution: [dac.FeeDistributionFractionsCount]uint64{30, 30, 40}, }, }, } )
var ( // ColumbusParams are the params used for columbus network ColumbusParams = Params{ TxFeeConfig: TxFeeConfig{ TxFee: units.MilliAvax, CreateAssetTxFee: units.MilliAvax, CreateSubnetTxFee: 100 * units.MilliAvax, CreateBlockchainTxFee: 100 * units.MilliAvax, }, StakingConfig: StakingConfig{ UptimeRequirement: .8, MinValidatorStake: 100 * units.KiloAvax, MaxValidatorStake: 100 * units.KiloAvax, MinDelegatorStake: 0, MinDelegationFee: 0, MinStakeDuration: 24 * time.Hour, MaxStakeDuration: 365 * 24 * time.Hour, RewardConfig: reward.Config{ MaxConsumptionRate: 0, MinConsumptionRate: 0, MintingPeriod: 365 * 24 * time.Hour, SupplyCap: 1000 * units.MegaAvax, }, CaminoConfig: caminoconfig.Config{ DACProposalBondAmount: 100 * units.Avax, FeeDistribution: [dac.FeeDistributionFractionsCount]uint64{30, 30, 40}, }, }, } )
var ( // KoperikusParams are the params used for kopernikus dev network KopernikusParams = Params{ TxFeeConfig: TxFeeConfig{ TxFee: units.MilliAvax, CreateAssetTxFee: units.MilliAvax, CreateSubnetTxFee: 100 * units.MilliAvax, CreateBlockchainTxFee: 100 * units.MilliAvax, }, StakingConfig: StakingConfig{ UptimeRequirement: .8, MinValidatorStake: 2 * units.KiloAvax, MaxValidatorStake: 2 * units.KiloAvax, MinDelegatorStake: 0 * units.Avax, MinDelegationFee: 0, MinStakeDuration: 5 * time.Minute, MaxStakeDuration: 5 * 365 * 24 * time.Hour, RewardConfig: reward.Config{ MaxConsumptionRate: 0, MinConsumptionRate: 0, MintingPeriod: 365 * 24 * time.Hour, SupplyCap: 1000 * units.MegaAvax, }, CaminoConfig: caminoconfig.Config{ DACProposalBondAmount: 100 * units.Avax, FeeDistribution: [dac.FeeDistributionFractionsCount]uint64{30, 30, 40}, }, }, } )
Functions ¶
func DepositOfferFromConfig ¶
func DepositOfferFromConfig(configDepositOffer DepositOffer) (*deposit.Offer, error)
func FromConfig ¶
FromConfig returns:
- The byte representation of the genesis state of the platform chain (ie the genesis state of the network)
- The asset ID of AVAX
func FromFile ¶
FromFile returns the genesis data of the Platform Chain.
Since an Avalanche network has exactly one Platform Chain, and the Platform Chain defines the genesis state of the network (who is staking, which chains exist, etc.), defining the genesis state of the Platform Chain is the same as defining the genesis state of the network.
FromFile accepts: 1) The ID of the new network. [networkID] 2) The location of a custom genesis config to load. filepath
If filepath is empty or the given network ID is Camino, Testnet, or Local, returns error. If filepath is non-empty and networkID isn't Mainnet, Testnet, or Local, loads the network genesis data from the config at filepath.
FromFile returns:
- The byte representation of the genesis state of the platform chain (ie the genesis state of the network)
- The asset ID of AVAX
func FromFlag ¶
func FromFlag(networkID uint32, genesisContent string, stakingCfg *StakingConfig) ([]byte, ids.ID, error)
FromFlag returns the genesis data of the Platform Chain.
Since an Avalanche network has exactly one Platform Chain, and the Platform Chain defines the genesis state of the network (who is staking, which chains exist, etc.), defining the genesis state of the Platform Chain is the same as defining the genesis state of the network.
FromFlag accepts: 1) The ID of the new network. [networkID] 2) The content of a custom genesis config to load. [genesisContent]
If [genesisContent] is empty or the given network ID is Mainnet, Testnet, or Local, returns error. If [genesisContent] is non-empty and networkID isn't Mainnet, Testnet, or Local, loads the network genesis data from [genesisContent].
FromFlag returns:
- The byte representation of the genesis state of the platform chain (ie the genesis state of the network)
- The asset ID of AVAX
func GenesisChainData ¶
func GetCChainAliases ¶
func GetCChainAliases() []string
func GetGenesisBlocksIDs ¶
func GetVMAliases ¶
func GetXChainAliases ¶
func GetXChainAliases() []string
func MultisigAliasFromConfig ¶
func MultisigAliasFromConfig(configMsigAlias MultisigAlias) (*multisig.Alias, error)
func SampleBeacons ¶
SampleBeacons returns the some beacons this node should connect to
func ValidateConfig ¶
func ValidateConfig(config *Config, stakingCfg *StakingConfig) error
ValidateConfig validates the generated config. Exposed for caminogo/tools/genesis generator It's not used in caminogo itself. Please don't delete.
Types ¶
type AddressStates ¶
type Allocation ¶
type Allocation struct {
ETHAddr ids.ShortID `json:"ethAddr"`
AVAXAddr ids.ShortID `json:"avaxAddr"`
InitialAmount uint64 `json:"initialAmount"`
UnlockSchedule []LockedAmount `json:"unlockSchedule"`
}
func (Allocation) Less ¶
func (a Allocation) Less(other Allocation) bool
func (Allocation) Unparse ¶
func (a Allocation) Unparse(networkID uint32) (UnparsedAllocation, error)
type Camino ¶
type Camino struct {
VerifyNodeSignature bool `json:"verifyNodeSignature"`
LockModeBondDeposit bool `json:"lockModeBondDeposit"`
InitialAdmin ids.ShortID `json:"initialAdmin"`
DepositOffers []DepositOffer `json:"depositOffers"`
Allocations []CaminoAllocation `json:"allocations"`
InitialMultisigAddresses []MultisigAlias `json:"initialMultisigAddresses"`
}
func (Camino) InitialSupply ¶
type CaminoAllocation ¶
type CaminoAllocation struct {
ETHAddr ids.ShortID `json:"ethAddr"`
AVAXAddr ids.ShortID `json:"avaxAddr"`
XAmount uint64 `json:"xAmount"`
AddressStates AddressStates `json:"addressStates"`
PlatformAllocations []PlatformAllocation `json:"platformAllocations"`
}
func (CaminoAllocation) Less ¶
func (a CaminoAllocation) Less(other CaminoAllocation) bool
func (CaminoAllocation) Unparse ¶
func (a CaminoAllocation) Unparse(networkID uint32) (UnparsedCaminoAllocation, error)
type Config ¶
type Config struct {
NetworkID uint32 `json:"networkID"`
Allocations []Allocation `json:"allocations"`
StartTime uint64 `json:"startTime"`
InitialStakeDuration uint64 `json:"initialStakeDuration"`
InitialStakeDurationOffset uint64 `json:"initialStakeDurationOffset"`
InitialStakedFunds []ids.ShortID `json:"initialStakedFunds"`
InitialStakers []Staker `json:"initialStakers"`
Camino *Camino `json:"camino"`
CChainGenesis string `json:"cChainGenesis"`
Message string `json:"message"`
}
Config contains the genesis addresses used to construct a genesis
var ( // CaminoConfig is the config that should be used to generate the camino // mainnet genesis. CaminoConfig Config // ColumbusConfig is the config that should be used to generate the columbus // genesis. ColumbusConfig Config // KopernikusConfig is the config that should be used to generate the kopernikus // genesis. KopernikusConfig Config // LocalConfig is the config that should be used to generate a local // genesis. LocalConfig Config )
func GetConfigContent ¶
GetConfigContent loads a *Config from a provided environment variable
func GetConfigFile ¶
GetConfigFile loads a *Config from a provided filepath.
func (*Config) InitialSupply ¶
func (Config) Unparse ¶
func (c Config) Unparse() (UnparsedConfig, error)
type DepositOffer ¶
type DepositOffer struct {
InterestRateNominator uint64 `json:"interestRateNominator"`
Start uint64 `json:"start"`
End uint64 `json:"end"`
MinAmount uint64 `json:"minAmount"`
MinDuration uint32 `json:"minDuration"`
MaxDuration uint32 `json:"maxDuration"`
UnlockPeriodDuration uint32 `json:"unlockPeriodDuration"`
NoRewardsPeriodDuration uint32 `json:"noRewardsPeriodDuration"`
Memo string `json:"memo"`
Flags deposit.OfferFlag `json:"flags"`
}
func (DepositOffer) Unparse ¶
func (parsedOffer DepositOffer) Unparse(startime uint64) (UnparsedDepositOffer, error)
type LockedAmount ¶
type MultisigAlias ¶
type MultisigAlias struct {
Alias ids.ShortID `serialize:"true" json:"alias"`
Threshold uint32 `serialize:"true" json:"threshold"`
Addresses []ids.ShortID `serialize:"true" json:"addresses"`
Memo string `serialize:"true" json:"memo"`
}
func (MultisigAlias) ComputeAlias ¶
func (ma MultisigAlias) ComputeAlias(txID ids.ID) ids.ShortID
func (MultisigAlias) Unparse ¶
func (ma MultisigAlias) Unparse(networkID uint32) (UnparsedMultisigAlias, error)
type Params ¶
type Params struct {
StakingConfig
TxFeeConfig
}
type PlatformAllocation ¶
type PlatformAllocation struct {
Amount uint64 `json:"amount"`
NodeID ids.NodeID `json:"nodeID"`
ValidatorDuration uint64 `json:"validatorDuration"`
DepositDuration uint64 `json:"depositDuration"`
TimestampOffset uint64 `json:"timestampOffset"`
DepositOfferMemo string `json:"depositOfferMemo"`
Memo string `json:"memo"`
}
func (PlatformAllocation) Unparse ¶
func (a PlatformAllocation) Unparse() (UnparsedPlatformAllocation, error)
type Staker ¶
type StakingConfig ¶
type StakingConfig struct {
// Staking uptime requirements
UptimeRequirement float64 `json:"uptimeRequirement"`
// Minimum stake, in nAVAX, required to validate the primary network
MinValidatorStake uint64 `json:"minValidatorStake"`
// Maximum stake, in nAVAX, allowed to be placed on a single validator in
// the primary network
MaxValidatorStake uint64 `json:"maxValidatorStake"`
// Minimum stake, in nAVAX, that can be delegated on the primary network
MinDelegatorStake uint64 `json:"minDelegatorStake"`
// Minimum delegation fee, in the range [0, 1000000], that can be charged
// for delegation on the primary network.
MinDelegationFee uint32 `json:"minDelegationFee"`
// MinStakeDuration is the minimum amount of time a validator can validate
// for in a single period.
MinStakeDuration time.Duration `json:"minStakeDuration"`
// MaxStakeDuration is the maximum amount of time a validator can validate
// for in a single period.
MaxStakeDuration time.Duration `json:"maxStakeDuration"`
// RewardConfig is the config for the reward function.
RewardConfig reward.Config `json:"rewardConfig"`
// CaminoConfig is the config for camino related features.
CaminoConfig caminoconfig.Config `json:"caminoConfig"`
}
func GetStakingConfig ¶
func GetStakingConfig(networkID uint32) StakingConfig
type TxFeeConfig ¶
type TxFeeConfig struct {
// Transaction fee
TxFee uint64 `json:"txFee"`
// Transaction fee for create asset transactions
CreateAssetTxFee uint64 `json:"createAssetTxFee"`
// Transaction fee for create subnet transactions
CreateSubnetTxFee uint64 `json:"createSubnetTxFee"`
// Transaction fee for transform subnet transactions
TransformSubnetTxFee uint64 `json:"transformSubnetTxFee"`
// Transaction fee for create blockchain transactions
CreateBlockchainTxFee uint64 `json:"createBlockchainTxFee"`
// Transaction fee for adding a primary network validator
AddPrimaryNetworkValidatorFee uint64 `json:"addPrimaryNetworkValidatorFee"`
// Transaction fee for adding a primary network delegator
AddPrimaryNetworkDelegatorFee uint64 `json:"addPrimaryNetworkDelegatorFee"`
// Transaction fee for adding a subnet validator
AddSubnetValidatorFee uint64 `json:"addSubnetValidatorFee"`
// Transaction fee for adding a subnet delegator
AddSubnetDelegatorFee uint64 `json:"addSubnetDelegatorFee"`
}
func GetTxFeeConfig ¶
func GetTxFeeConfig(networkID uint32) TxFeeConfig
type UnparsedAllocation ¶
type UnparsedAllocation struct {
ETHAddr string `json:"ethAddr"`
AVAXAddr string `json:"avaxAddr"`
InitialAmount uint64 `json:"initialAmount"`
UnlockSchedule []LockedAmount `json:"unlockSchedule"`
}
func (UnparsedAllocation) Parse ¶
func (ua UnparsedAllocation) Parse() (Allocation, error)
type UnparsedCamino ¶
type UnparsedCamino struct {
VerifyNodeSignature bool `json:"verifyNodeSignature"`
LockModeBondDeposit bool `json:"lockModeBondDeposit"`
InitialAdmin string `json:"initialAdmin"`
DepositOffers []UnparsedDepositOffer `json:"depositOffers"`
Allocations []UnparsedCaminoAllocation `json:"allocations"`
InitialMultisigAddresses []UnparsedMultisigAlias `json:"initialMultisigAddresses"`
}
type UnparsedCaminoAllocation ¶
type UnparsedCaminoAllocation struct {
ETHAddr string `json:"ethAddr"`
AVAXAddr string `json:"avaxAddr"`
XAmount uint64 `json:"xAmount"`
AddressStates AddressStates `json:"addressStates"`
PlatformAllocations []UnparsedPlatformAllocation `json:"platformAllocations"`
}
func (UnparsedCaminoAllocation) Parse ¶
func (ua UnparsedCaminoAllocation) Parse() (CaminoAllocation, error)
type UnparsedConfig ¶
type UnparsedConfig struct {
NetworkID uint32 `json:"networkID"`
Allocations []UnparsedAllocation `json:"allocations"`
StartTime uint64 `json:"startTime"`
InitialStakeDuration uint64 `json:"initialStakeDuration"`
InitialStakeDurationOffset uint64 `json:"initialStakeDurationOffset"`
InitialStakedFunds []string `json:"initialStakedFunds"`
InitialStakers []UnparsedStaker `json:"initialStakers"`
Camino *UnparsedCamino `json:"camino"`
CChainGenesis string `json:"cChainGenesis"`
Message string `json:"message"`
}
UnparsedConfig contains the genesis addresses used to construct a genesis
func (UnparsedConfig) Parse ¶
func (uc UnparsedConfig) Parse() (Config, error)
type UnparsedDepositOffer ¶
type UnparsedDepositOffer struct {
InterestRateNominator uint64 `json:"interestRateNominator"`
StartOffset uint64 `json:"startOffset"`
EndOffset uint64 `json:"endOffset"`
MinAmount uint64 `json:"minAmount"`
MinDuration uint32 `json:"minDuration"`
MaxDuration uint32 `json:"maxDuration"`
UnlockPeriodDuration uint32 `json:"unlockPeriodDuration"`
NoRewardsPeriodDuration uint32 `json:"noRewardsPeriodDuration"`
Memo string `json:"memo"`
Flags UnparsedDepositOfferFlags `json:"flags"`
}
func (UnparsedDepositOffer) Parse ¶
func (udo UnparsedDepositOffer) Parse(startTime uint64) (DepositOffer, error)
type UnparsedDepositOfferFlags ¶
type UnparsedDepositOfferFlags struct {
Locked bool `json:"locked"`
}
type UnparsedMultisigAlias ¶
type UnparsedMultisigAlias struct {
Alias string `json:"alias"`
Addresses []string `json:"addresses"`
Threshold uint32 `json:"threshold"`
Memo string `json:"memo,omitempty"`
}
UnparsedMultisigAlias defines a multisignature alias address. [Alias] is the alias of the multisignature address. It's encoded to string the same way as ShortID String() method does. [Addresses] are the addresses that are allowed to sign transactions from the multisignature address. All addresses are encoded to string the same way as ShortID String() method does. [Threshold] is the number of signatures required to sign transactions from the multisignature address.
func (UnparsedMultisigAlias) Parse ¶
func (uma UnparsedMultisigAlias) Parse() (MultisigAlias, error)
type UnparsedPlatformAllocation ¶
type UnparsedPlatformAllocation struct {
Amount uint64 `json:"amount"`
NodeID string `json:"nodeID,omitempty"`
ValidatorDuration uint64 `json:"validatorDuration,omitempty"`
DepositDuration uint64 `json:"depositDuration,omitempty"`
TimestampOffset uint64 `json:"timestampOffset,omitempty"`
DepositOfferMemo string `json:"depositOfferMemo,omitempty"`
Memo string `json:"memo,omitempty"`
}
func (UnparsedPlatformAllocation) Parse ¶
func (ua UnparsedPlatformAllocation) Parse() (PlatformAllocation, error)