From 50fb1faf455b421ffd645908232af4e1a2335f63 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 27 Dec 2024 10:26:11 +0100 Subject: [PATCH 1/8] Throw error when implementation is not present in blockchain module --- src/modules/base-module-manager.js | 4 ++-- src/modules/blockchain/blockchain-module-manager.js | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/modules/base-module-manager.js b/src/modules/base-module-manager.js index 2bdc901d6a..382bf869c7 100644 --- a/src/modules/base-module-manager.js +++ b/src/modules/base-module-manager.js @@ -73,8 +73,8 @@ class BaseModuleManager { getImplementation(name = null) { const keys = Object.keys(this.handlers); - if (keys.length === 1 || !name) { - return this.handlers[keys[0]]; + if (!keys.includes(name)) { + throw new Error(`Blockchain: ${name} implementation is not enabled.`); } return this.handlers[name]; } diff --git a/src/modules/blockchain/blockchain-module-manager.js b/src/modules/blockchain/blockchain-module-manager.js index 9e6f691ea4..f3115c9e19 100644 --- a/src/modules/blockchain/blockchain-module-manager.js +++ b/src/modules/blockchain/blockchain-module-manager.js @@ -6,12 +6,8 @@ class BlockchainModuleManager extends BaseModuleManager { } callImplementationFunction(blockchain, functionName, args = []) { - if (blockchain) { - if (this.getImplementation(blockchain)) { - return this.getImplementation(blockchain).module[functionName](...args); - } - } else { - return this.getImplementation().module[functionName](...args); + if (this.getImplementation(blockchain)) { + return this.getImplementation(blockchain).module[functionName](...args); } } From eee089b9d080bb2d5a5a98c1b2ff594995ab93a8 Mon Sep 17 00:00:00 2001 From: brkagithub Date: Fri, 27 Dec 2024 14:05:59 +0100 Subject: [PATCH 2/8] Fix get for KA --- .../receiver/v1.0.0/v1-0-0-handle-get-request-command.js | 8 ++++++++ src/commands/protocols/get/sender/local-get-command.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-request-command.js b/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-request-command.js index 6d4efc5133..3210c2267d 100644 --- a/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-request-command.js +++ b/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-request-command.js @@ -173,7 +173,15 @@ class HandleGetRequestCommand extends HandleProtocolMessageCommand { burned: [], }; } + } else { + // kaId is number, so transform it to range + knowledgeAssetId = { + startTokenId: knowledgeAssetId, + endTokenId: knowledgeAssetId, + burned: [], + }; } + assertionPromise = this.tripleStoreService .getAssertion( blockchain, diff --git a/src/commands/protocols/get/sender/local-get-command.js b/src/commands/protocols/get/sender/local-get-command.js index 11001d3081..48969419d0 100644 --- a/src/commands/protocols/get/sender/local-get-command.js +++ b/src/commands/protocols/get/sender/local-get-command.js @@ -155,7 +155,15 @@ class LocalGetCommand extends Command { burned: [], }; } + } else { + // kaId is number, so transform it to range + knowledgeAssetId = { + startTokenId: knowledgeAssetId, + endTokenId: knowledgeAssetId, + burned: [], + }; } + assertionPromise = this.tripleStoreService .getAssertion( blockchain, From 622b54bf6eb4abfd72d592f0794177402e3a1ff9 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 27 Dec 2024 14:42:47 +0100 Subject: [PATCH 3/8] Don't call getNextCommand data for each command --- .../protocols/common/protocol-schedule-messages-command.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/commands/protocols/common/protocol-schedule-messages-command.js b/src/commands/protocols/common/protocol-schedule-messages-command.js index 2361ffb21f..cdb3a7f88a 100644 --- a/src/commands/protocols/common/protocol-schedule-messages-command.js +++ b/src/commands/protocols/common/protocol-schedule-messages-command.js @@ -40,6 +40,8 @@ class ProtocolScheduleMessagesCommand extends Command { currentBatchNodes.length }, leftover for retry: ${currentBatchLeftoverNodes.length}`, ); + const nextCommandData = this.getNextCommandData(command); + console.log('NEXT COMMAND DATA:', JSON.stringify(nextCommandData, null, 2)); const addCommandPromises = currentBatchNodes.map(async (node) => { const commandSequence = this.protocolService.getSenderCommandSequence(node.protocol); @@ -48,7 +50,7 @@ class ProtocolScheduleMessagesCommand extends Command { sequence: commandSequence.slice(1), delay: 0, data: { - ...this.getNextCommandData(command), + ...nextCommandData, blockchain, operationId, node, From b41e559cadea185b5b9a6fc072eb9d38593d6129 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 27 Dec 2024 14:43:26 +0100 Subject: [PATCH 4/8] version bump --- 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 a0c0240fe1..38aba858b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "8.0.0+hotfix.1", + "version": "8.0.0+hotfix.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "8.0.0+hotfix.1", + "version": "8.0.0+hotfix.2", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index c56db6cace..bdec974b17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "8.0.0+hotfix.1", + "version": "8.0.0+hotfix.2", "description": "OTNode V8", "main": "index.js", "type": "module", From 912dfae9c0257d670f37b7b0b899b9ebee221e6b Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 27 Dec 2024 14:46:03 +0100 Subject: [PATCH 5/8] Remove logs --- .../protocols/common/protocol-schedule-messages-command.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/protocols/common/protocol-schedule-messages-command.js b/src/commands/protocols/common/protocol-schedule-messages-command.js index cdb3a7f88a..fb57ad349e 100644 --- a/src/commands/protocols/common/protocol-schedule-messages-command.js +++ b/src/commands/protocols/common/protocol-schedule-messages-command.js @@ -41,7 +41,6 @@ class ProtocolScheduleMessagesCommand extends Command { }, leftover for retry: ${currentBatchLeftoverNodes.length}`, ); const nextCommandData = this.getNextCommandData(command); - console.log('NEXT COMMAND DATA:', JSON.stringify(nextCommandData, null, 2)); const addCommandPromises = currentBatchNodes.map(async (node) => { const commandSequence = this.protocolService.getSenderCommandSequence(node.protocol); From e64a16ea2efad62658757c7459a6337a68159cfb Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 27 Dec 2024 15:29:59 +0100 Subject: [PATCH 6/8] Fix getImplementation --- src/modules/base-module-manager.js | 4 ++-- src/modules/blockchain/blockchain-module-manager.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/modules/base-module-manager.js b/src/modules/base-module-manager.js index 382bf869c7..2bdc901d6a 100644 --- a/src/modules/base-module-manager.js +++ b/src/modules/base-module-manager.js @@ -73,8 +73,8 @@ class BaseModuleManager { getImplementation(name = null) { const keys = Object.keys(this.handlers); - if (!keys.includes(name)) { - throw new Error(`Blockchain: ${name} implementation is not enabled.`); + if (keys.length === 1 || !name) { + return this.handlers[keys[0]]; } return this.handlers[name]; } diff --git a/src/modules/blockchain/blockchain-module-manager.js b/src/modules/blockchain/blockchain-module-manager.js index f3115c9e19..56395fd2b8 100644 --- a/src/modules/blockchain/blockchain-module-manager.js +++ b/src/modules/blockchain/blockchain-module-manager.js @@ -278,6 +278,14 @@ class BlockchainModuleManager extends BaseModuleManager { tokenId, ]); } + + getImplementation(name = null) { + const keys = Object.keys(this.handlers); + if (!keys.includes(name)) { + throw new Error(`Blockchain: ${name} implementation is not enabled.`); + } + return this.handlers[name]; + } } export default BlockchainModuleManager; From 52803120ac8d0fb3ddb19c1fd0931b407ccd0053 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 27 Dec 2024 15:36:06 +0100 Subject: [PATCH 7/8] fix handleParameterChangedEvent function --- .../blockchain-event-listener-command.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/blockchain-event-listener/blockchain-event-listener-command.js b/src/commands/blockchain-event-listener/blockchain-event-listener-command.js index 1b38097f50..4104e43e11 100644 --- a/src/commands/blockchain-event-listener/blockchain-event-listener-command.js +++ b/src/commands/blockchain-event-listener/blockchain-event-listener-command.js @@ -209,12 +209,12 @@ class BlockchainEventListenerCommand extends Command { } async handleParameterChangedEvent(event) { - const { blockchainId, contract, data } = event; + const { blockchain, contract, data } = event; const { parameterName, parameterValue } = JSON.parse(data); switch (contract) { case CONTRACTS.PARAMETERS_STORAGE: this.blockchainModuleManager.setContractCallCache( - blockchainId, + blockchain, CONTRACTS.PARAMETERS_STORAGE, parameterName, parameterValue, From 3199f03c74dfc23f754d6015113174a11722b578 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 27 Dec 2024 15:37:01 +0100 Subject: [PATCH 8/8] version bump --- 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 38aba858b4..67bebf2241 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "8.0.0+hotfix.2", + "version": "8.0.0+hotfix.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "8.0.0+hotfix.2", + "version": "8.0.0+hotfix.3", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index bdec974b17..5d0449e3b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "8.0.0+hotfix.2", + "version": "8.0.0+hotfix.3", "description": "OTNode V8", "main": "index.js", "type": "module",