Skip to content

feat: implement gas optimization utilities and add GasGuard G014 rule - #719

Merged
mijinummi merged 4 commits into
MDTechLabs:mainfrom
lishmanTech:newiss
Jul 29, 2026
Merged

feat: implement gas optimization utilities and add GasGuard G014 rule#719
mijinummi merged 4 commits into
MDTechLabs:mainfrom
lishmanTech:newiss

Conversation

@lishmanTech

Copy link
Copy Markdown
Contributor

Summary

This PR introduces several gas optimization improvements across the codebase, including low-level Yul optimizations, storage packing techniques, and a new GasGuard analysis rule.

Changes

Contracts

  • Implemented a zero-allocation ERC-20 permit processor using inline Yul assembly.
  • Added a compact packed storage map that stores up to 32 uint8 values in a single bytes32 storage slot.
  • Implemented a scratch-space Keccak hasher that computes hashes using memory locations 0x00 and 0x20, eliminating unnecessary memory allocation.

Gas Optimizations

  • Eliminated dynamic memory allocation for permit calldata construction.
  • Reduced storage operations by replacing fixed-size mappings with bit-packed storage.
  • Optimized hashing by utilizing EVM scratch memory and avoiding free memory pointer expansion.

GasGuard

  • Added Rule G014 to detect uncached storage array .length accesses inside loops and conditional statements.
  • Emits actionable diagnostics recommending caching storage array lengths in local variables.
  • Excludes memory and calldata array length accesses from detection.

Testing

  • Added unit tests covering the new contract implementations.
  • Added fixtures validating the new GasGuard rule.
  • Included gas comparison benchmarks where applicable.

Closes

Closes #683
Closes #684
Closes #687
Closes #689

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@lishmanTech Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mijinummi
mijinummi merged commit 6bf323a into MDTechLabs:main Jul 29, 2026
1 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants