Work Types - JAM

Submodules

Module Contents

Work-related types for the JAM protocol.

class jam.types.work.RefineContext(anchor: ByteArray32, state_root: ByteArray32, beefy_root: ByteArray32, lookup_anchor: ByteArray32, lookup_anchor_slot: U32, prerequisites: OpaqueHashes)[source]

Bases: Codable, JsonSerde

Refine context structure.

anchor: ByteArray32
state_root: ByteArray32
beefy_root: ByteArray32
lookup_anchor: ByteArray32
lookup_anchor_slot: U32
prerequisites: OpaqueHashes
__init__(anchor: ByteArray32, state_root: ByteArray32, beefy_root: ByteArray32, lookup_anchor: ByteArray32, lookup_anchor_slot: U32, prerequisites: OpaqueHashes) 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.work.ImportSpec(tree_root: ByteArray32, index: U16)[source]

Bases: Codable, JsonSerde

Import specification structure.

tree_root: ByteArray32
index: U16
__init__(tree_root: ByteArray32, index: U16) 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.work.ExtrinsicSpec(hash: ByteArray32, len: U32)[source]

Bases: Codable, JsonSerde

Extrinsic specification structure.

hash: ByteArray32
len: U32
__init__(hash: ByteArray32, len: 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.work.WorkItem(service: U32, code_hash: ByteArray32, payload: Bytes, refine_gas_limit: U64, accumulate_gas_limit: U64, import_segments: ImportSpecs, extrinsic: ExtrinsicSpecs, export_count: U16)[source]

Bases: Codable, JsonSerde

Work item structure.

service: U32
code_hash: ByteArray32
payload: Bytes
refine_gas_limit: U64
accumulate_gas_limit: U64
import_segments: ImportSpecs
extrinsic: ExtrinsicSpecs
export_count: U16
__init__(service: U32, code_hash: ByteArray32, payload: Bytes, refine_gas_limit: U64, accumulate_gas_limit: U64, import_segments: ImportSpecs, extrinsic: ExtrinsicSpecs, export_count: U16) 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.work.Authorizer(code_hash: ByteArray32, params: Bytes)[source]

Bases: Codable, JsonSerde

Authorizer structure.

code_hash: ByteArray32
params: Bytes
__init__(code_hash: ByteArray32, params: Bytes) 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.work.WorkPackage(authorization: Bytes, auth_code_host: U32, authorizer: Authorizer, context: RefineContext, items: WorkItems)[source]

Bases: Codable, JsonSerde

Work package structure.

authorization: Bytes
auth_code_host: U32
authorizer: Authorizer
context: RefineContext
items: WorkItems
__init__(authorization: Bytes, auth_code_host: U32, authorizer: Authorizer, context: RefineContext, items: WorkItems) 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.work.WorkExecResult(initial: Dict[str, Codable[T]] | Codable[T])[source]

Bases: Choice

Work execution result choice.

ok: Bytes
out_of_gas: Nullable
panic: Nullable
bad_code: Nullable
code_oversize: Nullable
static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Choice, int]

Decode choice from buffer.

Parameters:
  • types – List of possible types for this choice

  • buffer – Source buffer

  • offset – Starting offset

Returns:

Tuple of (decoded value, bytes read)

Raises:
class jam.types.work.WorkResult(service_id: U32, code_hash: ByteArray32, payload_hash: ByteArray32, accumulate_gas: U64, result: WorkExecResult)[source]

Bases: Codable, JsonSerde

Work result structure.

service_id: U32
code_hash: ByteArray32
payload_hash: ByteArray32
accumulate_gas: U64
result: WorkExecResult
__init__(service_id: U32, code_hash: ByteArray32, payload_hash: ByteArray32, accumulate_gas: U64, result: WorkExecResult) 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.work.WorkPackageSpec(hash: ByteArray32, length: U32, erasure_root: ByteArray32, exports_root: ByteArray32, exports_count: U16)[source]

Bases: Codable, JsonSerde

Work package specification structure.

hash: ByteArray32
length: U32
erasure_root: ByteArray32
exports_root: ByteArray32
exports_count: U16
__init__(hash: ByteArray32, length: U32, erasure_root: ByteArray32, exports_root: ByteArray32, exports_count: U16) 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.work.SegmentRootLookupItem(work_package_hash: ByteArray32, segment_tree_root: ByteArray32)[source]

Bases: Codable, JsonSerde

Segment root lookup item structure.

work_package_hash: ByteArray32
segment_tree_root: ByteArray32
__init__(work_package_hash: ByteArray32, segment_tree_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.work.WorkReport(package_spec: WorkPackageSpec, context: RefineContext, core_index: U16, authorizer_hash: ByteArray32, auth_output: Bytes, segment_root_lookup: SegmentRootLookup, results: WorkResults)[source]

Bases: Codable, JsonSerde

Work report structure.

package_spec: WorkPackageSpec
context: RefineContext
core_index: U16
authorizer_hash: ByteArray32
auth_output: Bytes
segment_root_lookup: SegmentRootLookup
results: WorkResults
__init__(package_spec: WorkPackageSpec, context: RefineContext, core_index: U16, authorizer_hash: ByteArray32, auth_output: Bytes, segment_root_lookup: SegmentRootLookup, results: WorkResults) 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.