Skip to content

Check pow10 and log10 against the oracle, not the unrounded functions - #411

Merged
thedavidmeister merged 5 commits into
mainfrom
2026-10-09-issue-386-independent-rounding-oracles
Oct 10, 2026
Merged

thedavidmeister merged 5 commits into
mainfrom
2026-10-09-issue-386-independent-rounding-oracles

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Closes #386

Test-only. The pow10/log10 rounding and relation tests no longer use the unrounded functions as their own oracle.

  • testLog10RoundsUnrounded (circular against log10Unrounded) is replaced by testLog10WithinOracle. It covers the same domain and asserts that log10 is within the README bound of LibTranscendentalOracle.log10, compared exactly in U512 at 1e-70.
  • testLog10DecadeShift, testLog10Monotone, testPow10DecadeShift, testPow10Monotone and testNoRevert keep their relations and now also check each result against the oracle.
  • New testPow10NearTiesWithinBound checks the four testPow10RoundsHalfUp inputs against 70-digit bc values (scale 220), within the README pow10 bound.
  • LibTranscendentalOracle.exp10's NatSpec domain is widened to "integer part fits int256"; the exponent ≥ 0 branch is exact.

Open question, not changed here: testPow10RoundsHalfUp is left as is. The true values of its inputs sit 9.6e-11 to 1.78e-9 of a unit from a 41st-digit tie, inside the README's allowed 3.28e-8. So the documented bound accepts either neighbour, and the tie behaviour can only be pinned through pow10Unrounded. Relatedly, for x = 62876337819492131669053461917963730523385842721800e-50 the true 10^x is just above a tie, but pow10 rounds down. That is within the bound, but conflicts with a literal reading of the NatSpec "rounded to nearest, half up".

Overlap: PR #354 edits the same two files, including the decade-shift and monotone tests, and moves the remaining library-arithmetic call sites. Whichever merges second takes a textual rebase.

QA

  • Discriminating tests: L3 (log10Unrounded + 1e-30) survived the old targeted tests and is killed by testLog10WithinOracle alone. P3 and L4, previously killed only through the circular remainder checks, are now killed by the oracle checks.
  • Mutations applied: 7 mutants in LibDecimalFloatImplementation.sol: L1 (roundSignificant tie >=→>, survives before and after), L2 (log10 truncates), L3, L4 (POW_FIXED_LN10 off at digit 30), P1 (pow10 guard tie rounds down, killed only by testPow10RoundsHalfUp), P2 (pow10 truncates), P3 (exp10Fixed 10^(1/4) off at digit 30). Full two-file suite: 6/7 before and after.
  • Oracle: LibTranscendentalOracle (Taylor and atanh series over OpenZeppelin mulDiv, bc constants) plus 70-digit bc references, with the README bounds.
  • Category check: test: pow10/log10 rounding tests use the unrounded function as their own oracle #386 bullet 2 is replaced; bullet 3 is anchored to the oracle; bullet 1 gains a bc check, but its tie assertions await the ruling above; bullet 4 is Bound the transcendental tests independently of the implementation #354's scope. forge test: 827 passed.

🤖 Generated with Claude Code

testLog10RoundsUnrounded took its expected value from log10Unrounded.
testLog10WithinOracle bounds log10 against LibTranscendentalOracle.log10
by the README's half a unit plus 2e-50, over the same inputs. The decade
shift, monotone and no-revert tests of both functions, which compared
the implementation only with itself, also check each result against the
oracle. testPow10NearTiesWithinBound checks the testPow10RoundsHalfUp
inputs against bc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d9168ca6-25d7-4867-a166-e2006cc92816

📥 Commits

Reviewing files that changed from the base of the PR and between c63e295 and 420adb5.


📒 Files selected for processing (5)
  • README.md
  • src/lib/implementation/LibDecimalFloatImplementation.sol
  • test/lib/LibTranscendentalOracle.sol
  • test/src/lib/implementation/LibDecimalFloatImplementation.log10.t.sol
  • test/src/lib/implementation/LibDecimalFloatImplementation.pow10.t.sol

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

baku-ccron and others added 4 commits October 9, 2026 17:55
…bound

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thedavidmeister
thedavidmeister merged commit d5605ae into main Oct 10, 2026
7 of 8 checks passed
@github-actions

Copy link
Copy Markdown

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

@linear

linear Bot commented Oct 10, 2026

Copy link
Copy Markdown

RAI-3154

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.

test: pow10/log10 rounding tests use the unrounded function as their own oracle

1 participant