Assessment reports>Acctual Batch Payments>Discussion>Possible gas savings

Possible gas savings

This section describes some possible ways to reduce the gas usage of the contract, both at deployment and at runtime. We note that the contract does not contain major inefficiencies and all suggestions save a limited amount of gas.

Inheritance from Ownable. The contract inherits from OpenZeppelin Ownable but makes no use of the features implemented by Ownable. This makes the contract use additional bytecode space and storage space. The wasted space is limited, but removing the dependency from Ownable is a trivial way to save a low amount of gas at deployment time.

Reentrancy guard. The contract uses a reentrancy guard; while it is normally recommended to implement reentrancy guards by default on all contracts not explicitly requiring reentrancy, AcctualBatchBillPay does not benefit from reentrancy guards, as the contract has no state or behavior that could be abused. Its complexity is low enough that we can confidently exclude any reentrancy issue. Therefore, the reentrancy guard could be removed to save a small amount of gas at deployment and runtime.

Events. The contract currently emits events that are not used by any off-chain client. These events could be removed to save a small amount of gas.

Remediation

The following commits address this discussion point:

  • removes reentrancy guards

  • removes inheritance from Ownable

  • other miscellaneous gas saving measures

Zellic © 2024Back to top ↑