swap fldist for aqua cli

This commit is contained in:
boneyard93501 2022-02-07 23:56:51 -06:00
parent 1b65d678a0
commit 430acaf1d9

View File

@ -19,8 +19,8 @@ ToDos:
- [ ] Refactor CLI adapter for optional built-in deployment - [ ] Refactor CLI adapter for optional built-in deployment
- [ ] Separate HTTP from CLI code - [ ] Separate HTTP from CLI code
- [ ] Add multimodule tests - [ ] Add multimodule tests
- [ ] Add use of Aqua demo - [X] Add use of Aqua demo
- [ ] Change fldist to aqua cli - [X] Change fldist to aqua cli
For another, comprehensive, end-to-end implementation of an adapter, see [Aqua IPFS Library](https://doc.fluence.dev/aqua-book/libraries/aqua-ipfs) and [Aqua IPFS demo](https://github.com/fluencelabs/examples/tree/main/aqua-examples/aqua-ipfs-integration). For another, comprehensive, end-to-end implementation of an adapter, see [Aqua IPFS Library](https://doc.fluence.dev/aqua-book/libraries/aqua-ipfs) and [Aqua IPFS demo](https://github.com/fluencelabs/examples/tree/main/aqua-examples/aqua-ipfs-integration).
@ -235,28 +235,35 @@ result: String("{\"streamId\":\"kjzl6cwe1jw147gy6h9ygbtzzs0pjg4qyhp4bhx69k88h25e
That is, `...\"chainId\":\"eip155:3\",\"blockNumber\":11266361,\"blockTimestamp\":1634752889}, ...` contains the chain confirmation reference and is readily viewable on [etherscan](https://ropsten.etherscan.io/block/11266361). That is, `...\"chainId\":\"eip155:3\",\"blockNumber\":11266361,\"blockTimestamp\":1634752889}, ...` contains the chain confirmation reference and is readily viewable on [etherscan](https://ropsten.etherscan.io/block/11266361).
Looks like our services are working and ready for deployment to the `stage` network. We use [`fldist`] command line tool to do so: Looks like our services are working and ready for deployment to the `stage` network. We use the `aqua` command line tool to do so:
```bash ```bash
fldist new_service \ aqua dist deploy \
--ms artifacts/curl_adapter.wasm:configs/curl_adapter_cfg.json \ --addr /dns4/stage.fluence.dev/tcp/19004/wss/p2p/12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE \
artifacts/ceramic_adapter_custom.wasm:configs/ceramic_adapter_cfg.json \ --data-path configs/ceramic_adapter_deploy_cfg.json \
--name ceramic-adapter \ --service ceramic-service
--verbose \
--env stage
``` ```
Which gives us our service id: Which gives us our service id:
```bash ```bash
client seed: GaVNhWaCzVc943kcxXhPbnbEmHFg1uUNNLHEKHVg6aTc Your peerId: 12D3KooWRhFutxYqaX9MEhR1vB98xSwjcerfR4p3MEMmbFwkeJJQ
client peerId: 12D3KooWS7mqgD5QUutPVuU4WoXdPUL8zzJpdPM44PzSYSTXYhcX "Going to upload a module..."
relay peerId: 12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE 2022.02.07 10:27:34 [INFO] created ipfs client to /ip4/134.209.186.43/tcp/5004
service id: 86314188-0571-4f42-8873-0cb07ffdcdcf # <-- this is different for you 2022.02.07 10:27:34 [INFO] connected to ipfs
service created successfully 2022.02.07 10:27:37 [INFO] file uploaded
"Going to upload a module..."
2022.02.07 10:27:37 [INFO] created ipfs client to /ip4/134.209.186.43/tcp/5004
2022.02.07 10:27:38 [INFO] connected to ipfs
2022.02.07 10:27:41 [INFO] file uploaded
"Now time to make a blueprint..."
"Blueprint id:"
"3ad65d83d277d3628ba930dcf65c5d71b53b0fc2af5815d4c727d53a8acbcefd"
"And your service id is:"
"39a67931-bca1-41b6-b64e-f8a5e68ac328" # <-- this is different for you
``` ```
With our modules deployed and linked into service `86314188-0571-4f42-8873-0cb07ffdcdcf`, we are now ready to utilize Ceramic streams from the Fluence network with Aqua. With our modules deployed and linked into service `39a67931-bca1-41b6-b64e-f8a5e68ac328`, we are now ready to utilize Ceramic streams from the Fluence network with Aqua.
## Using the Ceramic Adapter With Aqua ## Using the Ceramic Adapter With Aqua
@ -300,7 +307,7 @@ func roundtrip(payload:string, payload_two: string, node:string, service_id:stri
<- create_res.stdout, show_res.stdout, update_res.stdout <- create_res.stdout, show_res.stdout, update_res.stdout
``` ```
We created three Aqua demo functions and used marine to export all interfaces to our aqua file before we added our code with `marine aqua artifacts/ceramic_adapter_custom.wasm >> aqua/ceramic_demo.aqua`.: We created three Aqua demo functions and used marine to export all interfaces to our aqua file before we added our code with `marine aqua artifacts/ceramic_adapter_custom.wasm >> aqua/ceramic_demo.aqua`.:
- `func create(payload:string, node:string, service_id:string) -> string:` shows how to create a stream and return only the StreamId as a string - `func create(payload:string, node:string, service_id:string) -> string:` shows how to create a stream and return only the StreamId as a string
- `func create_obj(payload:string, node:string, service_id:string) -> CeramicResult:` shows how to create a stream and return the `CeramicResult` struct - `func create_obj(payload:string, node:string, service_id:string) -> CeramicResult:` shows how to create a stream and return the `CeramicResult` struct
@ -309,88 +316,61 @@ We created three Aqua demo functions and used marine to export all interfaces to
For the purposes of this demo, we continue to use `fldist` to run our Aqua scripts and therefore compile `ceramic_demo.aqua` to (raw) AIR: We continue to use `aqua` cli to run our Aqua scripts. First, let's run our simple `create` which returns the StreamId as a string:
```bash ```bash
aqua -i aqua -o compiled-aqua -a aqua run -i aqua \
--addr /dns4/stage.fluence.dev/tcp/19004/wss/p2p/12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE \
-f'create(arg, "12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE", "39a67931-bca1-41b6-b64e-f8a5e68ac328")' \
-d '{"arg": "{\"foo\":\"bar\"}"
}'
``` ```
which gives us an AIR file for each functions: Returns:
```bash ```bash
2021.10.20 14:43:50 [INFO] Aqua Compiler 0.3.2-233 Your peerId: 12D3KooWKgpdZo2xVDYQ9MPqT3tMQwgo2zWQFWNtVPYWyhLN5kK5
2021.10.20 14:43:51 [INFO] Result /Users/bebo/localdev/examples/aqua-examples/ceramic-demo/compiled-aqua/ceramic_demo.create.air: compilation OK (3 functions, 1 services) "kjzl6cwe1jw145d1ks7ubujk6hxc8em4n3z65may2mc9b321wep8hci0eprrpo3"
2021.10.20 14:43:51 [INFO] Result /Users/bebo/localdev/examples/aqua-examples/ceramic-demo/compiled-aqua/ceramic_demo.create_obj.air: compilation OK (3 functions, 1 services)
2021.10.20 14:43:51 [INFO] Result /Users/bebo/localdev/examples/aqua-examples/ceramic-demo/compiled-aqua/ceramic_demo.roundtrip.air: compilation OK (3 functions, 1 services)
``` ```
Let's run through our Aqua functions. First, we run our simple `create` which returns the StreamId as a string: Now, we run the same functionality but with the `CeramicResult` as the return value:
```bash ```bash
fldist --node-id 12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE \ aqua run -i aqua \
run_air \ --addr /dns4/stage.fluence.dev/tcp/19004/wss/p2p/12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE \
-p compiled-aqua/ceramic_demo.create.air \ -f'create_obj(arg, "12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE", "39a67931-bca1-41b6-b64e-f8a5e68ac328")' \
-d '{"node":"12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE", -d '{"arg": "{\"foo\":\"bar\"}"
"service_id":"86314188-0571-4f42-8873-0cb07ffdcdcf", }'
"payload": "{\"foo\":\"bar\"}"}'\
--env stage \
--generated
```
Yields:
```bash
[
"kjzl6cwe1jw14b840zszph98opnp0mlt2ca2y77ln2crxtljmnknsomfx036q4u"
]
```
Please note that we need to escape the Ceramic payload(s)! Now, we run the same functionality but with the `CeramicResult` as the return value:
```bash
fldist --node-id 12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE \
run_air \
-p compiled-aqua/ceramic_demo.create_obj.air \
-d '{"node":"12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE",
"service_id":"86314188-0571-4f42-8873-0cb07ffdcdcf",
"payload": "{\"foo\":\"bar\"}"}' \
--env stage \
--generated
``` ```
Which returns the `CeramicResult` object: Which returns the `CeramicResult` object:
```bash ```bash
[ Your peerId: 12D3KooWLsy44ycUSiQzEDX9PNZW3XEpLmAcLMaKxCZHqJKhu2Uc
{ {
"ret_code": 0, "ret_code": 0,
"stderr": "", "stderr": "",
"stdout": "kjzl6cwe1jw14atuounxr2gi9ddc5i8ale3rgti7qetao8j81v6ea00ek8b7cdb" "stdout": "kjzl6cwe1jw1485qhhhjzpua7cc7xq03qqi2z0w93e12qc1w8sob78o2pebdvef"
} }
]
``` ```
This allows us to access members with the dot notation, e.g, CeramicResultObj.stderr. Finally, we run our roundtrip function where we create, update and show: This allows us to access members with the dot notation, e.g, CeramicResultObj.stderr. Finally, we run our roundtrip function where we create, update and show:
```bash ```bash
fldist --node-id 12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE \ aqua run -i aqua \
run_air \ --addr /dns4/stage.fluence.dev/tcp/19004/wss/p2p/12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE \
-p compiled-aqua/ceramic_demo.roundtrip.air \ -f'roundtrip(arg, arg_2, "12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE", "39a67931-bca1-41b6-b64e-f8a5e68ac328")' \
-d '{"node":"12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE", -d '{"arg": "{\"foo\":\"bar open\"}", "arg_2":"{\"foo\":\"bar closed\"}"}'
"service_id":"86314188-0571-4f42-8873-0cb07ffdcdcf",
"payload": "{\"foo\":\"bar\"}",
"payload_two":"{\"foo\":\"bar open\"}"}' \
--env stage \
--generated
``` ```
Which returns the triple: Which returns the triple:
```bash ```bash
Your peerId: 12D3KooWDvsgbe7MByxPkCwLU96kLcaq3Fyyc15w8SpZf6ELwtAW
[ [
"kjzl6cwe1jw145gqlqwk0vv4bktbtn654fur4o9dyqdo797bkbohfa0wuip7b9l", "kjzl6cwe1jw149tb39f0fe8bmig9kfi49ih2wuf09eslamxb4hckwgrfk2ivox9",
"{\n \"foo\": \"bar\"\n}\n", "{\n \"foo\": \"bar open\"\n}\n",
"{\n \"foo\": \"bar open\"\n}\n" "{\n \"foo\": \"bar closed\"\n}\n"
] ]
``` ```