Commit f7bd20f
committed
refactor(config): move storage clamp/validation into bean postProcess
Address PR review from lxcmyf (2026-04-22, Args.java:255) — architectural
consistency with NodeConfig / VmConfig / CommitteeConfig where clamps and
validation live in the bean's own postProcess().
Before: Args.applyStorageConfig held an inline clamp for
estimatedTransactions ([100, 10000]) and an inline range check for
maxFlushCount ((0, 500]). This was carried over from develop's static
Storage helpers during the bean-binding refactor.
Now:
- SnapshotConfig.postProcess() enforces maxFlushCount in (0, 500],
throwing IllegalArgumentException on violation (same messages as develop).
- TxCacheConfig.postProcess() clamps estimatedTransactions to [100, 10000].
- StorageConfig.fromConfig() calls both alongside the existing
dbSettings.postProcess().
- Args.applyStorageConfig now simply reads already-validated values.
This also lets StorageConfig enforce its invariants when loaded standalone
(e.g. in tests) without depending on the Args bridge.
Tests (StorageConfigTest):
- testSnapshotMaxFlushCountZeroRejected
- testSnapshotMaxFlushCountNegativeRejected
- testSnapshotMaxFlushCountOver500Rejected
- testTxCacheEstimatedClampedBelowMin
- testTxCacheEstimatedClampedAboveMax
- testTxCacheEstimatedWithinRangePreserved1 parent 434d917 commit f7bd20f
3 files changed
Lines changed: 61 additions & 18 deletions
File tree
- common/src
- main/java/org/tron/core/config/args
- test/java/org/tron/core/config/args
- framework/src/main/java/org/tron/core/config/args
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
165 | 175 | | |
166 | 176 | | |
167 | 177 | | |
168 | 178 | | |
169 | 179 | | |
170 | 180 | | |
171 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
172 | 191 | | |
173 | 192 | | |
174 | 193 | | |
| |||
200 | 219 | | |
201 | 220 | | |
202 | 221 | | |
| 222 | + | |
| 223 | + | |
203 | 224 | | |
204 | 225 | | |
205 | 226 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
106 | 142 | | |
Lines changed: 4 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
246 | 241 | | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
| 242 | + | |
257 | 243 | | |
258 | 244 | | |
259 | 245 | | |
| |||
0 commit comments