For the complete documentation index, see llms.txt. This page is also available as Markdown.

ElaraBase

Git Source

Inherits: IElaraBase, AccessManagedUpgradeable, UUPSUpgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable

Title: Elara Base Contract

Abstract base contract for all Elara upgradeable contracts

  • Provides UUPS upgradeability, pausability, reentrancy protection, and access management

  • Invariants:

  • Only authorized accounts can pause/unpause functionality

  • Only authorized accounts can upgrade the implementation

  • Upgradeability:

  • Uses UUPS upgradeability pattern via {UUPSUpgradeable}

  • Initializer must be called exactly once; preserve storage layout for upgrade safety

  • All upgradeable contracts should inherit from this base to ensure consistent security controls

  • Access Control:

  • All critical functions are gated by AccessManagedUpgradeable-restricted modifier

  • Access management is handled by a centralized {AccessManager} contract

Note: security-contact: [email protected]

Functions

constructor

Note: oz-upgrades-unsafe-allow: constructor

__ElaraBase_init

Internal initializer wiring shared upgrade and access control modules.

Security:

  • Only callable during initialization via {initializer} modifier

  • Sets up inherited contracts via their respective initialization functions

  • Reverts if _accessManager is zero address

  • Critical for establishing access control; must be called exactly once per proxy

Parameters

Name
Type
Description

_accessManager

address

Address of the AccessManager contract

pause

Triggers pause state in {PausableUpgradeable}. May affect other contracts that depend on this contract's functionality.

unpause

Triggers unpause state in {PausableUpgradeable}. May affect other contracts that depend on this contract's functionality.

upgradeToAndCall

Restricted to proxy calls only via {onlyProxy}; direct calls to the implementation revert. Delegates to UUPSUpgradeable-upgradeToAndCall, which internally calls _authorizeUpgrade where access control is enforced via {restricted}.

_authorizeUpgrade

Authorization is enforced via {restricted} modifier on this internal function. Note: While OpenZeppelin generally recommends against using {restricted} on internal functions, UUPS contracts are a special case where this pattern is appropriate and secure. Why this works for UUPS:

  • upgradeToAndCall (from UUPSUpgradeable) is the ONLY external entry point for upgrades

  • When _authorizeUpgrade executes, _msgData() still contains the upgradeToAndCall selector

  • AccessManager checks permissions for the upgradeToAndCall selector, which is the intended behavior

  • This approach avoids redundant authorization checks while maintaining complete security The security flow is:

  1. External call to upgradeToAndCall (inherited from UUPSUpgradeable)

  2. UUPSUpgradeable.upgradeToAndCall calls _authorizeUpgrade internally

  3. Our _authorizeUpgrade uses {restricted} to check AccessManager permissions

  4. AccessManager validates that msg.sender can call upgradeToAndCall Reference: https://forum.openzeppelin.com/t/uupsupgradeable-and-accessmanaged/41142

Last updated

Was this helpful?