@streamr/node 101.1.2 → 102.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/entry-point.ts +2 -2
- package/bin/streamr-node.ts +0 -1
- package/configs/development-1.env.json +0 -3
- package/configs/development-2.env.json +0 -3
- package/configs/development-3.env.json +0 -3
- package/configs/development-prod-resend.env.json +0 -3
- package/configs/docker-1.env.json +0 -3
- package/configs/docker-2.env.json +0 -3
- package/configs/docker-3.env.json +0 -3
- package/dist/bin/entry-point.js +1 -1
- package/dist/bin/entry-point.js.map +1 -1
- package/dist/bin/streamr-node.js +0 -1
- package/dist/bin/streamr-node.js.map +1 -1
- package/dist/package.json +18 -23
- package/dist/src/broker.js +1 -1
- package/dist/src/broker.js.map +1 -1
- package/dist/src/config/ConfigWizard.js +22 -15
- package/dist/src/config/ConfigWizard.js.map +1 -1
- package/dist/src/config/config.js +19 -9
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/migration.js +0 -1
- package/dist/src/config/migration.js.map +1 -1
- package/dist/src/config/validateConfig.js +1 -0
- package/dist/src/config/validateConfig.js.map +1 -1
- package/dist/src/helpers/PayloadFormat.js +1 -0
- package/dist/src/helpers/PayloadFormat.js.map +1 -1
- package/dist/src/helpers/applyPluginClientConfigs.d.ts +1 -1
- package/dist/src/helpers/partitions.js +2 -2
- package/dist/src/helpers/partitions.js.map +1 -1
- package/dist/src/helpers/weightedSample.d.ts +3 -3
- package/dist/src/helpers/weightedSample.js +1 -2
- package/dist/src/helpers/weightedSample.js.map +1 -1
- package/dist/src/httpServer.d.ts +1 -3
- package/dist/src/plugins/http/publishEndpoint.js +3 -3
- package/dist/src/plugins/http/publishEndpoint.js.map +1 -1
- package/dist/src/plugins/mqtt/MqttPlugin.js +0 -1
- package/dist/src/plugins/mqtt/MqttPlugin.js.map +1 -1
- package/dist/src/plugins/mqtt/MqttServer.js +17 -7
- package/dist/src/plugins/mqtt/MqttServer.js.map +1 -1
- package/dist/src/plugins/operator/MaintainTopologyHelper.js +1 -1
- package/dist/src/plugins/operator/OperatorPlugin.d.ts +5 -0
- package/dist/src/plugins/operator/OperatorPlugin.js +11 -16
- package/dist/src/plugins/operator/OperatorPlugin.js.map +1 -1
- package/dist/src/plugins/operator/checkOperatorValueBreach.d.ts +2 -2
- package/dist/src/plugins/operator/checkOperatorValueBreach.js +9 -4
- package/dist/src/plugins/operator/checkOperatorValueBreach.js.map +1 -1
- package/dist/src/plugins/operator/config.schema.json +27 -1
- package/dist/src/plugins/operator/createIsLeaderFn.js +1 -2
- package/dist/src/plugins/operator/createIsLeaderFn.js.map +1 -1
- package/dist/src/plugins/operator/formCoordinationStreamId.js +1 -2
- package/dist/src/plugins/operator/formCoordinationStreamId.js.map +1 -1
- package/dist/src/plugins/operator/heartbeatUtils.d.ts +4 -1
- package/dist/src/plugins/operator/heartbeatUtils.js +8 -5
- package/dist/src/plugins/operator/heartbeatUtils.js.map +1 -1
- package/dist/src/plugins/operator/inspectOverTime.d.ts +2 -3
- package/dist/src/plugins/operator/inspectOverTime.js +13 -13
- package/dist/src/plugins/operator/inspectOverTime.js.map +1 -1
- package/dist/src/plugins/operator/inspectRandomNode.d.ts +1 -2
- package/dist/src/plugins/operator/inspectRandomNode.js +4 -5
- package/dist/src/plugins/operator/inspectRandomNode.js.map +1 -1
- package/dist/src/plugins/operator/inspectionUtils.d.ts +0 -1
- package/dist/src/plugins/operator/inspectionUtils.js +3 -4
- package/dist/src/plugins/operator/inspectionUtils.js.map +1 -1
- package/dist/src/plugins/operator/maintainOperatorValue.d.ts +2 -1
- package/dist/src/plugins/operator/maintainOperatorValue.js +4 -5
- package/dist/src/plugins/operator/maintainOperatorValue.js.map +1 -1
- package/dist/src/plugins/operator/reviewSuspectNode.d.ts +3 -4
- package/dist/src/plugins/operator/reviewSuspectNode.js +7 -7
- package/dist/src/plugins/operator/reviewSuspectNode.js.map +1 -1
- package/dist/src/plugins/storage/Batch.d.ts +2 -4
- package/dist/src/plugins/storage/Batch.js +1 -1
- package/dist/src/plugins/storage/Batch.js.map +1 -1
- package/dist/src/plugins/storage/BatchManager.d.ts +0 -1
- package/dist/src/plugins/storage/BatchManager.js +1 -1
- package/dist/src/plugins/storage/BatchManager.js.map +1 -1
- package/dist/src/plugins/storage/Bucket.js +2 -2
- package/dist/src/plugins/storage/Bucket.js.map +1 -1
- package/dist/src/plugins/storage/BucketManager.js +2 -5
- package/dist/src/plugins/storage/BucketManager.js.map +1 -1
- package/dist/src/plugins/storage/DeleteExpiredCmd.js +2 -2
- package/dist/src/plugins/storage/DeleteExpiredCmd.js.map +1 -1
- package/dist/src/plugins/storage/SetMembershipSynchronizer.js +1 -1
- package/dist/src/plugins/storage/Storage.d.ts +3 -6
- package/dist/src/plugins/storage/Storage.js +2 -5
- package/dist/src/plugins/storage/Storage.js.map +1 -1
- package/dist/src/plugins/storage/StorageConfig.js +8 -8
- package/dist/src/plugins/storage/StorageConfig.js.map +1 -1
- package/dist/src/plugins/storage/StorageEventListener.d.ts +1 -1
- package/dist/src/plugins/storage/StorageEventListener.js +3 -3
- package/dist/src/plugins/storage/StorageEventListener.js.map +1 -1
- package/dist/src/plugins/storage/StoragePlugin.js +1 -1
- package/dist/src/plugins/storage/StoragePlugin.js.map +1 -1
- package/dist/src/plugins/storage/StoragePoller.d.ts +1 -2
- package/dist/src/plugins/storage/StoragePoller.js +1 -1
- package/dist/src/plugins/storage/StoragePoller.js.map +1 -1
- package/dist/src/plugins/storage/dataQueryEndpoint.js +12 -5
- package/dist/src/plugins/storage/dataQueryEndpoint.js.map +1 -1
- package/jest.config.ts +9 -0
- package/package.json +18 -23
- package/bin/broker.ts +0 -11
- package/bin/config-wizard.js +0 -4
- package/bin/config-wizard.ts +0 -9
- package/dist/bin/broker.d.ts +0 -2
- package/dist/bin/broker.js +0 -12
- package/dist/bin/broker.js.map +0 -1
- package/dist/bin/config-wizard.d.ts +0 -2
- package/dist/bin/config-wizard.js +0 -10
- package/dist/bin/config-wizard.js.map +0 -1
- package/dist/src/helpers/fetchOrThrow.d.ts +0 -2
- package/dist/src/helpers/fetchOrThrow.js +0 -20
- package/dist/src/helpers/fetchOrThrow.js.map +0 -1
- package/dist/src/helpers/multiply.d.ts +0 -1
- package/dist/src/helpers/multiply.js +0 -10
- package/dist/src/helpers/multiply.js.map +0 -1
package/dist/src/httpServer.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { Server as HttpServer } from 'http';
|
|
4
2
|
import https, { Server as HttpsServer } from 'https';
|
|
5
3
|
import { Request, Response, NextFunction, RequestHandler } from 'express';
|
|
@@ -12,5 +10,5 @@ export interface Endpoint {
|
|
|
12
10
|
apiAuthentication?: ApiAuthentication;
|
|
13
11
|
}
|
|
14
12
|
export declare const createAuthenticatorMiddleware: (apiAuthentication?: ApiAuthentication) => (req: Request, res: Response, next: NextFunction) => void;
|
|
15
|
-
export declare const startServer: (endpoints: Endpoint[], config: StrictConfig[
|
|
13
|
+
export declare const startServer: (endpoints: Endpoint[], config: StrictConfig["httpServer"]) => Promise<HttpServer | https.Server>;
|
|
16
14
|
export declare const stopServer: (httpServer: HttpServer | HttpsServer) => Promise<void>;
|
|
@@ -21,7 +21,7 @@ const createHandler = (msgChainId, streamrClient) => {
|
|
|
21
21
|
content = PAYLOAD_FORMAT.createMessage(req.body.toString()).content;
|
|
22
22
|
timestamp = (0, parser_1.parseQueryParameter)('timestamp', req.query, parser_1.parseTimestamp);
|
|
23
23
|
partition = (0, parser_1.parseQueryParameter)('partition', req.query, parser_1.parsePositiveInteger);
|
|
24
|
-
partitionKey = req.query
|
|
24
|
+
partitionKey = req.query.partitionKey;
|
|
25
25
|
}
|
|
26
26
|
catch (e) {
|
|
27
27
|
res.status(400).send({
|
|
@@ -46,11 +46,11 @@ const createHandler = (msgChainId, streamrClient) => {
|
|
|
46
46
|
partitionKey,
|
|
47
47
|
msgChainId
|
|
48
48
|
});
|
|
49
|
-
|
|
49
|
+
res.sendStatus(200);
|
|
50
50
|
}
|
|
51
51
|
catch (err) {
|
|
52
52
|
logger.error('Unable to publish to message', { streamId, err });
|
|
53
|
-
|
|
53
|
+
res.sendStatus(500);
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publishEndpoint.js","sourceRoot":"","sources":["../../../../src/plugins/http/publishEndpoint.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAoE;AAEpE,0CAAuC;AACvC,+BAAiC;AACjC,iDAAgG;AAChG,+DAAgE;AAGhE,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AACjC,MAAM,cAAc,GAAG,IAAI,kCAAkB,EAAE,CAAA;AAE/C,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAE,aAA4B,EAAkB,EAAE;IACvF,OAAO,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,EAAE;QACzC,IAAI,OAAgC,CAAA;QACpC,IAAI,SAA6B,CAAA;QACjC,IAAI,SAA6B,CAAA;QACjC,IAAI,YAAgC,CAAA;QACpC,IAAI,CAAC;YACD,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAA;YACnE,SAAS,GAAG,IAAA,4BAAmB,EAAS,WAAW,EAAE,GAAG,CAAC,KAAK,EAAE,uBAAc,CAAC,CAAA;YAC/E,SAAS,GAAG,IAAA,4BAAmB,EAAS,WAAW,EAAE,GAAG,CAAC,KAAK,EAAE,6BAAoB,CAAC,CAAA;YACrF,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"publishEndpoint.js","sourceRoot":"","sources":["../../../../src/plugins/http/publishEndpoint.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAoE;AAEpE,0CAAuC;AACvC,+BAAiC;AACjC,i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efault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MqttServer.js","sourceRoot":"","sources":["../../../../src/plugins/mqtt/MqttServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MqttServer.js","sourceRoot":"","sources":["../../../../src/plugins/mqtt/MqttServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA0B;AAC1B,gDAAuB;AACvB,0CAAuC;AACvC,+DAAkF;AAClF,kDAAyB;AAEzB,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAQjC,MAAa,UAAU;IACX,MAAM,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ACP,GAAG,EAAE,UAAU,CAAC,eAAsB;YACtC,GAAG,EAAE,UAAU,CAAC,gBAAuB;YACvC,GAAG,EAAE,KAAK;YACV,MAAM,EAAE,KAAK;SAChB,CAAA;QACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,GAAW,EAAE,EAAE;YACvC,IAAI,GAAG,EAAE,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;YACpD,CAAC;QACL,CAAC,CAAC,CAAA;IACN,CAAC;IAEO,MAAM,CAAC,0BAA0B,CAAC,iBAAqC;QAC3E,OAAO,CACH,OAAqB,EACrB,SAAuC,EACvC,QAAsC,EACtC,IAA8E,EAChF,EAAE;YACA,IAAI,IAAA,yCAAqB,EAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,EAAE,CAAC;gBACjE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YACpB,CAAC;iBAAM,CAAC;gBACJ,MAAM,KAAK,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,EAAE,EAAE;oBAC9D,UAAU,EAAE,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC,CAAC,UAAU,CAAC,cAAc;iBACzG,CAAC,CAAA;gBACF,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;YACtB,CAAC;QACL,CAAC,CAAA;IACL,CAAC;;AAjFL,gCAkFC"}
|
|
@@ -55,7 +55,7 @@ class MaintainTopologyHelper extends eventemitter3_1.EventEmitter {
|
|
|
55
55
|
for await (const stake of queryResult) {
|
|
56
56
|
if (this.streamIdOfSponsorship.get(stake.sponsorship) !== stake.streamId) {
|
|
57
57
|
this.streamIdOfSponsorship.set(stake.sponsorship, stake.streamId);
|
|
58
|
-
const sponsorshipCount = (this.sponsorshipCountOfStream.get(stake.streamId)
|
|
58
|
+
const sponsorshipCount = (this.sponsorshipCountOfStream.get(stake.streamId) ?? 0) + 1;
|
|
59
59
|
this.sponsorshipCountOfStream.set(stake.streamId, sponsorshipCount);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -26,6 +26,11 @@ export interface OperatorPluginConfig {
|
|
|
26
26
|
};
|
|
27
27
|
inspectRandomNode: {
|
|
28
28
|
intervalInMs: number;
|
|
29
|
+
maxInspectionCount: number;
|
|
30
|
+
};
|
|
31
|
+
reviewSuspectNode: {
|
|
32
|
+
maxInspectionCount: number;
|
|
33
|
+
maxDelayBeforeFirstInspectionInMs: number;
|
|
29
34
|
};
|
|
30
35
|
closeExpiredFlags: {
|
|
31
36
|
intervalInMs: number;
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.OperatorPlugin = void 0;
|
|
7
|
-
const sdk_1 = require("@streamr/sdk");
|
|
8
7
|
const utils_1 = require("@streamr/utils");
|
|
9
8
|
const Plugin_1 = require("../../Plugin");
|
|
10
9
|
const MaintainTopologyHelper_1 = require("./MaintainTopologyHelper");
|
|
@@ -46,13 +45,9 @@ class OperatorPlugin extends Plugin_1.Plugin {
|
|
|
46
45
|
const maintainTopologyService = new MaintainTopologyService_1.MaintainTopologyService(streamrClient, streamPartAssignments);
|
|
47
46
|
await fleetState.start();
|
|
48
47
|
await maintainTopologyHelper.start();
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const operators = streamPartAssignments.getAssignedNodesForStreamPart(streamPartId);
|
|
53
|
-
return sdk_1.OperatorDiscoveryResponse.create({ operators: operators.map((operator) => (0, sdk_1.peerDescriptorTranslator)(operator)) });
|
|
54
|
-
};
|
|
55
|
-
await networkNode.registerExternalRpcMethod(sdk_1.OperatorDiscoveryRequest, sdk_1.OperatorDiscoveryResponse, 'discoverOperators', rpcServerFunction);
|
|
48
|
+
await streamrClient.getNode().registerOperator({
|
|
49
|
+
getAssignedNodesForStreamPart: (streamPartId) => streamPartAssignments.getAssignedNodesForStreamPart(streamPartId)
|
|
50
|
+
});
|
|
56
51
|
this.abortController.signal.addEventListener('abort', async () => {
|
|
57
52
|
await fleetState.destroy();
|
|
58
53
|
});
|
|
@@ -64,10 +59,6 @@ class OperatorPlugin extends Plugin_1.Plugin {
|
|
|
64
59
|
await (0, announceNodeToStream_1.announceNodeToStream)((0, utils_1.toEthereumAddress)(this.pluginConfig.operatorContractAddress), streamrClient);
|
|
65
60
|
})();
|
|
66
61
|
}, this.pluginConfig.heartbeatUpdateIntervalInMs, this.abortController.signal);
|
|
67
|
-
const stakedOperatorsCache = new utils_1.Cache(() => operator.getStakedOperators(), STAKED_OPERATORS_CACHE_MAX_AGE);
|
|
68
|
-
await (0, utils_1.scheduleAtInterval)(async () => (0, checkOperatorValueBreach_1.checkOperatorValueBreach)(operator, streamrClient, () => stakedOperatorsCache.get(), this.pluginConfig.maintainOperatorValue.minSponsorshipEarningsInWithdraw, this.pluginConfig.maintainOperatorValue.maxSponsorshipsInWithdraw).catch((err) => {
|
|
69
|
-
logger.warn('Encountered error', { err });
|
|
70
|
-
}), this.pluginConfig.checkOperatorValueBreachIntervalInMs, true, this.abortController.signal);
|
|
71
62
|
await fleetState.waitUntilReady();
|
|
72
63
|
const isLeader = await (0, createIsLeaderFn_1.createIsLeaderFn)(streamrClient, fleetState, logger);
|
|
73
64
|
try {
|
|
@@ -84,7 +75,7 @@ class OperatorPlugin extends Plugin_1.Plugin {
|
|
|
84
75
|
await (0, utils_1.scheduleAtInterval)(async () => {
|
|
85
76
|
if (isLeader()) {
|
|
86
77
|
try {
|
|
87
|
-
await (0, maintainOperatorValue_1.maintainOperatorValue)(this.pluginConfig.maintainOperatorValue.withdrawLimitSafetyFraction, this.pluginConfig.maintainOperatorValue.minSponsorshipEarningsInWithdraw, this.pluginConfig.maintainOperatorValue.maxSponsorshipsInWithdraw, operator);
|
|
78
|
+
await (0, maintainOperatorValue_1.maintainOperatorValue)(this.pluginConfig.maintainOperatorValue.withdrawLimitSafetyFraction, BigInt(this.pluginConfig.maintainOperatorValue.minSponsorshipEarningsInWithdraw), this.pluginConfig.maintainOperatorValue.maxSponsorshipsInWithdraw, operator);
|
|
88
79
|
}
|
|
89
80
|
catch (err) {
|
|
90
81
|
logger.error('Encountered error while checking earnings', { err });
|
|
@@ -93,7 +84,7 @@ class OperatorPlugin extends Plugin_1.Plugin {
|
|
|
93
84
|
}, this.pluginConfig.maintainOperatorValue.intervalInMs, true, this.abortController.signal);
|
|
94
85
|
await (0, utils_1.scheduleAtInterval)(async () => {
|
|
95
86
|
try {
|
|
96
|
-
await (0, inspectRandomNode_1.inspectRandomNode)(operatorContractAddress, operator, streamPartAssignments, streamrClient, this.pluginConfig.heartbeatTimeoutInMs, async (targetOperatorContractAddress) => {
|
|
87
|
+
await (0, inspectRandomNode_1.inspectRandomNode)(operatorContractAddress, operator, streamPartAssignments, streamrClient, this.pluginConfig.heartbeatTimeoutInMs, this.pluginConfig.inspectRandomNode.maxInspectionCount, async (targetOperatorContractAddress) => {
|
|
97
88
|
return streamrClient.getOperator(targetOperatorContractAddress).fetchRedundancyFactor();
|
|
98
89
|
}, createOperatorFleetState, this.abortController.signal);
|
|
99
90
|
}
|
|
@@ -109,6 +100,10 @@ class OperatorPlugin extends Plugin_1.Plugin {
|
|
|
109
100
|
logger.error('Encountered error while closing expired flags', { err });
|
|
110
101
|
}
|
|
111
102
|
}, this.pluginConfig.closeExpiredFlags.intervalInMs, false, this.abortController.signal);
|
|
103
|
+
const stakedOperatorsCache = new utils_1.Cache(() => operator.getStakedOperators(), STAKED_OPERATORS_CACHE_MAX_AGE);
|
|
104
|
+
await (0, utils_1.scheduleAtInterval)(async () => (0, checkOperatorValueBreach_1.checkOperatorValueBreach)(operator, streamrClient, () => stakedOperatorsCache.get(), BigInt(this.pluginConfig.maintainOperatorValue.minSponsorshipEarningsInWithdraw), this.pluginConfig.maintainOperatorValue.maxSponsorshipsInWithdraw).catch((err) => {
|
|
105
|
+
logger.warn('Encountered error', { err });
|
|
106
|
+
}), this.pluginConfig.checkOperatorValueBreachIntervalInMs, false, this.abortController.signal);
|
|
112
107
|
(0, utils_1.addManagedEventListener)(operator, 'reviewRequested', (event) => {
|
|
113
108
|
setImmediate(async () => {
|
|
114
109
|
try {
|
|
@@ -123,14 +118,14 @@ class OperatorPlugin extends Plugin_1.Plugin {
|
|
|
123
118
|
getRedundancyFactor: async (targetOperatorContractAddress) => {
|
|
124
119
|
return streamrClient.getOperator(targetOperatorContractAddress).fetchRedundancyFactor();
|
|
125
120
|
},
|
|
126
|
-
|
|
121
|
+
maxDelayBeforeFirstInspectionInMs: this.pluginConfig.reviewSuspectNode.maxDelayBeforeFirstInspectionInMs,
|
|
127
122
|
heartbeatTimeoutInMs: this.pluginConfig.heartbeatTimeoutInMs,
|
|
128
123
|
votingPeriod: {
|
|
129
124
|
startTime: event.votingPeriodStartTimestamp,
|
|
130
125
|
endTime: event.votingPeriodEndTimestamp
|
|
131
126
|
},
|
|
132
127
|
inspectionIntervalInMs: 8 * 60 * 1000,
|
|
133
|
-
|
|
128
|
+
maxInspectionCount: this.pluginConfig.reviewSuspectNode.maxInspectionCount,
|
|
134
129
|
abortSignal: this.abortController.signal
|
|
135
130
|
});
|
|
136
131
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperatorPlugin.js","sourceRoot":"","sources":["../../../../src/plugins/operator/OperatorPlugin.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"OperatorPlugin.js","sourceRoot":"","sources":["../../../../src/plugins/operator/OperatorPlugin.ts"],"names":[],"mappings":";;;;;;AAKA,0CASuB;AAGvB,yCAAqC;AACrC,qEAAiE;AACjE,uEAAmE;AACnE,6DAAyD;AACzD,mEAA+D;AAC/D,qEAAiE;AACjE,iEAA6D;AAC7D,yEAAqE;AACrE,2DAA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AE,KAAK,CAAC,0BAA0B;oCAC3C,OAAO,EAAE,KAAK,CAAC,wBAAwB;iCAC1C;gCACD,sBAAsB,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;gCACrC,kBAAkB,EAAE,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,kBAAkB;gCAC1E,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM;6BAC3C,CAAC,CAAA;wBACN,CAAC;oBACL,CAAC;oBAAC,OAAO,GAAG,EAAE,CAAC;wBACX,MAAM,CAAC,KAAK,CAAC,mDAAmD,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;oBAC9E,CAAC;gBACL,CAAC,CAAC,CAAA;YACN,CAAC,EACD,IAAI,CAAC,eAAe,CAAC,MAAM,CAC9B,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;IAED,KAAK,CAAC,IAAI;QACN,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;IAChC,CAAC;IAED,kDAAkD;IACzC,eAAe;QACpB,OAAO,4BAAoB,CAAA;IAC/B,CAAC;IAED,kDAAkD;IACzC,eAAe;QACpB,OAAO,CAAC;gBACJ,IAAI,EAAE,qCAAqC,EAAE,KAAK,EAAE,IAAI;aAC3D,CAAC,CAAA;IACN,CAAC;CACJ;AAzMD,wCAyMC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StreamrClient, Operator } from '@streamr/sdk';
|
|
2
|
-
import { EthereumAddress } from '@streamr/utils';
|
|
3
|
-
export declare const checkOperatorValueBreach: (myOperator: Operator, client: StreamrClient, getStakedOperators: () => Promise<EthereumAddress[]>, minSponsorshipEarningsInWithdraw:
|
|
2
|
+
import { EthereumAddress, WeiAmount } from '@streamr/utils';
|
|
3
|
+
export declare const checkOperatorValueBreach: (myOperator: Operator, client: StreamrClient, getStakedOperators: () => Promise<EthereumAddress[]>, minSponsorshipEarningsInWithdraw: WeiAmount, maxSponsorshipsInWithdraw: number) => Promise<void>;
|
|
@@ -11,10 +11,15 @@ const checkOperatorValueBreach = async (myOperator, client, getStakedOperators,
|
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
logger.info('Check other operator\'s earnings for breach', { targetOperatorAddress });
|
|
14
|
-
const {
|
|
15
|
-
logger.trace(` -> is ${
|
|
16
|
-
if (
|
|
17
|
-
logger.info('Withdraw earnings from sponsorships (target operator value in breach)', {
|
|
14
|
+
const { sum, maxAllowedEarnings, sponsorshipAddresses } = await client.getOperator(targetOperatorAddress).getEarnings(minSponsorshipEarningsInWithdraw, maxSponsorshipsInWithdraw);
|
|
15
|
+
logger.trace(` -> is ${sum} > ${maxAllowedEarnings}?`);
|
|
16
|
+
if (sum > maxAllowedEarnings) {
|
|
17
|
+
logger.info('Withdraw earnings from sponsorships (target operator value in breach)', {
|
|
18
|
+
targetOperatorAddress,
|
|
19
|
+
sponsorshipAddresses,
|
|
20
|
+
sum: sum.toString(),
|
|
21
|
+
maxAllowedEarnings: maxAllowedEarnings.toString()
|
|
22
|
+
});
|
|
18
23
|
await myOperator.triggerAnotherOperatorWithdraw(targetOperatorAddress, sponsorshipAddresses);
|
|
19
24
|
}
|
|
20
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkOperatorValueBreach.js","sourceRoot":"","sources":["../../../../src/plugins/operator/checkOperatorValueBreach.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"checkOperatorValueBreach.js","sourceRoot":"","sources":["../../../../src/plugins/operator/checkOperatorValueBreach.ts"],"names":[],"mappings":";;;AACA,0CAAmE;AACnE,mCAAwC;AAExC,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAE1B,MAAM,wBAAwB,GAAG,KAAK,EACzC,UAAoB,EACpB,MAAqB,EACrB,kBAAoD,EACpD,gCAA2C,EAC3C,yBAAiC,EACpB,EAAE;IACf,MAAM,qBAAqB,GAAG,IAAA,eAAM,EAAC,IAAA,gBAAO,EAAC,MAAM,kBAAkB,EAAE,EAAE,MAAM,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAA;IAChH,IAAI,qBAAqB,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;QACjC,OAAM;IACV,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,6CAA6C,EAAE,EAAE,qBAAqB,EAAE,CAAC,CAAA;IACrF,MAAM,EAAE,GAAG,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,WAAW,CACjH,gCAAgC,EAChC,yBAAyB,CAC5B,CAAA;IACD,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,kBAAkB,GAAG,CAAC,CAAA;IACtD,IAAI,GAAG,GAAG,kBAAkB,EAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC,uEAAuE,EAC/E;YACI,qBAAqB;YACrB,oBAAoB;YACpB,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;YACnB,kBAAkB,EAAE,kBAAkB,CAAC,QAAQ,EAAE;SACpD,CAAC,CAAA;QACN,MAAM,UAAU,CAAC,8BAA8B,CAAC,qBAAqB,EAAE,oBAAoB,CAAC,CAAA;IAChG,CAAC;AACL,CAAC,CAAA;AA5BY,QAAA,wBAAwB,4BA4BpC"}
|
|
@@ -125,6 +125,32 @@
|
|
|
125
125
|
"description": "How often to run (in milliseconds)",
|
|
126
126
|
"minimum": 0,
|
|
127
127
|
"default": 900000
|
|
128
|
+
},
|
|
129
|
+
"maxInspectionCount": {
|
|
130
|
+
"type": "integer",
|
|
131
|
+
"description": "How many rounds of analysis are performed at most",
|
|
132
|
+
"minimum": 1,
|
|
133
|
+
"default": 10
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"reviewSuspectNode": {
|
|
138
|
+
"type": "object",
|
|
139
|
+
"description": "Review suspect node settings",
|
|
140
|
+
"additionalProperties": false,
|
|
141
|
+
"default": {},
|
|
142
|
+
"properties": {
|
|
143
|
+
"maxInspectionCount": {
|
|
144
|
+
"type": "integer",
|
|
145
|
+
"description": "How many rounds of analysis are performed at most",
|
|
146
|
+
"minimum": 1,
|
|
147
|
+
"default": 10
|
|
148
|
+
},
|
|
149
|
+
"maxDelayBeforeFirstInspectionInMs": {
|
|
150
|
+
"type": "integer",
|
|
151
|
+
"description": "The maximum time (in milliseconds) to wait before the 1st inspection round",
|
|
152
|
+
"minimum": 0,
|
|
153
|
+
"default": 300000
|
|
128
154
|
}
|
|
129
155
|
}
|
|
130
156
|
},
|
|
@@ -142,7 +168,7 @@
|
|
|
142
168
|
},
|
|
143
169
|
"maxAgeInMs": {
|
|
144
170
|
"type": "integer",
|
|
145
|
-
"description": "
|
|
171
|
+
"description": "After the voting ends, how soon (in milliseconds) does the flag expire",
|
|
146
172
|
"minimum": 0,
|
|
147
173
|
"default": 86400000
|
|
148
174
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createIsLeaderFn =
|
|
3
|
+
exports.createIsLeaderFn = createIsLeaderFn;
|
|
4
4
|
async function createIsLeaderFn(streamrClient, operatorFleetState, logger) {
|
|
5
5
|
const myNodeId = await streamrClient.getNodeId();
|
|
6
6
|
return () => {
|
|
@@ -10,5 +10,4 @@ async function createIsLeaderFn(streamrClient, operatorFleetState, logger) {
|
|
|
10
10
|
return isLeader;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
exports.createIsLeaderFn = createIsLeaderFn;
|
|
14
13
|
//# sourceMappingURL=createIsLeaderFn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createIsLeaderFn.js","sourceRoot":"","sources":["../../../../src/plugins/operator/createIsLeaderFn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createIsLeaderFn.js","sourceRoot":"","sources":["../../../../src/plugins/operator/createIsLeaderFn.ts"],"names":[],"mappings":";;AAIA,4CAYC;AAZM,KAAK,UAAU,gBAAgB,CAClC,aAA4B,EAC5B,kBAAsC,EACtC,MAAe;IAEf,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,SAAS,EAAE,CAAA;IAChD,OAAO,GAAG,EAAE;QACR,MAAM,YAAY,GAAG,kBAAkB,CAAC,eAAe,EAAE,CAAA;QACzD,MAAM,QAAQ,GAAG,QAAQ,KAAK,YAAY,CAAA;QAC1C,MAAM,EAAE,KAAK,CAAC,sBAAsB,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC3E,OAAO,QAAQ,CAAA;IACnB,CAAC,CAAA;AACL,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formCoordinationStreamId =
|
|
3
|
+
exports.formCoordinationStreamId = formCoordinationStreamId;
|
|
4
4
|
const utils_1 = require("@streamr/utils");
|
|
5
5
|
function formCoordinationStreamId(operatorContractAddress) {
|
|
6
6
|
return (0, utils_1.toStreamID)('/operator/coordination', operatorContractAddress);
|
|
7
7
|
}
|
|
8
|
-
exports.formCoordinationStreamId = formCoordinationStreamId;
|
|
9
8
|
//# sourceMappingURL=formCoordinationStreamId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formCoordinationStreamId.js","sourceRoot":"","sources":["../../../../src/plugins/operator/formCoordinationStreamId.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formCoordinationStreamId.js","sourceRoot":"","sources":["../../../../src/plugins/operator/formCoordinationStreamId.ts"],"names":[],"mappings":";;AAEA,4DAEC;AAJD,0CAAsE;AAEtE,SAAgB,wBAAwB,CAAC,uBAAwC;IAC7E,OAAO,IAAA,kBAAU,EAAC,wBAAwB,EAAE,uBAAuB,CAAC,CAAA;AACxE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { NetworkNodeType, NetworkPeerDescriptor } from '@streamr/sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
export declare const HeartbeatMessageSchema: z.ZodObject<{
|
|
4
4
|
msgType: z.ZodEnum<["heartbeat"]>;
|
|
5
5
|
peerDescriptor: z.ZodObject<{
|
|
@@ -38,6 +38,7 @@ export declare const HeartbeatMessageSchema: z.ZodObject<{
|
|
|
38
38
|
} | undefined;
|
|
39
39
|
region?: number | undefined;
|
|
40
40
|
}>;
|
|
41
|
+
applicationVersion: z.ZodOptional<z.ZodString>;
|
|
41
42
|
}, "strip", z.ZodTypeAny, {
|
|
42
43
|
msgType: "heartbeat";
|
|
43
44
|
peerDescriptor: {
|
|
@@ -50,6 +51,7 @@ export declare const HeartbeatMessageSchema: z.ZodObject<{
|
|
|
50
51
|
} | undefined;
|
|
51
52
|
region?: number | undefined;
|
|
52
53
|
};
|
|
54
|
+
applicationVersion?: string | undefined;
|
|
53
55
|
}, {
|
|
54
56
|
msgType: "heartbeat";
|
|
55
57
|
peerDescriptor: {
|
|
@@ -62,6 +64,7 @@ export declare const HeartbeatMessageSchema: z.ZodObject<{
|
|
|
62
64
|
} | undefined;
|
|
63
65
|
region?: number | undefined;
|
|
64
66
|
};
|
|
67
|
+
applicationVersion?: string | undefined;
|
|
65
68
|
}>;
|
|
66
69
|
export type HeartbeatMessage = z.infer<typeof HeartbeatMessageSchema>;
|
|
67
70
|
export declare function createHeartbeatMessage(peerDescriptor: NetworkPeerDescriptor): HeartbeatMessage;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.HeartbeatMessageSchema = void 0;
|
|
4
|
+
exports.createHeartbeatMessage = createHeartbeatMessage;
|
|
5
5
|
const sdk_1 = require("@streamr/sdk");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const package_json_1 = require("../../../package.json");
|
|
6
8
|
exports.HeartbeatMessageSchema = zod_1.z.object({
|
|
7
9
|
msgType: zod_1.z.enum(['heartbeat']),
|
|
8
10
|
peerDescriptor: zod_1.z.object({
|
|
@@ -14,13 +16,14 @@ exports.HeartbeatMessageSchema = zod_1.z.object({
|
|
|
14
16
|
tls: zod_1.z.boolean()
|
|
15
17
|
})),
|
|
16
18
|
region: zod_1.z.optional(zod_1.z.number())
|
|
17
|
-
})
|
|
19
|
+
}),
|
|
20
|
+
applicationVersion: zod_1.z.optional(zod_1.z.string()) // optional for backward compatibility (written from v102 onward)
|
|
18
21
|
});
|
|
19
22
|
function createHeartbeatMessage(peerDescriptor) {
|
|
20
23
|
return {
|
|
21
24
|
msgType: 'heartbeat',
|
|
22
|
-
peerDescriptor
|
|
25
|
+
peerDescriptor,
|
|
26
|
+
applicationVersion: package_json_1.version
|
|
23
27
|
};
|
|
24
28
|
}
|
|
25
|
-
exports.createHeartbeatMessage = createHeartbeatMessage;
|
|
26
29
|
//# sourceMappingURL=heartbeatUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heartbeatUtils.js","sourceRoot":"","sources":["../../../../src/plugins/operator/heartbeatUtils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"heartbeatUtils.js","sourceRoot":"","sources":["../../../../src/plugins/operator/heartbeatUtils.ts"],"names":[],"mappings":";;;AAqBA,wDAMC;AA3BD,sCAAqE;AACrE,6BAAuB;AACvB,wDAAqE;AAExD,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC;IAC9B,cAAc,EAAE,OAAC,CAAC,MAAM,CAAC;QACrB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;QAClB,IAAI,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,UAAU,CAAC,qBAAe,CAAC,CAAC;QAC/C,SAAS,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,CAAC;YAC3B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,GAAG,EAAE,OAAC,CAAC,OAAO,EAAE;SACnB,CAAC,CAAC;QACH,MAAM,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;KACjC,CAAC;IACF,kBAAkB,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAE,iEAAiE;CAChH,CAAC,CAAA;AAIF,SAAgB,sBAAsB,CAAC,cAAqC;IACxE,OAAO;QACH,OAAO,EAAE,WAAW;QACpB,cAAc;QACd,kBAAkB,EAAlB,sBAAkB;KACrB,CAAA;AACL,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { EthereumAddress } from '@streamr/utils';
|
|
3
2
|
import { StreamrClient } from '@streamr/sdk';
|
|
4
3
|
import { CreateOperatorFleetStateFn } from './OperatorFleetState';
|
|
@@ -8,10 +7,10 @@ interface InspectOverTimeOpts {
|
|
|
8
7
|
streamrClient: StreamrClient;
|
|
9
8
|
createOperatorFleetState: CreateOperatorFleetStateFn;
|
|
10
9
|
getRedundancyFactor: (operatorContractAddress: EthereumAddress) => Promise<number | undefined>;
|
|
11
|
-
|
|
10
|
+
delayBeforeFirstInspectionInMs: number;
|
|
12
11
|
heartbeatTimeoutInMs: number;
|
|
13
12
|
inspectionIntervalInMs: number;
|
|
14
|
-
|
|
13
|
+
maxInspectionCount: number;
|
|
15
14
|
waitUntilPassOrDone: boolean;
|
|
16
15
|
abortSignal: AbortSignal;
|
|
17
16
|
traceId: string;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.inspectOverTime =
|
|
6
|
+
exports.inspectOverTime = inspectOverTime;
|
|
7
7
|
const utils_1 = require("@streamr/utils");
|
|
8
8
|
const inspectionUtils_1 = require("./inspectionUtils");
|
|
9
9
|
const formCoordinationStreamId_1 = require("./formCoordinationStreamId");
|
|
@@ -19,16 +19,15 @@ function inspectOverTime(opts) {
|
|
|
19
19
|
return task.calculateResult();
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
exports.inspectOverTime = inspectOverTime;
|
|
23
22
|
class InspectionOverTimeTask {
|
|
24
23
|
target;
|
|
25
24
|
streamrClient;
|
|
26
25
|
createOperatorFleetState;
|
|
27
26
|
getRedundancyFactor;
|
|
28
|
-
|
|
27
|
+
delayBeforeFirstInspectionInMs;
|
|
29
28
|
heartbeatTimeoutInMs;
|
|
30
29
|
inspectionIntervalInMs;
|
|
31
|
-
|
|
30
|
+
maxInspectionCount;
|
|
32
31
|
abortSignal;
|
|
33
32
|
findNodesForTargetGivenFleetStateFn;
|
|
34
33
|
inspectTargetFn;
|
|
@@ -38,15 +37,15 @@ class InspectionOverTimeTask {
|
|
|
38
37
|
abortController = new AbortController();
|
|
39
38
|
passedSingleInspectionGate = new utils_1.Gate(false);
|
|
40
39
|
doneGate = new utils_1.Gate(false);
|
|
41
|
-
constructor({ target, streamrClient, createOperatorFleetState, getRedundancyFactor,
|
|
40
|
+
constructor({ target, streamrClient, createOperatorFleetState, getRedundancyFactor, delayBeforeFirstInspectionInMs, heartbeatTimeoutInMs, inspectionIntervalInMs, maxInspectionCount, abortSignal: userAbortSignal, traceId, findNodesForTargetGivenFleetStateFn = inspectionUtils_1.findNodesForTargetGivenFleetState, inspectTargetFn = inspectionUtils_1.inspectTarget, }) {
|
|
42
41
|
this.target = target;
|
|
43
42
|
this.streamrClient = streamrClient;
|
|
44
43
|
this.createOperatorFleetState = createOperatorFleetState;
|
|
45
44
|
this.getRedundancyFactor = getRedundancyFactor;
|
|
46
|
-
this.
|
|
45
|
+
this.delayBeforeFirstInspectionInMs = delayBeforeFirstInspectionInMs;
|
|
47
46
|
this.heartbeatTimeoutInMs = heartbeatTimeoutInMs;
|
|
48
47
|
this.inspectionIntervalInMs = inspectionIntervalInMs;
|
|
49
|
-
this.
|
|
48
|
+
this.maxInspectionCount = maxInspectionCount;
|
|
50
49
|
this.abortSignal = (0, utils_1.composeAbortSignals)(userAbortSignal, this.abortController.signal);
|
|
51
50
|
this.findNodesForTargetGivenFleetStateFn = findNodesForTargetGivenFleetStateFn;
|
|
52
51
|
this.inspectTargetFn = inspectTargetFn;
|
|
@@ -79,18 +78,19 @@ class InspectionOverTimeTask {
|
|
|
79
78
|
}
|
|
80
79
|
destroy() {
|
|
81
80
|
this.abortController.abort();
|
|
81
|
+
this.doneGate.open();
|
|
82
82
|
}
|
|
83
83
|
async run() {
|
|
84
84
|
this.logger.info('Start', {
|
|
85
85
|
target: this.target,
|
|
86
86
|
heartbeatTimeoutInMs: this.heartbeatTimeoutInMs,
|
|
87
87
|
inspectionIntervalInMs: this.inspectionIntervalInMs,
|
|
88
|
-
|
|
88
|
+
maxInspectionCount: this.maxInspectionCount
|
|
89
89
|
});
|
|
90
90
|
await this.initializeNewOperatorFleetState();
|
|
91
|
-
this.logger.
|
|
92
|
-
await (0, utils_1.wait)(this.
|
|
93
|
-
for (const attemptNo of (0, range_1.default)(1, this.
|
|
91
|
+
this.logger.debug('Sleep', { timeInMs: this.delayBeforeFirstInspectionInMs });
|
|
92
|
+
await (0, utils_1.wait)(this.delayBeforeFirstInspectionInMs, this.abortSignal);
|
|
93
|
+
for (const attemptNo of (0, range_1.default)(1, this.maxInspectionCount + 1)) {
|
|
94
94
|
const startTime = Date.now();
|
|
95
95
|
this.logger.info('Inspecting target', { attemptNo, target: this.target });
|
|
96
96
|
const onlineNodeDescriptors = await this.findNodesForTargetGivenFleetStateFn(this.target, this.fleetState, this.getRedundancyFactor, this.logger);
|
|
@@ -113,7 +113,7 @@ class InspectionOverTimeTask {
|
|
|
113
113
|
timeElapsedInMs,
|
|
114
114
|
target: this.target
|
|
115
115
|
});
|
|
116
|
-
if (attemptNo !== this.
|
|
116
|
+
if (attemptNo !== this.maxInspectionCount) {
|
|
117
117
|
// TODO: remove when NET-1169 landed;
|
|
118
118
|
// workaround subscribe bug in @streamr/sdk (sometimes messages don't come thru to heartbeat stream)
|
|
119
119
|
if (this.fleetState?.getNodeIds().length === 0) {
|
|
@@ -126,7 +126,7 @@ class InspectionOverTimeTask {
|
|
|
126
126
|
this.abortSignal.throwIfAborted();
|
|
127
127
|
}
|
|
128
128
|
const sleepTime = Math.max(this.inspectionIntervalInMs - timeElapsedInMs, 0);
|
|
129
|
-
this.logger.
|
|
129
|
+
this.logger.debug('Sleep', { timeInMs: sleepTime });
|
|
130
130
|
await (0, utils_1.wait)(sleepTime, this.abortSignal);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspectOverTime.js","sourceRoot":"","sources":["../../../../src/plugins/operator/inspectOverTime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inspectOverTime.js","sourceRoot":"","sources":["../../../../src/plugins/operator/inspectOverTime.ts"],"names":[],"mappings":";;;;;AA6BA,0CAUC;AAvCD,0CAAqG;AAGrG,uDAM0B;AAC1B,yEAAqE;AACrE,yDAAgC;AAkBhC,SAAgB,eAAe,CAAC,IAAyB;IACrD,MAAM,IAAI,GAAG,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAA;IAC7C,IAAI,CAAC,KAAK,EAAE,CAAA;IACZ,OAAO,KAAK,IAAI,EAAE;QACd,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC3B,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAA;QACpC,CAAC;Q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K,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAA;gBACnD,MAAM,IAAA,YAAI,EAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;YAC3C,CAAC;QACL,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;IAEO,KAAK,CAAC,+BAA+B;QACzC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,wBAAwB,CAAC,IAAA,mDAAwB,EAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAA;QACtG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAA;QAC7B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAA;QAC3C,MAAM,OAAO,CAAC,IAAI,CAAC;YACf,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE;YAChC,IAAA,YAAI,EAAC,IAAI,CAAC,oBAAoB,EAAE,IAAI,CAAC,WAAW,CAAC;SACpD,CAAC,CAAA;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;IAC3G,CAAC;CACJ"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Operator, StreamrClient } from '@streamr/sdk';
|
|
3
2
|
import { EthereumAddress } from '@streamr/utils';
|
|
4
3
|
import { CreateOperatorFleetStateFn } from './OperatorFleetState';
|
|
5
4
|
import { StreamPartAssignments } from './StreamPartAssignments';
|
|
6
5
|
import { findTarget } from './inspectionUtils';
|
|
7
|
-
export declare function inspectRandomNode(operatorContractAddress: EthereumAddress, myOperator: Operator, assignments: StreamPartAssignments, streamrClient: StreamrClient, heartbeatTimeoutInMs: number, getRedundancyFactor: (operatorContractAddress: EthereumAddress) => Promise<number | undefined>, createOperatorFleetState: CreateOperatorFleetStateFn, abortSignal: AbortSignal, findTargetFn?: typeof findTarget): Promise<void>;
|
|
6
|
+
export declare function inspectRandomNode(operatorContractAddress: EthereumAddress, myOperator: Operator, assignments: StreamPartAssignments, streamrClient: StreamrClient, heartbeatTimeoutInMs: number, maxInspectionCount: number, getRedundancyFactor: (operatorContractAddress: EthereumAddress) => Promise<number | undefined>, createOperatorFleetState: CreateOperatorFleetStateFn, abortSignal: AbortSignal, findTargetFn?: typeof findTarget): Promise<void>;
|