Skip to content

Commit 62cb6b7

Browse files
feat: changing node accounts ids wip
Signed-off-by: venilinvasilev <[email protected]>
1 parent e93981e commit 62cb6b7

File tree

10 files changed

+647
-6
lines changed

10 files changed

+647
-6
lines changed

.github/workflows/build.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,62 @@ jobs:
169169
token: ${{ secrets.CODECOV_TOKEN }}
170170
fail_ci_if_error: true
171171

172+
dab-tests:
173+
name: DAB Tests using Node ${{ matrix.node }}
174+
runs-on: hiero-client-sdk-linux-medium
175+
strategy:
176+
matrix:
177+
node: [ "22" ]
178+
179+
steps:
180+
- name: Harden Runner
181+
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
182+
with:
183+
egress-policy: audit
184+
185+
- name: Checkout Code
186+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
187+
with:
188+
submodules: recursive
189+
190+
- name: Install Task
191+
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
192+
with:
193+
version: 3.35.1
194+
195+
- name: Install PNPM
196+
uses: step-security/action-setup@3d419c73e38e670dbffe349ffff26dd13c164640 # v4.2.0
197+
with:
198+
version: 9.15.5
199+
200+
- name: Setup Node
201+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
202+
with:
203+
node-version: ${{ matrix.node }}
204+
cache: pnpm
205+
206+
- name: Build @hashgraph/sdk
207+
id: build-sdk
208+
run: task build
209+
210+
- name: Prepare Hiero Solo
211+
id: solo
212+
uses: hiero-ledger/hiero-solo-action@2576140d0c1bb084c9be2ba59e82a4604c388e06 # branch: 75-add-support-for-multiple-consensus-nodes
213+
with:
214+
installMirrorNode: true
215+
hieroVersion: v0.68.1-rc.1
216+
dualMode: true
217+
218+
- name: Set Operator Account
219+
run: |
220+
echo "OPERATOR_KEY=${{ steps.solo.outputs.ed25519PrivateKey }}" >> $GITHUB_ENV
221+
echo "OPERATOR_ID=${{ steps.solo.outputs.ed25519AccountId }}" >> $GITHUB_ENV
222+
echo "HEDERA_NETWORK=local-node" >> $GITHUB_ENV
223+
224+
- name: Run DAB Integration Tests
225+
if: ${{ steps.build-sdk.conclusion == 'success' && !cancelled() && always() }}
226+
run: npx vitest --coverage --poolOptions.threads.singleThread --config=test/vitest-node-integration-dual-mode.config.ts NodeUpdateIntegrationTest.js
227+
172228
examples:
173229
name: Run examples using Node ${{ matrix.node }}
174230
runs-on: hiero-client-sdk-linux-medium

src/Executable.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,37 @@ 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: mark node as unusable
804+
// and update network to get latest node account IDs
805+
if (status === Status.InvalidNodeAccount) {
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+
try {
818+
await client.updateNetwork();
819+
console.log("VLIZAME W RETRAQ DGE");
820+
console.log(client._network.network);
821+
} catch (error) {
822+
if (this._logger) {
823+
const errorMessage =
824+
error instanceof Error
825+
? error.message
826+
: String(error);
827+
this._logger.trace(
828+
`failed to update client address book after INVALID_NODE_ACCOUNT_ID: ${errorMessage}`,
829+
);
830+
}
831+
}
832+
}
833+
803834
await delayForAttempt(
804835
isLocalNode,
805836
attempt,

src/Status.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ export default class Status {
742742
return "GRPC_WEB_PROXY_NOT_SUPPORTED";
743743
case Status.NftTransfersOnlyAllowedForNonFungibleUnique:
744744
return "NFT_TRANSFERS_ONLY_ALLOWED_FOR_NON_FUNGIBLE_UNIQUE";
745+
case Status.NodeAccountHasZeroBalance:
746+
return "NODE_ACCOUNT_HAS_ZERO_BALANCE";
745747
default:
746748
return `UNKNOWN (${this._code})`;
747749
}
@@ -1472,6 +1474,8 @@ export default class Status {
14721474
return Status.GrpcWebProxyNotSupported;
14731475
case 400:
14741476
return Status.NftTransfersOnlyAllowedForNonFungibleUnique;
1477+
case 526:
1478+
return Status.NodeAccountHasZeroBalance;
14751479
default:
14761480
throw new Error(
14771481
`(BUG) Status.fromCode() does not handle code: ${code}`,
@@ -3351,3 +3355,11 @@ Status.GrpcWebProxyNotSupported = new Status(399);
33513355
* An NFT transfers list referenced a token type other than NON_FUNGIBLE_UNIQUE.
33523356
*/
33533357
Status.NftTransfersOnlyAllowedForNonFungibleUnique = new Status(400);
3358+
3359+
/**
3360+
* This operation cannot be completed because the target
3361+
* account has a zero balance.<br/>
3362+
* Node accounts require a positive balance. The transaction may be
3363+
* resubmitted once the account has been funded.
3364+
*/
3365+
Status.NodeAccountHasZeroBalance = new Status(526);

src/client/Network.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,7 @@ export default class Network extends ManagedNetwork {
284284
if (this._maxNodesPerTransaction > 0) {
285285
return this._maxNodesPerTransaction;
286286
}
287-
// ultimately it does not matter if we round up or down
288-
// if we round up, we will eventually take one more healthy node for execution
289-
// and we would hit the 'nodes.length == count' check in _getNumberOfMostHealthyNodes() less often
290-
return this._nodes.length <= 9
291-
? this._nodes.length
292-
: Math.floor((this._nodes.length + 3 - 1) / 3);
287+
return this._healthyNodes.length;
293288
}
294289

295290
/**

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.InvalidNodeAccount:
19691970
return [status, ExecutionState.Retry];
19701971
case Status.Ok:
19711972
return [status, ExecutionState.Finished];

0 commit comments

Comments
 (0)