2023-02-22 19:54:47 +03:00
|
|
|
# AquaVM
|
|
|
|
|
2020-12-29 18:20:20 +03:00
|
|
|
[](https://crates.io/crates/air-interpreter-wasm)
|
2021-06-02 14:04:41 +03:00
|
|
|
[](https://www.npmjs.com/package/@fluencelabs/avm)
|
2023-03-02 21:22:32 +02:00
|
|
|
[](https://coveralls.io/github/fluencelabs/aquavm?branch=master)
|
2020-12-29 18:20:20 +03:00
|
|
|
|
2023-03-02 13:31:05 +02:00
|
|
|
AquaVM executes compiled [Aqua](https://github.com/fluencelabs/aqua), i.e., Aqua
|
|
|
|
Intermediate Representation (AIR) scripts, and plays an integral role in the
|
|
|
|
implementation of the [Fluence](https://fluence.network) peer-to-peer compute
|
|
|
|
protocol. Specifically, AquaVM allows expressing network choreography in scripts
|
|
|
|
and composing distributed, peer-to-peer hosted services. Moreover, AquaVM plays
|
|
|
|
a significant role in facilitating _function addressability_ in the Fluence
|
|
|
|
network, see Figure 1.
|
2020-11-12 18:25:34 +03:00
|
|
|
|
2023-03-02 13:31:05 +02:00
|
|
|
<img alt="AquaVM & AIR model" src="images/aquavm_air_model.png" />
|
2020-09-30 22:24:30 +03:00
|
|
|
|
2022-05-14 17:12:48 +03:00
|
|
|
**Figure 1: Stylized AquaVM And AIR Model**
|
2020-11-05 15:01:27 +03:00
|
|
|
|
2023-03-02 13:31:05 +02:00
|
|
|
Since AquaVM compiles to Wasm, it can run in both client, such as browsers and
|
|
|
|
Node.js apps, and server environments.
|
2020-11-12 18:04:36 +03:00
|
|
|
|
2022-05-14 17:12:48 +03:00
|
|
|
## AquaVM: Interpreter Execution Model
|
2020-11-05 15:01:27 +03:00
|
|
|
|
2023-03-02 13:31:05 +02:00
|
|
|
AquaVM's execution model facilitates Fluence protocol's data push model
|
|
|
|
implemented as a _particle_, i.e., a smart packet comprised of data, AIR, and
|
|
|
|
some metadata. In this context, AquaVM can be viewed as a pure state transition
|
|
|
|
function that facilitates particle updates, which includes state management of
|
|
|
|
particle data by taking previous and current state to produce a new state and an
|
|
|
|
updated list of peers and call requests in the remaining AIR workflow. In
|
|
|
|
addition to local service call execution, AquaVM handles requests from remote
|
|
|
|
peers, e.g., as a part of a parallel execution block, to call local services and
|
|
|
|
handle the future response, see Figure 2.
|
2020-11-05 15:01:27 +03:00
|
|
|
|
2022-05-14 17:12:48 +03:00
|
|
|
<img alt="interpreter execution model" src="images/interpreter_execution_model.png"/>
|
2020-11-05 15:01:27 +03:00
|
|
|
|
2023-02-22 19:54:47 +03:00
|
|
|
**Figure 2: AquaVM Interpreter Execution Model**
|
2022-05-14 17:12:48 +03:00
|
|
|
|
2023-03-02 13:31:05 +02:00
|
|
|
In summary, the AquaVM execution model handles the topological hops for simple
|
2023-09-25 12:19:27 +02:00
|
|
|
and advanced composition patterns, such as (async) parallel service execution on
|
2023-03-02 13:31:05 +02:00
|
|
|
one or multiple peers.
|
2020-11-05 15:01:27 +03:00
|
|
|
|
2023-02-22 19:54:47 +03:00
|
|
|
## Aquamarine Intermediate Representation (AIR): IR for P2P Systems
|
2020-11-05 15:01:27 +03:00
|
|
|
|
2023-03-02 13:31:05 +02:00
|
|
|
AIR is an [S-expression](https://www.s-expressions.org/home)-based low-level
|
|
|
|
language with binary form to come. It currently consists of fourteen
|
|
|
|
instructions with more instructions to come. Semantics of AIR is inspired by
|
|
|
|
[π-calculus](https://en.wikipedia.org/wiki/%CE%A0-calculus),
|
|
|
|
[λ-calculus](https://en.wikipedia.org/wiki/Lambda_calculus), and
|
|
|
|
[category theory](https://en.wikipedia.org/wiki/Category_theory). Its syntax is
|
|
|
|
inspired by
|
|
|
|
[Wasm Text Format](https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format)
|
|
|
|
(WAT) and [Lisp](https://en.wikipedia.org/wiki/Lisp_(programming_language)). AIR
|
|
|
|
scripts control the Fluence peer-to-peer network, its peers and even resources
|
|
|
|
on other (p2p) networks, such as IPFS and Filecoin, e.g.,
|
|
|
|
[Fluence IPFS library](https://fluence.dev/docs/aqua-book/libraries/aqua-ipfs)
|
|
|
|
through Marine adapter services.
|
|
|
|
|
|
|
|
A description of AIR values and a list of AIR instructions together with
|
|
|
|
examples of their usage can be found [here](./docs/AIR.md). The main properties
|
|
|
|
of AIR and its interface are discussed [here](./air/README.md).
|
|
|
|
|
|
|
|
A complete list of AIR instructions with examples of their usage can be found
|
|
|
|
[here](./docs/AIR.md). The fundamental contracts of the AquaVM interface, along
|
|
|
|
with a more detailed interaction scheme can be found [here](./air/README.md).
|
2020-11-05 15:01:27 +03:00
|
|
|
|
2023-02-22 19:54:47 +03:00
|
|
|
## Repository Structure
|
2022-09-19 14:36:46 +03:00
|
|
|
|
2023-02-22 19:54:47 +03:00
|
|
|
- [**air**](./air) is the core of AquaVM
|
2023-03-02 13:31:05 +02:00
|
|
|
- [**air-interpreter**](./air-interpreter) is a crate to support different
|
|
|
|
compilation targets (Marine and wasm-bindgen)
|
2023-02-22 19:54:47 +03:00
|
|
|
- [**avm**](./avm)
|
2023-03-02 13:31:05 +02:00
|
|
|
- [client](./avm/client) is an AquaVM launcher for browser and Node.js targets
|
|
|
|
- [server](./avm/server) is an AquaVM launcher for server-side targets
|
|
|
|
- [**crates**](./crates)
|
|
|
|
- [air-lib](./crates/air-lib) contains all main crates for the core of AquaVM
|
|
|
|
- [beautifier](./crates/beautifier) is an implementation of AIR-beautifier
|
|
|
|
- [data-store](./crates/data-store) defines a `DataStore` trait used by the
|
|
|
|
Fluence node
|
|
|
|
- [interpreter-wasm](./crates/interpreter-wasm) is a crate for better
|
|
|
|
integration of compiled Wasm code into the Fluence node
|
|
|
|
- [testing-framework](./crates/testing-framework) is an implementation of the
|
|
|
|
framework that improves test writing experience
|
2023-02-22 19:54:47 +03:00
|
|
|
- [**tools**](./tools) contains AquaVM-related tools
|
2022-09-19 14:36:46 +03:00
|
|
|
|
2023-02-22 19:54:47 +03:00
|
|
|
## Support
|
2020-11-05 15:01:27 +03:00
|
|
|
|
2023-03-02 13:31:05 +02:00
|
|
|
Please, file an [issue](https://github.com/fluencelabs/aquavm/issues) if you
|
|
|
|
find a bug. You can also contact us at
|
|
|
|
[Discord](https://discord.com/invite/5qSnPZKh7u) or
|
|
|
|
[Telegram](https://t.me/fluence_project). We will do our best to resolve the
|
|
|
|
issue ASAP.
|
2022-05-14 17:12:48 +03:00
|
|
|
|
2023-02-22 19:54:47 +03:00
|
|
|
## Contributing
|
2022-05-14 17:12:48 +03:00
|
|
|
|
2023-03-02 13:31:05 +02:00
|
|
|
Any interested person is welcome to contribute to the project. Please, make sure
|
|
|
|
you read and follow some basic [rules](./CONTRIBUTING.md).
|
2022-05-14 17:12:48 +03:00
|
|
|
|
2023-02-22 19:54:47 +03:00
|
|
|
## License
|
2022-08-26 00:43:43 +03:00
|
|
|
|
2024-06-26 12:34:36 +03:00
|
|
|
All software code is copyright (c) Fluence DAO under the
|
|
|
|
[AGPLv3](./LICENSE) license.
|