Automatically merged updates to draft EIP(s) 2535 (#3071)

Hi, I'm a bot! This change was automatically merged because:

 - It only modifies existing Draft or Last Call EIP(s)
 - The PR was approved or written by at least one author of each modified EIP
 - The build is passing
This commit is contained in:
Nick Mudge 2020-10-26 09:22:54 -04:00 committed by GitHub
parent 32042e078c
commit 1cdf55466d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,37 @@ A diamond is a contract that implements the Specification in this standard.
Terminology from the diamond industry.
## Motivation
There are a number of different reasons to use diamonds. Here are some of them:
1. **Your contract exceeds the 24KB maximum contract size.** You may have related functionality that it makes sense to keep in a single contract, or at a single contract address. A diamond does not have a max contract size.
2. **A diamond provides a way to organize contract code and data.** You may want to build a contract system with a lot of functionality. A diamond provides a systematic way to isolate different functionality and connect them together and share data between them as needed in a gas-efficient way.
3. **A diamond provides a way to upgrade functionality.** Upgradeable diamonds can be upgraded to add/replace/remove functionality. Because diamonds have no max contract size, there is no limit to the amount of functionality that can be added to diamonds over time. Diamonds can be upgradeable or immutable. It is also possible to make an upgradeable diamond and then at a later time remove its upgrade capability.
### Diamonds Support Transparency
To find out what functions a regular smart contract has it is only necessary to look at its verified source code.
The verified source code of a diamond does not include what functions it has so a different mechanism is needed.
A diamond has four standard functions called the loupe functions that are used to show what functions a diamond has.
The loupe functions can be used for many things including:
1. To show all functions used by a diamond.
1. To query services like Etherscan or files to retrieve and show all source code used by a diamond.
1. To query services like Etherscan or files to retrieve ABI information for a diamond.
1. To test or verify that a transaction that adds/replaces/removes functions on a diamond succeeded.
1. To be used by tools and programming libraries to deploy and upgrade diamonds.
1. To be used by user interfaces to show information about diamonds.
1. To be used by user interfaces to enable users to call functions on diamonds.
Diamonds support another form of transparency which is a historical record of all upgrades on a diamond. This is done with the DiamondCut event which is used to record all functions that are added, replaced or removed on diamond.
This standard is an improvement of [EIP-1538 Transparent Contract Standard](https://eips.ethereum.org/EIPS/eip-1538). The same motivations of that standard apply to this standard.
See the [Learning & References section](https://eips.ethereum.org/EIPS/eip-2535#learning--references) for additional information and uses of diamonds.
## What is a Diamond?
A diamond is a contract with external functions that are supplied by contracts called **facets**.
@ -286,6 +317,7 @@ The `DiamondCut` event records all changes to a diamond.
```Solidity
interface IDiamondCut {
enum FacetCutAction {Add, Replace, Remove}
// Add=0, Replace=1, Remove=2
struct FacetCut {
address facetAddress;
@ -527,7 +559,7 @@ This standard makes upgradeable diamonds compatible with future standards and fu
[Why Ethereum Diamonds Need A Standard](https://dev.to/mudgen/why-diamonds-need-a-standard-1i1h)
[Should Diamonds Have Loupe Functions?](https://dev.to/mudgen/why-loupe-functions-for-diamonds-1kc3)
[Diamond Loupe Functions?](https://dev.to/mudgen/why-loupe-functions-for-diamonds-1kc3)
[The Diamond Standard: A new paradigm for upgradeability](https://medium.com/derivadex/the-diamond-standard-a-new-paradigm-for-upgradeability-569121a08954)
@ -579,4 +611,4 @@ This standard was also inspired by the design and implementation of the [Mokens
## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/)..