Skip to content

[LAU-04C] Significant Optimization of Call Relays #11

@dkuppitz

Description

@dkuppitz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions