Skip to content

Commit

Permalink
merge fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Dec 16, 2024
1 parent c23e39f commit ccb47da
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/blob-sink/src/factory.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,7 +18,7 @@ async function getDataStoreConfig(config?: BlobSinkConfig): Promise<AztecKVStore
/**
* Creates a blob sink service from the provided config.
*/
export async function createBlobSinkService(config?: BlobSinkConfig): Promise<BlobSinkServer> {
export async function createBlobSinkServer(config?: BlobSinkConfig): Promise<BlobSinkServer> {
const store = await getDataStoreConfig(config);

return new BlobSinkServer(config, store);
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/blob-sink/src/server.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/end-to-end/src/fixtures/snapshot_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -53,7 +53,7 @@ export type SubsystemsContext = {
watcher: AnvilTestWatcher;
cheatCodes: CheatCodes;
dateProvider: TestDateProvider;
blobSink: BlobSinkService;
blobSink: BlobSinkServer;
};

type SnapshotEntry = {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -429,7 +429,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;

// TODO(md): will this revive state???
const blobSink = await createBlobSinkService({
const blobSink = await createBlobSinkServer({
port: blobSinkPort,
dataStoreConfig: {
dataDirectory: statePath,
Expand Down
7 changes: 3 additions & 4 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import {
import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint';
import { type BBNativePrivateKernelProver } from '@aztec/bb-prover';
import { createBlobSinkService } from '@aztec/blob-sink';
import { BlobSinkService } from '@aztec/blob-sink';
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink';
import { type EthAddress, FEE_JUICE_INITIAL_MINT, Fr, Gas, getContractClassFromArtifact } from '@aztec/circuits.js';
import {
type DeployL1ContractsArgs,
Expand Down Expand Up @@ -288,7 +287,7 @@ export type EndToEndContext = {
/** Allows tweaking current system time, used by the epoch cache only (undefined if connected to remote environment) */
dateProvider: TestDateProvider | undefined;
/** The blob sink (undefined if connected to remote environment) */
blobSink: BlobSinkService | undefined;
blobSink: BlobSinkServer | undefined;
/** Function to stop the started services. */
teardown: () => Promise<void>;
};
Expand Down Expand Up @@ -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 =
Expand Down
38 changes: 10 additions & 28 deletions yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 } }) =>
Expand All @@ -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 = [
Expand All @@ -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
Expand Down

0 comments on commit ccb47da

Please sign in to comment.