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

Fixes to run the bootloader integration tests #37

Conversation

odesenfans
Copy link

This PR contains all the changes and fixes required to run the bootloader integration tests in the madara-prover-api repository.

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.
    • CHANGELOG has been updated.

@odesenfans odesenfans force-pushed the dev-bootloader-hints-rebased-on-main branch from f183751 to 79dc495 Compare January 18, 2024 10:59
@odesenfans odesenfans force-pushed the od/bootloader-itests-rebased-on-main branch 2 times, most recently from e0f3574 to 444e7f2 Compare January 22, 2024 10:38
Copy link

github-actions bot commented Jan 22, 2024

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.310 ± 0.037 2.264 2.397 1.00
head big_factorial 2.312 ± 0.047 2.261 2.410 1.00 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.301 ± 0.037 2.262 2.383 1.02 ± 0.02
head big_fibonacci 2.267 ± 0.035 2.225 2.314 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 8.734 ± 0.090 8.618 8.831 1.01 ± 0.03
head blake2s_integration_benchmark 8.654 ± 0.252 8.467 9.189 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.357 ± 0.037 2.305 2.416 1.00
head compare_arrays_200000 2.380 ± 0.026 2.347 2.436 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.468 ± 0.009 1.458 1.488 1.00
head dict_integration_benchmark 1.484 ± 0.015 1.462 1.510 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.428 ± 0.018 1.404 1.459 1.01 ± 0.02
head field_arithmetic_get_square_benchmark 1.412 ± 0.014 1.389 1.432 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 8.527 ± 0.118 8.384 8.730 1.00
head integration_builtins 8.775 ± 0.165 8.603 9.207 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 8.895 ± 0.101 8.785 9.101 1.00
head keccak_integration_benchmark 8.914 ± 0.382 8.679 9.978 1.00 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.388 ± 0.037 2.330 2.442 1.02 ± 0.02
head linear_search 2.337 ± 0.044 2.298 2.443 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.828 ± 0.033 1.796 1.906 1.00
head math_cmp_and_pow_integration_benchmark 1.876 ± 0.027 1.838 1.913 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.664 ± 0.019 1.634 1.700 1.03 ± 0.01
head math_integration_benchmark 1.623 ± 0.006 1.611 1.633 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.297 ± 0.023 1.272 1.333 1.00
head memory_integration_benchmark 1.315 ± 0.031 1.271 1.371 1.01 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.977 ± 0.038 1.947 2.070 1.03 ± 0.02
head operations_with_data_structures_benchmarks 1.923 ± 0.010 1.907 1.945 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 600.9 ± 4.4 594.6 609.2 1.00
head pedersen 605.6 ± 9.6 596.7 627.8 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.005 ± 0.011 0.992 1.026 1.00
head poseidon_integration_benchmark 1.006 ± 0.005 0.999 1.013 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.048 ± 0.010 2.033 2.064 1.00
head secp_integration_benchmark 2.049 ± 0.010 2.038 2.071 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 788.0 ± 7.0 776.4 797.7 1.01 ± 0.02
head set_integration_benchmark 783.7 ± 12.0 772.4 815.5 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.825 ± 0.040 4.770 4.898 1.00 ± 0.02
head uint256_integration_benchmark 4.825 ± 0.086 4.667 4.951 1.00

@odesenfans odesenfans force-pushed the dev-bootloader-hints-rebased-on-main branch 2 times, most recently from 2ae2391 to 0945d6d Compare February 22, 2024 22:58
Some issues occurred when compiling the project with the Madara prover
API.
Store the `simple_bootloader_input` field of the bootloader input
instead of storing the whole bootloader_input.
The hint is compiled to a different code.
A backslash was encoded the wrong way in the hint code.
Implement the hint that determines whether a specific builtin is
selected for the given program.
`pre_execution_builtin_ptrs` is an array of pointers, not of values as
we previously understood.
Problem: `write_return_builtins` copies data from the pre-execution
builtins for each builtin not used by the program. We specify that the
value of the pre-execution builtins is integer, which is not the case.

Solution: just copy the memory without enforcing a specific type.
Implemented `get_task_fact_topologies` for Cairo PIE tasks at the same
time.
The hint is compiled to a different code.
…utput)

The hint is compiled to a different code.
Remove the hardcoded value for `ret_pc` and compute it using the program
identifiers instead. We now expect the bootloader program to be
accessible as the `bootloader_program` variable in the root execution
scope.
Problem: Deserializing the PIE additional data as a hashmap of
`BuiltinAdditionalData` enums because of an issue with deserializing
untagged unions in `serde`
(see serde-rs/json#1103).

Solution: add a new `AdditionalData` struct with explicit fields for each
builtin, circumventing the untagged union issue. This solution has the
advantage of always associating the correct data type for each builtin
(it's not possible anymore to associate a builtin with a different data
type), but requires modifications if a new builtin is added.
Problem: the ECDSA/signature builtin additional data is stored
internally as a hashmap, but the Python VM stores it as a vector of
tuples.

Solution: Add a `SignatureBuiltinAdditionalData` struct and implement a
custom deserializer for it that can take either a hashmap or a vector.
Fixed a bug in the memory file loader implementation.
Problem: output page IDs do not appear when exporting the builtin
memory, but default to page 0 instead.

Solution: add a `get_public_memory` to the output builtin to export page
IDs correctly.
Added a `from_bytes` class method to build a `CairoPie` method in
addition to the existing `from_file` method.
@odesenfans odesenfans force-pushed the od/bootloader-itests-rebased-on-main branch from b2f69d2 to e0a4653 Compare February 22, 2024 23:35
@odesenfans
Copy link
Author

Obsolete, we upstreamed all the changes.

@odesenfans odesenfans closed this Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants