hiero-ledger / hiero-ledger/hiero-sdk-python

feat: Implement `ping` and `pingAll` methods in Client

Open
#2,607 7 comments 0 reactions 1 assignee Claimed by @AntonioCeppellini View on GitHub
approved lang: python scope: TCK skill: advanced
Dominant language
Python
Stars
63
Forks
298
Avg merge
3d 18h
Merged PRs (30d)
38

Description

**Problem**

The Python SDK currently does not implement `Client.ping()` / `Client.ping_all()`. According to the [AccountBalanceQuery deprecation proposal](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/proposals/account-balance-query-deprecation.md), the replacement probe must use `CryptoService/getAccountInfo` for account `0.0.2` with `ResponseType = COST_ANSWER`.

**Relationship to AccountBalanceQuery deprecation**

The Python SDK does not currently have `ping()` / `ping_all()`, so there is no existing SDK `AccountBalanceQuery` dependency to migrate.

For `AccountBalanceQuery` itself:

- **Stage 1:** emit a deprecation warning when the query is constructed.
- **Stage 2:** make execute() throw the deprecation error.

The TCK specification requires the [ClientPing](https://github.com/hiero-ledger/hiero-sdk-tck/blob/main/docs/test-specifications/crypto-service/ClientPing.md) suite to pass before the **TCK prerequisite for Stage 2** of #2525 `AccountBalanceQuery` deprecation tests are run. Therefore, this issue is also `TCK` prerequisite for `Stage 2`, even though the SDK level `AccountBalanceQuery` deprecation can be implemented independently.

**Proposed Solution**

1. SDK changes:

- [ ] Add `Client.ping(node_account_id)` and `Client.ping_all()` using a `AccountInfoQuery`, probe for account 0.0.2
```python
def ping(self, node_account_id: AccountId) -> None:
(
AccountInfoQuery()
.set_account_id(AccountId.from_string("0.0.2"))
.set_node_account_ids([node_account_id])
.get_cost(self)
)

def ping_all(self) -> None:
for node_account_id in self.get_node_account_ids():
self.ping(node_account_id)

```
- [ ] Deprecate the `AccountBalanceQuery` to raise warning with message when AccountBalanceQuery.execute() is called.
```txt
# message

warning: AccountBalanceQuery will stop working when the Hedera network removes the CryptoGetBalance endpoint (estimated September 2026, consensus node release 77). Use the mirror node REST API to retrieve account balances.
```
- [ ] Add relevant unit/e2e test for the above changes.

---

2. TCK changes

- [ ] Add `PingParams` following the [Spec](https://github.com/hiero-ledger/hiero-sdk-tck/blob/main/docs/test-specifications/crypto-service/ClientPing.md) to a `tck/param/` module.
- [ ] Add `ping` and `pingAll` handlers registered via `@rpc_method("ping")` / `@rpc_method("pingAll")` to `tck/handlers/` module.
- [ ] Valid the method by running it against the `hiero-sdk-tck`.

**Acceptance criteria**

- [ ] `ping` and `pingAll` registered and dispatchable
- [ ] Proxy capture shows a `CryptoService/getAccountInfo` COST_ANSWER probe of `0.0.2` and **no** `cryptoGetBalance` call
- [ ] `ping` targets exactly the requested node; `pingAll` probes every node in the network map exactly once
- [ ] Failed ping opens node backoff; successful ping resets it (spec tests 4–5)
- [ ] Spec error cases behave as specified (unreachable/invalid node)
- [ ] Unit tests added and the TCK `ClientPing` suite passes

**References**
- [TCK Spec](https://github.com/hiero-ledger/hiero-sdk-tck/blob/main/docs/test-specifications/crypto-service/ClientPing.md)
- [AccountBalanceQuery Deprecation proposal](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/proposals/account-balance-query-deprecation.md)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.