Skip to content

Commit

Permalink
feat: up spell v0.7.6, nox v0.21.2; fix aqua from fluence.yaml compil…
Browse files Browse the repository at this point in the history
…ation (#811)

* feat: up spell v0.7.6, fix aqua from fluence.yaml compilation

* Apply automatic changes

* Update src/lib/const.ts

---------

Co-authored-by: shamsartem <shamsartem@users.noreply.github.com>
  • Loading branch information
shamsartem and shamsartem authored Feb 27, 2024
1 parent 9e41ec4 commit d5445f5
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 60 deletions.
2 changes: 1 addition & 1 deletion docs/configs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Defines secrets config used for provider set up

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

Defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). You can use `fluence module new` command to generate a template for new module
!IMPORTANT: All the properties in this config (except for "name") are relevant only for providers who provide effector modules. If you are not a provider - properties in this config will be ignored when you deploy your code. But they will still have effect when running using 'fluence service repl' command. This config defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). You can use `fluence module new` command to generate a template for new module

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

Expand Down
2 changes: 1 addition & 1 deletion docs/configs/module.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# module.yaml

Defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). You can use `fluence module new` command to generate a template for new module
!IMPORTANT: All the properties in this config (except for "name") are relevant only for providers who provide effector modules. If you are not a provider - properties in this config will be ignored when you deploy your code. But they will still have effect when running using 'fluence service repl' command. This config defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). You can use `fluence module new` command to generate a template for new module

## Properties

