fix: use first validator address for initialStakedFunds

The initialStakedFunds field must reference an address that exists
in the allocations with proper unlock schedule. Previously it used
the treasury address which wasn't in allocations.

Now uses the first validator key address which is guaranteed to
exist in the allocations generated from ~/.lux/keys/ files.

This fixes "initial staked funds validation failed" error when
starting mainnet/testnet networks.
This commit is contained in:
Zach Kelling
2025-12-11 11:17:51 -08:00
parent 9daf099eb3
commit f0c2dc979e
+8 -8
View File
@@ -180,12 +180,6 @@ func NewConfigForNetwork(binaryPath string, numNodes uint32, networkID uint32) (
// Update genesis with initial stakers
genesis["initialStakers"] = initialStakers
// Ensure there's a staked funds entry - use treasury address
stakeAddr, err := address.Format("X", hrp, treasuryShortID[:])
if err != nil {
return network.Config{}, fmt.Errorf("couldn't format stake address: %w", err)
}
// Load validator keys from ~/.lux/keys/ (generates new ones if missing)
// Each key gets 1B LUX with 1% vesting per year since Jan 1, 2020
validatorKeys, err := LoadOrGenerateKeys("", 5)
@@ -220,8 +214,14 @@ func NewConfigForNetwork(binaryPath string, numNodes uint32, networkID uint32) (
}
}
// Set initial staked funds
genesis["initialStakedFunds"] = []string{stakeAddr}
// Set initialStakedFunds to the first validator key address
// This address must exist in allocations with proper unlock schedule
// The genesis package uses this to split staked funds among validators
firstValidatorAddr, err := FormatAddress("X", hrp, validatorKeys[0].ShortID)
if err != nil {
return network.Config{}, fmt.Errorf("couldn't format first validator address: %w", err)
}
genesis["initialStakedFunds"] = []string{firstValidatorAddr}
// Update start time to now
genesis["startTime"] = uint64(now)