Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OriginTrail Testnet Release v6.0.17 #2748

Merged
merged 11 commits into from
Nov 3, 2023
Merged
72 changes: 52 additions & 20 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,25 @@
}
}
}
},
"telemetry": {
"enabled": true,
"implementation": {
"ot-telemetry": {
"enabled": true,
"package": "./telemetry/implementation/ot-telemetry.js",
"config": {
"sendTelemetryData": false,
"signalingServerUrl": "null"
}
}
}
}
},
"maximumAssertionSizeInKb": 2500,
"commandExecutorVerboseLoggingEnabled": false,
"appDataPath": "data",
"logLevel": "info",
"telemetry": {
"enabled": true,
"sendTelemetryData": false,
"signalingServerUrl": "null"
},
"auth": {
"ipBasedAuthEnabled": true,
"tokenBasedAuthEnabled": false,
Expand Down Expand Up @@ -301,17 +309,25 @@
"config": {}
}
}
},
"telemetry": {
"enabled": true,
"implementation": {
"ot-telemetry": {
"enabled": true,
"package": "./telemetry/implementation/ot-telemetry.js",
"config": {
"sendTelemetryData": false,
"signalingServerUrl": "null"
}
}
}
}
},
"maximumAssertionSizeInKb": 2500,
"commandExecutorVerboseLoggingEnabled": false,
"appDataPath": "data",
"logLevel": "trace",
"telemetry": {
"enabled": true,
"sendTelemetryData": false,
"signalingServerUrl": "null"
},
"auth": {
"ipBasedAuthEnabled": true,
"tokenBasedAuthEnabled": false,
Expand Down Expand Up @@ -448,17 +464,25 @@
"config": {}
}
}
},
"telemetry": {
"enabled": true,
"implementation": {
"ot-telemetry": {
"enabled": true,
"package": "./telemetry/implementation/ot-telemetry.js",
"config": {
"sendTelemetryData": true,
"signalingServerUrl": "https://testnet-signaling.origin-trail.network/signal"
}
}
}
}
},
"maximumAssertionSizeInKb": 2500,
"commandExecutorVerboseLoggingEnabled": false,
"appDataPath": "data",
"logLevel": "trace",
"telemetry": {
"enabled": true,
"sendTelemetryData": true,
"signalingServerUrl": "https://testnet-signaling.origin-trail.network/signal"
},
"auth": {
"ipBasedAuthEnabled": true,
"tokenBasedAuthEnabled": false,
Expand Down Expand Up @@ -596,17 +620,25 @@
"config": {}
}
}
},
"telemetry": {
"enabled": true,
"implementation": {
"ot-telemetry": {
"enabled": true,
"package": "./telemetry/implementation/ot-telemetry.js",
"config": {
"sendTelemetryData": true,
"signalingServerUrl": "https://mainnet-signaling.origin-trail.network/signal"
}
}
}
}
},
"maximumAssertionSizeInKb": 2500,
"commandExecutorVerboseLoggingEnabled": false,
"appDataPath": "data",
"logLevel": "trace",
"telemetry": {
"enabled": true,
"sendTelemetryData": true,
"signalingServerUrl": "https://mainnet-signaling.origin-trail.network/signal"
},
"auth": {
"ipBasedAuthEnabled": true,
"tokenBasedAuthEnabled": false,
Expand Down
54 changes: 37 additions & 17 deletions ot-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import OtnodeUpdateCommand from './src/commands/common/otnode-update-command.js'
import OtAutoUpdater from './src/modules/auto-updater/implementation/ot-auto-updater.js';
import PullBlockchainShardingTableMigration from './src/migration/pull-sharding-table-migration.js';
import TripleStoreUserConfigurationMigration from './src/migration/triple-store-user-configuration-migration.js';
import TelemetryModuleUserConfigurationMigration from './src/migration/telemetry-module-user-configuration-migration.js';
import PrivateAssetsMetadataMigration from './src/migration/private-assets-metadata-migration.js';
import ServiceAgreementsMetadataMigration from './src/migration/service-agreements-metadata-migration.js';
import RemoveAgreementStartEndTimeMigration from './src/migration/remove-agreement-start-end-time-migration.js';
Expand All @@ -36,6 +37,7 @@ class OTNode {
await this.checkForUpdate();
await this.removeUpdateFile();
await this.executeTripleStoreUserConfigurationMigration();
await this.executeTelemetryModuleUserConfigurationMigration();
this.logger.info(' ██████╗ ████████╗███╗ ██╗ ██████╗ ██████╗ ███████╗');
this.logger.info('██╔═══██╗╚══██╔══╝████╗ ██║██╔═══██╗██╔══██╗██╔════╝');
this.logger.info('██║ ██║ ██║ ██╔██╗ ██║██║ ██║██║ ██║█████╗');
Expand Down Expand Up @@ -65,11 +67,11 @@ class OTNode {

await this.initializeCommandExecutor();
await this.initializeShardingTableService();
await this.initializeTelemetryInjectionService();
await this.initializeBlockchainEventListenerService();

await this.initializeRouters();
await this.startNetworkModule();
this.startTelemetryModule();
this.resumeCommandExecutor();
this.logger.info('Node is up and running!');
}
Expand Down Expand Up @@ -275,6 +277,21 @@ class OTNode {
await networkModuleManager.start();
}

startTelemetryModule() {
const telemetryModuleManager = this.container.resolve('telemetryModuleManager');
const repositoryModuleManager = this.container.resolve('repositoryModuleManager');
telemetryModuleManager.listenOnEvents((eventData) => {
repositoryModuleManager.createEventRecord(
eventData.operationId,
eventData.lastEvent,
eventData.timestamp,
eventData.value1,
eventData.value2,
eventData.value3,
);
});
}

async executePrivateAssetsMetadataMigration() {
if (
process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT ||
Expand Down Expand Up @@ -305,6 +322,25 @@ class OTNode {
}
}

async executeTelemetryModuleUserConfigurationMigration() {
if (
process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT ||
process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST
)
return;

const migration = new TelemetryModuleUserConfigurationMigration(
'telemetryModuleUserConfigurationMigration',
this.logger,
this.config,
);
if (!(await migration.migrationAlreadyExecuted())) {
await migration.migrate();
this.logger.info('Node will now restart!');
this.stop(1);
}
}

async executeTripleStoreUserConfigurationMigration() {
if (
process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT ||
Expand Down Expand Up @@ -474,22 +510,6 @@ class OTNode {
}
}

async initializeTelemetryInjectionService() {
if (this.config.telemetry.enabled) {
try {
const telemetryHubModuleManager = this.container.resolve(
'telemetryInjectionService',
);
telemetryHubModuleManager.initialize();
this.logger.info('Telemetry Injection Service initialized successfully');
} catch (e) {
this.logger.error(
`Telemetry hub module initialization failed. Error message: ${e.message}`,
);
}
}
}

async removeUpdateFile() {
const updateFilePath = this.fileService.getUpdateFilePath();
await this.fileService.removeFile(updateFilePath).catch((error) => {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "origintrail_node",
"version": "6.0.16",
"version": "6.0.17",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down
60 changes: 33 additions & 27 deletions src/commands/common/send-telemetry-command.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import axios from 'axios';
import { createRequire } from 'module';
import Command from '../command.js';
import { SEND_TELEMETRY_COMMAND_FREQUENCY_MINUTES } from '../../constants/constants.js';
Expand All @@ -11,45 +10,42 @@ class SendTelemetryCommand extends Command {
super(ctx);
this.logger = ctx.logger;
this.config = ctx.config;
this.telemetryInjectionService = ctx.telemetryInjectionService;
this.networkModuleManager = ctx.networkModuleManager;
this.blockchainModuleManager = ctx.blockchainModuleManager;
this.repositoryModuleManager = ctx.repositoryModuleManager;
this.telemetryModuleManager = ctx.telemetryModuleManager;
}

/**
* Performs code update by fetching new code from github repo
* @param command
*/
async execute() {
if (!this.config.telemetry.enabled || !this.config.telemetry.sendTelemetryData) {
if (
!this.config.modules.telemetry.enabled ||
!this.telemetryModuleManager.getModuleConfiguration().sendTelemetryData
) {
return Command.empty();
}

try {
const events = await this.telemetryInjectionService.getUnpublishedEvents();
const signalingMessage = {
nodeData: {
version: pjson.version,
identity: this.networkModuleManager.getPeerId().toB58String(),
hostname: this.config.hostname,
operational_wallet: this.blockchainModuleManager.getPublicKey(),
management_wallet: this.blockchainModuleManager.getManagementKey(),
triple_store: this.config.modules.tripleStore.defaultImplementation,
auto_update_enabled: this.config.modules.autoUpdater.enabled,
multiaddresses: this.networkModuleManager.getMultiaddrs(),
},
events: events || [],
};
const config = {
method: 'post',
url: this.config.telemetry.signalingServerUrl,
headers: {
'Content-Type': 'application/json',
},
data: JSON.stringify(signalingMessage),
const events = (await this.getUnpublishedEvents()) || [];
const nodeData = {
version: pjson.version,
identity: this.networkModuleManager.getPeerId().toB58String(),
hostname: this.config.hostname,
operational_wallet: this.blockchainModuleManager.getPublicKey(),
management_wallet: this.blockchainModuleManager.getManagementKey(),
triple_store: this.config.modules.tripleStore.defaultImplementation,
auto_update_enabled: this.config.modules.autoUpdater.enabled,
multiaddresses: this.networkModuleManager.getMultiaddrs(),
};
const response = await axios(config);
if (response.status === 200 && events?.length > 0) {
await this.telemetryInjectionService.removePublishedEvents(events);
const isDataSuccessfullySent = await this.telemetryModuleManager.sendTelemetryData(
nodeData,
events,
);
if (isDataSuccessfullySent && events?.length > 0) {
await this.removePublishedEvents(events);
}
} catch (e) {
await this.handleError(e);
Expand Down Expand Up @@ -83,6 +79,16 @@ class SendTelemetryCommand extends Command {
Object.assign(command, map);
return command;
}

async getUnpublishedEvents() {
return this.repositoryModuleManager.getUnpublishedEvents();
}

async removePublishedEvents(events) {
const ids = events.map((event) => event.id);

await this.repositoryModuleManager.destroyEvents(ids);
}
}

export default SendTelemetryCommand;
7 changes: 4 additions & 3 deletions src/commands/protocols/common/submit-commit-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ class SubmitCommitCommand extends Command {
stateIndex,
);
if (alreadySubmitted) {
this.logger.trace(
`Commit already submitted for blockchain: ${blockchain} agreement id: ${agreementId}, epoch: ${epoch}, state index: ${stateIndex}`,
);
const errorMessage = `Commit already submitted for blockchain: ${blockchain} agreement id: ${agreementId}, epoch: ${epoch}, state index: ${stateIndex}`;
this.logger.trace(errorMessage);

await this.handleError(operationId, errorMessage, this.errorType, true);
return Command.empty();
}

Expand Down
20 changes: 16 additions & 4 deletions src/commands/protocols/common/submit-proofs-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ class SubmitProofsCommand extends Command {
);

if (!assertion.length) {
this.logger.trace(`Assertion with id: ${assertionId} not found in triple store.`);
const errorMessage = `Assertion with id: ${assertionId} not found in triple store.`;
this.logger.trace(errorMessage);

await this.handleError(operationId, errorMessage, this.errorType, true);
return Command.empty();
}

Expand Down Expand Up @@ -97,9 +100,18 @@ class SubmitProofsCommand extends Command {
stateIndex,
);
if (alreadySubmitted) {
this.logger.trace(
`Proofs already submitted for blockchain: ${blockchain} agreement id: ${agreementId}, epoch: ${epoch}, state index: ${stateIndex}`,
);
const errorMessage = `Proofs already submitted for blockchain: ${blockchain} agreement id: ${agreementId}, epoch: ${epoch}, state index: ${stateIndex}`;
this.logger.trace(errorMessage);

await this.handleError(operationId, errorMessage, this.errorType, true);
return Command.empty();
}

if (proof.length === 0) {
const errorMessage = `Error during Merkle Proof calculation for blockchain: ${blockchain} agreement id: ${agreementId}, epoch: ${epoch}, state index: ${stateIndex}, proof cannot be empty`;
this.logger.trace(errorMessage);

await this.handleError(operationId, errorMessage, this.errorType, true);
return Command.empty();
}

Expand Down
Loading