Commit 95a26147 authored by Matt Solomon's avatar Matt Solomon Committed by GitHub

doc: update style guide (#11290)

* doc: update style guide

* apply suggestion from code review
Co-authored-by: default avatarMaurelian <john@oplabs.co>

* Update packages/contracts-bedrock/STYLE_GUIDE.md

---------
Co-authored-by: default avatarMaurelian <john@oplabs.co>
parent e0c733d5
...@@ -104,9 +104,15 @@ Unless explicitly discussed otherwise, you MUST include the following basic upgr ...@@ -104,9 +104,15 @@ Unless explicitly discussed otherwise, you MUST include the following basic upgr
pattern for each new implementation contract: pattern for each new implementation contract:
1. Extend OpenZeppelin's `Initializable` base contract. 1. Extend OpenZeppelin's `Initializable` base contract.
2. Include a `uint8 public constant VERSION = X` at the TOP of your contract. 2. Include a function `initialize` with the modifier `initializer()`.
3. Include a function `initialize` with the modifier `reinitializer(VERSION)`. 3. In the `constructor`:
4. In the `constructor`, set any `immutable` variables and call the `initialize` function for setting mutables. 1. Call `_disableInitializers()` to ensure the implementation contract cannot be initialized.
2. Set any immutables. However, we generally prefer to not use immutables to ensure the same implementation contracts can be used for all chains, and to allow chain operators to dynamically configure parameters
Because `reinitializer(uint64 version)` is not used, the process for upgrading the implementation is to atomically:
1. Upgrade the implementation to the `StorageSetter` contract.
2. Use that to set the initialized slot (typically slot 0) to zero.
3. Upgrade the implementation to the desired new implementation and `initialize` it.
### Versioning ### Versioning
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment