mirror of
https://github.com/luxfi/proto.git
synced 2026-10-30 15:21:09 +00:00
proto required luxfi/node and luxfi/node required proto, with no replace directive on either side. The cycle was not load-bearing: most of it was proto reaching into the node for packages proto already owns — p/warp, p/txs, p/signer, p/stakeable, p/security, x/txs — which now name themselves. Two were real. The UTXO components moved here, where the chains that use them already live, and the node is the only other caller, so that dependency now runs one way. And p/config held the node's chain manager to queue a chain the P-Chain had accepted a CreateChainTx for; it calls one method, so it declares one method. A P-Chain that imports the node to describe QueueChainCreation is what made two modules require each other. Dropping the requirement dropped a registration with it: lux.ParseUTXO is a registry filled by an init, which the node used to link in on proto's behalf. The packages that call it now say so themselves. Co-authored-by: Hanzo Dev <[email protected]>
115 lines
3.6 KiB
Go
115 lines
3.6 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package config
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/luxfi/constants"
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/math/set"
|
|
|
|
"github.com/luxfi/proto/p/reward"
|
|
"github.com/luxfi/proto/p/txs"
|
|
"github.com/luxfi/proto/p/validators/fee"
|
|
"github.com/luxfi/upgrade"
|
|
validators "github.com/luxfi/validators"
|
|
"github.com/luxfi/validators/uptime"
|
|
"github.com/luxfi/vm/components/gas"
|
|
)
|
|
|
|
// Internal contains all of the parameters for the PlatformVM that are
|
|
// internally set by the node.
|
|
type Internal struct {
|
|
// The node's chain manager
|
|
Chains ChainCreator
|
|
|
|
// Node's validator set maps chainID -> validators of the chain
|
|
//
|
|
// Invariant: The primary network's validator set should have been added to
|
|
// the manager before calling VM.Initialize.
|
|
// Invariant: The primary network's validator set should be empty before
|
|
// calling VM.Initialize.
|
|
Validators validators.Manager
|
|
|
|
// Dynamic fees are active after Quasar Edition
|
|
DynamicFeeConfig gas.Config
|
|
|
|
// LP-77 validator fees are active after Quasar Edition
|
|
ValidatorFeeConfig fee.Config
|
|
|
|
// Provides access to the uptime manager as a thread safe data structure
|
|
UptimeLockedCalculator uptime.LockedCalculator
|
|
|
|
// True if the node is being run with staking enabled
|
|
SybilProtectionEnabled bool
|
|
|
|
// If true, only the P-chain will be instantiated on the primary network.
|
|
PartialSyncPrimaryNetwork bool
|
|
|
|
// Set of chains that this node is validating
|
|
TrackedChains set.Set[ids.ID]
|
|
|
|
// If true, track all chains automatically (useful for dev/test networks)
|
|
TrackAllChains bool
|
|
|
|
// The minimum amount of tokens one must bond to be a validator
|
|
MinValidatorStake uint64
|
|
|
|
// The maximum amount of tokens that can be bonded on a validator
|
|
MaxValidatorStake uint64
|
|
|
|
// Minimum stake, in nLUX, that can be delegated on the primary network
|
|
MinDelegatorStake uint64
|
|
|
|
// Minimum fee that can be charged for delegation
|
|
MinDelegationFee uint32
|
|
|
|
// UptimePercentage is the minimum uptime required to be rewarded for staking
|
|
UptimePercentage float64
|
|
|
|
// Minimum amount of time to allow a staker to stake
|
|
MinStakeDuration time.Duration
|
|
|
|
// Maximum amount of time to allow a staker to stake
|
|
MaxStakeDuration time.Duration
|
|
|
|
// Config for the minting function
|
|
RewardConfig reward.Config
|
|
|
|
// All network upgrade timestamps
|
|
UpgradeConfig upgrade.Config
|
|
|
|
// UseCurrentHeight forces [GetMinimumHeight] to return the current height
|
|
// of the P-Chain instead of the oldest block in the [recentlyAccepted]
|
|
// window.
|
|
//
|
|
// This config is particularly useful for triggering proposervm activation
|
|
// on recently created chains (without this, users need to wait for
|
|
// [recentlyAcceptedWindowTTL] to pass for activation to occur).
|
|
UseCurrentHeight bool
|
|
}
|
|
|
|
// Create the blockchain described in [tx], but only if this node is a member of
|
|
// the chain that validates the blockchain
|
|
func (c *Internal) CreateChain(blockchainID ids.ID, tx *txs.CreateChainTx) {
|
|
if c.SybilProtectionEnabled && // Sybil protection is enabled, so nodes might not validate all blockchains
|
|
constants.PrimaryNetworkID != tx.ValidateNetworkID && // All nodes must validate the primary network
|
|
!c.TrackAllChains && // Not tracking all chains automatically
|
|
!c.TrackedChains.Contains(tx.ValidateNetworkID) { // This node doesn't validate this blockchain
|
|
return
|
|
}
|
|
|
|
chainParams := ChainParameters{
|
|
ID: blockchainID,
|
|
ChainID: tx.ValidateNetworkID,
|
|
GenesisData: tx.GenesisData,
|
|
VMID: tx.VMID,
|
|
FxIDs: tx.FxIDs,
|
|
Name: tx.BlockchainName,
|
|
}
|
|
|
|
c.Chains.QueueChainCreation(chainParams)
|
|
}
|