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.
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.
LAU-04C: Significant Optimization of Call Relays
Description:
The
LzAppUpgradeable
contract is meant to be an upgradeable version of theLzApp
by LayerZero. To achieve this, its storage space has been migrated to a pointer-basedLzAppStorage
struct causing thelzEndpoint
to no longer beimmutable
and require a fullSLOAD
operation per-use.Example:
Recommendation:
We advise the
lzEndpoint
to be relocated to the contract itself and set as animmutable
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 theLzAppUpgradeable::constructor
and utilized in the other functions of the contract viadelegatecall
operations.