Protocol Rule Processor Diamond Facets
Purpose
The Rule Processor Diamond Facets are where rule adding and rule check functions are stored in the protocol. Storage facets store the add rule functions for each rule type. Processor facets store the rule check functions and are called by an application’s handler contracts. Facets can be added or removed by the diamond to allow for upgrades to functionality of the diamond. Application contracts never call the facets directly and will only ever interact with the Rule Processor Proxy.
see facet list
Upgrading
Through The Script
- see Upgrade a Rule Processor Facet.
- If an upgrade needs to be reverted, see Revert a Diamond Upgrade.
Manually
Note: it is not encourage to upgrade a facet manually. Instead, try the upgrade scripts as explained in the previous section. If a manual upgrade is preferred, make sure to record the deployment in the deployment/diamonds.json
directory.
-
The new facet that is to be added to the diamond should first be deployed to the network the Rule Processor Diamond is deployed to.
-
The new facet address and function selectors are used as parameters for the DiamondCut function.
-
Once the new facet is deployed and the function selectors are known, call diamondCut on the Rule Processor Diamond contract. This is the address of the Rule Processor Proxy.
-
Any attempt to remove an immutable function from the diamond will revert.
-
Adding functions that already exist within the diamond will revert with an error “Cannot add function that already exists”.
-
The diamondCut function will add the new selectors to storage and are then able to be called through the proxy address.
-
Record the deployment in the
deployment/diamonds.json
Events
- event DiamondCut(_diamondCut, init, data):
- Emitted when: the Rule Processor Diamond has been upgraded.
- Parameters:
- _diamondCut: Facets Array
- init: Address of the contract or facet to execute “data”
- data: A function call, including function selector and arguments calldata is executed with delegatecall on “init”