Skip to content

Commit c81c76a

Browse files
authored
fix: removed the custom ip address logic and '@hashgraph/proto' (#518)
Signed-off-by: instamenta <[email protected]>
1 parent f11af20 commit c81c76a

File tree

3 files changed

+1
-40
lines changed

3 files changed

+1
-40
lines changed

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"author": "Swirlds Labs",
3939
"license": "Apache2.0",
4040
"dependencies": {
41-
"@hashgraph/proto": "^2.15.0-beta.3",
4241
"@hashgraph/sdk": "^2.50.0",
4342
"@kubernetes/client-node": "^0.21.0",
4443
"@listr2/prompt-adapter-enquirer": "^2.0.11",

src/core/account_manager.mjs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
import * as HashgraphProto from '@hashgraph/proto'
1817
import * as Base64 from 'js-base64'
1918
import os from 'os'
2019
import * as constants from './constants.mjs'
@@ -626,43 +625,7 @@ export class AccountManager {
626625
async prepareAddressBookBase64 (namespace) {
627626
// fetch AddressBook
628627
const fileQuery = new FileContentsQuery().setFileId(FileId.ADDRESS_BOOK)
629-
let addressBookBytes = await fileQuery.execute(this._nodeClient)
630-
631-
/** @type {Map<string, NetworkNodeServices>} **/
632-
const networkNodeServicesMap = await this.getNodeServiceMap(namespace)
633-
634-
// ensure serviceEndpoint.ipAddressV4 value for all nodes in the addressBook is a 4 bytes array instead of string
635-
// See: https://github.com/hashgraph/hedera-protobufs/blob/main/services/basic_types.proto#L1309
636-
// TODO: with v0.53 will mirror node no longer need this and we can remove @hashgraph/proto: https://github.com/hashgraph/solo/issues/493
637-
const addressBook = HashgraphProto.proto.NodeAddressBook.decode(addressBookBytes)
638-
const hasAlphaRegEx = /[a-zA-Z]+/
639-
let modified = false
640-
for (const nodeAddress of addressBook.nodeAddress) {
641-
const address = nodeAddress.serviceEndpoint[0].ipAddressV4.toString()
642-
643-
if (hasAlphaRegEx.test(address)) {
644-
const nodeId = Templates.nodeIdFromFullyQualifiedNetworkSvcName(address)
645-
nodeAddress.serviceEndpoint[0].ipAddressV4 = Uint8Array.from(ip.toBuffer(networkNodeServicesMap.get(nodeId).nodeServiceClusterIp))
646-
nodeAddress.ipAddress = Uint8Array.from(ip.toBuffer(networkNodeServicesMap.get(nodeId).nodeServiceClusterIp))
647-
modified = true
648-
continue
649-
}
650-
// overwrite ipAddressV4 as 4 bytes array if required, unless there is alpha, which means it is a domain name
651-
if (nodeAddress.serviceEndpoint[0].ipAddressV4.byteLength !== 4) {
652-
const parts = address.split('.')
653-
654-
if (parts.length !== 4) {
655-
throw new FullstackTestingError(`expected node IP address to have 4 parts, found ${parts.length}: ${address}`)
656-
}
657-
658-
nodeAddress.serviceEndpoint[0].ipAddressV4 = Uint8Array.from(parts)
659-
modified = true
660-
}
661-
}
662-
663-
if (modified) {
664-
addressBookBytes = HashgraphProto.proto.NodeAddressBook.encode(addressBook).finish()
665-
}
628+
const addressBookBytes = await fileQuery.execute(this._nodeClient)
666629

667630
// convert addressBook into base64
668631
return Base64.encode(addressBookBytes)

0 commit comments

Comments
 (0)