Skip to content
Merged
Show file tree
Hide file tree
Changes from 103 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
1e05c3a
adding bls12_g1_add
aaravm Feb 24, 2025
9f43287
Updated the util functions
aaravm Feb 24, 2025
b363408
add precompile addresses
aaravm Mar 3, 2025
dbfd513
Adding tests and correcting utility functions
aaravm Mar 3, 2025
84ed0a7
remove padding from input in extract_g1_poin
aaravm Mar 3, 2025
5b119e3
add bls12_g1msm fn
aaravm Mar 3, 2025
656d5ba
added testcase for bls_add
aaravm Mar 5, 2025
3431a5f
added gls12_g1msm scalars
aaravm Mar 5, 2025
a29fdb0
added tests test_g1_msm_success and test_g1_msm_failures
aaravm Mar 10, 2025
e2846b3
adding details about the bug
aaravm Mar 10, 2025
1ffbe1a
Adding the g2_add_function
aaravm Mar 12, 2025
ff0b1f6
Adding the g2_msm_function
aaravm Mar 12, 2025
cdf1f2a
corrected subgroup check testcase in g1msm
aaravm Mar 12, 2025
cec90bf
adding testcases for g2_add
aaravm Mar 12, 2025
0614ee5
adding testcases for g2_add_fail
aaravm Mar 12, 2025
8104180
adding testcases for g2_msm
aaravm Mar 12, 2025
9f78dff
separated util file
aaravm Mar 19, 2025
9c687f3
separates bls12_381 into 7 files
aaravm Mar 19, 2025
ff40af6
update g1_add unit tests
aaravm Mar 19, 2025
91dad92
add fp2_to_g2, pairing fn
aaravm Mar 19, 2025
0d7e13d
Add utility functions to pairing.rs
aaravm Mar 24, 2025
c78655e
Add util functions for map_fp_to_g1 and map_fp2_to_g2
aaravm Mar 24, 2025
53fa0fd
Fix the Curve-error bug
aaravm Mar 31, 2025
4e82a45
corrected the bug in g1_msm and g2_add
aaravm Mar 31, 2025
13fd9e0
added testcases for map_fp_to_g1
aaravm Mar 31, 2025
93deac4
add successful tests to pairing.rs
aaravm Mar 31, 2025
dc7ef60
Add more testcases for pairing
aaravm Mar 31, 2025
7bf5811
added more tests for g1_msm, and g2_add
aaravm Mar 31, 2025
96ca478
change g1_msm variable names
aaravm Apr 1, 2025
cff0fb0
add g2msm failure tests
aaravm Apr 1, 2025
b051dca
correct bug in g2_msm
aaravm Apr 1, 2025
2f8e8ae
fixed corresponding bug in g1_msm
aaravm Apr 1, 2025
3d00793
update pairing tests
aaravm Apr 1, 2025
28066f0
added remaining tests
aaravm Apr 1, 2025
e4613d0
Merge branch 'master' of github.com:aaravm/builtin-actors
snissn Apr 4, 2025
a1a124b
run cargo fmt --all
snissn Apr 8, 2025
4ca96d7
refactor(bls12_381): unify G1ADD and G2ADD precompile implementations…
snissn Apr 8, 2025
046c5d0
refactor(bls12_381): unify is_infinity logic for G1 and G2 MSM and ad…
snissn Apr 8, 2025
f5c6960
refactor(bls12_mapping): standardize map_fp2_to_g2 and map_fp_to_g1 p…
snissn Apr 8, 2025
564f71f
Merge pull request #1 from snissn/mikers/bls-review
aaravm Apr 11, 2025
7a4c94d
remove repeatedly defined fns
aaravm Apr 11, 2025
0cca6de
correct clippy errors
aaravm Apr 11, 2025
62d5dd3
recompile cargo.lock
aaravm Apr 17, 2025
304409a
temporarily removed cargo.lock
aaravm Apr 17, 2025
6840879
merging from upstream
aaravm Apr 17, 2025
b3cf19b
cargo fmt --all
aaravm Apr 17, 2025
1444225
Merge branch 'master' of github.com:filecoin-project/builtin-actors
snissn Apr 23, 2025
b409cd3
using input.chunks_exact instead of manual indexing
snissn May 19, 2025
a25f6c4
using input.chunks_exact instead of manual indexing
snissn May 19, 2025
fc764ef
simplify input parsing using chunks_exact and split_at
snissn May 19, 2025
bb5a4fc
refactor(pairing): use split_first for safer empty input handling
snissn May 19, 2025
9dcd627
fmt
snissn May 19, 2025
1990118
install clang in ci
snissn May 19, 2025
cb2a1d3
Revert "install clang in ci"
snissn May 19, 2025
bceaeef
install clang in docker
snissn May 19, 2025
951f003
initial BLS precompile solidity test working
snissn May 20, 2025
a59a701
rename clean up solidity test
snissn May 20, 2025
bf7c374
use split_at in g1_add
snissn May 20, 2025
63533f3
cargo fmt fix
snissn May 20, 2025
d890694
Merge pull request #2 from snissn/master
snissn May 21, 2025
b56a83c
Update BLSPrecompile.sol
snissn May 21, 2025
0feecb5
Merge branch 'filecoin-project:master' into master
snissn May 27, 2025
127cd02
Merge pull request #3 from snissn/master
snissn May 27, 2025
de97365
Merge branch 'master' of github.com:aaravm/builtin-actors
snissn May 27, 2025
e482a8b
Merge pull request #4 from snissn/master
snissn May 27, 2025
4ed841f
merge pre-megre and master
aaravm Jun 11, 2025
5d30561
cargo fmt
aaravm Jun 11, 2025
e12cc90
add remaining fns except pairing
aaravm Jun 17, 2025
5818890
add pairing tests
aaravm Jun 17, 2025
7bce060
cargo fmt
aaravm Jun 17, 2025
6d9965f
Merge branch 'filecoin-project:master' into master
snissn Aug 6, 2025
096dc13
add clang for tests
snissn Aug 6, 2025
b3055b8
Update actors/evm/tests/contracts/BLSPrecompile.sol
snissn Aug 6, 2025
7e37a9e
Update actors/evm/tests/contracts/BLSPrecompile.sol
snissn Aug 6, 2025
497c7d8
Update actors/evm/tests/contracts/BLSPrecompile.sol
snissn Aug 6, 2025
22fbb08
Update actors/evm/tests/contracts/BLSPrecompile.sol
snissn Aug 6, 2025
643bd65
Update actors/evm/tests/contracts/BLSPrecompile.sol
snissn Aug 6, 2025
fddd3ba
Merge branch 'filecoin-project:master' into master
snissn Aug 13, 2025
729d15b
Update actors/evm/src/interpreter/precompiles/bls_util.rs
snissn Aug 20, 2025
6a66353
Update actors/evm/src/interpreter/precompiles/bls_util.rs
snissn Aug 20, 2025
81dd006
Update actors/evm/src/interpreter/precompiles/bls_util.rs
snissn Aug 20, 2025
8c71907
Merge branch 'filecoin-project:master' into master
snissn Aug 20, 2025
7c251f2
**feat(evm/bls): localize FFI `unsafe`, prefer refs over raw ptrs; mi…
snissn Aug 20, 2025
4727f52
Updated safety comments to clarify the unsafe blocks
aaravm Aug 21, 2025
08dd45a
Update actors/evm/src/interpreter/precompiles/bls12_381/g1_msm.rs
aaravm Aug 21, 2025
f0bb2e3
Update actors/evm/src/interpreter/precompiles/bls12_381/g1_msm.rs
aaravm Aug 21, 2025
5d666da
Update actors/evm/src/interpreter/precompiles/bls12_381/g1_msm.rs
aaravm Aug 21, 2025
cdf1986
added better comments for g1_add
aaravm Aug 21, 2025
e69720d
Update actors/evm/src/interpreter/precompiles/bls12_381/g2_add.rs
aaravm Aug 21, 2025
6434e65
added better comments in g2_add
aaravm Aug 21, 2025
bfc77fa
removed unnecessary variables
aaravm Aug 21, 2025
265f531
bls12-381: fix pairing filter; accept ∞; clarify G2 ABI; tests; CI
snissn Aug 21, 2025
f98bfe3
Merge branch 'master' of github.com:aaravm/builtin-actors
snissn Aug 21, 2025
fb9b974
cargo fmt
snissn Aug 21, 2025
50479b7
Update actors/evm/src/interpreter/precompiles/bls12_381/map_fp2_to_g2.rs
aaravm Aug 25, 2025
34ffcb5
Update actors/evm/src/interpreter/precompiles/bls12_381/g1_msm.rs
aaravm Aug 26, 2025
bc9fdcf
Update actors/evm/src/interpreter/precompiles/bls12_381/g2_msm.rs
aaravm Aug 26, 2025
eca5ee6
Update actors/evm/src/interpreter/precompiles/bls12_381/pairing.rs
aaravm Aug 26, 2025
3027923
using is_infinity trait
aaravm Aug 26, 2025
635e1ee
add remaining g1_msm tests
aaravm Aug 26, 2025
88fc159
correct g1_msm fail tests
aaravm Aug 26, 2025
b48581c
added missing g2_msm test
aaravm Aug 26, 2025
4f50148
added test names in map_gp_to_g1
aaravm Aug 26, 2025
27ded2d
Update actors/evm/src/interpreter/precompiles/bls_util.rs
aaravm Aug 27, 2025
309488e
removed repeated check in bls_util
aaravm Aug 27, 2025
931ba51
reduced ffi calls in bls_util, removed unnecessary debug_assert_eq
aaravm Aug 27, 2025
b11a19b
changed safety comment
aaravm Aug 27, 2025
51c871b
added test names to solidity fns
aaravm Aug 27, 2025
3ee50b2
cargo fmt
aaravm Aug 27, 2025
54aa9d6
check c compiler does wasm via @ZenGround0
snissn Aug 27, 2025
92dced7
format
snissn Aug 27, 2025
725341c
Merge branch 'filecoin-project:master' into master
snissn Aug 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ jobs:
uses: actions/checkout@v3
- if: env.RUNNER_ENVIRONMENT != 'github-hosted'
uses: dtolnay/rust-toolchain@stable
- name: Install Clang (Linux only)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang
- name: Installing the toolchain
run: make toolchain
- name: Install cargo-nextest
Expand Down
91 changes: 82 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ FROM rust:1.81.0-bookworm@sha256:7b7f7ae5e49819e708369d49925360bde2af4f1962842e7

