feat: cleanup and refactor for gas-655 branch (reduce allocations, consolidate helpers, safer paths) #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements a targeted cleanup for the gas-655 branch by refactoring the Ledger-related contracts to reduce gas usage, remove unused state and deprecated calls, and consolidate helper logic into fewer, well-audited paths. The changes aim to make the core tx path more predictable under high load and simplify future audits.
Testing coverage has been expanded to validate the refactor paths, including regression checks for the main ledger upload/execute flows and updated calldata handling. Some non-critical helpers were inlined where it reduces allocations without sacrificing readability. Administrative state changes are minimized and scoped to initialization-safe patterns.
Deployment impact is expected to be minimal for existing deployments, but there may be small gas deltas due to the refactor. A careful upgrade path remains chủ to ensure compatibility with prior state structures; please run the provided migration tests in Hardhat before production use. If you rely on exact gas measurements for budgeting, expect minor shifts and review the new gas-usage reports in test artifacts.
Testing strategy and validation are emphasized in this PR. The suite now includes targeted gas benchmarks, fuzzed input coverage for edge cases, and property-based checks for invariants across ledger operations. The tests exercise both the happy path and failure scenarios (e.g., reverts on invalid signatures or mismatched state). See the Testing section below for more details and steps to reproduce locally.