How to make a Service and distribute it with the Fluence network
CC Attribution 2.0 Belgium:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Shakhtarin, Dmitriy
Voronov, Mike
This section aims to show how a service can be created from scratch and then deployed to the Fluence network. We will start with a discussion of FCE – special runtimes that designed to run multi-module Wasm applications with help of interface-types. Then we will create several simple services and discuss how to compile, run locally, and debug them with our tooling. Finally, we will deploy these services to Fluence nodes to use them next by the front-end application.
 you Hi guys, my name is Mike and in this section you will discuss fluent services and fluent complete engine. In particular the agenda of this section is as follows. First of all, we will start with a little introduction to our assembly, just a couple of slides. Then we will walk through some fluent services internals and FC runtime. And finally I will show you how to develop in the back a simple whole world service for the fluent network from scratch. Let's start with answering to the simple question what is WebAssembly? Actually I have taken this marvelous slide from the BandsMeetTalk on the PPcon 2019, you can find the link at the bottom of the slide. And here we can see the directed graph and moving from left to right you can construct our own definition what is WebAssembly. I ended with this one. So WebAssembly is the open standard of stack based virtual machine that has different parts such as stack, tables, global variables, all new memories and so on. And the WebAssembly specifications introduce concept of modules with imports and experts. A WebAssembly modules could be considered as a black boxes whose experts contains entry points that define how exactly it could be called from some external world, for example from a browser or operation system. And imports define which functions from external world a module could call. And also it importance that WebAssembly specification defines only primitive types. By primitive I mean that there are only integers and forwarding point numbers. For example there are no any arrays, strings, records and so on. Just these types. And of course it's making it difficult to make handy API and API of modules. But WebAssembly provides us a way to abstract our resistance constraints with help of interface types. On this slide you can see a complex scheme where on the middle of this blue box represents a role of WebAssembly module with role, imports and experts. So by role, import and export I mean that this function could operate with only primitive types. It's only forwarding point and integers. And this adapted module could wrap this role module and provide some adapted import and adapted export that could alluring and lifting types between complex and road types. So half of work by type conversion could be done by module itself. And another gem of WebAssembly world is Vazin. Vazin stands for WebAssembly system interface. So it is standard of POSIX-YX imports that module could call from runtime. And on this slide you can see the compilation of two whole world program written on Rust and C++. And actually this gives WebAssembly binary with the same imports thanks to Vazin. So here we can see five imports. Yep, and WebAssembly provides us a way with help of Vazin and help of modules with imports and experts to make heterogeneous runtime that could run modules written on different languages. So, but actually at the moment we provide SDK only for Rust. So Rust is our primary language for backend service developing. And I think that it's right time to dig into the details of this SDK and the service internals. Fluent service is a group of modules linked together by Charlotte Nassink linking scheme. So this linking scheme is based on linking only imports and experts of modules. This means that all modules stayed keep in private. For example, WebAssembly module doesn't expose memory, tables, globals and so on. And all of this is possible because we use interface types and each module contains adapter functions that could worry and lifting types. And also with help of interface types, our module keeps its states in private and linked together only by imports and experts. And actually we have three types of modules. The first one called Fossate. So this module actually expose the API front-line service. So in this each service there could be only one such module. Next one is pure modules. Pure modules could contain all business logic and they can't access file system or call external binaries. And last one called Effectors. And the purpose is to do some stuff related to file system, other operations system services or calling external binaries. And also each service should have a configuration file. Well, that's why you can see the example of configuration file for URL download or service. You can find also the full code of the service by the link in the bottom. This service consists of three modules. The first one called local storage. As you can see it is a factor because it requires access to file system through Vazir. So in particular it requires access to indirect code sites. Here pre-opened files is a list of directors of files that a module could access during its work. And mapped durars here could be used for setting aliases for each pre-opened files. The next one is also a factor because it requires access to mounted binary code CURL. So here is this mounted binary option says that a module could call a binary located by this path. Here is the USERB bin CURL on file system. And the last one is always FASATEMODEL that exposes API of an entire service. And on the slide you can see the principle scheme of Fluence Compute Engine. Fluence Compute Engine allows to load several services at the same moment. Each service could consist of several modules. As we discussed, this module is linked together by import and exports. And the effectors modules of each service could access some operation system services with help of Vazir. And also as you heard on previous slides, ACOMARINE is our language based on PICALCOS for complex multi-agents scenarios across the Fluence network. But what is the connection between FC and ACOMARINE? And so actually ACOMARINE interpreter is compiled to WebAssembly and could be loaded to FC Runtime as a module. But this module has a special property that allows the interpreter to call other services that are loaded to FC at the moment. By special instruction code CALL, so you can find more information about ACOMARINE on the next sections and also in ALODOC. And finally, let's consider how services for Fluence could be built and debugged. So all complexity of generation of WebAssembly binary and generation and compiling interface types is encapsulated in our SDK and building tools. On this slide you can see how how world for Fluence could look like. So this example contains two functions main and greeting. And the first one is needed for initialization of Vazir. So it's code only once on the module startup. The second one greeting is wrapped by our special procedure macro FC and this makes this function exported from a module and allows other modules or ACOMARINE scripts called. And so as you see, you can find the complete example of the service by the link on the bottom of the slide. So this FC macro could be applied to function, external bulk and structures. So applying to functions is as we saw on the previous slide, made this function exported from module. Applying to external block tells our building tools that a module requires imports from such module. For example, in this case, it's CurveAdapter. And the last one option provides a way to use structure types in signature of import and exported function. So in first and second variants. So and finally, in this section, we discussed FC and our SDK a little bit. And you can find repository for them by these links. And also we have documentation about module developing that could be found by this link. And so on the next, we will take some hand on section with developing a simple whole world fluent service. Let's see how simple whole world module could be built for films and then could be turned to a service. But first of all, we need to install Rust and also implementry tool, and then install our build tool and tool for dividing. So actually, you can find all comments on our docs. The link was on the previous on the last slide. So actually also, I have all this tool installed on my stuff. On your it could take more time course. And also, please note that it's important to install Nike Rust, because our repo requires only only nightly to chain of Rust. So then let's install wasp32 was a target, it could be done by this command. So for me to read installed, then we need to install our building tool. It's code FCLI. So this command adds binary code FC to your system. And then we also need to install repo that could be used for dividing. And it is so we installed Rust wasm32 was a target for us, and our building can divide tools. And actually here, we could create a new project. So the Rust could be done by cargo new, let's call it greeting, and make it binary. So here, binary means that final WebAssembly binary, you contain some internalization code for rising. So it's important to make it binary. So okay. And then let's edit a little bit cargo to make it compile to WebAssembly. So and to specify our, our free-winds SDK. So actually, let's change it into something like this one. And also, let's add our SDKs dependency. Actually, its current version is 2.17. But it doesn't matter for our example, we could use the last one. So let's save it the next and then let's open our greeting, assert C and main, the main project, main assert C file. And so here we need to include our macro. So it could be done by this. And then we need to leave main empty. So and then we could run our main function that wrapped with fc. So let's follow the example that was on slides. So let's call this function like greeting that takes a string and return a new string. And internally, it could, for example, append to string something like this. Yep. So and it is. And actually, it is all code for simple whole world. There are only two functions main for initializing quasi and greeting as a main export functions. So it is. And then we need to compile this. Compiling is done by our fc. So we could compile it by fc build. It just a wrapper on cargo that could embed interface types. So after compiling, it takes some time to different on the cache of compiled cargo artifacts. So also fc allow you to, for example, find out what interface types is generated. For example, let's see for our case. Because we haven't specified release. So it's should contain should I keep it in debug folder. So and here we can see generated interface types for our simple binary. So then let's convert it to a service to convert to this binary, this service module to a service, we need to do only one thing. So actually, we need to write a config. Yep, let's create a new config. Tomo and so just write something something like this. So here we specify that. Binary for this service is located on this folder called artifact. And the service is consistent on one module called greeting. And it is so that's all. Let's say we'll be successfully created any service greeting. And then let's see how it could be called. Actually, there are several ways to call it one way to upload it. And then call it with a submarine or something like that. But for the binding purposes, we have special tool called Ripple. But first of all, we need to create a different folders and then copy our greeting binaries to it. So something like that. Then we could run fc rebel and specify config config Tomo do it. Actually, rebel supports several comments for loading and loading modules, coding, obtaining their interfaces, environment variables file system, state and so on. But today for us important to call module and see, see the result of calling. So calling module should be done with specifying module name in our case is greeting, export function name in our case, it's also called greeting and arguments and arguments should be encoded in JSON. So it could look like this. And let us see something like John. And here we see that the result is a high John. Yep. It's the same string that we expected. So thank you very much. On this, on this my section is done. On next section, on the next section, you will see how more complex services could be built, then how they could be deployed to fluent network and called by Akoma. Thank you. Hello, my name is Dmitry. I'm a software developer in Fluence. Let's continue our journey to the fluent system. I hope that you already saw previous videos of our speech series. Today, I'll show you some tips and tricks on how to build services in the fluence network. I'll take services that we used in fluence part project, for example, to start the creation of our service, we simply initialize our REST project and on Fluence library to dependencies as you see on the screen. First of all, we want to initialize our fresh services in service lifecycle, it could be logger initialization as you see on the screen, or creating a database or initialization some preloaded data. And we use the main method for this. So how to build functions that we could call from AirScrip. As Michael already said, we need to mark our functions with FCE tag. FCE environment doesn't support result types as a result. So we need to wrap possible errors in structure. For this, we create custom structures, as you see on the screen, with the return code to understand if it is an error or a successful result for every function and convert results to these structures for the convenience of application development. And this is code for conversion. So when our methods, we just use into and convert our simple function that returns out to our structures. And to use the structures from AirScript, we mark them with the FCE tag as well. This project is quite simple, we just add some data to our storage and return it if needed. For this, we have a join function to add user to database to some sort of storage live user to delete user from our storage and some helper functions that we later discuss. In this example, we use in memory storage that will be cleaned after service will restart, not restart or some other reason. As you see, it's only a hash map to store our data. But if needed, we can connect and use database modulus. We have a school light and registers was modulus for now, but it is possible to create a proxy models for every database and other stuff that can use a file system and store data and long term storage to connect other modulus, we need to describe a P of a model to connect it to your code. For this, we need to write this code. We need to tag our code with FCE tag, write our model name as you see on the screen and add functions from this model. If you make a mistake in your code, you'll see it when you compile your was modulus in a frapple as Michael said before, or after deploying node will return an error that it cannot create such link of models. After this, you could simply use these functions in your code as you see on the screen. Do you see CLI or maybe some operating system comments you need to import host functions like this. So main difference is that name of model is host. And here is a CLI tool name and comments are passed as string. If you want to use file system, you can use it as you would normally do it in Rust, but all this, like file system or other modules or host functions should be specified in the config that Michael mentioned before. Another important thing that we need to build our services properly is authorization and authentication. First of all, to check if a caller is an owner of a service, or it exists in some sort of list, we need to get the colors ID. These and other useful info could be found in call parameters. Call parameters we could get like this. And what is call parameters? It's all necessary information about color and about arguments that we pass through our function. It is like initpred, service ID, service creator pred, host ID, particle ID, and tetra plates. So here in the user list, we only need an initpred to check. But what if we need to verify into that the user is authorized in other services? So let's have a look in a history service that store our messages and these messages could add only that users that is authorized in user list service. In user list, we have a function that called isUntiticated and it return a result of authentication. So if user is in list or he is an owner of this service, we return true, otherwise we return false. So how can we check it in history service? This is our function to add messages. And we have argument called alpha. That is a boolean. How can we check from this argument that it is valid info from user service? We check it in isUntiticated function. So let's have a look. First of all, what we need is get our call parameters. As we seen before, and then we need to check our tetra plates. Tetra plate is a security tetra plate that store necessary data to have a proof of calls. So here we have pure public case service ID function name and just on path. How can we use it? So tetra plates are vector of vector. First vector is as our list of arguments in function. And second vector is for the case if our argument is a vector and we need to check each element of this vector. So simply we have an index of our argument and we get tetra plate for our argument and all that we need that tetra plate for our argument match the specified parameters. As you see, we need to check all fields of our tetra plate with specified parameter and that auth is true. After that, we can be sure that the call is authorized. After we write our code, we can build our services with FCE and upload them via js JavaScript SDK. To simplify this process and use simple commands from the terminal, we wrote protodistributor that use js SDK and could upload models, create blueprints and services. Let's have a look on this thing. This command line tool could be found in our GitHub repository. I'll show you how to do this in a few steps. First of all, we can look at the help and use comments to upload our model. With this comment, we could upload, for example, user list, basm file that we will name as user list. So model uploaded successfully. And after this, we need to create blueprint in which we list all our modulus that we want to use in our service. So it looks like this. Command called add blueprint. Here we need to list our dependencies. Here we have only one dependency, but if we want to use maybe a SQLite, we need to add this before model that used this model. After that, we need to specify an idea of our blueprint. It could be some custom ID, maybe UU ID or something like that. And the name of blueprint. So blueprint usually started successfully. And after that, we need to create a service. So here we use blueprint ID to do a call to a service as an owner. So it's just create our service. And here is our service ID to use in our air scripts or in JS SDK. That's all with these services, we could build big network, big application that will use services from other providers that can use data storage, local storage, file system, operating system, comments, and other stuff. Thank you for watching. And let's move on to the next video. Thank you for watching. And let's move on to the next video. Hi, everyone. Welcome to the second day of FOSDEM. Can you hear me? Hi, everyone. Welcome to the second day of FOSDEM. Welcome to the second day of FOSDEM. And we hear your... It seems that you should skip your record. I mean stream. So we are live. I understand you. Yes. Hello, everyone. Hi there. It seems that there are no many questions. Anybody here? First of all, we have some updates after this video recorded. So like about Protodydistributor, you can use it without cloning the repo. So we can install it like with the NPM. And then install FLDist. It's called FLDist. And it becomes much simpler to upload models to run services on our network. And we are waiting for questions. How can I import the existing model? I thought it's possible to use Kuro. How? So, Michael, can you answer this question? So first of all, thank you for the question. So regarding the first part about how can you import existing modules. So there are actually several ways. The most common here is like in Rust, of course, yes, because we have SDK for Rust only now. And in Rust, you could use it called foreign-mode construction, like when you write XTERM-C. And then here in this block, you could write a function that you could import from existing modules. And also, it should be wrapped with our FC macro. And it's in itself. So it's the only thing that you need to do to import existing module. And if you want to use Rapples, you should load it explicitly by the command. So regarding the next part about how to use Kuro, yes, actually, you're right. It's possible. And you provide an option to use so-called mounted binaries. So mounted binaries is a special field in config where you could specify which binaries from your operation system could be called. So, and for example, you could see in our repository and in FC, you could see an example of this config.toml file, whereas Kuro with R-specified. So, and actually, after all of this, after specifying in config, you could use it in your Rust module as a usual function. The function that receives string is an argument and output types is also string. I can show it. I think. Great. So, in this case, we'll download, by Kuro can download pages and store it on in file system. So, how we can import Kuro? It's, it looks like this macro where we use host. And the name of function is the name of command. So, cmd is arguments after the command. And config, I don't know if it here. So, in this set, we need to, this is a name of function and this is the path to our binary. And that's it. And Follux is a copy of this information. And it's like, by the examples more updated. Maybe you could show our repositories and also, whereas each of them could be found. Yeah. All repositories influence labs company. And for now, I think most updated for examples is at Denner hackathon repository that have examples with off front end part and back end part. We have services that go into Ethereum. And, you know, notice by Kuro. And there is a lot of documentation how to use it and all description about how it works. And after this, what Michael talked about is FCE. It's a compute engine that could start awesome files and combine it with each other. And also, there is examples that you can start with. And some other parts is, so my, my, where not notice is you can start notice you can work the code, if you want, it's fluence repo. And it's how you can upload your models and create services in network. And it could be used like you can install. You can use it once labs. And after installation, you can use it like all possible ways you can, you can check what interfaces uploaded in network right now. List of models upload model. Like to create services, create service and other stuff. Part work only on one note, but a little bit later, you can choose different notice, you can use your own key pairs to create services that will be owned by you. And then you can come in. So how can it come in? Maybe control plus. Yeah. So, and yeah, this is the tool that I, that we use for like working with the network, uploading models creating blueprints blueprints is the list. Simply it is a list of models that will be combined by FCE and linked between each other by FCE. And then with this blueprint, you can create your own service and each service is like one thread in note that could be used separately separately. And right now, where this deployed. Thank you for question. It is deployed on fluence notice you can run your own note. So in testnet we have like 10 or maybe more notice. And on them. Services will be deployed. Maybe Mike could say something more about this. I can actually know I think that your answer question, but so if it's if it's not, please elaborate a little bit what you mean by deployed. Yeah. So, and this tool is like CLI tool so it isn't deployed anywhere is just so like to to for to to explore services and our notes. And about the plan. As I said, first you need to upload model. Then you need to create blueprint that describes which models should be in your service and then create service and it will be deployed on fluence notice or you all not or some note that you want. Like you can create multiple internal networks of fluence notice and. Yeah. And choose not that you want. Yeah, maybe follow it's good. The doctor create new notice. Maybe folks you can link this because Wait a second. Yeah. So, and yeah, this link is also for all documentation about uploading lunch note using front front end like this. And a lot of other useful information. So we are waiting for other questions. How much table is for us. For now, it's not very stable because we are on like test net phase. But we work with it. We working on security model, a lot and on stabilization. So it's, it's an high development phase right now. Yes, and our point is to finish. So the first phase of blockchain this somewhere around the summer. And now all other parts is almost done, but then maybe not in the 100% stable phase actually so they're developing a lot now. But if you want to use some somehow so we would like to help you in any case so if you have any questions please ask us in our discord and our discussions or in telegram group so we would like to answer your questions. Also, and help with the stuff lunch note or using just as the care using some models creating models to be great. I do I understand correctly that when blockchain layer comes in the developers would be able to monetize their code their modules or services. Yes, so, so, Mike, you can you put on some. I think so. Yes, but I think it's maybe the point here is not blockchain but maybe a main net. And what I say it seems that we do not have any deadline for main net now on the football chain. And with blockchain year to the possible to monetize your code and we working on economic model right now we have like a lot of research about economic model. And the main party that we want to make it be able to monetize every app that you will upload to fluence network. Every player in our network will be monetized like a not influence not creator of model, not that run services on their own computers. So, creator will be monetized, not will be monetized and people who create their services on on the top of other services will be monetized as well by users that will be use services and by other models that we will. And maybe you know, we will talk about economic model here or we maybe talk before we'll talk. No, it's not. And what people can do already now. So, for now people can create their own models and services, they can run their own notice, they can create services on notice and use them from fluence.js is the case. And also they could run a common in scripts across the fluence network, and more about a common scheme to be presented on the next talk. So that will be in about five minutes. Yeah, and a little bit about a chlorine script so it's a glue that can link different services in network in like one. I don't know how to describe one runtime call maybe something like this. So one super service. One super service like distributed with different services and you can run it with aquamarine right now, but under aquamarine is a bottom layer language. So, a little bit later we will create top level language that will be much more easy to use. So yes, I can read now has only a common intermediate representation so because it air. So it's like a kind of low level language that has some primitives. Like inspired by type to be calculus, but in future yes we are working on high level language that will be much simpler than air. And actually so if you can see so all fluence is about is about components and about modules. So, inside all of this, there is a one little module, and several modules could be combined to a sense equal service. Several services could be combined to application or like super service that has aquamarine scripts that could call each services inside this application. So it's like a module systems. Or like a way to combine your applications. And the great thing that you can use all languages that like all libraries in your office. Thank you.
 you  Hi guys, my name is Mike and in this section you will discuss fluent services and fluent  complete engine. In particular the agenda of this section is as follows. First of all,  we will start with a little introduction to our assembly, just a couple of slides. Then we will  walk through some fluent services internals and FC runtime. And finally I will show you how to  develop in the back a simple whole world service for the fluent network from scratch. Let's start  with answering to the simple question what is WebAssembly? Actually I have taken this marvelous  slide from the BandsMeetTalk on the PPcon 2019, you can find the link at the bottom of the slide.  And here we can see the directed graph and moving from left to right you can construct our own  definition what is WebAssembly. I ended with this one. So WebAssembly is the open standard of stack  based virtual machine that has different parts such as stack, tables, global variables, all  new memories and so on. And the WebAssembly specifications introduce concept of modules with  imports and experts. A WebAssembly modules could be considered as a black boxes whose experts  contains entry points that define how exactly it could be called from some external world,  for example from a browser or operation system. And imports define which functions from external  world a module could call. And also it importance that WebAssembly specification defines only  primitive types. By primitive I mean that there are only integers and forwarding point numbers.  For example there are no any arrays, strings, records and so on. Just these types. And of  course it's making it difficult to make handy API and API of modules. But WebAssembly provides us a  way to abstract our resistance constraints with help of interface types. On this slide you can see  a complex scheme where on the middle of this blue box represents a role of WebAssembly module with  role, imports and experts. So by role, import and export I mean that this function could operate with  only primitive types. It's only forwarding point and integers. And this adapted module could wrap  this role module and provide some adapted import and adapted export that could alluring and lifting  types between complex and road types. So half of work by type conversion could be done by module  itself. And another gem of WebAssembly world is Vazin. Vazin stands for WebAssembly system interface.  So it is standard of POSIX-YX imports that module could call from runtime. And on this slide you  can see the compilation of two whole world program written on Rust and C++. And actually this gives  WebAssembly binary with the same imports thanks to Vazin. So here we can see five imports. Yep,  and WebAssembly provides us a way with help of Vazin and help of modules with imports and experts  to make heterogeneous runtime that could run modules written on different languages. So,  but actually at the moment we provide SDK only for Rust. So Rust is our primary language for  backend service developing. And I think that it's right time to dig into the details of this SDK  and the service internals. Fluent service is a group of modules linked together by Charlotte  Nassink linking scheme. So this linking scheme is based on linking only imports and experts of  modules. This means that all modules stayed keep in private. For example, WebAssembly module doesn't  expose memory, tables, globals and so on. And all of this is possible because we use interface types  and each module contains adapter functions that could worry and lifting types. And also with  help of interface types, our module keeps its states in private and linked together only by  imports and experts. And actually we have three types of modules. The first one called Fossate. So  this module actually expose the API front-line service. So in this each service there could be  only one such module. Next one is pure modules. Pure modules could contain all business logic  and they can't access file system or call external binaries. And last one called Effectors. And the  purpose is to do some stuff related to file system, other operations system services or calling  external binaries. And also each service should have a configuration file. Well, that's why you  can see the example of configuration file for URL download or service. You can find also the full  code of the service by the link in the bottom. This service consists of three modules. The first  one called local storage. As you can see it is a factor because it requires access to file system  through Vazir. So in particular it requires access to indirect code sites. Here pre-opened files is  a list of directors of files that a module could access during its work. And mapped  durars here could be used for setting aliases for each pre-opened files. The next one is also  a factor because it requires access to mounted binary code CURL. So here is this mounted binary  option says that a module could call a binary located by this path. Here is the USERB bin  CURL on file system. And the last one is always FASATEMODEL that exposes API of an entire service.  And on the slide you can see the principle scheme of Fluence Compute Engine. Fluence Compute Engine  allows to load several services at the same moment. Each service could consist of several modules.  As we discussed, this module is linked together by import and exports. And the effectors modules of  each service could access some operation system services with help of Vazir. And also as you  heard on previous slides, ACOMARINE is our language based on PICALCOS for complex multi-agents  scenarios across the Fluence network. But what is the connection between FC and ACOMARINE?  And so actually ACOMARINE interpreter is compiled to WebAssembly and could be loaded  to FC Runtime as a module. But this module has a special property that allows the interpreter  to call other services that are loaded to FC at the moment. By special instruction code CALL,  so you can find more information about ACOMARINE on the next sections and also in ALODOC.  And finally, let's consider how services for Fluence could be built and debugged. So all  complexity of generation of WebAssembly binary and generation and compiling interface types is  encapsulated in our SDK and building tools. On this slide you can see how how world for  Fluence could look like. So this example contains two functions main and greeting. And the first  one is needed for initialization of Vazir. So it's code only once on the module startup. The  second one greeting is wrapped by our special procedure macro FC and this makes this function  exported from a module and allows other modules or ACOMARINE scripts called. And so as you see,  you can find the complete example of the service by the link on the bottom of the slide. So this  FC macro could be applied to function, external bulk and structures. So applying to functions is  as we saw on the previous slide, made this function exported from module. Applying to  external block tells our building tools that a module requires imports from such module. For  example, in this case, it's CurveAdapter. And the last one option provides a way to use structure  types in signature of import and exported function. So in first and second variants. So and finally,  in this section, we discussed FC and our SDK a little bit. And you can find repository for  them by these links. And also we have documentation about module developing that could be found  by this link. And so on the next, we will take some hand on section with developing a simple  whole world fluent service. Let's see how simple whole world module could be built for  films and then could be turned to a service. But first of all, we need to install Rust and  also implementry tool, and then install our build tool and tool for dividing. So actually,  you can find all comments on our docs. The link was on the previous on the last slide. So  actually also, I have all this tool installed on my stuff. On your it could take more time  course. And also, please note that it's important to install Nike Rust, because our repo requires  only only nightly to chain of Rust. So then let's install wasp32 was a target, it could be done  by this command. So for me to read installed, then we need to install our building tool. It's code  FCLI. So this command adds binary code FC to your system. And then we also need to install  repo that could be used for dividing. And it is so we installed Rust wasm32 was a target for us,  and our building can divide tools. And actually here, we could create a new project. So the  Rust could be done by cargo new, let's call it greeting, and make it binary. So here, binary means  that final WebAssembly binary, you contain some internalization code for rising. So it's important  to make it binary. So okay. And then let's edit a little bit cargo to make it compile to WebAssembly.  So and to specify our, our free-winds SDK. So actually, let's change it into something like this one. And also, let's add our SDKs dependency.  Actually, its current version is 2.17. But it doesn't matter for our example, we could use the last one. So  let's save it the next and then let's open our greeting, assert C and main, the main project, main  assert C file. And so here we need to include our macro. So it could be done by this. And then we need to leave main empty.  So and then we could run our main function that wrapped with fc. So let's follow the example that was on  slides. So let's call this function like greeting that takes a string and return a new string. And internally, it could, for  example, append to string something like this. Yep. So and it is. And actually, it is all code for simple whole world. There are only  two functions main for initializing quasi and greeting as a main export functions. So it is. And then we need to compile this.  Compiling is done by our fc. So we could compile it by fc build. It just a wrapper on cargo that could embed interface types. So  after compiling, it takes some time to different on the cache of compiled cargo artifacts. So also fc allow you to, for example,  find out what interface types is generated. For example, let's see for our case. Because we haven't specified release. So it's should contain  should I keep it in debug folder. So and here we can see generated interface types for our simple binary. So then let's convert it to a  service to convert to this binary, this service module to a service, we need to do only one thing. So actually, we need to write a config.  Yep, let's create a new config. Tomo and so just write something something like this. So here we specify that. Binary for this service is  located on this folder called artifact. And the service is consistent on one module called greeting. And it is so that's all. Let's say  we'll be successfully created any service greeting. And then let's see how it could be called. Actually, there are several ways to call it one  way to upload it. And then call it with a submarine or something like that. But for the binding purposes, we have special tool called  Ripple. But first of all, we need to create a different folders and then copy our greeting binaries to it. So something like that. Then we could run fc  rebel and specify config config Tomo do it. Actually, rebel supports several comments for loading and loading modules, coding, obtaining their  interfaces, environment variables file system, state and so on. But today for us important to call module and see, see the result of  calling. So calling module should be done with specifying module name in our case is greeting, export function name in our case, it's also called  greeting and arguments and arguments should be encoded in JSON. So it could look like this. And let us see something like John. And here we see  that the result is a high John. Yep. It's the same string that we expected. So thank you very much. On this, on this my section is done. On next  section, on the next section, you will see how more complex services could be built, then how they could be deployed to fluent network and  called by Akoma. Thank you. Hello, my name is Dmitry. I'm a software developer in Fluence. Let's continue our journey to the fluent  system. I hope that you already saw previous videos of our speech series. Today, I'll show you some tips and tricks on how to build  services in the fluence network. I'll take services that we used in fluence part project, for example, to start the creation of our  service, we simply initialize our REST project and on Fluence library to dependencies as you see on the screen. First of all, we want to  initialize our fresh services in service lifecycle, it could be logger initialization as you see on the screen, or creating a database or  initialization some preloaded data. And we use the main method for this. So how to build functions that we could call from  AirScrip. As Michael already said, we need to mark our functions with FCE tag. FCE environment doesn't support result types as a result.  So we need to wrap possible errors in structure. For this, we create custom structures, as you see on the screen, with the return  code to understand if it is an error or a successful result for every function and convert results to these structures for the  convenience of application development. And this is code for conversion. So when our methods, we just use into and convert our simple  function that returns out to our structures. And to use the structures from AirScript, we mark them with the FCE tag as well. This project is  quite simple, we just add some data to our storage and return it if needed. For this, we have a join function to add user to database to  some sort of storage live user to delete user from our storage and some helper functions that we later discuss. In this example, we use  in memory storage that will be cleaned after service will restart, not restart or some other reason. As you see, it's only a hash map to store  our data. But if needed, we can connect and use database modulus. We have a school light and registers was modulus for now, but it is  possible to create a proxy models for every database and other stuff that can use a file system and store data and long term storage  to connect other modulus, we need to describe a P of a model to connect it to your code. For this, we need to write this code. We  need to tag our code with FCE tag, write our model name as you see on the screen and add functions from this model. If you make a mistake  in your code, you'll see it when you compile your was modulus in a frapple as Michael said before, or after deploying node will return an error  that it cannot create such link of models. After this, you could simply use these functions in your code as you see on the screen. Do you see  CLI or maybe some operating system comments you need to import host functions like this. So main difference is that name of model is host. And here is a CLI  tool name and comments are passed as string. If you want to use file system, you can use it as you would normally do it in Rust, but all this, like file system or other  modules or host functions should be specified in the config that Michael mentioned before. Another important thing that we need to build our services properly is  authorization and authentication. First of all, to check if a caller is an owner of a service, or it exists in some sort of list, we need to get the colors  ID. These and other useful info could be found in call parameters. Call parameters we could get like this. And what is call parameters? It's all necessary information  about color and about arguments that we pass through our function. It is like initpred, service ID, service creator pred, host ID, particle ID, and tetra plates. So here in  the user list, we only need an initpred to check. But what if we need to verify into that the user is authorized in other services? So let's have a look in a history service that store our messages and these messages  could add only that users that is authorized in user list service. In user list, we have a function that called isUntiticated and it return a result of  authentication. So if user is in list or he is an owner of this service, we return true, otherwise we return false. So how can we check it in history service? This is our function to add messages. And we have argument called  alpha. That is a boolean. How can we check from this argument that it is valid info from user service? We check it in isUntiticated function. So let's have a look. First of all, what we need is get our call  parameters. As we seen before, and then we need to check our tetra plates. Tetra plate is a security tetra plate that store necessary data to have a proof of calls. So here we have pure public case service ID function name and just on path. How can we use it? So tetra plates are  vector of vector. First vector is as our list of arguments in function. And second vector is for the case if our argument is a vector and we need to check each element of this  vector. So simply we have an index of our argument and we get tetra plate for our argument and all that we need that tetra plate for our argument match the specified parameters. As you see, we need to check all fields of our tetra plate with specified  parameter and that auth is true. After that, we can be sure that the call is authorized. After we write our code, we can build our services with FCE and upload them via js JavaScript SDK. To simplify this process and use simple commands from the terminal, we wrote  protodistributor that use js SDK and could upload models, create blueprints and services. Let's have a look on this thing. This command line tool could be found in our GitHub repository. I'll show you how to do this in a few steps. First of all, we can look at the help and use comments to upload our  model. With this comment, we could upload, for example, user list, basm file that we will name as user list. So model uploaded successfully. And after this, we need to create blueprint in which we list all our  modulus that we want to use in our service. So it looks like this. Command called add blueprint. Here we need to list our dependencies. Here we have only one dependency, but if we want to use maybe a  SQLite, we need to add this before model that used this model. After that, we need to specify an idea of our blueprint. It could be some custom ID, maybe UU ID or something like that. And the name of blueprint. So blueprint usually started successfully. And after that, we need to create  a service. So here we use blueprint ID to do a call to a service as an owner. So it's just create our service. And here is our service ID to use in our air scripts or in JS SDK. That's all with these services, we could build big network, big application that will use services from other  providers that can use data storage, local storage, file system, operating system, comments, and other stuff. Thank you for watching. And let's move on to the next video.  Thank you for watching. And let's move on to the next video.  Hi, everyone. Welcome to the second day of FOSDEM.  Can you hear me? Hi, everyone. Welcome to the second day of FOSDEM.  Welcome to the second day of FOSDEM. And we hear your...  It seems that you should skip your record. I mean stream.  So we are live. I understand you. Yes. Hello, everyone.  Hi there. It seems that there are no many questions.  Anybody here? First of all, we have some updates after this video recorded. So like about Protodydistributor, you can use it without cloning the repo. So we can install it like with the NPM.  And then install FLDist. It's called FLDist. And it becomes much simpler to upload models to run services on our network.  And we are waiting for questions. How can I import the existing model? I thought it's possible to use Kuro. How?  So, Michael, can you answer this question?  So first of all, thank you for the question. So regarding the first part about how can you import existing modules. So there are actually several ways.  The most common here is like in Rust, of course, yes, because we have SDK for Rust only now. And in Rust, you could use it called foreign-mode construction, like when you write XTERM-C.  And then here in this block, you could write a function that you could import from existing modules. And also, it should be wrapped with our FC macro.  And it's in itself. So it's the only thing that you need to do to import existing module. And if you want to use Rapples, you should load it explicitly by the command.  So regarding the next part about how to use Kuro, yes, actually, you're right. It's possible. And you provide an option to use so-called mounted binaries.  So mounted binaries is a special field in config where you could specify which binaries from your operation system could be called.  So, and for example, you could see in our repository and in FC, you could see an example of this config.toml file, whereas Kuro with R-specified.  So, and actually, after all of this, after specifying in config, you could use it in your Rust module as a usual function. The function that receives string is an argument and output types is also string.  I can show it. I think. Great.  So, in this case, we'll download, by Kuro can download pages and store it on in file system. So, how we can import Kuro? It's, it looks like this macro where we use host.  And the name of function is the name of command. So, cmd is arguments after the command.  And config, I don't know if it here.  So, in this set, we need to, this is a name of function and this is the path to our binary.  And that's it.  And Follux is a copy of this information.  And it's like, by the examples more updated.  Maybe you could show our repositories and also, whereas each of them could be found.  Yeah.  All repositories influence labs company. And for now, I think most updated for examples is at Denner hackathon repository that have examples with off front end part and back end part.  We have services that go into Ethereum.  And, you know, notice by Kuro. And there is a lot of documentation how to use it and all description about how it works.  And after this, what Michael talked about is FCE. It's a compute engine that could start awesome files and combine it with each other.  And also, there is examples that you can start with.  And some other parts is, so my, my, where not notice is you can start notice you can work the code, if you want, it's fluence repo.  And it's how you can upload your models and create services in network.  And it could be used like you can install.  You can use it once labs.  And after installation, you can use it like all possible ways you can, you can check what interfaces uploaded in network right now.  List of models upload model.  Like to create services, create service and other stuff.  Part work only on one note, but a little bit later, you can choose different notice, you can use your own key pairs to create services that will be owned by you.  And then you can come in.  So how can it come in?  Maybe control plus.  Yeah.  So, and yeah, this is the tool that I, that we use for like working with the network, uploading models creating blueprints blueprints is the list.  Simply it is a list of models that will be combined by FCE and linked between each other by FCE.  And then with this blueprint, you can create your own service and each service is like one thread in note that could be used separately separately.  And right now, where this deployed.  Thank you for question.  It is deployed on fluence notice you can run your own note.  So in testnet we have like 10 or maybe more notice.  And on them.  Services will be deployed.  Maybe Mike could say something more about this.  I can actually know I think that your answer question, but so if it's if it's not, please elaborate a little bit what you mean by deployed.  Yeah.  So, and this tool is like CLI tool so it isn't deployed anywhere is just so like to to for to to explore services and our notes.  And about the plan.  As I said, first you need to upload model.  Then you need to create blueprint that describes which models should be in your service and then create service and it will be deployed on fluence notice or you all not or some note that you want.  Like you can create multiple internal networks of fluence notice and.  Yeah.  And choose not that you want.  Yeah, maybe follow it's good.  The doctor create new notice.  Maybe folks you can link this because  Wait a second. Yeah.  So, and yeah, this link is also for all documentation about uploading lunch note using front front end like this.  And a lot of other useful information.  So we are waiting for other questions.  How much table is for us.  For now, it's not very stable because we are on like test net phase.  But we work with it. We working on security model, a lot and on stabilization.  So it's, it's an high development phase right now.  Yes, and our point is to finish.  So the first phase of blockchain this somewhere around the summer.  And now all other parts is almost done, but then maybe not in the 100% stable phase actually so they're developing a lot now.  But if you want to use some somehow so we would like to help you in any case so if you have any questions please ask us in our discord and our discussions or in telegram group so we would like to answer your questions.  Also, and help with the stuff lunch note or using just as the care using some models creating models to be great.  I do I understand correctly that when blockchain layer comes in the developers would be able to monetize their code their modules or services.  Yes, so, so, Mike, you can you put on some.  I think so. Yes, but I think it's maybe the point here is not blockchain but maybe a main net.  And what I say it seems that we do not have any deadline for main net now on the football chain.  And with blockchain year to the possible to monetize your code and we working on economic model right now we have like a lot of research about economic model.  And the main party that we want to make it be able to monetize every app that you will upload to fluence network.  Every player in our network will be monetized like a not influence not creator of model, not that run services on their own computers.  So, creator will be monetized, not will be monetized and people who create their services on on the top of other services will be monetized as well by users that will be use services and by other models that we will.  And maybe you know, we will talk about economic model here or we maybe talk before we'll talk.  No, it's not.  And what people can do already now.  So, for now people can create their own models and services, they can run their own notice, they can create services on notice and use them from fluence.js is the case.  And also they could run a common in scripts across the fluence network, and more about a common scheme to be presented on the next talk. So that will be in about five minutes.  Yeah, and a little bit about a chlorine script so it's a glue that can link different services in network in like one.  I don't know how to describe one runtime call maybe something like this. So one super service.  One super service like distributed with different services and you can run it with aquamarine right now, but under aquamarine is a bottom layer language.  So, a little bit later we will create top level language that will be much more easy to use.  So yes, I can read now has only a common intermediate representation so because it air.  So it's like a kind of low level language that has some primitives.  Like inspired by type to be calculus, but in future yes we are working on high level language that will be much simpler than air.  And actually so if you can see so all fluence is about is about components and about modules.  So, inside all of this, there is a one little module, and several modules could be combined to a sense equal service.  Several services could be combined to application or like super service that has aquamarine scripts that could call each services inside this application.  So it's like a module systems.  Or like a way to combine your applications.  And the great thing that you can use all languages that like all libraries in your office.  Thank you.
fluence_backend_0_1115.png fluence_backend_1116_1163.png fluence_backend_1164_3971.png fluence_backend_3972_6995.png fluence_backend_6996_7067.png fluence_backend_7068_9803.png fluence_backend_9804_10619.png fluence_backend_10620_13043.png fluence_backend_13044_14351.png fluence_backend_14352_16019.png fluence_backend_16020_16403.png fluence_backend_16404_21719.png fluence_backend_21720_22511.png fluence_backend_22512_23543.png fluence_backend_23544_25055.png fluence_backend_25056_25859.png fluence_backend_25860_26303.png fluence_backend_26304_26495.png fluence_backend_26496_26663.png fluence_backend_26664_28331.png fluence_backend_28332_30743.png fluence_backend_30744_32279.png fluence_backend_32280_33071.png fluence_backend_33072_37379.png fluence_backend_37380_44531.png fluence_backend_44532_45407.png fluence_backend_45408_45527.png fluence_backend_45528_45803.png fluence_backend_45804_45863.png fluence_backend_45864_45959.png fluence_backend_45960_46139.png fluence_backend_46140_46271.png fluence_backend_46272_47291.png fluence_backend_47292_47987.png fluence_backend_47988_50975.png fluence_backend_50976_51023.png fluence_backend_51024_51095.png fluence_backend_51096_52655.png fluence_backend_52656_53687.png fluence_backend_53688_53819.png fluence_backend_53820_53975.png fluence_backend_53976_55343.png fluence_backend_55344_55475.png fluence_backend_55476_55523.png fluence_backend_55524_55931.png fluence_backend_55932_56063.png fluence_backend_56064_56351.png fluence_backend_56352_58187.png fluence_backend_58188_60743.png fluence_backend_60744_60827.png fluence_backend_60828_60911.png fluence_backend_60912_61295.png fluence_backend_61296_64835.png fluence_backend_64836_66011.png fluence_backend_66012_66395.png fluence_backend_66396_66563.png fluence_backend_66564_66827.png fluence_backend_66828_67091.png fluence_backend_67092_68579.png fluence_backend_68580_69923.png fluence_backend_69924_70091.png fluence_backend_70092_70523.png fluence_backend_70524_70883.png fluence_backend_70884_71423.png fluence_backend_71424_71471.png fluence_backend_71472_72143.png fluence_backend_72144_74063.png fluence_backend_74064_74255.png fluence_backend_74256_75131.png fluence_backend_75132_75254.png