From 3ebae9f58386ba000e43347f0f8768beeeb29b76 Mon Sep 17 00:00:00 2001 From: Zvonimir Sculac Date: Tue, 1 Oct 2024 14:21:14 +0200 Subject: [PATCH 1/3] Extend logging --- src/commands/common/validate-asset-command.js | 6 +++++- src/commands/local-store/local-store-command.js | 7 +++++++ .../update/receiver/delete-pending-state-command.js | 5 ++++- .../http-api/v0/publish-http-api-controller-v0.js | 2 +- src/service/file-service.js | 1 + src/service/operation-id-service.js | 8 +++++++- src/service/pending-storage-service.js | 2 ++ src/service/ual-service.js | 5 +++++ 8 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/commands/common/validate-asset-command.js b/src/commands/common/validate-asset-command.js index ec25cd8c0..fd150f546 100644 --- a/src/commands/common/validate-asset-command.js +++ b/src/commands/common/validate-asset-command.js @@ -30,6 +30,10 @@ class ValidateAssetCommand extends Command { storeType = LOCAL_STORE_TYPES.TRIPLE, } = command.data; + this.logger.debug( + `Validating Asset Command with operation id: ${operationId}, blockchain: ${blockchain}, contract: ${contract}, tokenId: ${tokenId}, store type: ${storeType}`, + ); + await this.operationIdService.updateOperationIdStatus( operationId, blockchain, @@ -61,7 +65,7 @@ class ValidateAssetCommand extends Command { await this.handleError( operationId, blockchain, - `Invalid assertion id for asset ${ual}. Received value from blockchain: ${blockchainAssertionId}, received value from request: ${cachedData.public.assertionId}`, + `Invalid assertion id for asset ${ual} and operation with id ${operationId}. Received value from blockchain: ${blockchainAssertionId}, received value from request: ${cachedData.public.assertionId}`, this.errorType, true, ); diff --git a/src/commands/local-store/local-store-command.js b/src/commands/local-store/local-store-command.js index 4a0aa82b3..0cfa92583 100644 --- a/src/commands/local-store/local-store-command.js +++ b/src/commands/local-store/local-store-command.js @@ -49,6 +49,10 @@ class LocalStoreCommand extends Command { if (storeType === LOCAL_STORE_TYPES.TRIPLE) { const storePromises = []; if (cachedData.public.assertion && cachedData.public.assertionId) { + this.logger.debug( + `Storing public assertion id: ${cachedData.public.assertionId}`, + ); + storePromises.push( this.tripleStoreService.localStoreAsset( TRIPLE_STORE_REPOSITORIES.PRIVATE_CURRENT, @@ -62,6 +66,9 @@ class LocalStoreCommand extends Command { ); } if (cachedData.private.assertion && cachedData.private.assertionId) { + this.logger.debug( + `Storing private assertion id: ${cachedData.private.assertionId}`, + ); storePromises.push( this.tripleStoreService.localStoreAsset( TRIPLE_STORE_REPOSITORIES.PRIVATE_CURRENT, diff --git a/src/commands/protocols/update/receiver/delete-pending-state-command.js b/src/commands/protocols/update/receiver/delete-pending-state-command.js index 4edf754a5..1a8afdb86 100644 --- a/src/commands/protocols/update/receiver/delete-pending-state-command.js +++ b/src/commands/protocols/update/receiver/delete-pending-state-command.js @@ -20,7 +20,8 @@ class DeletePendingStateCommand extends Command { this.logger.trace( `Started ${command.name} for blockchain: ${blockchain} contract: ${contract}, ` + - `token id: ${tokenId}, assertion id: ${assertionId}`, + `token id: ${tokenId}, assertion id: ${assertionId}, operation id: ${operationId}` + + `keyword: ${keyword}, hash function id: ${hashFunctionId}`, ); const pendingStateExists = await this.pendingStateExists( @@ -73,6 +74,7 @@ class DeletePendingStateCommand extends Command { } await this.deletePendingState(blockchain, contract, tokenId, assertionId, operationId); } + this.logger.trace(`No pending state found`); return Command.empty(); } @@ -111,6 +113,7 @@ class DeletePendingStateCommand extends Command { return true; } } + this.logger.debug(`No pending state exists for assertion id: ${assertionId}`); return false; } diff --git a/src/controllers/http-api/v0/publish-http-api-controller-v0.js b/src/controllers/http-api/v0/publish-http-api-controller-v0.js index f3de5c7c4..dc555cf50 100644 --- a/src/controllers/http-api/v0/publish-http-api-controller-v0.js +++ b/src/controllers/http-api/v0/publish-http-api-controller-v0.js @@ -24,7 +24,7 @@ class PublishController extends BaseController { const hashFunctionId = req.body.hashFunctionId ?? CONTENT_ASSET_HASH_FUNCTION_ID; this.logger.info( - `Received asset with assertion id: ${assertionId}, blockchain: ${blockchain}, hub contract: ${contract}, token id: ${tokenId}`, + `[PUBLISH] Received asset with assertion id: ${assertionId}, blockchain: ${blockchain}, hub contract: ${contract}, token id: ${tokenId}. Hash function id: ${hashFunctionId}`, ); const operationId = await this.operationIdService.generateOperationId( diff --git a/src/service/file-service.js b/src/service/file-service.js index 34c1c68c4..dc12a0456 100644 --- a/src/service/file-service.js +++ b/src/service/file-service.js @@ -191,6 +191,7 @@ class FileService { } getParentDirectory(filePath) { + this.logger.trace(`Parent directory: ${path.dirname(filePath)}`); return path.dirname(filePath); } } diff --git a/src/service/operation-id-service.js b/src/service/operation-id-service.js index 8331c067e..9aabd73f6 100644 --- a/src/service/operation-id-service.js +++ b/src/service/operation-id-service.js @@ -74,6 +74,10 @@ class OperationIdService { this.emitChangeEvent(status, operationId, blockchain, errorMessage, errorType); + this.logger.debug( + `Updated operation id status: ${status}. Operation id: ${operationId}, blockchain: ${blockchain}`, + ); + await this.repositoryModuleManager.updateOperationIdRecord(response, operationId); } @@ -102,7 +106,9 @@ class OperationIdService { } async cacheOperationIdData(operationId, data) { - this.logger.debug(`Caching data for operation id: ${operationId} in file`); + this.logger.debug( + `Caching data for operation id: ${operationId} in file. Data to be cached: ${data}`, + ); const operationIdCachePath = this.fileService.getOperationIdCachePath(); await this.fileService.writeContentsToFile( diff --git a/src/service/pending-storage-service.js b/src/service/pending-storage-service.js index 1269e760f..364fe6edb 100644 --- a/src/service/pending-storage-service.js +++ b/src/service/pending-storage-service.js @@ -36,6 +36,8 @@ class PendingStorageService { tokenId, ); + this.logger.debug(`Pending storage folder path: ${pendingStorageFolderPath}`); + await this.fileService.writeContentsToFile( pendingStorageFolderPath, assertionId, diff --git a/src/service/ual-service.js b/src/service/ual-service.js index f3f2b3526..895d48817 100644 --- a/src/service/ual-service.js +++ b/src/service/ual-service.js @@ -94,6 +94,11 @@ class UALService { tokenId, 0, )); + + this.logger.debug( + `Calculating location keyword for blockchain: ${blockchain}, contract ${contract}, assertion id: ${assertionId}`, + ); + return this.blockchainModuleManager.encodePacked( blockchain, ['address', 'bytes32'], From c6c1a08aa4e619fc64beeb055968785c0f3bbf1f Mon Sep 17 00:00:00 2001 From: Zvonimir Sculac Date: Tue, 1 Oct 2024 16:01:02 +0200 Subject: [PATCH 2/3] Add PR suggestions --- src/commands/local-store/local-store-command.js | 7 ------- .../update/receiver/delete-pending-state-command.js | 4 +++- src/service/file-service.js | 1 - src/service/operation-id-service.js | 8 +------- src/service/pending-storage-service.js | 2 -- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/commands/local-store/local-store-command.js b/src/commands/local-store/local-store-command.js index 0cfa92583..4a0aa82b3 100644 --- a/src/commands/local-store/local-store-command.js +++ b/src/commands/local-store/local-store-command.js @@ -49,10 +49,6 @@ class LocalStoreCommand extends Command { if (storeType === LOCAL_STORE_TYPES.TRIPLE) { const storePromises = []; if (cachedData.public.assertion && cachedData.public.assertionId) { - this.logger.debug( - `Storing public assertion id: ${cachedData.public.assertionId}`, - ); - storePromises.push( this.tripleStoreService.localStoreAsset( TRIPLE_STORE_REPOSITORIES.PRIVATE_CURRENT, @@ -66,9 +62,6 @@ class LocalStoreCommand extends Command { ); } if (cachedData.private.assertion && cachedData.private.assertionId) { - this.logger.debug( - `Storing private assertion id: ${cachedData.private.assertionId}`, - ); storePromises.push( this.tripleStoreService.localStoreAsset( TRIPLE_STORE_REPOSITORIES.PRIVATE_CURRENT, diff --git a/src/commands/protocols/update/receiver/delete-pending-state-command.js b/src/commands/protocols/update/receiver/delete-pending-state-command.js index 1a8afdb86..94cf0fdc7 100644 --- a/src/commands/protocols/update/receiver/delete-pending-state-command.js +++ b/src/commands/protocols/update/receiver/delete-pending-state-command.js @@ -74,7 +74,9 @@ class DeletePendingStateCommand extends Command { } await this.deletePendingState(blockchain, contract, tokenId, assertionId, operationId); } - this.logger.trace(`No pending state found`); + this.logger.trace( + `No pending state found for operation id: ${operationId} and assertion id`, + ); return Command.empty(); } diff --git a/src/service/file-service.js b/src/service/file-service.js index dc12a0456..34c1c68c4 100644 --- a/src/service/file-service.js +++ b/src/service/file-service.js @@ -191,7 +191,6 @@ class FileService { } getParentDirectory(filePath) { - this.logger.trace(`Parent directory: ${path.dirname(filePath)}`); return path.dirname(filePath); } } diff --git a/src/service/operation-id-service.js b/src/service/operation-id-service.js index 9aabd73f6..99d8dc754 100644 --- a/src/service/operation-id-service.js +++ b/src/service/operation-id-service.js @@ -74,10 +74,6 @@ class OperationIdService { this.emitChangeEvent(status, operationId, blockchain, errorMessage, errorType); - this.logger.debug( - `Updated operation id status: ${status}. Operation id: ${operationId}, blockchain: ${blockchain}`, - ); - await this.repositoryModuleManager.updateOperationIdRecord(response, operationId); } @@ -106,9 +102,7 @@ class OperationIdService { } async cacheOperationIdData(operationId, data) { - this.logger.debug( - `Caching data for operation id: ${operationId} in file. Data to be cached: ${data}`, - ); + this.logger.trace(`Caching data for operation id: ${operationId} in file.`); const operationIdCachePath = this.fileService.getOperationIdCachePath(); await this.fileService.writeContentsToFile( diff --git a/src/service/pending-storage-service.js b/src/service/pending-storage-service.js index 364fe6edb..1269e760f 100644 --- a/src/service/pending-storage-service.js +++ b/src/service/pending-storage-service.js @@ -36,8 +36,6 @@ class PendingStorageService { tokenId, ); - this.logger.debug(`Pending storage folder path: ${pendingStorageFolderPath}`); - await this.fileService.writeContentsToFile( pendingStorageFolderPath, assertionId, From 5e402e1a524843ea3a7eb31bd3bfa21ba6ed3e53 Mon Sep 17 00:00:00 2001 From: Zvonimir Sculac Date: Tue, 1 Oct 2024 17:07:35 +0200 Subject: [PATCH 3/3] Extend logs for publish --- src/commands/protocols/common/find-nodes-command.js | 2 +- src/commands/protocols/common/protocol-message-command.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands/protocols/common/find-nodes-command.js b/src/commands/protocols/common/find-nodes-command.js index f11691fbd..268542d63 100644 --- a/src/commands/protocols/common/find-nodes-command.js +++ b/src/commands/protocols/common/find-nodes-command.js @@ -60,7 +60,7 @@ class FindNodesCommand extends Command { await this.handleError( operationId, blockchain, - `Unable to find enough nodes for operationId: ${operationId}, keyword: ${keyword}. Minimum number of nodes required: ${minAckResponses}`, + `Unable to find enough nodes for operationId: ${operationId}, keyword: ${keyword}. Minimum number of nodes required: ${minAckResponses}, number of nodes found: ${closestNodes.length}`, this.errorType, true, ); diff --git a/src/commands/protocols/common/protocol-message-command.js b/src/commands/protocols/common/protocol-message-command.js index b0ee5c48b..b0c2852fb 100644 --- a/src/commands/protocols/common/protocol-message-command.js +++ b/src/commands/protocols/common/protocol-message-command.js @@ -30,6 +30,10 @@ class ProtocolMessageCommand extends Command { const keywordUuid = uuidv5(keyword, uuidv5.URL); + this.logger.debug( + `Sending protocol message with operation id: ${operationId}, keyword uuidv5: ${keywordUuid}`, + ); + const response = await this.networkModuleManager.sendMessage( node.protocol, node.id, @@ -52,7 +56,7 @@ class ProtocolMessageCommand extends Command { default: await this.markResponseAsFailed( command, - `Received unknown message type from node during ${command.name}`, + `Received unknown message type from node during ${command.name}. Unknown message type: ${response.header.messageType}`, ); return Command.empty(); }