Skip to content

Commit 9eeeb0f

Browse files
author
Akim
authored
feat(fluence-network-environment): Introduce fluence-network-environment package (#442)
* Introduce fluence-network-environment package * Refactor types * Fix type * Remove BC * Update CLI * Remove fluence local up from CI * Add configs * Add type module * Update e2e file * Remove lock file * Revert "Add configs" This reverts commit ade4476. * Revert "Remove fluence local up from CI" This reverts commit 477a12d.
1 parent aea5efb commit 9eeeb0f

File tree

47 files changed

+199
-64
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+199
-64
lines changed

.fluence/schemas/env.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
"enum": [
1212
"dar",
1313
"stage",
14-
"kras",
1514
"local",
1615
"custom"
1716
],
1817
"nullable": true
1918
},
2019
"version": {
21-
"type": "number",
20+
"type": "integer",
2221
"const": 0
2322
}
2423
},

.github/release-please/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"packages/core/marine-worker": {},
1414
"packages/core/aqua-to-js": {},
1515
"packages/core/interfaces": {},
16-
"packages/core/npm-aqua-compiler": {}
16+
"packages/core/npm-aqua-compiler": {},
17+
"packages/core/fluence-network-environment": {}
1718
}
1819
}

.github/release-please/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"packages/core/aqua-to-js": "0.3.13",
55
"packages/core/js-client-isomorphic": "0.6.0",
66
"packages/core/interfaces": "0.12.0",
7-
"packages/core/npm-aqua-compiler": "0.0.3"
7+
"packages/core/npm-aqua-compiler": "0.0.3",
8+
"packages/core/fluence-network-environment": "1.1.2"
89
}

.github/workflows/e2e.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ jobs:
4343
uses: fluencelabs/aqua/.github/workflows/tests.yml@main
4444
with:
4545
js-client-snapshots: "${{ needs.js-client.outputs.js-client-snapshots }}"
46+
nox-image: "docker.fluence.dev/nox:feat-vm-425-aquavm-mem-limits-from-config-2_5056_1"
4647
flox:
4748
needs:
4849
- js-client
4950

5051
uses: fluencelabs/flox/.github/workflows/tests.yml@main
5152
with:
5253
js-client-snapshots: "${{ needs.js-client.outputs.js-client-snapshots }}"
54+
nox-image: "docker.fluence.dev/nox:feat-vm-425-aquavm-mem-limits-from-config-2_5056_1"

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
uses: ./.github/workflows/tests.yml
2929
with:
3030
ref: ${{ github.ref }}
31-
nox-image: "docker.fluence.dev/nox:renovate-avm_4905_1"
31+
nox-image: "docker.fluence.dev/nox:feat-vm-425-aquavm-mem-limits-from-config-2_5056_1"

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ jobs:
8181

8282
- name: Run nox network
8383
run: fluence local up
84+
env:
85+
FCLI_V_NOX: docker.fluence.dev/nox:feat-vm-425-aquavm-mem-limits-from-config-2_5056_1
8486

8587
- name: Setup pnpm
8688
uses: pnpm/action-setup@v2.2.4

packages/core/aqua-to-js/src/generate/service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { JSONValue, ServiceDef } from "@fluencelabs/interfaces";
17+
import { ServiceDef } from "@fluencelabs/interfaces";
1818

1919
import { recursiveRenameLaquaProps } from "../utils.js";
2020

@@ -63,6 +63,6 @@ function generateRegisterServiceOverload(
6363
}
6464

6565
function serviceToJson(service: ServiceDef): string {
66-
const record: Record<never, JSONValue> = service;
66+
const record: Record<never, unknown> = service;
6767
return JSON.stringify(recursiveRenameLaquaProps(record), null, 4);
6868
}

packages/core/aqua-to-js/src/utils.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { join } from "path";
2020
import {
2121
ArrowType,
2222
ArrowWithoutCallbacks,
23-
JSONValue,
2423
LabeledProductType,
2524
NilType,
2625
SimpleTypes,
@@ -67,7 +66,7 @@ export function getFuncArgs(
6766
}
6867
}
6968

