Abilities & Services
While Execution flow organizes the flow from peer to peer, Abilities & Services describe what exactly can be called on these peers, and how to call it.
Ability is a concept of "what is possible in this context": like a peer-specific trait or a typeclass. It will be better explained once abilities passing is implemented.
Ability passing Β· Issue #33 Β· fluencelabs/aqua
GitHub

Services

A Service interfaces functions (often provided via WebAssembly interface) executable on a peer. Example of service definition:
1
service MyService:
2
foo(arg: string) -> string
3
bar() -> bool
4
baz(arg: i32)
Copied!
Service functions in Aqua have no function body. Computations, of any complexity, are implemented with any programming language that fits, and then brought to the Aqua execution context. Aqua calls these functions but does not peak into what's going on inside.

Built-in Services

Some services may be singletons available on all peers. Such services are called built-ins, and are always available in any scope.
1
-- Built-in service has a constant ID, so it's always resolved
2
service Op("op"):
3
noop()
4
​
5
func foo():
6
-- Call the noop function of "op" service locally
7
Op.noop()
Copied!

Service Resolution

A peer may host many services of the same type. To distinguish services from each other, Aqua requires Service resolution to be done: that means, the developer must provide an ID of the service to be used on the peer.
1
service MyService:
2
noop()
3
​
4
func foo():
5
-- Will fail
6
MyService.noop()
7
​
8
-- Resolve MyService: it has id "noop"
9
MyService "noop"
10
​
11
-- Can use it now
12
MyService.noop()
13
​
14
on "other peer":
15
-- Should fail: we haven't resolved MyService ID on other peer
16
MyService.noop()
17
​
18
-- Resolve MyService on peer "other peer"
19
MyService "other noop"
20
MyService.noop()
21
​
22
-- Moved back to initial peer, here MyService is resolved to "noop"
23
MyService.noop()
Copied!
There's no way to call an external function in Aqua without defining all the data types and the service type. One of the most convenient ways to do it is to generate Aqua types from Wasm code in Marine.
Last modified 3mo ago