update to aqua cli

This commit is contained in:
boneyard93501 2022-02-08 14:42:55 -06:00
parent 69010c46d0
commit b3de2c11e0
2 changed files with 52 additions and 45 deletions

View File

@ -33,7 +33,6 @@ cargo install mrepl
cargo install marine cargo install marine
npm -g install @fluencelabs/aqua npm -g install @fluencelabs/aqua
npm -g install @fluencelabs/fldist
``` ```
To compile the code to the wasi target: To compile the code to the wasi target:
@ -54,29 +53,32 @@ test the code with
cargo +nightly test --release cargo +nightly test --release
``` ```
and deploy the service to a peer of your choice with the `fldist` tool: and deploy the service to a peer of your choice with the `aqua` cli tool:
```bash ```bash
fldist new_service \ aqua dist deploy \
--ms artifacts/ts_oracle.wasm:artifacts/ts_oracle_cfg.json \ --addr /dns4/kras-06.fluence.dev/tcp/19001/wss/p2p/12D3KooWDUszU2NeWyUVjCXhGEt1MoZrhvdmaQQwtZUriuGN1jTr \
--name ts-consensus \ --data-path configs/ts_oracle_deploy_cfg.json \
--verbose --service ts-oracle
``` ```
As always, take note of the service id and let's compile our Aqua scripts: which results in:
```bash ```bash
# results in air-scripts ts_getter.ts Your peerId: 12D3KooWHS2Eys5GmmdBGZHwUGRM4TRvcaW4m7dgGAShxbMEcKms
aqua -i aqua-scripts -o air-scripts "Going to upload a module..."
2022.02.08 14:30:48 [INFO] created ipfs client to /ip4/161.35.212.85/tcp/5001
2022.02.08 14:30:48 [INFO] connected to ipfs
2022.02.08 14:30:50 [INFO] file uploaded
"Now time to make a blueprint..."
"Blueprint id:"
"5617e051fbd7f8e18dfc16cace62f71f0ff090d576ee09e3520c196ef44f6a79"
"And your service id is:"
"388d8717-b547-43c3-af05-b4713893d453"
``` ```
which generates Typescript code wrapping of the compiled Aqua intermediary representation (AIR) or we can use the `-a` flag to compile Aqua to AIR files: As always, take note of the service id!
```bash
# results in air-scripts
# ts_getter.ts_getter.air and ts_getter.ts_oracle.air
aqua -i aqua-scripts -o air-scripts -a
```
### Approach ### Approach
We implemented a custom service that returns the mode and frequency for an array of timestamps, see `src/` that can be deployed on to any node of the peer-to-peer network and, once deployed, used to in an Aqua script. Moreover, network peers have builtin services including Kademlia and timestamp services. Both custom and bultin services are accessible by Aqua and ready for composition into an application. We implemented a custom service that returns the mode and frequency for an array of timestamps, see `src/` that can be deployed on to any node of the peer-to-peer network and, once deployed, used to in an Aqua script. Moreover, network peers have builtin services including Kademlia and timestamp services. Both custom and bultin services are accessible by Aqua and ready for composition into an application.
@ -138,23 +140,21 @@ We can run our Aqua `ts_oracle` script against the deployed processing service t
```bash ```bash
aqua run \ aqua run \
-i aqua-scripts \ -i aqua \
-a /dns4/kras-02.fluence.dev/tcp/19001/wss/p2p/12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf \ -a /dns4/kras-02.fluence.dev/tcp/19001/wss/p2p/12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf \
-f 'ts_oracle("12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf", "ed657e45-0fe3-4d6c-b3a4-a2981b7cadb9", 5)' -f 'ts_oracle("12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf", "ed657e45-0fe3-4d6c-b3a4-a2981b7cadb9", 5)'
``` ```
Which results in below but may be different for you: Which results in below but may be different for you:
```text ```text
Your peerId: 12D3KooWC6WzVSHaKxkedGcoHJgqj7pEaeXXWsiMtC8M7vjC1qTX Your peerId: 12D3KooWDB6bCvW7vim4iw88TRyyuouLiyZz2Cr2ZdaaBZKJ916d
[ {
{ "err_str": "",
"err_str": "", "freq": 3,
"freq": 4, "mode": 1644352733889,
"mode": 1638595617657, "n": 12
"n": 12 }
}
]
``` ```
Alternatively, we can run the `ts_getter` functions just for the timestamps: Alternatively, we can run the `ts_getter` functions just for the timestamps:
@ -169,24 +169,19 @@ aqua run \
Which gives us just the timestamps, which wil be different for you: Which gives us just the timestamps, which wil be different for you:
```text ```text
Your peerId: 12D3KooWKeRZaNkubmibXhBGVHRC1WBn9h9j4Qao6s9xPdiJiHxu Your peerId: 12D3KooWEdPZCXxSEDMLMTR8doUVhjcZ6YB5CUJnq36QwU65XVFH
[ [
[ 1644352807634,
1638595815113, 1644352807632,
1638595815112, 1644352807630,
1638595815109, 1644352807629,
1638595815112, 1644352807650,
1638595815115, 1644352807630,
1638595815114, 1644352807633,
1638595815111, 1644352807633,
1638595815110, 1644352807634,
1638595815109, 1644352807631,
1638595815111, 1644352807631
1638595815113,
1638595815112,
1638595815111,
1638595815111
]
] ]
``` ```

View File

@ -0,0 +1,12 @@
{
"ts-oracle": {
"name": "ts-oracle",
"modules": [
{
"name": "ts_oracle",
"path": "./artifacts/ts_oracle.wasm",
"logger_enabled": [true]
}
]
}
}