-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add CLI command for gathering proving metrics (#8221)
Run `yarn aztec prover-stats --l1-rpc-url https://provernet-mainnet-fork.aztec.network:8545/$APIKEY -c 677692 --start-block 15918000 --batch-size 200 --node-url https://api.aztec.network/provernet/aztec-node-1/$APIKEY` to get prover stats from provernet.
- Loading branch information
1 parent
03bcd62
commit 5929a42
Showing
5 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { retrieveL2ProofVerifiedEvents } from '@aztec/archiver'; | ||
import { createAztecNodeClient } from '@aztec/circuit-types'; | ||
import { EthAddress } from '@aztec/circuits.js'; | ||
import { createEthereumChain } from '@aztec/ethereum'; | ||
import { type LogFn, createDebugLogger } from '@aztec/foundation/log'; | ||
|
||
import groupBy from 'lodash.groupby'; | ||
import { createPublicClient, http } from 'viem'; | ||
|
||
export async function proverStats(opts: { | ||
l1RpcUrl: string; | ||
chainId: number; | ||
l1RollupAddress: string | undefined; | ||
nodeUrl: string | undefined; | ||
log: LogFn; | ||
startBlock: bigint; | ||
batchSize: bigint; | ||
}) { | ||
const debugLog = createDebugLogger('aztec:cli:prover_stats'); | ||
const { startBlock, chainId, l1RpcUrl, l1RollupAddress, batchSize, nodeUrl, log } = opts; | ||
if (!l1RollupAddress && !nodeUrl) { | ||
throw new Error('Either L1 rollup address or node URL must be set'); | ||
} | ||
const rollup = l1RollupAddress | ||
? EthAddress.fromString(l1RollupAddress) | ||
: await createAztecNodeClient(nodeUrl!) | ||
.getL1ContractAddresses() | ||
.then(a => a.rollupAddress); | ||
|
||
const chain = createEthereumChain(l1RpcUrl, chainId).chainInfo; | ||
const publicClient = createPublicClient({ chain, transport: http(l1RpcUrl) }); | ||
const lastBlockNum = await publicClient.getBlockNumber(); | ||
debugLog.verbose(`Querying events on rollup at ${rollup.toString()} from ${startBlock} up to ${lastBlockNum}`); | ||
|
||
let blockNum = startBlock; | ||
const events = []; | ||
while (blockNum <= lastBlockNum) { | ||
const end = blockNum + batchSize > lastBlockNum + 1n ? lastBlockNum + 1n : blockNum + batchSize; | ||
debugLog.verbose(`Querying events from block ${blockNum} to ${end}`); | ||
const newEvents = await retrieveL2ProofVerifiedEvents(publicClient, rollup, blockNum, end); | ||
events.push(...newEvents); | ||
debugLog.verbose(`Got ${newEvents.length} events`); | ||
blockNum += batchSize; | ||
} | ||
|
||
const stats = groupBy(events, 'proverId'); | ||
for (const proverId in stats) { | ||
log(`${proverId}, ${stats[proverId].length}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters