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: CHANGELOG.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,10 +45,31 @@ forge lint
45
45
- Update surya doc by running the 3 scripts in [./doc/script](./doc/script)
46
46
- Update changelog
47
47
48
+
### v3.0.0-rc3 - 2026-04-28
48
49
50
+
### Security
51
+
52
+
- Enforce an on-chain maximum rule count in `RulesManagementModule` to mitigate transfer liveness risk from unbounded per-transfer rule iteration (Nethermind AuditAgent finding 3 follow-up).
53
+
- Add cap checks in both `addRule` and `setRules`, reverting with `RuleEngine_RulesManagementModule_MaxRulesExceeded(uint256)` when exceeded.
54
+
55
+
### Added
56
+
57
+
- Add `maxRules()` and `setMaxRules(uint256)` to `IRulesManagementModule`.
58
+
- Add `DEFAULT_MAX_RULES = 10` and initialize module state with this default cap.
59
+
- Add `SetMaxRules(uint256)` event emitted on cap updates.
60
+
- Add dedicated access-control hook for cap governance:
61
+
-`RuleEngine`: `DEFAULT_ADMIN_ROLE` can update cap.
62
+
-`RuleEngineOwnable` and `RuleEngineOwnable2Step`: owner can update cap.
63
+
64
+
### Testing
65
+
66
+
- Add tests for default cap value, cap enforcement for `addRule` and `setRules`, and access control on `setMaxRules`.
Copy file name to clipboardExpand all lines: README.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,7 @@ This diagram illustrates how a transfer with a CMTAT or ERC-3643 token with a Ru
67
67
2. The transfer function inside the token calls the ERC-3643 function `transferred` from the RuleEngine with the following parameters inside: `from, to, value`.
68
68
3. The Rule Engine calls each rule separately. If the transfer is not authorized by the rule, the rule must directly revert (no return value).
69
69
70
-
> **Warning:** The RuleEngine iterates over all configured rules on every transfer (and on every call to `detectTransferRestriction`, `canTransfer`, etc.). Adding a large number of rules increases gas consumption for each transfer and may eventually exceed the block gas limit, effectively preventing any transfer from succeeding. There is no hard on-chain maximum rule count; administrators are responsible for sizing the rule set for their target blockchain and should keep it small. A misconfigured or gas-heavy rule can also impact all transfers.
70
+
> **Warning:** The RuleEngine iterates over all configured rules on every transfer (and on every call to `detectTransferRestriction`, `canTransfer`, etc.). Adding a large number of rules increases gas consumption for each transfer and may eventually exceed the block gas limit, effectively preventing any transfer from succeeding. An on-chain rule cap is enforced (`maxRules`), set to `10` by default, and can be changed by governance (`DEFAULT_ADMIN_ROLE` on `RuleEngine`, owner on ownable variants). A misconfigured or gas-heavy rule can still impact all transfers.
71
71
72
72
> **Warning (restriction code conventions):** Rule implementations should use unique ERC-1404 restriction codes across the rule set. If several rules intentionally share the same restriction code, they should return the exact same `messageForTransferRestriction` text for that code to avoid inconsistent operator/user feedback.
73
73
@@ -77,6 +77,7 @@ This diagram illustrates how a transfer with a CMTAT or ERC-3643 token with a Ru
`addRule`/`setRules` have no cap on rule count. `_transferred` and `_detectTransferRestriction` loop over all rules per transfer. Adding too many rules can push gas cost above the block limit, permanently freezing token operations.
96
96
97
97
### Developer assessment
98
98
99
-
**Partially agree.** The risk is real as an operational concern. However, a fixed on-chain maximum would be deployment-dependent and potentially overly restrictive across different blockchains and rule complexities. Operator responsibility is retained; the mitigation is explicit documentation.
99
+
**Updated in rc3: fully addressed on-chain.** The prior rc2 docs-only mitigation was insufficient for liveness guarantees. `v3.0.0-rc3` introduces an on-chain configurable cap with a safe default.
100
100
101
101
### Implementation
102
102
103
-
-**`src/modules/RulesManagementModule.sol`**:
104
-
-`setRules`: "No on-chain maximum number of rules is enforced. Operators are responsible for keeping the rule set size compatible with the target chain gas limits."
105
-
-`addRule`: "No on-chain maximum number of rules is enforced. Adding too many rules can increase transfer-time gas usage because rule checks are linear in rule count."
106
-
-`_transferred` (both overloads): "Complexity is O(number of configured rules). Large rule sets can make transfers too expensive on chains with lower block gas limits."
107
-
-**`README.md`** — explicit "How it works" warning paragraph added about gas scaling and absence of an on-chain rule count cap.
0 commit comments