Skip to content

Backport Release v1.2 #352

Merged
ericnordelo merged 16 commits into
mainfrom
backport/release-v1.2-into-main
Jun 4, 2026
Merged

Backport Release v1.2 #352
ericnordelo merged 16 commits into
mainfrom
backport/release-v1.2-into-main

Conversation

@ericnordelo

@ericnordelo ericnordelo commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • AccessControl: Added new constructor for explicit initial admin configuration
  • Improvements

    • Fixed-point logarithm functions now produce exact results for integer powers of ten
    • Enhanced error handling and reporting in logarithm operations
  • Documentation

    • Updated AccessControl initialization guidance
    • Added v1.2.0 audit entries
    • Refined fixed-point logarithm documentation

Review Change Stack

ericnordelo and others added 10 commits May 29, 2026 13:14
* feat: update comments

* feat: apply updates

* feat: update bag references

* feat: rename param

* feat: apply review updates

* feat: rollback renmae
* feat: update delay logic

* feat: improve doc comments

* feat: improve events

* feat: apply review updates
* feat: update delay logic

* feat: improve doc comments

* feat: improve events

* feat: apply review update

* feat: apply review updates
* Fix N-02 (exact powers of 10 for log10)

* Apply minor suggestion
* Fix N-01 (Internal Precision Comment Overstates raw_log2 Error Bound)

* Fix raw_log2 precision wording
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f81d7638-228b-4e1a-9607-d07ef8ea4017

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR contains two independent feature cohorts: a major AccessControl refactoring transitioning role storage from Bag to Table with typed events, new constructor APIs, and clock-aware delay management; and fixed-point math improvements adding exact power-of-ten log10 computation and refined error handling for logarithm operations.

Changes

AccessControl Storage and API Refactoring

Layer / File(s) Summary
Storage schema and event type refactoring
contracts/access/sources/access_control.move
AccessControl struct changes from Bag-based roles to Table<TypeName, RoleData>, adds explicit default_admin: Option<address> field. Role/admin events become RootRole-parameterized and lose sender field.
Constructors and role membership operations
contracts/access/sources/access_control.move
new delegates to new_with_admin; grant_role/revoke_role use Table storage; renounce_role redesigned to remove account parameter and operate on caller only; set_role_admin updated for Table-backed lookups.
Root admin transfer and renounce state machine
contracts/access/sources/access_control.move
begin_default_admin_transfer adds self-transfer check and pending-delay refresh; accept_default_admin_transfer updates default_admin directly with role events; begin/accept renounce redesigned; cancel operations delegate to typed internal helpers.
Delay change management and clock-aware getters
contracts/access/sources/access_control.move
default_admin_delay_ms becomes clock-dependent returning effective delay; new pending delay getters take clock and return Option; begin_default_admin_delay_change refreshes elapsed changes; cancel_default_admin_delay_change requires clock and validates cancellability.
Test-only event helpers
contracts/access/sources/access_control.move
Test-only helpers updated to construct RootRole-parameterized event structs without sender field and provide default-admin event constructors.
AccessControl test suite
contracts/access/tests/access_control_tests.move
All test assertions switched to typed events (e.g., RoleGranted<ACCESS_CONTROL_TESTS>); delay getters called with explicit clock parameter; renounce calls omit account; added self-transfer and post-transfer permission tests; strengthened acceptance tests with event count deltas; added elapsed delay-change application coverage.
AccessControl documentation
contracts/access/README.md
Clarifies publishing initializing module plus AccessControl registry; specifies when to use new vs new_with_admin for initial admin selection.

Fixed-point Logarithm Exactness and Error Handling

Layer / File(s) Summary
Logarithm error code reorganization
math/fixed_point/sources/ud30x9/ud30x9_base.move
Adds u128 import; introduces ELogResultUnrepresentable (code 6) for log results on (0,1) range; updates ELogUndefined (code 5) documentation for zero/non-zero semantics.
UD30x9 logarithm power-of-ten fast path
math/fixed_point/sources/ud30x9/ud30x9_base.move
log10 detects exact powers of ten using u128::is_power_of_ten, computes scaled result exactly, and falls back to raw_log2 for non-powers; ln/log2 use new error split (ELogUndefined on zero, ELogResultUnrepresentable on (0,1)); documentation precision bounds updated.
SD29x9 logarithm implementations
math/fixed_point/sources/sd29x9/sd29x9_base.move
log10 power-of-ten fast path handles integer powers and sub-unit 10^-k with correct sign handling; log2 documentation clarifies rounding relationship; sqrt abort documentation adjusted.
Internal utilities and documentation
math/fixed_point/sources/internal/common.move, math/fixed_point/sources/sd29x9/sd29x9.move
Reorganizes constants (INTERNAL_LOG_SCALE, LOG_FACTOR_DENOM_E27) into top section; expands div_away_u256 abort documentation; adds raw_log2 precision documentation; reorders SD29x9.rem/sqrt re-exports.
Fixed-point test updates
math/fixed_point/tests/**/log{10,2}_tests.move, math/fixed_point/tests/**/ln_tests.move
Removes 1-ulp rounding expectations for power-of-ten tests, asserts exact results; updates abort code expectations from ELogUndefined to ELogResultUnrepresentable for (0,1) and zero cases; updates test names to reflect exactness.
Fixed-point public documentation
math/fixed_point/README.md
Documents log10 exactness for integer powers of ten and sub-unit 10^-k; removes note about ~1 ulp deviation at irrational identity points.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • OpenZeppelin/contracts-sui#337: Refactors AccessControl storage from Bag to Table and changes renounce_role/constructor semantics with the same signature updates as this PR.
  • OpenZeppelin/contracts-sui#339: Updates AccessControl typed Role*/DefaultAdmin* events (dropping sender), adds clock-aware default_admin_delay_ms, and revises renounce_role API changes matching this PR's core refactor.
  • OpenZeppelin/contracts-sui#344: Implements the same log10 power-of-ten exactness changes for UD30x9 and SD29x9 with identical fast-path logic and test expectation updates.

Suggested reviewers

  • immrsd
  • 0xNeshi

Poem

🐰 Behold the table-based realm,
Where AdminTransfers steer the helm,
And logs of ten compute exact,
No longer haunted by ulp-impact!
Clock-aware delays now understand,
The wisdom of this refactored land.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is completely empty; no description or checklist items were provided by the author. Add a comprehensive description including what changes are being backported, why they matter, and complete the PR checklist (Tests, Documentation, Changelog).
Title check ❓ Inconclusive The title 'Backport Release v1.2' is too vague and generic; it lacks specificity about what is being backported or why. Clarify the title to describe the main purpose, such as 'Backport v1.2 AccessControl and fixed-point math updates' or similar specific detail.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backport/release-v1.2-into-main

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.28%. Comparing base (11a0c2e) to head (6a79c48).

❌ Your project check has failed because the head coverage (42.28%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (11a0c2e) and HEAD (6a79c48). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (11a0c2e) HEAD (6a79c48)
contracts/access 1 0
math/fixed_point 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #352       +/-   ##
===========================================
- Coverage   77.15%   42.28%   -34.87%     
===========================================
  Files          23        8       -15     
  Lines        1703      402     -1301     
  Branches      630      221      -409     
===========================================
- Hits         1314      170     -1144     
+ Misses        361      225      -136     
+ Partials       28        7       -21     
Flag Coverage Δ
contracts/access ?
contracts/utils 42.28% <ø> (ø)
math/fixed_point ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@contracts/access/sources/access_control.move`:
- Around line 336-380: new_with_admin currently hands the root role immediately
to initial_admin which blocks same-transaction setup by ctx.sender(); change
new_with_admin to bootstrap ownership to ctx.sender() and register initial_admin
as pending so ctx.sender() can perform grant_role/set_role_admin calls before a
later explicit handoff: in new_with_admin set default_admin =
option::some(ctx.sender()) and pending_default_admin =
option::some(initial_admin) (keep pending_default_admin_delay_change as none and
default_admin_delay_ms as provided), and adjust the RoleGranted emission to
grant the root role to ctx.sender() instead of initial_admin; ensure the
existing acceptance function (e.g., accept_pending_default_admin or similar)
completes the transfer to pending_default_admin when called.

In `@math/fixed_point/README.md`:
- Line 95: Update the UD30x9 README line to separate the zero case from
negative-result aborts: change the sentence that currently reads “aborts on x <
1 (the result would be negative). Rounds down.” into two concise clauses
explaining (1) UD30x9 aborts for 0 < x < 1 because the fixed-point logarithm
would be negative, and (2) x == 0 is a distinct undefined/invalid input for the
log operation (not merely “negative”); reference UD30x9 explicitly so readers
see both behaviors clearly.

In `@math/fixed_point/sources/ud30x9/ud30x9_base.move`:
- Around line 289-290: The documentation comment stating "`log10(10)` may be
below `one()`" is now stale because the new power-of-ten branch makes log10(10)
exact; remove or update that sentence in the comment near the implementation of
log10 (and any mention of the kernel's precision bound) in ud30x9_base.move so
it no longer claims log10(10) can be up to 2 ulps below one(), and instead
documents the exact power-of-ten behavior introduced by the power-of-ten branch
in the log10 implementation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6ff8f863-acaa-4124-9ae1-111b09597f4d

📥 Commits

Reviewing files that changed from the base of the PR and between 11a0c2e and 159befe.

⛔ Files ignored due to path filters (2)
  • audits/2026-06-v1.2.0-access-control.pdf is excluded by !**/*.pdf
  • audits/2026-06-v1.2.0-fp-math-diff.pdf is excluded by !**/*.pdf
📒 Files selected for processing (13)
  • audits/README.md
  • contracts/access/README.md
  • contracts/access/sources/access_control.move
  • contracts/access/tests/access_control_tests.move
  • math/fixed_point/README.md
  • math/fixed_point/sources/internal/common.move
  • math/fixed_point/sources/sd29x9/sd29x9.move
  • math/fixed_point/sources/sd29x9/sd29x9_base.move
  • math/fixed_point/sources/ud30x9/ud30x9_base.move
  • math/fixed_point/tests/sd29x9_tests/log10_tests.move
  • math/fixed_point/tests/ud30x9_tests/ln_tests.move
  • math/fixed_point/tests/ud30x9_tests/log10_tests.move
  • math/fixed_point/tests/ud30x9_tests/log2_tests.move

Comment thread contracts/access/sources/access_control.move
Comment thread math/fixed_point/README.md Outdated
Comment thread math/fixed_point/sources/ud30x9/ud30x9_base.move Outdated
@0xNeshi

0xNeshi commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

@ericnordelo coderabbitai reviews actually seem relevant 👀

@immrsd immrsd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ericnordelo ericnordelo merged commit 6df7fd4 into main Jun 4, 2026
13 of 15 checks passed
@ericnordelo ericnordelo deleted the backport/release-v1.2-into-main branch June 4, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants