Skip to content

feat: Added Transaction size calculation methods#1795

Open
manishdait wants to merge 26 commits intohiero-ledger:mainfrom
manishdait:feat/tx-size
Open

feat: Added Transaction size calculation methods#1795
manishdait wants to merge 26 commits intohiero-ledger:mainfrom
manishdait:feat/tx-size

Conversation

@manishdait
Copy link
Copy Markdown
Contributor

@manishdait manishdait commented Feb 13, 2026

Description:
This PR introduces new helper properties to allow calculating transaction size prior to submission.

Added Properties

  • size: Returns the total encoded transaction size in bytes (including signatures).
  • body_size: Returns the encoded TransactionBody size in bytes.
  • body_size_all_chunks: Returns a list of encoded body sizes for each chunk in multi-chunk transactions (e.g., FileAppendTransaction, TopicMessageSubmitTransaction).

Changes Made

  • Added the new @property helpers:

    • size
    • body_size
    • body_size_all_chunks
  • Refactored freeze() to properly support chunked transaction size calculations

  • Fixed an issue in FileAppendTransaction.execute() cause due to improper indentation

  • Added comprehensive unit and e2e tests

Related issue(s):

Fixes #1794

Notes for reviewer:

Checklist

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 13, 2026

Codecov Report

❌ Patch coverage is 98.48485% with 1 line in your changes missing coverage. Please review.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1795      +/-   ##
==========================================
+ Coverage   93.68%   93.72%   +0.04%     
==========================================
  Files         145      145              
  Lines        9426     9456      +30     
==========================================
+ Hits         8831     8863      +32     
+ Misses        595      593       -2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown

Hi, this is MergeConflictBot.
Your pull request cannot be merged because it contains merge conflicts.

Please resolve these conflicts locally and push the changes.

Quick Fix for CHANGELOG.md Conflicts

If your conflict is only in CHANGELOG.md, you can resolve it easily using the GitHub web editor:

  1. Click on the "Resolve conflicts" button in the PR
  2. Accept both changes (keep both changelog entries)
  3. Click "Mark as resolved"
  4. Commit the merge

For all other merge conflicts, please read:

Thank you for contributing!

@github-actions
Copy link
Copy Markdown

Hi @manishdait,

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 9, 2026

Hi @manishdait, this is InactivityBot 👋

This pull request has had no new commits for 21 days, so I'm closing it and unassigning you from the linked issue to keep the backlog healthy.

If you're no longer interested, no action is needed.

Tip: You can comment /unassign on any issue to proactively step away before this bot kicks in.

If you'd like to continue working on this later, feel free to comment /assign on the issue to get re-assigned, and open a new PR when you're ready. 🚀

@github-actions github-actions Bot closed this Mar 9, 2026
@manishdait manishdait reopened this Mar 10, 2026
@github-actions
Copy link
Copy Markdown

Hi @manishdait, this is InactivityBot 👋

This pull request has had no new commits for 22 days, so I'm closing it and unassigning you from the linked issue to keep the backlog healthy.

If you're no longer interested, no action is needed.

Tip: You can comment /unassign on any issue to proactively step away before this bot kicks in.

If you'd like to continue working on this later, feel free to comment /assign on the issue to get re-assigned, and open a new PR when you're ready. 🚀

@github-actions
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:

@manishdait manishdait force-pushed the feat/tx-size branch 2 times, most recently from fbac757 to 1489840 Compare March 22, 2026 08:00
@manishdait manishdait marked this pull request as ready for review March 23, 2026 17:29
@manishdait manishdait requested review from a team as code owners March 23, 2026 17:29
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 23, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds transaction size calculation properties (size, body_size, body_size_all_chunks), centralizes transaction ID and node resolution during freeze, adjusts multi-chunk freeze behavior, introduces tests validating sizing/chunking, and updates CHANGELOG.

Changes

Cohort / File(s) Summary
Core transaction logic
src/hiero_sdk_python/transaction/transaction.py
Added size and body_size properties; freeze() delegates to freeze_with(None); new helpers _resolve_transaction_id and _resolve_node_ids; tightened freeze validation; build_transaction_body() annotated.
File append multi-chunk
src/hiero_sdk_python/file/file_append_transaction.py
freeze_with simplified to rely on parent freeze and to ensure _transaction_ids generation; added body_size_all_chunks property that iterates chunks by temporarily swapping transaction_id; minor TYPE_CHECKING import change.
Topic message multi-chunk
src/hiero_sdk_python/consensus/topic_message_submit_transaction.py
freeze_with now resolves transaction IDs unconditionally when needed; added body_size_all_chunks property to collect per-chunk body_size by temporarily mutating transaction_id and restoring state.
Node / channel plumbing
src/hiero_sdk_python/node.py
Added a debug print emitting _node_pem_cert when root certificates exist in _get_channel().
Tests — unit
tests/unit/transaction_test.py, tests/unit/topic_message_submit_transaction_test.py, tests/unit/mock_server.py
Added sizing and chunking tests and fixtures; new freeze-related unit test; mock server port retry behavior changed and TLS handling moved to network-level with additional per-node overrides.
Tests — integration
tests/integration/file_append_transaction_e2e_test.py, tests/integration/topic_message_submit_transaction_e2e_test.py
Added E2E tests that manually set TransactionId/NodeAccountId, call .freeze(), sign/execute multi-chunk FileAppend and TopicMessageSubmit flows, and assert expected ledger state.
Changelog
CHANGELOG.md
Added Unreleased entry documenting new transaction size properties: size, body_size, and body_size_all_chunks.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client
participant Transaction
participant Node
participant Ledger
Client->>Transaction: configure (payload, chunk_size, optional ids)
Client->>Transaction: freeze_with(client)
Transaction->>Transaction: _resolve_transaction_id(client) / _resolve_node_ids(client)
Transaction->>Transaction: build per-chunk TransactionBody (compute body_size / size)
Transaction->>Node: assign/send signed transaction chunk(s)
Node->>Ledger: submit transaction chunk(s)
Ledger-->>Node: return receipt(s)
Node-->>Client: return execution result

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive Most changes are directly scoped to transaction size calculation. However, modifications to mock_server.py (TLS setup refactoring) and node.py (debug print statement) appear tangential to the primary objective. Clarify whether TLS/mock server and debug logging changes in node.py are necessary for the size calculation feature or should be in separate pull requests.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main feature addition—transaction size calculation methods—and clearly summarizes the primary changeset.
Description check ✅ Passed The description is directly related to the changeset, explaining the new properties added, refactoring performed, and tests included.
Linked Issues check ✅ Passed All three required properties (size, body_size, body_size_all_chunks) are implemented across Transaction and its subclasses, with comprehensive unit and integration tests validating the functionality.
Docstring Coverage ✅ Passed Docstring coverage is 90.70% which is sufficient. The required threshold is 80.00%.

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

✨ 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/hiero_sdk_python/transaction/transaction.py (1)

419-432: ⚠️ Potential issue | 🟠 Major

Return type of build_transaction_body() must be transaction_pb2.TransactionBody.

Line 419 declares the return type as transaction_pb2.Transaction, but the docstring and all subclass implementations use transaction_pb2.TransactionBody. This creates a type contract violation: every subclass override (transfer_transaction.py, batch_transaction.py, etc.) declares TransactionBody, making them incompatible with the base signature.

Suggested fix
-    def build_transaction_body(self) -> transaction_pb2.Transaction:
+    def build_transaction_body(self) -> transaction_pb2.TransactionBody:
src/hiero_sdk_python/consensus/topic_message_submit_transaction.py (1)

273-287: ⚠️ Potential issue | 🔴 Critical

BLOCKER: carry seconds when chunk valid_start.nanos overflows.

Lines 280-283 add i directly to base_timestamp.nanos without checking for overflow. Protobuf Timestamp.nanos must be in the range [0, 999_999_999]. With the default max_chunks=20, if a transaction is created with a valid_start near the end of a second (e.g., nanos=999_999_980), chunk indices approaching 20 will cause the nanos value to exceed the valid range, resulting in invalid or rejected transaction IDs on the network.

Suggested fix
-                    chunk_valid_start = timestamp_pb2.Timestamp(
-                        seconds=base_timestamp.seconds,
-                        nanos=base_timestamp.nanos + i
-                    )
+                    total_nanos = base_timestamp.nanos + i
+                    chunk_valid_start = timestamp_pb2.Timestamp(
+                        seconds=base_timestamp.seconds + total_nanos // 1_000_000_000,
+                        nanos=total_nanos % 1_000_000_000,
+                    )

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9f37e713-f101-4e75-99e8-ac95e67c3a50

📥 Commits

Reviewing files that changed from the base of the PR and between 2898bf9 and 1489840.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • src/hiero_sdk_python/consensus/topic_message_submit_transaction.py
  • src/hiero_sdk_python/file/file_append_transaction.py
  • src/hiero_sdk_python/transaction/transaction.py
  • tests/integration/file_append_transaction_e2e_test.py
  • tests/integration/topic_message_submit_transaction_e2e_test.py
  • tests/unit/topic_message_submit_transaction_test.py
  • tests/unit/transaction_test.py

Comment thread src/hiero_sdk_python/consensus/topic_message_submit_transaction.py
Comment thread src/hiero_sdk_python/file/file_append_transaction.py
Comment thread src/hiero_sdk_python/file/file_append_transaction.py
Comment thread src/hiero_sdk_python/transaction/transaction.py
Comment thread tests/integration/file_append_transaction_e2e_test.py
Comment thread tests/unit/transaction_test.py
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

♻️ Duplicate comments (6)
src/hiero_sdk_python/transaction/transaction.py (1)

261-261: ⚠️ Potential issue | 🔴 Critical

Don't route freeze() through subclass freeze_with(None).

This now dispatches manual freezing into every override with client=None. TokenCreateTransaction.freeze_with() still reads client.operator_account_id before delegating when auto_renew_period is set, so freeze() can now raise AttributeError on that path. Keep freeze() on a non-virtual path, or make every override null-safe before it touches client.

As per coding guidelines: Any change to public methods (freeze, freeze_with, sign, execute, to_bytes, from_bytes, etc.) includes backwards-compatibility analysis.

src/hiero_sdk_python/file/file_append_transaction.py (2)

300-314: ⚠️ Potential issue | 🔴 Critical

Carry nanosecond overflow into seconds for later chunks.

base_timestamp.nanos + i can exceed 999_999_999, which produces an invalid protobuf timestamp for the chunk transaction ID. Multi-chunk append near a second boundary will then fail to freeze or submit correctly.

🛠️ Proposed fix
-                    chunk_valid_start = timestamp_pb2.Timestamp(
-                        seconds=base_timestamp.seconds,
-                        nanos=base_timestamp.nanos + i
-                    )
+                    total_nanos = base_timestamp.nanos + i
+                    chunk_valid_start = timestamp_pb2.Timestamp(
+                        seconds=base_timestamp.seconds + total_nanos // 1_000_000_000,
+                        nanos=total_nanos % 1_000_000_000,
+                    )
As per coding guidelines: `valid_start timestamps for each chunk are spaced out correctly (e.g., incremented by at least 1 nanosecond)`.

470-478: ⚠️ Potential issue | 🟠 Major

Advance _current_chunk_index while computing body_size_all_chunks.

body_size slices self.contents using _current_chunk_index, but this loop only swaps transaction_id. Every entry is therefore measured against the same chunk payload, so a shorter final chunk reports the wrong size.

🛠️ Proposed fix
-        for transaction_id in self._transaction_ids:
-            self.transaction_id = transaction_id
-            sizes.append(self.body_size)
-        
-        self._current_chunk_index = original_index
-        self.transaction_id = original_transaction_id
-        return sizes
+        try:
+            for index, transaction_id in enumerate(self._transaction_ids):
+                self._current_chunk_index = index
+                self.transaction_id = transaction_id
+                sizes.append(self.body_size)
+            return sizes
+        finally:
+            self._current_chunk_index = original_index
+            self.transaction_id = original_transaction_id
src/hiero_sdk_python/consensus/topic_message_submit_transaction.py (1)

434-442: ⚠️ Potential issue | 🟠 Major

MAJOR: body_size_all_chunks never advances _current_index.

Both the message slice and chunkInfo.number depend on _current_index, but this loop only swaps transaction_id. As written, every entry is measured against the same chunk, so the returned size list is wrong for multi-chunk messages.

🛠️ Proposed fix
-        for transaction_id in self._transaction_ids:
-            self.transaction_id = transaction_id
-            sizes.append(self.body_size)
-        
-        self._current_index = original_index
-        self.transaction_id = original_transaction_id
-        return sizes
+        try:
+            for index, transaction_id in enumerate(self._transaction_ids):
+                self._current_index = index
+                self.transaction_id = transaction_id
+                sizes.append(self.body_size)
+            return sizes
+        finally:
+            self._current_index = original_index
+            self.transaction_id = original_transaction_id
tests/integration/file_append_transaction_e2e_test.py (1)

328-339: ⚠️ Potential issue | 🟠 Major

This "manual freeze" test still exercises freeze_with().

The test name says manual freeze, but it uses freeze_with(env.client) and leaves a debug print() / commented sign call behind. That misses the regression surface this PR is trying to cover.

🛠️ Proposed fix
+    node_account_id = env.client.network.nodes[0]._account_id
     tx = (
         FileAppendTransaction()
         .set_file_id(file_id)
         .set_chunk_size(1024)
         .set_contents(content)
-        .freeze_with(env.client)
+        .set_transaction_id(TransactionId.generate(env.client.operator_account_id))
+        .set_node_account_id(node_account_id)
+        .freeze()
     )
-
-    # tx.sign(env.client.operator_private_key)
-
-    print(tx.get_required_chunks())
+    tx.sign(env.client.operator_private_key)
As per coding guidelines: `Tests should be end-to-end: construct → freeze → sign → execute → verify`.
tests/unit/transaction_test.py (1)

282-406: ⚠️ Potential issue | 🟠 Major

Chunk-sizing tests still miss high-risk regressions

These cases can still pass with incorrect implementations: Lines 285 and 322 use exact multiples (no short final chunk), and Line 376 relies on implicit defaults (without explicit set_chunk_size, chunking may not occur at all). Add at least one non-multiple payload and assert the last chunk body size differs.

Suggested test hardening
 def test_file_append_chunk_tx_should_return_list_of_body_sizes(file_id, account_id, transaction_id):
     """Test file append tx should return array of body sizes for multi-chunk transaction."""
     chunk_size = 1024
-    content = "a" * (chunk_size * 3)
+    content = "a" * (chunk_size * 2 + 137)  # force a short final chunk

@@
     sizes = tx.body_size_all_chunks
     assert isinstance(sizes, list)
     assert len(sizes) == 3
+    assert all(isinstance(s, int) and s > 0 for s in sizes)
+    assert sizes[-1] < sizes[0], "Final chunk should be smaller for non-multiple payload"


 def test_message_submit_chunk_tx_should_return_list_of_body_sizes(topic_id, account_id, transaction_id):
@@
     chunk_size = 1024
-    message= "a" * (chunk_size * 3)
+    message = "a" * (chunk_size * 2 + 137)

@@
     sizes = tx.body_size_all_chunks
     assert isinstance(sizes, list)
     assert len(sizes) == 3
+    assert all(isinstance(s, int) and s > 0 for s in sizes)
+    assert sizes[-1] < sizes[0], "Final chunk should be smaller for non-multiple payload"


 def test_chunked_tx_return_proper_sizes(file_id, account_id, transaction_id):
@@
     large_tx = (
         FileAppendTransaction()
         .set_file_id(file_id)
+        .set_chunk_size(1024)
         .set_contents(large_content)
@@
     )
+    assert len(large_tx.body_size_all_chunks) > 1, "Expected multi-chunk transaction"

