payload

package
v0.5.6-fuji-warp Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: GPL-3.0, LGPL-3.0 Imports: 7 Imported by: 0

README

Payload

An Avalanche Unsigned Warp Message already includes a networkID, sourceChainID, and payload field. The payload field is parsed into one of the types included in this package to be handled by the EVM.

AddressedPayload

AddressedPayload:

+---------------------+----------+-------------------+
|             codecID :   uint16 |           2 bytes |
+---------------------+----------+-------------------+
|              typeID :   uint32 |           4 bytes |
+---------------------+----------+-------------------+
|       sourceAddress : [20]byte |          20 bytes |
+---------------------+----------+-------------------+
|  destinationChainID : [32]byte |          32 bytes |
+---------------------+----------+-------------------+
|  destinationAddress : [20]byte |          20 bytes |
+---------------------+----------+-------------------+
|             payload :   []byte |  4 + len(payload) |
+---------------------+----------+-------------------+
                                 | 82 + len(payload) |
                                 +-------------------+
  • codecID is the codec version used to serialize the payload and is hardcoded to 0x0000
  • typeID is the payload type identifier and is 0x00000000 for AddressedPayload
  • sourceAddress is the address that called sendWarpPrecompile on the source chain
  • destinationChainID is the blockchainID that the message is intended for
  • destinationAddress is the address that should be called on the destination chain
  • payload is an arbitrary byte array payload

BlockHashPayload

BlockHashPayload:

+-----------------+----------+-----------+
|         codecID :   uint16 |   2 bytes |
+-----------------+----------+-----------+
|          typeID :   uint32 |   4 bytes |
+-----------------+----------+-----------+
|       blockHash : [32]byte |  32 bytes |
+-----------------+----------+-----------+
                             |  38 bytes |
                             +-----------+
  • codecID is the codec version used to serialize the payload and is hardcoded to 0x0000
  • typeID is the payload type identifier and is 0x00000001 for BlockHashPayload
  • blockHash is a blockHash from the sourceChainID. A signed block hash payload indicates that the signer has accepted the block on the source chain.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressedPayload

type AddressedPayload struct {
	SourceAddress      common.Address `serialize:"true"`
	DestinationChainID common.Hash    `serialize:"true"`
	DestinationAddress common.Address `serialize:"true"`
	Payload            []byte         `serialize:"true"`
	// contains filtered or unexported fields
}

AddressedPayload defines the format for delivering a point to point message across VMs ie. (ChainA, AddressA) -> (ChainB, AddressB)

func NewAddressedPayload

func NewAddressedPayload(sourceAddress common.Address, destinationChainID common.Hash, destinationAddress common.Address, payload []byte) (*AddressedPayload, error)

NewAddressedPayload creates a new *AddressedPayload and initializes it.

func ParseAddressedPayload

func ParseAddressedPayload(b []byte) (*AddressedPayload, error)

ParseAddressedPayload converts a slice of bytes into an initialized AddressedPayload.

func (*AddressedPayload) Bytes

func (a *AddressedPayload) Bytes() []byte

Bytes returns the binary representation of this payload. It assumes that the payload is initialized from either NewAddressedPayload or ParseAddressedPayload.

type BlockHashPayload added in v0.5.6

type BlockHashPayload struct {
	BlockHash common.Hash `serialize:"true"`
	// contains filtered or unexported fields
}

BlockHashPayload includes the block hash

func NewBlockHashPayload added in v0.5.6

func NewBlockHashPayload(blockHash common.Hash) (*BlockHashPayload, error)

NewBlockHashPayload creates a new *BlockHashPayload and initializes it.

func ParseBlockHashPayload added in v0.5.6

func ParseBlockHashPayload(b []byte) (*BlockHashPayload, error)

ParseBlockHashPayload converts a slice of bytes into an initialized BlockHashPayload

func (*BlockHashPayload) Bytes added in v0.5.6

func (b *BlockHashPayload) Bytes() []byte

Bytes returns the binary representation of this payload. It assumes that the payload is initialized from either NewBlockHashPayload or ParseBlockHashPayload.

Jump to

Keyboard shortcuts

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