WORKDIR /usr/src/builtin-actors

# Install clang
RUN apt-get update && apt-get install -y clang
Copy link
Contributor

Choose a reason for hiding this comment

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

This is my understanding of why clang is now a dependency:

We are compiling BLST C code directly into WASM so we can't rely purely on rust compiler which compiles directly from rust to WASM -- we now need a C compiler. Furthermore gcc doesn't yet have support for wasm compilation so it can't be gcc.

This is not the only possible option -- the other option is laid out in the BLST rust bindings crate:

Alternatively you can build your project with CC environment variable set to emcc, the Emscripten compiler, and AR set to emar, naturally, with both commands available on your PATH

Copy link
Contributor

@ZenGround0 ZenGround0 Jul 8, 2025

Choose a reason for hiding this comment

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

I want to understand if there is anything we can do in builtin-actors build.rs to make this update to clang / CC dependency as smooth as possible. Should we be checking this dependency before we even start building or is the BLST build error going to be ergonomic enough for those building actors bundles?

My other open question is whether we have clang installed on the github actions infra that runs actor bundle generation -- we'll want to make sure that's the case to prevent jobs from failing mysteriously. All of the CI testing flows build properly but I want to make sure this also holds for tagged bundle generation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd recommend throwing this check into the top of the build.rs main function (courtesy of AI but looks correct)

