Skip to content

Conversation

@indocs
Copy link
Owner

@indocs indocs commented Sep 30, 2025

The changes introduce a streamlined transaction encoding path and centralized gas accounting for Ledger-supported flows. Key updates include:

  • Consolidation of the tx builder and signer interfaces to reduce redundant state reads and minimize stack depth.
  • Updated encoding/decoding helpers to use inline assembly where safe, cutting several gas-heavy parameter extractions.
  • A new optional gasEstimator pathway that leverages already-calculated deltas to avoid recalculating gas usage multiple times in cross-contract calls.
  • Adjusted tests to cover the refactor’s edge cases, including bundled nonce handling and error propagation through the ledger signer.
  • Migration notes: if you previously relied on the old tx path, ensure you migrate callers to the new builder API and update any mocks accordingly.

Gas trade-offs:
This refactor targets lower gas usage by avoiding repeated reads and by moving invariant computations out of hot paths. The trade-off is a slightly larger initial function footprint and increased complexity in the signer path, which may affect readability. When used in conjunction with the existing ledger optimization, total gas per tx should decrease on common paths, while some atypical flows may see marginal increases due to new inline checks. Overall, expected net gas savings should be observable across bulk-tx scenarios and higher-volume deployments.

Copy link
Owner Author

@indocs indocs left a comment

Choose a reason for hiding this comment

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

Security nit: verify no reentrancy or unexpected external calls are introduced by the new modular path; confirm all external interactions are strictly via vetted interfaces and guard against untrusted call data.

Copy link
Owner Author

@indocs indocs left a comment

Choose a reason for hiding this comment

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

Testing suggestion: add property-based tests or randomized input tests for the gas-optimized path to stress test under varying ledger inputs and ensure gas consumption stays within expected bounds across scenarios.

Copy link
Owner Author

@indocs indocs left a comment

Choose a reason for hiding this comment

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

Developer-experience remark: consider centralizing common testing utilities (mock ledger, helpers for gas measurement) to reduce duplication and improve onboarding for new contributors.

@indocs indocs changed the title feat: refactor/gas-827-1 - modularize gas-optimized ledger tx path and API polish feat: Refactor gas-optimized tx path for Ledger (refactor/gas-827-1) Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants