Documentation
¶
Index ¶
Constants ¶
const CodecVersion = block.CodecVersion
CodecVersion is the canonical write version for new P-Chain genesis blobs. It is shared with the block codec (and txs codec) so a single constant bumps the whole stack.
Variables ¶
var Codec = txs.GenesisCodec
Codec is the multi-version codec.Manager used to (un)marshal P-Chain genesis blobs. It is intentionally an alias for txs.GenesisCodec rather than block.GenesisCodec because:
- txs.GenesisCodec registers BOTH the v0 (v1.23.x Apricot/Banff) and v1 (current) tx slot maps, so it can decode v0-prefixed cached-genesis blobs that pre-date the codec bump. block.Genesis Codec carries only the v1 slot map and errors on prefix=0 with codec.ErrUnknownVersion — exactly the failure mode that broke v1.28.0 testnet canary at first-byte parse of <data>/genesis.bytes.
- The outer Genesis struct itself has no slot ID; all version- sensitive data lives in the embedded []*txs.Tx (validators, chains). Decoding via txs.GenesisCodec is therefore exactly the dispatch we need — version is taken from the 2-byte wire prefix and routed to the v0 or v1 tx slot map.
- Marshal at CodecVersion (== v1) is unchanged: the v1 slot map in txs.GenesisCodec is byte-for-byte identical to the v1 slot map in block.GenesisCodec (both come from registerV1TxTypes).
All write paths (Genesis.Bytes, New, static_service) MUST continue to use CodecVersion. v0 is a READ-ONLY decoder.
Functions ¶
This section is empty.
Types ¶
type Allocation ¶
Allocation is a UTXO on the Platform Chain that exists at the chain's genesis
func (Allocation) Compare ¶
func (a Allocation) Compare(other Allocation) int
Compare compares two allocations
type Chain ¶
Chain defines a chain that exists at the network's genesis [GenesisData] is the initial state of the chain. [VMID] is the ID of the VM this blockchain runs. [FxIDs] are the IDs of the Fxs the blockchain supports. [Name] is a human-readable, non-unique name for the blockchain. [ChainID] is the ID of the chain that validates the blockchain
type Genesis ¶
type Genesis struct {
UTXOs []*UTXO `serialize:"true"`
Validators []*txs.Tx `serialize:"true"`
Chains []*txs.Tx `serialize:"true"`
Timestamp uint64 `serialize:"true"`
InitialSupply uint64 `serialize:"true"`
Message string `serialize:"true"`
}
Genesis represents a genesis state of the platform chain
func New ¶
func New( utxoAssetID ids.ID, networkID uint32, allocations []Allocation, validators []PermissionlessValidator, chains []Chain, time uint64, initialSupply uint64, message string, ) (*Genesis, error)
New builds the genesis state of the P-Chain (and thereby the Lux network.) [utxoAssetID] is the ID of the LUX asset [networkID] is the ID of the network [allocations] are the UTXOs on the Platform Chain that exist at genesis. [validators] are the validators of the primary network at genesis. [chains] are the chains that exist at genesis. time is the Platform Chain's time at network genesis. [initialSupply] is the initial supply of the LUX asset. [message] is the message to be sent to the genesis UTXOs.
func Parse ¶
Parse deserializes a P-Chain genesis blob produced by either the v0 (v1.23.x) or v1 (current) codec. Wire version is taken from the 2-byte codec prefix; the matching codec.Manager entry is used to unmarshal the outer Genesis struct, and embedded validator + chain txs are bound to their original signedBytes via InitializeFromBytes (NOT Initialize, which would re-marshal and rotate the TxID).
TxID stability across the v0->v1 migration is preserved because:
- v0 genesis blobs decode via the v0 slot map and embedded txs are re-bound at version 0; their hash(signedBytes) is identical to what the v1.23.x producer committed.
- v1 genesis blobs decode via the v1 slot map; embedded txs are re-bound at version 1; bytes are deterministic so the result is byte-equal to what a v1 producer emits.
Genesis blobs are typically produced fresh from the JSON config at each bootstrap (see New + Bytes), so the path that matters for mainnet/testnet is the v0 fallback: the originally-committed genesis hash is what subsequent block headers chain back to, and that hash is hash(v0 genesis bytes).
type PermissionlessValidator ¶
type PermissionlessValidator struct {
Validator
RewardOwner *Owner
DelegationFee float32
ExactDelegationFee uint32
Staked []Allocation
Signer *signer.ProofOfPossession
}
GenesisPermissionlessValidator represents a permissionless validator at genesis