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!: new provider.yaml and new contracts v2 [JS-850, JS-851] #1082

Merged
merged 62 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c6312f0
feat: new provider.yaml
shamsartem Dec 23, 2024
2c29ba0
feat: new provider.yaml
shamsartem Dec 23, 2024
b02b4ce
use 1.1.1.1
shamsartem Dec 23, 2024
6cf65b9
Merge branch 'main' into new-provider-config
shamsartem Dec 23, 2024
bea907c
Apply automatic changes
shamsartem Dec 23, 2024
8deca5a
use 2, fix offerName
shamsartem Dec 23, 2024
6f4b70a
Apply automatic changes
shamsartem Dec 23, 2024
568f2c3
improve validation, try some ideas
shamsartem Dec 23, 2024
e2f6778
Apply automatic changes
shamsartem Dec 23, 2024
be37f9f
use ones again
shamsartem Dec 23, 2024
0f916ee
Apply automatic changes
shamsartem Dec 23, 2024
3ae1baa
group resource names by type, rename vcpu to cpu
shamsartem Dec 24, 2024
7f1dbb2
Apply automatic changes
shamsartem Dec 24, 2024
8386480
feat: add balance keeper
shamsartem Dec 25, 2024
a9df52c
feat: use registerMarketOfferV2
shamsartem Dec 24, 2024
971465a
move over the rest of v2 I could find
shamsartem Dec 25, 2024
546a6c2
improve resource definition in provider.yaml
shamsartem Dec 26, 2024
49a1456
Apply automatic changes
shamsartem Dec 26, 2024
2fc2d2d
rename nox to computePeer
shamsartem Dec 26, 2024
d839aba
Apply automatic changes
shamsartem Dec 26, 2024
6751450
product review fixes
shamsartem Dec 26, 2024
716d5ea
fix integer
shamsartem Dec 26, 2024
3fa81ca
Apply automatic changes
shamsartem Dec 26, 2024
e2828ed
add resource validation and autocomplete
shamsartem Dec 26, 2024
9294d47
use snapshot
shamsartem Dec 26, 2024
862d96d
Merge branch 'add-balance-keeper' into new-provider-config
shamsartem Dec 26, 2024
688d8fb
prepare for getting resources from chain
shamsartem Dec 26, 2024
f3cd7de
Apply automatic changes
shamsartem Dec 26, 2024
3a5d0f4
fix offer-create
shamsartem Dec 27, 2024
063db2a
more offer update functionality
shamsartem Dec 27, 2024
3fc437d
use containers
shamsartem Dec 27, 2024
3ed7a1a
Merge branch 'main' into new-provider-config
shamsartem Dec 27, 2024
202bd5b
use chain to get resources, temporary remove resource validation, tem…
shamsartem Dec 28, 2024
6ff73ae
use latest containers
shamsartem Dec 31, 2024
9e5327d
add ip validation across compute peers
shamsartem Dec 31, 2024
0267e74
add 2x when creating offer, check enough ram per core
shamsartem Jan 3, 2025
3f2f137
Apply automatic changes
shamsartem Jan 3, 2025
446c3ef
fix storage description
shamsartem Jan 3, 2025
6fa45d0
Apply automatic changes
shamsartem Jan 3, 2025
e4b22c8
fix add, remove and display CU
shamsartem Jan 3, 2025
d6a6e6f
remove type assertions
shamsartem Jan 6, 2025
3fdb2aa
fix
shamsartem Jan 6, 2025
a4d9dbe
fix
shamsartem Jan 6, 2025
f5c3aa8
convert stuff
shamsartem Jan 6, 2025
b276b16
Apply automatic changes
shamsartem Jan 6, 2025
0605447
use megabytes and megabits per second for network
shamsartem Jan 6, 2025
4ba0c02
up containers and snapshot
shamsartem Jan 6, 2025
8be3309
fix some update problems
shamsartem Jan 6, 2025
96d640b
fix provider test
shamsartem Jan 6, 2025
86f772d
fix test
shamsartem Jan 7, 2025
2126c72
fix change CU?
shamsartem Jan 7, 2025
4e2afa2
Add docker login to docs job
nahsi Jan 7, 2025
d795805
another fix for CU update
shamsartem Jan 7, 2025
f5d6b4b
improve resource update?
shamsartem Jan 7, 2025
5013e68
use supply to 0 instead of removePeerResource
shamsartem Jan 7, 2025
87cbd3e
first update ram then CPU
shamsartem Jan 7, 2025
a857586
first remove resources then add and check if details changed
shamsartem Jan 7, 2025
f94f05d
fix update
shamsartem Jan 8, 2025
0f4fd99
Merge branch 'main' into new-provider-config
shamsartem Jan 8, 2025
c10db90
use mebibytes, fix cpu price so it is per VCPU on chain but is still …
shamsartem Jan 8, 2025
3ee3941
Apply automatic changes
shamsartem Jan 8, 2025
a312afd
fix offer update
shamsartem Jan 8, 2025
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
25 changes: 25 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ env:

jobs:
docs:
permissions:
contents: write
id-token: write
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
Expand Down Expand Up @@ -50,6 +53,28 @@ jobs:
restore-keys: |
${{ runner.os }}-turbo-

- name: Import secrets
uses: hashicorp/[email protected]
id: secrets
with:
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
exportToken: false
secrets: |
kv/docker-registry/basicauth/ci username | DOCKER_USERNAME ;
kv/docker-registry/basicauth/ci password | DOCKER_PASSWORD ;

- name: Login to private docker registry
uses: docker/login-action@v3
with:
registry: docker.fluence.dev
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}

- name: Run on each commit
run: yarn on-each-commit

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package/docs/configs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## [provider.yaml](./provider.md)

Defines config used for provider set up
Defines provider configuration

## [provider-secrets.yaml](./provider-secrets.md)

Expand Down
11 changes: 6 additions & 5 deletions packages/cli/package/docs/configs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ Deployed contract address overrides

### Properties

| Property | Type | Required | Description |
|--------------|--------|----------|-------------|
| `diamond` | string | No | |
| `multicall3` | string | No | |
| `usdc` | string | No | |
| Property | Type | Required | Description |
|-----------------|--------|----------|-------------|
| `balanceKeeper` | string | No | |
| `diamond` | string | No | |
| `multicall3` | string | No | |
| `usdc` | string | No | |

40 changes: 20 additions & 20 deletions packages/cli/package/docs/configs/provider-artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ Created offers

#### Properties

| Property | Type | Required | Description |
|-----------|--------------------|----------|-------------|
| `noxName` | [object](#noxname) | No | |
| Property | Type | Required | Description |
|-------------|----------------------|----------|-------------|
| `offerName` | [object](#offername) | No | |

#### noxName
#### offerName

##### Properties

Expand All @@ -48,11 +48,11 @@ Created offers

#### Properties

| Property | Type | Required | Description |
|-----------|--------------------|----------|-------------|
| `noxName` | [object](#noxname) | No | |
| Property | Type | Required | Description |
|-------------|----------------------|----------|-------------|
| `offerName` | [object](#offername) | No | |

#### noxName
#### offerName

##### Properties

Expand All @@ -67,11 +67,11 @@ Created offers

#### Properties

| Property | Type | Required | Description |
|-----------|--------------------|----------|-------------|
| `noxName` | [object](#noxname) | No | |
| Property | Type | Required | Description |
|-------------|----------------------|----------|-------------|
| `offerName` | [object](#offername) | No | |

#### noxName
#### offerName

##### Properties

Expand All @@ -86,11 +86,11 @@ Created offers

#### Properties

| Property | Type | Required | Description |
|-----------|--------------------|----------|-------------|
| `noxName` | [object](#noxname) | No | |
| Property | Type | Required | Description |
|-------------|----------------------|----------|-------------|
| `offerName` | [object](#offername) | No | |

#### noxName
#### offerName

##### Properties

Expand All @@ -105,11 +105,11 @@ Created offers

#### Properties

| Property | Type | Required | Description |
|-----------|--------------------|----------|-------------|
| `noxName` | [object](#noxname) | No | |
| Property | Type | Required | Description |
|-------------|----------------------|----------|-------------|
| `offerName` | [object](#offername) | No | |

#### noxName
#### offerName

##### Properties

Expand Down
653 changes: 218 additions & 435 deletions packages/cli/package/docs/configs/provider.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/cli/package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"whatwg-url": "^14.0.0"
},
"dependencies": {
"@fluencelabs/deal-ts-clients": "0.22.1",
"@fluencelabs/deal-ts-clients": "0.23.2-feat-marketplace-v2-resources-03f7996-7429-1.0",
"@kubernetes/client-node": "github:fluencelabs/kubernetes-client-javascript#e72ee00a52fec4eb4a8327632895d888ee504f4d",
"@libp2p/crypto": "4.0.1",
"@libp2p/peer-id-factory": "4.0.5",
Expand Down
33 changes: 1 addition & 32 deletions packages/cli/package/src/commands/provider/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ import { readFile } from "node:fs/promises";
import { isAbsolute, resolve } from "node:path";

import type k8s from "@kubernetes/client-node";
import { color } from "@oclif/color";

import { BaseCommand } from "../../baseCommand.js";
import { commandObj } from "../../lib/commandObj.js";
import { ensureReadonlyProviderConfig } from "../../lib/configs/project/provider/provider.js";
import { CHAIN_FLAGS, PEER_AND_OFFER_NAMES_FLAGS } from "../../lib/const.js";
import { splitErrorsAndResults } from "../../lib/helpers/utils.js";
import { initCli } from "../../lib/lifeCycle.js";
import { projectRootDir } from "../../lib/paths.js";
import { resolveComputePeersByNames } from "../../lib/resolveComputePeersByNames.js";
Expand All @@ -41,35 +38,7 @@ export default class Deploy extends BaseCommand<typeof Deploy> {
const { flags } = await initCli(this, await this.parse(Deploy));
const computePeers = await resolveComputePeersByNames(flags);

const [invalidPeers, peers] = splitErrorsAndResults(
computePeers,
({ kubeconfigPath, ipSupplies, name, ...restPeer }) => {
return kubeconfigPath === undefined || ipSupplies.length === 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not anymore cause now all of this is required in the config instead of being optional

? {
error: [
kubeconfigPath === undefined &&
`computePeer ${color.yellow(name)} must have a ${color.yellow("kubeconfigPath")} property`,
ipSupplies.length === 0 &&
`computePeer ${color.yellow(name)} must have a ${color.yellow("resources.ip.supply")} property, which must be a non-empty array`,
]
.filter((err) => {
return typeof err === "string";
})
.join("\n"),
}
: { result: { name, ipSupplies, kubeconfigPath, ...restPeer } };
},
);

if (invalidPeers.length > 0) {
const providerConfig = await ensureReadonlyProviderConfig();

commandObj.error(
`Invalid config at ${providerConfig.$getPath()}:\n${invalidPeers.join("\n")}`,
);
}

for (const { kubeconfigPath, name, manifestPath } of peers) {
for (const { kubeconfigPath, name, manifestPath } of computePeers) {
await kubectlApply(kubeconfigPath, manifestPath, name);
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/package/src/lib/ajvInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ import addFormats from "ajv-formats";

import { jsonStringify } from "../common.js";

import { HEX_REGEX } from "./helpers/validations.js";

export function getAjv() {
const ajv = new Ajv.default({
allowUnionTypes: true,
code: { esm: true },
});

addFormats.default(ajv);
ajv.addFormat("hex", /^0x[0-9a-fA-F]*$/);
ajv.addFormat("hex", HEX_REGEX);
return ajv;
}

Expand Down
27 changes: 9 additions & 18 deletions packages/cli/package/src/lib/chain/commitment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ export async function collateralWithdraw(
})) {
const { ccId, name: peerName } = commitment;

// TODO: improve how we get this info
const [unitIds, isExitedStatuses] =
await contracts.diamond.getUnitExitStatuses(ccId);

Expand Down Expand Up @@ -544,30 +545,20 @@ export async function collateralWithdraw(
return unit.unitInfo.deal !== ZeroAddress;
});

const unitIdsByOnChainWorkerId: Record<string, string[]> = {};
const onChainWorkerIds = new Set<string>();

for (const { unitId, unitInfo } of unitsWithDeals) {
let unitIds = unitIdsByOnChainWorkerId[unitInfo.onchainWorkerId];

if (unitIds === undefined) {
unitIds = [];
unitIdsByOnChainWorkerId[unitInfo.onchainWorkerId] = unitIds;
}

unitIds.push(unitId);
for (const { unitInfo } of unitsWithDeals) {
onChainWorkerIds.add(unitInfo.onchainWorkerId);
}

const moveResourcesFromDealTxs = Object.entries(
unitIdsByOnChainWorkerId,
).flatMap(([onchainWorkerId, unitIds]) => {
return unitIds.map((unit) => {
const moveResourcesFromDealTxs = Array.from(onChainWorkerIds).map(
(onchainWorkerId) => {
return populateTx(
contracts.diamond.moveResourcesFromDeal,
[unit],
contracts.diamond.moveResourcesFromDealV2,
onchainWorkerId,
);
});
});
},
);

const [firstMoveResourcesFromDealTx, ...restMoveResourcesFromDealTxs] =
moveResourcesFromDealTxs;
Expand Down
Loading
Loading