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

Serialize and deserialize program #1458

Merged
merged 27 commits into from
Oct 24, 2023
Merged

Conversation

pefontana
Copy link
Collaborator

@pefontana pefontana commented Oct 10, 2023

Add a Serialize and Deserialize method for the Program struct

Description

  • Create the ProgramSerializer Struct used to Serialize and Deserialize a Program struct. The goal of this struct, is to be equal to the ProgramJson but is to keep the Default Serialization and Deserialization traits
  • Add the method to Serialize and Deserialize a Program struct

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.

@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Merging #1458 (5df44fc) into main (01a5773) will increase coverage by 0.00%.
The diff coverage is 97.04%.

@@           Coverage Diff            @@
##             main    #1458    +/-   ##
========================================
  Coverage   96.82%   96.82%            
========================================
  Files          94       95     +1     
  Lines       39215    39451   +236     
========================================
+ Hits        37970    38199   +229     
- Misses       1245     1252     +7     
Files Coverage Δ
vm/src/serde/deserialize_program.rs 97.36% <100.00%> (ø)
vm/src/types/program.rs 99.43% <100.00%> (+0.01%) ⬆️
vm/src/serde/serialize_program.rs 96.71% <96.71%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link

github-actions bot commented Oct 10, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 3.534 ± 0.012 3.513 3.551 1.00
head big_factorial 3.604 ± 0.017 3.589 3.645 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.969 ± 0.014 2.956 3.005 1.00
head big_fibonacci 3.034 ± 0.012 3.016 3.054 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.997 ± 0.073 7.916 8.128 1.00
head blake2s_integration_benchmark 8.219 ± 0.040 8.177 8.295 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.995 ± 0.016 2.970 3.017 1.00
head compare_arrays_200000 3.035 ± 0.020 3.022 3.077 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 2.083 ± 0.004 2.078 2.091 1.00
head dict_integration_benchmark 2.126 ± 0.003 2.121 2.131 1.02 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.541 ± 0.009 1.532 1.561 1.00
head field_arithmetic_get_square_benchmark 1.564 ± 0.005 1.558 1.575 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 8.000 ± 0.085 7.914 8.112 1.00
head integration_builtins 8.191 ± 0.066 8.140 8.330 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 8.219 ± 0.084 8.130 8.333 1.00
head keccak_integration_benchmark 8.382 ± 0.026 8.363 8.449 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base linear_search 3.039 ± 0.016 3.024 3.072 1.00
head linear_search 3.075 ± 0.009 3.065 3.097 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 2.197 ± 0.006 2.187 2.205 1.00
head math_cmp_and_pow_integration_benchmark 2.225 ± 0.014 2.214 2.260 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.985 ± 0.005 1.981 1.994 1.00
head math_integration_benchmark 2.020 ± 0.003 2.016 2.026 1.02 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.757 ± 0.012 1.745 1.781 1.00
head memory_integration_benchmark 1.774 ± 0.009 1.764 1.789 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.969 ± 0.007 1.958 1.982 1.00
head operations_with_data_structures_benchmarks 2.008 ± 0.003 2.002 2.011 1.02 ± 0.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 752.1 ± 0.8 750.9 753.9 1.00
head pedersen 761.0 ± 2.4 758.4 764.8 1.01 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.480 ± 0.005 1.471 1.486 1.00
head poseidon_integration_benchmark 1.490 ± 0.009 1.483 1.511 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.499 ± 0.005 2.490 2.506 1.00
head secp_integration_benchmark 2.538 ± 0.009 2.529 2.557 1.02 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 1.283 ± 0.003 1.280 1.286 1.00
head set_integration_benchmark 1.356 ± 0.035 1.340 1.454 1.06 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 5.398 ± 0.023 5.365 5.448 1.00
head uint256_integration_benchmark 5.544 ± 0.045 5.512 5.661 1.03 ± 0.01

@pefontana pefontana force-pushed the serialize-and-deserialize-program branch from a0f8665 to fd791ed Compare October 12, 2023 20:10
@pefontana pefontana linked an issue Oct 12, 2023 that may be closed by this pull request
@pefontana pefontana marked this pull request as ready for review October 12, 2023 20:57
@pefontana pefontana linked an issue Oct 12, 2023 that may be closed by this pull request
CHANGELOG.md Outdated Show resolved Hide resolved
@Oppen
Copy link
Contributor

Oppen commented Oct 19, 2023

The goal of this struct, is to be equal to the ProgramJson but is to keep the Default Serialization and Deserialization traits

Why can't ProgramJson derive them?

@pefontana
Copy link
Collaborator Author

pefontana commented Oct 19, 2023

The goal of this struct, is to be equal to the ProgramJson but is to keep the Default Serialization and Deserialization traits

Why can't ProgramJson derive them?

Because the ProgramJson has custom implementations of the Deserialize trait in some fields,
That causes errors when serializing (with the default implementation) and then deserializing the ProgramJson struct

@pefontana pefontana requested a review from fmoletta October 20, 2023 14:29
@fmoletta fmoletta added this pull request to the merge queue Oct 24, 2023
Merged via the queue into main with commit e6171d6 Oct 24, 2023
50 checks passed
@fmoletta fmoletta deleted the serialize-and-deserialize-program branch October 24, 2023 22:22
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.

Implement a Program Serialization method Program serialization
4 participants