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 bash test for transaction profiler; improve profiler output #9931

Merged
merged 7 commits into from
Nov 15, 2024
Merged
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
10 changes: 6 additions & 4 deletions yarn-project/cli-wallet/src/cmds/simulate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import { type LogFn } from '@aztec/foundation/log';
import { format } from 'util';

function printProfileResult(result: ProfileResult, log: LogFn) {
log(format('Simulation result:'));
log(format('Return value: ', JSON.stringify(result.returnValues, null, 2)));
log(format('\nSimulation result:'));
log(format('Return value:', JSON.stringify(result.returnValues, null, 2)));

log(format('Gate count: '));
log(format('\nGate count per circuit:'));
let acc = 0;
result.gateCounts.forEach(r => {
acc += r.gateCount;
log(format(' ', r.circuitName.padEnd(30), 'Gates:', r.gateCount, '\tAcc:', acc));
log(format(' ', r.circuitName.padEnd(50), 'Gates:', r.gateCount.toLocaleString(), '\tAcc:', acc.toLocaleString()));
});

log(format('\nTotal gates:', acc.toLocaleString()));
}

export async function simulate(
Expand Down
39 changes: 39 additions & 0 deletions yarn-project/cli-wallet/test/flows/profile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
set -e
source ../utils/setup.sh

test_title "Profile private transfer with authwit"

echo
warn //////////////////////////////////////////////////////////////////////////////
warn // Note: this test requires proving to be enabled to show meaningful output //
warn //////////////////////////////////////////////////////////////////////////////
echo

# Deploy account contracts for owner (token deployer and minter),
# operator (who use authwit to transfer token from user's account) and user
aztec-wallet create-account -a owner
aztec-wallet create-account -a user
aztec-wallet create-account -a operator

# Deploy a token contract and mint 100 tokens to the user
aztec-wallet deploy token_contract@Token --args accounts:owner Test TST 18 -f owner -a token
aztec-wallet send mint_to_private -ca token --args accounts:owner accounts:user 100 -f owner

# Create an authwit for the operator to transfer tokens from the user's account (to operator's own acc)
aztec-wallet create-secret -a auth_nonce
aztec-wallet create-authwit transfer_from operator -ca token --args accounts:user accounts:operator 100 secrets:auth_nonce -f user
aztec-wallet add-authwit authwits:last user -f operator

# Simulate and profile `transfer_from`
aztec-wallet simulate --profile transfer_from -ca token --args accounts:user accounts:operator 100 secrets:auth_nonce -f operator

# Verify gate count is present in the output
GATE_COUNT=$(aztec-wallet simulate --profile transfer_from -ca token --args accounts:user accounts:operator 100 secrets:auth_nonce -f operator | grep "Total gates:" | awk '{print $3}')
if [ -z "$GATE_COUNT" ]; then
GATE_COUNT_SET=0
else
GATE_COUNT_SET=1
fi

assert_eq $GATE_COUNT_SET 1
Loading