Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit e92daa6

Browse files
fix: stop calling removeCuFromCC (#1133)
* fix image * update chain version * upade bindings dep * use snapshot * use snapshot * allow finish active cc * update lockfile * Apply automatic changes * fix status check * Apply automatic changes * fix text * Apply automatic changes
1 parent 902a8b1 commit e92daa6

7 files changed

Lines changed: 39 additions & 81 deletions

File tree

packages/cli/package/docs/commands/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,12 @@ Move resources from deals, withdraw FLT collateral from capacity commitments, re
319319
```
320320
USAGE
321321
$ fluence provider cc-finish [--no-input] [--peer-names <peer-1,peer-2> | --cc-ids <value>] [--offers
322-
<offer-1,offer-2>] [--env <testnet | mainnet | stage | local>] [--priv-key <private-key>]
322+
<offer-1,offer-2>] [--env <testnet | mainnet | stage | local>] [--priv-key <private-key>] [--force]
323323
324324
FLAGS
325325
--cc-ids=<value> Comma separated capacity commitment IDs
326326
--env=<testnet | mainnet | stage | local> Fluence Environment to use when running the command
327+
--force Allow finish Active CC
327328
--no-input Don't interactively ask for any input from the user
328329
--offers=<offer-1,offer-2> Comma-separated list of offer names. To use all of your offers: --offers
329330
all

packages/cli/package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"whatwg-url": "^14.0.0"
5757
},
5858
"dependencies": {
59-
"@fluencelabs/deal-ts-clients": "0.24.3-feat-beam-support-f0edb5b-8391-1.0",
59+
"@fluencelabs/deal-ts-clients": "0.27.2-release-candidate-v0-27-2-7faf671-9169-1.0",
6060
"@kubernetes/client-node": "github:fluencelabs/kubernetes-client-javascript#e72ee00a52fec4eb4a8327632895d888ee504f4d",
6161
"@libp2p/crypto": "4.0.1",
6262
"@libp2p/peer-id-factory": "4.0.5",

packages/cli/package/src/commands/provider/cc-finish.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717

1818
import { BaseCommand } from "../../baseCommand.js";
1919
import { collateralWithdraw } from "../../lib/chain/commitment.js";
20-
import { CHAIN_FLAGS, FLT_SYMBOL, CC_FLAGS } from "../../lib/const.js";
20+
import {
21+
CHAIN_FLAGS,
22+
FLT_SYMBOL,
23+
CC_FLAGS,
24+
CC_FINISH_FORCE_FLAG,
25+
} from "../../lib/const.js";
2126
import { aliasesText } from "../../lib/helpers/aliasesText.js";
2227
import { initCli } from "../../lib/lifeCycle.js";
2328

@@ -30,6 +35,7 @@ export default class CCFinish extends BaseCommand<typeof CCFinish> {
3035
static override flags = {
3136
...CC_FLAGS,
3237
...CHAIN_FLAGS,
38+
...CC_FINISH_FORCE_FLAG,
3339
};
3440

3541
async run(): Promise<void> {

packages/cli/package/src/lib/chain/commitment.ts

Lines changed: 15 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -538,14 +538,24 @@ export async function removeCommitments(flags: CCFlags) {
538538
export async function collateralWithdraw(
539539
flags: CCFlags & {
540540
[FINISH_COMMITMENT_FLAG_NAME]?: boolean;
541+
force?: boolean;
541542
},
542543
) {
544+
const isStatusAllowed: (status: CapacityCommitmentStatusString) => boolean =
545+
flags.force === true
546+
? (status) => {
547+
return (
548+
status === "Completed" || status === "Failed" || status === "Active"
549+
);
550+
}
551+
: (status) => {
552+
return status === "Completed" || status === "Failed";
553+
};
554+
543555
const [invalidCommitments, commitments] = splitErrorsAndResults(
544556
await getCommitmentsGroupedByStatus(flags),
545557
(c) => {
546-
return c.status === "Completed" || c.status === "Failed"
547-
? { result: c }
548-
: { error: c };
558+
return isStatusAllowed(c.status) ? { result: c } : { error: c };
549559
},
550560
);
551561

@@ -570,52 +580,6 @@ export async function collateralWithdraw(
570580
})) {
571581
const { ccId, name: peerName } = commitment;
572582

573-
// TODO: improve how we get this info
574-
const [unitIds, isExitedStatuses] =
575-
await contracts.diamond.getUnitExitStatuses(ccId);
576-
577-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
578-
const computeUnitInfos = (await multicallRead(
579-
unitIds.map((unitId): MulticallReadItem => {
580-
return {
581-
target: contracts.deployment.diamond,
582-
callData: contracts.diamond.interface.encodeFunctionData(
583-
"getComputeUnit",
584-
[unitId],
585-
),
586-
decode(returnData) {
587-
return contracts.diamond.interface.decodeFunctionResult(
588-
"getComputeUnit",
589-
returnData,
590-
);
591-
},
592-
};
593-
}),
594-
)) as (
595-
| Awaited<ReturnType<typeof contracts.diamond.getComputeUnit>>
596-
| undefined
597-
)[];
598-
599-
const units = unitIds.map((unitId, i) => {
600-
return {
601-
unitId,
602-
unitInfo:
603-
computeUnitInfos[i] ??
604-
(() => {
605-
throw new Error(
606-
`Unreachable. Unit ${unitId} not found after running getComputeUnit`,
607-
);
608-
})(),
609-
isExited:
610-
isExitedStatuses[i] ??
611-
(() => {
612-
throw new Error(
613-
`Unreachable. No exit status returned from getUnitExitStatuses for unit ${unitId}`,
614-
);
615-
})(),
616-
};
617-
});
618-
619583
await sign({
620584
title: `withdraw collateral from: ${ccId}`,
621585
method: contracts.diamond.withdrawCollateral,
@@ -632,28 +596,9 @@ export async function collateralWithdraw(
632596
continue;
633597
}
634598

635-
const [firstNotExitedUnit, ...restNotExitedUnits] = units.filter(
636-
({ isExited }) => {
637-
return !isExited;
638-
},
639-
);
640-
641599
await signBatch({
642-
title: `${firstNotExitedUnit === undefined ? "Finish" : "Remove compute units from capacity commitments and finish"} commitment ${peerName === undefined ? ccId : `for ${peerName} (${ccId})`} ${ccId}`,
643-
populatedTxs:
644-
firstNotExitedUnit === undefined
645-
? [populateTx(contracts.diamond.finishCommitment, ccId)]
646-
: [
647-
populateTx(contracts.diamond.removeCUFromCC, ccId, [
648-
firstNotExitedUnit.unitId,
649-
]),
650-
...restNotExitedUnits.map(({ unitId }) => {
651-
return populateTx(contracts.diamond.removeCUFromCC, ccId, [
652-
unitId,
653-
]);
654-
}),
655-
populateTx(contracts.diamond.finishCommitment, ccId),
656-
],
600+
title: `Finish commitment ${peerName === undefined ? ccId : `for ${peerName} (${ccId})`} ${ccId}`,
601+
populatedTxs: [populateTx(contracts.diamond.finishCommitment, ccId)],
657602
});
658603
}
659604
}

packages/cli/package/src/lib/const.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ export const CC_FLAGS = {
258258
...OFFER_FLAG,
259259
};
260260

261+
export const CC_FINISH_FORCE_FLAG = {
262+
force: Flags.boolean({
263+
description: "Allow finish Active CC",
264+
}),
265+
};
266+
261267
export const FINISH_COMMITMENT_FLAG_NAME = "finish";
262268

263269
export const JSON_FLAG = {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"protocolVersion": 2,
3-
"chain-rpc": "docker.fluence.dev/chain-rpc:feat-beam-support-f0edb5b-8391-1",
4-
"chain-deploy-script": "docker.fluence.dev/chain-deploy-script:feat-beam-support-f0edb5b-8391-1",
5-
"subgraph-deploy-script": "docker.fluence.dev/subgraph-deploy-script:feat-beam-support-f0edb5b-8391-1"
3+
"chain-rpc": "docker.fluence.dev/chain-rpc:release-candidate-v0-27-2-1d44fe4-9165-1",
4+
"chain-deploy-script": "docker.fluence.dev/chain-deploy-script:release-candidate-v0-27-2-1d44fe4-9165-1",
5+
"subgraph-deploy-script": "docker.fluence.dev/subgraph-deploy-script:release-candidate-v0-27-2-1d44fe4-9165-1"
66
}

packages/cli/package/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,7 @@ __metadata:
19641964
dependencies:
19651965
"@actions/core": "npm:1.11.1"
19661966
"@aws-sdk/lib-storage": "npm:^3.501.0"
1967-
"@fluencelabs/deal-ts-clients": "npm:0.24.3-feat-beam-support-f0edb5b-8391-1.0"
1967+
"@fluencelabs/deal-ts-clients": "npm:0.27.2-release-candidate-v0-27-2-7faf671-9169-1.0"
19681968
"@graphql-codegen/cli": "npm:^5.0.3"
19691969
"@graphql-codegen/typescript": "npm:^4.1.1"
19701970
"@graphql-codegen/typescript-graphql-request": "npm:^6.2.0"
@@ -2038,9 +2038,9 @@ __metadata:
20382038
languageName: unknown
20392039
linkType: soft
20402040

2041-
"@fluencelabs/deal-ts-clients@npm:0.24.3-feat-beam-support-f0edb5b-8391-1.0":
2042-
version: 0.24.3-feat-beam-support-f0edb5b-8391-1.0
2043-
resolution: "@fluencelabs/deal-ts-clients@npm:0.24.3-feat-beam-support-f0edb5b-8391-1.0"
2041+
"@fluencelabs/deal-ts-clients@npm:0.27.2-release-candidate-v0-27-2-7faf671-9169-1.0":
2042+
version: 0.27.2-release-candidate-v0-27-2-7faf671-9169-1.0
2043+
resolution: "@fluencelabs/deal-ts-clients@npm:0.27.2-release-candidate-v0-27-2-7faf671-9169-1.0"
20442044
dependencies:
20452045
"@graphql-typed-document-node/core": "npm:^3.2.0"
20462046
debug: "npm:^4.3.4"
@@ -2052,7 +2052,7 @@ __metadata:
20522052
graphql-tag: "npm:^2.12.6"
20532053
ipfs-http-client: "npm:^60.0.1"
20542054
multiformats: "npm:^13.0.1"
2055-
checksum: 10c0/2478de8b0eeb12a98f3206dbf2af4501f59da55d413b261dbd84303054ad1053c7f602ce786e4fafb4ce322318605e897d48182759c5875c46685877f5356d58
2055+
checksum: 10c0/21a9db2c8f3651a7fd0e89d53aed6fe69755577c3c379317406fd9542006e7cb2f273e4f2786135bf1fbdaba8f8f2370d03cececb0afe95cad2929d6713f1835
20562056
languageName: node
20572057
linkType: hard
20582058

0 commit comments

Comments
 (0)