pi constant word#535
Conversation
Add a `pi` standard op mirroring the existing `e` word (LibOpE), stacking the mathematical constant pi as a Float. - New `LibOpPi` library with integrity/run/referenceFn, encoding pi as a Float at the same precision/convention as `LibDecimalFloat.FLOAT_E` (67-digit coefficient * 10^-66; round-trips to pi to 66 decimal places). - Register `pi` in `LibAllStandardOps` between `mul` and `power` across all four parallel arrays (authoring meta, operand handlers, integrity pointers, opcode pointers); bump ALL_STANDARD_OPS_LENGTH 72 -> 73. - Update the word-ordering assertions in LibAllStandardOps.t.sol. - Add `LibOpPi.t.sol` mirroring `LibOpE.t.sol` (parse + eval to pi, integrity, operand-disallowed, bad input/output arity). - Regenerate bytecode pointer artifacts: interpreter, parser, expression deployer, and Rainlang `.pointers.sol` (creation/runtime code, deploy addresses, codehashes, parse-meta, function pointer tables) plus the CBOR authoring meta. Converged to a stable fixed point. This is a deployed-interpreter-bytecode change: the pinned deploy addresses and codehashes change, so landing REQUIRES the multi-network interpreter redeploy workflow (per #237 / the LibOpE class of change). Closes #225 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 12 minutes and 29 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (36)
📝 WalkthroughWalkthroughAdds a Changespi opcode implementation, wiring, and artifacts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
The pi opcode changes the interpreter bytecode, which cascades through the expression deployer, parser, and Rainlang registry. Refresh the committed forge ABI artifacts so the copy-artifacts determinism check passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@src/lib/op/math/LibOpPi.sol`:
- Around line 11-12: The NatSpec documentation block in LibOpPi.sol for the pi
constant has an explicit `@dev` tag on line 11 but line 12 (containing the
hexadecimal representation) is untagged. According to NatSpec formatting rules,
when a block uses explicit tags, all lines must be explicitly tagged. Add the
`@dev` tag to line 12 to properly tag the continuation of the pi constant
documentation.
- Line 3: The pragma declaration in LibOpPi.sol uses a caret range (^0.8.25)
which allows multiple compiler versions and violates the requirement for
deterministic builds. Change the pragma solidity statement from using the caret
operator (^) to an equals operator (=) to pin the exact version. Replace pragma
solidity ^0.8.25; with pragma solidity =0.8.25; to enforce exact version
matching as required by the coding guidelines.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 379c9863-5c0c-4155-9707-a529c59b7d1f
⛔ Files ignored due to path filters (4)
src/generated/Rainlang.pointers.solis excluded by!**/generated/**src/generated/RainlangExpressionDeployer.pointers.solis excluded by!**/generated/**src/generated/RainlangInterpreter.pointers.solis excluded by!**/generated/**src/generated/RainlangParser.pointers.solis excluded by!**/generated/**
📒 Files selected for processing (11)
crates/bindings/abi/Rainlang.jsoncrates/test_fixtures/abi/Rainlang.jsoncrates/test_fixtures/abi/RainlangExpressionDeployer.jsoncrates/test_fixtures/abi/RainlangInterpreter.jsoncrates/test_fixtures/abi/RainlangParser.jsonmeta/AuthoringMeta.rain.metameta/RainlangExpressionDeployer.rain.metasrc/lib/op/LibAllStandardOps.solsrc/lib/op/math/LibOpPi.soltest/src/lib/op/LibAllStandardOps.t.soltest/src/lib/op/math/LibOpPi.t.sol
| @@ -0,0 +1,49 @@ | |||
| // SPDX-License-Identifier: LicenseRef-DCL-1.0 | |||
| // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd | |||
| pragma solidity ^0.8.25; | |||
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Pragma in changed Solidity file:"
rg -n '^pragma solidity' src/lib/op/math/LibOpPi.sol
echo
echo "Checking toolchain config for Cancun target (if foundry.toml exists):"
fd -H 'foundry.toml' | xargs -r rg -n '^\s*(evm_version|solc_version)\s*='Repository: rainlanguage/rainlang
Length of output: 222
Pin pragma to exact 0.8.25.
Line 3 uses pragma solidity ^0.8.25; (caret range), but the repository requires exact version pinning to ensure deterministic builds and compiler behavior consistency.
Suggested fix
-pragma solidity ^0.8.25;
+pragma solidity =0.8.25;Per coding guidelines: "**/*.sol: Solidity version must be exactly 0.8.25 with EVM target cancun." The EVM target is correctly configured in foundry.toml, but the pragma declaration must use = instead of ^.
🤖 Prompt for 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.
In `@src/lib/op/math/LibOpPi.sol` at line 3, The pragma declaration in LibOpPi.sol
uses a caret range (^0.8.25) which allows multiple compiler versions and
violates the requirement for deterministic builds. Change the pragma solidity
statement from using the caret operator (^) to an equals operator (=) to pin the
exact version. Replace pragma solidity ^0.8.25; with pragma solidity =0.8.25; to
enforce exact version matching as required by the coding guidelines.
Source: Coding guidelines
| /// @dev The mathematical constant pi as a `Float`. | ||
| /// 3.141592653589793238462643383279502884197169399375105820974944592308e66, -66 |
There was a problem hiding this comment.
Fix tagged NatSpec block formatting.
Line 12 is untagged inside a block that already uses an explicit tag (@dev), which violates the NatSpec tagging rule.
Suggested fix
/// `@dev` The mathematical constant pi as a `Float`.
-/// 3.141592653589793238462643383279502884197169399375105820974944592308e66, -66
+/// `@dev` Encoded as coefficient/exponent: 3.141592653589793238462643383279502884197169399375105820974944592308e66, -66.As per coding guidelines: "In NatSpec doc blocks containing explicit tags (e.g., @title), all entries must be explicitly tagged; untagged lines do not continue the previous tag."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /// @dev The mathematical constant pi as a `Float`. | |
| /// 3.141592653589793238462643383279502884197169399375105820974944592308e66, -66 | |
| /// `@dev` The mathematical constant pi as a `Float`. | |
| /// `@dev` Encoded as coefficient/exponent: 3.141592653589793238462643383279502884197169399375105820974944592308e66, -66. |
🤖 Prompt for 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.
In `@src/lib/op/math/LibOpPi.sol` around lines 11 - 12, The NatSpec documentation
block in LibOpPi.sol for the pi constant has an explicit `@dev` tag on line 11 but
line 12 (containing the hexadecimal representation) is untagged. According to
NatSpec formatting rules, when a block uses explicit tags, all lines must be
explicitly tagged. Add the `@dev` tag to line 12 to properly tag the continuation
of the pi constant documentation.
Source: Coding guidelines
The prior red was transient: CI staged rainix@main during the ~3.5h window when rainix main HEAD (c54864d1) had the dangling LICENSE symlink that broke GitHub action-staging. That is now fixed on rainix main (LICENSE -> LICENSES/ LicenseRef-DCL-1.0.txt); this retriggers CI to pick it up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds a
piconstant standard op, mirroring the existingeword (LibOpE).Closes #225
This is a deployed-interpreter-bytecode change (the same class as the
eword / #237). Adding the op shifts the interpreter/parser/expression-deployer/Rainlang bytecode, so the pinned deploy addresses and codehashes change. The fork-gatedLibInterpreterDeployTest/LibInterpreterDeployProdTesttests assert the live on-chain bytecode against these pins and will stay red on every network until the contracts are redeployed via the manual interpreter-redeploy workflow. Do not merge without human review + the redeploy at land.What changed (mirrors the
ePRs #246 / #375)LibOpEmirror:src/lib/op/math/LibOpPi.sol—integrity(0 in / 1 out),run(pushes the constant),referenceFn, identical in structure/gas toLibOpE.piis encoded as aFloatat the same precision/convention asLibDecimalFloat.FLOAT_E: a 67-digit coefficient × 10⁻⁶⁶, packedFloat.wrap(bytes32(0xffffffbe1dd4c9e873614f593bba9c6007d9a7ac8d03a4b6c700a65cb537a1b4)). (The same packing reproduces the publishedFLOAT_Ebyte-for-byte; thepivalue round-trips to π accurate to 66 decimal places.rain-math-float 0.1.1has noFLOAT_PI, so the constant is defined locally inLibOpPi, matching how the lib definesFLOAT_E.)piinsrc/lib/op/LibAllStandardOps.solbetweenmulandpoweracross all four parallel arrays (authoring meta, operand handlers, integrity pointers, opcode pointers);ALL_STANDARD_OPS_LENGTH72 → 73.test/src/lib/op/LibAllStandardOps.t.sol(piat index 59; later indices shifted).test/src/lib/op/math/LibOpPi.t.solmirroringLibOpE.t.sol(parse_: pi();+ eval to π, integrity, operand-disallowed, bad input/output arity).Regenerated artifacts (staged):
src/generated/RainlangInterpreter.pointers.solsrc/generated/RainlangParser.pointers.solsrc/generated/RainlangExpressionDeployer.pointers.solsrc/generated/Rainlang.pointers.solmeta/AuthoringMeta.rain.meta,meta/RainlangExpressionDeployer.rain.meta(
RainlangStore.pointers.solunchanged — store bytecode doesn't depend on opcodes. Pointer generation was iterated to a stable fixed point;rainix-sol-artifactsproduces no further diff and leaves the crate ABIs untouched.)New pinned values after regeneration:
0x7E694007Bb400ab2147a2060D2e48703F3FA1cef0x3069f10fd2956d0681277d4834e35e9fefaf6d3a079af0a44ccab979ffba052d0x088Bdb2B554E3CdedA4137bEeF92ffEe1e9F4DBf0x844ca2709f34283f566cee50abb1b948bf0e46fc62e1ff46df5659570186eaea0xC0BFfCcb665d3ebCa5Aba3816d94F35C8467d6f70x65c7c20b94c1878de8d25c6c0bd22ba470a9983719e274626e87e679b8da1df70x7c08C22E0700E9bB51082907514F8F68806fEEA00xe6cdd994c12e5626c2c0d6e0ad7c0fdf0bd290ea4c8a474e1f32ae040b12df6f0x1Aa775533E28B1D843e1A589034984E3a62005DC0xdaa0024dc105c6a9ea0838604bad0a5e662743eca97789c2cecfdf8667d0bf9bVerification
forge buildclean (only pre-existingboolean-cstlint warnings in unrelated files).forge fmt --checkclean; one-contract-per-file respected.*_RPC_URLenv vars (LibInterpreterDeploy*, plus fork-constructor math op tests) — environment-gated, identical onmain, and exactly the codehash checks the redeploy resolves.LibOpPiTest(7) +LibOpETest+LibAllStandardOpsTest+ filesystem-ordering all green.LibOpPi.runatFLOAT_Einstead ofFLOAT_PImakestestOpPiRunfail (run≠referenceFn); restored to π and re-confirmed green.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes