|
1 | 1 | --- |
2 | | -title: Upgrades to the Colony Network |
| 2 | +title: The Delegate Proxy Pattern |
3 | 3 | section: Docs |
4 | | -order: 10 |
| 4 | +order: 2 |
5 | 5 | --- |
| 6 | +The contracts comprising the Colony Network are upgradeable using the Delegate Proxy design pattern. |
6 | 7 |
|
7 | | -Improvements to the Colony Network are expected to be continuously developed and periodically deployed. |
| 8 | +Providing an upgrade path is important to allow for the continuous improvement of the Colony Network. At the same time, all depreciated versions of Colony should remain functional indefinitely after deployment, so that the organizations created are not predicated upon the actions/efforts of a third party. |
8 | 9 |
|
9 | | -Providing an upgrade path is important to allow people to use Colony without preventing themselves using new features as they are added to the Network. At the same time, all depreciated versions of Colony should remain functional indefinitely after deployment, so that the organizations created are not predicated upon the actions/efforts of a third party. |
| 10 | +In other words, upgrades to any individual colony on the network are "opt-in", while the network as a whole remains eternally backwards-compatible. |
10 | 11 |
|
11 | | -The contracts comprising the Colony Network are upgradeable using the design pattern called EtherRouter. |
| 12 | +## For whom the delegate calls |
| 13 | +Interacting with both the Colony Network and individual colonies on the network is somewhat different than many other smart contract interactions that a blockchain developer might not be accustomed to. |
12 | 14 |
|
13 | | -## EtherRouter |
14 | | -This pattern uses two contracts in addition to the contract(s) providing their intended functionality: |
| 15 | +Rather than calling functions directly from the contract in which they are deployed, all transactions are signed and sent to the `EtherRouter` contract. |
15 | 16 |
|
16 | | -* The `EtherRouter` contract which passes transactions (via `delegatecall`) to the contract that implements the called function. |
17 | | -* A `Resolver` contract where the addresses of the contracts that implement the desired function are defined. |
| 17 | +Whenever a transaction is received by the `EtherRouter` contract, it looks the function up in a `Resolver` contract, using the function signature. |
18 | 18 |
|
19 | | -Whenever a transaction is received by the `EtherRouter` contract, it looks up the contract that implements that function (if any) in the `Resolver`, and then `delegatecall`s that contract. |
| 19 | +The `Resolver` contract contains a mapping of whitelisted function signatures to addresses (`mapping ( bytes4 => address )`). |
| 20 | + |
| 21 | +A function signature lookup will return the address of the contracts that implement the desired function. `EtherRouter` in turn calls the function via `delegatecall`, and passes any returns from the call back to `msg.sender`. |
20 | 22 |
|
21 | 23 |  |
22 | 24 |
|
23 | | -In order to upgrade, new contracts are deployed with new functionality, and then contracts that the `Resolver` contract points to must be changed to point to these new contracts. |
| 25 | +This pattern enables both fine-grained control of permissions for individual functions (see below), well as eternal backwards-compatibility following network upgrades. To learn more about planned upgrades to the Colony Network, please see [Releases](/colonynetwork/docs-releases/). |
| 26 | + |
| 27 | +## It calls for `roleId` |
| 28 | +Most functions in colony are *authorized* by a separate contract which defines the rules for who can call which functions. Any function that is decorated with the `auth` modifier will perform an authorization check before granting access to the function. |
| 29 | + |
| 30 | +In the current Glider release, authority is based on roles, which are defined in the relevant "authority" contracts, e.g. `ColonyAuthority.sol`. |
| 31 | + |
| 32 | +Roles within Colony act as a white-list for functions, registering specific addresses to a `Founder` or `Admin` role, approved to call a certain set of functions within a colony. |
24 | 33 |
|
25 | | -In order to avoid a situation where the contract partially implements both old and new functionality, a new instance of `Resolver` will be deployed for each upgrade, and then a single transaction can point `EtherRouter` at the new Resolver. |
| 34 | +Roles also are used in task-level permissions. A more specific example of task roles can be seen in the [task workflow](https://docs.colony.io/colonyjs/topics-task-lifecycle/#task-roles). |
26 | 35 |
|
27 | | -This pattern applies for both upgrades to individual colonies as well as to the Network-level contracts. |
| 36 | +In future releases, this pattern will allow for reputation-mediated authority in Colony. |
0 commit comments