Skip to content

Commit

Permalink
feat: Output timestamps in prover-stats raw logs
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Sep 10, 2024
1 parent d5b2397 commit ee40a67
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions yarn-project/cli/src/cmds/l1/prover_stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function proverStats(opts: {
const events = await getL2ProofVerifiedEvents(startBlock, lastBlockNum, batchSize, debugLog, publicClient, rollup);

// If we only care for raw logs, output them
if (rawLogs) {
if (rawLogs && !provingTimeout) {
log(`l1_block_number, l2_block_number, prover_id, tx_hash`);
for (const event of events) {
const { l1BlockNumber, l2BlockNumber, proverId, txHash } = event;
Expand Down Expand Up @@ -88,7 +88,23 @@ export async function proverStats(opts: {
l2BlockSubmissions[blockEvent.args.blockNumber.toString()] = blockEvent.blockNumber;
}

// Now calculate stats
// If we want raw logs, output them
if (rawLogs) {
log(`l1_block_number, l2_block_number, l2_block_submission_timestamp, proof_timestamp, prover_id, tx_hash`);
for (const event of events) {
const { l1BlockNumber, l2BlockNumber, proverId, txHash } = event;
const uploadedBlockNumber = l2BlockSubmissions[l2BlockNumber.toString()];
if (!uploadedBlockNumber) {
continue;
}
const uploadedTimestamp = l1BlockTimestamps[uploadedBlockNumber.toString()];
const provenTimestamp = l1BlockTimestamps[l1BlockNumber.toString()];
log(`${l1BlockNumber}, ${l2BlockNumber}, ${uploadedTimestamp}, ${provenTimestamp}, ${proverId}, ${txHash}`);
}
return;
}

// Or calculate stats per prover
const stats = mapValues(groupBy(events, 'proverId'), (blocks, proverId) =>
compactArray(
blocks.map(e => {
Expand Down

0 comments on commit ee40a67

Please sign in to comment.