FirewallTransparentUpgradableProxy.sol

FirewallTransparentUpgradeableProxy is Ironblocks' extended version of OpenZeppelin's TransparentUpgradableProxy contract.

Using this contract instead of the standard TransparentUpgradableProxy contract, alongside the FirewallProxyAdmin instead of the standard ProxyAdmin allows you to enable firewall protection on every one of your external methods without having to add any firewall-specific code to your implementation contract.

While the exact technical specifications of this implementation can be found in our source code, the important changes to note are the following:

  1. The proxy constructor now receives the firewall address and firewallAdmin address.

  2. Similar to the implementation and admin addresses, these are stored in pseudorandom deterministic slots to prevent storage collision.

  3. The Firewall Admin is responsible for managing the Firewall Consumer policies, and the standard admin can change the Firewall and Firewall Admin addresses.

Initialization

constructor()

constructor(address _logic, address admin_, bytes memory _data, address _firewall, address _firewallAdmin)

Initializes a firewall upgradeable proxy managed by _admin, backed by the implementation at _logic, and optionally initialized with _data (as explained in ERC1967Proxy-constructor). Also sets _firewall and _firewallAdmin.

Modifiers

ifFirewallOrAdmin()

Used for routing calls to this Firewall Proxy if they were called by the Firewall or the Firewall Admin. Otherwise, forwards calls to the implementation contract (i.e. _fallback()).

firewallProtected()

Used to protect calls to the implementation contract, so that any calls to it would go through the Firewall's Pre Execution and Post Execution hooks.

Methods

changeFirewall()

function changeFirewall(address _firewall)

Callable only by the Firewall Admin, use this function to change the Firewall that this Firewall Proxy uses.

changeFirewallAdmin()

function changeFirewallAdmin(address _firewallAdmin)

Callable only by the Firewall Admin, use this function to change the Firewall Admin of the Firewall that this Firewall Proxy uses.

firewall()

function firewall()

Returns the current Firewall address.

firewallAdmin()

function firewallAdmin()

Returns the current Firewall Admin address.

Source Code

On our GitLab repository: FirewallTransparentUpgradeableProxy.sol

Last updated