Skip to content

Commit c3b1a53

Browse files
committed
docs
1 parent 684c758 commit c3b1a53

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

docs/core/AllocationManager.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Libraries and Mixins:
1010

1111
| File | Notes |
1212
| -------- | -------- |
13+
| [`SplitContractMixin.sol`](../../src/contracts/mixins/SplitContractMixin.sol) | contract splitting for codesize optimization |
1314
| [`PermissionControllerMixin.sol`](../../src/contracts/mixins/PermissionControllerMixin.sol) | account delegation |
1415
| [`Deprecated_OwnableUpgradeable`](../../src/contracts/mixins/Deprecated_OwnableUpgradeable.sol) | deprecated ownable logic |
1516
| [`Pausable.sol`](../../src/contracts/permissions/Pausable.sol) | |
@@ -29,11 +30,51 @@ The `AllocationManager` manages AVS metadata registration, registration and dere
2930

3031
The `AllocationManager's` responsibilities are broken down into the following concepts:
3132

33+
* [Contract Architecture](#contract-architecture)
3234
* [AVS Metadata](#avs-metadata)
3335
* [Operator Sets](#operator-sets)
3436
* [Allocations and Slashing](#allocations-and-slashing)
3537
* [Config](#config)
3638

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+
3778
## Parameterization
3879

3980
* `ALLOCATION_CONFIGURATION_DELAY`: The delay in blocks before allocations take effect.

0 commit comments

Comments
 (0)