diff --git a/yarn-project/archiver/package.json b/yarn-project/archiver/package.json index 2134edc632e4..5bab49643e92 100644 --- a/yarn-project/archiver/package.json +++ b/yarn-project/archiver/package.json @@ -64,6 +64,7 @@ ] }, "dependencies": { + "@aztec/blob-lib": "workspace:^", "@aztec/blob-sink": "workspace:^", "@aztec/circuit-types": "workspace:^", "@aztec/circuits.js": "workspace:^", diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index 6d31d0dac9e9..c1adc87376a5 100644 --- a/yarn-project/archiver/src/archiver/archiver.test.ts +++ b/yarn-project/archiver/src/archiver/archiver.test.ts @@ -1,8 +1,8 @@ +import { Blob } from '@aztec/blob-lib'; import { type BlobSinkClientInterface } from '@aztec/blob-sink/client'; import { InboxLeaf, type L1RollupConstants, L2Block } from '@aztec/circuit-types'; import { GENESIS_ARCHIVE_ROOT, PrivateLog } from '@aztec/circuits.js'; import { DefaultL1ContractsConfig } from '@aztec/ethereum'; -import { Blob } from '@aztec/foundation/blob'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { type Logger, createLogger } from '@aztec/foundation/log'; diff --git a/yarn-project/archiver/src/archiver/data_retrieval.ts b/yarn-project/archiver/src/archiver/data_retrieval.ts index bde78daa4071..f85b272fd8cb 100644 --- a/yarn-project/archiver/src/archiver/data_retrieval.ts +++ b/yarn-project/archiver/src/archiver/data_retrieval.ts @@ -1,8 +1,8 @@ +import { Blob, BlobDeserializationError } from '@aztec/blob-lib'; import { type BlobSinkClientInterface } from '@aztec/blob-sink/client'; import { Body, InboxLeaf, L2Block } from '@aztec/circuit-types'; import { AppendOnlyTreeSnapshot, BlockHeader, Fr, Proof } from '@aztec/circuits.js'; import { asyncPool } from '@aztec/foundation/async-pool'; -import { Blob, BlobDeserializationError } from '@aztec/foundation/blob'; import { type EthAddress } from '@aztec/foundation/eth-address'; import { type ViemSignature } from '@aztec/foundation/eth-signature'; import { type Logger, createLogger } from '@aztec/foundation/log'; diff --git a/yarn-project/archiver/tsconfig.json b/yarn-project/archiver/tsconfig.json index 050085a41a49..a4129646732b 100644 --- a/yarn-project/archiver/tsconfig.json +++ b/yarn-project/archiver/tsconfig.json @@ -6,6 +6,9 @@ "tsBuildInfoFile": ".tsbuildinfo" }, "references": [ + { + "path": "../blob-lib" + }, { "path": "../blob-sink" }, diff --git a/yarn-project/blob-lib/.eslintrc.cjs b/yarn-project/blob-lib/.eslintrc.cjs new file mode 100644 index 000000000000..e659927475c0 --- /dev/null +++ b/yarn-project/blob-lib/.eslintrc.cjs @@ -0,0 +1 @@ +module.exports = require('@aztec/foundation/eslint'); diff --git a/yarn-project/blob-lib/package.json b/yarn-project/blob-lib/package.json new file mode 100644 index 000000000000..820e73d84383 --- /dev/null +++ b/yarn-project/blob-lib/package.json @@ -0,0 +1,84 @@ +{ + "name": "@aztec/blob-lib", + "version": "0.1.0", + "type": "module", + "exports": { + ".": "./dest/index.js" + }, + "typedocOptions": { + "entryPoints": [ + "./src/index.ts" + ], + "name": "Blob Lib", + "tsconfig": "./tsconfig.json" + }, + "scripts": { + "build": "yarn clean && tsc -b", + "build:dev": "tsc -b --watch", + "clean": "rm -rf ./dest .tsbuildinfo", + "formatting": "run -T prettier --check ./src && run -T eslint ./src", + "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", + "start:dev": "tsc-watch -p tsconfig.json --onSuccess 'yarn start'", + "start": "node ./dest/index.js", + "test": "HARDWARE_CONCURRENCY=${HARDWARE_CONCURRENCY:-16} RAYON_NUM_THREADS=${RAYON_NUM_THREADS:-4} NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}" + }, + "inherits": [ + "../package.common.json" + ], + "dependencies": { + "@aztec/foundation": "workspace:^", + "c-kzg": "4.0.0-alpha.1", + "tslib": "^2.4.0" + }, + "devDependencies": { + "@jest/globals": "^29.5.0", + "@types/jest": "^29.5.0", + "@types/node": "^18.14.6", + "get-port": "^7.1.0", + "jest": "^29.5.0", + "ts-node": "^10.9.1", + "typescript": "^5.0.4" + }, + "files": [ + "dest", + "src", + "!*.test.*" + ], + "types": "./dest/index.d.ts", + "jest": { + "moduleNameMapper": { + "^(\\.{1,2}/.*)\\.[cm]?js$": "$1" + }, + "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", + "rootDir": "./src", + "transform": { + "^.+\\.tsx?$": [ + "@swc/jest", + { + "jsc": { + "parser": { + "syntax": "typescript", + "decorators": true + }, + "transform": { + "decoratorVersion": "2022-03" + } + } + } + ] + }, + "extensionsToTreatAsEsm": [ + ".ts" + ], + "reporters": [ + "default" + ], + "testTimeout": 30000, + "setupFiles": [ + "../../foundation/src/jest/setup.mjs" + ] + }, + "engines": { + "node": ">=18" + } +} diff --git a/yarn-project/foundation/src/blob/blob.test.ts b/yarn-project/blob-lib/src/blob.test.ts similarity index 98% rename from yarn-project/foundation/src/blob/blob.test.ts rename to yarn-project/blob-lib/src/blob.test.ts index 0163a4cad0b6..94e83e2c1559 100644 --- a/yarn-project/foundation/src/blob/blob.test.ts +++ b/yarn-project/blob-lib/src/blob.test.ts @@ -1,8 +1,9 @@ +import { poseidon2Hash } from '@aztec/foundation/crypto'; +import { Fr } from '@aztec/foundation/fields'; + import cKzg from 'c-kzg'; import type { Blob as BlobBuffer, Bytes48, KZGProof } from 'c-kzg'; -import { poseidon2Hash } from '../crypto/index.js'; -import { Fr } from '../fields/index.js'; import { Blob, makeEncodedBlob } from './index.js'; // Importing directly from 'c-kzg' does not work, ignoring import/no-named-as-default-member err: diff --git a/yarn-project/foundation/src/blob/blob.ts b/yarn-project/blob-lib/src/blob.ts similarity index 98% rename from yarn-project/foundation/src/blob/blob.ts rename to yarn-project/blob-lib/src/blob.ts index e1504f392534..b9c0f5359f8b 100644 --- a/yarn-project/foundation/src/blob/blob.ts +++ b/yarn-project/blob-lib/src/blob.ts @@ -1,10 +1,11 @@ // Importing directly from 'c-kzg' does not work, ignoring import/no-named-as-default-member err: +import { poseidon2Hash, sha256 } from '@aztec/foundation/crypto'; +import { Fr } from '@aztec/foundation/fields'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; + import cKzg from 'c-kzg'; import type { Blob as BlobBuffer } from 'c-kzg'; -import { poseidon2Hash, sha256 } from '../crypto/index.js'; -import { Fr } from '../fields/index.js'; -import { BufferReader, serializeToBuffer } from '../serialize/index.js'; import { deserializeEncodedBlobToFields, extractBlobFieldsFromBuffer } from './encoding.js'; import { BlobDeserializationError } from './errors.js'; import { type BlobJson } from './interface.js'; diff --git a/yarn-project/foundation/src/blob/encoding.ts b/yarn-project/blob-lib/src/encoding.ts similarity index 76% rename from yarn-project/foundation/src/blob/encoding.ts rename to yarn-project/blob-lib/src/encoding.ts index c9b63b242802..3598eefc244e 100644 --- a/yarn-project/foundation/src/blob/encoding.ts +++ b/yarn-project/blob-lib/src/encoding.ts @@ -3,12 +3,14 @@ import { BufferReader, FieldReader } from '@aztec/foundation/serialize'; import type { Blob as BlobBuffer } from 'c-kzg'; +// Note duplicated from circuit-types ! // This will appear as 0x74785f7374617274 in logs export const TX_START_PREFIX = 8392562855083340404n; // These are helper constants to decode tx effects from blob encoded fields export const TX_START_PREFIX_BYTES_LENGTH = TX_START_PREFIX.toString(16).length / 2; // 7 bytes for: | 0 | txlen[0] | txlen[1] | 0 | REVERT_CODE_PREFIX | 0 | revertCode | export const TX_EFFECT_PREFIX_BYTE_LENGTH = TX_START_PREFIX_BYTES_LENGTH + 7; +export const REVERT_CODE_PREFIX = 1; /** * Deserializes a blob buffer into an array of field elements. @@ -66,11 +68,50 @@ export function deserializeEncodedBlobToFields(blob: BlobBuffer): Fr[] { return array.slice(0, fieldReader.cursor); } +/** + * Get the length of the transaction from the first field. + * + * @param firstField - The first field of the transaction. + * @returns The length of the transaction. + * + * @throws If the first field does not include the correct prefix - encoding invalid. + */ export function getLengthFromFirstField(firstField: Fr): number { + // Check that the first field includes the correct prefix + if (!isValidFirstField(firstField)) { + throw new Error('Invalid prefix'); + } const buf = firstField.toBuffer().subarray(-TX_EFFECT_PREFIX_BYTE_LENGTH); return new Fr(buf.subarray(TX_START_PREFIX_BYTES_LENGTH + 1, TX_START_PREFIX_BYTES_LENGTH + 3)).toNumber(); } +// NOTE: duplicated from circuit-types tx effect! +/** + * Determines whether a field is the first field of a tx effect + */ +export function isValidFirstField(field: Fr): boolean { + const buf = field.toBuffer(); + if ( + !buf + .subarray(0, field.size - TX_EFFECT_PREFIX_BYTE_LENGTH) + .equals(Buffer.alloc(field.size - TX_EFFECT_PREFIX_BYTE_LENGTH)) + ) { + return false; + } + const sliced = buf.subarray(-TX_EFFECT_PREFIX_BYTE_LENGTH); + if ( + // Checking we start with the correct prefix... + !new Fr(sliced.subarray(0, TX_START_PREFIX_BYTES_LENGTH)).equals(new Fr(TX_START_PREFIX)) || + // ...and include the revert code prefix.. + sliced[sliced.length - 3] !== REVERT_CODE_PREFIX || + // ...and the following revert code is valid. + sliced[sliced.length - 1] > 4 + ) { + return false; + } + return true; +} + /** * Extract the fields from a blob buffer, but do not take into account encoding * that will include trailing zeros. diff --git a/yarn-project/foundation/src/blob/errors.ts b/yarn-project/blob-lib/src/errors.ts similarity index 100% rename from yarn-project/foundation/src/blob/errors.ts rename to yarn-project/blob-lib/src/errors.ts diff --git a/yarn-project/foundation/src/blob/index.ts b/yarn-project/blob-lib/src/index.ts similarity index 100% rename from yarn-project/foundation/src/blob/index.ts rename to yarn-project/blob-lib/src/index.ts diff --git a/yarn-project/foundation/src/blob/interface.ts b/yarn-project/blob-lib/src/interface.ts similarity index 100% rename from yarn-project/foundation/src/blob/interface.ts rename to yarn-project/blob-lib/src/interface.ts diff --git a/yarn-project/foundation/src/blob/mocks.ts b/yarn-project/blob-lib/src/mocks.ts similarity index 100% rename from yarn-project/foundation/src/blob/mocks.ts rename to yarn-project/blob-lib/src/mocks.ts diff --git a/yarn-project/blob-lib/tsconfig.json b/yarn-project/blob-lib/tsconfig.json new file mode 100644 index 000000000000..e92b3fa25626 --- /dev/null +++ b/yarn-project/blob-lib/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "..", + "compilerOptions": { + "outDir": "dest", + "rootDir": "src", + "tsBuildInfoFile": ".tsbuildinfo" + }, + "include": ["src"], + "references": [ + { + "path": "../foundation" + } + ] +} diff --git a/yarn-project/blob-sink/package.json b/yarn-project/blob-sink/package.json index e5d0bf982478..d9d61c123918 100644 --- a/yarn-project/blob-sink/package.json +++ b/yarn-project/blob-sink/package.json @@ -52,6 +52,7 @@ ] }, "dependencies": { + "@aztec/blob-lib": "workspace:^", "@aztec/circuit-types": "workspace:^", "@aztec/foundation": "workspace:^", "@aztec/kv-store": "workspace:*", diff --git a/yarn-project/blob-sink/src/blobstore/blob_store_test_suite.ts b/yarn-project/blob-sink/src/blobstore/blob_store_test_suite.ts index 5fc5f5aa5591..523128a77714 100644 --- a/yarn-project/blob-sink/src/blobstore/blob_store_test_suite.ts +++ b/yarn-project/blob-sink/src/blobstore/blob_store_test_suite.ts @@ -1,4 +1,4 @@ -import { Blob } from '@aztec/foundation/blob'; +import { Blob } from '@aztec/blob-lib'; import { Fr } from '@aztec/foundation/fields'; import { BlobWithIndex } from '../types/index.js'; diff --git a/yarn-project/blob-sink/src/client/blob-sink-client-tests.ts b/yarn-project/blob-sink/src/client/blob-sink-client-tests.ts index b416a7b99c0f..c3c0b7625cff 100644 --- a/yarn-project/blob-sink/src/client/blob-sink-client-tests.ts +++ b/yarn-project/blob-sink/src/client/blob-sink-client-tests.ts @@ -1,4 +1,4 @@ -import { makeEncodedBlob } from '@aztec/foundation/blob'; +import { makeEncodedBlob } from '@aztec/blob-lib'; import { type BlobSinkClientInterface } from './interface.js'; diff --git a/yarn-project/blob-sink/src/client/http.test.ts b/yarn-project/blob-sink/src/client/http.test.ts index 5230ead1733f..7cfbd1bf21d4 100644 --- a/yarn-project/blob-sink/src/client/http.test.ts +++ b/yarn-project/blob-sink/src/client/http.test.ts @@ -1,4 +1,4 @@ -import { Blob, makeEncodedBlob, makeUnencodedBlob } from '@aztec/foundation/blob'; +import { Blob, makeEncodedBlob, makeUnencodedBlob } from '@aztec/blob-lib'; import { Fr } from '@aztec/foundation/fields'; import { jest } from '@jest/globals'; diff --git a/yarn-project/blob-sink/src/client/http.ts b/yarn-project/blob-sink/src/client/http.ts index 4641126e9864..4984ac81c0c6 100644 --- a/yarn-project/blob-sink/src/client/http.ts +++ b/yarn-project/blob-sink/src/client/http.ts @@ -1,4 +1,4 @@ -import { Blob, BlobDeserializationError, type BlobJson } from '@aztec/foundation/blob'; +import { Blob, BlobDeserializationError, type BlobJson } from '@aztec/blob-lib'; import { type Logger, createLogger } from '@aztec/foundation/log'; import { makeBackoff, retry } from '@aztec/foundation/retry'; diff --git a/yarn-project/blob-sink/src/client/interface.ts b/yarn-project/blob-sink/src/client/interface.ts index ac098c0bb479..4e5b9369c283 100644 --- a/yarn-project/blob-sink/src/client/interface.ts +++ b/yarn-project/blob-sink/src/client/interface.ts @@ -1,4 +1,4 @@ -import { type Blob } from '@aztec/foundation/blob'; +import { type Blob } from '@aztec/blob-lib'; export interface BlobSinkClientInterface { sendBlobsToBlobSink(blockId: string, blobs: Blob[]): Promise; diff --git a/yarn-project/blob-sink/src/client/local.ts b/yarn-project/blob-sink/src/client/local.ts index 44985bf2cb6a..2b5a3a036872 100644 --- a/yarn-project/blob-sink/src/client/local.ts +++ b/yarn-project/blob-sink/src/client/local.ts @@ -1,4 +1,4 @@ -import { type Blob } from '@aztec/foundation/blob'; +import { type Blob } from '@aztec/blob-lib'; import { type BlobStore } from '../blobstore/index.js'; import { BlobWithIndex } from '../types/blob_with_index.js'; diff --git a/yarn-project/blob-sink/src/server/server.test.ts b/yarn-project/blob-sink/src/server/server.test.ts index 3668db2dc257..fbb178af6733 100644 --- a/yarn-project/blob-sink/src/server/server.test.ts +++ b/yarn-project/blob-sink/src/server/server.test.ts @@ -1,4 +1,4 @@ -import { Blob, makeEncodedBlob } from '@aztec/foundation/blob'; +import { Blob, makeEncodedBlob } from '@aztec/blob-lib'; import request from 'supertest'; diff --git a/yarn-project/blob-sink/src/server/server.ts b/yarn-project/blob-sink/src/server/server.ts index 60c4b5d6b7cc..aacfcb3a7c61 100644 --- a/yarn-project/blob-sink/src/server/server.ts +++ b/yarn-project/blob-sink/src/server/server.ts @@ -1,4 +1,4 @@ -import { Blob } from '@aztec/foundation/blob'; +import { Blob } from '@aztec/blob-lib'; import { type Logger, createLogger } from '@aztec/foundation/log'; import { type AztecAsyncKVStore } from '@aztec/kv-store'; import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client'; diff --git a/yarn-project/blob-sink/src/types/blob_with_index.test.ts b/yarn-project/blob-sink/src/types/blob_with_index.test.ts index 26c77b20f42f..4664c52f399d 100644 --- a/yarn-project/blob-sink/src/types/blob_with_index.test.ts +++ b/yarn-project/blob-sink/src/types/blob_with_index.test.ts @@ -1,4 +1,4 @@ -import { Blob } from '@aztec/foundation/blob'; +import { Blob } from '@aztec/blob-lib'; import { Fr } from '@aztec/foundation/fields'; import { BlobWithIndex, BlobsWithIndexes } from './blob_with_index.js'; diff --git a/yarn-project/blob-sink/src/types/blob_with_index.ts b/yarn-project/blob-sink/src/types/blob_with_index.ts index e3a217be528e..c22113e6567c 100644 --- a/yarn-project/blob-sink/src/types/blob_with_index.ts +++ b/yarn-project/blob-sink/src/types/blob_with_index.ts @@ -1,4 +1,4 @@ -import { Blob, type BlobJson } from '@aztec/foundation/blob'; +import { Blob, type BlobJson } from '@aztec/blob-lib'; import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; /** Serialized an array of blobs with their indexes to be stored at a given block id */ diff --git a/yarn-project/blob-sink/tsconfig.json b/yarn-project/blob-sink/tsconfig.json index 535eabe58633..7a0d24d7adf3 100644 --- a/yarn-project/blob-sink/tsconfig.json +++ b/yarn-project/blob-sink/tsconfig.json @@ -6,6 +6,9 @@ "tsBuildInfoFile": ".tsbuildinfo" }, "references": [ + { + "path": "../blob-lib" + }, { "path": "../circuit-types" }, diff --git a/yarn-project/circuit-types/package.json b/yarn-project/circuit-types/package.json index 90e86cd04dca..3a4008fbbdc2 100644 --- a/yarn-project/circuit-types/package.json +++ b/yarn-project/circuit-types/package.json @@ -4,6 +4,7 @@ "type": "module", "exports": { ".": "./dest/index.js", + "./blob": "./dest/blob/index.js", "./stats": "./dest/stats/index.js", "./jest": "./dest/jest/index.js", "./interfaces": "./dest/interfaces/index.js", diff --git a/yarn-project/circuits.js/package.json b/yarn-project/circuits.js/package.json index fe7cad68382e..56f46011f0a0 100644 --- a/yarn-project/circuits.js/package.json +++ b/yarn-project/circuits.js/package.json @@ -42,6 +42,7 @@ }, "dependencies": { "@aztec/bb.js": "portal:../../barretenberg/ts", + "@aztec/blob-lib": "workspace:^", "@aztec/ethereum": "workspace:^", "@aztec/foundation": "workspace:^", "@aztec/types": "workspace:^", diff --git a/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.test.ts b/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.test.ts index d7893596b66d..def32b893cd5 100644 --- a/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.test.ts +++ b/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.test.ts @@ -1,4 +1,4 @@ -import { Blob } from '@aztec/foundation/blob'; +import { Blob } from '@aztec/blob-lib'; import { timesParallel } from '@aztec/foundation/collection'; import { randomInt } from '@aztec/foundation/crypto'; diff --git a/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.ts b/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.ts index 537bace933da..c3429a310b24 100644 --- a/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.ts @@ -1,6 +1,6 @@ +import { type Blob } from '@aztec/blob-lib'; import { makeTuple } from '@aztec/foundation/array'; import { toBigIntBE, toBufferBE, toHex } from '@aztec/foundation/bigint-buffer'; -import { type Blob } from '@aztec/foundation/blob'; import { sha256, sha256Trunc } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, FieldReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; diff --git a/yarn-project/circuits.js/tsconfig.json b/yarn-project/circuits.js/tsconfig.json index f37d6d829a88..b5050d9ffeaa 100644 --- a/yarn-project/circuits.js/tsconfig.json +++ b/yarn-project/circuits.js/tsconfig.json @@ -6,6 +6,9 @@ "tsBuildInfoFile": ".tsbuildinfo" }, "references": [ + { + "path": "../blob-lib" + }, { "path": "../ethereum" }, diff --git a/yarn-project/end-to-end/.gitignore b/yarn-project/end-to-end/.gitignore index 0ea345f31884..4f89329dc51b 100644 --- a/yarn-project/end-to-end/.gitignore +++ b/yarn-project/end-to-end/.gitignore @@ -1,2 +1,3 @@ joblog.txt -results \ No newline at end of file +results +web/main.js* \ No newline at end of file diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index e40f75080c43..40f9a0484d36 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -33,6 +33,7 @@ "@aztec/aztec-node": "workspace:^", "@aztec/aztec.js": "workspace:^", "@aztec/bb-prover": "workspace:^", + "@aztec/blob-lib": "workspace:^", "@aztec/blob-sink": "workspace:^", "@aztec/bot": "workspace:^", "@aztec/circuit-types": "workspace:^", diff --git a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts index cab04920740b..5745702fb55d 100644 --- a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts @@ -1,6 +1,7 @@ import { type ArchiveSource } from '@aztec/archiver'; import { getConfigEnvVars } from '@aztec/aztec-node'; import { AztecAddress, Fr, GlobalVariables, type L2Block, createLogger } from '@aztec/aztec.js'; +import { Blob } from '@aztec/blob-lib'; // eslint-disable-next-line no-restricted-imports import { type L2Tips, type ProcessedTx } from '@aztec/circuit-types'; import { makeBloatedProcessedTx } from '@aztec/circuit-types/test'; @@ -27,7 +28,6 @@ import { } from '@aztec/ethereum'; import { EthCheatCodesWithState } from '@aztec/ethereum/test'; import { range } from '@aztec/foundation/array'; -import { Blob } from '@aztec/foundation/blob'; import { timesParallel } from '@aztec/foundation/collection'; import { sha256, sha256ToField } from '@aztec/foundation/crypto'; import { TestDateProvider } from '@aztec/foundation/timer'; diff --git a/yarn-project/end-to-end/tsconfig.json b/yarn-project/end-to-end/tsconfig.json index 0343efeec57c..23d03acc37f4 100644 --- a/yarn-project/end-to-end/tsconfig.json +++ b/yarn-project/end-to-end/tsconfig.json @@ -21,6 +21,9 @@ { "path": "../bb-prover" }, + { + "path": "../blob-lib" + }, { "path": "../blob-sink" }, diff --git a/yarn-project/ethereum/package.json b/yarn-project/ethereum/package.json index 6e313f4a018a..207d0f8b3833 100644 --- a/yarn-project/ethereum/package.json +++ b/yarn-project/ethereum/package.json @@ -32,6 +32,7 @@ "../package.common.json" ], "dependencies": { + "@aztec/blob-lib": "workspace:^", "@aztec/foundation": "workspace:^", "@aztec/l1-artifacts": "workspace:^", "@viem/anvil": "^0.0.10", diff --git a/yarn-project/ethereum/src/l1_tx_utils.test.ts b/yarn-project/ethereum/src/l1_tx_utils.test.ts index 8430fedd73b1..962001b430b5 100644 --- a/yarn-project/ethereum/src/l1_tx_utils.test.ts +++ b/yarn-project/ethereum/src/l1_tx_utils.test.ts @@ -1,4 +1,4 @@ -import { Blob } from '@aztec/foundation/blob'; +import { Blob } from '@aztec/blob-lib'; import { EthAddress } from '@aztec/foundation/eth-address'; import { createLogger } from '@aztec/foundation/log'; import { sleep } from '@aztec/foundation/sleep'; diff --git a/yarn-project/ethereum/src/l1_tx_utils_with_blobs.ts b/yarn-project/ethereum/src/l1_tx_utils_with_blobs.ts index 0f860e403cdd..a3932f575562 100644 --- a/yarn-project/ethereum/src/l1_tx_utils_with_blobs.ts +++ b/yarn-project/ethereum/src/l1_tx_utils_with_blobs.ts @@ -1,4 +1,4 @@ -import { Blob } from '@aztec/foundation/blob'; +import { Blob } from '@aztec/blob-lib'; import { formatGwei } from 'viem'; diff --git a/yarn-project/ethereum/tsconfig.json b/yarn-project/ethereum/tsconfig.json index b12e902b9463..19a1a3cb4ce6 100644 --- a/yarn-project/ethereum/tsconfig.json +++ b/yarn-project/ethereum/tsconfig.json @@ -7,6 +7,9 @@ }, "include": ["src"], "references": [ + { + "path": "../blob-lib" + }, { "path": "../foundation" }, diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index 8110aac88a9a..85573396351f 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -41,7 +41,6 @@ "./wasm": "./dest/wasm/index.js", "./worker": "./dest/worker/index.js", "./bigint-buffer": "./dest/bigint-buffer/index.js", - "./blob": "./dest/blob/index.js", "./types": "./dest/types/index.js", "./schemas": "./dest/schemas/index.js", "./url": "./dest/url/index.js", diff --git a/yarn-project/foundation/src/index.ts b/yarn-project/foundation/src/index.ts index e8a8348de1f0..78694f262f8f 100644 --- a/yarn-project/foundation/src/index.ts +++ b/yarn-project/foundation/src/index.ts @@ -3,7 +3,6 @@ export * as abi from './abi/index.js'; export * as asyncMap from './async-map/index.js'; export * as aztecAddress from './aztec-address/index.js'; export * as bigintBuffer from './bigint-buffer/index.js'; -export * as blob from './blob/index.js'; export * as collection from './collection/index.js'; export * as committable from './committable/index.js'; export * as crypto from './crypto/index.js'; diff --git a/yarn-project/noir-protocol-circuits-types/package.json b/yarn-project/noir-protocol-circuits-types/package.json index 1193df56f13f..0485a535db69 100644 --- a/yarn-project/noir-protocol-circuits-types/package.json +++ b/yarn-project/noir-protocol-circuits-types/package.json @@ -66,6 +66,7 @@ ] }, "dependencies": { + "@aztec/blob-lib": "workspace:^", "@aztec/circuits.js": "workspace:^", "@aztec/foundation": "workspace:^", "@aztec/types": "workspace:^", diff --git a/yarn-project/noir-protocol-circuits-types/src/utils/server/foreign_call_handler.ts b/yarn-project/noir-protocol-circuits-types/src/utils/server/foreign_call_handler.ts index 00ce35f286fa..854c4c042b63 100644 --- a/yarn-project/noir-protocol-circuits-types/src/utils/server/foreign_call_handler.ts +++ b/yarn-project/noir-protocol-circuits-types/src/utils/server/foreign_call_handler.ts @@ -1,6 +1,6 @@ +import { Blob } from '@aztec/blob-lib'; import { Fr } from '@aztec/circuits.js'; import { BlockBlobPublicInputs, SpongeBlob } from '@aztec/circuits.js/blobs'; -import { Blob } from '@aztec/foundation/blob'; import { applyStringFormatting, createLogger } from '@aztec/foundation/log'; import { type ForeignCallInput, type ForeignCallOutput } from '@noir-lang/acvm_js'; diff --git a/yarn-project/noir-protocol-circuits-types/tsconfig.json b/yarn-project/noir-protocol-circuits-types/tsconfig.json index 99be5d0c203a..15aef4138e7d 100644 --- a/yarn-project/noir-protocol-circuits-types/tsconfig.json +++ b/yarn-project/noir-protocol-circuits-types/tsconfig.json @@ -7,6 +7,9 @@ "resolveJsonModule": true }, "references": [ + { + "path": "../blob-lib" + }, { "path": "../circuits.js" }, diff --git a/yarn-project/package.json b/yarn-project/package.json index 946d3c46406c..94c7a77a1143 100644 --- a/yarn-project/package.json +++ b/yarn-project/package.json @@ -27,6 +27,7 @@ "validator-client", "bb-prover", "blob-sink", + "blob-lib", "bot", "builder", "pxe", diff --git a/yarn-project/prover-client/package.json b/yarn-project/prover-client/package.json index a57f7a06d1b1..06190f73f530 100644 --- a/yarn-project/prover-client/package.json +++ b/yarn-project/prover-client/package.json @@ -68,6 +68,7 @@ }, "dependencies": { "@aztec/bb-prover": "workspace:^", + "@aztec/blob-lib": "workspace:^", "@aztec/circuit-types": "workspace:^", "@aztec/circuits.js": "workspace:^", "@aztec/foundation": "workspace:^", diff --git a/yarn-project/prover-client/src/block_builder/light.test.ts b/yarn-project/prover-client/src/block_builder/light.test.ts index 8a149e9554da..36419e70e394 100644 --- a/yarn-project/prover-client/src/block_builder/light.test.ts +++ b/yarn-project/prover-client/src/block_builder/light.test.ts @@ -1,4 +1,5 @@ import { TestCircuitProver } from '@aztec/bb-prover'; +import { Blob } from '@aztec/blob-lib'; import { MerkleTreeId, type MerkleTreeWriteOperations, @@ -49,7 +50,6 @@ import { SingleTxBlockRootRollupInputs, } from '@aztec/circuits.js/rollup'; import { makeGlobalVariables } from '@aztec/circuits.js/testing'; -import { Blob } from '@aztec/foundation/blob'; import { padArrayEnd, times, timesParallel } from '@aztec/foundation/collection'; import { sha256ToField } from '@aztec/foundation/crypto'; import { type Logger, createLogger } from '@aztec/foundation/log'; diff --git a/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts b/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts index f4b93e2a6247..86970228f20f 100644 --- a/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts +++ b/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts @@ -1,3 +1,4 @@ +import { Blob } from '@aztec/blob-lib'; import { Body, MerkleTreeId, @@ -44,7 +45,6 @@ import { PublicBaseStateDiffHints, } from '@aztec/circuits.js/rollup'; import { makeTuple } from '@aztec/foundation/array'; -import { Blob } from '@aztec/foundation/blob'; import { padArrayEnd } from '@aztec/foundation/collection'; import { sha256Trunc } from '@aztec/foundation/crypto'; import { type Logger } from '@aztec/foundation/log'; diff --git a/yarn-project/prover-client/tsconfig.json b/yarn-project/prover-client/tsconfig.json index 50a340d09161..09e32edf21f3 100644 --- a/yarn-project/prover-client/tsconfig.json +++ b/yarn-project/prover-client/tsconfig.json @@ -9,6 +9,9 @@ { "path": "../bb-prover" }, + { + "path": "../blob-lib" + }, { "path": "../circuit-types" }, diff --git a/yarn-project/sequencer-client/package.json b/yarn-project/sequencer-client/package.json index 7e8ac6ebd593..a74193bf26c7 100644 --- a/yarn-project/sequencer-client/package.json +++ b/yarn-project/sequencer-client/package.json @@ -30,6 +30,7 @@ "dependencies": { "@aztec/aztec.js": "workspace:^", "@aztec/bb-prover": "workspace:^", + "@aztec/blob-lib": "workspace:^", "@aztec/blob-sink": "workspace:^", "@aztec/circuit-types": "workspace:^", "@aztec/circuits.js": "workspace:^", diff --git a/yarn-project/sequencer-client/src/publisher/sequencer-publisher.test.ts b/yarn-project/sequencer-client/src/publisher/sequencer-publisher.test.ts index 8dc52cb2b44a..81dd2e9bea88 100644 --- a/yarn-project/sequencer-client/src/publisher/sequencer-publisher.test.ts +++ b/yarn-project/sequencer-client/src/publisher/sequencer-publisher.test.ts @@ -1,3 +1,4 @@ +import { Blob } from '@aztec/blob-lib'; import { HttpBlobSinkClient } from '@aztec/blob-sink/client'; import { inboundTransform } from '@aztec/blob-sink/encoding'; import { L2Block } from '@aztec/circuit-types'; @@ -15,7 +16,6 @@ import { defaultL1TxUtilsConfig, getL1ContractsConfigEnvVars, } from '@aztec/ethereum'; -import { Blob } from '@aztec/foundation/blob'; import { sleep } from '@aztec/foundation/sleep'; import { EmpireBaseAbi, RollupAbi } from '@aztec/l1-artifacts'; diff --git a/yarn-project/sequencer-client/src/publisher/sequencer-publisher.ts b/yarn-project/sequencer-client/src/publisher/sequencer-publisher.ts index a806d0db0328..5842b1370a5d 100644 --- a/yarn-project/sequencer-client/src/publisher/sequencer-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/sequencer-publisher.ts @@ -1,3 +1,4 @@ +import { Blob } from '@aztec/blob-lib'; import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client'; import { ConsensusPayload, @@ -27,7 +28,6 @@ import { formatViemError, } from '@aztec/ethereum'; import { toHex } from '@aztec/foundation/bigint-buffer'; -import { Blob } from '@aztec/foundation/blob'; import { type Signature } from '@aztec/foundation/eth-signature'; import { createLogger } from '@aztec/foundation/log'; import { Timer } from '@aztec/foundation/timer'; diff --git a/yarn-project/sequencer-client/tsconfig.json b/yarn-project/sequencer-client/tsconfig.json index 02644b0fbec6..64c3377012ea 100644 --- a/yarn-project/sequencer-client/tsconfig.json +++ b/yarn-project/sequencer-client/tsconfig.json @@ -12,6 +12,9 @@ { "path": "../bb-prover" }, + { + "path": "../blob-lib" + }, { "path": "../blob-sink" }, diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 9dd5197d7f5a..5cc77649f10b 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -87,6 +87,7 @@ __metadata: version: 0.0.0-use.local resolution: "@aztec/archiver@workspace:archiver" dependencies: + "@aztec/blob-lib": "workspace:^" "@aztec/blob-sink": "workspace:^" "@aztec/circuit-types": "workspace:^" "@aztec/circuits.js": "workspace:^" @@ -368,10 +369,28 @@ __metadata: languageName: node linkType: soft +"@aztec/blob-lib@workspace:^, @aztec/blob-lib@workspace:blob-lib": + version: 0.0.0-use.local + resolution: "@aztec/blob-lib@workspace:blob-lib" + dependencies: + "@aztec/foundation": "workspace:^" + "@jest/globals": "npm:^29.5.0" + "@types/jest": "npm:^29.5.0" + "@types/node": "npm:^18.14.6" + c-kzg: "npm:4.0.0-alpha.1" + get-port: "npm:^7.1.0" + jest: "npm:^29.5.0" + ts-node: "npm:^10.9.1" + tslib: "npm:^2.4.0" + typescript: "npm:^5.0.4" + languageName: unknown + linkType: soft + "@aztec/blob-sink@workspace:^, @aztec/blob-sink@workspace:blob-sink": version: 0.0.0-use.local resolution: "@aztec/blob-sink@workspace:blob-sink" dependencies: + "@aztec/blob-lib": "workspace:^" "@aztec/circuit-types": "workspace:^" "@aztec/foundation": "workspace:^" "@aztec/kv-store": "workspace:*" @@ -477,6 +496,7 @@ __metadata: resolution: "@aztec/circuits.js@workspace:circuits.js" dependencies: "@aztec/bb.js": "portal:../../barretenberg/ts" + "@aztec/blob-lib": "workspace:^" "@aztec/ethereum": "workspace:^" "@aztec/foundation": "workspace:^" "@aztec/types": "workspace:^" @@ -592,6 +612,7 @@ __metadata: "@aztec/aztec-node": "workspace:^" "@aztec/aztec.js": "workspace:^" "@aztec/bb-prover": "workspace:^" + "@aztec/blob-lib": "workspace:^" "@aztec/blob-sink": "workspace:^" "@aztec/bot": "workspace:^" "@aztec/circuit-types": "workspace:^" @@ -711,6 +732,7 @@ __metadata: version: 0.0.0-use.local resolution: "@aztec/ethereum@workspace:ethereum" dependencies: + "@aztec/blob-lib": "workspace:^" "@aztec/foundation": "workspace:^" "@aztec/l1-artifacts": "workspace:^" "@jest/globals": "npm:^29.5.0" @@ -961,6 +983,7 @@ __metadata: version: 0.0.0-use.local resolution: "@aztec/noir-protocol-circuits-types@workspace:noir-protocol-circuits-types" dependencies: + "@aztec/blob-lib": "workspace:^" "@aztec/circuits.js": "workspace:^" "@aztec/foundation": "workspace:^" "@aztec/kv-store": "workspace:^" @@ -1108,6 +1131,7 @@ __metadata: resolution: "@aztec/prover-client@workspace:prover-client" dependencies: "@aztec/bb-prover": "workspace:^" + "@aztec/blob-lib": "workspace:^" "@aztec/circuit-types": "workspace:^" "@aztec/circuits.js": "workspace:^" "@aztec/foundation": "workspace:^" @@ -1243,6 +1267,7 @@ __metadata: "@aztec/archiver": "workspace:^" "@aztec/aztec.js": "workspace:^" "@aztec/bb-prover": "workspace:^" + "@aztec/blob-lib": "workspace:^" "@aztec/blob-sink": "workspace:^" "@aztec/circuit-types": "workspace:^" "@aztec/circuits.js": "workspace:^"