Skip to content

Commit 878c977

Browse files
ArtiomTrsauliusgrigaitis
authored andcommitted
Update rust toolchain
1 parent 09e1b73 commit 878c977

29 files changed

+74
-71
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arkworks3/src/kzg_proofs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub struct KZGSettings {
5353
pub cell_size: usize,
5454
}
5555

56-
impl<'a> TryFrom<&'a CKZGSettings> for KZGSettings {
56+
impl TryFrom<&CKZGSettings> for KZGSettings {
5757
type Error = String;
5858

5959
fn try_from(c_settings: &CKZGSettings) -> Result<KZGSettings, String> {
@@ -100,6 +100,7 @@ impl<'a> TryFrom<&'a CKZGSettings> for KZGSettings {
100100
.collect::<Vec<_>>()
101101
})
102102
.collect::<Vec<_>>(),
103+
#[allow(static_mut_refs)]
103104
precomputation: unsafe { PRECOMPUTATION_TABLES.get_precomputation(c_settings) },
104105
cell_size: eth::FIELD_ELEMENTS_PER_CELL,
105106
})

arkworks3/src/recover.rs

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ static mut UNSCALE_FACTOR_POWERS: Vec<BlstFr> = Vec::new();
1717
pub fn scale_poly(p: &mut PolyData) {
1818
let scale_factor = BlstFr::from_u64(SCALE_FACTOR);
1919
let inv_factor = scale_factor.inverse();
20+
21+
#[allow(static_mut_refs)]
2022
#[cfg(feature = "parallel")]
2123
{
2224
let optim = next_pow_of_2(p.len() - 1);
@@ -56,6 +58,8 @@ pub fn scale_poly(p: &mut PolyData) {
5658
#[allow(clippy::needless_range_loop)]
5759
pub fn unscale_poly(p: &mut PolyData) {
5860
let scale_factor = BlstFr::from_u64(SCALE_FACTOR);
61+
62+
#[allow(static_mut_refs)]
5963
#[cfg(feature = "parallel")]
6064
{
6165
unsafe {

arkworks4/src/kzg_types.rs

+1
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ impl<'a> TryFrom<&'a CKZGSettings> for LKZGSettings {
921921
.collect::<Vec<_>>()
922922
})
923923
.collect::<Vec<_>>(),
924+
#[allow(static_mut_refs)]
924925
precomputation: unsafe { PRECOMPUTATION_TABLES.get_precomputation(c_settings) },
925926
cell_size: eth::FIELD_ELEMENTS_PER_CELL,
926927
})

arkworks4/src/recover.rs

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ static mut UNSCALE_FACTOR_POWERS: Vec<BlstFr> = Vec::new();
1717
pub fn scale_poly(p: &mut PolyData) {
1818
let scale_factor = BlstFr::from_u64(SCALE_FACTOR);
1919
let inv_factor = scale_factor.inverse();
20+
21+
#[allow(static_mut_refs)]
2022
#[cfg(feature = "parallel")]
2123
{
2224
let optim = next_pow_of_2(p.len() - 1);
@@ -56,6 +58,8 @@ pub fn scale_poly(p: &mut PolyData) {
5658
#[allow(clippy::needless_range_loop)]
5759
pub fn unscale_poly(p: &mut PolyData) {
5860
let scale_factor = BlstFr::from_u64(SCALE_FACTOR);
61+
62+
#[allow(static_mut_refs)]
5963
#[cfg(feature = "parallel")]
6064
{
6165
unsafe {

arkworks5/src/kzg_types.rs

+1
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ impl<'a> TryFrom<&'a CKZGSettings> for LKZGSettings {
921921
.collect::<Vec<_>>()
922922
})
923923
.collect::<Vec<_>>(),
924+
#[allow(static_mut_refs)]
924925
precomputation: unsafe { PRECOMPUTATION_TABLES.get_precomputation(c_settings) },
925926
cell_size: eth::FIELD_ELEMENTS_PER_CELL,
926927
})

arkworks5/src/recover.rs

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ static mut UNSCALE_FACTOR_POWERS: Vec<BlstFr> = Vec::new();
1717
pub fn scale_poly(p: &mut PolyData) {
1818
let scale_factor = BlstFr::from_u64(SCALE_FACTOR);
1919
let inv_factor = scale_factor.inverse();
20+
21+
#[allow(static_mut_refs)]
2022
#[cfg(feature = "parallel")]
2123
{
2224
let optim = next_pow_of_2(p.len() - 1);
@@ -56,6 +58,8 @@ pub fn scale_poly(p: &mut PolyData) {
5658
#[allow(clippy::needless_range_loop)]
5759
pub fn unscale_poly(p: &mut PolyData) {
5860
let scale_factor = BlstFr::from_u64(SCALE_FACTOR);
61+
62+
#[allow(static_mut_refs)]
5963
#[cfg(feature = "parallel")]
6064
{
6165
unsafe {

blst/src/types/kzg_settings.rs

+1
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ impl<'a> TryFrom<&'a CKZGSettings> for FsKZGSettings {
420420
.collect::<Vec<_>>()
421421
})
422422
.collect::<Vec<_>>(),
423+
#[allow(static_mut_refs)]
423424
precomputation: unsafe { PRECOMPUTATION_TABLES.get_precomputation(settings) },
424425
cell_size: eth::FIELD_ELEMENTS_PER_CELL,
425426
})

kzg-bench/src/benches/eip_7594.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub fn bench_eip_7594<B: EcBackend>(
118118

119119
let mut group = c.benchmark_group("recover_cells_and_kzg_proofs (missing)");
120120
for i in 1..=5 {
121-
let modulo = (eth::CELLS_PER_EXT_BLOB + i - 1) / i;
121+
let modulo = eth::CELLS_PER_EXT_BLOB.div_ceil(i);
122122
let (cell_indices, partial_cells) =
123123
get_partial_cells(&blob_cells[0], eth::FIELD_ELEMENTS_PER_CELL, modulo);
124124

kzg-bench/src/tests/c_bindings.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
use std::{
2-
ffi::{CStr, CString},
3-
fs::File,
4-
io::Read,
5-
path::PathBuf,
6-
ptr::null_mut,
7-
};
1+
use std::{ffi::CString, fs::File, io::Read, path::PathBuf, ptr::null_mut};
82

93
use kzg::eth::c_bindings::{Blob, Bytes48, CKZGSettings, KZGCommitment, KZGProof};
104
use kzg::{
@@ -54,12 +48,7 @@ fn get_ckzg_settings(
5448
};
5549

5650
let trusted_setup_path = CString::new(get_trusted_setup_path()).unwrap();
57-
let file = unsafe {
58-
libc::fopen(
59-
trusted_setup_path.as_ptr(),
60-
CStr::from_bytes_with_nul_unchecked(b"r\0").as_ptr(),
61-
)
62-
};
51+
let file = unsafe { libc::fopen(trusted_setup_path.as_ptr(), c"r".as_ptr()) };
6352
assert!(!file.is_null());
6453

6554
let out = unsafe { load_trusted_setup_file(&mut c_settings, file) };
@@ -408,10 +397,7 @@ pub fn load_trusted_setup_file_invalid_format_test(
408397
let file_path = get_trusted_setup_fixture_path(&fixture.name);
409398
let file = unsafe {
410399
let c_file_path = CString::new(file_path.clone()).unwrap();
411-
libc::fopen(
412-
c_file_path.as_ptr(),
413-
CStr::from_bytes_with_nul_unchecked(b"r\0").as_ptr(),
414-
)
400+
libc::fopen(c_file_path.as_ptr(), c"r".as_ptr())
415401
};
416402

417403
assert!(!file.is_null());
@@ -469,10 +455,7 @@ pub fn load_trusted_setup_file_valid_format_test(
469455
let file_path = get_trusted_setup_fixture_path(&fixture.name);
470456
let file = unsafe {
471457
let c_file_path = CString::new(file_path.clone()).unwrap();
472-
libc::fopen(
473-
c_file_path.as_ptr(),
474-
CStr::from_bytes_with_nul_unchecked(b"r\0").as_ptr(),
475-
)
458+
libc::fopen(c_file_path.as_ptr(), c"r".as_ptr())
476459
};
477460

478461
assert!(!file.is_null());

kzg-bench/src/tests/das.rs

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub fn das_extension_test_known<TFr: Fr, TFFTSettings: FFTSettings<TFr> + DASExt
3232

3333
/// Check that DAS extension produces correct odds.
3434
/// Verify this by checking that the second half of the inverse FFT coefficients of odd-even interpolated vector results in zeros.
35-
3635
pub fn das_extension_test_random<
3736
TFr: Fr,
3837
TFFTSettings: FFTSettings<TFr> + DASExtension<TFr> + FFTFr<TFr>,

kzg-bench/src/tests/zero_poly.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn reduce_partials_random<
102102
missing.shuffle(&mut thread_rng());
103103

104104
let missing_per_partial = 63;
105-
let partial_count = (missing_count + missing_per_partial - 1) / missing_per_partial;
105+
let partial_count = missing_count.div_ceil(missing_per_partial);
106106

107107
let mut idxs = vec![0usize; missing_per_partial];
108108
let mut partials = Vec::new();

kzg/src/das.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ fn compute_weighted_sum_of_commitments<B: EcBackend>(
664664
#[cfg(feature = "parallel")]
665665
{
666666
let num_threads = rayon::current_num_threads();
667-
let chunk_size = (r_powers.len() + num_threads - 1) / num_threads;
667+
let chunk_size = r_powers.len().div_ceil(num_threads);
668668

669669
let intermediate_weights: Vec<_> = r_powers
670670
.par_chunks(chunk_size)

kzg/src/eip_4844.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -956,10 +956,7 @@ pub fn evaluate_polynomial_in_evaluation_form<
956956
}
957957

958958
tmp = TFr::from_u64(FIELD_ELEMENTS_PER_BLOB as u64);
959-
out = match out.div(&tmp) {
960-
Ok(value) => value,
961-
Err(err) => return Err(err),
962-
};
959+
out = out.div(&tmp)?;
963960
tmp = x.pow(FIELD_ELEMENTS_PER_BLOB);
964961
tmp = tmp.sub(&TFr::one());
965962
out = out.mul(&tmp);

kzg/src/msm/arkmsm/arkmsm_msm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl VariableBaseMSM {
6666
max_batch: u32,
6767
max_collisions: u32,
6868
) -> TG1 {
69-
let num_slices: usize = ((G1_SCALAR_SIZE_GLV + window_bits - 1) / window_bits) as usize;
69+
let num_slices: usize = G1_SCALAR_SIZE_GLV.div_ceil(window_bits) as usize;
7070
let mut bucket_msm = BucketMSM::<TG1, TG1Fp, TG1Affine, TProjAddAffine>::new(
7171
G1_SCALAR_SIZE_GLV,
7272
window_bits,
@@ -120,7 +120,7 @@ impl VariableBaseMSM {
120120
max_batch: u32,
121121
max_collisions: u32,
122122
) -> TG1 {
123-
let num_slices: usize = ((G1_SCALAR_SIZE + window_bits - 1) / window_bits) as usize;
123+
let num_slices: usize = G1_SCALAR_SIZE.div_ceil(window_bits) as usize;
124124
let mut bucket_msm = BucketMSM::<TG1, TG1Fp, TG1Affine, TProjAddAffine>::new(
125125
G1_SCALAR_SIZE,
126126
window_bits,

kzg/src/msm/arkmsm/bucket_msm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<
5151
max_collision_cnt: u32, // default: 128
5252
) -> Self {
5353
// TODO: Check if these can be turned into consts
54-
let num_windows = (scalar_bits + window_bits - 1) / window_bits;
54+
let num_windows = scalar_bits.div_ceil(window_bits);
5555
let batch_size = core::cmp::max(8192, max_batch_cnt);
5656
let bucket_bits = window_bits - 1; // half buckets needed because of signed-bucket-index
5757
let bucket_size = num_windows << bucket_bits;

kzg/src/msm/bgmw.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ const fn get_table_dimensions(window: BgmwWindow) -> (usize, usize) {
5454
}
5555
}
5656

57-
let h =
58-
(NBITS + window_width - 1) / window_width + is_zero((NBITS % window_width) as u64) as usize;
57+
let h = NBITS.div_ceil(window_width) + is_zero((NBITS % window_width) as u64) as usize;
5958

6059
(window_width, h)
6160
}
@@ -126,7 +125,7 @@ const fn bgmw_parallel_window_size(npoints: usize, ncpus: usize) -> (usize, usiz
126125

127126
let mut win = 2;
128127
while win <= 40 {
129-
let ops = (1 << win) + ((((255 + win - 1) / win) + ncpus - 1) / ncpus * npoints) - 2;
128+
let ops = (1 << win) + (255usize.div_ceil(win).div_ceil(ncpus) * npoints) - 2;
130129
if min_ops >= ops {
131130
min_ops = ops;
132131
opt = win;
@@ -142,7 +141,7 @@ const fn bgmw_parallel_window_size(npoints: usize, ncpus: usize) -> (usize, usiz
142141
let nx = ncpus * mult;
143142
let wnd = bgmw_window_size(npoints / nx);
144143

145-
let ops = mult * ((255 + wnd - 1) / wnd) * ((npoints + nx - 1) / nx) + (1 << wnd) - 2;
144+
let ops = mult * 255usize.div_ceil(wnd) * npoints.div_ceil(nx) + (1 << wnd) - 2;
146145

147146
if min_ops > ops {
148147
min_ops = ops;
@@ -153,7 +152,7 @@ const fn bgmw_parallel_window_size(npoints: usize, ncpus: usize) -> (usize, usiz
153152
mult += 1;
154153
}
155154

156-
(opt_x, (255 + opt - 1) / opt, opt)
155+
(opt_x, 255usize.div_ceil(opt), opt)
157156
}
158157

159158
impl<

kzg/src/msm/parallel_pippenger_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pub const fn breakdown(window: usize, ncpus: usize) -> (usize, usize, usize) {
1111
if (window + wnd) > 18 {
1212
wnd = window - wnd;
1313
} else {
14-
wnd = (NBITS / window + ncpus - 1) / ncpus;
15-
if (NBITS / (window + 1) + ncpus - 1) / ncpus < wnd {
14+
wnd = (NBITS / window).div_ceil(ncpus);
15+
if (NBITS / (window + 1)).div_ceil(ncpus) < wnd {
1616
wnd = window + 1;
1717
} else {
1818
wnd = window;

mcl/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ rand = { version = "0.8.5", optional = true }
1212
rayon = { version = "1.8.0", optional = true }
1313
smallvec = { version = "1.11.1", features = ["const_generics"] }
1414
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
15-
mcl_rust = { git = "https://github.com/herumi/mcl-rust.git" }
15+
mcl_rust = { git = "https://github.com/herumi/mcl-rust.git", rev = "db8e9a639d27fffb167bc48159ef2e3178b347dc" }
1616

1717
[dev-dependencies]
1818
criterion = "0.5.1"

mcl/src/mcl_methods.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use core::ops::{Sub, SubAssign};
1010
use core::primitive::str;
1111
use once_cell::sync::OnceCell;
1212

13-
#[link(name = "mcl", kind = "static")]
1413
#[link(name = "mclbn384_256", kind = "static")]
14+
#[link(name = "mcl", kind = "static")]
1515
#[cfg_attr(target_arch = "x86_64", link(name = "stdc++"))]
1616
#[allow(non_snake_case, clippy::duplicated_attributes)]
1717
extern "C" {

mcl/src/types/kzg_settings.rs

+1
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ impl<'a> TryFrom<&'a CKZGSettings> for MclKZGSettings {
401401
.collect::<Vec<_>>()
402402
})
403403
.collect::<Vec<_>>(),
404+
#[allow(static_mut_refs)]
404405
precomputation: unsafe { PRECOMPUTATION_TABLES.get_precomputation(settings) },
405406
cell_size: eth::FIELD_ELEMENTS_PER_CELL,
406407
})

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[toolchain]
2-
channel = 'stable-2024-09-05'
2+
channel = 'stable-2025-01-30'
33
profile = 'minimal'
44
components = ['clippy', 'rustfmt']
55
targets = ["x86_64-unknown-linux-gnu", "x86_64-pc-windows-gnu", "wasm32-unknown-unknown"]

zkcrypto/bls12_381/src/fp12.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl Fp12 {
194194
}
195195
}
196196

197-
impl<'a, 'b> Mul<&'b Fp12> for &'a Fp12 {
197+
impl<'b> Mul<&'b Fp12> for &Fp12 {
198198
type Output = Fp12;
199199

200200
#[inline]
@@ -213,7 +213,7 @@ impl<'a, 'b> Mul<&'b Fp12> for &'a Fp12 {
213213
}
214214
}
215215

216-
impl<'a, 'b> Add<&'b Fp12> for &'a Fp12 {
216+
impl<'b> Add<&'b Fp12> for &Fp12 {
217217
type Output = Fp12;
218218

219219
#[inline]
@@ -225,7 +225,7 @@ impl<'a, 'b> Add<&'b Fp12> for &'a Fp12 {
225225
}
226226
}
227227

228-
impl<'a> Neg for &'a Fp12 {
228+
impl Neg for &Fp12 {
229229
type Output = Fp12;
230230

231231
#[inline]
@@ -246,7 +246,7 @@ impl Neg for Fp12 {
246246
}
247247
}
248248

249-
impl<'a, 'b> Sub<&'b Fp12> for &'a Fp12 {
249+
impl<'b> Sub<&'b Fp12> for &Fp12 {
250250
type Output = Fp12;
251251

252252
#[inline]

zkcrypto/bls12_381/src/fp6.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl Fp6 {
312312
}
313313
}
314314

315-
impl<'a, 'b> Mul<&'b Fp6> for &'a Fp6 {
315+
impl<'b> Mul<&'b Fp6> for &Fp6 {
316316
type Output = Fp6;
317317

318318
#[inline]
@@ -321,7 +321,7 @@ impl<'a, 'b> Mul<&'b Fp6> for &'a Fp6 {
321321
}
322322
}
323323

324-
impl<'a, 'b> Add<&'b Fp6> for &'a Fp6 {
324+
impl<'b> Add<&'b Fp6> for &Fp6 {
325325
type Output = Fp6;
326326

327327
#[inline]
@@ -334,7 +334,7 @@ impl<'a, 'b> Add<&'b Fp6> for &'a Fp6 {
334334
}
335335
}
336336

337-
impl<'a> Neg for &'a Fp6 {
337+
impl Neg for &Fp6 {
338338
type Output = Fp6;
339339

340340
#[inline]
@@ -356,7 +356,7 @@ impl Neg for Fp6 {
356356
}
357357
}
358358

359-
impl<'a, 'b> Sub<&'b Fp6> for &'a Fp6 {
359+
impl<'b> Sub<&'b Fp6> for &Fp6 {
360360
type Output = Fp6;
361361

362362
#[inline]

0 commit comments

Comments
 (0)