@@
     small_tx = (
         FileAppendTransaction()
         .set_file_id(file_id)
+        .set_chunk_size(1024)
         .set_contents(small_content)

As per coding guidelines: Unit tests should be extensive - test even if we don't expect users to use it currently.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5c5fae07-ce46-46cd-8e61-093dfc735866

📥 Commits

Reviewing files that changed from the base of the PR and between 1489840 and 2a2bd41.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • src/hiero_sdk_python/consensus/topic_message_submit_transaction.py
  • src/hiero_sdk_python/file/file_append_transaction.py
  • src/hiero_sdk_python/transaction/transaction.py
  • tests/integration/file_append_transaction_e2e_test.py
  • tests/integration/topic_message_submit_transaction_e2e_test.py
  • tests/unit/mock_server.py
  • tests/unit/topic_message_submit_transaction_test.py
  • tests/unit/transaction_test.py

Comment thread src/hiero_sdk_python/consensus/topic_message_submit_transaction.py Outdated
Comment thread src/hiero_sdk_python/file/file_append_transaction.py Outdated
Comment thread src/hiero_sdk_python/transaction/transaction.py Outdated
Comment thread src/hiero_sdk_python/transaction/transaction.py
Comment thread tests/integration/topic_message_submit_transaction_e2e_test.py
Comment thread tests/unit/mock_server.py Outdated
Comment on lines +643 to +652
def test_topic_submit_message_raises_error_on_freeze(topic_id):
"""Test transaction raises error on freeze when the transaction_id and node_id not set"""
tx = (
TopicMessageSubmitTransaction()
.set_topic_id(topic_id)
.set_message("Hello Hiero")
)

with pytest.raises(ValueError):
tx.freeze()
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.

⚠️ Potential issue | 🟡 Minor

Match the expected failure reason in this test.

A bare pytest.raises(ValueError) will also pass on unrelated validation failures, so this doesn't pin the new manual-freeze contract. Please match the missing-transaction-id error text here, and ideally add the sibling missing-node-id case as well.

🛠️ Proposed fix
-    with pytest.raises(ValueError):
+    with pytest.raises(
+        ValueError,
+        match="Transaction ID must be set before freezing",
+    ):
         tx.freeze()
As per coding guidelines: `Tests must provide useful error messages when they fail for future debugging`.

Comment thread tests/unit/transaction_test.py
Comment thread tests/unit/transaction_test.py Outdated
@manishdait manishdait marked this pull request as draft March 24, 2026 19:51
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 70d640d3-78dc-4545-a5c8-db16b77403d8

📥 Commits

Reviewing files that changed from the base of the PR and between 2a2bd41 and 75650a0.

📒 Files selected for processing (3)
  • src/hiero_sdk_python/transaction/transaction.py
  • tests/integration/file_append_transaction_e2e_test.py
  • tests/unit/mock_server.py

Comment thread src/hiero_sdk_python/transaction/transaction.py Outdated
Comment thread src/hiero_sdk_python/transaction/transaction.py
Comment thread tests/integration/file_append_transaction_e2e_test.py Outdated
Comment thread tests/integration/file_append_transaction_e2e_test.py Outdated
Comment thread tests/unit/mock_server.py Outdated
@manishdait manishdait force-pushed the feat/tx-size branch 2 times, most recently from a9fef8c to 31ddd71 Compare March 25, 2026 15:45
@manishdait manishdait marked this pull request as ready for review March 25, 2026 17:31
@manishdait manishdait requested a review from a team as a code owner March 25, 2026 17:31
return self._make_request().ByteSize()

@property
def body_size(self) -> int:
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.

should we use the frozen bytes here?
self._transaction_body_bytes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we can use that, but in chuck tx the frozen bytes is only valid for a single chunk. Since each chunk will has a unique message slice and chunk metadata, we must force a rebuild of the transaction body for each index to get a measurement of every chunks size.

Comment thread src/hiero_sdk_python/file/file_append_transaction.py Outdated
Copy link
Copy Markdown
Contributor

@aceppaluni aceppaluni left a comment

Choose a reason for hiding this comment

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

@manishdait
I had a question about body_size_all_chunks.

While the state is restored at the end, I'm concerned about a potential issue:

Exception handling: If an exception occurs during the loop iteration, the state restoration code won't execute, potentially leaving the transaction in an inconsistent state. Should we consider using a try/finally block here?

What do you think, Should we consider

  • Adding a try/finally block to ensure state is always restored? OR
  • Adding a prominent comment or docstring warning about this side effect?

Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
@manishdait
Copy link
Copy Markdown
Contributor Author

@manishdait I had a question about body_size_all_chunks.

While the state is restored at the end, I'm concerned about a potential issue:

Exception handling: If an exception occurs during the loop iteration, the state restoration code won't execute, potentially leaving the transaction in an inconsistent state. Should we consider using a try/finally block here?

What do you think, Should we consider

* Adding a try/finally block to ensure state is always restored? OR

* Adding a prominent comment or docstring warning about this side effect?

@aceppaluni, Thank for the review, I think try/finally will be a good choice

Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

intermediate requires some knowledge of the codebase with some defined steps to implement or examples lang: python Uses Python programming language reviewer: write requires a review with write permissions step: 1st 1st stage of the review approval process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Transaction Size Calculation Methods to Python SDK

4 participants