You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-22Lines changed: 20 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,30 +12,28 @@ forge test
12
12
```
13
13
14
14
## Storage layout of `SemVerProxy`
15
-
`SemVerProxy` reserves storage slots **0 to 99** for implementation contracts by declaring a fixed-size array that occupies these slots:
16
-
```solidity
17
-
uint256[100] private __gap; // Reserves slots 0-99 for implementations
18
-
```
19
-
So, the storage layout of a proxy and an arbitrary implementation contract can be represented as follows:
15
+
`SemVerProxy` stores variables in the storage, starting at slot 1000. Therefore, implementation contracts can safely use all storage slots except 1000, 1001, and 1002.
16
+
So, the storage layout of the proxy and an arbitrary implementation contract can be represented as follows:
20
17
```text
21
18
Proxy storage layout:
22
-
┌─────────────┐
23
-
│ Slot 0-99 │ ← `__gap` placeholder (reserved for implementations)
24
-
├─────────────┤
25
-
│ Slot 100 │ ← `_latestVersion`
26
-
│ Slot 101 │ ← Other state variables
27
-
│ ... │
28
-
└─────────────┘
19
+
┌───────────────┐
20
+
│ Slot 0-1000 │ ← empty
21
+
├───────────────┤
22
+
│ Slot 1000 │ ← `_latestVersion`
23
+
│ Slot 1001 │ ← `_releases` mapping
24
+
│ Slot 1002 │ ← `_subscribedClients` mapping
25
+
│ ... │
26
+
└───────────────┘
29
27
30
-
Implementation storage example:
31
-
┌─────────────┐
32
-
│ Slot 0 │ ← Implementation's first state variable
33
-
│ Slot 1 │ ← Implementation's second state variable
34
-
│ ... │
35
-
│ Slot 99 │ ← Last available slot for implementation
36
-
├─────────────┤
37
-
| Slot 100| ← ⚠️ This will collide with proxy's storage
38
-
└─────────────┘
28
+
Implementation's storage example:
29
+
┌───────────────┐
30
+
│ Slot 0 │ ← Implementation's 1st state variable
31
+
│ Slot 1 │ ← Implementation's 2nd state variable
32
+
│ ... │
33
+
│ Slot 999│ ← Implementation's 998th state variable
34
+
├───────────────┤
35
+
| Slot 1000 │ ← ⚠️ This will collide with proxy's storage
36
+
└───────────────┘
39
37
```
40
38
41
39
## Releases and Versioning
@@ -91,5 +89,5 @@ function unsubscribeFromVersioning() external;
91
89
```
92
90
93
91
## Security Considerations
94
-
-Since `SemVerProxy` only reserves slots from 0 to 99, any 100+ slot of the implementation will collide with proxy.
92
+
-Storing variables in implementation's storage at slots 1000, 1001, 1002 will collide with the proxy's storage.
95
93
-`SemVerProxy` has externally accessable function, therefore there's a possibiliy of function selector clash (i.e., if implementation defines functions that have the same signature as external functions of `SemVerProxy`).
0 commit comments