message

package
v1.36.3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

README

P-Chain warp message payloads

This package defines parsing and serialization for the payloads of unsigned warp messages on the P-Chain.

These payloads are specified in LP-77, and are expected as part of the payload field of an AddressedCall message, with an empty source address.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidChainID = errors.New("invalid chain ID")
	ErrInvalidWeight  = errors.New("invalid weight")
	ErrInvalidNodeID  = errors.New("invalid node ID")
	ErrInvalidOwner   = errors.New("invalid owner")
)
View Source
var ErrNonceReservedForRemoval = errors.New("maxUint64 nonce is reserved for removal")
View Source
var ErrWrongType = errors.New("wrong payload type")

Functions

func ChainToL1ConversionID added in v1.22.23

func ChainToL1ConversionID(data ChainToL1ConversionData) (ids.ID, error)

ChainToL1ConversionID creates a chain conversion ID from the provided chain conversion data. The preimage is exactly ChainToL1ConversionData.Marshal.

Types

type ChainToL1Conversion added in v1.22.23

type ChainToL1Conversion struct {

	// ID of the chain conversion. It is typically generated by calling
	// ChainToL1ConversionID.
	ID ids.ID `json:"id"`
	// contains filtered or unexported fields
}

ChainToL1Conversion reports the summary of the chain conversion that occurred on the P-chain.

Wire: mkind u8 @0, ID 32B @1 = 33 bytes.

func NewChainToL1Conversion added in v1.22.23

func NewChainToL1Conversion(id ids.ID) (*ChainToL1Conversion, error)

NewChainToL1Conversion creates a new initialized ChainToL1Conversion.

func ParseChainToL1Conversion added in v1.22.23

func ParseChainToL1Conversion(b []byte) (*ChainToL1Conversion, error)

ParseChainToL1Conversion parses bytes into an initialized ChainToL1Conversion.

func (ChainToL1Conversion) Bytes added in v1.22.23

func (p ChainToL1Conversion) Bytes() []byte

type ChainToL1ConversionData added in v1.22.23

type ChainToL1ConversionData struct {
	ChainID        ids.ID                             `json:"chainID"`
	ManagerChainID ids.ID                             `json:"managerChainID"`
	ManagerAddress types.JSONByteSlice                `json:"managerAddress"`
	Validators     []ChainToL1ConversionValidatorData `json:"validators"`
}

func (*ChainToL1ConversionData) Marshal added in v1.36.3

func (d *ChainToL1ConversionData) Marshal() ([]byte, error)

Marshal is the ONE canonical byte encoding of the conversion data — the hash preimage of ChainToL1ConversionID. ChainToL1ConversionID calls this same encoder, so the ID and the bytes can never diverge.

type ChainToL1ConversionValidatorData added in v1.22.23

type ChainToL1ConversionValidatorData struct {
	NodeID       types.JSONByteSlice    `json:"nodeID"`
	BLSPublicKey [bls.PublicKeyLen]byte `json:"blsPublicKey"`
	Weight       uint64                 `json:"weight"`
}

type L1ValidatorRegistration

type L1ValidatorRegistration struct {
	ValidationID ids.ID `json:"validationID"`
	// Registered being true means that validationID is currently a validator on
	// the P-chain.
	//
	// Registered being false means that validationID is not and can never
	// become a validator on the P-chain. It is possible that validationID was
	// previously a validator on the P-chain.
	Registered bool `json:"registered"`
	// contains filtered or unexported fields
}

L1ValidatorRegistration reports if a validator is registered on the P-chain.

Wire: mkind u8 @0, ValidationID 32B @1, Registered u8 @33 = 34 bytes.

func NewL1ValidatorRegistration

func NewL1ValidatorRegistration(
	validationID ids.ID,
	registered bool,
) (*L1ValidatorRegistration, error)

NewL1ValidatorRegistration creates a new initialized L1ValidatorRegistration.

func ParseL1ValidatorRegistration

func ParseL1ValidatorRegistration(b []byte) (*L1ValidatorRegistration, error)

ParseL1ValidatorRegistration parses bytes into an initialized L1ValidatorRegistration.

func (L1ValidatorRegistration) Bytes

