jam.state.components.delta module

class jam.state.components.delta.AccountStorage(initial: Mapping[K, V] | None = None)[source]

Bases: Dictionary[ByteArray32, Bytes]

Storage dictionary

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Dictionary[K, V], 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

key_type

alias of ByteArray32

value_type

alias of Bytes

class jam.state.components.delta.PreImageLookup(initial: Mapping[K, V] | None = None)[source]

Bases: Dictionary[ByteArray32, Bytes]

Lookup dictionary

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Dictionary[K, V], 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

key_type

alias of ByteArray32

value_type

alias of Bytes

class jam.state.components.delta.LookupTable(data: jam.types.base.sequences.bytes.byte_array.ByteArray32, length: jam.types.base.integers.fixed.U32)[source]

Bases: Codable

data: ByteArray32
length: U32
__init__(data: ByteArray32, length: 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.state.components.delta.Timestamps(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Array[U32]

Lookup timestamps

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.state.components.delta.LookupTimestamps(initial: Mapping[K, V] | None = None)[source]

Bases: Dictionary[ByteArray32, Timestamps]

Lookup timestamps

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Dictionary[K, V], 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

key_type

alias of ByteArray32

value_type

alias of Timestamps

class jam.state.components.delta.AccountData(storage: jam.state.components.delta.AccountStorage, lookup: jam.state.components.delta.PreImageLookup, timestamps: jam.state.components.delta.LookupTimestamps, code_hash: jam.types.base.sequences.bytes.byte_array.ByteArray32, balance: jam.types.base.integers.fixed.U64, gas_limit: jam.types.base.integers.fixed.U64, min_gas: jam.types.base.integers.fixed.U64)[source]

Bases: Codable

storage: AccountStorage
lookup: PreImageLookup
timestamps: LookupTimestamps
code_hash: ByteArray32
balance: U64
gas_limit: U64
min_gas: U64
__init__(storage: AccountStorage, lookup: PreImageLookup, timestamps: LookupTimestamps, code_hash: ByteArray32, balance: U64, gas_limit: U64, min_gas: U64) 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.state.components.delta.Delta(initial: Mapping[K, V] | None = None)[source]

Bases: Dictionary[U32, AccountData]

Delta state

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Dictionary[K, V], 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

key_type

alias of U32

value_type

alias of AccountData

jam.state.components.delta.Ai

The total number of octets used in storage

jam.state.components.delta.Ao

The minimum, or threshold, balance needed for any given service account