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

handle invalid blob type #161

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 23 additions & 2 deletions src/blob-inner/blob-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,13 @@ module.exports = class BlobProcessor {
* Execute Blob
*/
async execute() {
// check blob type
this._checkBlobType();

// build blobData
this._buildBlobData();
if (this.isInvalid === false) {
this._buildBlobData();
}

// check forced batches
if (this.isInvalid === false) {
Expand All @@ -177,6 +182,17 @@ module.exports = class BlobProcessor {
this.builded = true;
}

_checkBlobType() {
if (this.blobType !== blobConstants.BLOB_TYPE.CALLDATA
&& this.blobType !== blobConstants.BLOB_TYPE.EIP4844
&& this.blobType !== blobConstants.BLOB_TYPE.FORCED) {
if (this.addingBatchData === true) {
throw new Error('BlobProcessor:executeBlob: invalid blob type not compatible with batch data');
}
this.isInvalid = true;
}
}

_buildBlobData() {
if (this.addingBatchData === true) {
this.blobData = computeBlobDataFromBatches(this.batches, this.blobType);
Expand Down Expand Up @@ -240,7 +256,12 @@ module.exports = class BlobProcessor {
this.pointZ = await computePointZ(this.blobData);
this.pointY = await computePointY(this.blobData, this.pointZ);
} else {
throw new Error('BlobProcessor:executeBlob: invalid blob type');
// enter here only if blobType is invalid. Hence, blobData has been added previously
// blobL2HashData not used
this.blobL2HashData = Constants.ZERO_BYTES32;
// compute points
this.pointZ = await computePointZ(this.blobData);
this.pointY = await computePointY(this.blobData, this.pointZ);
}

this.newBlobAccInputHash = computeBlobAccInputHash(
Expand Down
34 changes: 34 additions & 0 deletions test/helpers/test-vectors/blob-inner/blob-inner-data.json

Large diffs are not rendered by default.