Skip to content

Commit

Permalink
Merge pull request #2893 from OriginTrail/v6/release/testnet
Browse files Browse the repository at this point in the history
OriginTrail 6.1.3 Mainnet Prerelease
  • Loading branch information
NZT48 authored Jan 18, 2024
2 parents cd0ec11 + 3e4394c commit dd0083c
Show file tree
Hide file tree
Showing 18 changed files with 284 additions and 54 deletions.
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.1.2",
"version": "6.1.3",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down
17 changes: 14 additions & 3 deletions src/commands/common/send-telemetry-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class SendTelemetryCommand extends Command {
this.config = ctx.config;
this.networkModuleManager = ctx.networkModuleManager;
this.blockchainModuleManager = ctx.blockchainModuleManager;
this.tripleStoreModuleManager = ctx.tripleStoreModuleManager;
this.repositoryModuleManager = ctx.repositoryModuleManager;
this.telemetryModuleManager = ctx.telemetryModuleManager;
}
Expand All @@ -31,8 +32,8 @@ class SendTelemetryCommand extends Command {
try {
const events = (await this.getUnpublishedEvents()) || [];
const blockchainsNodeInfo = [];
const implementations = this.blockchainModuleManager.getImplementationNames();
for (const implementation of implementations) {
const blockchainImplementations = this.blockchainModuleManager.getImplementationNames();
for (const implementation of blockchainImplementations) {
const blockchainInfo = {
blockchain_id: implementation,
// eslint-disable-next-line no-await-in-loop
Expand All @@ -43,11 +44,21 @@ class SendTelemetryCommand extends Command {
};
blockchainsNodeInfo.push(blockchainInfo);
}

const tripleStoreNodeInfo = [];
const tripleStoreImplementations =
this.tripleStoreModuleManager.getImplementationNames();
for (const implementation of tripleStoreImplementations) {
const tripleStoreInfo = {
implementationName: implementation,
};
tripleStoreNodeInfo.push(tripleStoreInfo);
}
const nodeData = {
version: pjson.version,
identity: this.networkModuleManager.getPeerId().toB58String(),
hostname: this.config.hostname,
triple_store: this.config.modules.tripleStore.defaultImplementation,
triple_stores: tripleStoreNodeInfo,
auto_update_enabled: this.config.modules.autoUpdater.enabled,
multiaddresses: this.networkModuleManager.getMultiaddrs(),
blockchains: blockchainsNodeInfo,
Expand Down
32 changes: 31 additions & 1 deletion src/commands/protocols/common/submit-commit-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,17 @@ class SubmitCommitCommand extends Command {
);
});

const sendSubmitCommitTransactionOperationId = this.operationIdService.generateId();
let txSuccess;
try {
this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_COMMIT_SEND_TX_START,
sendSubmitCommitTransactionOperationId,
blockchain,
agreementId,
epoch,
operationId,
);
txSuccess = await transactionCompletePromise;
} catch (error) {
this.logger.warn(
Expand All @@ -121,7 +130,13 @@ class SubmitCommitCommand extends Command {
`Epoch: ${epoch}, State Index: ${stateIndex}, Operation ID: ${operationId}, ` +
`Retry number: ${COMMAND_RETRIES.SUBMIT_COMMIT - command.retries + 1}.`,
);

this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.FAILED,
sendSubmitCommitTransactionOperationId,
blockchain,
error.message,
ERROR_TYPE.COMMIT_PROOF.SUBMIT_COMMIT_SEND_TX_ERROR,
);
let newGasPrice;
if (
error.message.includes(`timeout exceeded`) ||
Expand All @@ -142,6 +157,14 @@ class SubmitCommitCommand extends Command {

let msgBase;
if (txSuccess) {
this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_COMMIT_SEND_TX_END,
sendSubmitCommitTransactionOperationId,
blockchain,
agreementId,
epoch,
operationId,
);
msgBase = 'Successfully executed';

this.operationIdService.emitChangeEvent(
Expand All @@ -153,6 +176,13 @@ class SubmitCommitCommand extends Command {
);
} else {
msgBase = 'Node has already submitted commit. Finishing';
this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.FAILED,
sendSubmitCommitTransactionOperationId,
blockchain,
msgBase,
ERROR_TYPE.COMMIT_PROOF.SUBMIT_COMMIT_SEND_TX_ERROR,
);
}

this.logger.trace(
Expand Down
31 changes: 29 additions & 2 deletions src/commands/protocols/common/submit-proofs-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,16 @@ class SubmitProofsCommand extends Command {
txGasPrice,
);
});

const sendSubmitProofsTransactionOperationId = this.operationIdService.generateId();
let txSuccess;
try {
this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_PROOFS_SEND_TX_START,
sendSubmitProofsTransactionOperationId,
blockchain,
agreementId,
epoch,
);
txSuccess = await transactionCompletePromise;
} catch (error) {
this.logger.warn(
Expand All @@ -173,7 +180,13 @@ class SubmitProofsCommand extends Command {
`Epoch: ${epoch}, State Index: ${stateIndex}, Operation ID: ${operationId}, ` +
`Retry number: ${COMMAND_RETRIES.SUBMIT_PROOFS - command.retries + 1}.`,
);

this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.FAILED,
sendSubmitProofsTransactionOperationId,
blockchain,
error.message,
ERROR_TYPE.COMMIT_PROOF.SUBMIT_PROOFS_SEND_TX_ERROR,
);
let newGasPrice;
if (
error.message.includes(`timeout exceeded`) ||
Expand All @@ -194,6 +207,13 @@ class SubmitProofsCommand extends Command {

let msgBase;
if (txSuccess) {
this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_PROOFS_SEND_TX_START,
sendSubmitProofsTransactionOperationId,
blockchain,
agreementId,
epoch,
);
msgBase = 'Successfully executed';

this.operationIdService.emitChangeEvent(
Expand All @@ -205,6 +225,13 @@ class SubmitProofsCommand extends Command {
);
} else {
msgBase = 'Node has already sent proof. Finishing';
this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.FAILED,
sendSubmitProofsTransactionOperationId,
blockchain,
msgBase,
ERROR_TYPE.COMMIT_PROOF.SUBMIT_COMMIT_SEND_TX_ERROR,
);
}

this.logger.trace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class PublishScheduleMessagesCommand extends ProtocolScheduleMessagesCommand {
constructor(ctx) {
super(ctx);
this.operationService = ctx.publishService;
this.serviceAgreementService = ctx.serviceAgreementService;
this.blockchainModuleManager = ctx.blockchainModuleManager;
this.repositoryModuleManager = ctx.repositoryModuleManager;

this.startEvent = OPERATION_ID_STATUS.PUBLISH.PUBLISH_REPLICATE_START;
this.errorType = ERROR_TYPE.PUBLISH.PUBLISH_START_ERROR;
Expand All @@ -26,7 +29,7 @@ class PublishScheduleMessagesCommand extends ProtocolScheduleMessagesCommand {
} = command.data;
let isValid = true;
// perform check only first time not for every batch
if (leftoverNodes === numberOfFoundNodes) {
if (leftoverNodes.length === numberOfFoundNodes) {
isValid = await this.validateBidsForNeighbourhood(
blockchain,
contract,
Expand Down Expand Up @@ -90,15 +93,15 @@ class PublishScheduleMessagesCommand extends ProtocolScheduleMessagesCommand {

let validBids = 0;

nodes.forEach((node) => {
const askNumber = this.blockchainModuleManager.convertToWei(blockchain, node.ask);

const ask = this.blockchainModuleManager.toBigNumber(blockchain, askNumber);
await Promise.all(
nodes.map(async (node) => {
const ask = await this.getAsk(blockchain, node.id);
if (ask.lte(serviceAgreementBid)) {
validBids += 1;
}
}),
);

if (ask.lte(serviceAgreementBid)) {
validBids += 1;
}
});
if (validBids < minAckResponses) {
await this.operationService.markOperationAsFailed(
operationId,
Expand All @@ -111,6 +114,13 @@ class PublishScheduleMessagesCommand extends ProtocolScheduleMessagesCommand {
return true;
}

async getAsk(blockchain, nodeId) {
const peerRecord = await this.repositoryModuleManager.getPeerRecord(nodeId, blockchain);
const ask = this.blockchainModuleManager.convertToWei(blockchain, peerRecord.ask);

return this.blockchainModuleManager.toBigNumber(blockchain, ask);
}

/**
* Builds default publishScheduleMessagesCommand
* @param map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,23 @@ class SubmitUpdateCommitCommand extends Command {
);
});

const sendSubmitUpdateCommitTransactionOperationId = this.operationIdService.generateId();
try {
this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_UPDATE_COMMIT_SEND_TX_START,
sendSubmitUpdateCommitTransactionOperationId,
blockchain,
agreementId,
epoch,
);
await transactionCompletePromise;
this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_UPDATE_COMMIT_SEND_TX_END,
sendSubmitUpdateCommitTransactionOperationId,
blockchain,
agreementId,
epoch,
);
} catch (error) {
this.logger.warn(
`Failed to execute ${command.name}, Error Message: ${error.message} for the Service Agreement ` +
Expand All @@ -100,7 +115,13 @@ class SubmitUpdateCommitCommand extends Command {
COMMAND_RETRIES.SUBMIT_UPDATE_COMMIT - command.retries + 1
}.`,
);

this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.FAILED,
sendSubmitUpdateCommitTransactionOperationId,
blockchain,
error.message,
ERROR_TYPE.COMMIT_PROOF.SUBMIT_UPDATE_COMMIT_SEND_TX_ERROR,
);
let newGasPrice;
if (
error.message.includes(`timeout exceeded`) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class HandleUpdateRequestCommand extends HandleProtocolMessageCommand {
// wait for 5 blocks for first batch to send commits
const commitsBlockDuration = blockTime * COMMIT_BLOCK_DURATION_IN_BLOCKS;
const commitBlock = Math.floor(rank / finalizationCommitsNumber);
// put 2 blocks delay between nodes if they are not in first batch
// put 5 blocks delay between nodes if they are not in first batch
const nextNodeDelay =
commitBlock === 0
? 0
Expand Down
17 changes: 16 additions & 1 deletion src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const PRIVATE_ASSERTION_PREDICATE =

export const COMMIT_BLOCK_DURATION_IN_BLOCKS = 5;

export const COMMITS_DELAY_BETWEEN_NODES_IN_BLOCKS = 2;
export const COMMITS_DELAY_BETWEEN_NODES_IN_BLOCKS = 5;

export const TRANSACTION_POLLING_TIMEOUT_MILLIS = 300 * 1000;

Expand Down Expand Up @@ -188,6 +188,8 @@ export const COMMAND_TX_GAS_INCREASE_FACTORS = {
SUBMIT_PROOFS: 1.2,
};

export const GNOSIS_DEFAULT_GAS_PRICE = 2;

export const WEBSOCKET_PROVIDER_OPTIONS = {
reconnect: {
auto: true,
Expand Down Expand Up @@ -283,8 +285,11 @@ export const ERROR_TYPE = {
CALCULATE_PROOFS_ERROR: 'CalculateProofsError',
EPOCH_CHECK_ERROR: 'EpochCheckError',
SUBMIT_COMMIT_ERROR: 'SubmitCommitError',
SUBMIT_COMMIT_SEND_TX_ERROR: 'SubmitCommitSendTxError',
SUBMIT_PROOFS_ERROR: 'SubmitProofsError',
SUBMIT_PROOFS_SEND_TX_ERROR: 'SubmitProofsSendTxError',
SUBMIT_UPDATE_COMMIT_ERROR: 'SubmitUpdateCommitError',
SUBMIT_UPDATE_COMMIT_SEND_TX_ERROR: 'SubmitUpdateCommitSendTxError',
},
};
export const OPERATION_ID_STATUS = {
Expand Down Expand Up @@ -344,12 +349,18 @@ export const OPERATION_ID_STATUS = {
EPOCH_CHECK_END: 'EPOCH_CHECK_END',
SUBMIT_COMMIT_START: 'SUBMIT_COMMIT_START',
SUBMIT_COMMIT_END: 'SUBMIT_COMMIT_END',
SUBMIT_COMMIT_SEND_TX_START: 'SUBMIT_COMMIT_SEND_TX_START',
SUBMIT_COMMIT_SEND_TX_END: 'SUBMIT_COMMIT_SEND_TX_END',
CALCULATE_PROOFS_START: 'CALCULATE_PROOFS_START',
CALCULATE_PROOFS_END: 'CALCULATE_PROOFS_END',
SUBMIT_PROOFS_START: 'SUBMIT_PROOFS_START',
SUBMIT_PROOFS_END: 'SUBMIT_PROOFS_END',
SUBMIT_PROOFS_SEND_TX_START: 'SUBMIT_PROOFS_START',
SUBMIT_PROOFS_SEND_TX_END: 'SUBMIT_PROOFS_END',
SUBMIT_UPDATE_COMMIT_START: 'SUBMIT_UPDATE_COMMIT_START',
SUBMIT_UPDATE_COMMIT_END: 'SUBMIT_UPDATE_COMMIT_END',
SUBMIT_UPDATE_COMMIT_SEND_TX_START: 'SUBMIT_UPDATE_COMMIT_START',
SUBMIT_UPDATE_COMMIT_SEND_TX_END: 'SUBMIT_UPDATE_COMMIT_END',
},
QUERY: {
QUERY_INIT_START: 'QUERY_INIT_START',
Expand Down Expand Up @@ -576,6 +587,10 @@ export const NODE_ENVIRONMENTS = {
MAINNET: 'mainnet',
};

export const MAXIMUM_FETCH_EVENTS_FAILED_COUNT = 1000;

export const DELAY_BETWEEN_FAILED_FETCH_EVENTS_MILLIS = 10 * 1000;

export const CONTRACT_EVENT_FETCH_INTERVALS = {
MAINNET: 10 * 1000,
DEVELOPMENT: 4 * 1000,
Expand Down
4 changes: 4 additions & 0 deletions src/modules/blockchain/blockchain-module-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ class BlockchainModuleManager extends BaseModuleManager {
]);
}

async getAssertionData(blockchain, assertionid) {
return this.callImplementationFunction(blockchain, 'getAssertionData', [assertionid]);
}

submitCommit(
blockchain,
assetContractAddress,
Expand Down
18 changes: 16 additions & 2 deletions src/modules/blockchain/implementation/gnosis/gnosis-service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import Web3Service from '../web3-service.js';
import { BLOCK_TIME_MILLIS } from '../../../../constants/constants.js';
import { BLOCK_TIME_MILLIS, GNOSIS_DEFAULT_GAS_PRICE } from '../../../../constants/constants.js';

class GnosisService extends Web3Service {
constructor(ctx) {
Expand All @@ -26,9 +26,23 @@ class GnosisService extends Web3Service {
this.logger.debug(`Gas price on Gnosis: ${gasPrice}`);
return gasPrice;
} catch (error) {
return undefined;
this.logger.warn(
`Failed to fetch the gas price from the Gnosis: ${error}. Using default value: ${GNOSIS_DEFAULT_GAS_PRICE} Gwei.`,
);
this.convertToWei(GNOSIS_DEFAULT_GAS_PRICE, 'gwei');
}
}

async healthCheck() {
try {
const blockNumber = await this.getBlockNumber();
if (blockNumber) return true;
} catch (e) {
this.logger.error(`Error on checking Gnosis blockchain. ${e}`);
return false;
}
return false;
}
}

export default GnosisService;
Loading

0 comments on commit dd0083c

Please sign in to comment.