From a98e5dd07f84d0f55f880987d62ff3ec8fdd1a9a Mon Sep 17 00:00:00 2001 From: instamenta Date: Wed, 28 Aug 2024 13:41:43 +0300 Subject: [PATCH] removed the custom ip address logic and '@hashgraph/proto' Signed-off-by: instamenta --- package-lock.json | 1 - package.json | 1 - src/core/account_manager.mjs | 39 +----------------------------------- 3 files changed, 1 insertion(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index e025d9a6a..6c4784285 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,6 @@ "win32" ], "dependencies": { - "@hashgraph/proto": "^2.15.0-beta.3", "@hashgraph/sdk": "^2.50.0", "@kubernetes/client-node": "^0.21.0", "@listr2/prompt-adapter-enquirer": "^2.0.11", diff --git a/package.json b/package.json index 60ce907f6..7b5cb79d5 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "author": "Swirlds Labs", "license": "Apache2.0", "dependencies": { - "@hashgraph/proto": "^2.15.0-beta.3", "@hashgraph/sdk": "^2.50.0", "@kubernetes/client-node": "^0.21.0", "@listr2/prompt-adapter-enquirer": "^2.0.11", diff --git a/src/core/account_manager.mjs b/src/core/account_manager.mjs index b1c13989e..dec20a943 100644 --- a/src/core/account_manager.mjs +++ b/src/core/account_manager.mjs @@ -14,7 +14,6 @@ * limitations under the License. * */ -import * as HashgraphProto from '@hashgraph/proto' import * as Base64 from 'js-base64' import os from 'os' import * as constants from './constants.mjs' @@ -626,43 +625,7 @@ export class AccountManager { async prepareAddressBookBase64 (namespace) { // fetch AddressBook const fileQuery = new FileContentsQuery().setFileId(FileId.ADDRESS_BOOK) - let addressBookBytes = await fileQuery.execute(this._nodeClient) - - /** @type {Map} **/ - const networkNodeServicesMap = await this.getNodeServiceMap(namespace) - - // ensure serviceEndpoint.ipAddressV4 value for all nodes in the addressBook is a 4 bytes array instead of string - // See: https://github.com/hashgraph/hedera-protobufs/blob/main/services/basic_types.proto#L1309 - // TODO: with v0.53 will mirror node no longer need this and we can remove @hashgraph/proto: https://github.com/hashgraph/solo/issues/493 - const addressBook = HashgraphProto.proto.NodeAddressBook.decode(addressBookBytes) - const hasAlphaRegEx = /[a-zA-Z]+/ - let modified = false - for (const nodeAddress of addressBook.nodeAddress) { - const address = nodeAddress.serviceEndpoint[0].ipAddressV4.toString() - - if (hasAlphaRegEx.test(address)) { - const nodeId = Templates.nodeIdFromFullyQualifiedNetworkSvcName(address) - nodeAddress.serviceEndpoint[0].ipAddressV4 = Uint8Array.from(ip.toBuffer(networkNodeServicesMap.get(nodeId).nodeServiceClusterIp)) - nodeAddress.ipAddress = Uint8Array.from(ip.toBuffer(networkNodeServicesMap.get(nodeId).nodeServiceClusterIp)) - modified = true - continue - } - // overwrite ipAddressV4 as 4 bytes array if required, unless there is alpha, which means it is a domain name - if (nodeAddress.serviceEndpoint[0].ipAddressV4.byteLength !== 4) { - const parts = address.split('.') - - if (parts.length !== 4) { - throw new FullstackTestingError(`expected node IP address to have 4 parts, found ${parts.length}: ${address}`) - } - - nodeAddress.serviceEndpoint[0].ipAddressV4 = Uint8Array.from(parts) - modified = true - } - } - - if (modified) { - addressBookBytes = HashgraphProto.proto.NodeAddressBook.encode(addressBook).finish() - } + const addressBookBytes = await fileQuery.execute(this._nodeClient) // convert addressBook into base64 return Base64.encode(addressBookBytes)