Protocol Helper Types

Submodules

Module Contents

jam.types.protocol.TimeSlot

alias of U32

jam.types.protocol.ValidatorIndex

alias of U16

jam.types.protocol.CoreIndex

alias of U16

jam.types.protocol.Gas

alias of U64

jam.types.protocol.ServiceId

alias of U32

jam.types.protocol.WorkPackageHash

alias of ByteArray32

jam.types.protocol.WorkReportHash

alias of ByteArray32

jam.types.protocol.ExportsRoot

alias of ByteArray32

jam.types.protocol.ErasureRoot

alias of ByteArray32

class jam.types.protocol.ServiceInfo(code_hash: ByteArray32, balance: U64, min_item_gas: U64, min_memo_gas: U64, bytes_data: U64, items: U32)[source]

Bases: Codable, JsonSerde

Service information structure.

code_hash: ByteArray32
balance: U64
min_item_gas: U64
min_memo_gas: U64
bytes_data: U64
items: U32
__init__(code_hash: ByteArray32, balance: U64, min_item_gas: U64, min_memo_gas: U64, bytes_data: U64, items: U32) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.protocol.AvailabilityAssignment(report: WorkReport, timeout: U32)[source]

Bases: Codable, JsonSerde

Availability assignment structure.

report: WorkReport
timeout: U32
__init__(report: WorkReport, timeout: U32) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.protocol.AvailabilityAssignments(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[Choice]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.protocol.Mmr(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Vector[Choice]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Vector[T], int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.protocol.BlockInfo(header_hash: ByteArray32, mmr: Mmr, state_root: ByteArray32, reported: List[ReportedWorkPackage])[source]

Bases: Codable, JsonSerde

Block information structure.

header_hash: ByteArray32
mmr: Mmr
state_root: ByteArray32
reported: List[ReportedWorkPackage]
__init__(header_hash: ByteArray32, mmr: Mmr, state_root: ByteArray32, reported: List[ReportedWorkPackage]) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.protocol.BlocksHistory(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[BlockInfo]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.protocol.ReportedWorkPackage(hash: ByteArray32, exports_root: ByteArray32)[source]

Bases: Codable, JsonSerde

Reported work package structure.

hash: ByteArray32
exports_root: ByteArray32
__init__(hash: ByteArray32, exports_root: ByteArray32) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.protocol.EpochMark(entropy: ByteArray32, tickets_entropy: ByteArray32, validators: ValidatorArray)[source]

Bases: Codable, JsonSerde

Epoch mark structure.

entropy: ByteArray32
tickets_entropy: ByteArray32
validators: ValidatorArray
__init__(entropy: ByteArray32, tickets_entropy: ByteArray32, validators: ValidatorArray) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.protocol.ValidatorMetadata(value: int | bool | bytes | str | bytearray | memoryview | Sequence)[source]

Bases: ByteArray128

Validator metadata structure.

class jam.types.protocol.ValidatorData(bandersnatch: ByteArray32, ed25519: ByteArray32, bls: ByteArray144, metadata: ValidatorMetadata)[source]

Bases: Codable, JsonSerde

Validator data structure.

bandersnatch: ByteArray32
ed25519: ByteArray32
bls: ByteArray144
metadata: ValidatorMetadata
__init__(bandersnatch: ByteArray32, ed25519: ByteArray32, bls: ByteArray144, metadata: ValidatorMetadata) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.protocol.ValidatorsData(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[ValidatorData]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.protocol.ValidatorArray(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[ByteArray32]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Any, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

jam.types.protocol.BandersnatchPublic

alias of ByteArray32

jam.types.protocol.BandersnatchVrfSignature

alias of ByteArray96

jam.types.protocol.HeaderHash

alias of ByteArray32

jam.types.protocol.StateRoot

alias of ByteArray32

jam.types.protocol.OpaqueHash

alias of ByteArray32

jam.types.protocol.Entropy

alias of ByteArray32

jam.types.protocol.BeefyRoot

alias of ByteArray32

class jam.types.protocol.MMR(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Vector[ByteArray32]

Merkle Mountain Range

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Vector[T], int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing