Commit b7b7cc6
[N-01] Core Math Audit (#357)
* feat: Implement Rate Limiter module (#315)
* feat: add rate limiter implementation
* docs: document invariants
* fix: enforce missing invariants
* test: add more tests
* feat: cooldown supports capacity/used
* ref: assume monotonic Clock
* fix: new_bucket accepts initial tokens (remove new_bucket_with_tokens)
* ref: track cooldown_end instead of last_used
* fix: cooldown used increases by 1 on consume
* ref: use 'available' design instead of 'used'
* ref: inline roll_window
* test: add cooldown_reconfigure_rearms_when_drained_and_deadline_elapsed
* docs: mention operator's responsibility for cooldown_ms
* ref: rename q to steps_to_full in bucket_accrue
* docs: update invariants
* fix: remove capacity + refill_amount assertion in assert_bucket_config
* docs: add missing / update docs
* feat: add variety of errors
* docs: add missing / update docs
* test: remove invariant class mentions
* ref: apply Code Quality Checklist (openzeppelin_utils)
* test: replace cleanup with 'abort EUnreachable' in expected-failure tests
* test: use abort 0 instead of error
* feat: remove 'Ms' suffix from Error names
* docs: error docs don't reference internal variables
* docs: rephrase rate_limiter error messages without internal field names
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs: update README
* docs: update README
* docs: align invariants.md to be sharing-ready
* docs: improve wording & clarity for invariants.md
* feat: cooldown now decrements available by amount
* test: change abort 0 to 100 (avoids confusing with ERateLimited)
* test: change all destructor patterns into abortions
* docs: invariant rewording
* docs: update format for invariants.md
* docs: update format for invariants.md and add missing invariants
* docs: align invariants format
* docs: update outdated invariant references
* docs: remove rate limiter temp. artifacts
* chore: simplify changelog
* ref: convert assert macros into funs
* docs: document private funs
* test(fix): add proper teardown in happy tests
* ci: add contracts/utils to CI test job dir matrix
* test: add regression tests for bucket_accrue
* fix: bucket_accrue double spend bug
* docs: add empty line before enum variant docs
Co-authored-by: Daniel Bigos <daniel.bigos96@gmail.com>
* Revert "docs: add empty line before enum variant docs"
This reverts commit 21a9076.
* feat: inline config validation assertions
* docs: add more info on rate limiter types in README
* docs: add clarifying comments for apparent overflow suspects
* docs: mention library being access control-agnostic
* docs: reword library to module
* feat: add initial_available to all limiter types
* ref: put capacity as first cooldown type field
* ref: use spread op instead of ignoring cooldown_ms field
* docs: show identical API for all types in README
* docs: for fixed window update wording that it resets to full capacity
* fix: reconfigure sets last_refill to now + forbid 0 initial available for cooldown
* docs: remove post-core artifact
* test: add bucket_reconfigure_to_faster_rate_discards_old_subinterval
* docs: add SAFETY before overflow-related comments
* test: verify available always returns up-to-date accrual state
* test: add missing zero-config reconfigure tests
* test: add try_consume_with_zero_amount for all limiter types
* test: add try_consume_of_available_aborts_when_drained
* docs: note that try_consume(0) aborts after available() == 0
* docs: note RateLimiter enum is not upgrade-compatible
Adding variants or fields to a deployed public enum would break BCS
deserialization for integrator objects that already stored the prior
shape. Document this constraint at the module level.
* test: add edge case test cases
* docs: remove llm artifacts
* ref: reorder fileds in new_cooldown
* test: remove Pub.local.toml
* ref: in reconfigure_fixed_window move let now into match
* ref: in reconfigure_bucket move let now into match
* docs: remove mention of reconfigure_cooldown clamping available to 0
* fix: align cooldown clamp behavior on reconfigure
* fix: try_consume updates state only on success
* docs: align
* ref: fixedwindow now shares bucket's internal logic
* ref: update capacity prior to accrual on reconfigure_bucket
* docs: add comment
* Revert "docs: add comment"
This reverts commit ecb0145.
* Revert "ref: update capacity prior to accrual on reconfigure_bucket"
This reverts commit b545b6d.
* ref: Rate Limiter: Reconfiguration via Rich `new_*` Functions (#326)
* impl
* simplify further
* fix: expose last_refill_ms for bucket
* tests: add missing
* docs: update utils README
* docs: fix new_cooldown accepted combos
* feat: project bucket-shaped anchor getters
`last_refill_ms` and `window_start_ms` now take `&Clock` and return the
anchor advanced by every whole interval elapsed since the last commit,
so the snapshot `(anchor, available(clock))` is internally coherent.
`cooldown_end_ms` stays a plain getter — a cooldown deadline does not
evolve with time.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: error numbering
* fix: error messages no longer reference private fields
* docs: move EBucketAnchorInFuture comment next to the error
* add spec
* update spec
* tests: add missing invariant tests
* feat: add is_type discriminator getters
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>
Co-authored-by: Daniel Bigos <daniel.bigos96@gmail.com>
* tests: fix formatting in rate limiter tests (#334)
* feat: add median implementation (#135)
* add separate quick_sort implementations for each type
* remove duplicated qsort implementations
* add in-place qsort implementation
* add partition function
* rewrite qsort without recursion
* convert quick_sort to macro
* add comprehensive test cases for qsort
* update qsort documentation
* add review fixes
* remove --trace flag from testing pipeline
* Revert "remove --trace flag from testing pipeline"
This reverts commit 9bf7065.
* split macro module
* inline partition macro
* add median implementation
* add more edge case test cases
* fix fmt
* remove quick_sort duplicate
* feat: add median
* docs: update PR
* Route median through u256 workhorse fun (#325)
* fix: fmt
* fix: apply CR comments
* test: add missing test
* fix: macro
* feat: use quickselect
* feat: improve CHANGELOG
* feat: apply review updates
* feat: update comment
---------
Co-authored-by: Daniel Bigos <daniel.bigos@openzeppelin.com>
Co-authored-by: Daniel Bigos <daniel.bigos@icloud.com>
Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com>
Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>
* feat: update check
* feat: update version
---------
Co-authored-by: Nenad <nenad.misic@openzeppelin.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Daniel Bigos <daniel.bigos96@gmail.com>
Co-authored-by: Alisander Qoshqosh <37006439+qalisander@users.noreply.github.com>
Co-authored-by: Daniel Bigos <daniel.bigos@openzeppelin.com>
Co-authored-by: Daniel Bigos <daniel.bigos@icloud.com>
Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com>1 parent 24c5e22 commit b7b7cc6
4 files changed
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
0 commit comments