Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ unresolved import. Install both:

```
forge soldeer install rain-lib-leakybucket~x.y.z
forge soldeer install rain-math-float~0.2.4
forge soldeer install rain-math-float~0.2.5
```

`0.2.4` there is exact, not a floor. `src/lib/LibLeakyBucket.sol` imports
`rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol` by that literal path, and
`0.2.5` there is exact, not a floor. `src/lib/LibLeakyBucket.sol` imports
`rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol` by that literal path, and
soldeer keys the remapping it generates on the installed directory name, so any
other revision of `rain-math-float` is remapped under a different prefix and the
import does not resolve.
Expand All @@ -97,7 +97,7 @@ so an untouched mapping entry is already a valid bucket that can mint nothing,
and no initializer is needed.

```solidity
import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {LibLeakyBucket, LeakyBucket} from "rain-lib-leakybucket-x.y.z/src/lib/LibLeakyBucket.sol";

contract Token {
Expand Down Expand Up @@ -301,7 +301,7 @@ second, with a write on each of those seconds, is still exactly full after half
an hour of it.

Outside those bounds it holds to the precision of the level and no further. A
`Float` subtraction keeps about 67 digits, and `rain.math.float` at `0.2.4` does
`Float` subtraction keeps about 67 digits, and `rain.math.float` at `0.2.5` does
not direct its rounding, so a leak below the last digit the level holds is not
taken off as it is. `test/src/lib/FloatHazards.t.sol` pins both outcomes against
a level of `1e40`, whose last digit is `1e-27`: a leak of `1e-29` takes a whole
Expand All @@ -328,7 +328,7 @@ visible. Round down, so the on chain rate is never faster than the policy.
### Arithmetic, and which way it fails

Every operation is a `Float` operation from
[`rain.math.float`](https://github.com/rainlanguage/rain.math.float) at `0.2.4`.
[`rain.math.float`](https://github.com/rainlanguage/rain.math.float) at `0.2.5`.
Eight distinct operations in the whole file: `add`, `sub`, `mul`, `max`, `lt`,
`gt`, `isZero` and the `packLossless` that spells zero. There is no saturating
math, no packing, no `unchecked` block, no assembly and no hand rolled overflow
Expand Down Expand Up @@ -474,7 +474,7 @@ in CI.

Not yet audited. The intended scope is `src/`, which is one file, plus the one
dependency it imports by path: `LibDecimalFloat` from `rain-math-float` at
`0.2.4`. Every number in a bucket is a `Float` and every operation on one is
`0.2.5`. Every number in a bucket is a `Float` and every operation on one is
that library's, so a review of this library's arithmetic is a review of how it
calls that one. Nothing in this repo, and nothing in the published
`rain-math-float` package, records an audit of it — the Protofire audit of
Expand Down
23 changes: 23 additions & 0 deletions audit/mutation-test-scans.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,5 +451,28 @@
"filed": [],
"notes": "One record for the whole pull request. At the named commit: green 82 baseline, mutation-probe over mutants.toml M01 to M33, 33/33 killed, 0 survived, 0 no-run, 0 harness errors. The before figures are the previous entry's: 22 mutants, all killed by the 63 tests on main. The other 11 mutants target settle, setPolicy and the shared leak, which do not exist on main, so they have no before verdict; some of the 22 were retargeted at the new spelling of the line they mutate. No adversarial pass was run."
}
},
{
"timestamp": "2026-10-04T15:23:16Z",
"commit": "81aed807cca42ba6fcd7306f00470849f5f7c1a5",
"testsAfterCommit": "81aed807cca42ba6fcd7306f00470849f5f7c1a5",
"publishedTag": "sol-v0.4.4",
"commitsAheadOfTag": 1,
"scope": "src/lib/LibLeakyBucket.sol against rain-math-float 0.2.5 and forge-std 1.17.0; the only source change is the float import path.",
"tool": "adversarial-mutation-test",
"skillVersion": "0.35.0",
"summary": {
"behaviours": 33,
"mutantsKilledByPreExistingSuite": 33,
"mutantsSurvivedPreExistingSuite": 0,
"mutantsKilledAfter": 33,
"candidates": 0,
"confirmed": 0,
"testsBefore": 82,
"testsAfter": 82,
"coveragePRs": [],
"filed": [],
"notes": "mutation-probe over mutants.toml M01 to M33 at the named commit: green 82 baseline, 33/33 killed, 0 survived, 0 no-run, 0 harness errors. No test or mutant changed; the suite and the mutants are the previous entry's, run against the bumped dependencies. No adversarial pass was run."
}
}
]
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ libs = ["dependencies"]
fuzz.runs = 4096

[dependencies]
forge-std = "1.16.2"
forge-std = "1.17.0"
# Every field of a bucket is a `Float`: the level, the capacity, the leak rate
# and the timestamp. Saturation is gone with the fixed point, since a `Float`
# has no type boundary a bucket reaches; what remains is the clamp at zero.
"rain-math-float" = "0.2.4"
"rain-math-float" = "0.2.5"

[soldeer]
recursive_deps = false
Expand Down
16 changes: 8 additions & 8 deletions soldeer.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[[dependencies]]
name = "forge-std"
version = "1.16.2"
url = "https://soldeer-revisions.s3.amazonaws.com/forge-std/1_16_2_03-07-2026_07:37:45_forge-std-1.16.zip"
checksum = "405dccc9d60d753f6abc412b4adf0359f4390f65dbadbbb277a12b4946ed8969"
integrity = "5fb4325b60d7d4194bd0481e2f94398cf1d9c6561dd12a66fb2748ef4a68205f"
version = "1.17.0"
url = "https://soldeer-revisions.s3.amazonaws.com/forge-std/1_17_0_01-10-2026_10:59:49_forge-std-1.17.zip"
checksum = "a77ad38d5fbef0ec10d1f4d191698e5fbaa2bffbee5d1aced91a39da5e9b908c"
integrity = "fa706c8a7caf3426c90f75e6aafa3224b0a6c899b490800cf6944e4ec42f9344"

[[dependencies]]
name = "rain-math-float"
version = "0.2.4"
url = "https://soldeer-revisions.s3.amazonaws.com/rain-math-float/0_2_4_27-09-2026_15:02:57_rain.math.zip"
checksum = "a13f6e73e32324a38a2da2826484c2a03dd1ed1514851c557d90ec8f3323b940"
integrity = "70b5b63f234f24b7719bf6a296caafb9120ce185d7a3dced231a660aca7adf83"
version = "0.2.5"
url = "https://soldeer-revisions.s3.amazonaws.com/rain-math-float/0_2_5_02-10-2026_10:34:50_rain.math.zip"
checksum = "403c9a47d91114bbcaffbfe4d9c4240f7e760f86b896daa6d75d1ca891cc72b8"
integrity = "b14524ac29868af6dbaabd1086f53e142b8f1170d994972eb948fa646f817768"
2 changes: 1 addition & 1 deletion src/lib/LibLeakyBucket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity ^0.8.25;

import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";

/// A fill of `amount` does not fit: `level + amount > capacity`.
error LeakyBucketCapacityExceeded(Float capacity, Float level, Float amount);
Expand Down
4 changes: 2 additions & 2 deletions test/abstract/LeakyBucketAsserts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity ^0.8.25;

import {Test} from "forge-std-1.16.2/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Test} from "forge-std-1.17.0/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {LeakyBucketCapacityExceeded} from "../../src/lib/LibLeakyBucket.sol";
import {LeakyBucketScratch} from "./LeakyBucketScratch.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/abstract/LeakyBucketScratch.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity ^0.8.25;

import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {LibLeakyBucket, LeakyBucket} from "../../src/lib/LibLeakyBucket.sol";

/// @title LeakyBucketScratch
Expand Down
2 changes: 1 addition & 1 deletion test/concrete/GasBucket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {LibLeakyBucket, LeakyBucket} from "../../src/lib/LibLeakyBucket.sol";

/// @title GasBucket
Expand Down
4 changes: 2 additions & 2 deletions test/concrete/LeakyBucketHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {Test} from "forge-std-1.16.2/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Test} from "forge-std-1.17.0/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {LeakyBucketMintCap} from "./LeakyBucketMintCap.sol";
import {LeakyBucketCapacityExceeded} from "../../src/lib/LibLeakyBucket.sol";
import {LeakyBucketAsserts} from "../abstract/LeakyBucketAsserts.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/concrete/LeakyBucketMintCap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {LibLeakyBucket, LeakyBucket} from "../../src/lib/LibLeakyBucket.sol";

/// @title LeakyBucketMintCap
Expand Down
2 changes: 1 addition & 1 deletion test/lib/FloatWords.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity ^0.8.25;

import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";

/// A whole number as a `Float` at exponent zero.
///
Expand Down
2 changes: 1 addition & 1 deletion test/lib/LibLeakyBucketSlow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity ^0.8.25;

import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";

/// @title LibLeakyBucketSlow
/// @notice The leak one step at a time, as an oracle for the closed form.
Expand Down
2 changes: 1 addition & 1 deletion test/lib/WorkedPolicy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity ^0.8.25;

import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {float} from "./FloatWords.sol";

// The worked policy: a 3600 unit burst draining at one unit per second.
Expand Down
4 changes: 2 additions & 2 deletions test/src/lib/CapacityBound.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {Test} from "forge-std-1.16.2/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Test} from "forge-std-1.17.0/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {LeakyBucketCapacityExceeded} from "../../../src/lib/LibLeakyBucket.sol";
import {workedCapacity, workedLeakRate, workedDrain, capacityOver} from "../../lib/WorkedPolicy.sol";
import {LeakyBucketAsserts} from "../../abstract/LeakyBucketAsserts.sol";
Expand Down
4 changes: 2 additions & 2 deletions test/src/lib/FloatHazards.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {Test} from "forge-std-1.16.2/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Test} from "forge-std-1.17.0/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
Comment thread
thedavidmeister marked this conversation as resolved.
Outdated
import {
LibLeakyBucket,
LeakyBucket,
Expand Down
4 changes: 2 additions & 2 deletions test/src/lib/LeakyBucketEmbedding.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {Test} from "forge-std-1.16.2/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Test} from "forge-std-1.17.0/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {LeakyBucketMintCap} from "../../concrete/LeakyBucketMintCap.sol";
import {
LeakyBucketCapacityExceeded,
Expand Down
4 changes: 2 additions & 2 deletions test/src/lib/LeakyBucketInvariant.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {Test} from "forge-std-1.16.2/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Test} from "forge-std-1.17.0/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {LeakyBucketMintCap} from "../../concrete/LeakyBucketMintCap.sol";
import {LeakyBucketHandler} from "../../concrete/LeakyBucketHandler.sol";

Expand Down
6 changes: 3 additions & 3 deletions test/src/lib/LibLeakyBucket.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {Test} from "forge-std-1.16.2/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {ExponentOverflow} from "rain-math-float-0.2.4/src/error/ErrDecimalFloat.sol";
import {Test} from "forge-std-1.17.0/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {ExponentOverflow} from "rain-math-float-0.2.5/src/error/ErrDecimalFloat.sol";
import {
LeakyBucket,
LeakyBucketCapacityExceeded,
Expand Down
4 changes: 2 additions & 2 deletions test/src/lib/LibLeakyBucketGas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {Test, console2} from "forge-std-1.16.2/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.4/src/lib/LibDecimalFloat.sol";
import {Test, console2} from "forge-std-1.17.0/src/Test.sol";
import {Float, LibDecimalFloat} from "rain-math-float-0.2.5/src/lib/LibDecimalFloat.sol";
import {GasBucket} from "../../concrete/GasBucket.sol";
import {LeakyBucketCapacityExceeded} from "../../../src/lib/LibLeakyBucket.sol";
import {workedCapacity, workedLeakRate, workedDrain} from "../../lib/WorkedPolicy.sol";
Expand Down
Loading