diff --git a/bin/stateless-guest/Cargo.lock b/bin/stateless-guest/Cargo.lock index d04a42535..1809aff88 100644 --- a/bin/stateless-guest/Cargo.lock +++ b/bin/stateless-guest/Cargo.lock @@ -2501,6 +2501,15 @@ dependencies = [ "syn 2.0.118", ] +[[package]] +name = "openvm-bigint-guest" +version = "2.0.0" +source = "git+https://github.com/openvm-org/openvm.git?branch=develop-v2.1.0#1417e1f11c5578a2fa364e8553f3923ee498fbf8" +dependencies = [ + "openvm-platform", + "strum_macros 0.26.4", +] + [[package]] name = "openvm-chainspec" version = "0.4.0" @@ -2754,6 +2763,7 @@ version = "0.4.0" dependencies = [ "openvm", "openvm-algebra-guest", + "openvm-bigint-guest", "openvm-ecc-guest", "openvm-stateless-executor", ] @@ -3823,8 +3833,7 @@ dependencies = [ [[package]] name = "ruint" version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45caf26f647c19115bf9c453c70ffe4a4a3a6390dceebd942610584f99b8ddce" +source = "git+https://github.com/Qumeric/uint?rev=cf03e356e38133ad27ee72644e0c4ef7c8e6433e#cf03e356e38133ad27ee72644e0c4ef7c8e6433e" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", @@ -3852,8 +3861,7 @@ dependencies = [ [[package]] name = "ruint-macro" version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" +source = "git+https://github.com/Qumeric/uint?rev=cf03e356e38133ad27ee72644e0c4ef7c8e6433e#cf03e356e38133ad27ee72644e0c4ef7c8e6433e" [[package]] name = "rustc-hash" diff --git a/bin/stateless-guest/Cargo.toml b/bin/stateless-guest/Cargo.toml index 0b4cf8229..8fcd9d520 100644 --- a/bin/stateless-guest/Cargo.toml +++ b/bin/stateless-guest/Cargo.toml @@ -13,6 +13,9 @@ openvm-stateless-executor = { path = "../../crates/stateless-executor", default- openvm = { git = "https://github.com/openvm-org/openvm.git", branch = "develop-v2.1.0", default-features = false, features = ["getrandom-unsupported"] } openvm-algebra-guest = { git = "https://github.com/openvm-org/openvm.git", branch = "develop-v2.1.0", optional = true } openvm-ecc-guest = { git = "https://github.com/openvm-org/openvm.git", branch = "develop-v2.1.0", optional = true } +# Defines the 256-bit instruction shims that the patched `ruint` below calls. Nothing here +# references it directly; it is linked in to provide those symbols. +openvm-bigint-guest = { git = "https://github.com/openvm-org/openvm.git", branch = "develop-v2.1.0", features = ["export-intrinsics"] } # Enable std feature for host builds (provides critical-section implementation) [target.'cfg(not(any(target_os = "none", target_os = "openvm")))'.dependencies] @@ -21,6 +24,12 @@ openvm-stateless-executor = { path = "../../crates/stateless-executor", default- [package.metadata.cargo-machete] ignored = ["openvm-algebra-guest", "openvm-ecc-guest"] +# `ruint`'s 256-bit multiply, shifts and comparison each become a single OpenVM instruction +# instead of a limb loop. Only this workspace is patched, because only the guest has the +# instructions; host builds keep the released crate. +[patch.crates-io] +ruint = { git = "https://github.com/Qumeric/uint", rev = "cf03e356e38133ad27ee72644e0c4ef7c8e6433e" } + [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = [ 'cfg(openvm_intrinsics)', diff --git a/bin/stateless-guest/src/main.rs b/bin/stateless-guest/src/main.rs index 3b75b5aea..b5efd01a7 100644 --- a/bin/stateless-guest/src/main.rs +++ b/bin/stateless-guest/src/main.rs @@ -5,6 +5,9 @@ #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::{read, reveal_bytes32}; +// Linked for the 256-bit instruction shims it exports, which `ruint` calls. Without a reference +// the rlib is dropped before those symbols reach the link. +use openvm_bigint_guest as _; use openvm_stateless_executor::{io::StatelessExecutorInput, ChainVariant, StatelessExecutor}; openvm::entry!(main);