Documentation
¶
Overview ¶
Package v0 defines the v1.23.x ("Apricot/Banff") P-Chain block layout.
These types EXIST ONLY FOR DECODING pre-codec-v1 blocks read from disk (mainnet, testnet) and from the wire during catch-up. New blocks are always written at codec version 1 using the canonical block types in the parent block package.
Invariants:
- Wire layout is byte-for-byte identical to v1.23.31's vms/platformvm/block package (slot IDs, struct layout).
- Each v0 block satisfies block.Block by translating its Visit call to the canonical v1 visitor method (ApricotProposalBlock -> StandardBlock at proposal-tail position, etc.).
- Block bytes are byte-preserved (BlockID = hash(input bytes); the input bytes are stashed on CommonBlock and returned verbatim by Bytes()). The block is never re-marshaled.
- Embedded txs are byte-preserved via tx.InitializeFromBytes using the codec version their bytes were decoded under.
Index ¶
- Constants
- func RegisterBlockTypes(c linearcodec.Codec) error
- func RegisterTxTypes(c linearcodec.Codec) error
- type ApricotAbortBlock
- type ApricotAtomicBlock
- type ApricotCommitBlock
- type ApricotProposalBlock
- type ApricotStandardBlock
- type BanffAbortBlock
- type BanffCommitBlock
- type BanffProposalBlock
- type BanffStandardBlock
- type Block
- type CommonBlock
Constants ¶
const CodecVersion uint16 = 0
CodecVersion is the wire-version prefix for the v1.23.x layout.
Variables ¶
This section is empty.
Functions ¶
func RegisterBlockTypes ¶
func RegisterBlockTypes(c linearcodec.Codec) error
RegisterBlockTypes registers the v0 block + tx type IDs in their canonical v1.23.x order on the given linearcodec.
Slot map (block codec):
0-4 Apricot blocks (Proposal, Abort, Commit, Standard, Atomic)
5 secp256k1fx.TransferInput
6 [skipped — was MintOutput, never used on P-Chain]
7 secp256k1fx.TransferOutput
8 [skipped — was MintOperation, never used on P-Chain]
9-11 secp256k1fx.{Credential, Input, OutputOwners}
12-20 Apricot txs (AddValidator..RewardValidator)
21-22 stakeable.{LockIn, LockOut}
23-26 Banff txs (RemoveChainValidator..AddPermissionlessDelegator)
27-28 signer.{Empty, ProofOfPossession}
29-32 Banff blocks (Proposal, Abort, Commit, Standard)
33-34 Durango txs (TransferChainOwnership, BaseTx)
35-39 Etna txs (ConvertChainToL1..DisableL1Validator)
ConvertChainToL1Tx is registered as the wire-format-equivalent ConvertNetworkToL1Tx (post-rename source type, identical struct layout, same slot 35). Codec wire matching is by slot ID, not type name; the rename did not change the serialized format.
func RegisterTxTypes ¶
func RegisterTxTypes(c linearcodec.Codec) error
RegisterTxTypes registers the v0 type IDs in the tx-only ordering used by v1.23.x txs.init(). Apricot block slots (0-4) and Banff block slots (29-32) are SkipRegistrations rather than RegisterType so that shared tx slots line up with the block codec.
Types ¶
type ApricotAbortBlock ¶
type ApricotAbortBlock struct {
CommonBlock `serialize:"true"`
}
ApricotAbortBlock decodes slot 1.
func (*ApricotAbortBlock) Height ¶
func (b *ApricotAbortBlock) Height() uint64
func (*ApricotAbortBlock) ParentID ¶
func (b *ApricotAbortBlock) ParentID() ids.ID
func (*ApricotAbortBlock) TimestampUnix ¶
func (*ApricotAbortBlock) TimestampUnix() uint64
func (*ApricotAbortBlock) Txs ¶
func (*ApricotAbortBlock) Txs() []*txs.Tx
type ApricotAtomicBlock ¶
type ApricotAtomicBlock struct {
CommonBlock `serialize:"true"`
Tx *txs.Tx `serialize:"true" json:"tx"`
}
ApricotAtomicBlock decodes slot 4. The atomic block flow is dead on the modern P-only network — Apricot atomic blocks only ever appear pre-Banff in legacy chain history.
func (*ApricotAtomicBlock) Height ¶
func (b *ApricotAtomicBlock) Height() uint64
func (*ApricotAtomicBlock) ParentID ¶
func (b *ApricotAtomicBlock) ParentID() ids.ID
func (*ApricotAtomicBlock) TimestampUnix ¶
func (*ApricotAtomicBlock) TimestampUnix() uint64
func (*ApricotAtomicBlock) Txs ¶
func (b *ApricotAtomicBlock) Txs() []*txs.Tx
type ApricotCommitBlock ¶
type ApricotCommitBlock struct {
CommonBlock `serialize:"true"`
}
ApricotCommitBlock decodes slot 2.
func (*ApricotCommitBlock) Height ¶
func (b *ApricotCommitBlock) Height() uint64
func (*ApricotCommitBlock) ParentID ¶
func (b *ApricotCommitBlock) ParentID() ids.ID
func (*ApricotCommitBlock) TimestampUnix ¶
func (*ApricotCommitBlock) TimestampUnix() uint64
func (*ApricotCommitBlock) Txs ¶
func (*ApricotCommitBlock) Txs() []*txs.Tx
type ApricotProposalBlock ¶
type ApricotProposalBlock struct {
CommonBlock `serialize:"true"`
Tx *txs.Tx `serialize:"true" json:"tx"`
}
ApricotProposalBlock decodes slot 0. Carries no header timestamp; pre-Banff time advances were carried in AdvanceTimeTx, not in the block header.
func (*ApricotProposalBlock) Height ¶
func (b *ApricotProposalBlock) Height() uint64
func (*ApricotProposalBlock) ParentID ¶
func (b *ApricotProposalBlock) ParentID() ids.ID
func (*ApricotProposalBlock) TimestampUnix ¶
func (*ApricotProposalBlock) TimestampUnix() uint64
func (*ApricotProposalBlock) Txs ¶
func (b *ApricotProposalBlock) Txs() []*txs.Tx
type ApricotStandardBlock ¶
type ApricotStandardBlock struct {
CommonBlock `serialize:"true"`
Transactions []*txs.Tx `serialize:"true" json:"txs"`
}
ApricotStandardBlock decodes slot 3.
func (*ApricotStandardBlock) Height ¶
func (b *ApricotStandardBlock) Height() uint64
func (*ApricotStandardBlock) ParentID ¶
func (b *ApricotStandardBlock) ParentID() ids.ID
func (*ApricotStandardBlock) TimestampUnix ¶
func (*ApricotStandardBlock) TimestampUnix() uint64
func (*ApricotStandardBlock) Txs ¶
func (b *ApricotStandardBlock) Txs() []*txs.Tx
type BanffAbortBlock ¶
type BanffAbortBlock struct {
Time uint64 `serialize:"true" json:"time"`
ApricotAbortBlock `serialize:"true"`
}
BanffAbortBlock decodes slot 30.
func (*BanffAbortBlock) TimestampUnix ¶
func (b *BanffAbortBlock) TimestampUnix() uint64
type BanffCommitBlock ¶
type BanffCommitBlock struct {
Time uint64 `serialize:"true" json:"time"`
ApricotCommitBlock `serialize:"true"`
}
BanffCommitBlock decodes slot 31.
func (*BanffCommitBlock) TimestampUnix ¶
func (b *BanffCommitBlock) TimestampUnix() uint64
type BanffProposalBlock ¶
type BanffProposalBlock struct {
Time uint64 `serialize:"true" json:"time"`
Transactions []*txs.Tx `serialize:"true" json:"txs"`
ApricotProposalBlock `serialize:"true"`
}
BanffProposalBlock decodes slot 29. Carries a Banff-era per-block timestamp ahead of the embedded Apricot proposal block (which still holds the proposal Tx). The on-wire field order is Time, then Transactions (the decision-tx tail), then ApricotProposalBlock.
func (*BanffProposalBlock) TimestampUnix ¶
func (b *BanffProposalBlock) TimestampUnix() uint64
func (*BanffProposalBlock) Txs ¶
func (b *BanffProposalBlock) Txs() []*txs.Tx
type BanffStandardBlock ¶
type BanffStandardBlock struct {
Time uint64 `serialize:"true" json:"time"`
ApricotStandardBlock `serialize:"true"`
}
BanffStandardBlock decodes slot 32.
func (*BanffStandardBlock) TimestampUnix ¶
func (b *BanffStandardBlock) TimestampUnix() uint64
type Block ¶
type Block interface {
// ParentID is the BlockID of the parent block.
ParentID() ids.ID
// Height is the block height. Genesis is at height 0.
Height() uint64
// TimestampUnix returns the block-header timestamp encoded in this
// block (Banff and later). Apricot blocks carry no header timestamp
// and return 0; the parent timestamp is used in their stead by the
// adapter.
TimestampUnix() uint64
// Txs returns the txs carried by this block in their canonical
// order. For ApricotProposalBlock the proposal Tx is the sole
// element; for BanffProposalBlock the proposal Tx is the trailing
// element (matching the v1.23.31 ProposalBlock.Txs() shape).
Txs() []*txs.Tx
}
Block is the v0-decoder-side counterpart of block.Block. It is satisfied by every concrete v0 block kind so that the v0 codec can dispatch on an interface destination at unmarshal time. The parent block package wraps the returned v0.Block in an adapter that implements block.Block (which in turn dispatches to the canonical v1 Visitor).
type CommonBlock ¶
type CommonBlock struct {
PrntID ids.ID `serialize:"true" json:"parentID"`
Hght uint64 `serialize:"true" json:"height"`
}
CommonBlock holds the parent-id + height fields shared across every v0 block kind. Wire layout: PrntID (ids.ID, 32 bytes) followed by Hght (uint64, 8 bytes). Byte-equal to v1.23.31 CommonBlock.