Deploy A Local Fluence Node
A significant chunk of developing and testing of Fluence services can be accomplished on an isolated, local node. In this brief tutorial we set up a local, dockerized Fluence node and test its functionality. In subsequent tutorials, we cover the steps required to join an existing network or how to run your own network.
The fastest way to get a Fluence node up and running is to use docker:
1
docker run -d --name fluence -e RUST_LOG="info" -p 7777:7777 -p 9999:9999 -p 18080 fluencelabs/fluence
Copied!
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
1
docker logs -f fluence
Copied!
Which gives os the logged output:
1
[2021-03-11T01:31:17.574274Z INFO particle_node]
2
+-------------------------------------------------+
3
| Hello from the Fluence Team. If you encounter |
4
| any troubles with node operation, please update |
5
| the node via |
6
| docker pull fluencelabs/fluence:latest |
7
| |
8
| or contact us at |
9
| github.com/fluencelabs/fluence/discussions |
10
+-------------------------------------------------+
11
12
[2021-03-11T01:31:17.575062Z INFO server_config::fluence_config] Loading config from "/.fluence/Config.toml"
13
[2021-03-11T01:31:17.575461Z INFO server_config::keys] generating a new key pair
14
[2021-03-11T01:31:17.575768Z WARN server_config::defaults] New management key generated. private in base64 = VE0jt68kqa2B/SMOd3VuuPd14O2WTmj6Dl//r6VM+Wc=; peer_id = 12D3KooWNGuGgQVUA6aJMGMGqkBCFmLZqMwmp6pzmv1WLYdi7gxN
15
[2021-03-11T01:31:17.575797Z INFO particle_node] AIR interpreter: "./aquamarine_0.7.3.wasm"
16
[2021-03-11T01:31:17.575864Z INFO particle_node::config::certificates] storing new certificate for the key pair
17
[2021-03-11T01:31:17.577028Z INFO particle_node] public key = BRqbUhVD2XQ6YcWqXW1D21n7gPg15STWTG8C7pMLfqg2
18
[2021-03-11T01:31:17.577848Z INFO particle_node::node] server peer id = 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx
19
<snip>
Copied!
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:
1
docker exec -it fluence bash
Copied!
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:
    node-id: 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx
    node-addr: /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx
Let's inspect our node and check for any available modules and interfaces:
1
fldist get_modules \
2
--node-id 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
3
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
4
--pretty
Copied!
Let's us check on available modules and gives us:
1
[[]]
Copied!
And checking on available interfaces:
1
fldist get_interfaces \
2
--node-id 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
3
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx
4
--expand
Copied!
Results in:
1
60000
2
[ [] ]
Copied!
Since we just initiated the node, we expect no modules and no interfaces and the fldist queries confirm our expectations. To further explore and validate the node, we can create a small greeting service.
1
mkdir fluence-greeter
2
cd fluence-greeeter
3
# download the greeting.wasm file into this directory
4
# https://github.com/fluencelabs/fce/blob/master/examples/greeting/artifacts/greeting.wasm -- Download button to the right
5
echo '{ "name":"greeting"}' > greeting_cfg.json
Copied!
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:
1
fldist --node-id 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
2
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
3
new_service \
4
--ms examples/greeting/artifacts/greeting.wasm:greeting_cfg.json \
5
-n GreetingService
Copied!
Which gives us the service id:
1
client seed: 7VtMT7dbdfuU2ewWHEo42Ysg5B9KTB5gAgM8oDEs4kJk
2
client peerId: 12D3KooWRSmoTL64JVXna34myzAuKWaGkjE6EBAb9gaR4hyyyQDM
3
node peerId: 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx
4
service id: 64551400-6296-4701-8e82-daf0b4e02751
5
service created successfully
Copied!
We now have a greeting service running on our node. As always, take note of the service id.
1
fldist get_modules \
2
--node-id 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
3
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
4
--pretty
Copied!
Which now lists our uploaded module:
1
[
2
{ "config": {
3
"logger_enabled":true,
4
"logging_mask":null,
5
"mem_pages_count":100,
6
"mounted_binaries":null,
7
"wasi":{
8
"envs":null,
9
"mapped_dirs":null,
10
"preopened_files":[]
11
},
12
"hash":"80a992ec969576289c61c4a911ba149083272166ffec2949d9d4a066532eec1d",
13
"name":"greeting"
14
}
15
]
Copied!
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:
1
service GreetingService("service-id"):
2
greeting: string -> string
3
4
func greeting(name:string, node:string, greeting_service_id: string) -> string:
5
on node:
6
GreetingService greeting_service_id
7
res <- GreetingService.greeting(name)
8
<- res
Copied!
Compile the script with aqua or aqua-js and use the resulting file with thefldist tool:
1
fldist --node-id 12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
2
--node-addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx \
3
run_air \
4
-p greeting.greeting.air \
5
-d '{"service": "64551400-6296-4701-8e82-daf0b4e02751", "name":"Fluence", "node": "12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx"}'
Copied!
1
<snip>
2
===================
3
[
4
"Hi, Fluence"
5
]
6
[
7
[
8
{
9
peer_pk: '12D3KooWLFCmDq4vDRfaxW2GA6kYnorxAiie78XzQrVDVoWEZnPx',
10
service_id: '64551400-6296-4701-8e82-daf0b4e02751',
11
function_name: 'greeting',
12
json_path: ''
13
}
14
]
15
]
16
===================
Copied!
Yep, our node and the tools are working as expected. Going back to the logs, we can further verify the script execution:
1
docker logs -f fluence
Copied!
And check from the bottom up:
1
<snip>
2
[2021-03-12T02:42:51.041267Z INFO aquamarine::particle_executor] Executing particle 14db3aff-b1a9-439e-8890-d0cdc9a0bacd
3
[2021-03-12T02:42:51.041927Z INFO particle_closures::host_closures] Executed host call "64551400-6296-4701-8e82-daf0b4e02751" "greeting" (96us 700ns)
4
[2021-03-12T02:42:51.046652Z INFO particle_node::network_api] Sent particle 14db3aff-b1a9-439e-8890-d0cdc9a0bacd to 12D3KooWLFqJwuHNe2kWF8SMgX6cm24L83JUADFcbrj5fC1z3b21 @ [/ip4/172.17.0.1/tcp/61636/ws]
Copied!
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 and update with docker pull fluencelabs/fluence:latest.
Happy composing!
Last modified 1mo ago
Copy link