mirror of
https://github.com/fluencelabs/gitbook-docs
synced 2025-06-16 08:21:45 +00:00
GitBook: [#227] No subject
This commit is contained in:
committed by
gitbook-bot
parent
ecbed8ec1a
commit
3ae65d12a3
@ -4,7 +4,7 @@ In order to develop within the Fluence solution, [Node](https://nodejs.org/en/),
|
||||
|
||||
### NodeJs
|
||||
|
||||
Download the \[installer\]\([https://nodejs.org/en/download/](https://nodejs.org/en/download/)\) for your platform and follow the instructions.
|
||||
Download the \[installer]\([https://nodejs.org/en/download/](https://nodejs.org/en/download/)) for your platform and follow the instructions.
|
||||
|
||||
### Rust
|
||||
|
||||
@ -14,7 +14,7 @@ Install Rust:
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
```
|
||||
|
||||
Once Rust is installed, we need to expand the toolchain and include [nightly build](https://rust-lang.github.io/rustup/concepts/channels.html) and the [Wasm](https://doc.rust-lang.org/stable/nightly-rustc/rustc_target/spec/wasm32_wasi/index.html) compile target.
|
||||
Once Rust is installed, we need to expand the toolchain and include [nightly build](https://rust-lang.github.io/rustup/concepts/channels.html) and the [Wasm](https://doc.rust-lang.org/stable/nightly-rustc/rustc\_target/spec/wasm32\_wasi/index.html) compile target.
|
||||
|
||||
```bash
|
||||
rustup install nightly
|
||||
@ -28,13 +28,13 @@ rustup self update
|
||||
rustup update
|
||||
```
|
||||
|
||||
There are a number of good Rust installation and IDE integration tutorials available. [DuckDuckGo](https://duckduckgo.com/) is your friend but if that's too much effort, have a look at [koderhq](https://www.koderhq.com/tutorial/rust/environment-setup/). Please note, however, that currently only VSCode is supported with Aqua syntax support.
|
||||
There are a number of good Rust installation and IDE integration tutorials available. [DuckDuckGo](https://duckduckgo.com) is your friend but if that's too much effort, have a look at [koderhq](https://www.koderhq.com/tutorial/rust/environment-setup/). Please note, however, that currently only VSCode is supported with Aqua syntax support.
|
||||
|
||||
### Aqua Tools
|
||||
|
||||
The Aqua compiler and standard library and be installed via npm:
|
||||
|
||||
```text
|
||||
```
|
||||
npm -g install @fluencelabs/aqua
|
||||
npm -g install @fluencelabs/aqua-lib
|
||||
```
|
||||
@ -43,11 +43,11 @@ npm -g install @fluencelabs/aqua-lib
|
||||
|
||||
If you are a VSCode user, note that am Aqua syntax-highlighting extension is available. In VSCode, click on the Extensions button, search for `aqua`and install the extension.
|
||||
|
||||

|
||||

|
||||
|
||||
Moreover, the aqua-playground provides a ready to go Typescript template and Aqua example. In a directory of you choice:
|
||||
|
||||
```text
|
||||
```
|
||||
git clone git@github.com:fluencelabs/aqua-playground.git
|
||||
```
|
||||
|
||||
@ -68,13 +68,17 @@ In addition, Fluence provides the `fldist` tool for the lifecycle management of
|
||||
npm -g install @fluencelabs/fldist
|
||||
```
|
||||
|
||||
### Fluence SDK
|
||||
{% hint style="info" %}
|
||||
Please note that we are in the process of deprecating Fldist in favor of [Aqua CLI](https://github.com/fluencelabs/aqua/tree/main/cli). At the time of this writing, `fldist` is fully functional **except** for `run_air` which needs to be replaced with `aqua run`. 
|
||||
|
||||
For frontend development, the Fluence [JS-SDK](https://github.com/fluencelabs/fluence-js) is currently the favored, and only, tool.
|
||||
We are currently in the process of updating the documentation to reflect these changes. If you run into an errant `fldist` reference, please let us now!
|
||||
{% endhint %}
|
||||
|
||||
### Fluence JS
|
||||
|
||||
For frontend development, the Fluence [JS](https://github.com/fluencelabs/fluence-js) is currently the favored, and only, tool.
|
||||
|
||||
```bash
|
||||
npm install @fluencelabs/fluence
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
@ -10,16 +10,16 @@ docker run -d --name fluence -e RUST_LOG="info" -p 7777:7777 -p 9999:9999 -p 180
|
||||
|
||||
where the `-d` flag runs the container in detached mode, `-e` flag sets the environment variables, `-p` flag exposes the ports: 7777 is the tcp port, 9999 the websocket port, and, optionally, 18080 the Prometheus port.
|
||||
|
||||
Once the container is up and running, we can tail the log \(output\) with
|
||||
Once the container is up and running, we can tail the log (output) with
|
||||
|
||||
```text
|
||||
```
|
||||
docker logs -f fluence
|
||||
```
|
||||
|
||||
Which gives os the logged output:
|
||||
|
||||
```bash
|
||||
[2021-03-11T01:31:17.574274Z INFO particle_node]
|
||||
[2021-12-02T19:42:20.734559Z INFO particle_node]
|
||||
+-------------------------------------------------+
|
||||
| Hello from the Fluence Team. If you encounter |
|
||||
| any troubles with node operation, please update |
|
||||
@ -30,19 +30,23 @@ Which gives os the logged output:
|
||||
| github.com/fluencelabs/fluence/discussions |
|
||||
+-------------------------------------------------+
|
||||
|
||||
[2021-03-11T01:31:17.575062Z INFO server_config::fluence_config] Loading config from "/.fluence/Config.toml"
|
||||
[2021-03-11T01:31:17.575461Z INFO server_config::keys] generating a new key pair
|
||||
[2021-03-11T01:31:17.575768Z WARN server_config::defaults] New management key generated. private in base64 = VE0jt68kqa2B/SMOd3VuuPd14O2WTmj6Dl//r6VM+Wc=; peer_id = 12D3KooWNGuGgQVUA6aJMGMGqkBCFmLZqMwmp6pzmv1WLYdi7gxN
|
||||
[2021-03-11T01:31:17.575797Z INFO particle_node] AIR interpreter: "./aquamarine_0.7.3.wasm"
|
||||
[2021-03-11T01:31:17.575864Z INFO particle_node::config::certificates] storing new certificate for the key pair
|
||||
[2021-03-11T01:31:17.577028Z INFO particle_node] public key = BRqbUhVD2XQ6YcWqXW1D21n7gPg15STWTG8C7pMLfqg2
|
||||
[2021-03-11T01:31:17.577848Z INFO particle_node::node] server peer id = 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx
|
||||
[2021-12-02T19:42:20.734599Z INFO server_config::resolved_config] Loading config from "/.fluence/v1/Config.toml"
|
||||
[2021-12-02T19:42:20.734842Z INFO server_config::keys] Generating a new key pair to "/.fluence/v1/builtins_secret_key.ed25519"
|
||||
[2021-12-02T19:42:20.735133Z INFO server_config::keys] Generating a new key pair to "/.fluence/v1/secret_key.ed25519"
|
||||
[2021-12-02T19:42:20.735409Z WARN server_config::defaults] New management key generated. ed25519 private key in base64 = M2sMsy5qguJIEttNct1+OBmbMhVELRUzBX9836A+yNE=
|
||||
[2021-12-02T19:42:20.736364Z INFO particle_node] AIR interpreter: "/.fluence/v1/aquamarine_0.16.0-restriction-operator.9.wasm"
|
||||
[2021-12-02T19:42:20.736403Z INFO particle_node::config::certificates] storing new certificate for the key pair
|
||||
[2021-12-02T19:42:20.736589Z INFO particle_node] node public key = 3iMsSHKmtioSHoTudBAn5dTtUpKGnZeVGvRpEV1NvVLH
|
||||
[2021-12-02T19:42:20.736616Z INFO particle_node] node server peer id = 12D3KooWCXj3BQuV5d4vhgyLFmv7rRYiy9MupFiyEWnqcUAGpS4D
|
||||
[2021-12-02T19:42:20.739248Z INFO particle_node::node] Fluence listening on ["/ip4/0.0.0.0/tcp/7777", "/ip4/0.0.0.0/tcp/9999/ws"]
|
||||
<snip>
|
||||
```
|
||||
|
||||
|
||||
|
||||
For future interaction with the node, we need to retain the server peer id 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx. And if you feel the need to snoop around the container:
|
||||
For future interaction with the node, we need to retain the server peer id \`12D3KooWCXj3BQuV5d4vhgyLFmv7rRYiy9MupFiyEWnqcUAGpS4D\`, which may be different for you. 
|
||||
|
||||
And if you feel the need to snoop around the container:
|
||||
|
||||
```bash
|
||||
docker exec -it fluence bash
|
||||
@ -50,17 +54,16 @@ docker exec -it fluence bash
|
||||
|
||||
will get you in.
|
||||
|
||||
Now that we have a local node, we can use the `fldist` tool to interact with it. From the Quick Start, you may recall that we need the node-id and node-addr:
|
||||
Now that we have a local node, we can use the `fldist` tool and `aqua cli` to interact with it. From the Quick Start, you may recall that we need the node-id and node-addr:
|
||||
|
||||
* node-id: 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx
|
||||
* node-addr: /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx
|
||||
* node-id: `12D3KooWCXj3BQuV5d4vhgyLFmv7rRYiy9MupFiyEWnqcUAGpS4D`
|
||||
* node-addr: `/ip4/127.0.0.1/tcp/9999/ws/p2p/112D3KooWCXj3BQuV5d4vhgyLFmv7rRYiy9MupFiyEWnqcUAGpS4D`
|
||||
|
||||
Let's inspect our node and check for any available modules and interfaces:
|
||||
|
||||
```text
|
||||
```
|
||||
fldist get_modules \
|
||||
--node-id 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
|
||||
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
|
||||
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWCXj3BQuV5d4vhgyLFmv7rRYiy9MupFiyEWnqcUAGpS4D \
|
||||
--pretty
|
||||
```
|
||||
|
||||
@ -72,16 +75,15 @@ Let's us check on available modules and gives us:
|
||||
|
||||
And checking on available interfaces:
|
||||
|
||||
```text
|
||||
```
|
||||
fldist get_interfaces \
|
||||
--node-id 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
|
||||
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx
|
||||
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWCXj3BQuV5d4vhgyLFmv7rRYiy9MupFiyEWnqcUAGpS4D \
|
||||
--expand
|
||||
```
|
||||
|
||||
Results in:
|
||||
|
||||
```text
|
||||
```
|
||||
60000
|
||||
[ [] ]
|
||||
```
|
||||
@ -91,28 +93,28 @@ Since we just initiated the node, we expect no modules and no interfaces and the
|
||||
```bash
|
||||
mkdir fluence-greeter
|
||||
cd fluence-greeeter
|
||||
# download the greeting.wasm file into this directory
|
||||
# https://github.com/fluencelabs/fce/blob/master/examples/greeting/artifacts/greeting.wasm -- Download button to the right
|
||||
# download the greeting.wasm file into this directory:
|
||||
# https://github.com/fluencelabs/marine/blob/master/examples/greeting/artifacts/greeting.wasm -- Download button to the right
|
||||
echo '{ "name":"greeting"}' > greeting_cfg.json
|
||||
```
|
||||
|
||||
We just grabbed the greeting Wasm file from the Fluence repo and created a service configuration file, `greeting_cfg.json`, which allow us to create a new GreetingService:
|
||||
|
||||
```bash
|
||||
fldist --node-id 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
|
||||
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
|
||||
new_service \
|
||||
--ms examples/greeting/artifacts/greeting.wasm:greeting_cfg.json \
|
||||
-n GreetingService
|
||||
fldist \
|
||||
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWCXj3BQuV5d4vhgyLFmv7rRYiy9MupFiyEWnqcUAGpS4D new_service \
|
||||
--ms greeting.wasm:greeting_cfg.json \
|
||||
-n greeting-service \
|
||||
--verbose
|
||||
```
|
||||
|
||||
Which gives us the service id:
|
||||
|
||||
```text
|
||||
client seed: 7VtMT7dbdfuU2ewWHEo42Ysg5B9KTB5gAgM8oDEs4kJk
|
||||
client peerId: 12D3KooWRSmoTL64JVXna34myzAuKWaGkjE6EBAb9gaR4hyyyQDM
|
||||
node peerId: 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx
|
||||
service id: 64551400-6296-4701-8e82-daf0b4e02751
|
||||
```
|
||||
client seed: GofK8dD9kHFv27HGrQstMoQTWGiKeBteoXT1gGdXLzqc
|
||||
client peerId: 12D3KooWAyyRcszmHTotttZNyTNhpUMxcrC7JesEurUZ4zKfvtyJ
|
||||
relay peerId: 12D3KooWCXj3BQuV5d4vhgyLFmv7rRYiy9MupFiyEWnqcUAGpS4D
|
||||
service id: 2bb578a1-f67e-4975-b952-b2979c63f0f0
|
||||
service created successfully
|
||||
```
|
||||
|
||||
@ -120,14 +122,13 @@ We now have a greeting service running on our node. As always, take note of the
|
||||
|
||||
```bash
|
||||
fldist get_modules \
|
||||
--node-id 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
|
||||
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
|
||||
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWCXj3BQuV5d4vhgyLFmv7rRYiy9MupFiyEWnqcUAGpS4D \
|
||||
--pretty
|
||||
```
|
||||
|
||||
Which now lists our uploaded module:
|
||||
|
||||
```text
|
||||
```
|
||||
[
|
||||
{ "config": {
|
||||
"logger_enabled":true,
|
||||
@ -145,9 +146,9 @@ Which now lists our uploaded module:
|
||||
]
|
||||
```
|
||||
|
||||
Yep, checking once again for modules, the output confirms that the greeting service is available. Writing a small AIR script allows us to use the service:
|
||||
Yep, checking once again for modules, the output confirms that the greeting service is available. Writing a small Aqua script allows us to use the service:
|
||||
|
||||
```text
|
||||
```python
|
||||
service GreetingService("service-id"):
|
||||
greeting: string -> string
|
||||
|
||||
@ -158,33 +159,20 @@ func greeting(name:string, node:string, greeting_service_id: string) -> string:
|
||||
<- res
|
||||
```
|
||||
|
||||
Compile the script with [`aqua`](https://doc.fluence.dev/aqua-book/getting-started/quick-start) or `aqua-js` and use the resulting file with the`fldist` tool:
|
||||
We run the script with [`aqua`](https://doc.fluence.dev/aqua-book/getting-started/quick-start)
|
||||
|
||||
```text
|
||||
fldist --node-id 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
|
||||
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
|
||||
run_air \
|
||||
-p greeting.greeting.air \
|
||||
-d '{"service": "64551400-6296-4701-8e82-daf0b4e02751", "name":"Fluence", "node": "12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx"}'
|
||||
```
|
||||
aqua run \
|
||||
-a /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWCXj3BQuV5d4vhgyLFmv7rRYiy9MupFiyEWnqcUAGpS4D \
|
||||
-i greeting.aqua \
|
||||
-f 'greeting("Fluence", "12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf", "04ef4459-474a-40b5-ba8d-1e9a697206ab")'
|
||||
```
|
||||
|
||||
```bash
|
||||
<snip>
|
||||
===================
|
||||
Your peerId: 12D3KooWAMTVBjHfEnSF54MT4wkXB1CvfDK3XqoGXt7birVsLFj6
|
||||
[
|
||||
"Hi, Fluence"
|
||||
]
|
||||
[
|
||||
[
|
||||
{
|
||||
peer_pk: '12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx',
|
||||
service_id: '64551400-6296-4701-8e82-daf0b4e02751',
|
||||
function_name: 'greeting',
|
||||
json_path: ''
|
||||
}
|
||||
]
|
||||
]
|
||||
===================
|
||||
```
|
||||
|
||||
Yep, our node and the tools are working as expected. Going back to the logs, we can further verify the script execution:
|
||||
@ -195,7 +183,7 @@ docker logs -f fluence
|
||||
|
||||
And check from the bottom up:
|
||||
|
||||
```text
|
||||
```
|
||||
<snip>
|
||||
[2021-03-12T02:42:51.041267Z INFO aquamarine::particle_executor] Executing particle 14db3aff-b1a9-439e-8890-d0cdc9a0bacd
|
||||
[2021-03-12T02:42:51.041927Z INFO particle_closures::host_closures] Executed host call "64551400-6296-4701-8e82-daf0b4e02751" "greeting" (96us 700ns)
|
||||
@ -205,4 +193,3 @@ And check from the bottom up:
|
||||
Looks like our node container and logging is up and running and ready for your development use. As the Fluence team is rapidly developing, make sure you stay up to date. Check the repo or [Docker hub](https://hub.docker.com/r/fluencelabs/fluence) and update with `docker pull fluencelabs/fluence:latest`.
|
||||
|
||||
Happy composing!
|
||||
|
||||
|
Reference in New Issue
Block a user