Skip to content

feat: provide json abi as flake output#187

Merged
0xgleb merged 1 commit intomainfrom
feat/abi-flake-output
May 6, 2026
Merged

feat: provide json abi as flake output#187
0xgleb merged 1 commit intomainfrom
feat/abi-flake-output

Conversation

@0xgleb
Copy link
Copy Markdown
Contributor

@0xgleb 0xgleb commented May 6, 2026

Closes RAI-329

Motivation

The ABI paths for DecimalFloat and TestDecimalFloat were hardcoded as relative file paths, making the build brittle and tightly coupled to a specific directory layout. This prevented reproducible builds in Nix environments where output paths are managed differently.

Solution

A Nix derivation (decimal-float-abi) is introduced to compile the Solidity contracts and produce the ABI JSON files as a proper build output. The hardcoded paths in lib.rs are replaced with environment variables (RAIN_MATH_FLOAT_DECIMAL_FLOAT_ABI and RAIN_MATH_FLOAT_TEST_DECIMAL_FLOAT_ABI) resolved at compile time via env!(). These variables are automatically set in the dev shell to point to the local build output, and the Nix derivation sets them to the compiled artifacts during CI/package builds. A new rain-math-float-wasm package entry is also added to the lockfile.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

@0xgleb has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 50 minutes and 17 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 656745e4-8a77-42ab-aeaa-2e168b05ef60

📥 Commits

Reviewing files that changed from the base of the PR and between abed8bd and 816a579.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • crates/float/src/lib.rs
  • flake.nix

Walkthrough

This PR establishes a build-time ABI resolution system for the Rain math float crate by adding a Rust build script that resolves Solidity contract ABI JSON paths from environment variables, updating the library code to consume those environment-provided paths, and adding a Nix derivation to build and expose the ABI artifacts.

Changes

Build-Time ABI Resolution

Layer / File(s) Summary
Build Configuration
crates/float/build.rs
New build script defines a resolver helper that computes ABI JSON paths from environment variables with manifest-dir-relative fallbacks, then exports resolved paths via cargo:rustc-env and installs rebuild triggers.
ABI Artifact Derivation
flake.nix
New rain-math-float-abi Nix derivation builds Foundry/Forge contracts with SOLC 0.8.25, copies JSON ABI artifacts to output, and exposes the derivation in the flake's per-system packages.
Library Integration
crates/float/src/lib.rs
DecimalFloat and TestDecimalFloat sol! macro invocations now fetch contract ABIs from environment variables (RAIN_MATH_FLOAT_DECIMAL_FLOAT_ABI and RAIN_MATH_FLOAT_TEST_DECIMAL_FLOAT_ABI) instead of static JSON paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: exposing JSON ABI as a flake output via the new decimal-float-abi derivation in flake.nix.
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 feat/abi-flake-output

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 and usage tips.

Copy link
Copy Markdown
Contributor Author

0xgleb commented May 6, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 `@crates/float/build.rs`:
- Around line 1-3: The file build.rs is missing the required SPDX license
header; add the repository's SPDX header comment as the first lines of
crates/float/build.rs (above the existing use statements) per REUSE.toml policy,
ensuring it matches the project's standard header format (e.g.,
SPDX-License-Identifier and copyright/owner if required) so the file complies
with the mandated SPDX header rules.

In `@crates/float/src/lib.rs`:
- Around line 24-35: Add the required SPDX license header to the top of
crates/float/src/lib.rs (above the first sol! macro invocation) using the exact
SPDX identifier specified in the repository's REUSE.toml; ensure the header is a
single-line comment like "SPDX-License-Identifier: <identifier>" and appears
before the DecimalFloat and TestDecimalFloat sol! macros so the file complies
with the mandated SPDX header policy.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: d8fb2ff7-8599-4af2-8a4f-6c889fa77313

📥 Commits

Reviewing files that changed from the base of the PR and between e3f1fd1 and abed8bd.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • crates/float/build.rs
  • crates/float/src/lib.rs
  • flake.nix

Comment thread crates/float/build.rs Outdated
Comment thread crates/float/src/lib.rs
Comment on lines 24 to 35
sol!(
#![sol(all_derives)]
DecimalFloat,
"../../out/DecimalFloat.sol/DecimalFloat.json"
env!("RAIN_MATH_FLOAT_DECIMAL_FLOAT_ABI")
);

#[cfg(test)]
sol!(
#![sol(all_derives)]
TestDecimalFloat,
"../../out/TestDecimalFloat.sol/TestDecimalFloat.json"
env!("RAIN_MATH_FLOAT_TEST_DECIMAL_FLOAT_ABI")
);
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot May 6, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

This touched Rust file also needs the mandatory SPDX header.

crates/float/src/lib.rs does not include the required SPDX license header. Please add it at the top of the file per REUSE.toml.

As per coding guidelines, **/*.{sol,rs,ts,tsx,js,jsx}: All source files must include SPDX license headers per REUSE.toml specification.

🤖 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 `@crates/float/src/lib.rs` around lines 24 - 35, Add the required SPDX license
header to the top of crates/float/src/lib.rs (above the first sol! macro
invocation) using the exact SPDX identifier specified in the repository's
REUSE.toml; ensure the header is a single-line comment like
"SPDX-License-Identifier: <identifier>" and appears before the DecimalFloat and
TestDecimalFloat sol! macros so the file complies with the mandated SPDX header
policy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

REUSE.toml already covers crates/**/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

Let me verify the REUSE.toml configuration.


🏁 Script executed:

#!/bin/bash
cat REUSE.toml 2>/dev/null || find . -name "REUSE.toml" -exec cat {} \;

Length of output: 612


@0xgleb, you're right — crates/**/ is explicitly listed in REUSE.toml, which covers all files under that directory including crates/float/src/lib.rs. No per-file SPDX header is needed. My comment was incorrect, sorry for the noise!


✏️ Learnings added
Learnt from: 0xgleb
Repo: rainlanguage/rain.math.float PR: 187
File: crates/float/src/lib.rs:24-35
Timestamp: 2026-05-06T10:07:02.630Z
Learning: In the rain.math.float repository, REUSE.toml uses glob-based annotations to cover entire directory trees (e.g., `crates/**/`, `flake.nix`, etc.) with `SPDX-License-Identifier = "LicenseRef-DCL-1.0"`. Files under these covered paths do NOT require individual in-file SPDX headers; the REUSE.toml annotation satisfies the license requirement for the whole tree.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@0xgleb 0xgleb force-pushed the feat/abi-flake-output branch from abed8bd to 816a579 Compare May 6, 2026 10:00
@0xgleb 0xgleb requested review from JuaniRios and findolor May 6, 2026 11:51
@0xgleb 0xgleb self-assigned this May 6, 2026
Copy link
Copy Markdown
Contributor Author

0xgleb commented May 6, 2026

Merge activity

  • May 6, 4:21 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 6, 4:21 PM UTC: @0xgleb merged this pull request with Graphite.

@0xgleb 0xgleb merged commit 3b2f33a into main May 6, 2026
11 checks passed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

@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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Tip

For best results, initiate chat on the files or code changes.

SIZE=M

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