From 3f610e0962ec584484da45eb5873fa51e7c5b1a6 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Fri, 3 Nov 2023 15:25:19 +0100 Subject: [PATCH 1/3] Added error handling for commits/proofs commands, added error handling when proof is empty, removed duplicated SA record update, increased tx polling timeout to 120 seconds --- .../protocols/common/submit-commit-command.js | 7 ++++--- .../protocols/common/submit-proofs-command.js | 20 +++++++++++++++---- .../v1-0-0-handle-store-request-command.js | 16 --------------- src/constants/constants.js | 8 ++++---- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/commands/protocols/common/submit-commit-command.js b/src/commands/protocols/common/submit-commit-command.js index 7c9cfba13a..f3452eb707 100644 --- a/src/commands/protocols/common/submit-commit-command.js +++ b/src/commands/protocols/common/submit-commit-command.js @@ -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); + + this.handleError(operationId, errorMessage, this.errorType, true); return Command.empty(); } diff --git a/src/commands/protocols/common/submit-proofs-command.js b/src/commands/protocols/common/submit-proofs-command.js index 8348480f84..3b724405bd 100644 --- a/src/commands/protocols/common/submit-proofs-command.js +++ b/src/commands/protocols/common/submit-proofs-command.js @@ -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); + + this.handleError(operationId, errorMessage, this.errorType, true); return Command.empty(); } @@ -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); + 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); + this.handleError(operationId, errorMessage, this.errorType, true); return Command.empty(); } diff --git a/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-request-command.js b/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-request-command.js index 0caa031c63..5e82bd6178 100644 --- a/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-request-command.js +++ b/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-request-command.js @@ -83,22 +83,6 @@ class HandleStoreRequestCommand extends HandleProtocolMessageCommand { stateIndex, ); - await this.repositoryModuleManager.updateServiceAgreementRecord( - blockchain, - contract, - tokenId, - agreementId, - agreementData.startTime, - agreementData.epochsNumber, - agreementData.epochLength, - agreementData.scoreFunctionId, - agreementData.proofWindowOffsetPerc, - hashFunctionId, - keyword, - assertionId, - stateIndex, - ); - await this.operationIdService.updateOperationIdStatus( operationId, OPERATION_ID_STATUS.PUBLISH.PUBLISH_LOCAL_STORE_END, diff --git a/src/constants/constants.js b/src/constants/constants.js index 3fff5854e4..285441faee 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -21,7 +21,7 @@ export const COMMIT_BLOCK_DURATION_IN_BLOCKS = 5; export const COMMITS_DELAY_BETWEEN_NODES_IN_BLOCKS = 2; -export const TRANSACTION_POLLING_TIMEOUT_MILLIS = 50 * 1000; +export const TRANSACTION_POLLING_TIMEOUT_MILLIS = 120 * 1000; export const SOLIDITY_ERROR_STRING_PREFIX = '0x08c379a0'; @@ -167,9 +167,9 @@ export const DEFAULT_COMMAND_REPEAT_INTERVAL_IN_MILLS = 5000; // 5 seconds export const DEFAULT_COMMAND_DELAY_IN_MILLS = 60 * 1000; // 60 seconds export const COMMAND_RETRIES = { - SUBMIT_COMMIT: 3, - SUBMIT_UPDATE_COMMIT: 3, - SUBMIT_PROOFS: 3, + SUBMIT_COMMIT: 0, + SUBMIT_UPDATE_COMMIT: 0, + SUBMIT_PROOFS: 0, }; export const WEBSOCKET_PROVIDER_OPTIONS = { From 4bcbf68f8d67991f4b8786340d27c07556a8e8e1 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Fri, 3 Nov 2023 15:25:57 +0100 Subject: [PATCH 2/3] Bumped version to 6.0.17 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4fdac68a57..b9088bc25c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.0.16", + "version": "6.0.17", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.0.16", + "version": "6.0.17", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index 307fadd425..a8218caca2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.0.16", + "version": "6.0.17", "description": "OTNode V6", "main": "index.js", "type": "module", From d556a6d5af63ceff171e2d7ffe8069b456ef71e4 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Fri, 3 Nov 2023 15:33:01 +0100 Subject: [PATCH 3/3] Added missing awaits for handleError --- src/commands/protocols/common/submit-commit-command.js | 2 +- src/commands/protocols/common/submit-proofs-command.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/commands/protocols/common/submit-commit-command.js b/src/commands/protocols/common/submit-commit-command.js index f3452eb707..b2312b72ee 100644 --- a/src/commands/protocols/common/submit-commit-command.js +++ b/src/commands/protocols/common/submit-commit-command.js @@ -52,7 +52,7 @@ class SubmitCommitCommand extends Command { const errorMessage = `Commit already submitted for blockchain: ${blockchain} agreement id: ${agreementId}, epoch: ${epoch}, state index: ${stateIndex}`; this.logger.trace(errorMessage); - this.handleError(operationId, errorMessage, this.errorType, true); + await this.handleError(operationId, errorMessage, this.errorType, true); return Command.empty(); } diff --git a/src/commands/protocols/common/submit-proofs-command.js b/src/commands/protocols/common/submit-proofs-command.js index 3b724405bd..2e44f23ba2 100644 --- a/src/commands/protocols/common/submit-proofs-command.js +++ b/src/commands/protocols/common/submit-proofs-command.js @@ -69,7 +69,7 @@ class SubmitProofsCommand extends Command { const errorMessage = `Assertion with id: ${assertionId} not found in triple store.`; this.logger.trace(errorMessage); - this.handleError(operationId, errorMessage, this.errorType, true); + await this.handleError(operationId, errorMessage, this.errorType, true); return Command.empty(); } @@ -101,17 +101,17 @@ class SubmitProofsCommand extends Command { ); if (alreadySubmitted) { const errorMessage = `Proofs already submitted for blockchain: ${blockchain} agreement id: ${agreementId}, epoch: ${epoch}, state index: ${stateIndex}`; - this.logger.trace(errorMessage); - this.handleError(operationId, errorMessage, this.errorType, true); + + 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); - this.handleError(operationId, errorMessage, this.errorType, true); + + await this.handleError(operationId, errorMessage, this.errorType, true); return Command.empty(); }