From ccb47dab36750fdfdc25c36b11f045a94a22dcde Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 16 Dec 2024 20:30:56 +0000 Subject: [PATCH] merge fix --- .../src/blobstore/disk_blob_store.test.ts | 2 +- yarn-project/blob-sink/src/factory.ts | 4 +- yarn-project/blob-sink/src/server.ts | 4 +- .../src/fixtures/snapshot_manager.ts | 8 ++-- yarn-project/end-to-end/src/fixtures/utils.ts | 7 ++-- .../src/publisher/l1-publisher.test.ts | 38 +++++-------------- 6 files changed, 22 insertions(+), 41 deletions(-) diff --git a/yarn-project/blob-sink/src/blobstore/disk_blob_store.test.ts b/yarn-project/blob-sink/src/blobstore/disk_blob_store.test.ts index dd61e739b67..8b523dbaef1 100644 --- a/yarn-project/blob-sink/src/blobstore/disk_blob_store.test.ts +++ b/yarn-project/blob-sink/src/blobstore/disk_blob_store.test.ts @@ -1,4 +1,4 @@ -import { openTmpStore } from '@aztec/kv-store/utils'; +import { openTmpStore } from '@aztec/kv-store/lmdb'; import { describeBlobStore } from './blob_store_test_suite.js'; import { DiskBlobStore } from './disk_blob_store.js'; diff --git a/yarn-project/blob-sink/src/factory.ts b/yarn-project/blob-sink/src/factory.ts index ba83fcbf5ef..3e04e6aae79 100644 --- a/yarn-project/blob-sink/src/factory.ts +++ b/yarn-project/blob-sink/src/factory.ts @@ -1,5 +1,5 @@ import { type AztecKVStore } from '@aztec/kv-store'; -import { createStore } from '@aztec/kv-store/utils'; +import { createStore } from '@aztec/kv-store/lmdb'; import { type BlobSinkConfig } from './config.js'; import { BlobSinkServer } from './server.js'; @@ -18,7 +18,7 @@ async function getDataStoreConfig(config?: BlobSinkConfig): Promise { +export async function createBlobSinkServer(config?: BlobSinkConfig): Promise { const store = await getDataStoreConfig(config); return new BlobSinkServer(config, store); diff --git a/yarn-project/blob-sink/src/server.ts b/yarn-project/blob-sink/src/server.ts index 78365ca4235..a3e30f1d37e 100644 --- a/yarn-project/blob-sink/src/server.ts +++ b/yarn-project/blob-sink/src/server.ts @@ -1,5 +1,5 @@ import { Blob } from '@aztec/foundation/blob'; -import { type Logger, createDebugLogger } from '@aztec/foundation/log'; +import { type Logger, createLogger } from '@aztec/foundation/log'; import { type AztecKVStore } from '@aztec/kv-store'; import { type TelemetryClient } from '@aztec/telemetry-client'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; @@ -33,7 +33,7 @@ export class BlobSinkServer { private blobStore: BlobStore; private readonly port: number; private metrics: BlobSinkMetrics; - private log: Logger = createDebugLogger('aztec:blob-sink'); + private log: Logger = createLogger('aztec:blob-sink'); constructor(config?: BlobSinkConfig, store?: AztecKVStore, telemetry: TelemetryClient = new NoopTelemetryClient()) { this.port = config?.port ?? 5052; // 5052 is beacon chain default http port diff --git a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts index 18eff675728..3420e459120 100644 --- a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts +++ b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts @@ -15,7 +15,7 @@ import { type Wallet, } from '@aztec/aztec.js'; import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment'; -import { type BlobSinkServer, createBlobSinkService } from '@aztec/blob-sink'; +import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink'; import { type DeployL1ContractsArgs, createL1Clients, getL1ContractsConfigEnvVars, l1Artifacts } from '@aztec/ethereum'; import { startAnvil } from '@aztec/ethereum/test'; import { asyncMap } from '@aztec/foundation/async-map'; @@ -53,7 +53,7 @@ export type SubsystemsContext = { watcher: AnvilTestWatcher; cheatCodes: CheatCodes; dateProvider: TestDateProvider; - blobSink: BlobSinkService; + blobSink: BlobSinkServer; }; type SnapshotEntry = { @@ -284,7 +284,7 @@ async function setupFromFresh( aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`; // Setup blob sink service - const blobSink = await createBlobSinkService({ + const blobSink = await createBlobSinkServer({ port: blobSinkPort, dataStoreConfig: { dataDirectory: statePath, @@ -429,7 +429,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise Promise; }; @@ -368,7 +367,7 @@ export async function setup( // Blob sink service - blobs get posted here and served from here const blobSinkPort = await getPort(); - const blobSink = await createBlobSinkService({ port: blobSinkPort }); + const blobSink = await createBlobSinkServer({ port: blobSinkPort }); config.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`; const deployL1ContractsValues = diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts index 6fb68d9e7bc..839dbcc4c25 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts @@ -14,7 +14,7 @@ import { RollupAbi } from '@aztec/l1-artifacts'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; import { jest } from '@jest/globals'; -import express from 'express'; +import express, { json } from 'express'; import { type Server } from 'http'; import { type MockProxy, mock } from 'jest-mock-extended'; import { @@ -91,8 +91,6 @@ describe('L1Publisher', () => { let blockHash: Buffer; let body: Buffer; - let account: PrivateKeyAccount; - let mockBlobSinkServer: Server | undefined = undefined; // An l1 publisher with some private methods exposed @@ -176,7 +174,7 @@ describe('L1Publisher', () => { const sendToBlobSinkSpy = jest.spyOn(publisher as any, 'sendBlobsToBlobSink'); const app = express(); - app.use(express.json({ limit: '10mb' })); + app.use(json({ limit: '10mb' })); app.post('/blob_sidecar', (req, res) => { const blobsBuffers = req.body.blobs.map((b: { index: number; blob: { type: string; data: string } }) => @@ -200,6 +198,13 @@ describe('L1Publisher', () => { const blobs = Blob.getBlobs(l2Block.body.toBlobFields()); + // Check the blobs were forwarded to the blob sink service + const sendToBlobSinkSpy = expectBlobsAreSentToBlobSink(blockHash.toString('hex'), blobs); + + const result = await publisher.proposeL2Block(l2Block); + + expect(result).toEqual(true); + const blobInput = Blob.getEthBlobEvaluationInputs(blobs); const args = [ @@ -217,38 +222,15 @@ describe('L1Publisher', () => { `0x${body.toString('hex')}`, blobInput, ] as const; - expect(l1TxUtils.sendAndMonitorTransaction).toHaveBeenCalledWith( { to: mockRollupAddress, data: encodeFunctionData({ abi: rollupContract.abi, functionName: 'propose', args }), }, { fixedGas: GAS_GUESS + L1Publisher.PROPOSE_GAS_GUESS }, - { blobs: blobs.map(b => b.data), kzg, maxFeePerBlobGas: 10000000000n }, + { blobs: blobs.map(b => b.fullData), kzg, maxFeePerBlobGas: 10000000000n }, ); - const data = encodeFunctionData({ - abi: RollupAbi, - functionName: 'propose', - args, - }); - - // Check the blobs were forwarded to the blob sink service - const sendToBlobSinkSpy = expectBlobsAreSentToBlobSink(blockHash.toString('hex'), blobs); - - const result = await publisher.proposeL2Block(l2Block); - - expect(result).toEqual(true); - expect(walletClient.sendTransaction).toHaveBeenCalledWith({ - data, - account, - to: rollupContract.address, - blobs: blobs.map(blob => blob.fullData), - kzg, - maxFeePerBlobGas: 10000000000n, - }); - expect(publicClient.getTransactionReceipt).toHaveBeenCalledWith({ hash: proposeTxHash }); - expect(sendToBlobSinkSpy).toHaveBeenCalledTimes(1); // If this does not return true, then the mocked server will have errored, and // the expects that run there will have failed