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 Devnet prerelease v6.1.3 #2881

Merged
merged 30 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
485c870
Fixed authorization middleware to check operation case-insensitively,…
0xbraindevd Dec 21, 2023
7852ce4
Added new events for transactions
djordjekovac Jan 8, 2024
954e443
updated sql migration query
Jan 9, 2024
83e262f
PR comment fixed
djordjekovac Jan 9, 2024
b78f916
merge v6/develop
Jan 10, 2024
197442a
Merge branch 'v6/develop' into fix/jwt-auth
Jan 10, 2024
f71e95e
merged with latest node version
Jan 10, 2024
2405cfb
changed implementation to work for multiple roles
Jan 10, 2024
8990653
Fix pre-publish bid validation for neighbourhood
NZT48 Jan 11, 2024
bc9cf12
bump version
Jan 11, 2024
c0dc285
Reducing number of RPC calls from ValidationService
Jan 11, 2024
f22d2d0
removed unnecessary values from return object in getAssertionData
Jan 11, 2024
cd84658
Updated transaction error events
djordjekovac Jan 12, 2024
b559953
Send all triple stopres implementetion to telemetry
Mihajlo-Pavlovic Jan 12, 2024
21a51b6
Update src/commands/protocols/publish/sender/publish-schedule-message…
NZT48 Jan 12, 2024
5bc09e2
Update src/commands/protocols/publish/sender/publish-schedule-message…
NZT48 Jan 12, 2024
2067923
Mittigated issue with blockchain removal during RPC outage
djordjekovac Jan 12, 2024
9aebfc8
removed unnecessary awaits
Jan 12, 2024
1c96063
Merge pull request #2875 from OriginTrail/v6/bugfix/validate-neighbou…
NZT48 Jan 12, 2024
bdd3235
Merge branch 'v6/develop' into v6/otnode-events-for-transactions
NZT48 Jan 12, 2024
5f45b26
Merge pull request #2873 from OriginTrail/v6/otnode-events-for-transa…
NZT48 Jan 12, 2024
87cdedb
Merge branch 'v6/develop' into v6/fix-blockchain-module-removal-bug
NZT48 Jan 12, 2024
0858dd3
Send triple store info as object
Mihajlo-Pavlovic Jan 12, 2024
797feae
Merge pull request #2878 from OriginTrail/v6/fix-blockchain-module-re…
NZT48 Jan 12, 2024
3c997a0
Merge branch 'v6/develop' into v6/improvement/validation-service-opti…
NZT48 Jan 12, 2024
4bf9855
Merge pull request #2877 from OriginTrail/v6/improvement/validation-s…
NZT48 Jan 12, 2024
25bcc4c
Merge branch 'v6/develop' into processsing-multiple-triple-store-bloc…
NZT48 Jan 12, 2024
efffab8
Merge pull request #2879 from OriginTrail/processsing-multiple-triple…
NZT48 Jan 12, 2024
75cb08d
Merge branch 'v6/develop' into fix/jwt-auth
NZT48 Jan 12, 2024
d411166
Merge pull request #2845 from OriginTrail/fix/jwt-auth
NZT48 Jan 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
34 changes: 33 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,14 @@ 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.COMMIT_PROOF.SUBMIT_COMMIT_SEND_TX_ERROR,
sendSubmitCommitTransactionOperationId,
blockchain,
error.message,
this.errorType,
operationId,
);
let newGasPrice;
if (
error.message.includes(`timeout exceeded`) ||
Expand All @@ -142,6 +158,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 +177,14 @@ class SubmitCommitCommand extends Command {
);
} else {
msgBase = 'Node has already submitted commit. Finishing';
this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_COMMIT_SEND_TX_ERROR,
sendSubmitCommitTransactionOperationId,
blockchain,
msgBase,
this.errorType,
operationId,
);
}

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.COMMIT_PROOF.SUBMIT_COMMIT_SEND_TX_ERROR,
sendSubmitProofsTransactionOperationId,
blockchain,
error.message,
this.errorType,
);
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.COMMIT_PROOF.SUBMIT_COMMIT_SEND_TX_ERROR,
sendSubmitProofsTransactionOperationId,
blockchain,
msgBase,
this.errorType,
);
}

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.COMMIT_PROOF.SUBMIT_COMMIT_SEND_TX_ERROR,
sendSubmitUpdateCommitTransactionOperationId,
blockchain,
error.message,
this.errorType,
);
let newGasPrice;
if (
error.message.includes(`timeout exceeded`) ||
Expand Down
13 changes: 13 additions & 0 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,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 +347,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 +585,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
14 changes: 14 additions & 0 deletions src/modules/blockchain/implementation/web3-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,20 @@ class Web3Service {
return Number(assertionChunksNumber);
}

async getAssertionData(assertionId) {
const assertionData = await this.callContractFunction(
this.AssertionStorageContract,
'getAssertion',
[assertionId],
);
return {
timestamp: Number(assertionData.timestamp),
size: Number(assertionData.size),
triplesNumber: Number(assertionData.triplesNumber),
chunksNumber: Number(assertionData.chunksNumber),
};
}

selectCommitManagerContract(latestStateIndex) {
return latestStateIndex === 0
? this.CommitManagerV1Contract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default (authService) => async (req, res, next) => {
const match = req.path.match(/^\/(?:v[0-9]+\/)?([^\/\?]+)/);
if (!match) return res.status(404).send('Not found.');

const operation = match[0].substring(1);
const operation = match[0].substring(1).toUpperCase();

if (authService.isPublicOperation(operation)) {
return next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default (authService) => async (req, res, next) => {
const match = req.path.match(/^\/(?:v[0-9]+\/)?([^\/\?]+)/);
if (!match) return res.status(404).send('Not found.');

const operation = match[0].substring(1);
const operation = match[0].substring(1).toUpperCase();

if (authService.isPublicOperation(operation)) {
return next();
Expand Down
Loading