Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Fail gracefully when looking up exports #154

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_arithmetic_u32_isodd",
"name": "tasmlib_arithmetic_u32_is_odd",
"benchmark_result": {
"clock_cycle_count": 8,
"hash_table_height": 12,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_arithmetic_u32_isodd",
"name": "tasmlib_arithmetic_u32_is_odd",
"benchmark_result": {
"clock_cycle_count": 8,
"hash_table_height": 12,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_arithmetic_u32_isu32",
"name": "tasmlib_arithmetic_u32_is_u32",
"benchmark_result": {
"clock_cycle_count": 7,
"hash_table_height": 12,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_arithmetic_u32_isu32",
"name": "tasmlib_arithmetic_u32_is_u32",
"benchmark_result": {
"clock_cycle_count": 7,
"hash_table_height": 12,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_arithmetic_u32_overflowingadd",
"name": "tasmlib_arithmetic_u32_overflowing_add",
"benchmark_result": {
"clock_cycle_count": 6,
"hash_table_height": 6,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_arithmetic_u32_overflowingadd",
"name": "tasmlib_arithmetic_u32_overflowing_add",
"benchmark_result": {
"clock_cycle_count": 6,
"hash_table_height": 6,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_arithmetic_u32_safeadd",
"name": "tasmlib_arithmetic_u32_safe_add",
"benchmark_result": {
"clock_cycle_count": 10,
"hash_table_height": 12,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_arithmetic_u32_safeadd",
"name": "tasmlib_arithmetic_u32_safe_add",
"benchmark_result": {
"clock_cycle_count": 10,
"hash_table_height": 12,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_arithmetic_u32_safemul",
"name": "tasmlib_arithmetic_u32_safe_mul",
"benchmark_result": {
"clock_cycle_count": 10,
"hash_table_height": 12,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_arithmetic_u32_safemul",
"name": "tasmlib_arithmetic_u32_safe_mul",
"benchmark_result": {
"clock_cycle_count": 10,
"hash_table_height": 12,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_arithmetic_u32_safepow",
"name": "tasmlib_arithmetic_u32_safe_pow",
"benchmark_result": {
"clock_cycle_count": 114,
"hash_table_height": 48,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_arithmetic_u32_safepow",
"name": "tasmlib_arithmetic_u32_safe_pow",
"benchmark_result": {
"clock_cycle_count": 195,
"hash_table_height": 48,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_arithmetic_u32_safesub",
"name": "tasmlib_arithmetic_u32_safe_sub",
"benchmark_result": {
"clock_cycle_count": 13,
"hash_table_height": 12,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_arithmetic_u32_safesub",
"name": "tasmlib_arithmetic_u32_safe_sub",
"benchmark_result": {
"clock_cycle_count": 13,
"hash_table_height": 12,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_arithmetic_u32_shiftleft",
"name": "tasmlib_arithmetic_u32_shift_left",
"benchmark_result": {
"clock_cycle_count": 13,
"hash_table_height": 12,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_arithmetic_u32_shiftleft",
"name": "tasmlib_arithmetic_u32_shift_left",
"benchmark_result": {
"clock_cycle_count": 13,
"hash_table_height": 12,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_arithmetic_u32_shiftright",
"name": "tasmlib_arithmetic_u32_shift_right",
"benchmark_result": {
"clock_cycle_count": 16,
"hash_table_height": 18,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_arithmetic_u32_shiftright",
"name": "tasmlib_arithmetic_u32_shift_right",
"benchmark_result": {
"clock_cycle_count": 16,
"hash_table_height": 18,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_list_length___digest",
"name": "tasmlib_list_length",
"benchmark_result": {
"clock_cycle_count": 5,
"hash_table_height": 6,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_list_length___digest",
"name": "tasmlib_list_length",
"benchmark_result": {
"clock_cycle_count": 5,
"hash_table_height": 6,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_list_new___digest",
"name": "tasmlib_list_new",
"benchmark_result": {
"clock_cycle_count": 32,
"hash_table_height": 36,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_list_new___digest",
"name": "tasmlib_list_new",
"benchmark_result": {
"clock_cycle_count": 32,
"hash_table_height": 36,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "tasmlib_list_set_length___digest",
"name": "tasmlib_list_set_length",
"benchmark_result": {
"clock_cycle_count": 7,
"hash_table_height": 12,
Expand All @@ -11,7 +11,7 @@
"case": "CommonCase"
},
{
"name": "tasmlib_list_set_length___digest",
"name": "tasmlib_list_set_length",
"benchmark_result": {
"clock_cycle_count": 7,
"hash_table_height": 12,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "tasmlib_neptune_mutator_get_swbf_indices_1048576_45",
"benchmark_result": {
"clock_cycle_count": 4395,
"hash_table_height": 481,
"hash_table_height": 475,
"u32_table_height": 4633,
"op_stack_table_height": 3184,
"ram_table_height": 470
Expand All @@ -14,7 +14,7 @@
"name": "tasmlib_neptune_mutator_get_swbf_indices_1048576_45",
"benchmark_result": {
"clock_cycle_count": 4395,
"hash_table_height": 481,
"hash_table_height": 475,
"u32_table_height": 4507,
"op_stack_table_height": 3184,
"ram_table_height": 470
Expand Down
4 changes: 2 additions & 2 deletions tasm-lib/benchmarks/tasmlib_verifier_fri_verify.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "tasmlib_verifier_fri_verify",
"benchmark_result": {
"clock_cycle_count": 43998,
"hash_table_height": 14682,
"hash_table_height": 14652,
"u32_table_height": 17999,
"op_stack_table_height": 42235,
"ram_table_height": 17563
Expand All @@ -14,7 +14,7 @@
"name": "tasmlib_verifier_fri_verify",
"benchmark_result": {
"clock_cycle_count": 43998,
"hash_table_height": 14682,
"hash_table_height": 14652,
"u32_table_height": 17395,
"op_stack_table_height": 42235,
"ram_table_height": 17563
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "tasmlib_verifier_stark_verify_dynamic_inner_padded_height_256_fri_exp_4",
"benchmark_result": {
"clock_cycle_count": 188148,
"hash_table_height": 138847,
"hash_table_height": 138823,
"u32_table_height": 25078,
"op_stack_table_height": 167240,
"ram_table_height": 289169
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "tasmlib_verifier_stark_verify_dynamic_inner_padded_height_512_fri_exp_4",
"benchmark_result": {
"clock_cycle_count": 195637,
"hash_table_height": 146539,
"hash_table_height": 146515,
"u32_table_height": 33679,
"op_stack_table_height": 171942,
"ram_table_height": 290320
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "tasmlib_verifier_stark_verify_static_inner_padded_height_256_fri_exp_4",
"benchmark_result": {
"clock_cycle_count": 176445,
"hash_table_height": 124807,
"hash_table_height": 124777,
"u32_table_height": 25078,
"op_stack_table_height": 159434,
"ram_table_height": 285270
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "tasmlib_verifier_stark_verify_static_inner_padded_height_512_fri_exp_4",
"benchmark_result": {
"clock_cycle_count": 183934,
"hash_table_height": 132499,
"hash_table_height": 132469,
"u32_table_height": 33679,
"op_stack_table_height": 164136,
"ram_table_height": 286421
Expand Down
12 changes: 6 additions & 6 deletions tasm-lib/src/arithmetic/i128/shift_right.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use triton_vm::prelude::*;

use crate::arithmetic::u32::isu32::Isu32;
use crate::arithmetic::u32::shiftleft::Shiftleft;
use crate::arithmetic::u32::shiftright::Shiftright;
use crate::arithmetic::u32::is_u32::IsU32;
use crate::arithmetic::u32::shift_left::ShiftLeft as ShlU32;
use crate::arithmetic::u32::shift_right::ShiftRight as ShrU32;
use crate::prelude::*;

/// Right-shift for 128-bit integers AKA [right-shift for `i128`][shr].
Expand Down Expand Up @@ -63,9 +63,9 @@ impl BasicSnippet for ShiftRight {
let clean_up_for_early_return = format!("{entrypoint}_early_return");
let entrypoint = self.entrypoint();

let is_u32 = library.import(Box::new(Isu32));
let shr_u32 = library.import(Box::new(Shiftright));
let shl_u32 = library.import(Box::new(Shiftleft));
let is_u32 = library.import(Box::new(IsU32));
let shr_u32 = library.import(Box::new(ShrU32));
let shl_u32 = library.import(Box::new(ShlU32));

triton_asm! {
// BEFORE: _ arg3 arg2 arg1 arg0 shamt
Expand Down
18 changes: 9 additions & 9 deletions tasm-lib/src/arithmetic/u32.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub mod isodd;
pub mod isu32;
pub mod is_odd;
pub mod is_u32;
pub mod leading_zeros;
pub mod next_power_of_two;
pub mod or;
pub mod overflowingadd;
pub mod safeadd;
pub mod safemul;
pub mod safepow;
pub mod safesub;
pub mod shiftleft;
pub mod shiftright;
pub mod overflowing_add;
pub mod safe_add;
pub mod safe_mul;
pub mod safe_pow;
pub mod safe_sub;
pub mod shift_left;
pub mod shift_right;
pub mod trailing_zeros;
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use crate::traits::deprecated_snippet::DeprecatedSnippet;
use crate::InitVmState;

#[derive(Clone, Debug)]
pub struct Isodd;
pub struct IsOdd;

impl DeprecatedSnippet for Isodd {
impl DeprecatedSnippet for IsOdd {
fn entrypoint_name(&self) -> String {
"tasmlib_arithmetic_u32_isodd".to_string()
"tasmlib_arithmetic_u32_is_odd".to_string()
}

fn input_field_names(&self) -> Vec<String> {
Expand Down Expand Up @@ -105,7 +105,7 @@ mod tests {

#[test]
fn is_odd_u32_test() {
test_rust_equivalence_multiple_deprecated(&Isodd, true);
test_rust_equivalence_multiple_deprecated(&IsOdd, true);
}

#[test]
Expand Down Expand Up @@ -135,7 +135,7 @@ mod tests {
expected_stack.push(BFieldElement::new((value % 2) as u64));

test_rust_equivalence_given_input_values_deprecated(
&Isodd,
&IsOdd,
&init_stack,
&[],
HashMap::default(),
Expand All @@ -151,6 +151,6 @@ mod benches {

#[test]
fn is_odd_u32_benchmark() {
bench_and_write(Isodd);
bench_and_write(IsOdd);
}
}
Loading
Loading