Skip to content

Commit e88a462

Browse files
committed
test(host-contracts): document HCULimit invariants in plain english
1 parent b091861 commit e88a462

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

host-contracts/test/hcuLimit/HCULimit.invariants.t.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,24 +176,29 @@ contract HCULimitInvariantTest is StdInvariant, Test {
176176
}
177177

178178
function invariant_blockMeterMatchesCurrentBlock() public view {
179+
// Invariant: getBlockMeter must always report the current block number.
179180
(uint64 blockNumber,) = hcuLimit.getBlockMeter();
180181
assertEq(blockNumber, uint64(block.number));
181182
}
182183

183184
function invariant_blockMeterUsesCastGranularity() public view {
185+
// Invariant: accounted block HCU is made of Uint8 cast ops (32 HCU each), so it stays a multiple of 32.
184186
(, uint192 usedHCU) = hcuLimit.getBlockMeter();
185187
assertEq(uint256(usedHCU) % 32, 0);
186188
}
187189

188190
function invariant_whitelistedCallsDoNotConsumePublicMeter() public view {
191+
// Invariant: calls from whitelisted callers must never increase the public block meter.
189192
assertFalse(handler.whitelistViolation());
190193
}
191194

192195
function invariant_nonWhitelistedAccountingIsConsistent() public view {
196+
// Invariant: for non-whitelisted callers, meter growth equals successful op count times cast-op cost.
193197
assertFalse(handler.nonWhitelistedAccountingViolation());
194198
}
195199

196200
function invariant_meterResetsAfterMinedBlocks() public view {
201+
// Invariant: once the block number advances, observed usedHCU for the new block is zero until a new op succeeds.
197202
assertFalse(handler.resetViolation());
198203
}
199204

0 commit comments

Comments
 (0)