Skip to content

Commit

Permalink
fix: sink logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Nov 26, 2024
1 parent 4abceef commit 012efb3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
9 changes: 9 additions & 0 deletions yarn-project/blob-sink/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export class BlobSinkService {
private async handlePostBlobSidecar(req: Request, res: Response) {
// eslint-disable-next-line camelcase
const { block_id, blobs } = req.body;


try {
// eslint-disable-next-line camelcase
const parsedBlockId = blockIdSchema.parse(block_id);
Expand All @@ -108,6 +110,8 @@ export class BlobSinkService {
return;
}

this.log.info(`Received blob sidecar for block ${parsedBlockId}`);

// TODO: tidy up the blob parsing
const blobObjects: BlobWithIndex[] = blobs.map(
(b: { index: number; blob: { type: string; data: string } }) =>
Expand All @@ -117,6 +121,8 @@ export class BlobSinkService {
await this.blobStore.addBlobSidecars(parsedBlockId.toString(), blobObjects);
this.metrics.recordBlobReciept(blobObjects);

this.log.info(`Blob sidecar stored successfully for block ${parsedBlockId}`);

res.json({ message: 'Blob sidecar stored successfully' });
} catch (error) {
res.status(400).json({
Expand All @@ -135,9 +141,11 @@ export class BlobSinkService {
}

public stop(): Promise<void> {
this.log.info("Stopping blob sink");
return new Promise((resolve, reject) => {
if (!this.server) {
resolve();
this.log.info("Blob sink already stopped");
return;
}

Expand All @@ -147,6 +155,7 @@ export class BlobSinkService {
return;
}
this.server = null;
this.log.info("Blob sink stopped");
resolve();
});
});
Expand Down
39 changes: 19 additions & 20 deletions yarn-project/sequencer-client/src/publisher/l1-publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ export class L1Publisher {
this.metrics.recordProcessBlockTx(timer.ms(), stats);

// Send the blobs to the blob sink
await this.sendBlobsToBlobSink(receipt.blockHash, blobs);
this.sendBlobsToBlobSink(receipt.blockHash, blobs);

return true;
}
Expand Down Expand Up @@ -956,34 +956,33 @@ export class L1Publisher {
* to calculate and will need to be mocked in e2e tests
*/
protected async sendBlobsToBlobSink(blockHash: string, blobs: Blob[]): Promise<boolean> {
console.log("block hash", blockHash);
// TODO: for now we are assuming the indexes of the blobs will be 0, 1, 2
// TODO(md): for now we are assuming the indexes of the blobs will be 0, 1, 2
// When in reality they will not, but for testing purposes this is fine
if (!this.blobSinkUrl) {
return false;
}

this.log.verbose(`Sending ${blobs.length} blobs to blob sink`);
try {
// const res = await fetch(`${this.blobSinkUrl}/blob_sidecar`, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({
// // eslint-disable-next-line camelcase
// block_id: blockHash,
// blobs: blobs.map((b, i) => ({ blob: b.toBuffer(), index: i })),
// }),
// });

// if (res.ok) {
// this.log.verbose(`Successfully sent blobs to blob sink ${res.status}`);
const res = await fetch(`${this.blobSinkUrl}/blob_sidecar`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
// eslint-disable-next-line camelcase
block_id: blockHash,
blobs: blobs.map((b, i) => ({ blob: b.toBuffer(), index: i })),
}),
});

if (res.ok) {
this.log.verbose(`Successfully sent blobs to blob sink ${res.status}`);
return true;
// }
}

// this.log.error('Failed to send blobs to blob sink', res.status);
// return false;
this.log.error('Failed to send blobs to blob sink', res.status);
return false;
} catch (err) {
this.log.error(`Error sending blobs to blob sink`, err);
return false;
Expand Down

0 comments on commit 012efb3

Please sign in to comment.