Skip to content

Commit 55e9bfb

Browse files
wip: changing node account ids
Signed-off-by: Ivaylo Nikolov <[email protected]>
1 parent e93981e commit 55e9bfb

11 files changed

+638
-3
lines changed

.env.sample

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ OPERATOR_KEY="302e020100300506032b6570042204202cc589a6343ff8d05b71edf54f69bff4cd
1414
# - previewnet: Connects to the Hedera preview network.
1515
# - local-node: Connects to a local Hedera node for development/testing.
1616
HEDERA_NETWORK="previewnet"
17+
18+
19+
NODE_ADMIN_KEY=302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137
20+
NODE_ADMIN_ID=0.0.2

src/Executable.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,33 @@ export default class Executable {
800800
// Determine by the executing state what we should do
801801
switch (shouldRetry) {
802802
case ExecutionState.Retry:
803+
// Special handling for INVALID_NODE_ACCOUNT_ID: mark node as unusable
804+
// and update network to get latest node account IDs
805+
if (status === Status.InvalidNodeAccountId) {
806+
if (this._logger) {
807+
this._logger.debug(
808+
`[${this._getLogId()}] node with accountId: ${node.accountId.toString()} and proxy IP: ${node.address.toString()} has invalid node account ID, marking as unhealthy and updating network`,
809+
);
810+
}
811+
812+
// Mark the node as unusable by increasing its backoff and removing it from the healthy nodes list
813+
client._network.increaseBackoff(node);
814+
815+
// Initiate addressbook query and update the client's network
816+
// This will make the SDK client have the latest node account IDs for subsequent transactions
817+
client.updateNetwork().catch((error) => {
818+
if (this._logger) {
819+
const errorMessage =
820+
error instanceof Error
821+
? error.message
822+
: String(error);
823+
this._logger.trace(
824+
`failed to update client address book after INVALID_NODE_ACCOUNT_ID: ${errorMessage}`,
825+
);
826+
}
827+
});
828+
}
829+
803830
await delayForAttempt(
804831
isLocalNode,
805832
attempt,

src/client/NativeClient.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,11 @@ export default class NativeClient extends Client {
280280
const network = {};
281281
for (const nodeAddress of addressBook.nodeAddresses) {
282282
for (const endpoint of nodeAddress.addresses) {
283-
if (nodeAddress.accountId != null) {
283+
// Exclude nodes with account ID 0.0.0 (removed node account IDs)
284+
if (
285+
nodeAddress.accountId != null &&
286+
nodeAddress.accountId.toString() !== "0.0.0"
287+
) {
284288
network[endpoint.toString()] = nodeAddress.accountId;
285289
}
286290
}

src/client/Network.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ export default class Network extends ManagedNetwork {
6565
for (const nodeAddress of addressBook.nodeAddresses) {
6666
for (const endpoint of nodeAddress.addresses) {
6767
// TODO: We hard code ports too much, should fix
68-
if (endpoint.port === port && nodeAddress.accountId != null) {
68+
// Exclude nodes with account ID 0.0.0 (removed node account IDs)
69+
if (
70+
endpoint.port === port &&
71+
nodeAddress.accountId != null &&
72+
nodeAddress.accountId.toString() !== "0.0.0"
73+
) {
6974
network[endpoint.toString()] = nodeAddress.accountId;
7075
}
7176
}

src/client/WebClient.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,11 @@ export default class WebClient extends Client {
317317
const network = {};
318318
for (const nodeAddress of addressBook.nodeAddresses) {
319319
for (const endpoint of nodeAddress.addresses) {
320-
if (nodeAddress.accountId != null) {
320+
// Exclude nodes with account ID 0.0.0 (removed node account IDs)
321+
if (
322+
nodeAddress.accountId != null &&
323+
nodeAddress.accountId.toString() !== "0.0.0"
324+
) {
321325
network[endpoint.toString()] = nodeAddress.accountId;
322326
}
323327
}

src/transaction/Transaction.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,7 @@ export default class Transaction extends Executable {
19661966
case Status.Unknown:
19671967
case Status.PlatformTransactionNotCreated:
19681968
case Status.PlatformNotActive:
1969+
case Status.InvalidNodeAccountId:
19691970
return [status, ExecutionState.Retry];
19701971
case Status.Ok:
19711972
return [status, ExecutionState.Finished];

0 commit comments

Comments
 (0)