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 sequencer address to metrics #9145

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 4 additions & 0 deletions yarn-project/circuit-types/src/stats/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export type L2BlockStats = {

/** Stats logged for each L1 publish tx.*/
export type L1PublishStats = {
/** Address of the sender. */
sender: string;
/** Effective gas price of the tx. */
gasPrice: bigint;
/** Effective gas used in the tx. */
Expand Down Expand Up @@ -177,6 +179,8 @@ export type CircuitVerificationStats = {

/** Stats for an L2 block built by a sequencer. */
export type L2BlockBuiltStats = {
/** The creator of the block */
creator: string;
/** Name of the event. */
eventName: 'l2-block-built';
/** Total duration in ms. */
Expand Down
8 changes: 6 additions & 2 deletions yarn-project/sequencer-client/src/publisher/l1-publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ import { prettyLogViemError } from './utils.js';
* Stats for a sent transaction.
*/
export type TransactionStats = {
/** Address of the sender. */
sender: string;
/** Hash of the transaction. */
transactionHash: string;
/** Size in bytes of the tx calldata */
Expand Down Expand Up @@ -327,6 +329,7 @@ export class L1Publisher {
}
const calldata = hexToBytes(tx.input);
return {
sender: tx.from.toString(),
transactionHash: tx.hash,
calldataSize: calldata.length,
calldataGas: getCalldataGasUsage(calldata),
Expand Down Expand Up @@ -403,7 +406,7 @@ export class L1Publisher {
const tx = await this.getTransactionStats(txHash);
const stats: L1PublishBlockStats = {
...pick(receipt, 'gasPrice', 'gasUsed', 'transactionHash'),
...pick(tx!, 'calldataGas', 'calldataSize'),
...pick(tx!, 'calldataGas', 'calldataSize', 'sender'),
...block.getStats(),
eventName: 'rollup-published-to-l1',
};
Expand Down Expand Up @@ -484,8 +487,9 @@ export class L1Publisher {
const tx = await this.getTransactionStats(txHash);
const stats: L1PublishProofStats = {
...pick(receipt, 'gasPrice', 'gasUsed', 'transactionHash'),
...pick(tx!, 'calldataGas', 'calldataSize'),
...pick(tx!, 'calldataGas', 'calldataSize', 'sender'),
eventName: 'proof-published-to-l1',
sender: this.account.address,
};
this.log.info(`Published epoch proof to L1 rollup contract`, { ...stats, ...ctx });
this.metrics.recordSubmitProof(timer.ms(), stats);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ describe('sequencer', () => {
);

publisher = mock<L1Publisher>();
publisher.getSenderAddress.mockImplementation(() => EthAddress.random());
publisher.getCurrentEpochCommittee.mockResolvedValue(committee);
publisher.canProposeAtNextEthBlock.mockResolvedValue([
block.header.globalVariables.slotNumber.toBigInt(),
Expand Down
7 changes: 4 additions & 3 deletions yarn-project/sequencer-client/src/sequencer/sequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export class Sequencer {
// @note It is very important that the following function will FAIL and not just return early
// if it have made any state changes. If not, we won't rollback the state, and you will
// be in for a world of pain.
await this.buildBlockAndPublish(validTxs, proposalHeader, historicalHeader);
await this.buildBlockAndAttemptToPublish(validTxs, proposalHeader, historicalHeader);
} catch (err) {
if (BlockProofError.isBlockProofError(err)) {
const txHashes = err.txHashes.filter(h => !h.isZero());
Expand Down Expand Up @@ -394,10 +394,10 @@ export class Sequencer {
* @param proposalHeader - The partial header constructed for the proposal
* @param historicalHeader - The historical header of the parent
*/
@trackSpan('Sequencer.buildBlockAndPublish', (_validTxs, proposalHeader, _historicalHeader) => ({
@trackSpan('Sequencer.buildBlockAndAttemptToPublish', (_validTxs, proposalHeader, _historicalHeader) => ({
[Attributes.BLOCK_NUMBER]: proposalHeader.globalVariables.blockNumber.toNumber(),
}))
private async buildBlockAndPublish(
private async buildBlockAndAttemptToPublish(
validTxs: Tx[],
proposalHeader: Header,
historicalHeader: Header | undefined,
Expand Down Expand Up @@ -465,6 +465,7 @@ export class Sequencer {
)})`,
{
eventName: 'l2-block-built',
creator: this.publisher.getSenderAddress().toString(),
duration: workDuration,
publicProcessDuration: publicProcessorDuration,
rollupCircuitsDuration: blockBuildingTimer.ms(),
Expand Down
Loading