-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
152 lines (128 loc) · 4.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Makefile for Cairo compilation and proof generation
LAYOUT ?= small
CAIRO_PROGRAM ?= examples/dummy_snos/dummy_snos.cairo
CPU_AIR_PROVER := ./dependencies/stone-prover/cpu_air_prover
CAIRO_ENV := ./dependencies/cairo-vm/cairo-vm-env/bin/activate
# Extract the base name without extension
FILENAME_WITH_EXT := $(notdir $(CAIRO_PROGRAM))
FILENAME_WITHOUT_EXT := $(basename $(FILENAME_WITH_EXT))
DIR_NAME := $(dir $(CAIRO_PROGRAM))
OUTPUT_DIR := $(DIR_NAME)output/$(LAYOUT)/
OUTPUT_BASE_NAME := $(OUTPUT_DIR)$(FILENAME_WITHOUT_EXT)
INPUT_BASE_NAME := $(basename $(CAIRO_PROGRAM))
# Variables
COMPILED_OUTPUT := $(OUTPUT_BASE_NAME)_compiled.json
PROGRAM_INPUT := $(INPUT_BASE_NAME)_input.json
PUBLIC_INPUT := $(OUTPUT_BASE_NAME)_public_input.json
PRIVATE_INPUT := $(OUTPUT_BASE_NAME)_private_input.json
TRACE_FILE := $(OUTPUT_BASE_NAME)_trace.bin
MEMORY_FILE := $(OUTPUT_BASE_NAME)_memory.bin
PROOF_FILE := $(OUTPUT_BASE_NAME)_proof.json
CAIRO_PIE_OUTPUT := $(BASE_NAME)_pie.zip
PROVER_CONFIG := $(INPUT_BASE_NAME)_cpu_air_prover_config.json
PARAM_FILE := $(INPUT_BASE_NAME)_cpu_air_params.json
# Phony targets
.PHONY: all compile run prove clean
# Default target
all: compile run prove
# Activate environment
define activate_env
. $(CAIRO_ENV) &&
endef
# Check if CAIRO_PROGRAM is provided
check_program_set:
ifndef CAIRO_PROGRAM
$(error CAIRO_PROGRAM is not set. Usage: make CAIRO_PROGRAM=your_program.cairo)
endif
# Compile the program
compile: check_program_set
mkdir -p $(OUTPUT_DIR)
@echo "Compiling the program..."
$(activate_env) cairo-compile $(CAIRO_PROGRAM) \
--output $(COMPILED_OUTPUT) \
--proof_mode
@echo "Compilation Successfull !!"
# Generate the pie output
generate_pie: compile
@echo "Genrating the PIE..."
$(activate_env) cairo-run \
--program=$(COMPILED_OUTPUT) \
--layout=$(LAYOUT) \
--program_input=$(PROGRAM_INPUT) \
--cairo_pie_output=$(CAIRO_PIE_OUTPUT) \
--trace_file=$(TRACE_FILE) \
--memory_file=$(MEMORY_FILE) \
--print_output
@echo "PIE generation Successfull !!"
# Run the program
run_pie: generate_pie
@echo "Running the prorgram with PIE..."
$(activate_env) cairo-run \
--layout=$(LAYOUT) \
--run_from_cairo_pie=$(CAIRO_PIE_OUTPUT) \
--trace_file=$(TRACE_FILE) \
--memory_file=$(MEMORY_FILE) \
--print_output \
@echo "Running with PIE Successfull !!"
# Run the program
run: compile
@echo "Running the program..."
$(activate_env) cairo-run \
--program=$(COMPILED_OUTPUT) \
--layout=$(LAYOUT) \
--program_input=$(PROGRAM_INPUT) \
--air_public_input=$(PUBLIC_INPUT) \
--air_private_input=$(PRIVATE_INPUT) \
--trace_file=$(TRACE_FILE) \
--memory_file=$(MEMORY_FILE) \
--print_output \
--proof_mode
@echo "Running Successfull !!"
run_bootloader: compile
cargo run -- \
--compiled-program $(COMPILED_OUTPUT) \
--air-public-input $(PUBLIC_INPUT) \
--air-private-input $(PRIVATE_INPUT) \
--memory-file $(MEMORY_FILE) \
--trace $(TRACE_FILE) \
--layout $(LAYOUT)
node format.js $(PUBLIC_INPUT)
@echo "Running with bootloader Successfull !!"
# Generate the proof
proove_with_bootloader: run_bootloader
@echo "Running the stone-prover..."
$(CPU_AIR_PROVER) \
--generate-annotations \
--out_file=$(PROOF_FILE) \
--private_input_file=$(PRIVATE_INPUT) \
--public_input_file=$(PUBLIC_INPUT) \
--prover_config_file=$(PROVER_CONFIG) \
--parameter_file=$(PARAM_FILE)
@echo "Prooving with bootloader Successfull !!"
# Generate the proof
proove_with_program: run
@echo "Running the stone-prover..."
$(CPU_AIR_PROVER) \
--generate-annotations \
--out_file=$(PROOF_FILE) \
--private_input_file=$(PRIVATE_INPUT) \
--public_input_file=$(PUBLIC_INPUT) \
--prover_config_file=$(PROVER_CONFIG) \
--parameter_file=$(PARAM_FILE)
@echo "Prooving without bootloader Successfull !!"
# Clean up generated files
clean: check_program_set
rm -f $(COMPILED_OUTPUT) $(TRACE_FILE) $(MEMORY_FILE) $(PROOF_FILE) $(PRIVATE_INPUT) $(PUBLIC_INPUT) $(CAIRO_PIE_OUTPUT)
# Print the current configuration
print-config:
@echo "Current configuration:"
@echo "CAIRO_PROGRAM: $(CAIRO_PROGRAM)"
@echo "DIR_NAME: $(DIR_NAME)"
@echo "OUTPUT_DIR: $(OUTPUT_DIR)"
@echo "BASE_NAME: $(BASE_NAME)"
@echo "COMPILED_OUTPUT: $(COMPILED_OUTPUT)"
@echo "PUBLIC_INPUT: $(PUBLIC_INPUT)"
@echo "PRIVATE_INPUT: $(PRIVATE_INPUT)"
@echo "TRACE_FILE: $(TRACE_FILE)"
@echo "MEMORY_FILE: $(MEMORY_FILE)"
@echo "PROOF_FILE: $(PROOF_FILE)"