func (p L1ValidatorRegistration) Bytes() []byte

type L1ValidatorWeight

type L1ValidatorWeight struct {
	ValidationID ids.ID `json:"validationID"`
	Nonce        uint64 `json:"nonce"`
	Weight       uint64 `json:"weight"`
	// contains filtered or unexported fields
}

L1ValidatorWeight is both received and sent by the P-chain.

If the P-chain is receiving this message, it is treated as a command to update the weight of the validator.

If the P-chain is sending this message, it is reporting the current nonce and weight of the validator.

Wire: mkind u8 @0, ValidationID 32B @1, Nonce u64 @33, Weight u64 @41 = 49B.

func NewL1ValidatorWeight

func NewL1ValidatorWeight(
	validationID ids.ID,
	nonce uint64,
	weight uint64,
) (*L1ValidatorWeight, error)

NewL1ValidatorWeight creates a new initialized L1ValidatorWeight.

func ParseL1ValidatorWeight

func ParseL1ValidatorWeight(b []byte) (*L1ValidatorWeight, error)

ParseL1ValidatorWeight parses bytes into an initialized L1ValidatorWeight.

func (L1ValidatorWeight) Bytes

func (p L1ValidatorWeight) Bytes() []byte

func (*L1ValidatorWeight) Verify

func (s *L1ValidatorWeight) Verify() error

type PChainOwner

type PChainOwner struct {
	// The threshold number of `Addresses` that must provide a signature in
	// order for the `PChainOwner` to be considered valid.
	Threshold uint32 `json:"threshold"`
	// The addresses that are allowed to sign to authenticate a `PChainOwner`.
	Addresses []ids.ShortID `json:"addresses"`
}

type Payload

type Payload interface {
	// Bytes returns the binary representation of this payload.
	//
	// If the payload is not initialized, this method will return nil.
	Bytes() []byte
	// contains filtered or unexported methods
}

Payload provides a common interface for all payloads implemented by this package. Each payload is a native-ZAP struct-is-wire object whose first byte is an mkind discriminator (the struct IS the buffer; no codec).

func Parse

func Parse(bytes []byte) (Payload, error)

Parse dispatches a payload buffer on its mkind discriminator.

type RegisterL1Validator

type RegisterL1Validator struct {
	ChainID               ids.ID                 `json:"chainID"`
	NodeID                types.JSONByteSlice    `json:"nodeID"`
	BLSPublicKey          [bls.PublicKeyLen]byte `json:"blsPublicKey"`
	Expiry                uint64                 `json:"expiry"`
	RemainingBalanceOwner PChainOwner            `json:"remainingBalanceOwner"`
	DisableOwner          PChainOwner            `json:"disableOwner"`
	Weight                uint64                 `json:"weight"`
	// contains filtered or unexported fields
}

RegisterL1Validator adds a validator to the chain.

Wire: mkind u8 @0, ChainID 32B @1, BLSPublicKey 48B @33, Expiry u64 @81, Weight u64 @89, NodeID bytes @97, RemainingBalanceOwner{threshold u32 @105, addrs 20B-stride list @109}, DisableOwner{threshold u32 @117, addrs @121} = 129-byte object header.

func NewRegisterL1Validator

func NewRegisterL1Validator(
	chainID ids.ID,
	nodeID ids.NodeID,
	blsPublicKey [bls.PublicKeyLen]byte,
	expiry uint64,
	remainingBalanceOwner PChainOwner,
	disableOwner PChainOwner,
	weight uint64,
) (*RegisterL1Validator, error)

NewRegisterL1Validator creates a new initialized RegisterL1Validator.

func ParseRegisterL1Validator

func ParseRegisterL1Validator(b []byte) (*RegisterL1Validator, error)

ParseRegisterL1Validator parses bytes into an initialized RegisterL1Validator.

func (RegisterL1Validator) Bytes

func (p RegisterL1Validator) Bytes() []byte

func (*RegisterL1Validator) ValidationID

func (r *RegisterL1Validator) ValidationID() ids.ID

func (*RegisterL1Validator) Verify

func (r *RegisterL1Validator) Verify() error

Jump to

Keyboard shortcuts

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