Skip to content

Commit

Permalink
fix: adjust rebase for blake2s + sha512 events
Browse files Browse the repository at this point in the history
  • Loading branch information
huitseeker committed Oct 7, 2024
1 parent 62f9557 commit d28b1b4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,12 @@ impl<'a> Runtime<'a> {
SyscallCode::SHA_COMPRESS => {
(self.opts.split_opts.sha_compress_split_threshold, 80)
}
SyscallCode::SHA512_EXTEND => {
(self.opts.split_opts.sha512_extend_split_threshold, 48)
}
SyscallCode::SHA512_COMPRESS => {
(self.opts.split_opts.sha512_compress_split_threshold, 80)
}
_ => (self.opts.split_opts.deferred_shift_threshold, 1),
};
let nonce = (((*syscall_count as usize) % threshold) * multiplier) as u32;
Expand Down
28 changes: 28 additions & 0 deletions core/src/runtime/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ pub struct SplitOpts {
pub keccak_split_threshold: usize,
pub sha_extend_split_threshold: usize,
pub sha_compress_split_threshold: usize,
pub sha512_extend_split_threshold: usize,
pub sha512_compress_split_threshold: usize,
pub memory_split_threshold: usize,
}

Expand All @@ -361,6 +363,8 @@ impl SplitOpts {
keccak_split_threshold: deferred_shift_threshold / 24,
sha_extend_split_threshold: deferred_shift_threshold / 48,
sha_compress_split_threshold: deferred_shift_threshold / 80,
sha512_extend_split_threshold: deferred_shift_threshold / 48,
sha512_compress_split_threshold: deferred_shift_threshold / 80,
memory_split_threshold: deferred_shift_threshold,
}
}
Expand Down Expand Up @@ -657,10 +661,13 @@ impl ExecutionRecord {
secp256k1_double_events: take(&mut self.secp256k1_double_events),
bn254_add_events: take(&mut self.bn254_add_events),
bn254_double_events: take(&mut self.bn254_double_events),
blake2s_round_events: take(&mut self.blake2s_round_events),
bls12381_g1_add_events: take(&mut self.bls12381_g1_add_events),
bls12381_g1_double_events: take(&mut self.bls12381_g1_double_events),
sha_extend_events: take(&mut self.sha_extend_events),
sha_compress_events: take(&mut self.sha_compress_events),
sha512_extend_events: take(&mut self.sha512_extend_events),
sha512_compress_events: take(&mut self.sha512_compress_events),
ed_add_events: take(&mut self.ed_add_events),
ed_decompress_events: take(&mut self.ed_decompress_events),
secp256k1_decompress_events: take(&mut self.secp256k1_decompress_events),
Expand Down Expand Up @@ -740,6 +747,13 @@ impl ExecutionRecord {
opts.deferred_shift_threshold,
last
);
split_events!(
self,
blake2s_round_events,
shards,
opts.deferred_shift_threshold,
last
);
split_events!(
self,
bls12381_g1_add_events,
Expand Down Expand Up @@ -768,6 +782,20 @@ impl ExecutionRecord {
opts.sha_compress_split_threshold,
last
);
split_events!(
self,
sha512_extend_events,
shards,
opts.sha512_extend_split_threshold,
last
);
split_events!(
self,
sha512_compress_events,
shards,
opts.sha512_compress_split_threshold,
last
);
split_events!(
self,
ed_add_events,
Expand Down
4 changes: 4 additions & 0 deletions core/src/stark/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ impl<F: PrimeField32> RiscvAir<F> {
chips.push(RiscvAir::Sha256Extend(sha_extend));
let sha_compress = ShaCompressChip;
chips.push(RiscvAir::Sha256Compress(sha_compress));
let sha512_extend = Sha512ExtendChip;
chips.push(RiscvAir::Sha512Extend(sha512_extend));
let sha512_compress = Sha512CompressChip;
chips.push(RiscvAir::Sha512Compress(sha512_compress));
let ed_add_assign = EdAddAssignChip::<EdwardsCurve<Ed25519Parameters>>::new();
chips.push(RiscvAir::Ed25519Add(ed_add_assign));
let ed_decompress = EdDecompressChip::<Ed25519Parameters>::default();
Expand Down

0 comments on commit d28b1b4

Please sign in to comment.