Internal packages#
Warning
Users shouldn’t use anything from this package directly, use re-exports
genlayer.py#
this module and it’s submodules contain entities that don’t depend on wasm and can be executed in pure python
genlayer.py._internal#
genlayer.py._internal.reflect#
genlayer.py._nn#
Basic support for generating embeddings
This file is highly inspired by tinygrad (MIT license)
genlayer.py._nn.onnx_ops#
- class genlayer.py._nn.onnx_ops.Any[source]#
Special type indicating an unconstrained type.
Any is compatible with every type.
Any assumed to have all methods.
All values assumed to be instances of Any.
Note that all the above statements are true from the point of view of static type checkers. At runtime, Any should not be used with instance checks.
- class genlayer.py._nn.onnx_ops.Sequence#
All the operations on a read-only sequence.
Concrete subclasses must override __new__ or __init__, __getitem__, and __len__.
- count(value) integer -- return number of occurrences of value #
- index(value[, start[, stop]]) integer -- return first index of value. #
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
genlayer.py._nn.tensor#
- class genlayer.py._nn.tensor.Sequence#
All the operations on a read-only sequence.
Concrete subclasses must override __new__ or __init__, __getitem__, and __len__.
- count(value) integer -- return number of occurrences of value #
- index(value[, start[, stop]]) integer -- return first index of value. #
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
genlayer.py.calldata#
This module is responsible for working with genvm calldata
Calldata supports following types:
Primitive types:
Composite types:
list
anddict
, as well ascollections.abc.Sequence
andcollections.abc.Mapping
For full calldata specification see genvm repo
- class genlayer.py.calldata.CalldataEncodable[source]#
Abstract class to support calldata encoding for custom types
Can be used to simplify code
- genlayer.py.calldata.decode(mem0: Buffer) Any [source]#
Decodes calldata encoded bytes into python DSL
Out of composite types it will contain only
dict
andlist
- Return type:
genlayer.py.eth#
This module is responsible for interactions with ghost contracts
- class genlayer.py.eth.MethodEncoder[source]#
Type used to encode method call
- encode(args: list[Any]) bytes [source]#
encodes
args
according to this encoderparams
to produce a calldata- Returns:
full calldata encoded call: both selector and arguments
- Return type:
genlayer.py.eth.calldata#
Module that provides eth calldata encoding and decoding
- class genlayer.py.eth.calldata.MethodEncoder[source]#
Type used to encode method call
- encode(args: list[Any]) bytes [source]#
encodes
args
according to this encoderparams
to produce a calldata- Returns:
full calldata encoded call: both selector and arguments
- Return type:
genlayer.py.eth.generate#
- class genlayer.py.eth.generate.EthContractProxy[source]#
- __init__(address: Address, view_impl: Callable[[EthContractProxy], TView], send_impl: Callable[[EthContractProxy], TWrite])[source]#
genlayer.py.get_schema#
genlayer.py.keccak#
Implements keccak hash
Source code is taken from ctz/keccak (Apache 2.0 license)
genlayer.py.storage#
- class genlayer.py.storage.Array[source]#
Constantly sized array that can be persisted on the blockchain
- count(value) integer -- return number of occurrences of value #
- index(value[, start[, stop]]) integer -- return first index of value. #
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- class genlayer.py.storage.DynArray[source]#
Represents exponentially growing array (
list
in python terms) that can be persisted on the blockchain- clear() None -- remove all items from S #
- count(value) integer -- return number of occurrences of value #
- extend(values)#
S.extend(iterable) – extend sequence by appending elements from the iterable
- index(value[, start[, stop]]) integer -- return first index of value. #
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- pop([index]) item -- remove and return item at index (default last). [source]#
Raise IndexError if list is empty or index is out of range.
- remove(value)#
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- reverse()#
S.reverse() – reverse IN PLACE
- class genlayer.py.storage.TreeMap[source]#
Represents a mapping from keys to values that can be persisted on the blockchain
- __eq__(other)#
Return self==value.
- __hash__ = None#
- clear() None. Remove all items from D. #
- compute_if_absent(k: K, supplier: Callable[[], V]) V [source]#
- Returns:
Value associated with k if it is present, otherwise get’s new value from the supplier, stores it at k and returns
- Return type:
V
- get(k: K, default: G = None) V | G [source]#
- Returns:
Value associated with k or default if there is no such value
- Return type:
V | G
- keys() a set-like object providing a view on D's keys #
- pop(k[, d]) v, remove specified key and return the corresponding value. #
If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem() (k, v), remove and return some (key, value) pair #
as a 2-tuple; but raise KeyError if D is empty.
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D #
- update([E, ]**F) None. Update D from mapping/iterable E and F. #
If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
- values() an object providing a view on D's values #
genlayer.py.storage._internal.core#
- class genlayer.py.storage._internal.core.TypeDesc[source]#
Basic type description
- copy_actions: list[CopyAction]#
actions that must be executed for copying this data
int
representsmemcpy
- abstract get(slot: StorageSlot, off: int) T [source]#
Method that reads value from slot and offset pair
- Return type:
T
genlayer.py.storage._internal.desc_base_types#
- class genlayer.py.storage._internal.desc_base_types.Address[source]#
Represents GenLayer Address
- SIZE = 20#
Constant that represents size of a Genlayer address
- class genlayer.py.storage._internal.desc_base_types.ComplexCopyAction[source]#
- __init__(*args, **kwargs)#
- class genlayer.py.storage._internal.desc_base_types.TypeDesc[source]#
Basic type description
- copy_actions: list[CopyAction]#
actions that must be executed for copying this data
int
representsmemcpy
- abstract get(slot: StorageSlot, off: int) T [source]#
Method that reads value from slot and offset pair
- Return type:
T
genlayer.py.storage._internal.desc_record#
- class genlayer.py.storage._internal.desc_record.ComplexCopyAction[source]#
- __init__(*args, **kwargs)#
- class genlayer.py.storage._internal.desc_record.TypeDesc[source]#
Basic type description
- copy_actions: list[CopyAction]#
actions that must be executed for copying this data
int
representsmemcpy
- abstract get(slot: StorageSlot, off: int) T [source]#
Method that reads value from slot and offset pair
- Return type:
T
genlayer.py.storage._internal.generate#
Module that uses reflections that generates python-friendly views to GenVM storage format (mapping from slot addresses to linear memories)
genlayer.py.storage.tree_map#
- class genlayer.py.storage.tree_map.TreeMap[source]#
Represents a mapping from keys to values that can be persisted on the blockchain
- compute_if_absent(k: K, supplier: Callable[[], V]) V [source]#
- Returns:
Value associated with k if it is present, otherwise get’s new value from the supplier, stores it at k and returns
- Return type:
V
genlayer.py.storage.vec#
- class genlayer.py.storage.vec.Array[source]#
Constantly sized array that can be persisted on the blockchain
genlayer.py.storage.vecdb#
genlayer.py.types#
Module that provides aliases for storage types and blockchain-specific types
- class genlayer.py.types.Address[source]#
Represents GenLayer Address
- SIZE = 20#
Constant that represents size of a Genlayer address
genlayer.std._internal#
- class genlayer.std._internal.ContractError[source]#
Represents “Contract error” result of a contract that is passed to validator function of
genlayer.std.run_nondet()
Validating leader output is the only place where contract can “handle” contract error
- __eq__(other)#
Return self==value.
- __hash__ = None#
- __repr__()#
Return repr(self).
- class genlayer.std._internal.ContractReturn[source]#
Represents a normal “Return” result of a contract that is passed to validator function of
genlayer.std.run_nondet()
- __eq__(other)#
Return self==value.
- __hash__ = None#
- __repr__()#
Return repr(self).
- class genlayer.std._internal.ResultCode[source]#
- __abs__()#
abs(self)
- __add__(value, /)#
Return self+value.
- __and__(value, /)#
Return self&value.
- __bool__()#
True if self else False
- __ceil__()#
Ceiling of an Integral returns itself.
- __dir__()#
Returns public methods and other interesting attributes.
- __divmod__(value, /)#
Return divmod(self, value).
- __eq__(value, /)#
Return self==value.
- __float__()#
float(self)
- __floor__()#
Flooring an Integral returns itself.
- __floordiv__(value, /)#
Return self//value.
- __format__(format_spec, /)#
Convert to a string according to format_spec.
- __ge__(value, /)#
Return self>=value.
- __getattribute__(name, /)#
Return getattr(self, name).
- __gt__(value, /)#
Return self>value.
- __hash__()#
Return hash(self).
- __index__()#
Return self converted to an integer, if self is suitable for use as an index into a list.
- __init__(*args, **kwds)#
- __int__()#
int(self)
- __invert__()#
~self
- __le__(value, /)#
Return self<=value.
- __lshift__(value, /)#
Return self<<value.
- __lt__(value, /)#
Return self<value.
- __mod__(value, /)#
Return self%value.
- __mul__(value, /)#
Return self*value.
- __ne__(value, /)#
Return self!=value.
- __neg__()#
-self
- __new__(value)#
- __or__(value, /)#
Return self|value.
- __pos__()#
+self
- __pow__(value, mod=None, /)#
Return pow(self, value, mod).
- __radd__(value, /)#
Return value+self.
- __rand__(value, /)#
Return value&self.
- __rdivmod__(value, /)#
Return divmod(value, self).
- __reduce_ex__(proto)#
Helper for pickle.
- __repr__()#
Return repr(self).
- __rfloordiv__(value, /)#
Return value//self.
- __rlshift__(value, /)#
Return value<<self.
- __rmod__(value, /)#
Return value%self.
- __rmul__(value, /)#
Return value*self.
- __ror__(value, /)#
Return value|self.
- __round__()#
Rounding an Integral returns itself.
Rounding with an ndigits argument also returns an integer.
- __rpow__(value, mod=None, /)#
Return pow(value, self, mod).
- __rrshift__(value, /)#
Return value>>self.
- __rshift__(value, /)#
Return self>>value.
- __rsub__(value, /)#
Return value-self.
- __rtruediv__(value, /)#
Return value/self.
- __rxor__(value, /)#
Return value^self.
- __sizeof__()#
Returns size in memory, in bytes.
- __str__()#
Return repr(self).
- __sub__(value, /)#
Return self-value.
- __truediv__(value, /)#
Return self/value.
- __trunc__()#
Truncating an Integral returns itself.
- __xor__(value, /)#
Return self^value.
- as_integer_ratio()#
Return a pair of integers, whose ratio is equal to the original int.
The ratio is in lowest terms and has a positive denominator.
>>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1)
- bit_count()#
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13) '0b1101' >>> (13).bit_count() 3
- bit_length()#
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()#
Returns self, the complex conjugate of any int.
- denominator#
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)#
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- imag#
the imaginary part of a complex number
- is_integer()#
Returns True. Exists for duck type compatibility with float.is_integer.
- numerator#
the numerator of a rational number in lowest terms
- real#
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)#
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
- exception genlayer.std._internal.Rollback[source]#
Exception that will be treated as a “Rollback”
- __cause__#
exception cause
- __context__#
exception context
- __getattribute__(name, /)#
Return getattr(self, name).
- __new__(**kwargs)#
- __reduce__()#
Helper for pickle.
- __repr__()#
Return repr(self).
- __str__()#
Return str(self).
- add_note()#
Exception.add_note(note) – add a note to the exception
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
genlayer.std._internal.prompt_ids#
- class genlayer.std._internal.prompt_ids.IntEnum[source]#
Enum where members are also (and must be) ints
- __abs__()#
abs(self)
- __add__(value, /)#
Return self+value.
- __and__(value, /)#
Return self&value.
- __bool__()#
True if self else False
- __ceil__()#
Ceiling of an Integral returns itself.
- __dir__()#
Returns public methods and other interesting attributes.
- __divmod__(value, /)#
Return divmod(self, value).
- __eq__(value, /)#
Return self==value.
- __float__()#
float(self)
- __floor__()#
Flooring an Integral returns itself.
- __floordiv__(value, /)#
Return self//value.
- __format__(format_spec, /)#
Convert to a string according to format_spec.
- __ge__(value, /)#
Return self>=value.
- __getattribute__(name, /)#
Return getattr(self, name).
- __gt__(value, /)#
Return self>value.
- __hash__()#
Return hash(self).
- __index__()#
Return self converted to an integer, if self is suitable for use as an index into a list.
- __init__(*args, **kwds)#
- __int__()#
int(self)
- __invert__()#
~self
- __le__(value, /)#
Return self<=value.
- __lshift__(value, /)#
Return self<<value.
- __lt__(value, /)#
Return self<value.
- __mod__(value, /)#
Return self%value.
- __mul__(value, /)#
Return self*value.
- __ne__(value, /)#
Return self!=value.
- __neg__()#
-self
- __new__(value)#
- __or__(value, /)#
Return self|value.
- __pos__()#
+self
- __pow__(value, mod=None, /)#
Return pow(self, value, mod).
- __radd__(value, /)#
Return value+self.
- __rand__(value, /)#
Return value&self.
- __rdivmod__(value, /)#
Return divmod(value, self).
- __reduce_ex__(proto)#
Helper for pickle.
- __repr__()#
Return repr(self).
- __rfloordiv__(value, /)#
Return value//self.
- __rlshift__(value, /)#
Return value<<self.
- __rmod__(value, /)#
Return value%self.
- __rmul__(value, /)#
Return value*self.
- __ror__(value, /)#
Return value|self.
- __round__()#
Rounding an Integral returns itself.
Rounding with an ndigits argument also returns an integer.
- __rpow__(value, mod=None, /)#
Return pow(value, self, mod).
- __rrshift__(value, /)#
Return value>>self.
- __rshift__(value, /)#
Return self>>value.
- __rsub__(value, /)#
Return value-self.
- __rtruediv__(value, /)#
Return value/self.
- __rxor__(value, /)#
Return value^self.
- __sizeof__()#
Returns size in memory, in bytes.
- __str__()#
Return repr(self).
- __sub__(value, /)#
Return self-value.
- __truediv__(value, /)#
Return self/value.
- __trunc__()#
Truncating an Integral returns itself.
- __xor__(value, /)#
Return self^value.
- as_integer_ratio()#
Return a pair of integers, whose ratio is equal to the original int.
The ratio is in lowest terms and has a positive denominator.
>>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1)
- bit_count()#
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13) '0b1101' >>> (13).bit_count() 3
- bit_length()#
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()#
Returns self, the complex conjugate of any int.
- denominator#
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)#
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- imag#
the imaginary part of a complex number
- is_integer()#
Returns True. Exists for duck type compatibility with float.is_integer.
- numerator#
the numerator of a rational number in lowest terms
- real#
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)#
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
- class genlayer.std._internal.prompt_ids.TemplateId[source]#
- __abs__()#
abs(self)
- __add__(value, /)#
Return self+value.
- __and__(value, /)#
Return self&value.
- __bool__()#
True if self else False
- __ceil__()#
Ceiling of an Integral returns itself.
- __dir__()#
Returns public methods and other interesting attributes.
- __divmod__(value, /)#
Return divmod(self, value).
- __eq__(value, /)#
Return self==value.
- __float__()#
float(self)
- __floor__()#
Flooring an Integral returns itself.
- __floordiv__(value, /)#
Return self//value.
- __format__(format_spec, /)#
Convert to a string according to format_spec.
- __ge__(value, /)#
Return self>=value.
- __getattribute__(name, /)#
Return getattr(self, name).
- __gt__(value, /)#
Return self>value.
- __hash__()#
Return hash(self).
- __index__()#
Return self converted to an integer, if self is suitable for use as an index into a list.
- __init__(*args, **kwds)#
- __int__()#
int(self)
- __invert__()#
~self
- __le__(value, /)#
Return self<=value.
- __lshift__(value, /)#
Return self<<value.
- __lt__(value, /)#
Return self<value.
- __mod__(value, /)#
Return self%value.
- __mul__(value, /)#
Return self*value.
- __ne__(value, /)#
Return self!=value.
- __neg__()#
-self
- __new__(value)#
- __or__(value, /)#
Return self|value.
- __pos__()#
+self
- __pow__(value, mod=None, /)#
Return pow(self, value, mod).
- __radd__(value, /)#
Return value+self.
- __rand__(value, /)#
Return value&self.
- __rdivmod__(value, /)#
Return divmod(value, self).
- __reduce_ex__(proto)#
Helper for pickle.
- __repr__()#
Return repr(self).
- __rfloordiv__(value, /)#
Return value//self.
- __rlshift__(value, /)#
Return value<<self.
- __rmod__(value, /)#
Return value%self.
- __rmul__(value, /)#
Return value*self.
- __ror__(value, /)#
Return value|self.
- __round__()#
Rounding an Integral returns itself.
Rounding with an ndigits argument also returns an integer.
- __rpow__(value, mod=None, /)#
Return pow(value, self, mod).
- __rrshift__(value, /)#
Return value>>self.
- __rshift__(value, /)#
Return self>>value.
- __rsub__(value, /)#
Return value-self.
- __rtruediv__(value, /)#
Return value/self.
- __rxor__(value, /)#
Return value^self.
- __sizeof__()#
Returns size in memory, in bytes.
- __str__()#
Return repr(self).
- __sub__(value, /)#
Return self-value.
- __truediv__(value, /)#
Return self/value.
- __trunc__()#
Truncating an Integral returns itself.
- __xor__(value, /)#
Return self^value.
- as_integer_ratio()#
Return a pair of integers, whose ratio is equal to the original int.
The ratio is in lowest terms and has a positive denominator.
>>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1)
- bit_count()#
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13) '0b1101' >>> (13).bit_count() 3
- bit_length()#
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()#
Returns self, the complex conjugate of any int.
- denominator#
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)#
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- imag#
the imaginary part of a complex number
- is_integer()#
Returns True. Exists for duck type compatibility with float.is_integer.
- numerator#
the numerator of a rational number in lowest terms
- real#
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)#
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
genlayer.std._internal.result_codes#
- class genlayer.std._internal.result_codes.IntEnum[source]#
Enum where members are also (and must be) ints
- __abs__()#
abs(self)
- __add__(value, /)#
Return self+value.
- __and__(value, /)#
Return self&value.
- __bool__()#
True if self else False
- __ceil__()#
Ceiling of an Integral returns itself.
- __dir__()#
Returns public methods and other interesting attributes.
- __divmod__(value, /)#
Return divmod(self, value).
- __eq__(value, /)#
Return self==value.
- __float__()#
float(self)
- __floor__()#
Flooring an Integral returns itself.
- __floordiv__(value, /)#
Return self//value.
- __format__(format_spec, /)#
Convert to a string according to format_spec.
- __ge__(value, /)#
Return self>=value.
- __getattribute__(name, /)#
Return getattr(self, name).
- __gt__(value, /)#
Return self>value.
- __hash__()#
Return hash(self).
- __index__()#
Return self converted to an integer, if self is suitable for use as an index into a list.
- __init__(*args, **kwds)#
- __int__()#
int(self)
- __invert__()#
~self
- __le__(value, /)#
Return self<=value.
- __lshift__(value, /)#
Return self<<value.
- __lt__(value, /)#
Return self<value.
- __mod__(value, /)#
Return self%value.
- __mul__(value, /)#
Return self*value.
- __ne__(value, /)#
Return self!=value.
- __neg__()#
-self
- __new__(value)#
- __or__(value, /)#
Return self|value.
- __pos__()#
+self
- __pow__(value, mod=None, /)#
Return pow(self, value, mod).
- __radd__(value, /)#
Return value+self.
- __rand__(value, /)#
Return value&self.
- __rdivmod__(value, /)#
Return divmod(value, self).
- __reduce_ex__(proto)#
Helper for pickle.
- __repr__()#
Return repr(self).
- __rfloordiv__(value, /)#
Return value//self.
- __rlshift__(value, /)#
Return value<<self.
- __rmod__(value, /)#
Return value%self.
- __rmul__(value, /)#
Return value*self.
- __ror__(value, /)#
Return value|self.
- __round__()#
Rounding an Integral returns itself.
Rounding with an ndigits argument also returns an integer.
- __rpow__(value, mod=None, /)#
Return pow(value, self, mod).
- __rrshift__(value, /)#
Return value>>self.
- __rshift__(value, /)#
Return self>>value.
- __rsub__(value, /)#
Return value-self.
- __rtruediv__(value, /)#
Return value/self.
- __rxor__(value, /)#
Return value^self.
- __sizeof__()#
Returns size in memory, in bytes.
- __str__()#
Return repr(self).
- __sub__(value, /)#
Return self-value.
- __truediv__(value, /)#
Return self/value.
- __trunc__()#
Truncating an Integral returns itself.
- __xor__(value, /)#
Return self^value.
- as_integer_ratio()#
Return a pair of integers, whose ratio is equal to the original int.
The ratio is in lowest terms and has a positive denominator.
>>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1)
- bit_count()#
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13) '0b1101' >>> (13).bit_count() 3
- bit_length()#
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()#
Returns self, the complex conjugate of any int.
- denominator#
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)#
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- imag#
the imaginary part of a complex number
- is_integer()#
Returns True. Exists for duck type compatibility with float.is_integer.
- numerator#
the numerator of a rational number in lowest terms
- real#
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)#
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
- class genlayer.std._internal.result_codes.ResultCode[source]#
- __abs__()#
abs(self)
- __add__(value, /)#
Return self+value.
- __and__(value, /)#
Return self&value.
- __bool__()#
True if self else False
- __ceil__()#
Ceiling of an Integral returns itself.
- __dir__()#
Returns public methods and other interesting attributes.
- __divmod__(value, /)#
Return divmod(self, value).
- __eq__(value, /)#
Return self==value.
- __float__()#
float(self)
- __floor__()#
Flooring an Integral returns itself.
- __floordiv__(value, /)#
Return self//value.
- __format__(format_spec, /)#
Convert to a string according to format_spec.
- __ge__(value, /)#
Return self>=value.
- __getattribute__(name, /)#
Return getattr(self, name).
- __gt__(value, /)#
Return self>value.
- __hash__()#
Return hash(self).
- __index__()#
Return self converted to an integer, if self is suitable for use as an index into a list.
- __init__(*args, **kwds)#
- __int__()#
int(self)
- __invert__()#
~self
- __le__(value, /)#
Return self<=value.
- __lshift__(value, /)#
Return self<<value.
- __lt__(value, /)#
Return self<value.
- __mod__(value, /)#
Return self%value.
- __mul__(value, /)#
Return self*value.
- __ne__(value, /)#
Return self!=value.
- __neg__()#
-self
- __new__(value)#
- __or__(value, /)#
Return self|value.
- __pos__()#
+self
- __pow__(value, mod=None, /)#
Return pow(self, value, mod).
- __radd__(value, /)#
Return value+self.
- __rand__(value, /)#
Return value&self.
- __rdivmod__(value, /)#
Return divmod(value, self).
- __reduce_ex__(proto)#
Helper for pickle.
- __repr__()#
Return repr(self).
- __rfloordiv__(value, /)#
Return value//self.
- __rlshift__(value, /)#
Return value<<self.
- __rmod__(value, /)#
Return value%self.
- __rmul__(value, /)#
Return value*self.
- __ror__(value, /)#
Return value|self.
- __round__()#
Rounding an Integral returns itself.
Rounding with an ndigits argument also returns an integer.
- __rpow__(value, mod=None, /)#
Return pow(value, self, mod).
- __rrshift__(value, /)#
Return value>>self.
- __rshift__(value, /)#
Return self>>value.
- __rsub__(value, /)#
Return value-self.
- __rtruediv__(value, /)#
Return value/self.
- __rxor__(value, /)#
Return value^self.
- __sizeof__()#
Returns size in memory, in bytes.
- __str__()#
Return repr(self).
- __sub__(value, /)#
Return self-value.
- __truediv__(value, /)#
Return self/value.
- __trunc__()#
Truncating an Integral returns itself.
- __xor__(value, /)#
Return self^value.
- as_integer_ratio()#
Return a pair of integers, whose ratio is equal to the original int.
The ratio is in lowest terms and has a positive denominator.
>>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1)
- bit_count()#
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13) '0b1101' >>> (13).bit_count() 3
- bit_length()#
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()#
Returns self, the complex conjugate of any int.
- denominator#
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)#
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- imag#
the imaginary part of a complex number
- is_integer()#
Returns True. Exists for duck type compatibility with float.is_integer.
- numerator#
the numerator of a rational number in lowest terms
- real#
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)#
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
- class genlayer.std._internal.result_codes.StorageType[source]#
- __abs__()#
abs(self)
- __add__(value, /)#
Return self+value.
- __and__(value, /)#
Return self&value.
- __bool__()#
True if self else False
- __ceil__()#
Ceiling of an Integral returns itself.
- __dir__()#
Returns public methods and other interesting attributes.
- __divmod__(value, /)#
Return divmod(self, value).
- __eq__(value, /)#
Return self==value.
- __float__()#
float(self)
- __floor__()#
Flooring an Integral returns itself.
- __floordiv__(value, /)#
Return self//value.
- __format__(format_spec, /)#
Convert to a string according to format_spec.
- __ge__(value, /)#
Return self>=value.
- __getattribute__(name, /)#
Return getattr(self, name).
- __gt__(value, /)#
Return self>value.
- __hash__()#
Return hash(self).
- __index__()#
Return self converted to an integer, if self is suitable for use as an index into a list.
- __init__(*args, **kwds)#
- __int__()#
int(self)
- __invert__()#
~self
- __le__(value, /)#
Return self<=value.
- __lshift__(value, /)#
Return self<<value.
- __lt__(value, /)#
Return self<value.
- __mod__(value, /)#
Return self%value.
- __mul__(value, /)#
Return self*value.
- __ne__(value, /)#
Return self!=value.
- __neg__()#
-self
- __new__(value)#
- __or__(value, /)#
Return self|value.
- __pos__()#
+self
- __pow__(value, mod=None, /)#
Return pow(self, value, mod).
- __radd__(value, /)#
Return value+self.
- __rand__(value, /)#
Return value&self.
- __rdivmod__(value, /)#
Return divmod(value, self).
- __reduce_ex__(proto)#
Helper for pickle.
- __repr__()#
Return repr(self).
- __rfloordiv__(value, /)#
Return value//self.
- __rlshift__(value, /)#
Return value<<self.
- __rmod__(value, /)#
Return value%self.
- __rmul__(value, /)#
Return value*self.
- __ror__(value, /)#
Return value|self.
- __round__()#
Rounding an Integral returns itself.
Rounding with an ndigits argument also returns an integer.
- __rpow__(value, mod=None, /)#
Return pow(value, self, mod).
- __rrshift__(value, /)#
Return value>>self.
- __rshift__(value, /)#
Return self>>value.
- __rsub__(value, /)#
Return value-self.
- __rtruediv__(value, /)#
Return value/self.
- __rxor__(value, /)#
Return value^self.
- __sizeof__()#
Returns size in memory, in bytes.
- __str__()#
Return repr(self).
- __sub__(value, /)#
Return self-value.
- __truediv__(value, /)#
Return self/value.
- __trunc__()#
Truncating an Integral returns itself.
- __xor__(value, /)#
Return self^value.
- as_integer_ratio()#
Return a pair of integers, whose ratio is equal to the original int.
The ratio is in lowest terms and has a positive denominator.
>>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1)
- bit_count()#
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13) '0b1101' >>> (13).bit_count() 3
- bit_length()#
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()#
Returns self, the complex conjugate of any int.
- denominator#
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)#
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- imag#
the imaginary part of a complex number
- is_integer()#
Returns True. Exists for duck type compatibility with float.is_integer.
- numerator#
the numerator of a rational number in lowest terms
- real#
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)#
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
genlayer.std._internal.storage#
- genlayer.std._internal.storage.STORAGE_MAN = <genlayer.std._internal.storage._ActualStorageMan object>#
Storage slots manager that provides an access to the “Host” (node) state
genlayer.std._wasi#
genlayer.std.advanced#
This module provides some “advanced” features that can be used for optimizations
If you are using something “advanced” you must know what you do
- class genlayer.std.advanced.AlreadySerializedResult[source]#
If contract method returns instance of this class, calldata encoding won’t be performed. Instead stored bytes will be passed as is
- __add__(value, /)#
Return self+value.
- __buffer__(flags, /)#
Return a buffer object that exposes the underlying memory of the object.
- __bytes__()#
Convert this value to exact type bytes.
- __contains__(key, /)#
Return bool(key in self).
- __eq__(value, /)#
Return self==value.
- __ge__(value, /)#
Return self>=value.
- __getattribute__(name, /)#
Return getattr(self, name).
- __getitem__(key, /)#
Return self[key].
- __gt__(value, /)#
Return self>value.
- __hash__()#
Return hash(self).
- __iter__()#
Implement iter(self).
- __le__(value, /)#
Return self<=value.
- __len__()#
Return len(self).
- __lt__(value, /)#
Return self<value.
- __mod__(value, /)#
Return self%value.
- __mul__(value, /)#
Return self*value.
- __ne__(value, /)#
Return self!=value.
- __repr__()#
Return repr(self).
- __rmod__(value, /)#
Return value%self.
- __rmul__(value, /)#
Return value*self.
- __str__()#
Return str(self).
- capitalize() copy of B #
Return a copy of B with only its first character capitalized (ASCII) and the rest lower-cased.
- center(width, fillchar=b' ', /)#
Return a centered string of length width.
Padding is done using the specified fill character.
- count(sub[, start[, end]]) int #
Return the number of non-overlapping occurrences of subsection sub in bytes B[start:end]. Optional arguments start and end are interpreted as in slice notation.
- decode(encoding='utf-8', errors='strict')#
Decode the bytes using the codec registered for encoding.
- encoding
The encoding with which to decode the bytes.
- errors
The error handling scheme to use for the handling of decoding errors. The default is ‘strict’ meaning that decoding errors raise a UnicodeDecodeError. Other possible values are ‘ignore’ and ‘replace’ as well as any other name registered with codecs.register_error that can handle UnicodeDecodeErrors.
- endswith(suffix[, start[, end]]) bool #
Return True if B ends with the specified suffix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. suffix can also be a tuple of bytes to try.
- expandtabs(tabsize=8)#
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
- find(sub[, start[, end]]) int #
Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- fromhex()#
Create a bytes object from a string of hexadecimal numbers.
Spaces between two numbers are accepted. Example: bytes.fromhex(‘B9 01EF’) -> b’\xb9\x01\xef’.
- hex()#
Create a string of hexadecimal numbers from a bytes object.
- sep
An optional single character or byte to separate hex bytes.
- bytes_per_sep
How many bytes between separators. Positive values count from the right, negative values count from the left.
Example: >>> value = b’xb9x01xef’ >>> value.hex() ‘b901ef’ >>> value.hex(‘:’) ‘b9:01:ef’ >>> value.hex(‘:’, 2) ‘b9:01ef’ >>> value.hex(‘:’, -2) ‘b901:ef’
- index(sub[, start[, end]]) int #
Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the subsection is not found.
- isalnum() bool #
Return True if all characters in B are alphanumeric and there is at least one character in B, False otherwise.
- isalpha() bool #
Return True if all characters in B are alphabetic and there is at least one character in B, False otherwise.
- isdigit() bool #
Return True if all characters in B are digits and there is at least one character in B, False otherwise.
- islower() bool #
Return True if all cased characters in B are lowercase and there is at least one cased character in B, False otherwise.
- isspace() bool #
Return True if all characters in B are whitespace and there is at least one character in B, False otherwise.
- istitle() bool #
Return True if B is a titlecased string and there is at least one character in B, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise.
- isupper() bool #
Return True if all cased characters in B are uppercase and there is at least one cased character in B, False otherwise.
- join(iterable_of_bytes, /)#
Concatenate any number of bytes objects.
The bytes whose method is called is inserted in between each pair.
The result is returned as a new bytes object.
Example: b’.’.join([b’ab’, b’pq’, b’rs’]) -> b’ab.pq.rs’.
- ljust(width, fillchar=b' ', /)#
Return a left-justified string of length width.
Padding is done using the specified fill character.
- lower() copy of B #
Return a copy of B with all ASCII characters converted to lowercase.
- lstrip(bytes=None, /)#
Strip leading bytes contained in the argument.
If the argument is omitted or None, strip leading ASCII whitespace.
- static maketrans(frm, to, /)#
Return a translation table useable for the bytes or bytearray translate method.
The returned table will be one where each byte in frm is mapped to the byte at the same position in to.
The bytes objects frm and to must be of the same length.
- partition(sep, /)#
Partition the bytes into three parts using the given separator.
This will search for the separator sep in the bytes. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original bytes object and two empty bytes objects.
- removeprefix(prefix, /)#
Return a bytes object with the given prefix string removed if present.
If the bytes starts with the prefix string, return bytes[len(prefix):]. Otherwise, return a copy of the original bytes.
- removesuffix(suffix, /)#
Return a bytes object with the given suffix string removed if present.
If the bytes ends with the suffix string and that suffix is not empty, return bytes[:-len(prefix)]. Otherwise, return a copy of the original bytes.
- replace(old, new, count=-1, /)#
Return a copy with all occurrences of substring old replaced by new.
- count
Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are replaced.
- rfind(sub[, start[, end]]) int #
Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- rindex(sub[, start[, end]]) int #
Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.
Raise ValueError when the subsection is not found.
- rjust(width, fillchar=b' ', /)#
Return a right-justified string of length width.
Padding is done using the specified fill character.
- rpartition(sep, /)#
Partition the bytes into three parts using the given separator.
This will search for the separator sep in the bytes, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty bytes objects and the original bytes object.
- rsplit(sep=None, maxsplit=-1)#
Return a list of the sections in the bytes, using sep as the delimiter.
- sep
The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).
- maxsplit
Maximum number of splits to do. -1 (the default value) means no limit.
Splitting is done starting at the end of the bytes and working to the front.
- rstrip(bytes=None, /)#
Strip trailing bytes contained in the argument.
If the argument is omitted or None, strip trailing ASCII whitespace.
- split(sep=None, maxsplit=-1)#
Return a list of the sections in the bytes, using sep as the delimiter.
- sep
The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).
- maxsplit
Maximum number of splits to do. -1 (the default value) means no limit.
- splitlines(keepends=False)#
Return a list of the lines in the bytes, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and true.
- startswith(prefix[, start[, end]]) bool #
Return True if B starts with the specified prefix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. prefix can also be a tuple of bytes to try.
- strip(bytes=None, /)#
Strip leading and trailing bytes contained in the argument.
If the argument is omitted or None, strip leading and trailing ASCII whitespace.
- swapcase() copy of B #
Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.
- title() copy of B #
Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.
- translate(table, /, delete=b'')#
Return a copy with each character mapped by the given translation table.
- table
Translation table, which must be a bytes object of length 256.
All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.
- upper() copy of B #
Return a copy of B with all ASCII characters converted to uppercase.
- zfill(width, /)#
Pad a numeric string with zeros on the left, to fill a field of the given width.
The original string is never truncated.
- class genlayer.std.advanced.ContractError[source]#
Represents “Contract error” result of a contract that is passed to validator function of
genlayer.std.run_nondet()
Validating leader output is the only place where contract can “handle” contract error
- __eq__(other)#
Return self==value.
- __hash__ = None#
- __repr__()#
Return repr(self).
- class genlayer.std.advanced.ContractReturn[source]#
Represents a normal “Return” result of a contract that is passed to validator function of
genlayer.std.run_nondet()
- __eq__(other)#
Return self==value.
- __hash__ = None#
- __repr__()#
Return repr(self).
- exception genlayer.std.advanced.Rollback[source]#
Exception that will be treated as a “Rollback”
- __cause__#
exception cause
- __context__#
exception context
- __getattribute__(name, /)#
Return getattr(self, name).
- __new__(**kwargs)#
- __reduce__()#
Helper for pickle.
- __repr__()#
Return repr(self).
- __str__()#
Return str(self).
- add_note()#
Exception.add_note(note) – add a note to the exception
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- genlayer.std.advanced.dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)[source]#
Add dunder methods based on the fields defined in the class.
Examines PEP 526 __annotations__ to determine fields.
If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method is added. If frozen is true, fields may not be assigned to after instance creation. If match_args is true, the __match_args__ tuple is added. If kw_only is true, then by default all fields are keyword-only. If slots is true, a new class with a __slots__ attribute is returned.
- genlayer.std.advanced.run_nondet(leader_fn: Callable[[], T], validator_fn: Callable[[ContractReturn | Rollback | ContractError], bool]) Lazy [source]#
Most generic user-friendly api to execute a non-deterministic block
- Parameters:
leader_fn (Callable[[], T]) – function that is executed in the leader
validator_fn (Callable[[ContractReturn | Rollback | ContractError], bool]) – function that is executed in the validator that also checks leader result
- Return type:
Uses cloudpickle to pass a “function” to sub VM
- genlayer.std.advanced.validator_handle_rollbacks_and_errors_default(fn: Callable[[], Any], leaders_result: ContractReturn | Rollback | ContractError) tuple[Any, Any] [source]#
Default function to handle rollbacks and contract errors
Errors and rollbacks are always checked for strict equality, which means that it’s user responsibility to dump least possible text in there
- Returns:
ContractReturn
.data iff both results are not errors/rollbacks- Return type:
genlayer.std.eq_principles#
- genlayer.std.eq_principles.eq_principle_prompt_comparative(fn: Callable[[], Any], principle: str) str #
Comparative equivalence principle that utilizes NLP for verifying that results are equivalent
- Parameters:
- Return type:
Note
As leader results are encoded as calldata,
format()
is used for string representation. However, operating on strings by yourself is more safe in generalNote
supports
.lazy()
version, which will returnLazy
- genlayer.std.eq_principles.eq_principle_prompt_non_comparative(fn: Callable[[], str], *, task: str, criteria: str) str #
Non-comparative equivalence principle that must cover most common use cases
Both leader and validator finish their execution via NLP, that is used to perform
task
oninput
. Leader just executes this task, but the validator checks if task was performed with integrity. This principle is useful when task is subjectiveNote
supports
.lazy()
version, which will returnLazy
- Return type:
genlayer.std.eth#
- genlayer.std.eth.eth_contract(contr: EthContractDeclaration) Callable[[Address], EthContractProxy] #
@gl.eth_contract class Ghost: class View: pass class Write: def test(self, x: u256, /) -> None: ...
- Return type:
genlayer.std.genvm_contracts#
- class genlayer.std.genvm_contracts.ContractAt[source]#
Provides a way to call view methods and send transactions to GenVM contracts
- emit(**data: Unpack[TransactionDataKwArgs])[source]#
Namespace with write message
- class genlayer.std.genvm_contracts.DeploymentTransactionDataKwArgs[source]#
Class for representing parameters of
deploy_contract
- salt_nonce: NotRequired[u256 | Literal[0]]#
iff it is provided and does not equal to \(0\) then
Address
of deployed contract will be known ahead of time. It will depend on this field
- class genlayer.std.genvm_contracts.TransactionDataKwArgs[source]#
Built-in parameters of all transaction messages that a contract can emit
Warning
parameters are subject to change!
- genlayer.std.genvm_contracts.contract_interface(_contr: GenVMContractDeclaration) Callable[[Address], GenVMContractProxy] [source]#
This decorator produces an “interface” for other GenVM contracts. It has no semantical value, but can be used for auto completion and type checks
@gl.contract_interface class MyContract: class View: def view_meth(self, i: int) -> int: ... class Write: def write_meth(self, i: int) -> None: ...
- genlayer.std.genvm_contracts.deploy_contract(*, code: bytes, args: Sequence[Any] = [], kwargs: Mapping[str, Any] = {}) None [source]#
- genlayer.std.genvm_contracts.deploy_contract(*, code: bytes, args: Sequence[Any] = [], salt_nonce: Literal[0], kwargs: Mapping[str, Any] = {}) Address
Function for deploying new genvm contracts
- Parameters:
code – code (i.e. contents of a python file) of the contract
- Returns:
address of new contract iff
salt_nonce
was provided
genlayer.std.nondet_fns#
- genlayer.std.nondet_fns.exec_prompt(prompt: str, **config: Unpack[ExecPromptKwArgs]) str #
API to execute a prompt (perform NLP)
- Parameters:
prompt (
str
) – prompt itself**config (
ExecPromptKwArgs
) – configuration
- Return type:
str
Note
supports
.lazy()
version, which will returnLazy
- genlayer.std.nondet_fns.get_webpage(url: str, **config: Unpack[GetWebpageKwArgs]) str #
API to get a webpage after rendering it
- Parameters:
url (
str
) – url of website**config (
GetWebpageKwArgs
) – configuration
- Return type:
str
Note
supports
.lazy()
version, which will returnLazy
genlayer.std.runner#
Module that is used to run python contracts in the default way