f env::var("CARGO_CFG_TARGET_ARCH").as_deref() == Ok("wasm32") &&
       env::var_os("CC").is_none()                       // user didn’t override
    {
        let clang_ok = Command::new("clang")
            .args(["--target=wasm32", "-###", "-"]) // dry-run
            .output()
            .map(|o| o.status.success())
            .unwrap_or(false);

        let emcc_ok  = Command::new("emcc")
            .arg("-v")
            .output()
            .map(|o| o.status.success())
            .unwrap_or(false);

        if !clang_ok && !emcc_ok {
            eprintln!(
                "error: a C compiler for WebAssembly is missing.\n\
                 Install LLVM/Clang with wasm32 support *or* the Emscripten SDK,\n\
                 then either:\n\
                   • nothing (if `clang --target=wasm32` works), or\n\
                   • set  CC=emcc  AR=emar  before invoking Cargo."
            );
            std::process::exit(1);
        }

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok the above doesn't work for a few reasons but this diff does:

diff --git a/build.rs b/build.rs
index 7dadee3c..7a0d1939 100644
--- a/build.rs
+++ b/build.rs
@@ -69,10 +69,59 @@ fn network_name() -> String {
     }.to_owned()
 }
 
+// To support EIP 2537 we compile blst library directly into evm actor
+// This requires a C => wasm32-unknown-unknown clang
+// Note that emcc while support by blst is not an option for us as it cannot
+// target wasm32-unknown-unknown
+fn check_c_compiler_does_wasm() {
+    // If CC is not set, default to "clang", else use the value from the environment.
+    let cc = match std::env::var_os("CC") {
+        Some(val) => val,
+        None => "clang".into(),
+    };
+
+    // First check cc actually runs / is in path
+    let version_check = std::process::Command::new(&cc)
+        .arg("--version")
+        .output();
+
+    if version_check.is_err() || !version_check.as_ref().unwrap().status.success() {
+        eprintln!(
+            "error: could not run C compiler '{}'.\n\
+             Please ensure clang is installed and in your PATH, or set CC to a working clang binary.",
+            cc.to_string_lossy()
+        );
+        std::process::exit(1);
+    }
+
+    // Then check that the compiler supports wasm32 target
+    let targets_check = std::process::Command::new(&cc)
+        .arg("--print-targets")
+        .output();
+
+    let has_wasm32 = match targets_check {
+        Ok(output) if output.status.success() => {
+            let targets = String::from_utf8_lossy(&output.stdout);
+            targets.lines().any(|line| line.trim().contains("wasm32"))
+        }
+        _ => false,
+    };
+
+    if !has_wasm32 {
+        eprintln!(
+            "error: C compiler '{}' does not support wasm32-unknown-unknown target.\n\
+             Install LLVM/Clang with wasm32 support \n",
+            cc.to_string_lossy()
+        );
+        std::process::exit(1);
+    }
+}
+
 fn main() -> Result<(), Box<dyn Error>> {
     // Cargo executable location.
     let cargo = std::env::var_os("CARGO").expect("no CARGO env var");
     println!("cargo:warning=cargo: {:?}", &cargo);
+    check_c_compiler_does_wasm();
 
     let out_dir = std::env::var_os("OUT_DIR")
         .as_ref()


# Install the compiler. Unfortunately, the rust docker container doesn't actually contain the rust
# compiler...
COPY ./rust-toolchain.toml .
Expand Down
1 change: 1 addition & 0 deletions actors/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ hex = { workspace = true }
hex-literal = { workspace = true }
substrate-bn = { workspace = true }
thiserror = { workspace = true }
blst = "0.3.14"

[dev-dependencies]
hex = { workspace = true, features = ["serde"] }
Expand Down
Loading