Expand Down
52 changes: 26 additions & 26 deletions src/cli-aqua-dependencies/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/cli-aqua-dependencies/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": {
"@fluencelabs/installation-spell": "0.6.9"
"@fluencelabs/installation-spell": "0.7.6"
}
}
12 changes: 6 additions & 6 deletions src/commands/aqua.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async function compileAquaFromFlags({
air: boolean;
watch: boolean;
}) {
const inputFlag = await resolveAbsoluteAquaPath({
const filePath = await resolveAbsoluteAquaPathFromCwd({
maybePathFromFlags: input,
inputArg: {
message: `Enter path to an aqua file or an input directory that contains your aqua files`,
Expand All @@ -134,9 +134,9 @@ async function compileAquaFromFlags({
},
});

const outputFlag = flags.dry
const outputPathAbsolute = flags.dry
? undefined
: await resolveAbsoluteAquaPath({
: await resolveAbsoluteAquaPathFromCwd({
maybePathFromFlags: output,
inputArg: {
message:
Expand All @@ -148,9 +148,9 @@ async function compileAquaFromFlags({
const targetType = resolveTargetType(flags);

await compileAquaAndWatch({
filePath: inputFlag,
filePath,
targetType,
outputPath: outputFlag,
outputPathAbsolute,
...flags,
});

Expand Down Expand Up @@ -184,7 +184,7 @@ type ResolveAbsoluteAquaPathArg = {
inputArg: InputArg;
};

async function resolveAbsoluteAquaPath({
async function resolveAbsoluteAquaPathFromCwd({
maybePathFromFlags,
inputArg,
}: ResolveAbsoluteAquaPathArg) {
Expand Down
16 changes: 10 additions & 6 deletions src/lib/aqua.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ const writeFileAndMakeSureDirExists = async (
};

export type CompileToFilesArgs = CompileFromPathArgs & {
outputPath: string | undefined;
outputPathAbsolute: string | undefined;
dry?: boolean;
};

export async function compileToFiles({
outputPath,
outputPathAbsolute,
targetType,
dry = false,
...compileArgs
Expand Down Expand Up @@ -140,11 +140,11 @@ export async function compileToFiles({
}

assert(
typeof outputPath === "string",
`outputPath type is "${typeof outputPath}", but it should be of type "string", because it's not dry run`,
typeof outputPathAbsolute === "string",
`Unreachable. outputPath type is "${typeof outputPathAbsolute}", but it should have been of type "string", because it's not dry run`,
);

await mkdir(outputPath, { recursive: true });
await mkdir(outputPathAbsolute, { recursive: true });

const inputDirPath = isInputPathADirectory
? compileArgs.filePath
Expand All @@ -158,7 +158,11 @@ export async function compileToFiles({
const parsedPath = parse(aquaFilePath);
const fileNameWithoutExt = parsedPath.name;
const dirPath = parsedPath.dir;
const finalOutputDirPath = dirPath.replace(inputDirPath, outputPath);

const finalOutputDirPath = dirPath.replace(
inputDirPath,
outputPathAbsolute,
);

if (targetType === "ts") {
return [
Expand Down
9 changes: 6 additions & 3 deletions src/lib/compileAquaAndWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

import { resolve } from "node:path";

import type { GatherImportsResult } from "@fluencelabs/npm-aqua-compiler";
import { color } from "@oclif/color";

Expand All @@ -34,6 +36,7 @@ import {
splitErrorsAndResults,
stringifyUnknown,
} from "./helpers/utils.js";
import { projectRootDir } from "./paths.js";
import type { Required } from "./typeHelpers.js";

type CompileAquaFromFluenceConfigArgs = {
Expand Down Expand Up @@ -93,7 +96,7 @@ export async function compileAquaFromFluenceConfig({
return compileAquaAndWatch(
{
...resolveAquaConfig(aquaConfig, imports),
outputPath: aquaConfig.output,
outputPathAbsolute: resolve(projectRootDir, aquaConfig.output),
watch,
dry,
},
Expand Down Expand Up @@ -157,9 +160,9 @@ export async function compileAquaAndWatch(
const from = ` from ${color.yellow(compileArgs.filePath)}`;

const to =
compileArgs.outputPath === undefined || compileArgs.dry
compileArgs.outputPathAbsolute === undefined || compileArgs.dry
? ""
: ` to ${color.yellow(compileArgs.outputPath)}`;
: ` to ${color.yellow(compileArgs.outputPathAbsolute)}`;

commandObj.logToStderr(
`Successfully compiled${aquaConfigName}${from}${to}. If you don't see files or functions you expect to see, make sure you exported things you require from your aqua files`,
Expand Down
7 changes: 5 additions & 2 deletions src/lib/configs/project/fluence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ import {
AQUA_LOG_LEVELS,
type AquaLogLevel,
PT_SYMBOL,
COMPILE_AQUA_PROPERTY_NAME,
DEFAULT_CURL_EFFECTOR_CID,
} from "../../const.js";
import { COMPILE_AQUA_PROPERTY_NAME } from "../../const.js";
import { splitErrorsAndResults } from "../../helpers/utils.js";
import {
validateCIDs,
Expand Down Expand Up @@ -924,6 +925,8 @@ deployments:
initialBalance: "${DEFAULT_INITIAL_BALANCE}" # initial balance after deploy in ${PT_SYMBOL}
services: [] # list of service names to be deployed to this worker
spells: [] # list of spell names to be deployed to this worker
effectors:
- "${DEFAULT_CURL_EFFECTOR_CID}"
${yamlDiffPatch(
"",
Expand Down Expand Up @@ -1478,7 +1481,7 @@ const validate: ConfigValidateFunction<LatestConfig> = async (config) => {
return (effectors ?? []).map((cid) => {
return {
cid,
location: `${FLUENCE_CONFIG_FULL_FILE_NAME} > deals > ${name} > effectors > ${cid}`,
location: `${FLUENCE_CONFIG_FULL_FILE_NAME} > deployments > ${name} > effectors > ${cid}`,
};
});
},
Expand Down
2 changes: 1 addition & 1 deletion src/lib/configs/project/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const configSchemaV0: JSONSchemaType<ConfigV0> = {
type: "object",
$id: `${TOP_LEVEL_SCHEMA_ID}/${MODULE_CONFIG_FULL_FILE_NAME}`,
title: MODULE_CONFIG_FULL_FILE_NAME,
description: `Defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). You can use \`${CLI_NAME} module new\` command to generate a template for new module`,
description: `!IMPORTANT: All the properties in this config (except for "name") are relevant only for providers who provide effector modules. If you are not a provider - properties in this config will be ignored when you deploy your code. But they will still have effect when running using 'fluence service repl' command. This config defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). You can use \`${CLI_NAME} module new\` command to generate a template for new module`,
properties: {
name: {
type: "string",
Expand Down
8 changes: 3 additions & 5 deletions src/lib/configs/project/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
ALL_FLAG_VALUE,
CHAIN_URLS,
PT_SYMBOL,
DEFAULT_CURL_EFFECTOR_CID,
} from "../../const.js";
import { ensureChainEnv } from "../../ensureChainNetwork.js";
import { type ProviderConfigArgs } from "../../generateUserProviderConfig.js";
Expand Down Expand Up @@ -460,9 +461,6 @@ const configSchemaV0 = {

const DEFAULT_NUMBER_OF_LOCAL_NET_NOXES = 3;

const DEFAULT_EFFECTOR =
"bafkreigkoxnkeyunbelr5qhqbt5nspaew7uysd2trdds346rrogfz3zvuq";

function getDefault(args: Omit<ProviderConfigArgs, "name">) {
return async () => {
commandObj.logToStderr(
Expand All @@ -478,7 +476,7 @@ function getDefault(args: Omit<ProviderConfigArgs, "name">) {
nox: {
effectors: {
curl: {
wasmCID: DEFAULT_EFFECTOR,
wasmCID: DEFAULT_CURL_EFFECTOR_CID,
allowedBinaries: {
curl: "/usr/bin/curl",
},
Expand Down Expand Up @@ -518,7 +516,7 @@ function getDefault(args: Omit<ProviderConfigArgs, "name">) {
[DEFAULT_OFFER_NAME]: {
...defaultNumberProperties,
computePeers: Object.keys(userProvidedConfig.computePeers),
effectors: [DEFAULT_EFFECTOR],
effectors: [DEFAULT_CURL_EFFECTOR_CID],
},
};

Expand Down
3 changes: 3 additions & 0 deletions src/lib/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export const MIN_MEMORY_PER_MODULE = xbytes.parseSize(
export const COMPUTE_UNIT_MEMORY_STR = "2GB";
export const COMPUTE_UNIT_MEMORY = xbytes.parseSize(COMPUTE_UNIT_MEMORY_STR);

export const DEFAULT_CURL_EFFECTOR_CID =
"bafkreids22lgia5bqs63uigw4mqwhsoxvtnkpfqxqy5uwyyerrldsr32ce";

const byteUnits = [
"kB",
"KB",
Expand Down
5 changes: 1 addition & 4 deletions src/lib/deployWorkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ import {
makeOptional,
type CustomTypes,
} from "./helpers/jsToAqua.js";
import { moduleToJSONModuleConfig } from "./helpers/moduleToJSONModuleConfig.js";
import { commaSepStrToArr, splitErrorsAndResults } from "./helpers/utils.js";
import { initMarineCli } from "./marineCli.js";
import { resolvePeerId } from "./multiaddres.js";
Expand Down Expand Up @@ -890,9 +889,7 @@ async function resolveWorker({

return {
wasm: getModuleWasmPath(overriddenModuleConfig),
config: JSON.stringify(
moduleToJSONModuleConfig(overriddenModuleConfig),
),
name: overriddenModuleConfig.name,
};
});

Expand Down
4 changes: 2 additions & 2 deletions src/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ async function initTSorJSProject({
fluenceConfig: fluenceConfig,
}),
targetType: isJS ? "js" : "ts",
outputPath: frontendCompiledAquaPath,
outputPathAbsolute: frontendCompiledAquaPath,
}),
]);
}
Expand Down Expand Up @@ -423,7 +423,7 @@ async function initTSorJSGatewayProject({
filePath: aquaDir,
imports: await getAquaImports({ fluenceConfig }),
targetType: ext,
outputPath: gatewayCompiledAquaPath,
outputPathAbsolute: gatewayCompiledAquaPath,
}),
]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/versions.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"nox": "fluencelabs/nox:0.20.1",
"nox": "fluencelabs/nox:0.21.2",
"chain-rpc": "fluencelabs/chain-rpc:0.6.7",
"chain-deploy-script": "fluencelabs/chain-deploy-script:0.6.7",
"subgraph-deploy-script": "fluencelabs/subgraph-deploy-script:0.6.7",
"rust-toolchain": "nightly-2023-08-27-x86_64",
"npm": {
"@fluencelabs/aqua-lib": "0.9.1",
"@fluencelabs/spell": "0.6.9"
"@fluencelabs/spell": "0.7.6"
},
"cargo": {
"marine": "0.19.2",
Expand Down

0 comments on commit d5445f5

Please sign in to comment.