@aztec-labs/cli-wallet 6.0.0-nightly.20260829
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/dest/bin/index.d.ts +3 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +96 -0
- package/dest/cmds/authorize_action.d.ts +5 -0
- package/dest/cmds/authorize_action.d.ts.map +1 -0
- package/dest/cmds/authorize_action.js +23 -0
- package/dest/cmds/bridge_fee_juice.d.ts +6 -0
- package/dest/cmds/bridge_fee_juice.d.ts.map +1 -0
- package/dest/cmds/bridge_fee_juice.js +54 -0
- package/dest/cmds/check_tx.d.ts +6 -0
- package/dest/cmds/check_tx.d.ts.map +1 -0
- package/dest/cmds/check_tx.js +181 -0
- package/dest/cmds/create_account.d.ts +17 -0
- package/dest/cmds/create_account.d.ts.map +1 -0
- package/dest/cmds/create_account.js +146 -0
- package/dest/cmds/create_authwit.d.ts +5 -0
- package/dest/cmds/create_authwit.d.ts.map +1 -0
- package/dest/cmds/create_authwit.js +16 -0
- package/dest/cmds/deploy.d.ts +10 -0
- package/dest/cmds/deploy.d.ts.map +1 -0
- package/dest/cmds/deploy.js +129 -0
- package/dest/cmds/deploy_account.d.ts +8 -0
- package/dest/cmds/deploy_account.d.ts.map +1 -0
- package/dest/cmds/deploy_account.js +111 -0
- package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
- package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
- package/dest/cmds/get_fee_juice_balance.js +27 -0
- package/dest/cmds/import_test_accounts.d.ts +5 -0
- package/dest/cmds/import_test_accounts.d.ts.map +1 -0
- package/dest/cmds/import_test_accounts.js +40 -0
- package/dest/cmds/index.d.ts +6 -0
- package/dest/cmds/index.d.ts.map +1 -0
- package/dest/cmds/index.js +208 -0
- package/dest/cmds/profile.d.ts +8 -0
- package/dest/cmds/profile.d.ts.map +1 -0
- package/dest/cmds/profile.js +28 -0
- package/dest/cmds/register_contract.d.ts +8 -0
- package/dest/cmds/register_contract.d.ts.map +1 -0
- package/dest/cmds/register_contract.js +27 -0
- package/dest/cmds/register_sender.d.ts +5 -0
- package/dest/cmds/register_sender.d.ts.map +1 -0
- package/dest/cmds/register_sender.js +4 -0
- package/dest/cmds/send.d.ts +11 -0
- package/dest/cmds/send.d.ts.map +1 -0
- package/dest/cmds/send.js +73 -0
- package/dest/cmds/simulate.d.ts +8 -0
- package/dest/cmds/simulate.d.ts.map +1 -0
- package/dest/cmds/simulate.js +33 -0
- package/dest/storage/wallet_db.d.ts +61 -0
- package/dest/storage/wallet_db.d.ts.map +1 -0
- package/dest/storage/wallet_db.js +231 -0
- package/dest/utils/authorizations.d.ts +6 -0
- package/dest/utils/authorizations.d.ts.map +1 -0
- package/dest/utils/authorizations.js +28 -0
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
- package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
- package/dest/utils/constants.d.ts +4 -0
- package/dest/utils/constants.d.ts.map +1 -0
- package/dest/utils/constants.js +8 -0
- package/dest/utils/ecdsa.d.ts +2 -0
- package/dest/utils/ecdsa.d.ts.map +1 -0
- package/dest/utils/ecdsa.js +13 -0
- package/dest/utils/options/fees.d.ts +36 -0
- package/dest/utils/options/fees.d.ts.map +1 -0
- package/dest/utils/options/fees.js +250 -0
- package/dest/utils/options/index.d.ts +3 -0
- package/dest/utils/options/index.d.ts.map +1 -0
- package/dest/utils/options/index.js +2 -0
- package/dest/utils/options/options.d.ts +24 -0
- package/dest/utils/options/options.d.ts.map +1 -0
- package/dest/utils/options/options.js +134 -0
- package/dest/utils/profiling.d.ts +5 -0
- package/dest/utils/profiling.d.ts.map +1 -0
- package/dest/utils/profiling.js +68 -0
- package/dest/utils/wallet.d.ts +64 -0
- package/dest/utils/wallet.d.ts.map +1 -0
- package/dest/utils/wallet.js +285 -0
- package/dest/utils/well_known_contracts.d.ts +8 -0
- package/dest/utils/well_known_contracts.d.ts.map +1 -0
- package/dest/utils/well_known_contracts.js +38 -0
- package/package.json +108 -0
- package/src/bin/index.ts +141 -0
- package/src/cmds/authorize_action.ts +47 -0
- package/src/cmds/bridge_fee_juice.ts +92 -0
- package/src/cmds/check_tx.ts +220 -0
- package/src/cmds/create_account.ts +176 -0
- package/src/cmds/create_authwit.ts +39 -0
- package/src/cmds/deploy.ts +157 -0
- package/src/cmds/deploy_account.ts +140 -0
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/import_test_accounts.ts +54 -0
- package/src/cmds/index.ts +732 -0
- package/src/cmds/profile.ts +47 -0
- package/src/cmds/register_contract.ts +43 -0
- package/src/cmds/register_sender.ts +8 -0
- package/src/cmds/send.ts +96 -0
- package/src/cmds/simulate.ts +55 -0
- package/src/storage/wallet_db.ts +264 -0
- package/src/utils/authorizations.ts +50 -0
- package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
- package/src/utils/constants.ts +10 -0
- package/src/utils/ecdsa.ts +15 -0
- package/src/utils/options/fees.ts +325 -0
- package/src/utils/options/index.ts +2 -0
- package/src/utils/options/options.ts +196 -0
- package/src/utils/profiling.ts +171 -0
- package/src/utils/wallet.ts +377 -0
- package/src/utils/well_known_contracts.ts +46 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare function extractECDSAPublicKeyFromBase64String(base64PublicKey: string): Buffer;
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWNkc2EuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9lY2RzYS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSx3QkFBZ0IscUNBQXFDLENBQUMsZUFBZSxFQUFFLE1BQU0sR0FBRyxNQUFNLENBY3JGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../src/utils/ecdsa.ts"],"names":[],"mappings":"AAAA,wBAAgB,qCAAqC,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAcrF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function extractECDSAPublicKeyFromBase64String(base64PublicKey) {
|
|
2
|
+
const buffer = Buffer.from(base64PublicKey, 'base64');
|
|
3
|
+
let keyOffset = 0;
|
|
4
|
+
const typeLen = buffer.readUInt32BE(keyOffset);
|
|
5
|
+
keyOffset += 4;
|
|
6
|
+
keyOffset += typeLen;
|
|
7
|
+
const curveLen = buffer.readUInt32BE(keyOffset);
|
|
8
|
+
keyOffset += 4;
|
|
9
|
+
keyOffset += curveLen;
|
|
10
|
+
const keyLen = buffer.readUInt32BE(keyOffset);
|
|
11
|
+
keyOffset += 5; // 4+1 to remove the prefix
|
|
12
|
+
return buffer.subarray(keyOffset, keyOffset + keyLen - 1);
|
|
13
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FeePaymentMethod } from '@aztec-labs/aztec.js/fee';
|
|
2
|
+
import type { AztecNode } from '@aztec-labs/aztec.js/node';
|
|
3
|
+
import type { Wallet } from '@aztec-labs/aztec.js/wallet';
|
|
4
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
5
|
+
import type { FieldsOf } from '@aztec-labs/foundation/types';
|
|
6
|
+
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
7
|
+
import { GasFees, GasSettings } from '@aztec-labs/stdlib/gas';
|
|
8
|
+
import type { FeeOptions } from '@aztec-labs/wallet-sdk/base-wallet';
|
|
9
|
+
import { Option } from 'commander';
|
|
10
|
+
import type { WalletDB } from '../../storage/wallet_db.js';
|
|
11
|
+
export type RawCliFeeArgs = {
|
|
12
|
+
estimateGasOnly: boolean;
|
|
13
|
+
gasLimits?: string;
|
|
14
|
+
payment?: string;
|
|
15
|
+
maxFeesPerGas?: string;
|
|
16
|
+
maxPriorityFeesPerGas?: string;
|
|
17
|
+
};
|
|
18
|
+
export type ParsedFeeOptions = {
|
|
19
|
+
paymentMethod?: FeePaymentMethod;
|
|
20
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
21
|
+
};
|
|
22
|
+
export declare function getPaymentMethodOption(): Option;
|
|
23
|
+
export declare function parsePaymentMethod(payment: string, log: LogFn, db?: WalletDB, estimateOnly?: boolean): (wallet: Wallet, from: AztecAddress, gasSettings: GasSettings) => Promise<FeePaymentMethod | undefined>;
|
|
24
|
+
export declare function parseGasFees(gasFees: string): GasFees;
|
|
25
|
+
export declare class CLIFeeArgs {
|
|
26
|
+
estimateOnly: boolean;
|
|
27
|
+
private paymentMethod;
|
|
28
|
+
private gasSettings;
|
|
29
|
+
constructor(estimateOnly: boolean, paymentMethod: (wallet: Wallet, feePayer: AztecAddress, gasSettings: GasSettings) => Promise<FeePaymentMethod | undefined>, gasSettings: Partial<FieldsOf<GasSettings>>);
|
|
30
|
+
toUserFeeOptions(node: AztecNode, wallet: Wallet, from: AztecAddress): Promise<ParsedFeeOptions>;
|
|
31
|
+
private getMinFees;
|
|
32
|
+
static parse(args: RawCliFeeArgs, log: LogFn, db?: WalletDB): CLIFeeArgs;
|
|
33
|
+
static getOptions(): Option[];
|
|
34
|
+
}
|
|
35
|
+
export declare function printGasEstimates(feeOpts: FeeOptions, gasEstimates: Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>, log: LogFn): void;
|
|
36
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3V0aWxzL29wdGlvbnMvZmVlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQ2pFLE9BQU8sS0FB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
|
|
2
|
+
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
3
|
+
import { Gas, GasFees, GasSettings, ManaUsageEstimate } from '@aztec-labs/stdlib/gas';
|
|
4
|
+
import { Option } from 'commander';
|
|
5
|
+
import { MIN_FEE_PADDING } from '../constants.js';
|
|
6
|
+
import { aliasedAddressParser } from './options.js';
|
|
7
|
+
function printOptionParams(params) {
|
|
8
|
+
const paramsWithDescription = Object.keys(params).filter((name)=>params[name].description);
|
|
9
|
+
const maxParamWidth = paramsWithDescription.reduce((v, name)=>Math.max(v, name.length), 0);
|
|
10
|
+
const indent = (size)=>''.padEnd(size, ' ');
|
|
11
|
+
const descriptionList = paramsWithDescription.map((name)=>[
|
|
12
|
+
`${indent(5)}${name}${indent(maxParamWidth - name.length)} ${params[name].description}`,
|
|
13
|
+
params[name].default ? `Default: ${params[name].default}` : ''
|
|
14
|
+
].join(' '));
|
|
15
|
+
return descriptionList.length ? `\n Parameters:\n${descriptionList.join('\n')}\nFormat: --payment ${Object.keys(params).slice(0, 3).map((name)=>`${name}=${params[name].type}`)} ${Object.keys(params).length > 3 ? '...' : ''}` : '';
|
|
16
|
+
}
|
|
17
|
+
function getFeePaymentMethodParams() {
|
|
18
|
+
return {
|
|
19
|
+
method: {
|
|
20
|
+
type: 'name',
|
|
21
|
+
description: 'Valid values: "fee_juice", "fpc-public", "fpc-private", "fpc-sponsored"',
|
|
22
|
+
default: 'fee_juice'
|
|
23
|
+
},
|
|
24
|
+
asset: {
|
|
25
|
+
type: 'address',
|
|
26
|
+
description: 'The asset used for fee payment. Required for "fpc-public" and "fpc-private".'
|
|
27
|
+
},
|
|
28
|
+
fpc: {
|
|
29
|
+
type: 'address',
|
|
30
|
+
description: 'The FPC contract that pays in fee juice. Not required for the "fee_juice" method.'
|
|
31
|
+
},
|
|
32
|
+
claim: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
description: 'Whether to use a previously stored claim to bridge fee juice.'
|
|
35
|
+
},
|
|
36
|
+
claimSecret: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: 'The secret to claim fee juice on L1.'
|
|
39
|
+
},
|
|
40
|
+
claimAmount: {
|
|
41
|
+
type: 'bigint',
|
|
42
|
+
description: 'The amount of fee juice to be claimed.'
|
|
43
|
+
},
|
|
44
|
+
messageLeafIndex: {
|
|
45
|
+
type: 'bigint',
|
|
46
|
+
description: 'The index of the claim in the l1toL2Message tree.'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function getPaymentMethodOption() {
|
|
51
|
+
const params = getFeePaymentMethodParams();
|
|
52
|
+
return new Option(`--payment <options>`, `Fee payment method and arguments.${printOptionParams(params)}`);
|
|
53
|
+
}
|
|
54
|
+
function getFeeOptions() {
|
|
55
|
+
return [
|
|
56
|
+
getPaymentMethodOption(),
|
|
57
|
+
new Option('--gas-limits <da=100,l2=100,teardownDA=10,teardownL2=10>', 'Gas limits for the tx.'),
|
|
58
|
+
new Option('--max-fees-per-gas <da=100,l2=100>', 'Maximum fees per gas unit for DA and L2 computation.'),
|
|
59
|
+
new Option('--max-priority-fees-per-gas <da=0,l2=0>', 'Maximum priority fees per gas unit for DA and L2 computation.'),
|
|
60
|
+
new Option('--estimate-gas-only', 'Only report gas estimation for the tx, do not send it.')
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
function parseGasSettings(args) {
|
|
64
|
+
const gasLimits = args.gasLimits ? parseGasLimits(args.gasLimits) : {};
|
|
65
|
+
const maxFeesPerGas = args.maxFeesPerGas ? parseGasFees(args.maxFeesPerGas) : undefined;
|
|
66
|
+
const maxPriorityFeesPerGas = args.maxPriorityFeesPerGas ? parseGasFees(args.maxPriorityFeesPerGas) : undefined;
|
|
67
|
+
return {
|
|
68
|
+
...gasLimits,
|
|
69
|
+
maxFeesPerGas,
|
|
70
|
+
maxPriorityFeesPerGas
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export function parsePaymentMethod(payment, log, db, estimateOnly) {
|
|
74
|
+
const parsed = payment.split(',').reduce((acc, item)=>{
|
|
75
|
+
const [dimension, value] = item.split('=');
|
|
76
|
+
acc[dimension] = value ?? 1;
|
|
77
|
+
return acc;
|
|
78
|
+
}, {});
|
|
79
|
+
const getFpc = ()=>{
|
|
80
|
+
if (!parsed.fpc) {
|
|
81
|
+
throw new Error('Missing "fpc" in payment option');
|
|
82
|
+
}
|
|
83
|
+
return aliasedAddressParser('contracts', parsed.fpc, db);
|
|
84
|
+
};
|
|
85
|
+
const getAsset = ()=>{
|
|
86
|
+
if (!parsed.asset) {
|
|
87
|
+
throw new Error('Missing "asset" in payment option');
|
|
88
|
+
}
|
|
89
|
+
return AztecAddress.fromStringUnsafe(parsed.asset);
|
|
90
|
+
};
|
|
91
|
+
return async (wallet, from, gasSettings)=>{
|
|
92
|
+
switch(parsed.method){
|
|
93
|
+
case 'fee_juice':
|
|
94
|
+
{
|
|
95
|
+
if (parsed.claim || parsed.claimSecret && parsed.claimAmount && parsed.messageLeafIndex) {
|
|
96
|
+
let claimAmount, claimSecret, messageLeafIndex;
|
|
97
|
+
if (parsed.claim && db) {
|
|
98
|
+
({ amount: claimAmount, secret: claimSecret, leafIndex: messageLeafIndex } = estimateOnly ? await db.peekBridgedFeeJuice(from, log) : await db.popBridgedFeeJuice(from, log));
|
|
99
|
+
} else {
|
|
100
|
+
({ claimAmount, claimSecret, messageLeafIndex } = parsed);
|
|
101
|
+
}
|
|
102
|
+
log(`Using Fee Juice for fee payments with claim for ${claimAmount} tokens`);
|
|
103
|
+
const { FeeJuicePaymentMethodWithClaim } = await import('@aztec-labs/aztec.js/fee');
|
|
104
|
+
return new FeeJuicePaymentMethodWithClaim(from, {
|
|
105
|
+
claimAmount: (typeof claimAmount === 'string' ? Fr.fromString(claimAmount) : new Fr(claimAmount)).toBigInt(),
|
|
106
|
+
claimSecret: typeof claimSecret === 'string' ? Fr.fromString(claimSecret) : claimSecret,
|
|
107
|
+
messageLeafIndex: BigInt(messageLeafIndex)
|
|
108
|
+
});
|
|
109
|
+
} else {
|
|
110
|
+
log(`Using Fee Juice for fee payment with the balance of account ${from}`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
case 'fpc-public':
|
|
115
|
+
{
|
|
116
|
+
const fpc = getFpc();
|
|
117
|
+
const asset = getAsset();
|
|
118
|
+
log(`WARNING: fpc-public is deprecated and will not work on mainnet alpha. Use fee_juice or fpc-sponsored instead.`);
|
|
119
|
+
log(`Using public fee payment with asset ${asset} via paymaster ${fpc}`);
|
|
120
|
+
const { PublicFeePaymentMethod } = await import('@aztec-labs/aztec.js/fee');
|
|
121
|
+
return new PublicFeePaymentMethod(fpc, from, wallet, gasSettings);
|
|
122
|
+
}
|
|
123
|
+
case 'fpc-private':
|
|
124
|
+
{
|
|
125
|
+
const fpc = getFpc();
|
|
126
|
+
const asset = getAsset();
|
|
127
|
+
log(`WARNING: fpc-private is deprecated and will not work on mainnet alpha. Use fee_juice or fpc-sponsored instead.`);
|
|
128
|
+
log(`Using private fee payment with asset ${asset} via paymaster ${fpc}`);
|
|
129
|
+
const { PrivateFeePaymentMethod } = await import('@aztec-labs/aztec.js/fee');
|
|
130
|
+
return new PrivateFeePaymentMethod(fpc, from, wallet, gasSettings);
|
|
131
|
+
}
|
|
132
|
+
case 'fpc-sponsored':
|
|
133
|
+
{
|
|
134
|
+
const sponsor = getFpc();
|
|
135
|
+
log(`Using sponsored fee payment with sponsor ${sponsor}`);
|
|
136
|
+
const { SponsoredFeePaymentMethod } = await import('@aztec-labs/aztec.js/fee/testing');
|
|
137
|
+
return new SponsoredFeePaymentMethod(sponsor);
|
|
138
|
+
}
|
|
139
|
+
case undefined:
|
|
140
|
+
throw new Error('Missing "method" in payment option');
|
|
141
|
+
default:
|
|
142
|
+
throw new Error(`Invalid fee payment method: ${payment}`);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function parseGasLimits(gasLimits) {
|
|
147
|
+
const parsed = gasLimits.split(',').reduce((acc, limit)=>{
|
|
148
|
+
const [dimension, value] = limit.split('=');
|
|
149
|
+
acc[dimension] = parseInt(value, 10);
|
|
150
|
+
return acc;
|
|
151
|
+
}, {});
|
|
152
|
+
const expected = [
|
|
153
|
+
'da',
|
|
154
|
+
'l2',
|
|
155
|
+
'teardownDA',
|
|
156
|
+
'teardownL2'
|
|
157
|
+
];
|
|
158
|
+
for (const dimension of expected){
|
|
159
|
+
if (!(dimension in parsed)) {
|
|
160
|
+
throw new Error(`Missing gas limit for ${dimension}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
gasLimits: new Gas(parsed.da, parsed.l2),
|
|
165
|
+
teardownGasLimits: new Gas(parsed.teardownDA, parsed.teardownL2)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
export function parseGasFees(gasFees) {
|
|
169
|
+
const parsed = gasFees.split(',').reduce((acc, fee)=>{
|
|
170
|
+
const [dimension, value] = fee.split('=');
|
|
171
|
+
acc[dimension] = parseInt(value, 10);
|
|
172
|
+
return acc;
|
|
173
|
+
}, {});
|
|
174
|
+
const expected = [
|
|
175
|
+
'da',
|
|
176
|
+
'l2'
|
|
177
|
+
];
|
|
178
|
+
for (const dimension of expected){
|
|
179
|
+
if (!(dimension in parsed)) {
|
|
180
|
+
throw new Error(`Missing gas fee for ${dimension}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return new GasFees(parsed.da, parsed.l2);
|
|
184
|
+
}
|
|
185
|
+
export class CLIFeeArgs {
|
|
186
|
+
estimateOnly;
|
|
187
|
+
paymentMethod;
|
|
188
|
+
gasSettings;
|
|
189
|
+
constructor(estimateOnly, paymentMethod, gasSettings){
|
|
190
|
+
this.estimateOnly = estimateOnly;
|
|
191
|
+
this.paymentMethod = paymentMethod;
|
|
192
|
+
this.gasSettings = gasSettings;
|
|
193
|
+
}
|
|
194
|
+
async toUserFeeOptions(node, wallet, from) {
|
|
195
|
+
const minFees = await this.getMinFees(node);
|
|
196
|
+
const maxFeesPerGas = minFees.mul(1 + MIN_FEE_PADDING);
|
|
197
|
+
const { txsLimits } = await node.getNodeInfo();
|
|
198
|
+
const gasLimits = this.gasSettings.gasLimits ?? Gas.from(txsLimits.gas);
|
|
199
|
+
const gasSettings = GasSettings.fallback({
|
|
200
|
+
...this.gasSettings,
|
|
201
|
+
gasLimits,
|
|
202
|
+
maxFeesPerGas
|
|
203
|
+
});
|
|
204
|
+
const paymentMethod = await this.paymentMethod(wallet, from, gasSettings);
|
|
205
|
+
return {
|
|
206
|
+
paymentMethod,
|
|
207
|
+
gasSettings
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Returns the worst-case min fee across predicted future slots.
|
|
212
|
+
* Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
|
|
213
|
+
*/ async getMinFees(node) {
|
|
214
|
+
try {
|
|
215
|
+
const predicted = await node.getPredictedMinFees(ManaUsageEstimate.Limit);
|
|
216
|
+
if (predicted.length === 0) {
|
|
217
|
+
return node.getCurrentMinFees();
|
|
218
|
+
}
|
|
219
|
+
return predicted.reduce((worst, fees)=>fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst);
|
|
220
|
+
} catch (err) {
|
|
221
|
+
// Fallback for old nodes that don't support getPredictedMinFees.
|
|
222
|
+
// Only fall back on method-not-found errors (JSON-RPC code -32601); rethrow others.
|
|
223
|
+
if (err?.cause?.code === -32601 || err?.message?.includes('Method not found')) {
|
|
224
|
+
return node.getCurrentMinFees();
|
|
225
|
+
}
|
|
226
|
+
throw err;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
static parse(args, log, db) {
|
|
230
|
+
const estimateOnly = !!args.estimateGasOnly;
|
|
231
|
+
return new CLIFeeArgs(estimateOnly, parsePaymentMethod(args.payment ?? 'method=fee_juice', log, db, estimateOnly), parseGasSettings(args));
|
|
232
|
+
}
|
|
233
|
+
static getOptions() {
|
|
234
|
+
return getFeeOptions();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// Printing
|
|
238
|
+
export function printGasEstimates(feeOpts, gasEstimates, log) {
|
|
239
|
+
log(`Estimated gas usage: ${formatGasEstimate(gasEstimates)}`);
|
|
240
|
+
log(`Maximum total tx fee: ${getEstimatedCost(gasEstimates, feeOpts.gasSettings.maxFeesPerGas)}`);
|
|
241
|
+
}
|
|
242
|
+
function formatGasEstimate(estimate) {
|
|
243
|
+
return `da=${estimate.gasLimits.daGas},l2=${estimate.gasLimits.l2Gas},teardownDA=${estimate.teardownGasLimits.daGas},teardownL2=${estimate.teardownGasLimits.l2Gas}`;
|
|
244
|
+
}
|
|
245
|
+
function getEstimatedCost(estimate, maxFeesPerGas) {
|
|
246
|
+
return GasSettings.fallback({
|
|
247
|
+
...estimate,
|
|
248
|
+
maxFeesPerGas
|
|
249
|
+
}).getFeeLimit().toBigInt();
|
|
250
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export * from './fees.js';
|
|
2
|
+
export * from './options.js';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy91dGlscy9vcHRpb25zL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsY0FBYyxDQUFDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/options/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TxHash } from '@aztec-labs/aztec.js/tx';
|
|
2
|
+
import { AuthWitness } from '@aztec-labs/stdlib/auth-witness';
|
|
3
|
+
import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
4
|
+
import { Option } from 'commander';
|
|
5
|
+
import type { AliasType, WalletDB } from '../../storage/wallet_db.js';
|
|
6
|
+
export declare const ARTIFACT_DESCRIPTION = "Path to a compiled Aztec contract's artifact in JSON format. If executed inside a nargo workspace, a package and contract name can be specified as package@contract";
|
|
7
|
+
export declare function integerArgParser(value: string, argName: string, min?: number, max?: number): number;
|
|
8
|
+
export declare function aliasedTxHashParser(txHash: string, db?: WalletDB): TxHash;
|
|
9
|
+
export declare function aliasedAuthWitParser(witnesses: string, db?: WalletDB): AuthWitness[];
|
|
10
|
+
export declare function aliasedAddressParser(defaultPrefix: AliasType, address: string, db?: WalletDB): AztecAddress;
|
|
11
|
+
export declare function aliasedSigningKeyParser(sk: string, db?: WalletDB): import("@aztec-labs/foundation/schemas").Fq;
|
|
12
|
+
export declare function createAliasOption(description: string, hide: boolean): Option;
|
|
13
|
+
export declare function createAccountOption(description: string, hide: boolean, db?: WalletDB): Option;
|
|
14
|
+
export declare function createAuthwitnessOption(description: string, hide: boolean, db?: WalletDB): Option;
|
|
15
|
+
export declare function createTypeOption(mandatory: boolean): Option;
|
|
16
|
+
export declare function createArgsOption(isConstructor: boolean, db?: WalletDB): Option;
|
|
17
|
+
export declare function createContractAddressOption(db?: WalletDB): Option;
|
|
18
|
+
export declare function createDebugExecutionStepsDirOption(): Option;
|
|
19
|
+
export declare function createVerboseOption(): Option;
|
|
20
|
+
export declare function artifactPathParser(filePath: string, db?: WalletDB): Promise<string>;
|
|
21
|
+
export declare function artifactPathFromPromiseOrAlias(artifactPathPromise: Promise<string>, contractAddress: AztecAddress, db?: WalletDB): Promise<string>;
|
|
22
|
+
export declare function createArtifactOption(db?: WalletDB): Option;
|
|
23
|
+
export declare function cleanupAuthWitnesses(authWitnesses: AuthWitness[] | undefined): AuthWitness[];
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW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AAO,UAMlD;AAED,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,QAAQ,UAQrE;AAED,wBAAgB,2BAA2B,CAAC,EAAE,CAAC,EAAE,QAAQ,UAIxD;AAED,wBAAgB,kCAAkC,WAKjD;AAED,wBAAgB,mBAAmB,WAKlC;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,mBAajE;AAED,wBAAsB,8BAA8B,CAClD,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,EACpC,eAAe,EAAE,YAAY,EAC7B,EAAE,CAAC,EAAE,QAAQ,mBAWd;AAED,wBAAgB,oBAAoB,CAAC,EAAE,CAAC,EAAE,QAAQ,UAIjD;AA6BD,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,WAAW,EAAE,GAAG,SAAS,GAAG,WAAW,EAAE,CAE5F"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { parseAztecAddress, parseSigningKey, parseTxHash } from '@aztec-labs/cli/utils';
|
|
2
|
+
import { AuthWitness } from '@aztec-labs/stdlib/auth-witness';
|
|
3
|
+
import { Option } from 'commander';
|
|
4
|
+
import { readdir, stat } from 'fs/promises';
|
|
5
|
+
import { AccountTypes } from '../constants.js';
|
|
6
|
+
const TARGET_DIR = 'target';
|
|
7
|
+
export const ARTIFACT_DESCRIPTION = "Path to a compiled Aztec contract's artifact in JSON format. If executed inside a nargo workspace, a package and contract name can be specified as package@contract";
|
|
8
|
+
export function integerArgParser(value, argName, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
|
|
9
|
+
const parsed = parseInt(value, 10);
|
|
10
|
+
if (parsed < min) {
|
|
11
|
+
throw new Error(`${argName} must be greater than ${min}`);
|
|
12
|
+
}
|
|
13
|
+
if (parsed > max) {
|
|
14
|
+
throw new Error(`${argName} must be less than ${max}`);
|
|
15
|
+
}
|
|
16
|
+
return parsed;
|
|
17
|
+
}
|
|
18
|
+
export function aliasedTxHashParser(txHash, db) {
|
|
19
|
+
try {
|
|
20
|
+
return parseTxHash(txHash);
|
|
21
|
+
} catch {
|
|
22
|
+
const prefixed = txHash.includes(':') ? txHash : `transactions:${txHash}`;
|
|
23
|
+
const rawTxHash = db ? db.tryRetrieveAlias(prefixed) : txHash;
|
|
24
|
+
return parseTxHash(rawTxHash);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function aliasedAuthWitParser(witnesses, db) {
|
|
28
|
+
const parsedWitnesses = witnesses.split(',').map((witness)=>{
|
|
29
|
+
try {
|
|
30
|
+
return AuthWitness.fromString(witness);
|
|
31
|
+
} catch {
|
|
32
|
+
const prefixed = witness.includes(':') ? witness : `authwits:${witness}`;
|
|
33
|
+
const rawAuthWitness = db ? db.tryRetrieveAlias(prefixed) : witness;
|
|
34
|
+
return AuthWitness.fromString(rawAuthWitness);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return parsedWitnesses;
|
|
38
|
+
}
|
|
39
|
+
export function aliasedAddressParser(defaultPrefix, address, db) {
|
|
40
|
+
if (address.startsWith('0x')) {
|
|
41
|
+
return parseAztecAddress(address);
|
|
42
|
+
} else {
|
|
43
|
+
const prefixed = address.includes(':') ? address : `${defaultPrefix}:${address}`;
|
|
44
|
+
const rawAddress = db ? db.tryRetrieveAlias(prefixed) : address;
|
|
45
|
+
return parseAztecAddress(rawAddress);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function aliasedSigningKeyParser(sk, db) {
|
|
49
|
+
if (sk.startsWith('0x')) {
|
|
50
|
+
return parseSigningKey(sk);
|
|
51
|
+
} else {
|
|
52
|
+
const prefixed = `${sk.startsWith('accounts') ? '' : 'accounts'}:${sk.endsWith(':signing') ? sk : `${sk}:signing`}`;
|
|
53
|
+
const rawSk = db ? db.tryRetrieveAlias(prefixed) : sk;
|
|
54
|
+
return parseSigningKey(rawSk);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export function createAliasOption(description, hide) {
|
|
58
|
+
return new Option(`-a, --alias <string>`, description).hideHelp(hide);
|
|
59
|
+
}
|
|
60
|
+
export function createAccountOption(description, hide, db) {
|
|
61
|
+
return new Option(`-f, --from <string>`, description).hideHelp(hide).argParser((address)=>aliasedAddressParser('accounts', address, db));
|
|
62
|
+
}
|
|
63
|
+
export function createAuthwitnessOption(description, hide, db) {
|
|
64
|
+
return new Option('-aw, --auth-witness <string,...>', description).hideHelp(hide).argParser((witness)=>aliasedAuthWitParser(witness, db));
|
|
65
|
+
}
|
|
66
|
+
export function createTypeOption(mandatory) {
|
|
67
|
+
return new Option('-t, --type <string>', 'Type of account to create').choices(AccountTypes).default('schnorr').conflicts('account-or-address').makeOptionMandatory(mandatory);
|
|
68
|
+
}
|
|
69
|
+
export function createArgsOption(isConstructor, db) {
|
|
70
|
+
return new Option('--args [args...]', `${isConstructor ? 'Constructor' : 'Function'} arguments`).argParser((arg, prev)=>{
|
|
71
|
+
const next = db?.tryRetrieveAlias(arg) || arg;
|
|
72
|
+
prev.push(next);
|
|
73
|
+
return prev;
|
|
74
|
+
}).default([]);
|
|
75
|
+
}
|
|
76
|
+
export function createContractAddressOption(db) {
|
|
77
|
+
return new Option('-ca, --contract-address <address>', 'Aztec address of the contract.').argParser((address)=>aliasedAddressParser('contracts', address, db)).makeOptionMandatory(true);
|
|
78
|
+
}
|
|
79
|
+
export function createDebugExecutionStepsDirOption() {
|
|
80
|
+
return new Option('--debug-execution-steps-dir <address>', 'Directory to write execution step artifacts for bb profiling/debugging.').makeOptionMandatory(false);
|
|
81
|
+
}
|
|
82
|
+
export function createVerboseOption() {
|
|
83
|
+
return new Option('-v, --verbose', 'Provide timings on all executed operations (synching, simulating, proving)').default(false);
|
|
84
|
+
}
|
|
85
|
+
export function artifactPathParser(filePath, db) {
|
|
86
|
+
if (filePath.includes('@')) {
|
|
87
|
+
const [pkg, contractName] = filePath.split('@');
|
|
88
|
+
return contractArtifactFromWorkspace(pkg, contractName);
|
|
89
|
+
} else if (!new RegExp(/^(\.|\/|[A-Z]:).*\.json$/).test(filePath)) {
|
|
90
|
+
filePath = db ? db.tryRetrieveAlias(`artifacts:${filePath}`) : filePath;
|
|
91
|
+
}
|
|
92
|
+
if (!filePath) {
|
|
93
|
+
throw new Error('This command has to be called from a nargo workspace or contract artifact path should be provided');
|
|
94
|
+
}
|
|
95
|
+
return Promise.resolve(filePath);
|
|
96
|
+
}
|
|
97
|
+
export async function artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db) {
|
|
98
|
+
let artifactPath = await artifactPathPromise;
|
|
99
|
+
if (db && !artifactPath) {
|
|
100
|
+
artifactPath = db.tryRetrieveAlias(`artifacts:${contractAddress.toString()}`);
|
|
101
|
+
if (!artifactPath) {
|
|
102
|
+
throw new Error(`No artifact found for contract address ${contractAddress}, please provide it via the -c option`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return artifactPath;
|
|
106
|
+
}
|
|
107
|
+
export function createArtifactOption(db) {
|
|
108
|
+
return new Option('-c, --contract-artifact <fileLocation>', ARTIFACT_DESCRIPTION).argParser((filePath)=>artifactPathParser(filePath, db)).makeOptionMandatory(false);
|
|
109
|
+
}
|
|
110
|
+
async function contractArtifactFromWorkspace(pkg, contractName) {
|
|
111
|
+
const cwd = process.cwd();
|
|
112
|
+
try {
|
|
113
|
+
await stat(`${cwd}/Nargo.toml`);
|
|
114
|
+
} catch {
|
|
115
|
+
throw new Error('Invalid contract artifact argument provided. To use this option, command should be called from a nargo workspace');
|
|
116
|
+
}
|
|
117
|
+
const filesInTarget = await readdir(`${cwd}/${TARGET_DIR}`);
|
|
118
|
+
const bestMatch = filesInTarget.filter((file)=>{
|
|
119
|
+
if (pkg && contractName) {
|
|
120
|
+
return file === `${pkg}-${contractName}.json`;
|
|
121
|
+
} else {
|
|
122
|
+
return file.endsWith('.json') && (file.includes(pkg || '') || file.includes(contractName || ''));
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
if (bestMatch.length === 0) {
|
|
126
|
+
throw new Error('No contract artifacts found in target directory with the specified criteria');
|
|
127
|
+
} else if (bestMatch.length > 1) {
|
|
128
|
+
throw new Error(`Multiple contract artifacts found in target directory with the specified criteria ${bestMatch.join(', ')}`);
|
|
129
|
+
}
|
|
130
|
+
return `${cwd}/${TARGET_DIR}/${bestMatch[0]}`;
|
|
131
|
+
}
|
|
132
|
+
export function cleanupAuthWitnesses(authWitnesses) {
|
|
133
|
+
return authWitnesses?.filter((w)=>w !== undefined) ?? [];
|
|
134
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
2
|
+
import type { PrivateExecutionStep } from '@aztec-labs/stdlib/kernel';
|
|
3
|
+
import type { ProvingStats, SimulationStats } from '@aztec-labs/stdlib/tx';
|
|
4
|
+
export declare function printProfileResult(stats: ProvingStats | SimulationStats, log: LogFn, printOracles?: boolean, executionSteps?: PrivateExecutionStep[]): void;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsaW5nLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvcHJvZmlsaW5nLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBQ3hELE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDdEUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFrQixlQUFlLEVBQXFCLE1BQU0sdUJBQXVCLENBQUM7QUFTOUcsd0JBQWdCLGtCQUFrQixDQUNoQyxLQUFLLEVBQUUsWUFBWSxHQUFHLGVBQWUsRUFDckMsR0FBRyxFQUFFLEtBQUssRUFDVixZQUFZLEdBQUUsT0FBZSxFQUM3QixjQUFjLENBQUMsRUFBRSxvQkFBb0IsRUFBRSxRQTJKeEMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiling.d.ts","sourceRoot":"","sources":["../../src/utils/profiling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAkB,eAAe,EAAqB,MAAM,uBAAuB,CAAC;AAS9G,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAAG,eAAe,EACrC,GAAG,EAAE,KAAK,EACV,YAAY,GAAE,OAAe,EAC7B,cAAc,CAAC,EAAE,oBAAoB,EAAE,QA2JxC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { format } from 'util';
|
|
2
|
+
const FN_NAME_PADDING = 60;
|
|
3
|
+
const COLUMN_MIN_WIDTH = 13;
|
|
4
|
+
const COLUMN_MAX_WIDTH = 15;
|
|
5
|
+
const ORACLE_NAME_PADDING = 50;
|
|
6
|
+
export function printProfileResult(stats, log, printOracles = false, executionSteps) {
|
|
7
|
+
log(format('\nPer circuit breakdown:\n'));
|
|
8
|
+
log(format(' ', 'Function name'.padEnd(FN_NAME_PADDING), 'Time'.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), executionSteps ? 'Gates'.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH) : '', executionSteps ? 'Subtotal'.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH) : ''));
|
|
9
|
+
log(format(''.padEnd(FN_NAME_PADDING + COLUMN_MAX_WIDTH + COLUMN_MAX_WIDTH + (executionSteps ? COLUMN_MAX_WIDTH + COLUMN_MAX_WIDTH : 0), '-')));
|
|
10
|
+
let acc = 0;
|
|
11
|
+
let biggest = executionSteps?.[0];
|
|
12
|
+
const timings = stats.timings;
|
|
13
|
+
timings.perFunction.forEach((fn, i)=>{
|
|
14
|
+
const currentExecutionStep = executionSteps?.[i];
|
|
15
|
+
if (currentExecutionStep && biggest && currentExecutionStep.gateCount > biggest.gateCount) {
|
|
16
|
+
biggest = currentExecutionStep;
|
|
17
|
+
}
|
|
18
|
+
acc += currentExecutionStep ? currentExecutionStep.gateCount : 0;
|
|
19
|
+
log(format(' - ', fn.functionName.padEnd(FN_NAME_PADDING), `${fn.time.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), currentExecutionStep ? currentExecutionStep.gateCount.toLocaleString().padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH) : '', currentExecutionStep ? acc.toLocaleString().padStart(COLUMN_MAX_WIDTH) : ''));
|
|
20
|
+
if (printOracles && fn.oracles) {
|
|
21
|
+
log('');
|
|
22
|
+
for (const [oracleName, { times }] of Object.entries(fn.oracles)){
|
|
23
|
+
const calls = times.length;
|
|
24
|
+
const min = Math.min(...times);
|
|
25
|
+
const max = Math.max(...times);
|
|
26
|
+
const total = times.reduce((acc, time)=>acc + time, 0);
|
|
27
|
+
const avg = total / calls;
|
|
28
|
+
log(format(' ', oracleName.padEnd(ORACLE_NAME_PADDING), `${calls} calls`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `${total.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `min: ${min.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `avg: ${avg.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `max: ${max.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH)));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
log('');
|
|
32
|
+
});
|
|
33
|
+
if (biggest) {
|
|
34
|
+
log(format('\nTotal gates:', acc.toLocaleString(), `(Biggest circuit: ${biggest.functionName} -> ${biggest.gateCount.toLocaleString()})`));
|
|
35
|
+
}
|
|
36
|
+
if (stats.nodeRPCCalls) {
|
|
37
|
+
log(format('\nRPC calls:\n'));
|
|
38
|
+
for (const [method, { times }] of Object.entries(stats.nodeRPCCalls.perMethod)){
|
|
39
|
+
const calls = times.length;
|
|
40
|
+
const total = times.reduce((acc, time)=>acc + time, 0);
|
|
41
|
+
const avg = total / calls;
|
|
42
|
+
const min = Math.min(...times);
|
|
43
|
+
const max = Math.max(...times);
|
|
44
|
+
log(format(method.padEnd(ORACLE_NAME_PADDING), `${calls} calls`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `${total.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `min: ${min.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `avg: ${avg.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `max: ${max.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH)));
|
|
45
|
+
}
|
|
46
|
+
const { roundTrips } = stats.nodeRPCCalls;
|
|
47
|
+
log(format('\nRound trips (actual blocking waits):\n'));
|
|
48
|
+
log(format('Round trips:'.padEnd(25), `${roundTrips.roundTrips}`.padStart(COLUMN_MAX_WIDTH)));
|
|
49
|
+
log(format('Total blocking time:'.padEnd(25), `${roundTrips.totalBlockingTime.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
|
50
|
+
if (roundTrips.roundTrips > 0) {
|
|
51
|
+
const avgRoundTrip = roundTrips.totalBlockingTime / roundTrips.roundTrips;
|
|
52
|
+
log(format('Avg round trip:'.padEnd(25), `${avgRoundTrip.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
log(format('\nSync time:'.padEnd(25), `${timings.sync?.toFixed(2)}ms`.padStart(16)));
|
|
56
|
+
log(format('Private simulation time:'.padEnd(25), `${timings.perFunction.reduce((acc, { time })=>acc + time, 0).toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
|
57
|
+
if (timings.proving) {
|
|
58
|
+
log(format('Proving time:'.padEnd(25), `${timings.proving?.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
|
59
|
+
}
|
|
60
|
+
if (timings.publicSimulation) {
|
|
61
|
+
log(format('Public simulation time:'.padEnd(25), `${timings.publicSimulation?.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
|
62
|
+
}
|
|
63
|
+
if (timings.validation) {
|
|
64
|
+
log(format('Validation time:'.padEnd(25), `${timings.validation?.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
|
65
|
+
}
|
|
66
|
+
log(format('Total time:'.padEnd(25), `${timings.total.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH), `(${timings.unaccounted.toFixed(2)}ms unaccounted)`));
|
|
67
|
+
log('\n');
|
|
68
|
+
}
|