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

Add script to automate the configuration of the fri steps #29

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,5 @@ FRI steps should typically be in the range 2-4;
the degree bound should be in the range 4-7.

The constant 4 that appears in the equation is hardcoded `log₂(trace_rows_per_step) = log₂(16) = 4`.

A python script to compute the `fri_step_list` can be found [here](fri_step_list.py)
33 changes: 33 additions & 0 deletions fri_step_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import math
import sys
import json

# python3 fri_step_list.py ../fibonacci_public_input.json ./new_cpu_air_params.json
if len(sys.argv) != 3:
raise ValueError('Please provide the path to the public input file and the destination file for new cpu air '
'params json file')
public_input_file_path = sys.argv[1]
cpu_air_params_destination_path = sys.argv[2]

with open(public_input_file_path, 'r') as file:
public_input_file = json.load(file)
program_n_steps = public_input_file['n_steps']

print(program_n_steps)
last_layer_degree_bound = 128
last_layer_degree_bound_log = math.ceil(
math.log(last_layer_degree_bound, 2)
)
program_n_steps_log = math.ceil(math.log(program_n_steps, 2))
sigma_fri_step_list = program_n_steps_log + 4 - last_layer_degree_bound_log

(q, r) = divmod(sigma_fri_step_list, 4)
fri_step_list = [0] + [4] * q
if r > 0:
fri_step_list.append(r)

with open('e2e_test/Cairo/cpu_air_params.json', 'r') as file:
cpu_air_params = json.load(file)
cpu_air_params['stark']['fri']['fri_step_list'] = fri_step_list
with open(cpu_air_params_destination_path, 'w') as new_file:
json.dump(cpu_air_params, new_file, indent=4)