Skip to content

Commit

Permalink
rename nox to peer
Browse files Browse the repository at this point in the history
  • Loading branch information
shamsartem committed Dec 19, 2024
1 parent a686d4a commit 28e4534
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 102 deletions.
8 changes: 4 additions & 4 deletions packages/cli/package/src/commands/local/up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { BaseCommand } from "../../baseCommand.js";
import { LOCAL_NET_DEFAULT_WALLET_KEY } from "../../common.js";
import { createCommitments } from "../../lib/chain/commitment.js";
import { depositCollateral } from "../../lib/chain/depositCollateral.js";
import { distributeToNox } from "../../lib/chain/distributeToNox.js";
import { distributeToPeer } from "../../lib/chain/distributeToNox.js";
import { createOffers } from "../../lib/chain/offer/offer.js";
import { registerProvider } from "../../lib/chain/providerInfo.js";
import { setChainFlags } from "../../lib/chainFlags.js";
Expand All @@ -35,7 +35,7 @@ import {
OFFER_FLAG_NAME,
ALL_FLAG_VALUE,
DOCKER_COMPOSE_FULL_FILE_NAME,
SERVERS_FLAG,
PEERS_FLAG,
PRIV_KEY_FLAG,
PROVIDER_CONFIG_FULL_FILE_NAME,
type FluenceEnv,
Expand All @@ -52,7 +52,7 @@ export default class Up extends BaseCommand<typeof Up> {
static override description = `Run ${DOCKER_COMPOSE_FULL_FILE_NAME} using docker compose and set up provider using all the offers from the 'offers' section in ${PROVIDER_CONFIG_FULL_FILE_NAME} config using default wallet key ${LOCAL_NET_DEFAULT_WALLET_KEY}`;
static override examples = ["<%= config.bin %> <%= command.id %>"];
static override flags = {
...SERVERS_FLAG,
...PEERS_FLAG,
timeout: Flags.integer({
description:
"Timeout in seconds for attempting to register local network on local peers",
Expand Down Expand Up @@ -146,7 +146,7 @@ export default class Up extends BaseCommand<typeof Up> {
}

const allOffers = { [OFFER_FLAG_NAME]: ALL_FLAG_VALUE };
await distributeToNox({ ...flags, ...allOffers, amount: "10" });
await distributeToPeer({ ...flags, ...allOffers, amount: "10" });
await registerProvider();
await createOffers({ force: true, ...allOffers });
await createCommitments({ ...flags, ...allOffers });
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/package/src/commands/provider/gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { color } from "@oclif/color";
import { Flags } from "@oclif/core";

import { BaseCommand } from "../../baseCommand.js";
import { withdrawFromNox } from "../../lib/chain/distributeToNox.js";
import { withdrawFromPeer } from "../../lib/chain/distributeToNox.js";
import { commandObj } from "../../lib/commandObj.js";
import { ensureComputerPeerConfigs } from "../../lib/configs/project/provider/provider.js";
import {
Expand Down Expand Up @@ -62,7 +62,7 @@ export default class Gen extends BaseCommand<typeof Gen> {
default: false,
}),
[NO_WITHDRAW_FLAG_NAME]: Flags.boolean({
description: `Is used only when --${RESET_PEER_SECRETS_FLAG_NAME} flag is present. Will not withdraw tokens from noxes (if you don't need it or it fails for some reason)`,
description: `Is used only when --${RESET_PEER_SECRETS_FLAG_NAME} flag is present. Will not withdraw tokens from peers (if you don't need it or it fails for some reason)`,
default: false,
}),
};
Expand All @@ -79,26 +79,26 @@ export default class Gen extends BaseCommand<typeof Gen> {
if (
flags[RESET_PEER_SECRETS_FLAG_NAME] &&
(await confirm({
message: `Are you sure you want to backup nox secrets ${color.yellow(providerSecretsConfigPath)} and ${color.yellow(fluenceSecretsDir)} (if they exist) to ${color.yellow(backupDirPath)} and generate new ones`,
message: `Are you sure you want to backup peer secrets ${color.yellow(providerSecretsConfigPath)} and ${color.yellow(fluenceSecretsDir)} (if they exist) to ${color.yellow(backupDirPath)} and generate new ones`,
default: flags[RESET_PEER_SECRETS_FLAG_NAME],
}))
) {
if (
!flags[NO_WITHDRAW_FLAG_NAME] &&
(await confirm({
message:
"Do you want to withdraw remaining tokens from your noxes before continuing",
"Do you want to withdraw remaining tokens from your peers before continuing",
default: !flags[NO_WITHDRAW_FLAG_NAME],
}))
) {
try {
await withdrawFromNox({
await withdrawFromPeer({
[PEER_NAMES_FLAG_NAME]: ALL_FLAG_VALUE,
amount: MAX_TOKEN_AMOUNT_KEYWORD,
});
} catch (e) {
return commandObj.error(
`Failed to withdraw tokens from noxes. Try using ${color.yellow(`${CLI_NAME} provider tokens-withdraw`)} command with specific nox names and amounts or don't withdraw anything if you don't need to by using --${NO_WITHDRAW_FLAG_NAME} flag. Error: ${stringifyUnknown(e)}`,
`Failed to withdraw tokens from peers. Try using ${color.yellow(`${CLI_NAME} provider tokens-withdraw`)} command with specific peer names and amounts or don't withdraw anything if you don't need to by using --${NO_WITHDRAW_FLAG_NAME} flag. Error: ${stringifyUnknown(e)}`,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package/src/commands/provider/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { ensureFluenceEnv } from "../../lib/resolveFluenceEnv.js";

export default class Info extends BaseCommand<typeof Info> {
static override hiddenAliases = ["provider:i"];
static override description = `Print nox signing wallets and peer ids${aliasesText.apply(this)}`;
static override description = `Print peer signing wallets and peer ids${aliasesText.apply(this)}`;
static override flags = {
...CHAIN_FLAGS,
...PEER_AND_OFFER_NAMES_FLAGS,
Expand Down
9 changes: 2 additions & 7 deletions packages/cli/package/src/commands/provider/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import { writeFile } from "node:fs/promises";

import { color } from "@oclif/color";
import { Flags } from "@oclif/core";

import { BaseCommand } from "../../baseCommand.js";
import { commandObj } from "../../lib/commandObj.js";
Expand All @@ -28,7 +27,7 @@ import {
} from "../../lib/configs/project/provider/provider.js";
import {
CHAIN_FLAGS,
SERVERS_FLAG,
PEERS_FLAG,
PROVIDER_CONFIG_FULL_FILE_NAME,
RECOMMENDED_GITIGNORE_CONTENT,
} from "../../lib/const.js";
Expand All @@ -38,12 +37,8 @@ import { getGitignorePath } from "../../lib/paths.js";
export default class Init extends BaseCommand<typeof Init> {
static override description = `Init provider config. Creates a ${PROVIDER_CONFIG_FULL_FILE_NAME} file`;
static override flags = {
...SERVERS_FLAG,
...PEERS_FLAG,
...CHAIN_FLAGS,
"no-vm": Flags.boolean({
description: `Generate ${PROVIDER_CONFIG_FULL_FILE_NAME} without vm configuration`,
default: false,
}),
};

async run(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { Flags } from "@oclif/core";

import { BaseCommand } from "../../baseCommand.js";
import { distributeToNox } from "../../lib/chain/distributeToNox.js";
import { distributeToPeer } from "../../lib/chain/distributeToNox.js";
import {
CHAIN_FLAGS,
FLT_SYMBOL,
Expand All @@ -31,17 +31,17 @@ export default class TokensDistribute extends BaseCommand<
typeof TokensDistribute
> {
static override hiddenAliases = ["provider:td"];
static override description = `Distribute ${FLT_SYMBOL} tokens to noxes${aliasesText.apply(this)}`;
static override description = `Distribute ${FLT_SYMBOL} tokens to peers${aliasesText.apply(this)}`;
static override flags = {
...CHAIN_FLAGS,
...PEER_AND_OFFER_NAMES_FLAGS,
amount: Flags.string({
description: `Amount of ${FLT_SYMBOL} tokens to distribute to noxes`,
description: `Amount of ${FLT_SYMBOL} tokens to distribute to peers`,
}),
};

async run(): Promise<void> {
const { flags } = await initCli(this, await this.parse(TokensDistribute));
await distributeToNox(flags);
await distributeToPeer(flags);
}
}
8 changes: 4 additions & 4 deletions packages/cli/package/src/commands/provider/tokens-withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { Flags } from "@oclif/core";

import { BaseCommand } from "../../baseCommand.js";
import { withdrawFromNox } from "../../lib/chain/distributeToNox.js";
import { withdrawFromPeer } from "../../lib/chain/distributeToNox.js";
import {
CHAIN_FLAGS,
FLT_SYMBOL,
Expand All @@ -32,17 +32,17 @@ const AMOUNT_FLAG_NAME = "amount";

export default class TokensWithdraw extends BaseCommand<typeof TokensWithdraw> {
static override hiddenAliases = ["provider:tw"];
static override description = `Withdraw ${FLT_SYMBOL} tokens from noxes${aliasesText.apply(this)}`;
static override description = `Withdraw ${FLT_SYMBOL} tokens from peers${aliasesText.apply(this)}`;
static override flags = {
...CHAIN_FLAGS,
...PEER_AND_OFFER_NAMES_FLAGS,
[AMOUNT_FLAG_NAME]: Flags.string({
description: `Amount of ${FLT_SYMBOL} tokens to withdraw from noxes. Use --${AMOUNT_FLAG_NAME} ${MAX_TOKEN_AMOUNT_KEYWORD} to withdraw maximum possible amount`,
description: `Amount of ${FLT_SYMBOL} tokens to withdraw from peers. Use --${AMOUNT_FLAG_NAME} ${MAX_TOKEN_AMOUNT_KEYWORD} to withdraw maximum possible amount`,
}),
};

async run(): Promise<void> {
const { flags } = await initCli(this, await this.parse(TokensWithdraw));
await withdrawFromNox(flags);
await withdrawFromPeer(flags);
}
}
24 changes: 12 additions & 12 deletions packages/cli/package/src/lib/chain/commitment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async function getComputePeersWithCCIds(
commandObj.warn(
`Some of the commitments were not found for:\n${computePeersWithoutCC
.map(({ name, peerId }) => {
return `Nox: ${name}, PeerId: ${peerId}`;
return `Peer: ${name}, PeerId: ${peerId}`;
})
.join(
"\n",
Expand Down Expand Up @@ -337,9 +337,9 @@ export async function createCommitments(flags: PeerAndOfferNameFlags) {

try {
createCommitmentsTxReceipts = await signBatch(
`Create commitments for the following noxes:\n\n${computePeers
`Create commitments for the following peers:\n\n${computePeers
.map(({ name, peerId }) => {
return `Nox: ${name}\nPeerId: ${peerId}`;
return `Peer: ${name}\nPeerId: ${peerId}`;
})
.join("\n\n")}`,
[firstCommitmentTx, ...restCommitmentTxs],
Expand Down Expand Up @@ -493,7 +493,7 @@ export async function collateralWithdraw(
for (const commitment of commitments.flatMap(({ ccInfos }) => {
return ccInfos;
})) {
const { ccId, name: noxName } = commitment;
const { ccId, name: peerName } = commitment;

const [unitIds, isExitedStatuses] =
await contracts.diamond.getUnitExitStatuses(ccId);
Expand Down Expand Up @@ -619,7 +619,7 @@ export async function collateralWithdraw(
);

await signBatch(
`${firstNotExitedUnit === undefined ? "F" : "Remove compute units from capacity commitments and f"}inish commitment ${noxName === undefined ? ccId : `for ${noxName} (${ccId})`} ${ccId}`,
`${firstNotExitedUnit === undefined ? "Finish" : "Remove compute units from capacity commitments and finish"} commitment ${peerName === undefined ? ccId : `for ${peerName} (${ccId})`} ${ccId}`,
firstNotExitedUnit === undefined
? [populateTx(contracts.diamond.finishCommitment, ccId)]
: [
Expand Down Expand Up @@ -662,8 +662,8 @@ export function stringifyBasicCommitmentInfo({
peerId,
ccId,
}: CapacityCommitment) {
const noxName = name === undefined ? "" : `Nox: ${name}\n`;
return `${color.yellow(`${noxName}PeerId: ${peerId}`)}\nCommitmentId: ${ccId}`;
const peerName = name === undefined ? "" : `Peer: ${name}\n`;
return `${color.yellow(`${peerName}PeerId: ${peerId}`)}\nCommitmentId: ${ccId}`;
}

type CapacityCommitment = {
Expand Down Expand Up @@ -984,10 +984,10 @@ export function stringifyDetailedCommitmentsInfo(
return detailedCommitmentsInfoGroupedByStatus
.map(({ statusInfo, CCs }) => {
return `${getStatusHeading(statusInfo)}${CCs.map((cc) => {
const noxNameString =
"noxName" in cc ? color.yellow(`Nox: ${cc.noxName}\n`) : "";
const peerNameString =
"peerName" in cc ? color.yellow(`Peer: ${cc.peerName}\n`) : "";
return `${noxNameString}${getDetailedCommitmentInfoString(cc)}`;
return `${peerNameString}${getDetailedCommitmentInfoString(cc)}`;
}).join("\n\n")}`;
})
.join("\n\n");
Expand All @@ -1009,7 +1009,7 @@ async function getDetailedCommitmentInfo({
status,
peerId,
ccId,
name: noxName,
name: peerName,
currentEpoch,
epochDuration,
initTimestamp,
Expand Down Expand Up @@ -1074,7 +1074,7 @@ async function getDetailedCommitmentInfo({
: undefined;

return {
...(noxName === undefined ? {} : { noxName }),
...(peerName === undefined ? {} : { peerName }),
peerId,
commitmentId: ccId,
status,
Expand Down
Loading

0 comments on commit 28e4534

Please sign in to comment.