-
Notifications
You must be signed in to change notification settings - Fork 26
[Feature] Authorizer_v2 #760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FHieser
wants to merge
71
commits into
dev
Choose a base branch
from
feature/Authorizer_v2
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
68b8870
[Audit] Feature/Authorizer-Update
FHieser 8ee380f
Create AUT_Roles_v1.md
FHieser bbe3bf5
Adapt the natspec header sections
FHieser 4167b48
Fix documentation
FHieser b584027
Update AUT_Roles_v1.md
FHieser 7776e79
Create AUT_TokenGated_Roles_v1.md
FHieser 7c908c9
Remove according natspec from contract headers
FHieser 6ca5225
Create 2025-06-05-team-omega-authorizer-update.pdf
FHieser 904f84d
Rename Authorizer Interface
FHieser 490ed94
Rename IAUT_EXT_VotingRoles_v1
FHieser 78d229b
Adapt versioning of md files
FHieser 098d087
Rename AUT_EXT_VotingRoles_v1
FHieser 213ab0b
Adapt natspec
FHieser 1bf4ef1
Rename AUT_Roles_v1
FHieser 395c52b
Rename AUT_TokenGated_Roles_v1
FHieser 4cf9fe5
Rename AuthorizerV1Mock
FHieser 586720b
Rename ModuleV1Mock
FHieser d7c268a
Rename Module_v1
FHieser 2d33fe7
Rename FM_BC_Bancor_Redeeming_VirtualSupply_v1
FHieser b8f334e
Rename FM_BC_BondingSurface_Redeeming_Restricted_Repayer_Seizable_v1
FHieser 35425ef
Rename FM_BC_BondingSurface_Redeeming_v1
FHieser cbe9396
Rename IBondingCurveBase_v1
FHieser 0736c04
Rename RedeemingBondingCurveBase_v1
FHieser dc50efd
Rename Tests
FHieser a1140b1
Rename BondingCurveBase_v1
FHieser d0dcfc4
Remove falsely placed comment
FHieser e94ca86
Rename Module test
FHieser 9dadb18
Rename FM_EXT_TokenVault_v1
FHieser 5d74fa4
Rename FM_PC_Oracle_Redeeming_v1
FHieser bb5ff29
Rename LM_Oracle_Permissioned_v1
FHieser 9de9fdb
Rename LM_PC_Bounties_v2
FHieser c6727a5
Rename LM_PC_KPIRewarder_v2
FHieser e1a4ef7
Rename LM_PC_PaymentRouter_v2
FHieser f7b2e1c
Rename LM_PC_RecurringPayments_v2
FHieser 11f5e44
Rename LM_PC_Staking_v2
FHieser 489d8cd
Rename ERC20PaymentClientBase_v2
FHieser d975bd9
Add natspec
FHieser 51130f6
Add todo comments
FHieser 16392a1
rename OptimisticOracleIntegrator
FHieser 9f28917
Add todo
FHieser 1901873
Rename PP_Queue_ManualExecution_v1
FHieser 7bb7f3a
Rename PP_Queue_v1
FHieser a03f038
Rename PP_Simple_v2
FHieser 1abc91e
Rename PP_Streaming_v2
FHieser 69cefc3
Rename IPaymentProcessor_v2
FHieser c0a5ebf
Renaming Orchestrator_v1
FHieser c903a18
Fix _ensureValidModule
FHieser 4d498a1
Readd IAuthorizer_v1
FHieser a508520
Create and Adapt Mocks
FHieser 5ff2443
Remove unnecessary variable
FHieser 21e90cd
Adapt Mock References
FHieser bf546ad
Make add and remove Modules Interface Agnostic
FHieser 809860c
Add comment
FHieser 3aec583
Update MetadataCollection_v1.s.sol
FHieser 03991b3
Merge branch 'dev' into feature/Authorizer_v2
FHieser f7aa43f
Fix Merge
FHieser b85558f
Rename Crosschain Contracts
FHieser 68892f7
Merge branch 'dev' into feature/Authorizer_v2
FHieser 9efa4ff
Make functions virtual
FHieser 832ec68
Update MetadataCollection_v1.s.sol
FHieser 73c30fa
Fixing comments
FHieser 0f19bf8
adapt variable naming
FHieser 48bb4b8
Adapt references
FHieser 98952a8
Apply suggestions from code review
FHieser 3061d2d
Apply suggestions from code review
FHieser ee6bc33
Merge branch 'feature/Authorizer_v2' of https://github.com/InverterNe…
FHieser a614527
Update md to use correct function format
FHieser 6f65c74
Adapt documentation link
FHieser 55779c0
Remove unnecessary code
FHieser 31ee35d
Update Mapping natspec
FHieser 237311c
Merge branch 'dev' into feature/Authorizer_v2
FHieser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,261 @@ | ||
| # AUT_Roles_v2 | ||
|
|
||
| ## Purpose of Contract | ||
|
|
||
| This contract provides the access control mechanism for managing roles and permissions across different modules within the Inverter Network, ensuring secure and controlled access to critical functionalities. | ||
|
|
||
| This contract has the following key features: | ||
|
|
||
| - **Role creation and management**: This includes the ability to create roles, revoke roles, assigning and revoking role admins, which can add and remove role members. | ||
| - **Role-based access control**: This includes the ability to grant roles access to functions that implement the permissioned modifier. Functions can also be set to public access by adding the public role to the function permissions. | ||
|
|
||
| ## Glossary | ||
|
|
||
| To understand the functionalities of the following contract, it is important to be familiar with the following definitions. | ||
|
|
||
| ### Roles | ||
|
|
||
| A role has the following properties: | ||
|
|
||
| - A unique identifier (ID) | ||
| - A label | ||
| - A list of members | ||
| - A associated admin role | ||
|
|
||
| The id is a value assigned by the authorizer module and is used to reference the role in the different functions of the authorizer module. | ||
|
|
||
| The label is a string that is emitted as an event when the role is created. It is used to make the role human-readable in the frontend and has no practical use on-chain. | ||
|
|
||
| The members are the addresses that inhabit the role. The admin role is the role that can add and remove new members to the role. | ||
|
|
||
| ### Native Roles | ||
|
|
||
| There are three native roles that are created with the authorizer module: | ||
|
|
||
| - The default admin role | ||
| - The public role | ||
| - The burn admin role | ||
|
|
||
| The default admin role holds the highest admin privileges and can access every `permissioned` function at all times. The public role is a role that can be added to a function's permission list and is used to make functions be publicly accessible. The burn admin role is a placeholder role that indicates that the admin role of a role has been burned and is no longer usable. | ||
|
|
||
| ### Permissioned Modifier | ||
|
|
||
| Most of the state altering functions in a workflow are so called `permissioned` functions. This means that only roles that have been granted the according function permission can call the function. The permissioned status is enforced by the `permissioned` modifier. | ||
|
|
||
| Some of the native roles have special rights in this system. The default admin role can access every `permissioned` function regardless of wether the default admin role was granted the permission or not. If the public role is granted the permission to a function, then every caller can access the function, regardless of wether they inhabit a already added role or not. | ||
|
|
||
| Note: As a workflow is intialized without any native permissions, some functions that could be perceived as "this should be publicly accessible" are not. Examples for this could be the "buy" and "sell" functions of some funding manager modules or the stake and unstake functions of the staking logic module. For these functions, the public role has to be added to the access of the respective function. | ||
|
|
||
| ## Inheritance | ||
|
|
||
| ### Class Diagramm | ||
|
|
||
| ```mermaid | ||
| classDiagram | ||
|
|
||
| Module <|-- AUT_Roles_v2 | ||
| AccessControlEnumerableUpgradeable <|-- AUT_Roles_v2 | ||
|
|
||
| note for Module "Base contract for every module implementation" | ||
| class Module{ | ||
| -IOrchestrator_v2 __Module_orchestrator | ||
| + permissioned | ||
| } | ||
|
|
||
| note for AccessControlEnumerableUpgradeable "OpenZeppelin Authorization System" | ||
| class AccessControlEnumerableUpgradeable { | ||
| - mapping(bytes32 role => EnumerableSet.AddressSet) _roleMembers | ||
| + getRoleMember() | ||
| + hasRole() | ||
| + getRoleAdmin() | ||
| + grantRole() | ||
| + revokeRole() | ||
| } | ||
|
|
||
| class AUT_Roles_v2{ | ||
| - mapping(address target => mapping(bytes4 selector => bytes32[] roleIds)) _permissions; | ||
| + getPermissions() | ||
| + isRolePermissioned() | ||
| + hasPermission() | ||
| + createRole() | ||
| + labelRole() | ||
| + transferAdminRole() | ||
| + burnRoleAdmin() | ||
| + addAccessPermission() | ||
| + removeAccessPermission() | ||
| + createRoleAndAddAccessPermissions() | ||
| } | ||
|
|
||
| ``` | ||
|
|
||
| ### Base Contracts | ||
|
|
||
| This contract is based on the following contracts and inherits their functionalities: | ||
|
|
||
| - [IAuthorizer_v2](../IAuthorizer_v2.md): Implementation interface. | ||
| - [Module_v2](../../base/Module_v2.md): Inverter network base module functionality. | ||
| - [AccessControlEnumerableUpgradeable](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/master/contracts/access/extensions/AccessControlEnumerableUpgradeable.sol): Access control functionality. | ||
|
|
||
| Functions that have been overridden to adapt functionalities are outlined below. | ||
|
|
||
| ### Key Changes to the Base Contracts | ||
|
|
||
| _The purpose of this section is to highlight which functions of the base contract have been overridden and why._ | ||
|
|
||
| - `grantRole`: This function has been overridden to allow only the distribution of roles that have already been created by the authorizer module. | ||
|
|
||
| ## Key Functionalities | ||
|
|
||
| In this section the key functionalities of the authorizer module are described. | ||
|
|
||
| ### Role Management | ||
|
|
||
| This section describes the functionalities of the authorizer module regarding role management. | ||
|
|
||
| #### Role Creation | ||
|
|
||
| A role can be created by calling the `createRole` function. The function takes the following parameters: | ||
|
|
||
| - The role name | ||
| - The role id of the role that will become the admin of the new role. | ||
| - The addresses of the initial members of the new role. | ||
|
|
||
| The rolename in this context refers to the label of the role and is therefore not referenceable onchain. The function can only be called by a permissioned address (See [permissioned](#permissioned-modifier)). | ||
|
|
||
| #### Role Labeling | ||
|
|
||
| The label of a role can be overwritten by calling the `labelRole` function. With this a new event is emitted, that signals the frontend that the label has been updated. The function can only be called by a permissioned address.(See [permissioned](#permissioned-modifier)). | ||
|
|
||
| #### Role granting | ||
|
|
||
| A role can be granted to a address by calling the `grantRole` function. The function takes the following parameters: | ||
|
|
||
| - The role id of the role to grant | ||
| - The address to grant the role to | ||
|
|
||
| The `grantRole` function can only be called by according admin of the role. | ||
|
|
||
| #### Role revoking | ||
|
|
||
| A role can be revoked from an address by calling the `revokeRole` function. The function takes the following parameters: | ||
|
|
||
| - The role id of the role to revoke | ||
| - The address to revoke the role from | ||
|
|
||
| The `revokeRole` function can only be called by according admin of the role. | ||
|
|
||
| #### Transferal of Admin Roles | ||
|
|
||
| The admin role of a role can be transferred by calling the `transferAdminRole` function. The function takes the following parameters: | ||
|
|
||
| - The role id of the role to transfer the admin from | ||
| - The role id of the role to transfer the admin to | ||
|
|
||
| The `transferAdminRole` function can only be called by according admin of the role. | ||
|
|
||
| #### Burning of Admin Roles: | ||
|
|
||
| The admin role can be burned by calling the `burnRoleAdmin` function. The function takes the following parameters: | ||
|
|
||
| - The role id of the role to burn the admin from | ||
|
|
||
| If the admin role is burned, then no members can be added or removed from a role anymore. Remember: This step is irreversible. | ||
|
|
||
| ### Role Based Access Control | ||
|
|
||
| This section describes the functionalities of the authorizer module regarding role based access control. | ||
|
|
||
| #### Adding access permissions | ||
|
|
||
| Adding access permissions is done by calling the `addAccessPermission` function. This function takes the following parameters: | ||
|
|
||
| - The contract for which the permission is added | ||
| - The function selector of the target function | ||
| - The role ID of the role that will receive the permission | ||
|
|
||
| Example: Adding the role "BOUNTY_MANAGER" to the `createBounty` function of the "bountyManager" contract would look like this: | ||
|
|
||
| ```solidity | ||
| authorizer.addAccessPermission( | ||
| address(bountyManager), | ||
| bountyManager.createBounty.selector, | ||
| bountyManagerId | ||
| ); | ||
| ``` | ||
|
|
||
| The function can only be called by a permissioned address.(See [permissioned](#permissioned-modifier)). | ||
|
|
||
| #### Making a function public | ||
|
|
||
| A function can be made public by calling the `addAccessPermission` function with the public role as target role. | ||
|
|
||
| Example: Making the `buy` function of the funding manager contract public would look like this: | ||
|
|
||
| ```solidity | ||
| authorizer.addAccessPermission( | ||
| address(fundingManager), | ||
| fundingManager.buy.selector, | ||
| authorizer.PUBLIC_ROLE() | ||
| );` | ||
| ``` | ||
|
|
||
| The public role can be removed in the same way as any other role. | ||
|
|
||
| ### Mixed Utility - `createRoleAndAddAccessPermissions()` | ||
|
|
||
| This function is a convenience function that combines the creation of a new role and the adding of access permissions. It takes the following parameters: | ||
|
|
||
| - The name of the role | ||
| - The role id of the role that will become the admin of the new role. | ||
| - The addresses of the initial members of the new role. | ||
| - The addresses of the targets contracts. | ||
| - The selectors of the functions. | ||
|
|
||
| Note: The selectors of the functions are linked to the respective target contracts. As the selectors are passedas a 2 Dimensional array, the first dimension is coupled to target contract and the second one contains the actual selectors for that target contract. | ||
|
|
||
| Example: The target contracts are the fundingManager at position 0 in the array and the logic module at position 1. The selectors therefore contain two arrays, one for position 0 and one for position 1. A call would look like this: | ||
|
|
||
| ```solidity | ||
| 'authorizer.createRoleAndAddAccessPermissions( | ||
| "newRole", | ||
| authorizer.DEFAULT_ADMIN_ROLE(), | ||
| [ | ||
| initialMember1, | ||
| initialMember2 | ||
| ], | ||
| [ | ||
| fundingManager.address, | ||
| logicModule.address | ||
| ], | ||
| [ | ||
| [ | ||
| fundingManager.buy.selector, | ||
| fundingManager.sell.selector | ||
| ], | ||
| [ | ||
| logicModule.execute.selector | ||
| ] | ||
| ] | ||
| ) | ||
| ``` | ||
|
|
||
| The function can only be called by a permissioned address.(See [permissioned](#permissioned-modifier)). | ||
|
|
||
| ## Deployment | ||
|
|
||
| ### Deployment Parameters | ||
|
|
||
| The list of deployment parameters can be found in the _Technical Reference_ section of the documentation under the `init()` function ([https://docs.inverter.network/contracts/technical-reference/modules/authorizer/role/aut_roles_v2.sol]()). | ||
|
|
||
| ### Deployment | ||
|
|
||
| Deployment should be done using one of the methods provided below: | ||
|
|
||
| - **Manual deployment:** Through Inverter Network's [Control Room application](https://beta.controlroom.inverter.network/). | ||
| - **SDK deployment:** Through Inverter Network's [TypeScript SDK](https://docs.inverter.network/sdk/typescript-sdk/guides/deploy-a-workflow) or [React SDK](https://docs.inverter.network/sdk/react-sdk/guides/deploy-a-workflow). | ||
|
|
||
| ### Setup Steps | ||
|
|
||
| #### Optional Setup Steps | ||
|
|
||
| Because a workflow and its authorizer module are deployed without any native permissions (except the initial admin role [here](#native-roles)), it might be necessary for some modules to modify the access of their functions. For this the sections [Mixed Utility](#mixed-utility---createroleandaddaccesspermissions), [Role Management](#role-management) and [Role Based Access Control](#role-based-access-control) can be referenced. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change being done? Or rather: was this an accident or on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it may just be your formatter or something? Same as later in the same file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah seems to be formatter issue
Doesnt seem to change the form of the output file though
So I would keep it