Skip to content

Module dev_lua.erl

A device that calls a Lua module upon a request and returns the result.

Function Index

ao_core_resolution_from_lua_test/0*Run an AO-Core resolution from the Lua environment.
ao_core_sandbox_test/0*Run an AO-Core resolution from the Lua environment.
aos_authority_not_trusted_test/0*
aos_process_benchmark_test_/0*Benchmark the performance of Lua executions.
compute/4*Call the Lua script with the given arguments.
decode/2Decode a Lua result into a HyperBEAM structured@1.0 message.
decode_params/3*Decode a list of Lua references, as found in a stack trace, into a list of Erlang terms.
decode_stacktrace/3*Parse a Lua stack trace into a list of messages.
decode_stacktrace/4*
direct_benchmark_test/0*Benchmark the performance of Lua executions.
encode/2Encode a HyperBEAM structured@1.0 message into a Lua term.
ensure_initialized/3*Initialize the Lua VM if it is not already initialized.
error_response_test/0*
find_modules/2*Find the script in the base message, either by ID or by string.
functions/3Return a list of all functions in the Lua environment.
generate_lua_process/2*Generate a Lua process message.
generate_stack/1*Generate a stack message for the Lua process.
generate_test_message/2*Generate a test message for a Lua process.
info/1All keys that are not directly available in the base message are resolved by calling the Lua function in the module of the same name.
init/3Initialize the device state, loading the script into memory if it is a reference.
initialize/3*Initialize a new Lua state with a given base message and module.
invoke_aos_test/0*
invoke_non_compute_key_test/0*Call a non-compute key on a Lua device message and ensure that the function of the same name in the script is called.
load_modules/2*Load a list of modules for installation into the Lua VM.
load_modules/3*
load_modules_by_id/0*
load_modules_by_id_test_/0*
lua_http_hook_test/0*Use a Lua module as a hook on the HTTP server via ~meta@1.0.
multiple_modules_test/0*
normalize/3Restore the Lua state from a snapshot, if it exists.
process_response/3*Process a response to a Luerl invocation.
pure_lua_process_benchmark/0*
pure_lua_process_benchmark_test_/0*
pure_lua_process_test/0*Call a process whose execution-device is set to lua@5.3a.
sandbox/3*Sandbox (render inoperable) a set of Lua functions.
sandboxed_failure_test/0*
simple_invocation_test/0*
snapshot/3Snapshot the Lua state from a live computation.

Function Details

ao_core_resolution_from_lua_test/0 *

ao_core_resolution_from_lua_test() -> any()

Run an AO-Core resolution from the Lua environment.

ao_core_sandbox_test/0 *

ao_core_sandbox_test() -> any()

Run an AO-Core resolution from the Lua environment.

aos_authority_not_trusted_test/0 *

aos_authority_not_trusted_test() -> any()

aos_process_benchmark_test_/0 *

aos_process_benchmark_test_() -> any()

Benchmark the performance of Lua executions.

compute/4 *

compute(Key, RawBase, Req, Opts) -> any()

Call the Lua script with the given arguments.

decode/2

decode(EncMsg, Opts) -> any()

Decode a Lua result into a HyperBEAM structured@1.0 message.

decode_params/3 *

decode_params(Rest, State, Opts) -> any()

Decode a list of Lua references, as found in a stack trace, into a list of Erlang terms.

decode_stacktrace/3 *

decode_stacktrace(StackTrace, State0, Opts) -> any()

Parse a Lua stack trace into a list of messages.

decode_stacktrace/4 *

decode_stacktrace(Rest, State, Acc, Opts) -> any()

direct_benchmark_test/0 *

direct_benchmark_test() -> any()

Benchmark the performance of Lua executions.

encode/2

encode(Map, Opts) -> any()

Encode a HyperBEAM structured@1.0 message into a Lua term.

ensure_initialized/3 *

ensure_initialized(Base, Req, Opts) -> any()

Initialize the Lua VM if it is not already initialized. Optionally takes the script as a Binary string. If not provided, the module will be loaded from the base message.

error_response_test/0 *

error_response_test() -> any()

find_modules/2 *

find_modules(Base, Opts) -> any()

Find the script in the base message, either by ID or by string.

functions/3

functions(Base, Req, Opts) -> any()

Return a list of all functions in the Lua environment.

generate_lua_process/2 *

generate_lua_process(File, Opts) -> any()

Generate a Lua process message.

generate_stack/1 *

generate_stack(File) -> any()

Generate a stack message for the Lua process.

generate_test_message/2 *

generate_test_message(Process, Opts) -> any()

Generate a test message for a Lua process.

info/1

info(Base) -> any()

All keys that are not directly available in the base message are resolved by calling the Lua function in the module of the same name. Additionally, we exclude the keys, set, encode and decode functions which are message@1.0 core functions, and Lua public utility functions.

init/3

init(Base, Req, Opts) -> any()

Initialize the device state, loading the script into memory if it is a reference.

initialize/3 *

initialize(Base, Modules, Opts) -> any()

Initialize a new Lua state with a given base message and module.

invoke_aos_test/0 *

invoke_aos_test() -> any()

invoke_non_compute_key_test/0 *

invoke_non_compute_key_test() -> any()

Call a non-compute key on a Lua device message and ensure that the function of the same name in the script is called.

load_modules/2 *

load_modules(Modules, Opts) -> any()

Load a list of modules for installation into the Lua VM.

load_modules/3 *

load_modules(Rest, Opts, Acc) -> any()

load_modules_by_id/0 *

load_modules_by_id() -> any()

load_modules_by_id_test_/0 *

load_modules_by_id_test_() -> any()

lua_http_hook_test/0 *

lua_http_hook_test() -> any()

Use a Lua module as a hook on the HTTP server via ~meta@1.0.

multiple_modules_test/0 *

multiple_modules_test() -> any()

normalize/3

normalize(Base, Req, RawOpts) -> any()

Restore the Lua state from a snapshot, if it exists.

process_response/3 *

process_response(X1, Priv, Opts) -> any()

Process a response to a Luerl invocation. Returns the typical AO-Core HyperBEAM response format.

pure_lua_process_benchmark/0 *

pure_lua_process_benchmark() -> any()

pure_lua_process_benchmark_test_/0 *

pure_lua_process_benchmark_test_() -> any()

pure_lua_process_test/0 *

pure_lua_process_test() -> any()

Call a process whose execution-device is set to lua@5.3a.

sandbox/3 *

sandbox(State, Map, Opts) -> any()

Sandbox (render inoperable) a set of Lua functions. Each function is referred to as if it is a path in AO-Core, with its value being what to return to the caller. For example, 'os.exit' would be referred to as referred to as os/exit. If preferred, a list rather than a map may be provided, in which case the functions all return sandboxed.

sandboxed_failure_test/0 *

sandboxed_failure_test() -> any()

simple_invocation_test/0 *

simple_invocation_test() -> any()

snapshot/3

snapshot(Base, Req, Opts) -> any()

Snapshot the Lua state from a live computation. Normalizes its priv state element, then serializes the state to a binary.