Skip to content

feat(client): add global max transaction fee configuration#2332

Open
tech0priyanshu wants to merge 7 commits into
hiero-ledger:mainfrom
tech0priyanshu:feat/add-client-set-max-transaction-fee
Open

feat(client): add global max transaction fee configuration#2332
tech0priyanshu wants to merge 7 commits into
hiero-ledger:mainfrom
tech0priyanshu:feat/add-client-set-max-transaction-fee

Conversation

@tech0priyanshu

@tech0priyanshu tech0priyanshu commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Description:
Adds support for configuring a global maximum transaction fee at the client level.

Related issue(s):

Fixes #2000

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@tech0priyanshu
tech0priyanshu requested review from a team as code owners June 3, 2026 20:21
@github-actions github-actions Bot added lang: python Uses Python programming language skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples labels Jun 3, 2026
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds client-level and transaction-level maximum fee setters, centralized fee coercion, and freeze-time precedence: explicit transaction fee, client default, then class default. Tests cover validation, serialization, round trips, mocked clients, and insufficient-fee handling.

Changes

Client and Transaction Max Fee Configuration

Layer / File(s) Summary
Client-level default max transaction fee
src/hiero_sdk_python/client/client.py, src/hiero_sdk_python/hbar.py, tests/unit/client_test.py, tests/unit/fee_estimate_query_test.py, tests/unit/file_append_transaction_test.py
Client adds a nullable default fee and fluent setter using Hbar._coerce_fee; inputs are type-checked and negative values rejected. Tests cover accepted inputs, errors, defaults, and mock-client configuration.
Transaction-level override and fee resolution
src/hiero_sdk_python/transaction/transaction.py, tests/unit/transaction_freeze_and_bytes_test.py, tests/integration/account_update_transaction_e2e_test.py
Transaction adds a validated fluent fee setter and resolves fees during freeze_with() using transaction, client, then class defaults. Tests cover serialization, round trips, precedence, and insufficient-fee exceptions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Developer
  participant Client
  participant Transaction
  participant TransactionBody
  Developer->>Client: set_max_transaction_fee value
  Client->>Client: validate and convert to Hbar
  Developer->>Transaction: set_max_transaction_fee value
  Transaction->>Transaction: validate and assign transaction_fee
  Developer->>Transaction: freeze_with client
  alt transaction fee is set
    Transaction->>TransactionBody: serialize explicit transaction fee
  else transaction fee is unset
    Transaction->>Client: read default_max_transaction_fee
    alt client default exists
      Transaction->>TransactionBody: serialize client default fee
    else no client default
      Transaction->>TransactionBody: serialize class default fee
    end
  end
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive Most issue requirements are covered, but the summary doesn't explicitly confirm the module default was changed to 2 Hbar. Confirm that _default_transaction_fee is set to 2 Hbar in transaction.py, or update the summary/tests to reflect that change.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding client-level max transaction fee configuration.
Description check ✅ Passed The description matches the changeset and correctly describes the new client-level max transaction fee support.
Out of Scope Changes check ✅ Passed The listed changes are focused on the fee feature and supporting tests, with only minor related formatting adjustments.
Docstring Coverage ✅ Passed Docstring coverage is 93.55% which is sufficient. The required threshold is 80.00%.
📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #2000

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5f52c8b9-6025-4004-85ec-a0350465b3be

📥 Commits

Reviewing files that changed from the base of the PR and between f2015e9 and 612e7a1.

📒 Files selected for processing (4)
  • src/hiero_sdk_python/client/client.py
  • src/hiero_sdk_python/transaction/transaction.py
  • tests/unit/client_test.py
  • tests/unit/transaction_freeze_and_bytes_test.py

Comment thread src/hiero_sdk_python/client/client.py Outdated
Comment thread src/hiero_sdk_python/client/client.py
Comment thread src/hiero_sdk_python/transaction/transaction.py Outdated
Comment thread src/hiero_sdk_python/transaction/transaction.py
Comment on lines +728 to +762
def test_fee_resolution_transaction_precedence(mock_client):
"""Transaction fee explicitly set should take precedence over client default."""
tx = TransferTransaction()
tx.set_max_transaction_fee(Hbar(10))

# client has different default
mock_client.set_max_transaction_fee(Hbar(5))

tx.freeze_with(mock_client)

assert tx.transaction_fee == Hbar(10)


def test_fee_resolution_client_default_used_when_transaction_missing(mock_client):
"""When transaction fee is not set, client.default_max_transaction_fee should be used."""
tx = TransferTransaction()
# leave tx.transaction_fee as None

mock_client.set_max_transaction_fee(Hbar(7))

tx.freeze_with(mock_client)

assert tx.transaction_fee == Hbar(7)


def test_fee_resolution_falls_back_to_transaction_default(mock_client):
"""When neither transaction nor client provide a fee, fallback to transaction default Hbar(1)."""
tx = TransferTransaction()
tx.set_transaction_id(TransactionId.generate(AccountId.from_string("0.0.1234")))
# Ensure client default is None
mock_client.default_max_transaction_fee = None

tx.freeze_with(mock_client)

assert tx.transaction_fee == 100000000 # Default fee for TransferTransaction

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add test coverage for fee resolution in single-node and multi-node paths.

The current tests (lines 728-762) only verify fee resolution when freeze_with(mock_client) uses the client's network nodes. Missing coverage: fee resolution when node_account_id or node_account_ids are explicitly set before freeze_with().

These additional test scenarios would catch the major issue flagged in transaction.py where the client's default_max_transaction_fee is bypassed in those code paths.

🧪 Proposed additional tests
def test_fee_resolution_with_explicit_node_account_id(mock_client):
    """Fee resolution should work when node_account_id is explicitly set."""
    tx = TransferTransaction()
    tx.node_account_id = AccountId(0, 0, 3)
    
    mock_client.set_max_transaction_fee(Hbar(7))
    
    tx.freeze_with(mock_client)
    
    # Should use client default, not transaction default
    assert tx.transaction_fee == Hbar(7)


def test_fee_resolution_with_explicit_node_account_ids(mock_client):
    """Fee resolution should work when node_account_ids list is explicitly set."""
    tx = TransferTransaction()
    tx.node_account_ids = [AccountId(0, 0, 3), AccountId(0, 0, 4)]
    
    mock_client.set_max_transaction_fee(Hbar(8))
    
    tx.freeze_with(mock_client)
    
    # Should use client default, not transaction default
    assert tx.transaction_fee == Hbar(8)

As per coding guidelines: "PRIORITY 3 - Comprehensive Coverage: Cover happy paths AND unhappy paths/edge cases."

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2332      +/-   ##
==========================================
+ Coverage   95.01%   95.02%   +0.01%     
==========================================
  Files         164      164              
  Lines       10464    10487      +23     
==========================================
+ Hits         9942     9965      +23     
  Misses        522      522              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

Hi, this is WorkflowBot.
Your pull request cannot be merged as it is not passing all our workflow checks.
Please click on each check to review the logs and resolve issues so all checks pass.
To help you:

@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review labels Jun 3, 2026
@tech0priyanshu
tech0priyanshu marked this pull request as draft June 4, 2026 06:12
@exploreriii exploreriii removed queue:junior-committer PR awaiting initial quality review open to community review PR is open for community review and feedback labels Jun 6, 2026
@tech0priyanshu
tech0priyanshu force-pushed the feat/add-client-set-max-transaction-fee branch from 612e7a1 to c7d3316 Compare June 8, 2026 16:36
@manishdait

Copy link
Copy Markdown
Contributor

@tech0priyanshu is this ready for review

@tech0priyanshu

Copy link
Copy Markdown
Contributor Author

need a bit time @tech0priyanshu

@tech0priyanshu
tech0priyanshu force-pushed the feat/add-client-set-max-transaction-fee branch from 749aad6 to 70637d1 Compare June 9, 2026 11:15
@tech0priyanshu
tech0priyanshu marked this pull request as ready for review June 9, 2026 11:43
@tech0priyanshu

Copy link
Copy Markdown
Contributor Author

pls review @manishdait @exploreriii

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 190c792b-bf8e-4549-9c44-2d9c78874f68

📥 Commits

Reviewing files that changed from the base of the PR and between 612e7a1 and 4b94571.

📒 Files selected for processing (7)
  • src/hiero_sdk_python/client/client.py
  • src/hiero_sdk_python/transaction/transaction.py
  • tests/integration/account_update_transaction_e2e_test.py
  • tests/unit/client_test.py
  • tests/unit/fee_estimate_query_test.py
  • tests/unit/file_append_transaction_test.py
  • tests/unit/transaction_freeze_and_bytes_test.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 190c792b-bf8e-4549-9c44-2d9c78874f68

📥 Commits

Reviewing files that changed from the base of the PR and between 612e7a1 and 4b94571.

📒 Files selected for processing (7)
  • src/hiero_sdk_python/client/client.py
  • src/hiero_sdk_python/transaction/transaction.py
  • tests/integration/account_update_transaction_e2e_test.py
  • tests/unit/client_test.py
  • tests/unit/fee_estimate_query_test.py
  • tests/unit/file_append_transaction_test.py
  • tests/unit/transaction_freeze_and_bytes_test.py
🛑 Comments failed to post (1)
src/hiero_sdk_python/transaction/transaction.py (1)

489-493: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Explicit zero fee is overwritten by default fee.

Line 489 and Line 517 use truthy fallback (self._transaction_fee or self._default_transaction_fee). If fee is explicitly set to 0, serialization silently falls back to the default fee, so zero-fee configuration is ignored.

💡 Suggested fix
-        fee = self._transaction_fee or self._default_transaction_fee
+        fee = self._transaction_fee if self._transaction_fee is not None else self._default_transaction_fee
         if hasattr(fee, "to_tinybars"):
             transaction_body.transactionFee = int(fee.to_tinybars())
         else:
             transaction_body.transactionFee = int(fee)
...
-        fee = self._transaction_fee or self._default_transaction_fee
+        fee = self._transaction_fee if self._transaction_fee is not None else self._default_transaction_fee
         if hasattr(fee, "to_tinybars"):
             schedulable_body.transactionFee = int(fee.to_tinybars())
         else:
             schedulable_body.transactionFee = int(fee)

Also applies to: 517-521

@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review labels Jun 9, 2026
@tech0priyanshu tech0priyanshu removed queue:junior-committer PR awaiting initial quality review open to community review PR is open for community review and feedback labels Jun 9, 2026
@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review labels Jun 9, 2026
@aceppaluni

Copy link
Copy Markdown
Contributor

@tech0priyanshu Is this ready for review again?

@tech0priyanshu
tech0priyanshu force-pushed the feat/add-client-set-max-transaction-fee branch from 4b94571 to 2a22053 Compare June 16, 2026 07:34
@github-actions

Copy link
Copy Markdown

Hello, this is the OfficeHourBot.

This is a reminder that the Hiero Python SDK Office Hours will begin in approximately 2 hours and 28 minutes (14:00 UTC).

This session provides an opportunity to ask questions regarding this Pull Request.

Details:

Disclaimer: This is an automated reminder. Please verify the schedule here for any changes.

From,
The Python SDK Team

@exploreriii

Copy link
Copy Markdown
Contributor

Hi @tech0priyanshu let us know please when this is ready to review again, thanks

@tech0priyanshu
tech0priyanshu force-pushed the feat/add-client-set-max-transaction-fee branch from 2a22053 to ed12851 Compare June 18, 2026 10:43
@github-actions

Copy link
Copy Markdown

Hi @tech0priyanshu,

This pull request has had no commit activity for 10 days. Are you still working on it?
To keep the PR active, you can:

  • Push a new commit.
  • Comment /working on the linked issue (not this PR).

If you're no longer working on this, please comment /unassign on the linked issue to release it for others. Otherwise, this PR may be closed due to inactivity.

Reach out on discord or join our office hours if you need assistance.

From the Python SDK Team

@aceppaluni aceppaluni added the status: update branch developer needs to click update branch label Jun 21, 2026
@tech0priyanshu
tech0priyanshu force-pushed the feat/add-client-set-max-transaction-fee branch 2 times, most recently from 81b0ce8 to 66bcc5b Compare June 24, 2026 09:44
@tech0priyanshu
tech0priyanshu force-pushed the feat/add-client-set-max-transaction-fee branch from 66bcc5b to fb4d6fe Compare June 30, 2026 09:36
@exploreriii

Copy link
Copy Markdown
Contributor

Hi @tech0priyanshu I see you've been making some changes, but it is still marked in draft. Let us know when it is ready to review again. Thank you

@exploreriii exploreriii removed status: update branch developer needs to click update branch status: Needs Developer Revision Author needs to apply suggested changes/improvements labels Jul 10, 2026
@github-actions

Copy link
Copy Markdown

Hi @tech0priyanshu,

This pull request has had no activity for 11 days. Are you still working on it?
To keep the PR active, you can:

  • Push a new commit.
  • Comment /working on the linked issue (not this PR).

If you're no longer working on this, please comment /unassign on the linked issue to release it for others. Otherwise, this PR may be closed due to inactivity.

Reach out on discord or join our office hours if you need assistance.

From the Python SDK Team

@aceppaluni aceppaluni added the status: update branch developer needs to click update branch label Jul 13, 2026
@aceppaluni

Copy link
Copy Markdown
Contributor

@tech0priyanshu Can you comment /working on issue #2000 or push a new commit so you are not unassigned from the issue?

Thank you!

@tech0priyanshu

tech0priyanshu commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@aceppaluni Thanks for reminding me

@tech0priyanshu
tech0priyanshu force-pushed the feat/add-client-set-max-transaction-fee branch from 835e87e to c744af3 Compare July 20, 2026 05:36
Signed-off-by: tech0priyanshu <priyanshuyadv101106@gmail.com>
Signed-off-by: tech0priyanshu <priyanshuyadv101106@gmail.com>
Signed-off-by: tech0priyanshu <priyanshuyadv101106@gmail.com>
Signed-off-by: tech0priyanshu <priyanshuyadv101106@gmail.com>
Signed-off-by: tech0priyanshu <priyanshuyadv101106@gmail.com>
Signed-off-by: tech0priyanshu <priyanshuyadv101106@gmail.com>
Signed-off-by: tech0priyanshu <priyanshuyadv101106@gmail.com>
@tech0priyanshu
tech0priyanshu force-pushed the feat/add-client-set-max-transaction-fee branch from 61ad8dd to 4c5eddd Compare July 20, 2026 11:21
@tech0priyanshu
tech0priyanshu marked this pull request as ready for review July 20, 2026 12:57

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 831231de-bb64-4c60-b8f9-e3271963bc1d

📥 Commits

Reviewing files that changed from the base of the PR and between 4b94571 and 4c5eddd.

📒 Files selected for processing (8)
  • src/hiero_sdk_python/client/client.py
  • src/hiero_sdk_python/hbar.py
  • src/hiero_sdk_python/transaction/transaction.py
  • tests/integration/account_update_transaction_e2e_test.py
  • tests/unit/client_test.py
  • tests/unit/fee_estimate_query_test.py
  • tests/unit/file_append_transaction_test.py
  • tests/unit/transaction_freeze_and_bytes_test.py

Comment on lines +311 to +316
if self.transaction_fee is None:
if client is not None and getattr(client, "default_max_transaction_fee", None) is not None:
self.transaction_fee = client.default_max_transaction_fee
else:
self.transaction_fee = self._default_transaction_fee

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Explicit max fees of 0 are ignored during serialization.

While the fee resolution correctly supports assigning a 0 fee (e.g. client.default_max_transaction_fee = Hbar(0)), a pre-existing bug in the unchanged build_base_transaction_body() and build_base_scheduled_body() methods will silently override it:

# In build_base_transaction_body() and build_base_scheduled_body()
fee = self._transaction_fee or self._default_transaction_fee

Since 0 evaluates to falsy in Python, an explicitly resolved fee of 0 will fallback to self._default_transaction_fee (Hbar(2)).

Consider updating the unchanged methods to use a strict None check to ensure explicit 0 fees are respected:

fee = self._transaction_fee if self._transaction_fee is not None else self._default_transaction_fee

@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review labels Jul 20, 2026
transaction_body, signed_transaction.bodyBytes, signed_transaction.sigMap
)

def set_max_transaction_fee(self, max_transaction_fee):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: Add a docstring here

# For each node, set the node_account_id and build the transaction body
# This allows the transaction to be submitted to any node in the network

# Use all nodes from client network

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this comment be placed before line 336 instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang: python Uses Python programming language open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples status: update branch developer needs to click update branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add global set_max_transaction_fee() to Client

4 participants