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

Cairo version update + improvements #20

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0430d63
Add helper function for mmr append
fmkra Sep 29, 2023
a143f6f
Check peaks length in mmr append
fmkra Sep 29, 2023
9cb7250
Add test for mmr forge peaks
fmkra Sep 29, 2023
6c130bd
Change utils function from u256 to u32
fmkra Sep 29, 2023
49fde6d
Add natspec comments
fmkra Sep 29, 2023
9b64079
Run scarb fmt
fmkra Sep 29, 2023
b309c9f
Implement trailing_ones helper function
fmkra Sep 29, 2023
a6989df
Improve mmr append
fmkra Sep 29, 2023
e98ef12
Remove unnecessary import in test_mmr
fmkra Sep 29, 2023
ce3e1f2
Run scarb fmt
fmkra Sep 29, 2023
d9e3148
fix words64 to u256 empty words
tiagofneto Oct 3, 2023
3ced64e
Implement get_peak_info function
fmkra Oct 12, 2023
2460417
Tests for get_peak_info function
fmkra Oct 12, 2023
c5af976
Fix verify_proof logic
fmkra Oct 12, 2023
a8581d4
Merge branch 'fixes' into improvement/append
fmkra Oct 12, 2023
01e7d3a
Format
fmkra Oct 12, 2023
fa1d030
use div_rem instead of operators
feltroidprime Mar 14, 2024
d36d653
as_u256_le optimisation
feltroidprime Mar 14, 2024
5c00047
use div_rem in extract_nibbles instead of bitwise ops
feltroidprime Mar 14, 2024
2d8b0ea
slice_le optimisation
feltroidprime Mar 15, 2024
89b5a39
Update scarb version
fmkra Mar 21, 2024
0b17101
Remove unused variable
fmkra Mar 21, 2024
11cfdc6
Refactor tests
fmkra Mar 21, 2024
3aaed82
Fmt
fmkra Mar 21, 2024
f41cbc5
Merge branch 'update-cairo' into improvement/append
fmkra Mar 21, 2024
b5ef6ee
Merge branch 'update-cairo' into safe-perf
fmkra Mar 22, 2024
fcf48af
Fix compatibility with 2.6.4
fmkra Mar 22, 2024
5add5cc
Merge pull request #19 from feltroidprime/safe-perf
fmkra Mar 22, 2024
1e2bc3f
Merge branch 'update-cairo' into improvement/append
fmkra Mar 22, 2024
c65b8e3
MMR append change loops to pop from span
fmkra Mar 22, 2024
f1419ee
Remove unused function
fmkra Mar 22, 2024
f1a5e9a
Use divrem in trailing_ones
fmkra Mar 22, 2024
c00222c
Change u32 to usize
fmkra Mar 22, 2024
f94a861
Benchmarking
fmkra Apr 22, 2024
895ca89
Use const spans in pow2
fmkra Apr 22, 2024
d8af0bd
Fmt with new formatter
fmkra Apr 22, 2024
f31c1ec
Minor optimization of append + comment
fmkra May 6, 2024
14604c0
Fmt
fmkra May 6, 2024
8b117d7
Remove formatting check from CI
fmkra May 6, 2024
52b8b2e
Add rlp decode test which fails
fmkra May 9, 2024
b0f93a1
Fix slice_le bug
fmkra May 9, 2024
bc453f9
Change MMR Size type to u128
fmkra Jun 3, 2024
0db686d
Change Mmr Size to u256
fmkra Jun 7, 2024
f1d8d57
Remove unnecessary if check from slice_le
fmkra Jun 20, 2024
b52286e
Merge pull request #21 from HerodotusDev/audit-fixes
fmkra Oct 23, 2024
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
Prev Previous commit
Next Next commit
Benchmarking
fmkra committed Apr 22, 2024
commit f94a861611e21479c8d76aa5f2dc1a04c1a31bb3
80 changes: 80 additions & 0 deletions benchmark/benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import argparse
import subprocess
import re
import os
import pandas as pd

def bench(name, force):
try:
with open(os.path.join("results", name), "w" if force else "x") as f:
test_out = subprocess.check_output(["scarb", "test"], cwd="..")
results = []
for line in test_out.decode("utf-8").split("\n"):
m = re.match(r"^test ([a-zA-Z0-9_:]+) ... ok \(gas usage est\.: (\d+)\)$", line)
if m:
results.append(f"{m.group(1)} {m.group(2)}")
f.write("\n".join(results))
except FileExistsError:
print(f"Bench {name} already exists. If you want to overwrite it, pass the --force flag.")


def results():
bench_names = []
for file in os.listdir("results"):
if file.startswith("."):
continue
bench_names.append(file)

results = {}
test_names = set()
for bench in bench_names:
with open(os.path.join("results", bench), "r") as f:
for line in f.read().split("\n"):
test_name, gas = line.split(" ")
test_names.add(test_name)
if not test_name in results:
results[test_name] = {}
results[test_name][bench] = gas
test_names = list(test_names)
test_names.sort()

table = [[None for _ in bench_names] for _ in test_names]
for i, test in enumerate(test_names):
for j, bench in enumerate(bench_names):
try:
table[i][j] = results[test][bench]
except KeyError:
pass
df = pd.DataFrame(table, index=test_names, columns=bench_names)
df.to_excel("results.xlsx")



def main():
parser = argparse.ArgumentParser(description="Process some commands.")

# Create a subparser object
subparsers = parser.add_subparsers(dest="command", help='sub-command help')

# Create the parser for the "bench" command
parser_bench = subparsers.add_parser('bench', help='Run a benchmark')
parser_bench.add_argument('benchmark_name', type=str, help='The name of the benchmark to run')
parser_bench.add_argument('--force', action='store_true', help='Overwrite the benchmark if it already exists')

# Create the parser for the "results" command
parser_results = subparsers.add_parser('results', help='Show results')

# Parse the arguments
args = parser.parse_args()

# Decide what to do based on the command
if args.command == 'bench':
bench(args.benchmark_name, args.force)
elif args.command == 'results':
results()
else:
parser.print_help()


if __name__ == '__main__':
main()
Empty file added benchmark/results/.gitkeep
Empty file.