Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support multi-cu contracts [BRND-48] #282

Merged
merged 7 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:

uses: fluencelabs/nox/.github/workflows/build.yml@master
with:
ref: multi_cu
cargo-dependencies: |
[
{
Expand All @@ -64,4 +65,5 @@ jobs:
- nox-snapshot
uses: fluencelabs/cli/.github/workflows/tests.yml@main
with:
ref: up-clients
nox-image: "${{ needs.nox-snapshot.outputs.nox-image }}"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
/src/air
/src/distro/decider-spell
/src/compiled-aqua/

shell.nix
4 changes: 2 additions & 2 deletions src/aqua/deal/install.aqua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func install_deal(settings: WorkerSettings, deal: Deal) -> ?WorkerId:
log = (msg: ⊤):
deal_log(deal.deal_id, msg)

worker_id <- WorkerHelper.get_or_create(deal.deal_id, deal.unit_ids)
worker_id <- WorkerHelper.get_or_create(deal.deal_id, deal.cu_ids)
if worker_id != nil:
-- If it's not active, the deal is installed
if Worker.is_active(deal.deal_id):
Expand All @@ -99,7 +99,7 @@ func install_deals(worker_settings: WorkerSettings, deals: []Deal):
worker_id <- install_deal(worker_settings, deal)
if worker_id != nil:
deal_log(deal.deal_id, ["Worker installed", worker_id])
tx_hash <- register_worker(deal.deal_id, worker_id!, deal.unit_ids)
tx_hash <- register_worker(deal.deal_id, worker_id!, deal.onchain_worker_id)
if tx_hash != nil:
DealStorage.store_deal(deal.deal_id, tx_hash!)
else:
Expand Down
10 changes: 6 additions & 4 deletions src/aqua/fluence/connector.aqua
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@
aqua Connector declares *

import CUID from "@fluencelabs/aqua-lib/workers.aqua"
import DealId, TxHash, Deal from "../types.aqua"
import DealId, TxHash, Deal, OnChainWorkerId from "../types.aqua"


data DealInfo:
-- For comparison, use DEAL_STATUS_* from consts.aqua
status: string
unit_ids: []CUID
cu_ids: []CUID
app_cid: string
onchain_worker_id: OnChainWorkerId

func info_to_deal(deal_id: DealId, deal_info: DealInfo) -> Deal:
<- Deal(
deal_id = deal_id,
status = deal_info.status,
app_cid = deal_info.app_cid,
unit_ids = deal_info.unit_ids
cu_ids = deal_info.cu_ids,
onchain_worker_id = deal_info.onchain_worker_id
)

data DealResult:
Expand Down Expand Up @@ -61,7 +63,7 @@ data TxResult:

service ChainConnector("connector"):
-- Register a worker on chain
register_worker(deal_id: string, worker_id: string, unit_ids: []CUID) -> TxHash
register_worker(deal_id: string, worker_id: string, onchain_worker_id: OnChainWorkerId) -> TxHash
-- Get the list of current deals
get_deals() -> []DealResult
-- Get transaction receipts for the given transaction hashes
Expand Down
4 changes: 3 additions & 1 deletion src/aqua/types.aqua
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ alias SpellId: string
alias WorkerId: string
alias CID: string
alias TxHash: string
alias OnChainWorkerId: []u8

data Deal:
deal_id: DealId
-- For comparision, use DEAL_STATUS_* from consts.aqua
status: string
unit_ids: []CUID
cu_ids: []CUID
app_cid: string
onchain_worker_id: OnChainWorkerId
6 changes: 3 additions & 3 deletions src/aqua/worker/register.aqua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Spell, TriggerConfig from "@fluencelabs/spell/spell_service.aqua"
import "@fluencelabs/spell/spell_service.aqua"

import deal_log, spell_log from "../fluence/spell.aqua"
import DealId, WorkerId, TxHash from "../types.aqua"
import DealId, WorkerId, TxHash, OnChainWorkerId from "../types.aqua"
import ChainConnector from "../fluence/connector.aqua"

use "../storage/tx.aqua" as TxStorage
Expand All @@ -33,7 +33,7 @@ import "../consts.aqua"
import Json from "../fluence/peer.aqua"


func register_worker(deal_id: DealId, worker_id: WorkerId, cu_ids: []CUID) -> ?TxHash:
func register_worker(deal_id: DealId, worker_id: WorkerId, onchain_worker_id: OnChainWorkerId) -> ?TxHash:
tx_hash: *TxHash
try:
exsiting_hash <- DealStorage.get_tx(deal_id)
Expand All @@ -42,7 +42,7 @@ func register_worker(deal_id: DealId, worker_id: WorkerId, cu_ids: []CUID) -> ?T
tx_hash <<- exsiting_hash!
else:
deal_log(deal_id, ["Registering worker"])
tx <- ChainConnector.register_worker(deal_id, worker_id, cu_ids)
tx <- ChainConnector.register_worker(deal_id, worker_id, onchain_worker_id)
TxStorage.store_tx(deal_id, tx)
deal_log(deal_id, ["Worker registered, tx hash:", tx])
tx_hash <<- tx
Expand Down
Loading
Loading