Skip to content

Commit

Permalink
Merge pull request #2767 from OriginTrail/v6/release/testnet
Browse files Browse the repository at this point in the history
OriginTrail Mainnet Prerelease v6.0.18
  • Loading branch information
NZT48 authored Nov 6, 2023
2 parents b6283b4 + da02b1e commit f2e2d05
Show file tree
Hide file tree
Showing 19 changed files with 490 additions and 200 deletions.
80 changes: 58 additions & 22 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@
"config": {
"networkId": "otp::testnet",
"hubContractAddress": "0x707233a55bD035C6Bc732196CA4dbffa63CbA169",
"rpcEndpoints": ["https://lofar-tm-rpc.origin-trail.network"],
"rpcEndpoints": [
"https://lofar-tm-rpc.origin-trail.network",
"https://lofar.origintrail.network/"
],
"initialStakeAmount": 50000,
"initialAskAmount": 2
}
Expand Down Expand Up @@ -166,17 +169,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 +312,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 +467,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 @@ -561,7 +588,8 @@
"hubContractAddress": "0x5fA7916c48Fe6D5F1738d12Ad234b78c90B4cAdA",
"rpcEndpoints": [
"https://astrosat-parachain-rpc.origin-trail.network",
"https://astrosat.origintrail.network/"
"https://astrosat.origintrail.network/",
"https://astrosat-2.origintrail.network/"
]
}
}
Expand Down Expand Up @@ -596,17 +624,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.18",
"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;
9 changes: 7 additions & 2 deletions src/commands/common/validate-asset-command.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import Command from '../command.js';
import { ERROR_TYPE, OPERATION_ID_STATUS, LOCAL_STORE_TYPES } from '../../constants/constants.js';
import {
ERROR_TYPE,
OPERATION_ID_STATUS,
LOCAL_STORE_TYPES,
ZERO_BYTES32,
} from '../../constants/constants.js';

class ValidateAssetCommand extends Command {
constructor(ctx) {
Expand Down Expand Up @@ -43,7 +48,7 @@ class ValidateAssetCommand extends Command {
tokenId,
);
}
if (!blockchainAssertionId) {
if (!blockchainAssertionId || blockchainAssertionId === ZERO_BYTES32) {
return Command.retry();
}
const cachedData = await this.operationIdService.getCachedOperationIdData(operationId);
Expand Down
Loading

0 comments on commit f2e2d05

Please sign in to comment.