-
Notifications
You must be signed in to change notification settings - Fork 1
[LAU-04C] Significant Optimization of Call Relays #11
Copy link
Copy link
Open
Description
LAU-04C: Significant Optimization of Call Relays
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() |
LzAppUpgradeable.sol:L51, L93 |
Description:
The LzAppUpgradeable contract is meant to be an upgradeable version of the LzApp by LayerZero. To achieve this, its storage space has been migrated to a pointer-based LzAppStorage struct causing the lzEndpoint to no longer be immutable and require a full SLOAD operation per-use.
Example:
/// @custom:storage-location erc7201:layerzero.storage.LzApp
struct LzAppStorage {
ILayerZeroEndpoint lzEndpoint;
mapping(uint16 => bytes) trustedRemoteLookup;
mapping(uint16 => mapping(uint16 => uint256)) minDstGasLookup;
mapping(uint16 => uint256) payloadSizeLimitLookup;
address precrime;
}Recommendation:
We advise the lzEndpoint to be relocated to the contract itself and set as an immutable variable. Immutable variables are upgradeability-compatible as they are placed within the bytecode of the contract rather than its storage space, meaning that they can safely be set in the LzAppUpgradeable::constructor and utilized in the other functions of the contract via delegatecall operations.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
