Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v1.36.186 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = Config{
	Network:                       DefaultNetwork,
	BlockCacheSize:                64 * constants.MiB,
	TxCacheSize:                   128 * constants.MiB,
	TransformedNetTxCacheSize:     4 * constants.MiB,
	RewardUTXOsCacheSize:          2048,
	ChainCacheSize:                2048,
	ChainDBCacheSize:              2048,
	BlockIDCacheSize:              8192,
	FxOwnerCacheSize:              4 * constants.MiB,
	NetToL1ConversionCacheSize:    4 * constants.MiB,
	L1WeightsCacheSize:            16 * constants.KiB,
	L1InactiveValidatorsCacheSize: 256 * constants.KiB,
	L1ChainIDNodeIDCacheSize:      16 * constants.KiB,
	ChecksumsEnabled:              false,
	MempoolPruneFrequency:         30 * time.Minute,
	TxFee:                         constants.MilliLux,
	CreateAssetTxFee:              constants.MilliLux,
	CreateNetworkTxFee:            constants.Lux,
	CreateChainTxFee:              constants.Lux,
	AddNetworkValidatorFee:        0,
	AddNetworkDelegatorFee:        0,
}
View Source
var DefaultExecutionConfig = ExecutionConfig{
	Network:                   DefaultNetworkConfig,
	BlockCacheSize:            64 * constants.MiB,
	TxCacheSize:               128 * constants.MiB,
	TransformedNetTxCacheSize: 4 * constants.MiB,
	RewardUTXOsCacheSize:      2048,
	ChainCacheSize:            2048,
	ChainDBCacheSize:          2048,
	BlockIDCacheSize:          8192,
	FxOwnerCacheSize:          4 * constants.MiB,
	ChecksumsEnabled:          false,
	MempoolPruneFrequency:     30 * time.Minute,
}
View Source
var DefaultNetwork = Network{
	MaxValidatorSetStaleness:                    time.Minute,
	TargetGossipSize:                            20 * constants.KiB,
	PushGossipPercentStake:                      .9,
	PushGossipNumValidators:                     100,
	PushGossipNumPeers:                          0,
	PushRegossipNumValidators:                   10,
	PushRegossipNumPeers:                        0,
	PushGossipDiscardedCacheSize:                16384,
	PushGossipMaxRegossipFrequency:              30 * time.Second,
	PushGossipFrequency:                         500 * time.Millisecond,
	PullGossipPollSize:                          1,
	PullGossipFrequency:                         1500 * time.Millisecond,
	PullGossipThrottlingPeriod:                  10 * time.Second,
	PullGossipThrottlingLimit:                   2,
	ExpectedBloomFilterElements:                 8 * 1024,
	ExpectedBloomFilterFalsePositiveProbability: .01,
	MaxBloomFilterFalsePositiveProbability:      .05,
}
View Source
var DefaultNetworkConfig = NetworkConfig{
	MaxValidatorSetStaleness:                    time.Minute,
	TargetGossipSize:                            20 * constants.KiB,
	PushGossipPercentStake:                      .9,
	PushGossipNumValidators:                     100,
	PushGossipNumPeers:                          0,
	PushRegossipNumValidators:                   10,
	PushRegossipNumPeers:                        0,
	PushGossipDiscardedCacheSize:                16384,
	PushGossipMaxRegossipFrequency:              30 * time.Second,
	PushGossipFrequency:                         500 * time.Millisecond,
	PullGossipPollSize:                          1,
	PullGossipFrequency:                         1500 * time.Millisecond,
	PullGossipThrottlingPeriod:                  10 * time.Second,
	PullGossipThrottlingLimit:                   2,
	ExpectedBloomFilterElements:                 8 * 1024,
	ExpectedBloomFilterFalsePositiveProbability: .01,
	MaxBloomFilterFalsePositiveProbability:      .05,
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Network                       Network         `json:"network"`
	BlockCacheSize                int             `json:"block-cache-size"`
	TxCacheSize                   int             `json:"tx-cache-size"`
	TransformedNetTxCacheSize     int             `json:"transformed-chain-tx-cache-size"`
	RewardUTXOsCacheSize          int             `json:"reward-utxos-cache-size"`
	ChainCacheSize                int             `json:"chain-cache-size"`
	ChainDBCacheSize              int             `json:"chain-db-cache-size"`
	BlockIDCacheSize              int             `json:"block-id-cache-size"`
	FxOwnerCacheSize              int             `json:"fx-owner-cache-size"`
	NetToL1ConversionCacheSize    int             `json:"chain-to-l1-conversion-cache-size"`
	L1WeightsCacheSize            int             `json:"l1-weights-cache-size"`
	L1InactiveValidatorsCacheSize int             `json:"l1-inactive-validators-cache-size"`
	L1ChainIDNodeIDCacheSize      int             `json:"l1-chain-id-node-id-cache-size"`
	ChecksumsEnabled              bool            `json:"checksums-enabled"`
	MempoolPruneFrequency         time.Duration   `json:"mempool-prune-frequency"`
	SybilProtectionEnabled        bool            `json:"sybil-protection-enabled"`
	TrackedChains                 set.Set[ids.ID] `json:"tracked-chains"`
	Chains                        chains.Manager  `json:"-"`

	// Transaction fees
	TxFee                  uint64 `json:"tx-fee"`
	CreateAssetTxFee       uint64 `json:"create-asset-tx-fee"`
	CreateNetworkTxFee     uint64 `json:"create-network-tx-fee"`
	CreateChainTxFee       uint64 `json:"create-chain-tx-fee"`
	AddNetworkValidatorFee uint64 `json:"add-network-validator-fee"`
	AddNetworkDelegatorFee uint64 `json:"add-network-delegator-fee"`
}

Config contains all of the user-configurable parameters of the PlatformVM.

func GetConfig

func GetConfig(b []byte) (*Config, error)

GetConfig returns a Config from the provided json encoded bytes. If a configuration is not provided in the bytes, the default value is set. If empty bytes are provided, the default config is returned.

type ExecutionConfig added in v1.1.11

type ExecutionConfig struct {
	Network                   NetworkConfig `json:"network"`
	BlockCacheSize            int           `json:"block-cache-size"`
	TxCacheSize               int           `json:"tx-cache-size"`
	TransformedNetTxCacheSize int           `json:"transformed-chain-tx-cache-size"`
	RewardUTXOsCacheSize      int           `json:"reward-utxos-cache-size"`
	ChainCacheSize            int           `json:"chain-cache-size"`
	ChainDBCacheSize          int           `json:"chain-db-cache-size"`
	BlockIDCacheSize          int           `json:"block-id-cache-size"`
	FxOwnerCacheSize          int           `json:"fx-owner-cache-size"`
	ChecksumsEnabled          bool          `json:"checksums-enabled"`
	MempoolPruneFrequency     time.Duration `json:"mempool-prune-frequency"`
}

ExecutionConfig provides execution parameters of PlatformVM

func GetExecutionConfig added in v1.1.11

func GetExecutionConfig(b []byte) (*ExecutionConfig, error)

GetExecutionConfig returns an ExecutionConfig input is unmarshalled into an ExecutionConfig previously initialized with default values

type Internal

type Internal struct {
	// The node's chain manager
	Chains chains.Manager

	// Node's validator set maps netID -> validators of the net
	//
	// 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

	DynamicFeeConfig gas.Config

	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

	// 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 µLUX, 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

	// SecurityProfile pins the chain-wide credential-admission policy
	// resolved at node bootstrap from the genesis SecurityProfile block
	// (F102). The platformvm threads this into its mempool builder via
	// SetAuthPolicy so strict-PQ chains refuse classical secp256k1
	// credentials at gossip time. Nil for legacy (classical-compat)
	// networks that pre-date the locked-profile pin.
	SecurityProfile *consensusconfig.ChainSecurityProfile

	// ClassicalCompatRegistry names the allow-list of legacy operators
	// that may still post classical secp256k1 credentials under a
	// classical-compat fork profile. Nil for strict-PQ (the empty
	// registry refuses everything classical) and for legacy networks
	// (the mempool gate is bypassed entirely).
	ClassicalCompatRegistry auth.ClassicalCompatRegistry

	// StakingParams is the governed primary-network staking policy, as an
	// append-only history of activations. Empty means ungoverned: the
	// compiled-in fields above are used verbatim, which is exactly today's
	// behaviour — so a node that carries no history behaves identically to one
	// built before this field existed.
	//
	// Every primary-network staking rule is read through StakingPolicyAt, so
	// replacing the source of this history — config today, P-Chain state once
	// the proposal tx lands — changes nothing else.
	StakingParams stakingparams.History
}

Internal contains all of the parameters for the PlatformVM that are internally set by the node.

func (*Internal) CreateChain

func (c *Internal) CreateChain(blockchainID ids.ID, tx *txs.CreateChainTx)

Create the blockchain described in [tx].

A validator of the primary network validates every chain the primary network runs. Which chains those are is decided by genesis, and a chain whose VM this node does not ship is declined by the chain manager, so neither needs a second switch here. Tracking governs the nets beyond the primary network: with sybil protection on, a chain on one of those is created only if this node asked to track it.

func (*Internal) StakingPolicyAt added in v1.36.59

func (c *Internal) StakingPolicyAt(t int64) stakingparams.Params

StakingPolicyAt returns the primary-network staking policy that binds a party which committed at unix time t.

The time argument is the whole non-retroactivity guarantee, and callers must pass the moment the party bound itself, not the moment of the check:

  • Admission (getValidatorRules, getDelegatorRules) passes the current chain time, because a joiner is choosing to accept the rules in force now.
  • The reward gate (block/executor prefersCommit) passes the staker's StartTime, because a validator that bonded under an 80% uptime rule must be judged at 80% however stake votes afterwards.

Getting that second call wrong would make the uptime requirement retroactive and hand a stake majority the power to raise the bar the day before a rival's stake matures and take its reward.

type Network

type Network struct {
	// MaxValidatorSetStaleness limits how old of a validator set the network
	// will use for peer sampling and rate limiting.
	MaxValidatorSetStaleness time.Duration `json:"max-validator-set-staleness"`
	// TargetGossipSize is the number of bytes that will be attempted to be
	// sent when pushing transactions and when responded to transaction pull
	// requests.
	TargetGossipSize int `json:"target-gossip-size"`
	// PushGossipPercentStake is the percentage of total stake to push
	// transactions to in the first round of gossip. Nodes with higher stake are
	// preferred over nodes with less stake to minimize the number of messages
	// sent over the p2p network.
	PushGossipPercentStake float64 `json:"push-gossip-percent-stake"`
	// PushGossipNumValidators is the number of validators to push transactions
	// to in the first round of gossip.
	PushGossipNumValidators int `json:"push-gossip-num-validators"`
	// PushGossipNumPeers is the number of peers to push transactions to in the
	// first round of gossip.
	PushGossipNumPeers int `json:"push-gossip-num-peers"`
	// PushRegossipNumValidators is the number of validators to push
	// transactions to after the first round of gossip.
	PushRegossipNumValidators int `json:"push-regossip-num-validators"`
	// PushRegossipNumPeers is the number of peers to push transactions to after
	// the first round of gossip.
	PushRegossipNumPeers int `json:"push-regossip-num-peers"`
	// PushGossipDiscardedCacheSize is the number of txIDs to cache to avoid
	// pushing transactions that were recently dropped from the mempool.
	PushGossipDiscardedCacheSize int `json:"push-gossip-discarded-cache-size"`
	// PushGossipMaxRegossipFrequency is the limit for how frequently a
	// transaction will be push gossiped.
	PushGossipMaxRegossipFrequency time.Duration `json:"push-gossip-max-regossip-frequency"`
	// PushGossipFrequency is how frequently rounds of push gossip are
	// performed.
	PushGossipFrequency time.Duration `json:"push-gossip-frequency"`
	// PullGossipPollSize is the number of validators to sample when performing
	// a round of pull gossip.
	PullGossipPollSize int `json:"pull-gossip-poll-size"`
	// PullGossipFrequency is how frequently rounds of pull gossip are
	// performed.
	PullGossipFrequency time.Duration `json:"pull-gossip-frequency"`
	// PullGossipThrottlingPeriod is how large of a window the throttler should
	// use.
	PullGossipThrottlingPeriod time.Duration `json:"pull-gossip-throttling-period"`
	// PullGossipThrottlingLimit is the number of pull querys that are allowed
	// by a validator in every throttling window.
	PullGossipThrottlingLimit int `json:"pull-gossip-throttling-limit"`
	// ExpectedBloomFilterElements is the number of elements to expect when
	// creating a new bloom filter. The larger this number is, the larger the
	// bloom filter will be.
	ExpectedBloomFilterElements int `json:"expected-bloom-filter-elements"`
	// ExpectedBloomFilterFalsePositiveProbability is the expected probability
	// of a false positive after having inserted ExpectedBloomFilterElements
	// into a bloom filter. The smaller this number is, the larger the bloom
	// filter will be.
	ExpectedBloomFilterFalsePositiveProbability float64 `json:"expected-bloom-filter-false-positive-probability"`
	// MaxBloomFilterFalsePositiveProbability is used to determine when the
	// bloom filter should be refreshed. Once the expected probability of a
	// false positive exceeds this value, the bloom filter will be regenerated.
	// The smaller this number is, the more frequently that the bloom filter
	// will be regenerated.
	MaxBloomFilterFalsePositiveProbability float64 `json:"max-bloom-filter-false-positive-probability"`
}

type NetworkConfig added in v1.11.14

type NetworkConfig struct {
	// MaxValidatorSetStaleness limits how old of a validator set the network
	// will use for peer sampling and rate limiting.
	MaxValidatorSetStaleness time.Duration `json:"max-validator-set-staleness"`
	// TargetGossipSize is the number of bytes that will be attempted to be
	// sent when pushing transactions and when responded to transaction pull
	// requests.
	TargetGossipSize int `json:"target-gossip-size"`
	// PushGossipPercentStake is the percentage of total stake to push
	// transactions to in the first round of gossip. Nodes with higher stake are
	// preferred over nodes with less stake to minimize the number of messages
	// sent over the p2p network.
	PushGossipPercentStake float64 `json:"push-gossip-percent-stake"`
	// PushGossipNumValidators is the number of validators to push transactions
	// to in the first round of gossip.
	PushGossipNumValidators int `json:"push-gossip-num-validators"`
	// PushGossipNumPeers is the number of peers to push transactions to in the
	// first round of gossip.
	PushGossipNumPeers int `json:"push-gossip-num-peers"`
	// PushRegossipNumValidators is the number of validators to push
	// transactions to after the first round of gossip.
	PushRegossipNumValidators int `json:"push-regossip-num-validators"`
	// PushRegossipNumPeers is the number of peers to push transactions to after
	// the first round of gossip.
	PushRegossipNumPeers int `json:"push-regossip-num-peers"`
	// PushGossipDiscardedCacheSize is the number of txIDs to cache to avoid
	// pushing transactions that were recently dropped from the mempool.
	PushGossipDiscardedCacheSize int `json:"push-gossip-discarded-cache-size"`
	// PushGossipMaxRegossipFrequency is the limit for how frequently a
	// transaction will be push gossiped.
	PushGossipMaxRegossipFrequency time.Duration `json:"push-gossip-max-regossip-frequency"`
	// PushGossipFrequency is how frequently rounds of push gossip are
	// performed.
	PushGossipFrequency time.Duration `json:"push-gossip-frequency"`
	// PullGossipPollSize is the number of validators to sample when performing
	// a round of pull gossip.
	PullGossipPollSize int `json:"pull-gossip-poll-size"`
	// PullGossipFrequency is how frequently rounds of pull gossip are
	// performed.
	PullGossipFrequency time.Duration `json:"pull-gossip-frequency"`
	// PullGossipThrottlingPeriod is how large of a window the throttler should
	// use.
	PullGossipThrottlingPeriod time.Duration `json:"pull-gossip-throttling-period"`
	// PullGossipThrottlingLimit is the number of pull querys that are allowed
	// by a validator in every throttling window.
	PullGossipThrottlingLimit int `json:"pull-gossip-throttling-limit"`
	// ExpectedBloomFilterElements is the number of elements to expect when
	// creating a new bloom filter. The larger this number is, the larger the
	// bloom filter will be.
	ExpectedBloomFilterElements int `json:"expected-bloom-filter-elements"`
	// ExpectedBloomFilterFalsePositiveProbability is the expected probability
	// of a false positive after having inserted ExpectedBloomFilterElements
	// into a bloom filter. The smaller this number is, the larger the bloom
	// filter will be.
	ExpectedBloomFilterFalsePositiveProbability float64 `json:"expected-bloom-filter-false-positive-probability"`
	// MaxBloomFilterFalsePositiveProbability is used to determine when the
	// bloom filter should be refreshed. Once the expected probability of a
	// false positive exceeds this value, the bloom filter will be regenerated.
	// The smaller this number is, the more frequently that the bloom filter
	// will be regenerated.
	MaxBloomFilterFalsePositiveProbability float64 `json:"max-bloom-filter-false-positive-probability"`
}

Jump to

Keyboard shortcuts

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