Skip to content

Commit

Permalink
actually we don't need 1.74 to do thist
Browse files Browse the repository at this point in the history
  • Loading branch information
martyall committed Dec 14, 2024
1 parent 1fe4676 commit 2384bb6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 31 deletions.
19 changes: 2 additions & 17 deletions nix/rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let
# override stdenv.targetPlatform here, if neccesary
};
toolchainHashes = {
"1.74" = "sha256-PjvuouwTsYfNKW5Vi5Ye7y+lL7SsWGBxCtBOOm2z14c=";
"1.72" = "sha256-dxE7lmCFWlq0nl/wKcmYvpP9zqQbBitAQgZ1zx9Ooik=";
# copy the placeholder line with the correct toolchain name when adding a new toolchain
# That is,
# 1. Put the correct version name;
Expand Down Expand Up @@ -108,21 +108,6 @@ in {
'';
};

wasm-pack =
let rust_platform = rustPlatformFor final.kimchi-rust.rust;
in rust_platform.buildRustPackage rec {
pname = "wasm-pack";
version = "0.13.1";
src = final.fetchCrate {
inherit pname version;
sha256 = "sha256-CuLvEiymShM+k02x33FKTDK9D1r6DXJ4eplgVZBCnsI=";
};
cargoSha256 = "sha256-RdBnW8HKSgjVnyafycGFTSTc5j1A9WRDvUuZu8upRWY=";

nativeBuildInputs = [ final.pkg-config ];
doCheck = false;

};
plonk_wasm = let
lock = ../src/lib/crypto/proof-systems/Cargo.lock;

Expand All @@ -135,7 +120,7 @@ in {

wasm-bindgen-cli = final.rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
version = "0.2.87";
version = deps.wasm-bindgen.version;
src = final.fetchCrate {
inherit pname version;
sha256 = "sha256-0u9bl+FkXEK2b54n7/l9JOCtKo+pb42GF9E1EnAUQa0=";
Expand Down
5 changes: 3 additions & 2 deletions src/lib/crypto/kimchi_bindings/js/node_js/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ set -euo pipefail
# When using nix this is already cached
if [[ -z "${PLONK_WASM_NODEJS-}" ]]; then
export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296"
# The version should stay in line with the one in kimchi_bindings/wasm/rust-toolchain.toml
rustup run 1.74 wasm-pack build --target nodejs --out-dir ../../kimchi_bindings/js/node_js ../../../proof-systems/plonk-wasm -- --features nodejs
# The rust version should stay in line with the one in kimchi_bindings/wasm/rust-toolchain.toml
# TODO: change out-dir to be relative to PWD when we upgrade to wasm-pack 0.13 (see https://github.com/rustwasm/wasm-pack/issues/704)
rustup run 1.72 wasm-pack build --target nodejs --out-dir ../../kimchi_bindings/js/node_js ../../../proof-systems/plonk-wasm -- --features nodejs
else
cp "$PLONK_WASM_NODEJS"/* -R .
fi
3 changes: 2 additions & 1 deletion src/lib/crypto/kimchi_bindings/js/web/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ set -euo pipefail
if [[ -z "${PLONK_WASM_WEB-}" ]]; then
export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296"
# The version should stay in line with the one in kimchi_bindings/wasm/rust-toolchain.toml
rustup run 1.74 wasm-pack build --target web --out-dir ../../kimchi_bindings/js/web ../../../proof-systems/plonk-wasm
# TODO: change out-dir to be relative to PWD when we upgrade to wasm-pack 0.13 (see https://github.com/rustwasm/wasm-pack/issues/704)
rustup run 1.72 wasm-pack build --target web --out-dir ../../kimchi_bindings/js/web ../../../proof-systems/plonk-wasm
else
cp "$PLONK_WASM_WEB"/* -R .
fi
2 changes: 1 addition & 1 deletion src/lib/crypto/kimchi_bindings/stubs/rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
# 4. figure out the hashes of the (now obsolete) docker images used in CI rules that are failing, grep for these hashes and replace them with the new hashes

[toolchain]
channel = "1.74"
channel = "1.72"
8 changes: 4 additions & 4 deletions src/lib/crypto/kimchi_bindings/stubs/src/caml/caml_pointer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
macro_rules! impl_caml_pointer {
($name: ident => $typ: ty) => {
#[derive(std::fmt::Debug, Clone, ::ocaml_gen::CustomType)]
pub struct $name(pub ::std::rc::Rc<std::cell::UnsafeCell<$typ>>);
pub struct $name(pub ::std::rc::Rc<$typ>);

impl $name {
extern "C" fn caml_pointer_finalize(v: ocaml::Raw) {
Expand Down Expand Up @@ -32,15 +32,15 @@ macro_rules! impl_caml_pointer {

impl $name {
pub fn create(x: $typ) -> $name {
$name(::std::rc::Rc::new(std::cell::UnsafeCell::new(x)))
$name(::std::rc::Rc::new(x))
}
}

impl ::std::ops::Deref for $name {
type Target = $typ;

fn deref(&self) -> &Self::Target {
unsafe { &*self.0.get() }
&*self.0
}
}

Expand All @@ -58,7 +58,7 @@ macro_rules! impl_caml_pointer {
// mutable, since we can call [`get_mut_unchecked`] in
// nightly, or can call [`get_mut`] and unwrap if this is
// the only live reference.
&mut *self.0.get() // Safe mutable access via UnsafeCell
&mut *(((&*self.0) as *const Self::Target) as *mut Self::Target)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use poly_commitment::commitment::{CommitmentCurve, PolyComm};
use poly_commitment::ipa::OpeningProof;
use std::array;
use std::convert::TryInto;
use std::ops::Deref;

type EFqSponge = DefaultFqSponge<VestaParameters, PlonkSpongeConstantsKimchi>;
type EFrSponge = DefaultFrSponge<Fp, PlonkSpongeConstantsKimchi>;
Expand Down Expand Up @@ -73,7 +72,7 @@ pub fn caml_pasta_fp_plonk_proof_create(
.collect()
};

let witness: Vec<Vec<_>> = witness.iter().map(|x| (*x).deref().clone()).collect();
let witness: Vec<Vec<_>> = witness.iter().map(|x| (*x.0).clone()).collect();
let witness: [Vec<_>; COLUMNS] = witness
.try_into()
.map_err(|_| ocaml::Error::Message("the witness should be a column of 15 vectors"))?;
Expand Down Expand Up @@ -141,7 +140,7 @@ pub fn caml_pasta_fp_plonk_proof_create_and_verify(
.collect()
};

let witness: Vec<Vec<_>> = witness.iter().map(|x| (*x).deref().clone()).collect();
let witness: Vec<Vec<_>> = witness.iter().map(|x| (*x.0).clone()).collect();
let witness: [Vec<_>; COLUMNS] = witness
.try_into()
.map_err(|_| ocaml::Error::Message("the witness should be a column of 15 vectors"))?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use poly_commitment::commitment::{CommitmentCurve, PolyComm};
use poly_commitment::ipa::OpeningProof;
use std::array;
use std::convert::TryInto;
use std::ops::Deref;

#[ocaml_gen::func]
#[ocaml::func]
Expand Down Expand Up @@ -67,7 +66,7 @@ pub fn caml_pasta_fq_plonk_proof_create(
.collect()
};

let witness: Vec<Vec<_>> = witness.iter().map(|x| (*x).deref().clone()).collect();
let witness: Vec<Vec<_>> = witness.iter().map(|x| (*x.0).clone()).collect();
let witness: [Vec<_>; COLUMNS] = witness
.try_into()
.expect("the witness should be a column of 15 vectors");
Expand Down
2 changes: 1 addition & 1 deletion src/lib/crypto/proof-systems

0 comments on commit 2384bb6

Please sign in to comment.