Skip to content

Commit

Permalink
fix(aqua): fix compilation under fcli 0.8.x (#96)
Browse files Browse the repository at this point in the history
* fix(aqua): fix compilation under fcli 0.8.x

* feat(ci): compile aqua & services in CI

* fix(readme): remove trailing spaces

* fix(ci): rename jobs

* Update README.md

Co-authored-by: boneyard93501 <4523011+boneyard93501@users.noreply.github.com>

---------

Co-authored-by: boneyard93501 <4523011+boneyard93501@users.noreply.github.com>
  • Loading branch information
folex and boneyard93501 authored Sep 26, 2023
1 parent 1ad23ca commit d88bfc1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
cancel-in-progress: true

jobs:
test:
frpc:
uses: ./.github/workflows/tests.yml
with:
ref: ${{ github.ref }}
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
tests:
name: "Tests placeholder"
name: "build"
runs-on: ubuntu-latest

steps:
Expand All @@ -20,4 +20,11 @@ jobs:
repository: fluencelabs/frpc
ref: ${{ inputs.ref }}

- run: exit 0
- name: Install fluence-cli@unstable
run: npm i -g @fluencelabs/cli@unstable

- name: Check if main.aqua compiles
run: fluence aqua --dry

- name: Check if services builds
run: fluence build
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Figure 1: Stylized fRPC Workflow With dAPP
R ->> N: Response or timeout
alt response
N ->> G: response to gateway
G ->> A: response to dApp
G ->> A: response to dApp
else timeout
loop over endpoint urls
N ->> R: try another request
Expand All @@ -33,7 +33,7 @@ Figure 1: Stylized fRPC Workflow With dAPP
G ->> A: response to dApp -- break
end
end
G ->> G: timeout
G ->> G: timeout
G ->> A: no response error
end
```
Expand Down Expand Up @@ -233,7 +233,7 @@ Figure 3: Stylized Project Creation And Deployment Workflow With Fluence CLI
```mermaid
stateDiagram
[*] --> InitProject: fluence init
InitProject --> CreateNewService: fluence service new
InitProject --> AddExistingService: fluence service add
Expand All @@ -259,14 +259,14 @@ workers: # worker settings for deploy
deals: # deal settings for deploy
defaultWorker:
minWorkers: 1 # default min worker settings -- you want your service deployed ot at least 1 worker
targetWorkers: 3 # default max worker settings -- you want your service deployed ot at least 3 workers
targetWorkers: 3 # default max worker settings -- you want your service deployed ot at least 3 workers
hosts:
defaultWorker:
peerIds:
- 12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE

relays: stage # Name of Fluence network used
services:
services:
eth_rpc: # service name
get: wasm-modules/ # and where to get the service config
```
Expand All @@ -293,7 +293,7 @@ Each module includes a module.yaml file in its root, e.g., [eth_rpc](./wasm-modu
# curl-adapter/module.yaml
version: 0
type: rust # language used to code the module
name: curl_adapter
name: curl_adapter
mountedBinaries: # effector module specific: what mechanism is used to access host resources
curl: /usr/bin/curl # host path to binary mapped to the alias used in the module's FFI link section
```
Expand Down Expand Up @@ -334,10 +334,10 @@ deals:
defaultWorker:
definition: Qmcvoi6tZeBEkva2yn7cXJd8GiocKmkuzuz8L9VtfNdSG2, # CID
timestamp: 2023-04-09T06:21:36.559Z,
dealIdOriginal: "0x0CC9E494CaFDea602b09013a8743012Ce720def2", # Original deal id
dealId: 0cc9e494cafdea602b09013a8743012ce720def2, # current deal id which may change after deal update
dealIdOriginal: "0x0CC9E494CaFDea602b09013a8743012Ce720def2", # Original deal id
dealId: 0cc9e494cafdea602b09013a8743012ce720def2, # current deal id which may change after deal update
chainNetwork: testnet, # Fluence on-chain network alias
chainNetworkId: 80001 # Fluence on-chain chain id
chainNetworkId: 80001 # Fluence on-chain chain id
```

See [FLuence CLI](https://github.com/fluencelabs/fluence-cli) for more details. For implementing your business logic with Rust and compiling it to wasm32-wasi, aka Wasm, module(s), see the [Marine book](https://fluence.dev/docs/marine-book/introduction). To learn more about distributed choreography and composition of services, see the [Aqua book](https://fluence.dev/docs/aqua-book/introduction).
Expand All @@ -354,12 +354,12 @@ Figure 4: Stylized fRPC Use With dAPPs

```mermaid
sequenceDiagram
participant D as dApp
participant G as Gateway
participant N as Fluence p2p network
participant R as Centralized RPC providers
G ->> G: Configure and start Gateway
D ->> D: Use gateway Address:port in web3 sdk setup
D ->> G: Make Web3 request
Expand Down Expand Up @@ -469,7 +469,7 @@ The *i* command lists all the exported interfaces from the wasm modules in Aqua

### Adding Modules To A Service

Regardless of your customization requirements, you probably will have no reason to modify the *curl_adapter* and *eth_rpc* modules. However, you may want to add new modules, or even services, to handle your additional business logic requirements. For example, you may want to capture RPC endpoint performance data, such as response times and availability, to some Web3 storage, e.g., IPFS or Ceramic, for further analysis to, say, derive a weighting scheme for endpoint selection.
Regardless of your customization requirements, you probably will have no reason to modify the *curl_adapter* and *eth_rpc* modules. However, you may want to add new modules, or even services, to handle your additional business logic requirements. For example, you may want to capture RPC endpoint performance data, such as response times and availability, to some Web3 storage, e.g., IPFS or Ceramic, for further analysis to, say, derive a weighting scheme for endpoint selection.

Fluence CLI allows you to quickly create a new, or add an existing, module to your project. For example,

Expand Down Expand Up @@ -549,7 +549,7 @@ One little command is doing quite a bit so you don't have to. Let's work through

Fluence CLI did a bunch of work for us behind the scenes and signing the transaction is a lot quicker than entering (virtual) credit card information. The parametric details necessary to write Aqua scripts are save in [deals.aqua](./.fluence/aqua/deals.aqua) and serves as an important dependency in your Aqua scripts, as we'll see in the next section.

Note that the deal's section in [fluence.yaml](./fluence.yaml) specifies the number of workers that should be deployed specified by *targetWorkers*. The default is three (3) and can be customized. It is important to note that this is a desire not a guarantee as the actual deployment depends on the number of peers willing to participate in the deal. Currently, *all* the testnet peers operated by Fluence will participate in your deal.
Note that the deal's section in [fluence.yaml](./fluence.yaml) specifies the number of workers that should be deployed specified by *targetWorkers*. The default is three (3) and can be customized. It is important to note that this is a desire not a guarantee as the actual deployment depends on the number of peers willing to participate in the deal. Currently, *all* the testnet peers operated by Fluence will participate in your deal.

### fRPC Algorithms

Expand Down Expand Up @@ -586,7 +586,7 @@ func randomLoadBalancing(uris: []string, method: string, jsonArgs: []string, cal
-- choose worker randomly
timeW <- NumOp.identity(Peer.timestamp_sec())
workerNumber = timeW % workers.length --< 3
worker = workers[workerNumber]
worker = workers[workerNumber]
-- choose provider randomly
timeP <- NumOp.identity(Peer.timestamp_sec())
providerNumber = timeP % uris.length --< 5
Expand Down
6 changes: 3 additions & 3 deletions src/aqua/main.aqua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "@fluencelabs/registry/subnetwork.aqua"
import Registry, Record from "@fluencelabs/registry/registry-service.aqua"
import "@fluencelabs/spell/spell_service.aqua"

import "workers.aqua"
import get from "deals.aqua"
import "services.aqua"

-- import App from "deployed.app.aqua"
Expand All @@ -26,8 +26,8 @@ export helloWorld, helloWorldRemote, getInfo, getInfos, getInfosInParallel, getW
-- print(any: ⊤)

func getWorkers() -> u32, [][]Service:
workersInfo <- getWorkersInfo()
dealId = workersInfo.deals.defaultWorker.dealId
workersInfo <- get()
dealId = workersInfo.defaultWorker!.dealId
services: *[]Service
on HOST_PEER_ID:
workersOp <- resolveSubnetwork(dealId)
Expand Down

0 comments on commit d88bfc1

Please sign in to comment.