diff --git a/docs/commands/README.md b/docs/commands/README.md index 432850151..af191f456 100644 --- a/docs/commands/README.md +++ b/docs/commands/README.md @@ -342,7 +342,8 @@ Create your deal with the specified parameters USAGE $ fluence deal create --app-cid --collateral-per-worker --min-workers --target-workers --max-workers-per-provider --price-per-worker-epoch [--no-input] [--initial-balance ] - [--effectors ] [--whitelist | --blacklist ] [--env ] [--priv-key ] + [--effectors ] [--whitelist | --blacklist ] [--protocol-version ] [--env ] + [--priv-key ] FLAGS --app-cid= (required) CID of the application that will be deployed @@ -359,6 +360,7 @@ FLAGS unsecure. On local network 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 key will be used by default + --protocol-version= Protocol version --target-workers= (required) Max workers in the deal --whitelist= Comma-separated list of whitelisted providers diff --git a/docs/configs/config.md b/docs/configs/config.md index 5e417dd36..22cd2be61 100644 --- a/docs/configs/config.md +++ b/docs/configs/config.md @@ -8,7 +8,7 @@ Defines global config for Fluence CLI |------------------------|---------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `countlyConsent` | boolean | **Yes** | Weather you consent to send usage data to Countly | | `defaultSecretKeyName` | string | **Yes** | Secret key with this name will be used by default by js-client inside CLI to run Aqua code | -| `version` | number | **Yes** | | +| `version` | integer | **Yes** | | | `docsInConfigs` | boolean | No | Whether to include commented-out documented config examples in the configs generated with the CLI | | `lastCheckForUpdates` | string | No | DEPRECATED. It's currently advised to install CLI without using npm (See README.md: https://github.com/fluencelabs/cli?tab=readme-ov-file#installation-and-usage). Last time when Fluence CLI checked for updates. Updates are checked daily unless this field is set to 'disabled' | diff --git a/docs/configs/env.md b/docs/configs/env.md index a960f9292..28f4373ef 100644 --- a/docs/configs/env.md +++ b/docs/configs/env.md @@ -4,8 +4,8 @@ Defines user project preferences ## Properties -| Property | Type | Required | Description | -|--------------|--------|----------|-------------------------------------------------------------------------------------------| -| `version` | number | **Yes** | | -| `fluenceEnv` | string | No | Fluence environment to connect to Possible values are: `dar`, `stage`, `local`, `custom`. | +| Property | Type | Required | Description | +|--------------|---------|----------|-------------------------------------------------------------------------------------------| +| `version` | integer | **Yes** | | +| `fluenceEnv` | string | No | Fluence environment to connect to Possible values are: `dar`, `stage`, `local`, `custom`. | diff --git a/docs/configs/fluence.md b/docs/configs/fluence.md index 58f006ecd..44f83113b 100644 --- a/docs/configs/fluence.md +++ b/docs/configs/fluence.md @@ -7,7 +7,7 @@ Defines Fluence Project, most importantly - what exactly you want to deploy and | Property | Type | Required | Description | |------------------------|-----------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `aquaDependencies` | [object](#aquadependencies) | **Yes** | A map of npm aqua dependency versions | -| `version` | number | **Yes** | | +| `version` | integer | **Yes** | | | `aquaImports` | string[] | No | A list of path to be considered by aqua compiler to be used as imports. First dependency in the list has the highest priority. Priority of imports is considered in the following order: imports from --import flags, imports from aquaImports property in fluence.yaml, project's .fluence/aqua dir, npm dependencies from fluence.yaml, npm dependencies from user's .fluence/config.yaml, npm dependencies recommended by fluence | | `cliVersion` | string | No | The version of the Fluence CLI that is compatible with this project. Set this to enforce a particular set of versions of all fluence components | | `compileAqua` | [object](#compileaqua) | No | A map of aqua files to compile | @@ -99,15 +99,16 @@ Deployment config | Property | Type | Required | Description | |-------------------------|----------|----------|----------------------------------------------------------------------------------------------------------------------------------------------| | `blacklist` | string[] | No | Blacklist of providers to deploy to. Can't be used together with whitelist | -| `computeUnits` | number | No | Number of compute units you require. 1 compute unit = 2GB. Currently the only allowed value is 1. This will change in the future. Default: 1 | +| `computeUnits` | integer | No | Number of compute units you require. 1 compute unit = 2GB. Currently the only allowed value is 1. This will change in the future. Default: 1 | | `effectors` | string[] | No | Effector CIDs to be used in the deal. Must be a valid CID | | `initialBalance` | string | No | Initial balance after deploy in USDC | -| `maxWorkersPerProvider` | number | No | Max workers per provider. Matches target workers by default | -| `minWorkers` | number | No | Required workers to activate the deal. Matches target workers by default | +| `maxWorkersPerProvider` | integer | No | Max workers per provider. Matches target workers by default | +| `minWorkers` | integer | No | Required workers to activate the deal. Matches target workers by default | | `pricePerWorkerEpoch` | string | No | Price per worker epoch in USDC | +| `protocolVersion` | integer | No | Protocol version. Default: 1 | | `services` | string[] | No | An array of service names to include in this worker. Service names must be listed in fluence.yaml | | `spells` | string[] | No | An array of spell names to include in this worker. Spell names must be listed in fluence.yaml | -| `targetWorkers` | number | No | Max workers in the deal | +| `targetWorkers` | integer | No | Max workers in the deal | | `whitelist` | string[] | No | Whitelist of providers to deploy to. Can't be used together with blacklist | ## hosts @@ -174,7 +175,7 @@ Overrides for the module config |-------------------|----------------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `envs` | [object](#envs) | No | environment variables accessible by a particular module with standard Rust env API like this: std::env::var(IPFS_ADDR_ENV_NAME). Please note that Marine adds three additional environment variables. Module environment variables could be examined with repl | | `loggerEnabled` | boolean | No | Set true to allow module to use the Marine SDK logger | -| `loggingMask` | number | No | manages the logging targets, described in detail: https://fluence.dev/docs/marine-book/marine-rust-sdk/developing/logging#using-target-map | +| `loggingMask` | integer | No | manages the logging targets, described in detail: https://fluence.dev/docs/marine-book/marine-rust-sdk/developing/logging#using-target-map | | `maxHeapSize` | string | No | DEPRECATED. Use `totalMemoryLimit` service property instead. Max size of the heap that a module can allocate in format: [number][whitespace?][B] where ? is an optional field and B is one of the following: kB, KB, kiB, KiB, KIB, mB, MB, miB, MiB, MIB, gB, GB, giB, GiB, GIB | | `mountedBinaries` | [object](#mountedbinaries) | No | A map of binary executable files that module is allowed to call. Example: curl: /usr/bin/curl | | `volumes` | [object](#volumes) | No | A map of accessible files and their aliases. Aliases should be used in Marine module development because it's hard to know the full path to a file | @@ -232,7 +233,7 @@ Spell config | `clock` | [object](#clock) | No | Trigger the spell execution periodically. If you want to disable this property by overriding it in fluence.yaml - pass empty config for it like this: `clock: {}` | | `function` | string | No | Name of the Aqua function that you want to use as a spell | | `initArgs` | [object](#initargs) | No | A map of Aqua function arguments names as keys and arguments values as values. They will be passed to the spell function and will be stored in the key-value storage for this particular spell. | -| `version` | number | No | | +| `version` | integer | No | | #### clock @@ -240,13 +241,13 @@ Trigger the spell execution periodically. If you want to disable this property b ##### Properties -| Property | Type | Required | Description | -|------------------|--------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `endDelaySec` | number | No | How long to wait before the last execution in seconds. If this property or `endTimestamp` not specified, periodic execution will never end. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. If it is in the past at the moment of spell creation - the spell will never be executed. This property conflicts with `endTimestamp`. You can specify only one of them | -| `endTimestamp` | string | No | An ISO timestamp when the periodic execution should end. If this property or `endDelaySec` not specified, periodic execution will never end. If it is in the past at the moment of spell creation on Rust peer - the spell will never be executed | -| `periodSec` | number | No | How often the spell will be executed. If set to 0, the spell will be executed only once. If this value not provided at all - the spell will never be executed | -| `startDelaySec` | number | No | How long to wait before the first execution in seconds. If this property or `startTimestamp` not specified, periodic execution will start immediately. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. This property conflicts with `startTimestamp`. You can specify only one of them | -| `startTimestamp` | string | No | An ISO timestamp when the periodic execution should start. If this property or `startDelaySec` not specified, periodic execution will start immediately. If it is set to 0 - the spell will never be executed | +| Property | Type | Required | Description | +|------------------|---------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `endDelaySec` | integer | No | How long to wait before the last execution in seconds. If this property or `endTimestamp` not specified, periodic execution will never end. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. If it is in the past at the moment of spell creation - the spell will never be executed. This property conflicts with `endTimestamp`. You can specify only one of them | +| `endTimestamp` | string | No | An ISO timestamp when the periodic execution should end. If this property or `endDelaySec` not specified, periodic execution will never end. If it is in the past at the moment of spell creation on Rust peer - the spell will never be executed | +| `periodSec` | integer | No | How often the spell will be executed. If set to 0, the spell will be executed only once. If this value not provided at all - the spell will never be executed | +| `startDelaySec` | integer | No | How long to wait before the first execution in seconds. If this property or `startTimestamp` not specified, periodic execution will start immediately. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. This property conflicts with `startTimestamp`. You can specify only one of them | +| `startTimestamp` | string | No | An ISO timestamp when the periodic execution should start. If this property or `startDelaySec` not specified, periodic execution will start immediately. If it is set to 0 - the spell will never be executed | #### initArgs diff --git a/docs/configs/module.md b/docs/configs/module.md index 42436e8f2..e835f5137 100644 --- a/docs/configs/module.md +++ b/docs/configs/module.md @@ -7,10 +7,10 @@ | Property | Type | Required | Description | |-------------------|----------------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `name` | string | **Yes** | "name" property from the Cargo.toml (for module type "rust") or name of the precompiled .wasm file (for module type "compiled") | -| `version` | number | **Yes** | | +| `version` | integer | **Yes** | | | `envs` | [object](#envs) | No | environment variables accessible by a particular module with standard Rust env API like this: std::env::var(IPFS_ADDR_ENV_NAME). Please note that Marine adds three additional environment variables. Module environment variables could be examined with repl | | `loggerEnabled` | boolean | No | Set true to allow module to use the Marine SDK logger | -| `loggingMask` | number | No | manages the logging targets, described in detail: https://fluence.dev/docs/marine-book/marine-rust-sdk/developing/logging#using-target-map | +| `loggingMask` | integer | No | manages the logging targets, described in detail: https://fluence.dev/docs/marine-book/marine-rust-sdk/developing/logging#using-target-map | | `maxHeapSize` | string | No | DEPRECATED. Use `totalMemoryLimit` service property instead. Max size of the heap that a module can allocate in format: [number][whitespace?][B] where ? is an optional field and B is one of the following: kB, KB, kiB, KiB, KIB, mB, MB, miB, MiB, MIB, gB, GB, giB, GiB, GIB | | `mountedBinaries` | [object](#mountedbinaries) | No | A map of binary executable files that module is allowed to call. Example: curl: /usr/bin/curl | | `type` | string | No | Module type "compiled" is for the precompiled modules. Module type "rust" is for the source code written in rust which can be compiled into a Marine module Possible values are: `rust`, `compiled`. | diff --git a/docs/configs/provider-artifacts.md b/docs/configs/provider-artifacts.md index e54464e5e..134855766 100644 --- a/docs/configs/provider-artifacts.md +++ b/docs/configs/provider-artifacts.md @@ -7,7 +7,7 @@ Defines artifacts created by the provider | Property | Type | Required | Description | |-----------|-------------------|----------|----------------| | `offers` | [object](#offers) | **Yes** | Created offers | -| `version` | number | **Yes** | Config version | +| `version` | integer | **Yes** | Config version | ## offers diff --git a/docs/configs/provider-secrets.md b/docs/configs/provider-secrets.md index 8ed0ec40a..b8039f152 100644 --- a/docs/configs/provider-secrets.md +++ b/docs/configs/provider-secrets.md @@ -7,7 +7,7 @@ Defines secrets config used for provider set up | Property | Type | Required | Description | |-----------|------------------|----------|-------------------------------| | `noxes` | [object](#noxes) | **Yes** | Secret keys for noxes by name | -| `version` | number | **Yes** | Config version | +| `version` | integer | **Yes** | Config version | ## noxes diff --git a/docs/configs/provider.md b/docs/configs/provider.md index b3fd82fcb..1fb8ce46b 100644 --- a/docs/configs/provider.md +++ b/docs/configs/provider.md @@ -10,7 +10,7 @@ Defines config used for provider set up | `computePeers` | [object](#computepeers) | **Yes** | A map with compute peer names as keys and compute peers as values | | `offers` | [object](#offers) | **Yes** | A map with offer names as keys and offers as values | | `providerName` | string | **Yes** | Provider name. Must not be empty | -| `version` | number | **Yes** | Config version | +| `version` | integer | **Yes** | Config version | | `nox` | [object](#nox) | No | Configuration to pass to the nox compute peer. Config.toml files are generated from this config | ## capacityCommitments @@ -53,7 +53,7 @@ Defines a compute peer | Property | Type | Required | Description | |----------------|----------------|----------|-------------------------------------------------------------------------------------------------| -| `computeUnits` | number | **Yes** | How many compute units should nox have. Default: 32 (each compute unit requires 2GB of RAM) | +| `computeUnits` | integer | **Yes** | How many compute units should nox have. Default: 32 (each compute unit requires 2GB of RAM) | | `nox` | [object](#nox) | No | Configuration to pass to the nox compute peer. Config.toml files are generated from this config | #### nox @@ -64,14 +64,14 @@ Configuration to pass to the nox compute peer. Config.toml files are generated f | Property | Type | Required | Description | |------------------|---------------------------|----------|-------------------------------------------------------------------------------------------------------------------| -| `aquavmPoolSize` | number | No | Number of aquavm instances to run. Default: 2 | +| `aquavmPoolSize` | integer | No | Number of aquavm instances to run. Default: 2 | | `chainConfig` | [object](#chainconfig) | No | Chain config | | `effectors` | [object](#effectors) | No | Effectors to allow on the nox | -| `httpPort` | number | No | Both host and container HTTP port to use. Default: for each nox a unique port is assigned starting from 18080 | +| `httpPort` | integer | No | Both host and container HTTP port to use. Default: for each nox a unique port is assigned starting from 18080 | | `rawConfig` | string | No | Raw TOML config string to parse and merge with the rest of the config. Has the highest priority | | `systemServices` | [object](#systemservices) | No | System services to run by default. aquaIpfs and decider are enabled by default | -| `tcpPort` | number | No | Both host and container TCP port to use. Default: for each nox a unique port is assigned starting from 7771 | -| `websocketPort` | number | No | Both host and container WebSocket port to use. Default: for each nox a unique port is assigned starting from 9991 | +| `tcpPort` | integer | No | Both host and container TCP port to use. Default: for each nox a unique port is assigned starting from 7771 | +| `websocketPort` | integer | No | Both host and container WebSocket port to use. Default: for each nox a unique port is assigned starting from 9991 | ##### chainConfig @@ -79,14 +79,14 @@ Chain config ###### Properties -| Property | Type | Required | Description | -|-------------------------|--------|----------|---------------------------------------------| -| `ccContractAddress` | string | No | Capacity commitment contract address | -| `coreContractAddress` | string | No | Core contract address | -| `httpEndpoint` | string | No | HTTP endpoint of the chain. Same as decider | -| `marketContractAddress` | string | No | Market contract address | -| `networkId` | number | No | Network ID | -| `walletKey` | string | No | Wallet key | +| Property | Type | Required | Description | +|-------------------------|---------|----------|---------------------------------------------| +| `ccContractAddress` | string | No | Capacity commitment contract address | +| `coreContractAddress` | string | No | Core contract address | +| `httpEndpoint` | string | No | HTTP endpoint of the chain. Same as decider | +| `marketContractAddress` | string | No | Market contract address | +| `networkId` | integer | No | Network ID | +| `walletKey` | string | No | Wallet key | ##### effectors @@ -148,15 +148,15 @@ Decider service configuration **Properties** -| Property | Type | Required | Description | -|-----------------------|--------|----------|----------------------------------| -| `deciderPeriodSec` | number | No | Decider period in seconds | -| `matcherAddress` | string | No | Matcher address | -| `networkApiEndpoint` | string | No | Network API endpoint | -| `networkId` | number | No | Network ID | -| `startBlock` | string | No | Start block | -| `walletKey` | string | No | Wallet key | -| `workerIpfsMultiaddr` | string | No | Multiaddress of worker IPFS node | +| Property | Type | Required | Description | +|-----------------------|---------|----------|----------------------------------| +| `deciderPeriodSec` | integer | No | Decider period in seconds | +| `matcherAddress` | string | No | Matcher address | +| `networkApiEndpoint` | string | No | Network API endpoint | +| `networkId` | integer | No | Network ID | +| `startBlock` | string | No | Start block | +| `walletKey` | string | No | Wallet key | +| `workerIpfsMultiaddr` | string | No | Multiaddress of worker IPFS node | ## nox @@ -166,14 +166,14 @@ Configuration to pass to the nox compute peer. Config.toml files are generated f | Property | Type | Required | Description | |------------------|---------------------------|----------|-------------------------------------------------------------------------------------------------------------------| -| `aquavmPoolSize` | number | No | Number of aquavm instances to run. Default: 2 | +| `aquavmPoolSize` | integer | No | Number of aquavm instances to run. Default: 2 | | `chainConfig` | [object](#chainconfig) | No | Chain config | | `effectors` | [object](#effectors) | No | Effectors to allow on the nox | -| `httpPort` | number | No | Both host and container HTTP port to use. Default: for each nox a unique port is assigned starting from 18080 | +| `httpPort` | integer | No | Both host and container HTTP port to use. Default: for each nox a unique port is assigned starting from 18080 | | `rawConfig` | string | No | Raw TOML config string to parse and merge with the rest of the config. Has the highest priority | | `systemServices` | [object](#systemservices) | No | System services to run by default. aquaIpfs and decider are enabled by default | -| `tcpPort` | number | No | Both host and container TCP port to use. Default: for each nox a unique port is assigned starting from 7771 | -| `websocketPort` | number | No | Both host and container WebSocket port to use. Default: for each nox a unique port is assigned starting from 9991 | +| `tcpPort` | integer | No | Both host and container TCP port to use. Default: for each nox a unique port is assigned starting from 7771 | +| `websocketPort` | integer | No | Both host and container WebSocket port to use. Default: for each nox a unique port is assigned starting from 9991 | ### chainConfig @@ -181,14 +181,14 @@ Chain config #### Properties -| Property | Type | Required | Description | -|-------------------------|--------|----------|---------------------------------------------| -| `ccContractAddress` | string | No | Capacity commitment contract address | -| `coreContractAddress` | string | No | Core contract address | -| `httpEndpoint` | string | No | HTTP endpoint of the chain. Same as decider | -| `marketContractAddress` | string | No | Market contract address | -| `networkId` | number | No | Network ID | -| `walletKey` | string | No | Wallet key | +| Property | Type | Required | Description | +|-------------------------|---------|----------|---------------------------------------------| +| `ccContractAddress` | string | No | Capacity commitment contract address | +| `coreContractAddress` | string | No | Core contract address | +| `httpEndpoint` | string | No | HTTP endpoint of the chain. Same as decider | +| `marketContractAddress` | string | No | Market contract address | +| `networkId` | integer | No | Network ID | +| `walletKey` | string | No | Wallet key | ### effectors @@ -250,15 +250,15 @@ Decider service configuration ##### Properties -| Property | Type | Required | Description | -|-----------------------|--------|----------|----------------------------------| -| `deciderPeriodSec` | number | No | Decider period in seconds | -| `matcherAddress` | string | No | Matcher address | -| `networkApiEndpoint` | string | No | Network API endpoint | -| `networkId` | number | No | Network ID | -| `startBlock` | string | No | Start block | -| `walletKey` | string | No | Wallet key | -| `workerIpfsMultiaddr` | string | No | Multiaddress of worker IPFS node | +| Property | Type | Required | Description | +|-----------------------|---------|----------|----------------------------------| +| `deciderPeriodSec` | integer | No | Decider period in seconds | +| `matcherAddress` | string | No | Matcher address | +| `networkApiEndpoint` | string | No | Network API endpoint | +| `networkId` | integer | No | Network ID | +| `startBlock` | string | No | Start block | +| `walletKey` | string | No | Wallet key | +| `workerIpfsMultiaddr` | string | No | Multiaddress of worker IPFS node | ## offers @@ -276,9 +276,11 @@ Defines a provider offer #### Properties -| Property | Type | Required | Description | -|--------------------------|----------|----------|-----------------------------------------------| -| `computePeers` | string[] | **Yes** | Number of Compute Units for this Compute Peer | -| `minPricePerWorkerEpoch` | string | **Yes** | Minimum price per worker epoch in USDC | -| `effectors` | string[] | No | | +| Property | Type | Required | Description | +|--------------------------|----------|----------|------------------------------------------------------------------------------------| +| `computePeers` | string[] | **Yes** | Number of Compute Units for this Compute Peer | +| `minPricePerWorkerEpoch` | string | **Yes** | Minimum price per worker epoch in USDC | +| `effectors` | string[] | No | | +| `maxProtocolVersion` | integer | No | Max protocol version. Must be more then or equal to minProtocolVersion. Default: 1 | +| `minProtocolVersion` | integer | No | Min protocol version. Must be less then or equal to maxProtocolVersion. Default: 1 | diff --git a/docs/configs/service.md b/docs/configs/service.md index a854e5687..72f3ab903 100644 --- a/docs/configs/service.md +++ b/docs/configs/service.md @@ -8,7 +8,7 @@ Defines a [Marine service](https://fluence.dev/docs/build/concepts/#services), m |--------------------|--------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `modules` | [object](#modules) | **Yes** | Service must have a facade module. Each module properties can be overridden by the same properties in the service config | | `name` | string | **Yes** | Service name. Currently it is used for the service name only when you add service to fluence.yaml using "add" command. But this name can be overridden to any other with the --name flag or manually in fluence.yaml | -| `version` | number | **Yes** | | +| `version` | integer | **Yes** | | | `totalMemoryLimit` | string | No | Memory limit for all service modules. If you specify this property please make sure it's at least `2 MiB * numberOfModulesInTheService`. In repl default is: Infinity. When deploying service as part of the worker default is: computeUnits * 2GB / (amount of services in the worker). Format: [number][whitespace?][B] where ? is an optional field and B is one of the following: kB, KB, kiB, KiB, KIB, mB, MB, miB, MiB, MIB, gB, GB, giB, GiB, GIB | ## modules @@ -31,7 +31,7 @@ Service must have a facade module. Each module properties can be overridden by t | `get` | string | **Yes** | Either path to the module directory or URL to the tar.gz archive which contains the content of the module directory | | `envs` | [object](#envs) | No | environment variables accessible by a particular module with standard Rust env API like this: std::env::var(IPFS_ADDR_ENV_NAME). Please note that Marine adds three additional environment variables. Module environment variables could be examined with repl | | `loggerEnabled` | boolean | No | Set true to allow module to use the Marine SDK logger | -| `loggingMask` | number | No | manages the logging targets, described in detail: https://fluence.dev/docs/marine-book/marine-rust-sdk/developing/logging#using-target-map | +| `loggingMask` | integer | No | manages the logging targets, described in detail: https://fluence.dev/docs/marine-book/marine-rust-sdk/developing/logging#using-target-map | | `maxHeapSize` | string | No | DEPRECATED. Use `totalMemoryLimit` service property instead. Max size of the heap that a module can allocate in format: [number][whitespace?][B] where ? is an optional field and B is one of the following: kB, KB, kiB, KiB, KIB, mB, MB, miB, MiB, MIB, gB, GB, giB, GiB, GIB | | `mountedBinaries` | [object](#mountedbinaries) | No | A map of binary executable files that module is allowed to call. Example: curl: /usr/bin/curl | | `volumes` | [object](#volumes) | No | A map of accessible files and their aliases. Aliases should be used in Marine module development because it's hard to know the full path to a file | @@ -75,7 +75,7 @@ A map of accessible files and their aliases. Aliases should be used in Marine mo | `get` | string | **Yes** | Either path to the module directory or URL to the tar.gz archive which contains the content of the module directory | | `envs` | [object](#envs) | No | environment variables accessible by a particular module with standard Rust env API like this: std::env::var(IPFS_ADDR_ENV_NAME). Please note that Marine adds three additional environment variables. Module environment variables could be examined with repl | | `loggerEnabled` | boolean | No | Set true to allow module to use the Marine SDK logger | -| `loggingMask` | number | No | manages the logging targets, described in detail: https://fluence.dev/docs/marine-book/marine-rust-sdk/developing/logging#using-target-map | +| `loggingMask` | integer | No | manages the logging targets, described in detail: https://fluence.dev/docs/marine-book/marine-rust-sdk/developing/logging#using-target-map | | `maxHeapSize` | string | No | DEPRECATED. Use `totalMemoryLimit` service property instead. Max size of the heap that a module can allocate in format: [number][whitespace?][B] where ? is an optional field and B is one of the following: kB, KB, kiB, KiB, KIB, mB, MB, miB, MiB, MIB, gB, GB, giB, GiB, GIB | | `mountedBinaries` | [object](#mountedbinaries) | No | A map of binary executable files that module is allowed to call. Example: curl: /usr/bin/curl | | `volumes` | [object](#volumes) | No | A map of accessible files and their aliases. Aliases should be used in Marine module development because it's hard to know the full path to a file | diff --git a/docs/configs/spell.md b/docs/configs/spell.md index 6acca569d..49a6ccd8c 100644 --- a/docs/configs/spell.md +++ b/docs/configs/spell.md @@ -8,7 +8,7 @@ Defines a spell. You can use `fluence spell new` command to generate a template |----------------|---------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `aquaFilePath` | string | **Yes** | Path to Aqua file which contains an Aqua function that you want to use as a spell | | `function` | string | **Yes** | Name of the Aqua function that you want to use as a spell | -| `version` | number | **Yes** | | +| `version` | integer | **Yes** | | | `clock` | [object](#clock) | No | Trigger the spell execution periodically. If you want to disable this property by overriding it in fluence.yaml - pass empty config for it like this: `clock: {}` | | `initArgs` | [object](#initargs) | No | A map of Aqua function arguments names as keys and arguments values as values. They will be passed to the spell function and will be stored in the key-value storage for this particular spell. | @@ -18,13 +18,13 @@ Trigger the spell execution periodically. If you want to disable this property b ### Properties -| Property | Type | Required | Description | -|------------------|--------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `endDelaySec` | number | No | How long to wait before the last execution in seconds. If this property or `endTimestamp` not specified, periodic execution will never end. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. If it is in the past at the moment of spell creation - the spell will never be executed. This property conflicts with `endTimestamp`. You can specify only one of them | -| `endTimestamp` | string | No | An ISO timestamp when the periodic execution should end. If this property or `endDelaySec` not specified, periodic execution will never end. If it is in the past at the moment of spell creation on Rust peer - the spell will never be executed | -| `periodSec` | number | No | How often the spell will be executed. If set to 0, the spell will be executed only once. If this value not provided at all - the spell will never be executed | -| `startDelaySec` | number | No | How long to wait before the first execution in seconds. If this property or `startTimestamp` not specified, periodic execution will start immediately. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. This property conflicts with `startTimestamp`. You can specify only one of them | -| `startTimestamp` | string | No | An ISO timestamp when the periodic execution should start. If this property or `startDelaySec` not specified, periodic execution will start immediately. If it is set to 0 - the spell will never be executed | +| Property | Type | Required | Description | +|------------------|---------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `endDelaySec` | integer | No | How long to wait before the last execution in seconds. If this property or `endTimestamp` not specified, periodic execution will never end. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. If it is in the past at the moment of spell creation - the spell will never be executed. This property conflicts with `endTimestamp`. You can specify only one of them | +| `endTimestamp` | string | No | An ISO timestamp when the periodic execution should end. If this property or `endDelaySec` not specified, periodic execution will never end. If it is in the past at the moment of spell creation on Rust peer - the spell will never be executed | +| `periodSec` | integer | No | How often the spell will be executed. If set to 0, the spell will be executed only once. If this value not provided at all - the spell will never be executed | +| `startDelaySec` | integer | No | How long to wait before the first execution in seconds. If this property or `startTimestamp` not specified, periodic execution will start immediately. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. This property conflicts with `startTimestamp`. You can specify only one of them | +| `startTimestamp` | string | No | An ISO timestamp when the periodic execution should start. If this property or `startDelaySec` not specified, periodic execution will start immediately. If it is set to 0 - the spell will never be executed | ## initArgs diff --git a/docs/configs/workers.md b/docs/configs/workers.md index 15b122650..fb74b91e0 100644 --- a/docs/configs/workers.md +++ b/docs/configs/workers.md @@ -6,7 +6,7 @@ A result of app deployment. This file is created automatically after successful | Property | Type | Required | Description | |-----------|------------------|----------|----------------------------------------------------------------------------------------------------| -| `version` | number | **Yes** | Config version | +| `version` | integer | **Yes** | Config version | | `deals` | [object](#deals) | No | Info about deals created when deploying workers that is stored by environment that you deployed to | | `hosts` | [object](#hosts) | No | Info about directly deployed workers that is stored by environment that you deployed to | @@ -39,14 +39,14 @@ Contains data related to your deployment, including, most importantly, deal id, ##### Properties -| Property | Type | Required | Description | -|------------------|--------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `chainNetworkId` | number | **Yes** | Blockchain network id that was used when deploying workers | -| `chainNetwork` | string | **Yes** | Blockchain network name that was used when deploying workers Possible values are: `dar`, `stage`, `local`. | -| `dealIdOriginal` | string | **Yes** | Blockchain transaction id that you get when deploy workers. Can be used in aqua to get worker and host ids. Check out example in the aqua generated in the default template | -| `dealId` | string | **Yes** | Lowercased version of dealIdOriginal without 0x prefix. Currently unused. Was previously used to resolve workers in aqua | -| `definition` | string | **Yes** | CID of uploaded to IPFS App Definition, which contains the data about everything that you are trying to deploy, including spells, service and module configs and CIDs for service wasms | -| `timestamp` | string | **Yes** | ISO timestamp of the time when the worker was deployed | +| Property | Type | Required | Description | +|------------------|---------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `chainNetworkId` | integer | **Yes** | Blockchain network id that was used when deploying workers | +| `chainNetwork` | string | **Yes** | Blockchain network name that was used when deploying workers Possible values are: `dar`, `stage`, `local`. | +| `dealIdOriginal` | string | **Yes** | Blockchain transaction id that you get when deploy workers. Can be used in aqua to get worker and host ids. Check out example in the aqua generated in the default template | +| `dealId` | string | **Yes** | Lowercased version of dealIdOriginal without 0x prefix. Currently unused. Was previously used to resolve workers in aqua | +| `definition` | string | **Yes** | CID of uploaded to IPFS App Definition, which contains the data about everything that you are trying to deploy, including spells, service and module configs and CIDs for service wasms | +| `timestamp` | string | **Yes** | ISO timestamp of the time when the worker was deployed | ### dar @@ -64,14 +64,14 @@ Contains data related to your deployment, including, most importantly, deal id, ##### Properties -| Property | Type | Required | Description | -|------------------|--------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `chainNetworkId` | number | **Yes** | Blockchain network id that was used when deploying workers | -| `chainNetwork` | string | **Yes** | Blockchain network name that was used when deploying workers Possible values are: `dar`, `stage`, `local`. | -| `dealIdOriginal` | string | **Yes** | Blockchain transaction id that you get when deploy workers. Can be used in aqua to get worker and host ids. Check out example in the aqua generated in the default template | -| `dealId` | string | **Yes** | Lowercased version of dealIdOriginal without 0x prefix. Currently unused. Was previously used to resolve workers in aqua | -| `definition` | string | **Yes** | CID of uploaded to IPFS App Definition, which contains the data about everything that you are trying to deploy, including spells, service and module configs and CIDs for service wasms | -| `timestamp` | string | **Yes** | ISO timestamp of the time when the worker was deployed | +| Property | Type | Required | Description | +|------------------|---------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `chainNetworkId` | integer | **Yes** | Blockchain network id that was used when deploying workers | +| `chainNetwork` | string | **Yes** | Blockchain network name that was used when deploying workers Possible values are: `dar`, `stage`, `local`. | +| `dealIdOriginal` | string | **Yes** | Blockchain transaction id that you get when deploy workers. Can be used in aqua to get worker and host ids. Check out example in the aqua generated in the default template | +| `dealId` | string | **Yes** | Lowercased version of dealIdOriginal without 0x prefix. Currently unused. Was previously used to resolve workers in aqua | +| `definition` | string | **Yes** | CID of uploaded to IPFS App Definition, which contains the data about everything that you are trying to deploy, including spells, service and module configs and CIDs for service wasms | +| `timestamp` | string | **Yes** | ISO timestamp of the time when the worker was deployed | ### local @@ -89,14 +89,14 @@ Contains data related to your deployment, including, most importantly, deal id, ##### Properties -| Property | Type | Required | Description | -|------------------|--------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `chainNetworkId` | number | **Yes** | Blockchain network id that was used when deploying workers | -| `chainNetwork` | string | **Yes** | Blockchain network name that was used when deploying workers Possible values are: `dar`, `stage`, `local`. | -| `dealIdOriginal` | string | **Yes** | Blockchain transaction id that you get when deploy workers. Can be used in aqua to get worker and host ids. Check out example in the aqua generated in the default template | -| `dealId` | string | **Yes** | Lowercased version of dealIdOriginal without 0x prefix. Currently unused. Was previously used to resolve workers in aqua | -| `definition` | string | **Yes** | CID of uploaded to IPFS App Definition, which contains the data about everything that you are trying to deploy, including spells, service and module configs and CIDs for service wasms | -| `timestamp` | string | **Yes** | ISO timestamp of the time when the worker was deployed | +| Property | Type | Required | Description | +|------------------|---------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `chainNetworkId` | integer | **Yes** | Blockchain network id that was used when deploying workers | +| `chainNetwork` | string | **Yes** | Blockchain network name that was used when deploying workers Possible values are: `dar`, `stage`, `local`. | +| `dealIdOriginal` | string | **Yes** | Blockchain transaction id that you get when deploy workers. Can be used in aqua to get worker and host ids. Check out example in the aqua generated in the default template | +| `dealId` | string | **Yes** | Lowercased version of dealIdOriginal without 0x prefix. Currently unused. Was previously used to resolve workers in aqua | +| `definition` | string | **Yes** | CID of uploaded to IPFS App Definition, which contains the data about everything that you are trying to deploy, including spells, service and module configs and CIDs for service wasms | +| `timestamp` | string | **Yes** | ISO timestamp of the time when the worker was deployed | ### stage @@ -114,14 +114,14 @@ Contains data related to your deployment, including, most importantly, deal id, ##### Properties -| Property | Type | Required | Description | -|------------------|--------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `chainNetworkId` | number | **Yes** | Blockchain network id that was used when deploying workers | -| `chainNetwork` | string | **Yes** | Blockchain network name that was used when deploying workers Possible values are: `dar`, `stage`, `local`. | -| `dealIdOriginal` | string | **Yes** | Blockchain transaction id that you get when deploy workers. Can be used in aqua to get worker and host ids. Check out example in the aqua generated in the default template | -| `dealId` | string | **Yes** | Lowercased version of dealIdOriginal without 0x prefix. Currently unused. Was previously used to resolve workers in aqua | -| `definition` | string | **Yes** | CID of uploaded to IPFS App Definition, which contains the data about everything that you are trying to deploy, including spells, service and module configs and CIDs for service wasms | -| `timestamp` | string | **Yes** | ISO timestamp of the time when the worker was deployed | +| Property | Type | Required | Description | +|------------------|---------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `chainNetworkId` | integer | **Yes** | Blockchain network id that was used when deploying workers | +| `chainNetwork` | string | **Yes** | Blockchain network name that was used when deploying workers Possible values are: `dar`, `stage`, `local`. | +| `dealIdOriginal` | string | **Yes** | Blockchain transaction id that you get when deploy workers. Can be used in aqua to get worker and host ids. Check out example in the aqua generated in the default template | +| `dealId` | string | **Yes** | Lowercased version of dealIdOriginal without 0x prefix. Currently unused. Was previously used to resolve workers in aqua | +| `definition` | string | **Yes** | CID of uploaded to IPFS App Definition, which contains the data about everything that you are trying to deploy, including spells, service and module configs and CIDs for service wasms | +| `timestamp` | string | **Yes** | ISO timestamp of the time when the worker was deployed | ## hosts diff --git a/package.json b/package.json index a863be327..feb9aa56d 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "@fluencelabs/air-beautify-wasm": "0.3.6", "@fluencelabs/aqua-api": "0.14.2", "@fluencelabs/aqua-to-js": "0.3.5", - "@fluencelabs/deal-ts-clients": "0.7.0", + "@fluencelabs/deal-ts-clients": "0.7.1", "@fluencelabs/fluence-network-environment": "1.1.2", "@fluencelabs/js-client": "0.8.4", "@fluencelabs/npm-aqua-compiler": "0.0.3", diff --git a/src/commands/deal/create.ts b/src/commands/deal/create.ts index d2d9a44be..6b834257b 100644 --- a/src/commands/deal/create.ts +++ b/src/commands/deal/create.ts @@ -69,6 +69,9 @@ export default class Create extends BaseCommand { description: "Comma-separated list of blacklisted providers", exclusive: ["whitelist"], }), + "protocol-version": Flags.integer({ + description: "Protocol version", + }), ...CHAIN_FLAGS, }; @@ -95,6 +98,7 @@ export default class Create extends BaseCommand { flags.blacklist === undefined ? undefined : commaSepStrToArr(flags.blacklist), + protocolVersion: flags["protocol-version"], }); commandObj.logToStderr( diff --git a/src/commands/local/up.ts b/src/commands/local/up.ts index 6c6f8eaf4..09e970522 100644 --- a/src/commands/local/up.ts +++ b/src/commands/local/up.ts @@ -78,7 +78,7 @@ export default class Up extends BaseCommand { description: "Resets docker-compose.yaml to default, removes volumes and previous local deployments", allowNo: true, - default: false, + default: true, char: "r", }), }; @@ -99,6 +99,7 @@ export default class Up extends BaseCommand { if (flags.reset) { const dirPath = dockerComposeDirPath(); + await initNewReadonlyDockerComposeConfig(); try { await dockerCompose({ diff --git a/src/commands/provider/deal-exit.ts b/src/commands/provider/deal-exit.ts index e6b7fa855..7b9640aa1 100644 --- a/src/commands/provider/deal-exit.ts +++ b/src/commands/provider/deal-exit.ts @@ -40,21 +40,25 @@ export default class DealExit extends BaseCommand { async run(): Promise { const { args } = await initCli(this, await this.parse(DealExit)); const { dealClient } = await getDealClient(); + const market = await dealClient.getMarket(); - const deals = await Promise.all( - commaSepStrToArr( - args["DEAL-IDS"] ?? - (await input({ - message: "Enter comma-separated deal ids", - })), - ).map((id) => { - return dealClient.getDeal(id); - }), - ); + const computeUnits = ( + await Promise.all( + commaSepStrToArr( + args["DEAL-IDS"] ?? + (await input({ + message: "Enter comma-separated deal ids", + })), + ).map(async (id) => { + const deal = dealClient.getDeal(id); + return deal.getComputeUnits(); + }), + ) + ).flat(); await signBatch( - deals.map((deal) => { - return [deal.stop]; + computeUnits.map((computeUnit) => { + return [market.returnComputeUnitFromDeal, computeUnit.id]; }), ); } diff --git a/src/commands/service/new.ts b/src/commands/service/new.ts index e3d1431b4..a54e9d774 100644 --- a/src/commands/service/new.ts +++ b/src/commands/service/new.ts @@ -60,7 +60,7 @@ export default class New extends BaseCommand { join(flags.path ?? (await ensureServicesDir()), serviceName), ); - const pathToModuleDir = join(absoluteServicePath, "modules", serviceName); + const pathToModuleDir = join(absoluteServicePath, serviceName); await generateNewModule(pathToModuleDir); await initNewReadonlyServiceConfig( diff --git a/src/lib/aqua.ts b/src/lib/aqua.ts index 55670ddc3..7bc6d24aa 100644 --- a/src/lib/aqua.ts +++ b/src/lib/aqua.ts @@ -25,6 +25,8 @@ import type { import type { GatherImportsResult } from "@fluencelabs/npm-aqua-compiler"; import { color } from "@oclif/color"; +import CLIPackageJSON from "../versions/cli.package.json" assert { type: "json" }; + import { commandObj } from "./commandObj.js"; import type { CompileAquaConfig, @@ -90,6 +92,22 @@ const writeFileAndMakeSureDirExists = async ( await writeFile(filePath, data, FS_OPTIONS); }; +let hasLoggedCompilerVersion = false; + +export async function importAquaCompiler() { + if (!hasLoggedCompilerVersion) { + commandObj.logToStderr( + color.blue( + `Using aqua compiler version: ${CLIPackageJSON.dependencies["@fluencelabs/aqua-api"]}`, + ), + ); + + hasLoggedCompilerVersion = true; + } + + return import("@fluencelabs/aqua-api"); +} + export type CompileToFilesArgs = CompileFromPathArgs & { outputPathAbsolute: string | undefined; dry?: boolean; @@ -105,7 +123,7 @@ export async function compileToFiles({ await stat(compileArgs.filePath) ).isDirectory(); - const { compileFromPath } = await import("@fluencelabs/aqua-api"); + const { compileFromPath } = await importAquaCompiler(); const [resultsWithErrors, compilationResultsWithFilePaths] = await compileDirOrFile(compileFromPath, compileArgs); @@ -208,7 +226,7 @@ export async function compileToFiles({ } export async function compileFunctionCall(args: CompileFuncCallFromPathArgs) { - const { compileAquaCallFromPath } = await import("@fluencelabs/aqua-api"); + const { compileAquaCallFromPath } = await importAquaCompiler(); return compileDirOrFile(compileAquaCallFromPath, args); } diff --git a/src/lib/helpers/validateCapacityCommitment.ts b/src/lib/chain/chainValidators.ts similarity index 56% rename from src/lib/helpers/validateCapacityCommitment.ts rename to src/lib/chain/chainValidators.ts index d350cdd6f..83b07db63 100644 --- a/src/lib/helpers/validateCapacityCommitment.ts +++ b/src/lib/chain/chainValidators.ts @@ -17,10 +17,10 @@ import { color } from "@oclif/color"; import parseDuration from "parse-duration"; +import { versions } from "../../versions.js"; import { getReadonlyDealClient } from "../dealClient.js"; import { ensureChainEnv } from "../ensureChainNetwork.js"; - -import type { ValidationResult } from "./validations.js"; +import type { ValidationResult } from "../helpers/validations.js"; export async function getMinCCDuration(): Promise { let minDuration: bigint = 0n; @@ -67,3 +67,50 @@ export async function validateAddress( return `Must be a valid address. Got: ${color.yellow(String(input))}`; } + +async function getProtocolVersions() { + let minProtocolVersion = BigInt(versions.protocolVersion); + let maxProtocolVersion = minProtocolVersion; + + if ((await ensureChainEnv()) !== "local") { + const { readonlyDealClient } = await getReadonlyDealClient(); + const core = await readonlyDealClient.getCore(); + + [minProtocolVersion, maxProtocolVersion] = await Promise.all([ + core.minProtocolVersion(), + core.maxProtocolVersion(), + ]); + } + + return { minProtocolVersion, maxProtocolVersion }; +} + +let protocolVersions: undefined | ReturnType; + +export async function validateProtocolVersion( + protocolVersion: number, +): Promise { + protocolVersions = + protocolVersions === undefined ? getProtocolVersions() : protocolVersions; + + const { minProtocolVersion, maxProtocolVersion } = await protocolVersions; + + if ( + protocolVersion < minProtocolVersion || + protocolVersion > maxProtocolVersion + ) { + if (minProtocolVersion === maxProtocolVersion) { + return `Protocol version must be equal to ${color.yellow( + `${minProtocolVersion}`, + )}. Got: ${color.yellow(protocolVersion)}`; + } + + return `Protocol version must be ${color.yellow( + `>=${minProtocolVersion}`, + )} and ${color.yellow(`<=${maxProtocolVersion}`)}. Got: ${color.yellow( + protocolVersion, + )}`; + } + + return true; +} diff --git a/src/lib/chain/offer.ts b/src/lib/chain/offer.ts index d595427fa..2f7b7c0b5 100644 --- a/src/lib/chain/offer.ts +++ b/src/lib/chain/offer.ts @@ -18,6 +18,7 @@ import { color } from "@oclif/color"; import times from "lodash-es/times.js"; import { yamlDiffPatch } from "yaml-diff-patch"; +import { versions } from "../../versions.js"; import { commandObj } from "../commandObj.js"; import { ensureComputerPeerConfigs, @@ -134,6 +135,8 @@ export async function createOffers(flags: OffersArgs) { effectorPrefixesAndHash, minPricePerWorkerEpochBigInt, offerName, + minProtocolVersion, + maxProtocolVersion, } = offer; const txReceipt = await sign( @@ -142,6 +145,8 @@ export async function createOffers(flags: OffersArgs) { usdcAddress, effectorPrefixesAndHash, computePeersToRegister, + minProtocolVersion ?? versions.protocolVersion, + maxProtocolVersion ?? versions.protocolVersion, ); registerMarketOfferTxReceipts.push({ offerName, txReceipt }); @@ -460,7 +465,13 @@ async function ensureOfferConfigs() { Object.entries(providerConfig.offers).map( async ([ offerName, - { minPricePerWorkerEpoch, effectors, computePeers }, + { + minPricePerWorkerEpoch, + effectors, + computePeers, + minProtocolVersion, + maxProtocolVersion, + }, ]) => { const computePeerConfigs = await ensureComputerPeerConfigs(computePeers); @@ -504,6 +515,8 @@ async function ensureOfferConfigs() { computePeersToRegister, offerId, offerInfo, + minProtocolVersion, + maxProtocolVersion, }; }, ), diff --git a/src/lib/configs/project/dockerCompose.ts b/src/lib/configs/project/dockerCompose.ts index b95ada0fa..2272d7e5a 100644 --- a/src/lib/configs/project/dockerCompose.ts +++ b/src/lib/configs/project/dockerCompose.ts @@ -105,6 +105,7 @@ function genNox({ }, command: [ `--config=${configLocation}`, + "--dev-mode", "--external-maddrs", `/dns4/${name}/tcp/${tcpPort}`, `/dns4/${name}/tcp/${webSocketPort}/ws`, diff --git a/src/lib/configs/project/env.ts b/src/lib/configs/project/env.ts index 05899a607..b9dc42366 100644 --- a/src/lib/configs/project/env.ts +++ b/src/lib/configs/project/env.ts @@ -52,7 +52,7 @@ const configSchemaV0: JSONSchemaType = { enum: [...FLUENCE_ENVS], nullable: true, }, - version: { type: "number", const: 0 }, + version: { type: "integer", const: 0 }, }, required: ["version"], additionalProperties: false, diff --git a/src/lib/configs/project/fluence.ts b/src/lib/configs/project/fluence.ts index 420877d88..fe5a84d33 100644 --- a/src/lib/configs/project/fluence.ts +++ b/src/lib/configs/project/fluence.ts @@ -27,6 +27,7 @@ import { yamlDiffPatch } from "yaml-diff-patch"; import CLIPackageJSON from "../../../versions/cli.package.json" assert { type: "json" }; import { versions } from "../../../versions.js"; import { ajv, validationErrorToString } from "../../ajvInstance.js"; +import { validateProtocolVersion } from "../../chain/chainValidators.js"; import { COMPUTE_UNIT_MEMORY_STR, MAX_HEAP_SIZE_DESCRIPTION, @@ -106,7 +107,7 @@ type ConfigV0 = { const configSchemaV0Obj = { type: "object", properties: { - version: { type: "number", const: 0 }, + version: { type: "integer", const: 0 }, services: { title: "Services", type: "array", @@ -114,7 +115,7 @@ const configSchemaV0Obj = { type: "object", properties: { name: { type: "string" }, - count: { type: "number", nullable: true, minimum: 1 }, + count: { type: "integer", nullable: true, minimum: 1 }, }, required: ["name"], }, @@ -206,7 +207,7 @@ const configSchemaV1Obj = { ], nullable: true, }, - version: { type: "number", const: 1 }, + version: { type: "integer", const: 1 }, }, required: ["version"], } as const; @@ -229,6 +230,7 @@ type Deal = { effectors?: string[]; whitelist?: string[]; blacklist?: string[]; + protocolVersion?: number; }; type Worker = { @@ -276,7 +278,7 @@ const dealSchemaObj = { type: "object", properties: { computeUnits: { - type: "number", + type: "integer", minimum: 1, maximum: 1, default: 1, @@ -284,21 +286,21 @@ const dealSchemaObj = { nullable: true, }, targetWorkers: { - type: "number", + type: "integer", description: "Max workers in the deal", default: TARGET_WORKERS_DEFAULT, nullable: true, minimum: 1, }, minWorkers: { - type: "number", + type: "integer", description: "Required workers to activate the deal. Matches target workers by default", nullable: true, minimum: 1, }, maxWorkersPerProvider: { - type: "number", + type: "integer", description: "Max workers per provider. Matches target workers by default", nullable: true, @@ -336,6 +338,13 @@ const dealSchemaObj = { items: { type: "string" }, nullable: true, }, + protocolVersion: { + type: "integer", + description: `Protocol version. Default: ${versions.protocolVersion}`, + nullable: true, + default: versions.protocolVersion, + minimum: 1, + }, }, required: [], } as const satisfies JSONSchemaType; @@ -395,7 +404,7 @@ const configSchemaV2Obj = { ...configSchemaV1Obj, properties: { ...configSchemaV1Obj.properties, - version: { type: "number", const: 2 }, + version: { type: "integer", const: 2 }, dependencies: { type: "object", title: "Dependencies", @@ -558,7 +567,7 @@ const configSchemaV3Obj = { delete properties.chainNetwork; return properties; })(), - version: { type: "number", const: 3 }, + version: { type: "integer", const: 3 }, customFluenceEnv: { type: "object", description: `Custom Fluence environment to use when connecting to Fluence network`, @@ -596,7 +605,7 @@ const configSchemaV4Obj = { ...configSchemaV3Obj, properties: { ...configSchemaV3Obj.properties, - version: { type: "number", const: 4 }, + version: { type: "integer", const: 4 }, defaultSecretKeyName: { description: "Secret key with this name will be used by default by js-client inside CLI to run Aqua code", @@ -642,7 +651,7 @@ const configSchemaV5Obj = { ...configSchemaV4Obj, properties: { ...configSchemaV4ObjPropertiesWithoutWorkers, - version: { type: "number", const: 5 }, + version: { type: "integer", const: 5 }, deals: { description: "A map of objects with worker names as keys, each object defines a deal", @@ -721,7 +730,7 @@ const configSchemaV6Obj = { ...configSchemaV5Obj, properties: { ...configSchemaV5ObjPropertiesWithoutDependencies, - version: { type: "number", const: 6 }, + version: { type: "integer", const: 6 }, aquaDependencies: { description: "A map of npm aqua dependency versions", type: "object", @@ -869,7 +878,7 @@ const configSchemaV7Obj = { ...configSchemaV6Obj, properties: { ...configSchemaV6ObjPropertiesWithoutAqua, - version: { type: "number", const: 7 }, + version: { type: "integer", const: 7 }, [COMPILE_AQUA_PROPERTY_NAME]: { type: "object", description: "A map of aqua files to compile", @@ -907,7 +916,7 @@ const configSchemaV8Obj = { description: `Defines Fluence Project, most importantly - what exactly you want to deploy and how. You can use \`${CLI_NAME} init\` command to generate a template for new Fluence project`, properties: { ...configSchemaV7ObjPropertiesWithoutDeals, - version: { type: "number", const: 8 }, + version: { type: "integer", const: 8 }, deployments: { ...configSchemaV7Obj.properties.deals, description: @@ -1515,6 +1524,43 @@ function validateNotBothBlacklistAndWhitelist( return true; } +async function validateProtocolVersions(config: LatestConfig) { + const errors = ( + await Promise.all( + Object.entries(config.deployments ?? {}) + .map(([deployment, { protocolVersion }]) => { + return { + deployment, + protocolVersion, + }; + }) + .filter((v): v is { deployment: string; protocolVersion: number } => { + return v.protocolVersion !== undefined; + }) + .map(async ({ deployment, protocolVersion }) => { + return { + validity: await validateProtocolVersion(protocolVersion), + deployment, + }; + }), + ) + ).filter((v): v is { validity: string; deployment: string } => { + return v.validity !== true; + }); + + if (errors.length !== 0) { + return errors + .map(({ deployment, validity }) => { + return `Deployment ${color.yellow( + deployment, + )} has invalid protocol version: ${color.yellow(validity)}`; + }) + .join("\n"); + } + + return true; +} + const validate: ConfigValidateFunction = async (config) => { return validateBatchAsync( validateNotBothBlacklistAndWhitelist(config), @@ -1535,6 +1581,7 @@ const validate: ConfigValidateFunction = async (config) => { checkDuplicatesAndPresence(config, "spells"), validateVersionsIsExact("marineVersion", config.marineVersion), validateVersionsIsExact("mreplVersion", config.mreplVersion), + validateProtocolVersions(config), ); }; diff --git a/src/lib/configs/project/module.ts b/src/lib/configs/project/module.ts index 12b18d7ab..5cf1987e5 100644 --- a/src/lib/configs/project/module.ts +++ b/src/lib/configs/project/module.ts @@ -66,7 +66,7 @@ const overridableModulePropertiesV0 = { description: "Set true to allow module to use the Marine SDK logger", }, loggingMask: { - type: "number", + type: "integer", nullable: true, description: "manages the logging targets, described in detail: https://fluence.dev/docs/marine-book/marine-rust-sdk/developing/logging#using-target-map", @@ -137,7 +137,7 @@ const configSchemaV0: JSONSchemaType = { description: `Module type "${MODULE_TYPE_COMPILED}" is for the precompiled modules. Module type "${MODULE_TYPE_RUST}" is for the source code written in rust which can be compiled into a Marine module`, }, ...overridableModulePropertiesV0, - version: { type: "number", const: 0 }, + version: { type: "integer", const: 0 }, }, additionalProperties: false, required: ["version", "name"], diff --git a/src/lib/configs/project/projectSecrets.ts b/src/lib/configs/project/projectSecrets.ts index 0924acd25..7a00f4710 100644 --- a/src/lib/configs/project/projectSecrets.ts +++ b/src/lib/configs/project/projectSecrets.ts @@ -63,7 +63,7 @@ const configSchemaV0: JSONSchemaType = { nullable: true, description: `Key pair with this name will be used for the deployment by default. You can override it with flags or by using keyPair properties in ${FLUENCE_CONFIG_FULL_FILE_NAME}`, }, - version: { type: "number", const: 0 }, + version: { type: "integer", const: 0 }, }, required: ["version", "keyPairs"], }; diff --git a/src/lib/configs/project/provider.ts b/src/lib/configs/project/provider.ts index 46718eab3..09dda6afa 100644 --- a/src/lib/configs/project/provider.ts +++ b/src/lib/configs/project/provider.ts @@ -27,7 +27,13 @@ import mergeWith from "lodash-es/mergeWith.js"; import snakeCase from "lodash-es/snakeCase.js"; import times from "lodash-es/times.js"; +import { versions } from "../../../versions.js"; import { getChainId } from "../../chain/chainId.js"; +import { + ccDurationValidator, + validateAddress, + validateProtocolVersion, +} from "../../chain/chainValidators.js"; import { commandObj } from "../../commandObj.js"; import { COMPUTE_UNIT_MEMORY_STR, @@ -65,10 +71,6 @@ import { jsonStringify, splitErrorsAndResults, } from "../../helpers/utils.js"; -import { - ccDurationValidator, - validateAddress, -} from "../../helpers/validateCapacityCommitment.js"; import { type ValidationResult, validateCIDs, @@ -130,6 +132,8 @@ export type Offer = { minPricePerWorkerEpoch: string; computePeers: Array; effectors?: Array; + minProtocolVersion?: number; + maxProtocolVersion?: number; }; type Effector = { @@ -201,22 +205,22 @@ const noxConfigYAMLSchema = { properties: { tcpPort: { nullable: true, - type: "number", + type: "integer", description: `Both host and container TCP port to use. Default: for each nox a unique port is assigned starting from ${TCP_PORT_START}`, }, websocketPort: { nullable: true, - type: "number", + type: "integer", description: `Both host and container WebSocket port to use. Default: for each nox a unique port is assigned starting from ${WEB_SOCKET_PORT_START}`, }, httpPort: { nullable: true, - type: "number", + type: "integer", description: `Both host and container HTTP port to use. Default: for each nox a unique port is assigned starting from ${HTTP_PORT_START}`, }, aquavmPoolSize: { nullable: true, - type: "number", + type: "integer", description: `Number of aquavm instances to run. Default: ${DEFAULT_AQUAVM_POOL_SIZE}`, }, systemServices: { @@ -259,7 +263,7 @@ const noxConfigYAMLSchema = { properties: { deciderPeriodSec: { nullable: true, - type: "number", + type: "integer", description: `Decider period in seconds`, }, workerIpfsMultiaddr: { @@ -274,7 +278,7 @@ const noxConfigYAMLSchema = { }, networkId: { nullable: true, - type: "number", + type: "integer", description: `Network ID`, }, startBlock: { @@ -336,7 +340,7 @@ const noxConfigYAMLSchema = { }, networkId: { nullable: true, - type: "number", + type: "integer", description: `Network ID`, }, walletKey: { @@ -388,6 +392,20 @@ const offerSchema = { uniqueItems: true, }, effectors: { type: "array", items: { type: "string" }, nullable: true }, + minProtocolVersion: { + type: "integer", + description: `Min protocol version. Must be less then or equal to maxProtocolVersion. Default: ${versions.protocolVersion}`, + nullable: true, + default: versions.protocolVersion, + minimum: 1, + }, + maxProtocolVersion: { + type: "integer", + description: `Max protocol version. Must be more then or equal to minProtocolVersion. Default: ${versions.protocolVersion}`, + nullable: true, + default: versions.protocolVersion, + minimum: 1, + }, }, required: ["minPricePerWorkerEpoch", "computePeers"], } as const satisfies JSONSchemaType; @@ -398,7 +416,7 @@ const computePeerSchema = { additionalProperties: false, properties: { computeUnits: { - type: "number", + type: "integer", description: `How many compute units should nox have. Default: ${DEFAULT_NUMBER_OF_COMPUTE_UNITS_ON_NOX} (each compute unit requires ${COMPUTE_UNIT_MEMORY_STR} of RAM)`, }, nox: noxConfigYAMLSchema, @@ -448,7 +466,7 @@ const configSchemaV0 = { }, required: [], }, - version: { type: "number", const: 0, description: "Config version" }, + version: { type: "integer", const: 0, description: "Config version" }, }, required: [ "version", @@ -583,9 +601,65 @@ const validate: ConfigValidateFunction = async (config) => { validateCC(config), validateMissingComputePeers(config), validateNoDuplicateNoxNamesInOffers(config), + validateProtocolVersions(config), ); }; +async function validateProtocolVersions(providerConfig: LatestConfig) { + const errors = ( + await Promise.all( + Object.entries(providerConfig.offers).flatMap( + ([ + offer, + { + maxProtocolVersion = versions.protocolVersion, + minProtocolVersion = versions.protocolVersion, + }, + ]) => { + return [ + Promise.resolve({ + offer, + property: "minProtocolVersion or maxProtocolVersion", + validity: + minProtocolVersion > maxProtocolVersion + ? `minProtocolVersion must be less than or equal to maxProtocolVersion. Got: minProtocolVersion=${color.yellow( + minProtocolVersion, + )} maxProtocolVersion=${color.yellow(maxProtocolVersion)}` + : true, + }), + ...( + [ + ["minProtocolVersion", minProtocolVersion], + ["maxProtocolVersion", maxProtocolVersion], + ] as const + ).map(async ([property, v]) => { + return { + offer, + property, + validity: await validateProtocolVersion(v), + }; + }), + ]; + }, + ), + ) + ).filter(({ validity }) => { + return validity !== true; + }); + + if (errors.length > 0) { + return errors + .map(({ offer, property, validity }) => { + return `Offer ${color.yellow(offer)} has invalid ${color.yellow( + property, + )} property: ${validity}`; + }) + .join("\n"); + } + + return true; +} + export async function validateEffectors( providerConfig: LatestConfig, ): Promise { diff --git a/src/lib/configs/project/providerArtifacts.ts b/src/lib/configs/project/providerArtifacts.ts index 4b2440879..c1554da74 100644 --- a/src/lib/configs/project/providerArtifacts.ts +++ b/src/lib/configs/project/providerArtifacts.ts @@ -59,7 +59,7 @@ const configSchemaV0: JSONSchemaType = { type: "object", additionalProperties: false, properties: { - version: { type: "number", const: 0, description: "Config version" }, + version: { type: "integer", const: 0, description: "Config version" }, offers: { type: "object", description: "Created offers", diff --git a/src/lib/configs/project/providerSecrets.ts b/src/lib/configs/project/providerSecrets.ts index 6a2bb34ac..5351c579a 100644 --- a/src/lib/configs/project/providerSecrets.ts +++ b/src/lib/configs/project/providerSecrets.ts @@ -69,7 +69,7 @@ const configSchemaV0: JSONSchemaType = { type: "object", additionalProperties: false, properties: { - version: { type: "number", const: 0, description: "Config version" }, + version: { type: "integer", const: 0, description: "Config version" }, noxes: { type: "object", description: "Secret keys for noxes by name", diff --git a/src/lib/configs/project/service.ts b/src/lib/configs/project/service.ts index a8bc3ee57..ea4cd12fc 100644 --- a/src/lib/configs/project/service.ts +++ b/src/lib/configs/project/service.ts @@ -129,7 +129,7 @@ const configSchemaV0: JSONSchemaType = { required: [FACADE_MODULE_NAME], }, ...overridableServiceProperties.properties, - version: { type: "number", const: 0 }, + version: { type: "integer", const: 0 }, }, required: [ "version", diff --git a/src/lib/configs/project/spell.ts b/src/lib/configs/project/spell.ts index 2d7c66b19..f2d9d76aa 100644 --- a/src/lib/configs/project/spell.ts +++ b/src/lib/configs/project/spell.ts @@ -65,7 +65,7 @@ type ConfigV0 = { } & SpellProperties; const spellProperties = { - version: { type: "number", const: 0 }, + version: { type: "integer", const: 0 }, aquaFilePath: { type: "string", description: @@ -88,7 +88,7 @@ const spellProperties = { description: `Trigger the spell execution periodically. If you want to disable this property by overriding it in ${FLUENCE_CONFIG_FULL_FILE_NAME} - pass empty config for it like this: \`clock: {}\``, properties: { periodSec: { - type: "number", + type: "integer", description: "How often the spell will be executed. If set to 0, the spell will be executed only once. If this value not provided at all - the spell will never be executed", minimum: 0, @@ -108,7 +108,7 @@ const spellProperties = { nullable: true, }, startDelaySec: { - type: "number", + type: "integer", description: "How long to wait before the first execution in seconds. If this property or `startTimestamp` not specified, periodic execution will start immediately. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. This property conflicts with `startTimestamp`. You can specify only one of them", nullable: true, @@ -116,7 +116,7 @@ const spellProperties = { maximum: U32_MAX, }, endDelaySec: { - type: "number", + type: "integer", description: "How long to wait before the last execution in seconds. If this property or `endTimestamp` not specified, periodic execution will never end. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. If it is in the past at the moment of spell creation - the spell will never be executed. This property conflicts with `endTimestamp`. You can specify only one of them", nullable: true, diff --git a/src/lib/configs/project/workers.ts b/src/lib/configs/project/workers.ts index 0f381047b..aa2696703 100644 --- a/src/lib/configs/project/workers.ts +++ b/src/lib/configs/project/workers.ts @@ -162,7 +162,7 @@ const dealSchema: JSONSchemaType = { "Blockchain network name that was used when deploying workers", }, chainNetworkId: { - type: "number", + type: "integer", description: "Blockchain network id that was used when deploying workers", }, }, @@ -201,7 +201,7 @@ const configSchemaV0: JSONSchemaType = { type: "object", additionalProperties: false, properties: { - version: { type: "number", const: 0 }, + version: { type: "integer", const: 0 }, deals: mapOfDealsSchema, hosts: mapOfHostsSchema, }, @@ -225,7 +225,7 @@ const configSchemaV1: JSONSchemaType = { additionalProperties: false, required: ["version"], properties: { - version: { type: "number", const: 1, description: "Config version" }, + version: { type: "integer", const: 1, description: "Config version" }, deals: { type: "object", description: diff --git a/src/lib/configs/user/config.ts b/src/lib/configs/user/config.ts index 45fba20be..0d2ddc6eb 100644 --- a/src/lib/configs/user/config.ts +++ b/src/lib/configs/user/config.ts @@ -73,7 +73,7 @@ const configSchemaV0Obj = { "Whether to include commented-out documented config examples in the configs generated with the CLI", nullable: true, }, - version: { type: "number", const: 0 }, + version: { type: "integer", const: 0 }, }, required: ["version", "countlyConsent"], } as const; @@ -92,7 +92,7 @@ const configSchemaV1Obj = { description: `Defines global config for ${CLI_NAME_FULL}`, properties: { ...configSchemaV0Obj.properties, - version: { type: "number", const: 1 }, + version: { type: "integer", const: 1 }, defaultSecretKeyName: { type: "string", description: diff --git a/src/lib/configs/user/userSecrets.ts b/src/lib/configs/user/userSecrets.ts index 3c78fd017..621d1c0d2 100644 --- a/src/lib/configs/user/userSecrets.ts +++ b/src/lib/configs/user/userSecrets.ts @@ -57,7 +57,7 @@ const configSchemaV0: JSONSchemaType = { type: "array", items: configKeyPairSchema, }, - version: { type: "number", const: 0 }, + version: { type: "integer", const: 0 }, }, required: ["version", "keyPairs", "defaultKeyPairName"], }; diff --git a/src/lib/deal.ts b/src/lib/deal.ts index 3fac23522..f42aef6e8 100644 --- a/src/lib/deal.ts +++ b/src/lib/deal.ts @@ -20,6 +20,8 @@ import assert from "node:assert"; import { color } from "@oclif/color"; +import { versions } from "../versions.js"; + import { cidStringToCIDV1Struct } from "./chain/conversions.js"; import { ptFormatWithSymbol, ptParse } from "./chain/currencies.js"; import { commandObj } from "./commandObj.js"; @@ -52,6 +54,7 @@ type DealCreateArg = { initialBalance: string; whitelist: string[] | undefined; blacklist: string[] | undefined; + protocolVersion: number | undefined; workerName?: string; }; @@ -65,6 +68,7 @@ export async function dealCreate({ initialBalance, whitelist, blacklist, + protocolVersion, workerName, }: DealCreateArg) { const { dealClient } = await getDealClient(); @@ -118,6 +122,7 @@ export async function dealCreate({ : blacklist !== undefined ? blacklist : [], + protocolVersion ?? versions.protocolVersion, ); const dealId = getEventValue({ diff --git a/src/lib/deploy.ts b/src/lib/deploy.ts index a9c408dda..868ab372d 100644 --- a/src/lib/deploy.ts +++ b/src/lib/deploy.ts @@ -225,6 +225,7 @@ export async function deployImpl(this: Deploy, cl: typeof Deploy) { initialBalance, whitelist: deal.whitelist, blacklist: deal.blacklist, + protocolVersion: deal.protocolVersion, }); if (flags["auto-match"]) { diff --git a/src/lib/deployWorkers.ts b/src/lib/deployWorkers.ts index d156cafc2..22776cb14 100644 --- a/src/lib/deployWorkers.ts +++ b/src/lib/deployWorkers.ts @@ -23,6 +23,7 @@ import sum from "lodash-es/sum.js"; import xbytes from "xbytes"; import { yamlDiffPatch } from "yaml-diff-patch"; +import { importAquaCompiler } from "./aqua.js"; import { buildModules } from "./build.js"; import { commandObj, isInteractive } from "./commandObj.js"; import { compileAquaFromFluenceConfigWithDefaults } from "./compileAquaAndWatch.js"; @@ -766,7 +767,7 @@ export async function compileSpells( spellConfig.aquaFilePath, ); - const { compileFromPath } = await import("@fluencelabs/aqua-api"); + const { compileFromPath } = await importAquaCompiler(); // TODO: consider how to compile spells with aqua compilation args const { errors, functions } = await compileFromPath({ diff --git a/src/lib/generateUserProviderConfig.ts b/src/lib/generateUserProviderConfig.ts index 7f65a881e..4fca16f52 100644 --- a/src/lib/generateUserProviderConfig.ts +++ b/src/lib/generateUserProviderConfig.ts @@ -16,6 +16,11 @@ import { color } from "@oclif/color"; +import { + ccDurationValidator, + getMinCCDuration, + validateAddress, +} from "./chain/chainValidators.js"; import { isInteractive } from "./commandObj.js"; import type { UserProvidedConfig, Offer } from "./configs/project/provider.js"; import { @@ -27,11 +32,6 @@ import { DEFAULT_NUMBER_OF_COMPUTE_UNITS_ON_NOX, } from "./const.js"; import { commaSepStrToArr } from "./helpers/utils.js"; -import { - ccDurationValidator, - getMinCCDuration, - validateAddress, -} from "./helpers/validateCapacityCommitment.js"; import { validatePercent, validatePositiveNumberOrEmpty, diff --git a/src/lib/init.ts b/src/lib/init.ts index a28f4ffda..63cf52504 100644 --- a/src/lib/init.ts +++ b/src/lib/init.ts @@ -245,7 +245,7 @@ export async function init(options: InitArg = {}): Promise { async function quickstart() { const serviceName = "myService"; const absoluteServicePath = join(await ensureServicesDir(), serviceName); - const pathToModuleDir = join(absoluteServicePath, "modules", serviceName); + const pathToModuleDir = join(absoluteServicePath, serviceName); await generateNewModule(pathToModuleDir); await initNewReadonlyServiceConfig( diff --git a/src/lib/lifeCycle.ts b/src/lib/lifeCycle.ts index eec4ddd42..c6bd08a88 100644 --- a/src/lib/lifeCycle.ts +++ b/src/lib/lifeCycle.ts @@ -151,15 +151,6 @@ export async function initCli< await ensureUserConfig(); - const res = requiresFluenceProject - ? { fluenceConfig: await ensureFluenceProject() } - : { maybeFluenceConfig: await initFluenceConfig() }; - - const maybeFluenceConfig = res.fluenceConfig ?? res.maybeFluenceConfig; - - await initCountly({ maybeFluenceConfig }); - ensureCorrectCliVersion(maybeFluenceConfig?.cliVersion); - if (requiresFluenceProject) { setEnvConfig(await initNewEnvConfig()); } else { @@ -181,6 +172,13 @@ export async function initCli< [PRIV_KEY_FLAG_NAME]: flags[PRIV_KEY_FLAG_NAME], }); + const res = requiresFluenceProject + ? { fluenceConfig: await ensureFluenceProject() } + : { maybeFluenceConfig: await initFluenceConfig() }; + + const maybeFluenceConfig = res.fluenceConfig ?? res.maybeFluenceConfig; + await initCountly({ maybeFluenceConfig }); + ensureCorrectCliVersion(maybeFluenceConfig?.cliVersion); await updateRelaysJSON(); return { args, flags, ...res }; } diff --git a/src/versions.json b/src/versions.json index d3d833673..54d2b41c1 100644 --- a/src/versions.json +++ b/src/versions.json @@ -1,8 +1,9 @@ { - "nox": "fluencelabs/nox:0.21.2", - "chain-rpc": "fluencelabs/chain-rpc:0.7.0", - "chain-deploy-script": "fluencelabs/chain-deploy-script:0.7.0", - "subgraph-deploy-script": "fluencelabs/subgraph-deploy-script:0.7.0", + "protocolVersion": 1, + "nox": "fluencelabs/nox:0.21.3", + "chain-rpc": "fluencelabs/chain-rpc:0.7.1", + "chain-deploy-script": "fluencelabs/chain-deploy-script:0.7.1", + "subgraph-deploy-script": "fluencelabs/subgraph-deploy-script:0.7.1", "rust-toolchain": "nightly-2023-08-27-x86_64", "npm": { "@fluencelabs/aqua-lib": "0.9.1", diff --git a/src/versions.ts b/src/versions.ts index 8295d1653..1666461fb 100644 --- a/src/versions.ts +++ b/src/versions.ts @@ -23,7 +23,9 @@ import versionsJSON from "./versions.json" assert { type: "json" }; // eslint-disable-next-line @typescript-eslint/consistent-type-assertions export const versions = override(versionsJSON, "FCLI_V") as typeof versionsJSON; -interface RecToOverride extends Record {} +type AllowedValues = string | number | boolean; + +interface RecToOverride extends Record {} /** * Override versions using env variables @@ -32,11 +34,11 @@ interface RecToOverride extends Record {} * @returns Overridden record */ function override(rec: RecToOverride, prefix: string): RecToOverride { - return Object.fromEntries( + return Object.fromEntries( Object.entries(rec).map(([name, version]) => { const envVarName = `${prefix}_${snakeCase(name).toUpperCase()}`; - if (typeof version === "string") { + if (typeof version !== "object") { const versionFromEnv = process.env[envVarName]; const overriddenVersion = diff --git a/test/helpers/paths.ts b/test/helpers/paths.ts index 8c9b32653..367865d8d 100644 --- a/test/helpers/paths.ts +++ b/test/helpers/paths.ts @@ -43,7 +43,7 @@ export function getModuleDirPath( return join(getSrcPath(cwd), "modules", moduleName); } - return join(getServiceDirPath(cwd, serviceName), "modules", moduleName); + return join(getServiceDirPath(cwd, serviceName), moduleName); } export function getMainRsPath( diff --git a/yarn.lock b/yarn.lock index 0dc130705..421b2ed2a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -629,7 +629,7 @@ __metadata: "@fluencelabs/air-beautify-wasm": 0.3.6 "@fluencelabs/aqua-api": 0.14.2 "@fluencelabs/aqua-to-js": 0.3.5 - "@fluencelabs/deal-ts-clients": 0.7.0 + "@fluencelabs/deal-ts-clients": 0.7.1 "@fluencelabs/fluence-network-environment": 1.1.2 "@fluencelabs/js-client": 0.8.4 "@fluencelabs/npm-aqua-compiler": 0.0.3 @@ -704,9 +704,9 @@ __metadata: languageName: unknown linkType: soft -"@fluencelabs/deal-ts-clients@npm:0.7.0": - version: 0.7.0 - resolution: "@fluencelabs/deal-ts-clients@npm:0.7.0" +"@fluencelabs/deal-ts-clients@npm:0.7.1": + version: 0.7.1 + resolution: "@fluencelabs/deal-ts-clients@npm:0.7.1" dependencies: "@graphql-typed-document-node/core": ^3.2.0 debug: ^4.3.4 @@ -716,7 +716,7 @@ __metadata: graphql-request: ^6.1.0 graphql-scalars: ^1.22.4 graphql-tag: ^2.12.6 - checksum: 24bcf0c8a717f928f03526d0261d5ae6d99c5f7b4e72e3bcdf73ebd040a2dd7c8c9529b98489b2574dabdbbb591b1ad4836c2ff4a0ac464a97bd82d535b6453c + checksum: 0d63580929ae628519af1f2495660f7f2f62b9f4b9deccbb7d2bdd7043b49ffef3653d7764f20a3a4898608b5dbce57fed32e33992abecad544fbfa3076a2761 languageName: node linkType: hard