Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
AIR
Overview
This crate defines the core of the AIR interpreter intended to execute scripts to control execution flow in the Fluence network. From a high level point of view, the interpreter can be considered as a state transition function that takes two states, merges them, and then produces a new state.
Interpreter interface
This interpreter has only one export function called invoke and no import functions. The export function has the following signature:
As it was already mentioned in the previous section, invoke takes two states (prev_data and current_data) and returns a new state (new_data). Additionally, it takes AIR script that should be executed, some run parameters (such as init_peer_id and current_peer_id), and call_results, results of services calling. As a result it provides the IntepreterOutcome structure described in the code snippet above.
Main properties
Let's consider the interpreter with respect to data first, because previous, current and resulted data are the most interesting parts of arguments and the outcome. Assuming X is a set of all possible values that data could have, we'll denote executed_air export function as f: X * X -> X. It could be seen that with respect to data f forms a magma.
Even more, f is an idempotent non-commutative monoid, because:
fis associative:forall a, b, c from X: f(f(a,b), c) = f(a, f(b,c))fhas a neutral element:exists e, forall a from X: f(e, a) = f(a, e) = a, whereeis a data with an empty tracefis a non-commutative function:exists a, b from X: f(a, b) != f(b, a)Xcould be constructed from a four based elements that form theExecutedStateenum (that why this monoid is free)fsatisfies these idempotence properties:forall x from X: f(x, x) = xforall a, b from X: f(a, b) = c, f(c, b) = c, f(c, a) = c
Interaction with the interpreter
The interpreter allows a peer (either a node or a browser) to call service asynchronously by collecting all arguments and other necessary stuff from each call instruction that could be called during the execution and return them in InterpreterOutcome. A host should then execute them at any time and call back the interpreter providing executed service results as the call_results argument.
A scheme of interacting with the interpreter should look as follows:
-
For each new
current_datareceived from a network, a host should call the interpreter with correspondingprev_dataandcurrent_dataand emptycall_results.prev_datahere is lastnew_datareturned from the interpreter. -
Having obtained a result of the interpreter, there could be non-empty
next_peer_idsand non-emptycall_requestsinInterpreterOutcome:- re
next_peer_pks: it's a peer duty to decide whether it should send particle after each interpreter call or after the whole particle execution, i.e. after completing allcall_requests. - re
call_requests:call_requestsis aHashMap<u32, CallRequestParams>and it's important for host to keep that correspondence betweenu32and callCallRequestParams, because they should be used when results are passed back on step 3.
- re
-
If
call_requestswas non-empty on step 2, a peer must call the interpreter again with supplied call results (HashMap<u32, CallServiceResult>) following next rules:
- current_data here shouldn't be supplied (actually, it could be supplied because of
fis idempotent, but it's unnecessary and slow down a bit an interpreter execution) - it's not necessary to supply
call_resultsbefore handling the next particle, actually a peer could supply it in any moment - a peer must preserve
new_dataafter each execution step. It's important, becausefis non-commutative and the interpreter save an additional info indataexpecting to see the resulted data back asprev_dataon the next launch. Then this flow should be repeated starting from point 2.
- If
call_requestswas empty, the whole execution is completed,new_datamust be preserved and particle send for allnew_peer_pksas usual.
An example of interaction can be found in tests.