Skip to content

Commit 1cadcec

Browse files
authored
Merge pull request #3 from VenusProtocol/governance/access-control-edits
fix: phrasing and formatting updates
2 parents 2c64378 + 0e4a075 commit 1cadcec

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

Governance/AccessControl.md renamed to Governance/Access Control Manager.md

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
# Access Control
22

3-
Access control play a crucial role in our Governance model. We use it to restrict certain functions to be called only from one account or list of accounts (EOA or Contract Accounts).
3+
Access control plays a crucial role in the Venus governance model. It is used to restrict functions so tha they can only be called from one account or list of accounts (EOA or Contract Accounts).
44

5+
# Access Control Manager
6+
The implementation of [AccessControlManagemer](https://github.com/VenusProtocol/isolated-pools/blob/main/contracts/Governance/AccessControlManager.sol) inherits the [Open Zeppelin AccessControl](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol) contract as a base for role management logic. There are two role types admin and granular permissions.
57

8+
### Granular Roles
69

10+
Granular roles are built by hashing the contract address and its function signature.
11+
For example, Given Contract Foo with function Foo.bar() which is guarded by ACM,
12+
calling `giveRolePermission` for account B do the following:
13+
1. Compute `keccak256(contractFooAddress,functionSignatureBar)`
14+
2. Add the computed role to the roles of account B
15+
3. Account B now can call `ContractFoo.bar()`
716

8-
# Access Control Manager
9-
The implementation of our AC Management we implemented [**AccessControlManager.sol**](https://github.com/VenusProtocol/isolated-pools/blob/main/contracts/Governance/AccessControlManager.sol) which is a contract that inherits [**@openzeppelin/contracts/access/AccessControl.sol**](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol) as a base of our role management logic.
10-
Roles are built by hashing the contract address and its function signature.
11-
E.g We have a Contract A with function A.try() which is guarded by ACM.
12-
Calling giveRolePermission for account B will basically do:
13-
1. compute keccak256({addrress-of-a},{function-sig-of-try()})
14-
2. add the computed role to the roles of account B
15-
3. Account B now can call try() of Contract A
16-
17-
**NOTE:** because of the existence of factory contracts, in some cases we don't need that granular permissions (e.g in PoolRegistry). So we introduced **DEFAULT_ADMIN_FUNCTION_ROLE**.
18-
This role is computed the same way, but instead of computing `keccak256({addrress-of-a},{function-sig-of-try()})`, we do `keccak256({zero-address},{function-sig-of-try()})`.
19-
If we consider the same case above and give account B the **DEFAULT_ADMIN_FUNCTION_ROLE** , account B will have permissions to call try() function on any contract that is guarded by ACM, not only contract A.
20-
Lets' take a look at each interface function of the contract:
17+
### Admin Roles
18+
19+
Admin roles allow for an address to call a function signature on any contract guarded by the AccessControlManager. This is particularly useful for contracts created by factories.
20+
21+
For Admin roles a null address is hashed in place of the contract address (`keccak256(0x0000000000000000000000000000000000000000,functionSignatureBar)`.
22+
23+
In the previous example, giving account B the admin role, account B will have permissions to call the bar() function on any contract that is guarded by ACM, not only contract A.
2124

2225
# Solidity API
2326

@@ -72,11 +75,8 @@ _Since the contract is calling itself this function, we can get contracts addres
7275

7376

7477
| Name | Type | Description |
75-
7678
| ---- | ---- | ----------- |
77-
7879
| caller | address | contract for which call permissions will be checked |
79-
8080
| functionSig | string | signature e.g. "functionName(uint,bool)" |
8181

8282

@@ -86,9 +86,7 @@ _Since the contract is calling itself this function, we can get contracts addres
8686

8787

8888
| Name | Type | Description |
89-
9089
| ---- | ---- | ----------- |
91-
9290
| [0] | bool | false if the user account cannot call the particular contract function |
9391

9492

@@ -120,13 +118,9 @@ May emit a {RoleGranted} event._
120118

121119

122120
| Name | Type | Description |
123-
124121
| ---- | ---- | ----------- |
125-
126122
| contractAddress | address | address of contract for which call permissions will be granted NOTE: if contractAddress is zero address, we give the account DEFAULT_ADMIN_ROLE, meaning that this account can access the certain function on ANY contract managed by this ACL |
127-
128123
| functionSig | string | signature e.g. "functionName(uint,bool)" |
129-
130124
| accountToPermit | address | account that will be given access to the contract function |
131125

132126

@@ -158,11 +152,7 @@ May emit a {RoleRevoked} event._
158152

159153

160154
| Name | Type | Description |
161-
162155
| ---- | ---- | ----------- |
163-
164156
| contractAddress | address | address of contract for which call permissions will be revoked |
165-
166157
| functionSig | string | signature e.g. "functionName(uint,bool)" |
167-
168158
| accountToRevoke | address | |

0 commit comments

Comments
 (0)