70-
export function recursiveRenameLaquaProps(obj: JSONValue): unknown {
69+
export function recursiveRenameLaquaProps(obj: unknown): unknown {
7170
if (typeof obj !== "object" || obj === null) {
7271
return obj;
7372
}
@@ -78,7 +77,9 @@ export function recursiveRenameLaquaProps(obj: JSONValue): unknown {
7877
});
7978
}
8079

81-
return Object.getOwnPropertyNames(obj).reduce((acc, prop) => {
80+
const objType: Record<never, unknown> = obj;
81+
82+
return Object.getOwnPropertyNames(objType).reduce((acc, prop) => {
8283
let accessProp = prop;
8384

8485
if (prop.includes("Laqua_js")) {
@@ -89,12 +90,14 @@ export function recursiveRenameLaquaProps(obj: JSONValue): unknown {
8990
throw new Error(`Bad property name: ${prop}.`);
9091
}
9192

92-
if (refinedProperty in obj) {
93+
if (refinedProperty in objType) {
9394
accessProp = refinedProperty;
9495
}
9596
}
9697

97-
const laquaProp = obj[accessProp];
98+
const accessObj: Record<string, unknown> = objType;
99+
100+
const laquaProp = accessObj[accessProp];
98101

99102
if (laquaProp === undefined) {
100103
return acc;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Compiled binary addons (https://nodejs.org/api/addons.html)
10+
build/Release
11+
bundle/
12+
dist/
13+
14+
# Dependency directories
15+
node_modules/
16+
jspm_packages/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Changelog
2+
3+
## [1.1.2](https://github.com/fluencelabs/fluence-network-environment/compare/fluence-network-environment-v1.1.1...fluence-network-environment-v1.1.2) (2023-07-05)
4+
5+
6+
### Bug Fixes
7+
8+
* Update DNS records after kras migration to Nomad ([#11](https://github.com/fluencelabs/fluence-network-environment/issues/11)) ([446df4f](https://github.com/fluencelabs/fluence-network-environment/commit/446df4f5eaa64d8d5b803e23f73b8cf8e4331d2e))
9+
10+
## [1.1.1](https://github.com/fluencelabs/fluence-network-environment/compare/fluence-network-environment-v1.1.0...fluence-network-environment-v1.1.1) (2023-07-03)
11+
12+
13+
### Bug Fixes
14+
15+
* Actually build package ([#9](https://github.com/fluencelabs/fluence-network-environment/issues/9)) ([25ef57e](https://github.com/fluencelabs/fluence-network-environment/commit/25ef57e061d75abaa08d58a4fef89e71d9cfb4da))
16+
17+
## [1.1.0](https://github.com/fluencelabs/fluence-network-environment/compare/fluence-network-environment-v1.0.14...fluence-network-environment-v1.1.0) (2023-06-19)
18+
19+
20+
### Features
21+
22+
* Rename krasnodar to kras. Add functions to pick random nodes ([#4](https://github.com/fluencelabs/fluence-network-environment/issues/4)) ([a65217f](https://github.com/fluencelabs/fluence-network-environment/commit/a65217fd2e0d3c65f4ae54105b54018af778e92d))
23+
* Update stage multiaddr ([#7](https://github.com/fluencelabs/fluence-network-environment/issues/7)) ([3c0f1f8](https://github.com/fluencelabs/fluence-network-environment/commit/3c0f1f89a5f713e94ee0104bcf0fa9b66f8a5cca))
24+
25+
26+
### Bug Fixes
27+
28+
* Update testnet DNS records ([#8](https://github.com/fluencelabs/fluence-network-environment/issues/8)) ([2ed6209](https://github.com/fluencelabs/fluence-network-environment/commit/2ed6209c9c122fe2cd2b7811379c97163c64db88))
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Fluence network environment
2+
3+
[![npm](https://img.shields.io/npm/v/@fluencelabs/fluence-network-environment)](https://www.npmjs.com/package/@fluencelabs/fluence-network-environment)
4+
5+
Maintained list of well-known Fluence network nodes. The package is meant to be used in combination with [Fluence JS SDK](https://github.com/fluencelabs/fluence-js).
6+
7+
## Installation
8+
9+
With npm
10+
11+
```bash
12+
npm install @fluencelabs/fluence-network-environment
13+
```
14+
15+
With yarn
16+
17+
```bash
18+
yarn add @fluencelabs/fluence-network-environment
19+
```
20+
21+
## Usage
22+
23+
Pick a node to connect to the Fluence network.
24+
25+
```typescript
26+
import { testNet } from "@fluencelabs/fluence-network-environment";
27+
28+
export const relayNode = testNet[0];
29+
```
30+
31+
Which can be used to initialize the Fluence client (see [Fluence JS SDK](https://github.com/fluencelabs/fluence-js).)
32+
33+
```typescript
34+
import { FluencePeer } from "@fluencelabs/fluence";
35+
36+
const peer = new FluencePeer();
37+
await peer.start({ connectTo: relayNode });
38+
```
39+
40+
## Known networks
41+
42+
- stage - unstable network for development tests; low capacity
43+
- TestNet - more stable network, used for QA of new releases; higher capacity
44+
- Kras - stable network, has the highest load capacity
45+
46+
All 3 networks are connected, i.e. any node can be discovered from every other. They're open and permissionless, meaning that anyone can use any node for bootstrapping.
47+
48+
## Fluence Stack
49+
50+
| Layer | Tech | Scale | State | Based on |
51+
| :-------------------: | :-------------------------------------------------------------------------------------------------------------------------------: | :------------------------------: | :-------------------------------: | :-----------------------------------------------------------------------------------------------------------: |
52+
| Execution | [Marine](https://github.com/fluencelabs/marine) | Single peer | Disk, network, external processes | Wasm, [IT](https://github.com/fluencelabs/interface-types), [Wasmer\*](https://github.com/fluencelabs/wasmer) |
53+
| Composition | [Aqua](https://github.com/fluencelabs/aqua) | Involved peers | Results and signatures | ⇅, π-calculus |
54+
| Topology | [TrustGraph](https://github.com/fluencelabs/fluence/tree/master/trust-graph), [DHT\*](https://github.com/fluencelabs/rust-libp2p) | Distributed with Kademlia\* algo | Actual state of the network | [libp2p](https://github.com/libp2p/rust-libp2p) |
55+
| Security & Accounting | Blockchain | Whole network | Licenses & payments | substrate? |
56+
57+
<br/>
58+
59+
<p width="100%">
60+
<img alt="aquamarine scheme" align="center" src="doc/image.png"/>
61+
</p>
62+
63+
## License
64+
65+
[Apache 2.0](https://github.com/fluencelabs/fluence/blob/trustless_computing/LICENSE.md)
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"type": "module",
3+
"name": "@fluencelabs/fluence-network-environment",
4+
"version": "1.1.2",
5+
"description": "Fluence network environments addresses",
6+
"files": [
7+
"dist"
8+
],
9+
"main": "./dist/index.js",
10+
"typings": "./dist/index.d.ts",
11+
"scripts": {
12+
"build": "tsc"
13+
},
14+
"repository": "https://github.com/fluencelabs/fluence-network-environment",
15+
"author": "Fluence Labs",
16+
"license": "Apache-2.0"
17+
}

packages/core/js-client/src/network.ts renamed to packages/core/fluence-network-environment/src/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,23 +165,24 @@ export const kras: Relay[] = [
165165
},
166166
];
167167

168-
export const randomKras = (): Relay => {
168+
// for backward compatibility
169+
export const krasnodar = kras;
170+
171+
export const randomKras = () => {
169172
return randomItem(kras);
170173
};
171174

172-
export const randomTestNet = (): Relay => {
175+
export const randomTestNet = () => {
173176
return randomItem(testNet);
174177
};
175178

176-
export const randomStage = (): Relay => {
179+
export const randomStage = () => {
177180
return randomItem(stage);
178181
};
179182

180-
function randomItem(arr: Relay[]): Relay {
183+
function randomItem(arr: Relay[]) {
181184
const index = randomInt(0, arr.length);
182-
// This array access always defined
183-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
184-
return arr[index] as Relay;
185+
return arr[index];
185186
}
186187

187188
function randomInt(min: number, max: number) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist"
5+
},
6+
"include": ["src/**/*"],
7+
"exclude": ["node_modules", "dist"]
8+
}

packages/core/interfaces/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@
1515
*/
1616

1717
export * from "./compilerSupport/aquaTypeDefinitions.js";
18-
export * from "./commonTypes.js";
1918
export * from "./future.js";

packages/core/js-client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@fluencelabs/avm": "0.62.0",
3636
"@fluencelabs/interfaces": "workspace:*",
3737
"@fluencelabs/js-client-isomorphic": "workspace:*",
38+
"@fluencelabs/fluence-network-environment": "workspace:*",
3839
"@fluencelabs/marine-worker": "0.6.0",
3940
"@fluencelabs/threads": "^2.0.0",
4041
"@libp2p/crypto": "4.0.1",

packages/core/js-client/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import type {
1818
ArrowWithoutCallbacks,
1919
FunctionCallDef,
20-
JSONValue,
2120
ServiceDef,
2221
SimpleTypes,
2322
} from "@fluencelabs/interfaces";
@@ -32,6 +31,7 @@ import {
3231
} from "./compilerSupport/conversions.js";
3332
import { ServiceImpl, UserServiceImpl } from "./compilerSupport/types.js";
3433
import { FluencePeer } from "./jsPeer/FluencePeer.js";
34+
import type { JSONValue } from "./util/types.js";
3535
import { zip } from "./util/utils.js";
3636

3737
import { callAquaFunction, Fluence, registerService } from "./index.js";

packages/core/js-client/src/clientPeer/__test__/client.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { JSONValue } from "@fluencelabs/interfaces";
1817
import { it, describe, expect, assert } from "vitest";
1918

2019
import { ExpirationError } from "../../jsPeer/errors.js";
2120
import { CallServiceData } from "../../jsServiceHost/interfaces.js";
2221
import { handleTimeout } from "../../particle/Particle.js";
2322
import { registerHandlersHelper, withClient } from "../../util/testUtils.js";
23+
import type { JSONValue } from "../../util/types.js";
2424
import { checkConnection } from "../checkConnection.js";
2525

2626
import { nodes, RELAY } from "./connection.js";

packages/core/js-client/src/clientPeer/checkConnection.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { JSONValue } from "@fluencelabs/interfaces";
18-
1917
import { WrapFnIntoServiceCall } from "../jsServiceHost/serviceUtils.js";
2018
import { handleTimeout } from "../particle/Particle.js";
2119
import { logger } from "../util/logger.js";
20+
import type { JSONValue } from "../util/types.js";
2221

2322
import { ClientPeer } from "./ClientPeer.js";
2423

packages/core/js-client/src/clientPeer/types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616

1717
import { z } from "zod";
1818

19-
/**
20-
* Peer ID's id as a base58 string (multihash/CIDv0).
21-
*/
22-
export type PeerIdB58 = string;
23-
2419
const relaySchema = z.object({
2520
peerId: z.string(),
2621
multiaddr: z.string(),

packages/core/js-client/src/compilerSupport/__test__/conversion.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { JSONValue, NonArrowSimpleType } from "@fluencelabs/interfaces";
17+
import { NonArrowSimpleType } from "@fluencelabs/interfaces";
1818
import { it, describe, expect, test } from "vitest";
1919

20+
import type { JSONValue } from "../../util/types.js";
2021
import { aqua2js, js2aqua } from "../conversions.js";
2122

2223
const i32 = { tag: "scalar", name: "i32" } as const;

packages/core/js-client/src/compilerSupport/callFunction.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { JSONValue } from "@fluencelabs/interfaces";
18-
1917
import { FluencePeer } from "../jsPeer/FluencePeer.js";
2018
import { logger } from "../util/logger.js";
2119
import { ArgCallbackFunction } from "../util/testUtils.js";
20+
import type { JSONValue } from "../util/types.js";
2221

2322
import {
2423
errorHandlingService,

0 commit comments

Comments
 (0)