-
Notifications
You must be signed in to change notification settings - Fork 1
2026 03 10 deploy #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2026 03 10 deploy #167
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| Decimal floating-point math library for Rainlang/DeFi. The `Float` type packs a 224-bit signed coefficient and 32-bit signed exponent into a single `bytes32`. Decimal (not binary) representation ensures exact decimal values (e.g., `0.1`). No NaN, Infinity, or negative zero — operations error on nonsense rather than producing special values. | ||
|
|
||
| Dual implementation: Solidity for on-chain, Rust/WASM for off-chain JS/TS consumption. The Rust crate uses revm to execute Solidity via an in-memory EVM, ensuring identical behavior. | ||
|
|
||
| ## Build Commands | ||
|
|
||
| ### Solidity (Foundry) | ||
| ```bash | ||
| forge build # Compile contracts | ||
| forge test # Run all Solidity tests (5096 fuzz runs) | ||
| forge test --mt testFunctionName # Run specific test by name | ||
| forge test -vvvv # Verbose trace output for debugging | ||
| ``` | ||
|
|
||
| ### Rust | ||
| ```bash | ||
| cargo build # Build native | ||
| cargo build --target wasm32-unknown-unknown --lib -r # Build WASM | ||
| cargo test # Run Rust tests | ||
| cargo test test_name # Run specific test | ||
| ``` | ||
|
|
||
| Rust tests depend on Foundry build artifacts (`out/`). Run `forge build` before `cargo test` if artifacts are missing. | ||
|
|
||
| ### JavaScript/WASM | ||
| ```bash | ||
| npm install | ||
| npm run build # Full pipeline: Rust WASM → wasm-bindgen → base64 embed → CJS/ESM dist | ||
| npm test # TypeScript type check + vitest (tests in test_js/) | ||
| ``` | ||
|
|
||
| ### Nix | ||
| ```bash | ||
| nix develop # Enter dev shell with all tooling | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Solidity Layer (`src/`) | ||
| - **`lib/LibDecimalFloat.sol`** — Public API: arithmetic, comparison, conversion, formatting, parsing. User-defined type `Float` wrapping `bytes32`. | ||
| - **`lib/implementation/`** — Internal arithmetic (512-bit intermediates for mul/div), normalization, packing. | ||
| - **`lib/parse/`** — String-to-Float parsing. | ||
| - **`lib/format/`** — Float-to-string formatting. | ||
| - **`lib/table/`** — Log lookup tables (deployed as a data contract at a deterministic address). | ||
| - **`concrete/DecimalFloat.sol`** — Exposes library functions as contract methods (required for Rust/revm interop via ABI). | ||
| - **`error/`** — Custom error definitions (CoefficientOverflow, ExponentOverflow, DivisionByZero, etc.). | ||
|
|
||
| ### Rust Layer (`crates/float/`) | ||
| - **`lib.rs`** — `Float` struct wrapping `B256`, implements `Add`/`Sub`/`Mul`/`Div`/`Neg`. Uses `alloy::sol!` macro to generate bindings from Foundry JSON artifacts in `out/`. | ||
| - **`js_api.rs`** — `#[wasm_bindgen]` exports for JS consumption (parse, format, arithmetic, conversions). | ||
| - **`evm.rs`** — In-memory EVM setup via revm. All Rust float operations delegate to Solidity through this. | ||
| - **`error.rs`** — Maps Solidity error selectors to Rust error types. | ||
|
|
||
| ### JavaScript Layer | ||
| - **`scripts/build.js`** — Build pipeline: compiles WASM, runs wasm-bindgen, base64-encodes WASM into JS modules for both CJS and ESM. | ||
| - **`test_js/`** — Vitest tests for the WASM bindings. | ||
| - **`dist/`** — Generated output (CJS + ESM with embedded WASM). | ||
|
|
||
| ### Dependencies (`lib/`) | ||
| Git submodules: forge-std, rain.string, rain.datacontract, rain.math.fixedpoint, rain.deploy, rain.sol.codegen. | ||
|
|
||
| ## Key Design Details | ||
|
|
||
| - 512-bit intermediate values in multiply/divide to preserve precision. | ||
| - Exponent underflow silently rounds toward zero; exponent overflow reverts. | ||
| - Log/power use lookup table approximations with linear interpolation (table deployed as a data contract). | ||
| - Two packing modes: lossless (reverts on precision loss) and lossy (returns bool flag). | ||
| - Solidity compiler: 0.8.25, EVM target: Cancun, optimizer: 1,000,000 runs. | ||
|
|
||
| ## License | ||
|
|
||
| LicenseRef-DCL-1.0 (Rain Decentralized Computer License). All source files require SPDX headers per REUSE.toml. | ||
|
Comment on lines
+1
to
+78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Split this agent guide into a docs-only follow-up. This file is orthogonal to the Base Sepolia / deploy-path change, so keeping it in the same PR makes the deployment review harder to reason about. Based on learnings, in the rainlanguage/rain.math.float repository, the maintainer 0xgleb prefers to handle documentation additions and improvements in separate issues rather than inline with feature PRs. 🧰 Tools🪛 markdownlint-cli2 (0.21.0)[warning] 13-13: Headings should be surrounded by blank lines (MD022, blanks-around-headings) [warning] 14-14: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) [warning] 21-21: Headings should be surrounded by blank lines (MD022, blanks-around-headings) [warning] 22-22: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) [warning] 31-31: Headings should be surrounded by blank lines (MD022, blanks-around-headings) [warning] 32-32: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) [warning] 38-38: Headings should be surrounded by blank lines (MD022, blanks-around-headings) [warning] 39-39: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) [warning] 45-45: Headings should be surrounded by blank lines (MD022, blanks-around-headings) [warning] 54-54: Headings should be surrounded by blank lines (MD022, blanks-around-headings) [warning] 60-60: Headings should be surrounded by blank lines (MD022, blanks-around-headings) [warning] 65-65: Headings should be surrounded by blank lines (MD022, blanks-around-headings) 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,11 +39,13 @@ runs = 5096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [rpc_endpoints] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| arbitrum = "${CI_DEPLOY_ARBITRUM_RPC_URL}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| base = "${CI_DEPLOY_BASE_RPC_URL}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| base_sepolia = "${CI_DEPLOY_BASE_SEPOLIA_RPC_URL}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| flare = "${CI_DEPLOY_FLARE_RPC_URL}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| polygon = "${CI_DEPLOY_POLYGON_RPC_URL}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [etherscan] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| arbitrum = { key = "${CI_DEPLOY_ARBITRUM_ETHERSCAN_API_KEY}" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| base = { key = "${CI_DEPLOY_BASE_ETHERSCAN_API_KEY}" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| base_sepolia = { key = "${CI_DEPLOY_BASE_SEPOLIA_ETHERSCAN_API_KEY}" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+42
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n --hidden -S '\bbase[-_]sepolia\b|supportedNetworks\s*\('Repository: rainlanguage/rain.math.float Length of output: 1822 🌐 Web query:
💡 Result: In Foundry, the chain keys you use in TOML config files (e.g., Where it’s documented / defined
Base Sepolia network details (for your
Example # deployments.toml
[base-sepolia]
endpoint_url = "https://sepolia.base.org"(Or use Use the canonical Base Sepolia alias spelling in foundry.toml. The Suggested change [rpc_endpoints]
arbitrum = "${CI_DEPLOY_ARBITRUM_RPC_URL}"
base = "${CI_DEPLOY_BASE_RPC_URL}"
-base_sepolia = "${CI_DEPLOY_BASE_SEPOLIA_RPC_URL}"
+"base-sepolia" = "${CI_DEPLOY_BASE_SEPOLIA_RPC_URL}"
flare = "${CI_DEPLOY_FLARE_RPC_URL}"
polygon = "${CI_DEPLOY_POLYGON_RPC_URL}"
[etherscan]
arbitrum = { key = "${CI_DEPLOY_ARBITRUM_ETHERSCAN_API_KEY}" }
base = { key = "${CI_DEPLOY_BASE_ETHERSCAN_API_KEY}" }
-base_sepolia = { key = "${CI_DEPLOY_BASE_SEPOLIA_ETHERSCAN_API_KEY}" }
+"base-sepolia" = { key = "${CI_DEPLOY_BASE_SEPOLIA_ETHERSCAN_API_KEY}" }
flare = { key = "${CI_DEPLOY_FLARE_ETHERSCAN_API_KEY}" }
polygon = { key = "${CI_DEPLOY_POLYGON_ETHERSCAN_API_KEY}" }📝 Committable suggestion
Suggested change
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| flare = { key = "${CI_DEPLOY_FLARE_ETHERSCAN_API_KEY}" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| polygon = { key = "${CI_DEPLOY_POLYGON_ETHERSCAN_API_KEY}" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| +7 −0 | .coderabbitai.yaml | |
| +5 −0 | .github/workflows/rainix.yaml | |
| +3 −1 | .gitignore | |
| +72 −0 | CLAUDE.md | |
| +1 −0 | REUSE.toml | |
| +32 −0 | audit/2026-03-05-01/pass0/process.md | |
| +72 −0 | audit/2026-03-05-01/pass1/LibRainDeploy.md | |
| +65 −0 | audit/2026-03-05-01/pass2/LibRainDeploy.md | |
| +109 −0 | audit/2026-03-05-01/pass3/LibRainDeploy.md | |
| +102 −0 | audit/2026-03-05-01/pass4/LibRainDeploy.md | |
| +108 −0 | audit/2026-03-05-01/pass5/LibRainDeploy.md | |
| +52 −0 | audit/2026-03-05-01/triage.md | |
| +22 −0 | audit/2026-03-05-02/pass0/process.md | |
| +99 −0 | audit/2026-03-05-02/pass1/LibRainDeploy.md | |
| +172 −0 | audit/2026-03-05-02/pass2/LibRainDeploy.md | |
| +61 −0 | audit/2026-03-05-02/pass3/LibRainDeploy.md | |
| +130 −0 | audit/2026-03-05-02/pass4/LibRainDeploy.md | |
| +155 −0 | audit/2026-03-05-02/pass5/LibRainDeploy.md | |
| +64 −0 | audit/2026-03-05-02/triage.md | |
| + − | audit/protofire.rain.deploy.feb-2026.pdf | |
| +16 −0 | foundry.toml | |
| +4 −0 | slither.config.json | |
| +156 −28 | src/lib/LibRainDeploy.sol | |
| +446 −0 | test/src/lib/LibRainDeploy.t.sol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the markdownlint spacing violations.
MD022andMD031are already firing across the new headings and fenced blocks, so this file will keep the docs lint noisy until blank lines are added around those sections.🧰 Tools
🪛 markdownlint-cli2 (0.21.0)
[warning] 13-13: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
[warning] 14-14: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
[warning] 21-21: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
[warning] 22-22: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
[warning] 31-31: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
[warning] 32-32: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
[warning] 38-38: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
[warning] 39-39: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
[warning] 45-45: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
[warning] 54-54: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
[warning] 60-60: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
[warning] 65-65: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
🤖 Prompt for AI Agents