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
@@ -29,11 +30,51 @@ The `AllocationManager` manages AVS metadata registration, registration and dere
29
30
30
31
The `AllocationManager's` responsibilities are broken down into the following concepts:
31
32
33
+
*[Contract Architecture](#contract-architecture)
32
34
*[AVS Metadata](#avs-metadata)
33
35
*[Operator Sets](#operator-sets)
34
36
*[Allocations and Slashing](#allocations-and-slashing)
35
37
*[Config](#config)
36
38
39
+
## Contract Architecture
40
+
41
+
The `AllocationManager` uses a **split contract pattern** implemented via the `SplitContractMixin` to address EVM contract size limitations while maintaining full backwards compatibility.
42
+
43
+
### Split Contract Pattern
44
+
45
+
**Main Contract (`AllocationManager`):**
46
+
- Contains all state-mutating functions (actions)
47
+
- Inherits from `SplitContractMixin` which provides delegation capabilities
48
+
- Delegates all view function calls to the separate view contract
49
+
- Maintains the same external interface as a monolithic contract
50
+
51
+
**View Contract (`AllocationManagerView`):**
52
+
- Contains all read-only view functions
53
+
- Shares the same storage layout as the main contract using `layout at 151` directive
54
+
- Implements the same `IAllocationManagerView` interface
55
+
56
+
### Rationale
57
+
58
+
**Codesize Optimization:**
59
+
- The EVM has a contract size limit of 24KB (24,576 bytes) for deployed contracts
60
+
- Complex contracts like `AllocationManager` with extensive functionality can exceed this limit
61
+
- By splitting view functions into a separate contract, the main contract stays under the size limit
62
+
- This allows for more comprehensive functionality without compromising deployability
63
+
64
+
**Backwards Compatibility:**
65
+
- The external interface remains identical to a monolithic contract
66
+
- All existing integrations continue to work without modification
67
+
- View functions are transparently delegated using `_delegateView()`
68
+
- No breaking changes to the ABI or function signatures
69
+
70
+
**Implementation Details:**
71
+
- View functions in the main contract use `_delegateView(viewImplementation)` to delegate calls
72
+
- The `viewImplementation` address is set during construction and stored as an immutable variable
73
+
- The `_delegateView()` function uses assembly to safely cast the non-view `_delegate()` function to a view context
74
+
- Storage layout alignment ensures both contracts access the same state variables correctly
75
+
76
+
This pattern is particularly valuable for complex contracts that need extensive view functionality while maintaining the ability to perform state mutations, ensuring both functionality and deployability on the EVM.
77
+
37
78
## Parameterization
38
79
39
80
*`ALLOCATION_CONFIGURATION_DELAY`: The delay in blocks before allocations take effect.
0 commit comments