Omniscia Gnosis Guild Audit
PermissionTracker Code Style Findings
PermissionTracker Code Style Findings
PTR-01C: Inefficient mapping
Lookups
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | PermissionTracker.sol:L74-L75 |
Description:
The linked statements perform key-based lookup operations on mapping
declarations from storage multiple times for the same key redundantly.
Example:
packages/evm/contracts/PermissionTracker.sol
74allowances[key].balance = balance - consumed;75allowances[key].refillTimestamp = refillTimestamp;
Recommendation:
As the lookups internally perform an expensive keccak256
operation, we advise the lookups to be cached wherever possible to a single local declaration that either holds the value of the mapping
in case of primitive types or holds a storage
pointer to the struct
contained.
Alleviation:
The referenced allowances
mapping lookups have been optimized as advised, utilizing a local storage
pointer and thus performing a single lookup operation for the desired Allowance
entry.