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]
-
Refine context structure.
- anchor: ByteArray32
- state_root: ByteArray32
- beefy_root: ByteArray32
- lookup_anchor: ByteArray32
- 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
- class jam.types.work.ImportSpec(tree_root: ByteArray32, index: U16)[source]
-
Import specification structure.
- tree_root: ByteArray32
- __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
- class jam.types.work.ExtrinsicSpec(hash: ByteArray32, len: U32)[source]
-
Extrinsic specification structure.
- hash: ByteArray32
- __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
- 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]
-
Work item structure.
- code_hash: ByteArray32
- import_segments: ImportSpecs
- extrinsic: ExtrinsicSpecs
- __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
- class jam.types.work.Authorizer(code_hash: ByteArray32, params: Bytes)[source]
-
Authorizer structure.
- code_hash: ByteArray32
- __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
- class jam.types.work.WorkPackage(authorization: Bytes, auth_code_host: U32, authorizer: Authorizer, context: RefineContext, items: WorkItems)[source]
-
Work package structure.
- authorizer: Authorizer
- context: RefineContext
- __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
- class jam.types.work.WorkExecResult(initial: Dict[str, Codable[T]] | Codable[T])[source]
Bases:
ChoiceWork execution result choice.
- 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:
DecodeError – If buffer is invalid or too short
ValueError – If types list is empty
- class jam.types.work.WorkResult(service_id: U32, code_hash: ByteArray32, payload_hash: ByteArray32, accumulate_gas: U64, result: WorkExecResult)[source]
-
Work result structure.
- code_hash: ByteArray32
- payload_hash: ByteArray32
- 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
- class jam.types.work.WorkPackageSpec(hash: ByteArray32, length: U32, erasure_root: ByteArray32, exports_root: ByteArray32, exports_count: U16)[source]
-
Work package specification structure.
- hash: ByteArray32
- erasure_root: ByteArray32
- exports_root: ByteArray32
- __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
- class jam.types.work.SegmentRootLookupItem(work_package_hash: ByteArray32, segment_tree_root: ByteArray32)[source]
-
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
- 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]
-
Work report structure.
- package_spec: WorkPackageSpec
- context: RefineContext
- authorizer_hash: ByteArray32
- 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