Skip to content

Commit

Permalink
fix(worker): shift ipfs to the host scope (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurinderu authored Jan 31, 2024
1 parent 7708aab commit dcedc75
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ jobs:
with:
version: main

- run: pnpm pack
working-directory: ./src/aqua/spell

- run: pnpm pack
working-directory: ./src/aqua/installation-spell

- run: fluence dep i

- name: Check if aqua compiles
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ jobs:
run: pip install -r requirements.txt
working-directory: integration-tests

- run: pnpm install -r

- run: pnpm pack
working-directory: ./src/aqua/spell

- run: pnpm pack
working-directory: ./src/aqua/installation-spell

- run: fluence dep i

- name: Check spell Aqua compiles
Expand Down
22 changes: 11 additions & 11 deletions fluence.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

# Documentation: https://github.com/fluencelabs/cli/tree/main/docs/configs/fluence.md

version: 5
version: 6

aquaInputPath: integration-tests/aqua

dependencies:
npm:
"@fluencelabs/spell": "../../src/aqua/spell"
"@fluencelabs/installation-spell": "../../src/aqua/installation-spell"
"@fluencelabs/aqua-lib": 0.9.0
"@fluencelabs/registry": 0.9.2
"@fluencelabs/aqua-ipfs": 0.5.28
cargo:
marine: 0.14.0
mrepl: 0.21.3
aquaDependencies:
"@fluencelabs/spell": file:./src/aqua/spell/fluencelabs-spell-0.6.9.tgz
"@fluencelabs/installation-spell": file:./src/aqua/installation-spell/fluencelabs-installation-spell-0.6.9.tgz
"@fluencelabs/aqua-lib": 0.9.1
"@fluencelabs/registry": 0.9.4
"@fluencelabs/aqua-ipfs": 0.5.30

marineVersion: 0.14.0

mreplVersion: 0.21.3
4 changes: 4 additions & 0 deletions integration-tests/aqua/test_spells.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua SpellsTest

export inc_other_spell, inc_value

import "@fluencelabs/aqua-lib/math.aqua"
import "../../src/aqua/spell/spell_service.aqua"

Expand Down
1 change: 1 addition & 0 deletions src/aqua/installation-spell/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
src/ts/src/aqua
src/js/src/aqua
air
*.tgz
18 changes: 9 additions & 9 deletions src/aqua/installation-spell/src/aqua/spell.aqua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
aqua Spell declares install

import Op, Hash, Dist, Srv, Debug from "@fluencelabs/aqua-lib/builtin.aqua"
import Ipfs from "@fluencelabs/aqua-ipfs/ipfs.aqua"
import get_from, cat_from from "@fluencelabs/aqua-ipfs/ipfs-api.aqua"
import Spell from "@fluencelabs/spell/spell_service.aqua"
import PeerSpell from "@fluencelabs/spell/api.aqua"
import Srv from "@fluencelabs/aqua-lib/builtin.aqua"
Expand Down Expand Up @@ -91,7 +91,7 @@ func deploy_spell(spell: SpellDefinition, ipfs: Multiaddr):
stored_config <- Spell.get_string(config_key(spell.name))
if stored_config.value != spell.config:
log([spell.name, "config mismath, updating config"])
config_json <- Ipfs.cat_from(spell.config, ipfs)
config_json <- cat_from(HOST_PEER_ID, spell.config, ipfs)
if config_json.success:
config <- TriggerConfigJson.parse(config_json.contents)

Expand All @@ -106,7 +106,7 @@ func deploy_spell(spell: SpellDefinition, ipfs: Multiaddr):
stored_init_args <- Spell.get_string(init_args_key(spell.name))
if stored_init_args.value != spell.init_args:
log([spell.name, "init_args changed, updating"])
new_init_args <- Ipfs.cat_from(spell.init_args, ipfs)
new_init_args <- cat_from(HOST_PEER_ID, spell.init_args, ipfs)
if new_init_args.success:
Spell spell.name
Spell.set_json_fields(new_init_args.contents)
Expand All @@ -118,9 +118,9 @@ func deploy_spell(spell: SpellDefinition, ipfs: Multiaddr):
log([spell.name, "init_args successfully updated"])
else:
set_status(INSTALLATION_IN_PROGRESS)
script <- Ipfs.cat_from(spell.script, ipfs)
cfg_json <- Ipfs.cat_from(spell.config, ipfs)
init_args_str <- Ipfs.cat_from(spell.init_args, ipfs)
script <- cat_from(HOST_PEER_ID, spell.script, ipfs)
cfg_json <- cat_from(HOST_PEER_ID, spell.config, ipfs)
init_args_str <- cat_from(HOST_PEER_ID, spell.init_args, ipfs)

if script.success && cfg_json.success && init_args_str.success:
cfg <- TriggerConfigJson.parse(cfg_json.contents)
Expand All @@ -141,8 +141,8 @@ func deploy_spell(spell: SpellDefinition, ipfs: Multiaddr):
func download_service(s: Service, ipfs: Multiaddr) -> []Hash:
hashes: *Hash
for m <- s.modules:
get_wasm <- Ipfs.get_from(m.wasm, ipfs)
json_cfg <- Ipfs.cat_from(m.config, ipfs)
get_wasm <- get_from(HOST_PEER_ID, m.wasm, ipfs)
json_cfg <- cat_from(HOST_PEER_ID, m.config, ipfs)
if get_wasm.success && json_cfg.success:
cfg <- ModuleConfigJson.parse(json_cfg.contents)
hashes <<- Dist.add_module_from_vault(get_wasm.path, cfg)
Expand All @@ -155,7 +155,7 @@ func install(ipfs: Multiaddr, worker_def_cid: CID):

try:
-- download App Config from IPFS
json <- Ipfs.cat_from(worker_def_cid, ipfs)
json <- cat_from(HOST_PEER_ID, worker_def_cid, ipfs)
if json.success:
worker_definition <- WDJson.parse(json.contents)
log(["parsed worker definition", worker_def_cid, worker_definition])
Expand Down
1 change: 1 addition & 0 deletions src/aqua/spell/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.tgz

0 comments on commit dcedc75

Please sign in to comment.