From 8583fb68c8390bd9310d2ec67a0bc9452525a164 Mon Sep 17 00:00:00 2001 From: IlijaMar Date: Sun, 15 Dec 2024 12:45:05 +0100 Subject: [PATCH 1/2] getBatchSize,getMinAckResponses functions use user provided values --- src/commands/local-store/local-store-command.js | 5 +++-- .../protocols/common/network-protocol-command.js | 7 ++++--- src/constants/constants.js | 14 ++++++++++++++ src/service/ask-service.js | 5 +++-- src/service/finality-service.js | 10 ++++++---- src/service/get-service.js | 10 ++++++---- src/service/publish-service.js | 8 +++++--- 7 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/commands/local-store/local-store-command.js b/src/commands/local-store/local-store-command.js index 113948f15..f027dd1db 100644 --- a/src/commands/local-store/local-store-command.js +++ b/src/commands/local-store/local-store-command.js @@ -40,6 +40,7 @@ class LocalStoreCommand extends Command { contract, tokenId, minimumNumberOfNodeReplications, + batchSize, } = command.data; try { @@ -233,14 +234,14 @@ class LocalStoreCommand extends Command { publisherNodeVS, ); - const batchSize = this.operationService.getBatchSize(); + const batchSizePar = this.operationService.getBatchSize(batchSize); const minAckResponses = this.operationService.getMinAckResponses( minimumNumberOfNodeReplications, ); const updatedData = { ...command.data, - batchSize, + batchSize: batchSizePar, minAckResponses, }; diff --git a/src/commands/protocols/common/network-protocol-command.js b/src/commands/protocols/common/network-protocol-command.js index d4a5e1394..8a2900514 100644 --- a/src/commands/protocols/common/network-protocol-command.js +++ b/src/commands/protocols/common/network-protocol-command.js @@ -17,11 +17,12 @@ class NetworkProtocolCommand extends Command { * @param command */ async execute(command) { - const { blockchain, operationId, minimumNumberOfNodeReplications } = command.data; + const { blockchain, operationId, minimumNumberOfNodeReplications, batchSize } = + command.data; this.operationIdService.emitChangeEvent(this.operationStartEvent, operationId, blockchain); - const batchSize = this.operationService.getBatchSize(); + const batchSizePar = this.operationService.getBatchSize(batchSize); const minAckResponses = this.operationService.getMinAckResponses( minimumNumberOfNodeReplications, ); @@ -36,7 +37,7 @@ class NetworkProtocolCommand extends Command { delay: 0, data: { ...command.data, - batchSize, + batchSize: batchSizePar, minAckResponses, errorType: this.errorType, }, diff --git a/src/constants/constants.js b/src/constants/constants.js index 77aa55edc..d1b6ce912 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -7,6 +7,20 @@ export const HTTP_RPC_PROVIDER_PRIORITY = 1; export const FALLBACK_PROVIDER_QUORUM = 1; +export const PUBLISH_SERVICE_BATCHSIZE = 20; + +export const PUBLISH_SERVICE_MIN_NUM_OF_NODE_REP = 10; + +export const GET_SERVICE_BATCHSIZE = 2; + +export const GET_SERVICE_MIN_NUM_OF_NODE_REP = 1; + +export const FINALITY_SERVICE_BATCHSIZE = 1; + +export const FINALITY_SERVICE_MIN_NUM_OF_NODE_REP = 1; + +export const ASK_SERVICE_BATCHSIZE = 20; + export const RPC_PROVIDER_STALL_TIMEOUT = 60 * 1000; export const UINT256_MAX_BN = ethers.constants.MaxUint256; diff --git a/src/service/ask-service.js b/src/service/ask-service.js index e0e2d243d..23d678c21 100644 --- a/src/service/ask-service.js +++ b/src/service/ask-service.js @@ -6,6 +6,7 @@ import { ERROR_TYPE, OPERATIONS, OPERATION_REQUEST_STATUS, + ASK_SERVICE_BATCHSIZE, } from '../constants/constants.js'; class AskService extends OperationService { @@ -102,8 +103,8 @@ class AskService extends OperationService { } } - getBatchSize() { - return 20; + getBatchSize(batchSize = null) { + return batchSize ?? ASK_SERVICE_BATCHSIZE; } } diff --git a/src/service/finality-service.js b/src/service/finality-service.js index 790e47163..2d5fd58c9 100644 --- a/src/service/finality-service.js +++ b/src/service/finality-service.js @@ -6,6 +6,8 @@ import { ERROR_TYPE, OPERATIONS, OPERATION_REQUEST_STATUS, + FINALITY_SERVICE_BATCHSIZE, + FINALITY_SERVICE_MIN_NUM_OF_NODE_REP, } from '../constants/constants.js'; class FinalityService extends OperationService { @@ -71,12 +73,12 @@ class FinalityService extends OperationService { } } - getBatchSize() { - return 1; + getBatchSize(batchSize = null) { + return batchSize ?? FINALITY_SERVICE_BATCHSIZE; } - getMinAckResponses() { - return 1; + getMinAckResponses(minimumNumberOfNodeReplications = null) { + return minimumNumberOfNodeReplications ?? FINALITY_SERVICE_MIN_NUM_OF_NODE_REP; } } diff --git a/src/service/get-service.js b/src/service/get-service.js index c9ae427b6..309045d32 100644 --- a/src/service/get-service.js +++ b/src/service/get-service.js @@ -6,6 +6,8 @@ import { ERROR_TYPE, OPERATIONS, OPERATION_REQUEST_STATUS, + GET_SERVICE_BATCHSIZE, + GET_SERVICE_MIN_NUM_OF_NODE_REP, } from '../constants/constants.js'; class GetService extends OperationService { @@ -89,12 +91,12 @@ class GetService extends OperationService { } } - getBatchSize() { - return 2; + getBatchSize(batchSize = null) { + return batchSize ?? GET_SERVICE_BATCHSIZE; } - getMinAckResponses() { - return 1; + getMinAckResponses(minimumNumberOfNodeReplications = null) { + return minimumNumberOfNodeReplications ?? GET_SERVICE_MIN_NUM_OF_NODE_REP; } } diff --git a/src/service/publish-service.js b/src/service/publish-service.js index 99577fe57..09621413b 100644 --- a/src/service/publish-service.js +++ b/src/service/publish-service.js @@ -6,6 +6,8 @@ import { NETWORK_PROTOCOLS, ERROR_TYPE, OPERATIONS, + PUBLISH_SERVICE_BATCHSIZE, + PUBLISH_SERVICE_MIN_NUM_OF_NODE_REP, } from '../constants/constants.js'; class PublishService extends OperationService { @@ -100,12 +102,12 @@ class PublishService extends OperationService { } } - getBatchSize() { - return 20; + getBatchSize(batchSize = null) { + return batchSize ?? PUBLISH_SERVICE_BATCHSIZE; } getMinAckResponses(minimumNumberOfNodeReplications = null) { - return minimumNumberOfNodeReplications ?? 10; + return minimumNumberOfNodeReplications ?? PUBLISH_SERVICE_MIN_NUM_OF_NODE_REP; } } From 70dfb6613bddcab2a1b533ebb3af8e52476a056b Mon Sep 17 00:00:00 2001 From: IlijaMar Date: Mon, 16 Dec 2024 11:41:04 +0100 Subject: [PATCH 2/2] Code review changes --- src/constants/constants.js | 14 +++++++------- src/service/ask-service.js | 4 ++-- src/service/finality-service.js | 8 ++++---- src/service/get-service.js | 8 ++++---- src/service/publish-service.js | 8 ++++---- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/constants/constants.js b/src/constants/constants.js index d1b6ce912..1533943b7 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -7,19 +7,19 @@ export const HTTP_RPC_PROVIDER_PRIORITY = 1; export const FALLBACK_PROVIDER_QUORUM = 1; -export const PUBLISH_SERVICE_BATCHSIZE = 20; +export const PUBLISH_BATCH_SIZE = 20; -export const PUBLISH_SERVICE_MIN_NUM_OF_NODE_REP = 10; +export const PUBLISH_MIN_NUM_OF_NODE_REPLICATIONS = 3; -export const GET_SERVICE_BATCHSIZE = 2; +export const GET_BATCH_SIZE = 2; -export const GET_SERVICE_MIN_NUM_OF_NODE_REP = 1; +export const GET_MIN_NUM_OF_NODE_REPLICATIONS = 1; -export const FINALITY_SERVICE_BATCHSIZE = 1; +export const FINALITY_BATCH_SIZE = 1; -export const FINALITY_SERVICE_MIN_NUM_OF_NODE_REP = 1; +export const FINALITY_MIN_NUM_OF_NODE_REPLICATIONS = 1; -export const ASK_SERVICE_BATCHSIZE = 20; +export const ASK_BATCH_SIZE = 20; export const RPC_PROVIDER_STALL_TIMEOUT = 60 * 1000; diff --git a/src/service/ask-service.js b/src/service/ask-service.js index 23d678c21..450ca7693 100644 --- a/src/service/ask-service.js +++ b/src/service/ask-service.js @@ -6,7 +6,7 @@ import { ERROR_TYPE, OPERATIONS, OPERATION_REQUEST_STATUS, - ASK_SERVICE_BATCHSIZE, + ASK_BATCH_SIZE, } from '../constants/constants.js'; class AskService extends OperationService { @@ -104,7 +104,7 @@ class AskService extends OperationService { } getBatchSize(batchSize = null) { - return batchSize ?? ASK_SERVICE_BATCHSIZE; + return batchSize ?? ASK_BATCH_SIZE; } } diff --git a/src/service/finality-service.js b/src/service/finality-service.js index 2d5fd58c9..a39e2087b 100644 --- a/src/service/finality-service.js +++ b/src/service/finality-service.js @@ -6,8 +6,8 @@ import { ERROR_TYPE, OPERATIONS, OPERATION_REQUEST_STATUS, - FINALITY_SERVICE_BATCHSIZE, - FINALITY_SERVICE_MIN_NUM_OF_NODE_REP, + FINALITY_BATCH_SIZE, + FINALITY_MIN_NUM_OF_NODE_REPLICATIONS, } from '../constants/constants.js'; class FinalityService extends OperationService { @@ -74,11 +74,11 @@ class FinalityService extends OperationService { } getBatchSize(batchSize = null) { - return batchSize ?? FINALITY_SERVICE_BATCHSIZE; + return batchSize ?? FINALITY_BATCH_SIZE; } getMinAckResponses(minimumNumberOfNodeReplications = null) { - return minimumNumberOfNodeReplications ?? FINALITY_SERVICE_MIN_NUM_OF_NODE_REP; + return minimumNumberOfNodeReplications ?? FINALITY_MIN_NUM_OF_NODE_REPLICATIONS; } } diff --git a/src/service/get-service.js b/src/service/get-service.js index 309045d32..e7de8a066 100644 --- a/src/service/get-service.js +++ b/src/service/get-service.js @@ -6,8 +6,8 @@ import { ERROR_TYPE, OPERATIONS, OPERATION_REQUEST_STATUS, - GET_SERVICE_BATCHSIZE, - GET_SERVICE_MIN_NUM_OF_NODE_REP, + GET_BATCH_SIZE, + GET_MIN_NUM_OF_NODE_REPLICATIONS, } from '../constants/constants.js'; class GetService extends OperationService { @@ -92,11 +92,11 @@ class GetService extends OperationService { } getBatchSize(batchSize = null) { - return batchSize ?? GET_SERVICE_BATCHSIZE; + return batchSize ?? GET_BATCH_SIZE; } getMinAckResponses(minimumNumberOfNodeReplications = null) { - return minimumNumberOfNodeReplications ?? GET_SERVICE_MIN_NUM_OF_NODE_REP; + return minimumNumberOfNodeReplications ?? GET_MIN_NUM_OF_NODE_REPLICATIONS; } } diff --git a/src/service/publish-service.js b/src/service/publish-service.js index 09621413b..cfcab86bd 100644 --- a/src/service/publish-service.js +++ b/src/service/publish-service.js @@ -6,8 +6,8 @@ import { NETWORK_PROTOCOLS, ERROR_TYPE, OPERATIONS, - PUBLISH_SERVICE_BATCHSIZE, - PUBLISH_SERVICE_MIN_NUM_OF_NODE_REP, + PUBLISH_BATCH_SIZE, + PUBLISH_MIN_NUM_OF_NODE_REPLICATIONS, } from '../constants/constants.js'; class PublishService extends OperationService { @@ -103,11 +103,11 @@ class PublishService extends OperationService { } getBatchSize(batchSize = null) { - return batchSize ?? PUBLISH_SERVICE_BATCHSIZE; + return batchSize ?? PUBLISH_BATCH_SIZE; } getMinAckResponses(minimumNumberOfNodeReplications = null) { - return minimumNumberOfNodeReplications ?? PUBLISH_SERVICE_MIN_NUM_OF_NODE_REP; + return minimumNumberOfNodeReplications ?? PUBLISH_MIN_NUM_OF_NODE_REPLICATIONS; } }