Skip to content

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

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

feat(client): add global max transaction fee configuration#2332
tech0priyanshu wants to merge 5 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

ℹ️ Recent 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

Walkthrough

Adds a client-level default_max_transaction_fee and fluent setter; adds a matching Transaction.set_max_transaction_fee() and updates freeze_with() to resolve max-fee precedence: transaction explicit → client default → class default. Tests updated/added to validate inputs, chaining, negative values, and freeze-time precedence.

Changes

Client and Transaction Max Fee Configuration

Layer / File(s) Summary
Client-level default max transaction fee
src/hiero_sdk_python/client/client.py, tests/unit/client_test.py, tests/unit/fee_estimate_query_test.py, tests/unit/file_append_transaction_test.py
Client introduces default_max_transaction_fee (initialized to None) and set_max_transaction_fee(...) with boolean rejection, type acceptance `int
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 set_max_transaction_fee(...) mirroring Client validation/coercion and updates freeze_with() to choose max fee by precedence: explicit transaction fee, then client.default_max_transaction_fee, then the class default _default_transaction_fee. Imports updated to include Decimal. Unit and integration tests exercise setter chaining, type coercion, negative-value handling, and freeze-time precedence across scenarios.

Sequence Diagram(s)

sequenceDiagram
  participant Developer
  participant Client
  participant Transaction
  participant TransactionBody
  Developer->>Client: set_max_transaction_fee value
  Client->>Client: validate input and convert to Hbar
  Developer->>Transaction: set_max_transaction_fee value
  Transaction->>Transaction: validate input and set transaction_fee
  Developer->>Transaction: freeze_with client
  alt transaction_fee is set
    Transaction->>TransactionBody: use explicit transaction fee
  else transaction_fee is not set
    Transaction->>Client: read default_max_transaction_fee
    alt client default exists
      Transaction->>TransactionBody: use client default fee
    else no client default
      Transaction->>TransactionBody: use class default fee
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a global max transaction fee configuration at the client level, which aligns with the primary objective.
Description check ✅ Passed The description is relevant to the changeset, mentioning the addition of global max transaction fee configuration at the client level and referencing issue #2000.
Linked Issues check ✅ Passed The PR implements all requirements from issue #2000: added default_max_transaction_fee field to Client, implemented set_max_transaction_fee() methods in both Client and Transaction, updated fee resolution precedence in freeze_with(), and maintained backward compatibility.
Out of Scope Changes check ✅ Passed All changes are within scope: client-level fee configuration, transaction-level fee setter, fee resolution logic updates, and corresponding unit/integration test coverage with necessary mock updates.
Docstring Coverage ✅ Passed Docstring coverage is 92.59% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📋 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 and usage tips.

@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.02%   95.03%           
=======================================
  Files         163      163           
  Lines       10473    10494   +21     
=======================================
+ Hits         9952     9973   +21     
  Misses        521      521           
🚀 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

Copy link
Copy Markdown
Contributor Author

Yeah 👍

Comment thread src/hiero_sdk_python/transaction/transaction.py Outdated
# 1. Explicit transaction fee (self.transaction_fee)
# 2. Client default_max_transaction_fee
# 3. Transaction class default (_default_transaction_fee)
if self.transaction_fee is None:

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.

Is it intentional that resolving the client default fee permanently mutates transaction_fee during freeze?

I believe a change may be required here as per issue.

Comment thread tests/unit/transaction_freeze_and_bytes_test.py
@aceppaluni aceppaluni added reviewer: maintainer PR needs a review from the maintainer team reviewer: committer request review help from a committer status: Needs Developer Revision Author needs to apply suggested changes/improvements status: update branch developer needs to click update branch labels Jun 9, 2026

@exploreriii exploreriii 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.

Hi @tech0priyanshu
Great work but we need to check for some inconsistencies as right now some parts can be handling 1 hbar and others 1 tinybar then should be looking pretty good. Really check up the typing

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.

Some of the logic here is quite complex, and duplicated elsewhere, which has also caused some typing curiosities

why not extract the fee calculation and place it e.g. in the hbar file?

self.default_max_transaction_fee = _coerce_fee(max_transaction_fee)

Then create

def _coerce_fee(value: int | float | Decimal | Hbar) -> Hbar:

and call that from the multiple points

Comment on lines 291 to +292

def set_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.

ideally can just call that same thing from the hbar class

Comment thread tests/unit/transaction_freeze_and_bytes_test.py
Comment thread tests/unit/transaction_freeze_and_bytes_test.py Outdated
Comment thread tests/unit/transaction_freeze_and_bytes_test.py Outdated
Comment thread tests/unit/transaction_freeze_and_bytes_test.py Outdated
Comment thread tests/unit/transaction_freeze_and_bytes_test.py Outdated
Comment thread tests/unit/transaction_freeze_and_bytes_test.py
Comment thread src/hiero_sdk_python/transaction/transaction.py
Comment thread src/hiero_sdk_python/transaction/transaction.py
@exploreriii exploreriii marked this pull request as draft June 14, 2026 09:19
@exploreriii exploreriii removed reviewer: maintainer PR needs a review from the maintainer team status: update branch developer needs to click update branch reviewer: committer request review help from a committer queue:junior-committer PR awaiting initial quality review open to community review PR is open for community review and feedback labels Jun 14, 2026
@tech0priyanshu

Copy link
Copy Markdown
Contributor Author

@exploreriii @aceppaluni Sorry I was busy last. But yeah, i try to update asap

@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
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 ed12851 to f3ceca8 Compare June 22, 2026 12:50
Signed-off-by: tech0priyanshu <priyanshuyadv101106@gmail.com>
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 skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples status: Needs Developer Revision Author needs to apply suggested changes/improvements 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