-
Notifications
You must be signed in to change notification settings - Fork 613
feat: blobs 2. #10188
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
Merged
Merged
feat: blobs 2. #10188
Changes from 23 commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
b4033be
Revert "fix: Revert "feat: blobs. (#9302)" (#10187)"
MirandaWood de14c32
chore: comments/renaming in Rollup.sol
MirandaWood b75a6f7
feat: give up and make blob oracle for simulation
MirandaWood 3391096
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 624c36d
fix: post merge fixes, fmt, fixtures
MirandaWood ccb82b2
chore: dummy change to fix ci runner
MirandaWood fe6fa68
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 64586d8
fix: do horrible things to reduce contract size
MirandaWood 21e8c3a
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 24f2f0e
chore: post merge fixes, add libs to gen contracts, comments
MirandaWood 566c2fc
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood fc03321
feat: integrate private logs, add blob oracle issue num, regen fixtur…
MirandaWood 5c5a655
chore: update proof fixture
MirandaWood 4bd1312
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood f5aac25
fix: revert merge changes, compile time down from 90 to 10 mins (#10341)
MirandaWood d4bf371
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 78ca2ab
chore: post merge fixes, fmt
MirandaWood 18a66b0
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood b14a892
chore: post merge fixes + update proof fixture
MirandaWood 25d5ba0
chore: some orch cleanup
MirandaWood a325000
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 933191b
chore: remake consts after merge
MirandaWood 64a4724
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 07449a3
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 5dd97e3
feat: redo blob publishing
MirandaWood 359758f
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 6c0a22a
feat: rearrange all blob l1 logic, replicate in ts
MirandaWood 681b53a
feat: add gas estimation for blob txs, cleanup contracts, increase he…
MirandaWood 1153bf8
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 8511d52
chore: typos, comments clarifications
MirandaWood ede52a6
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 4d927d2
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood c44e158
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 5506aa2
chore: fix bad noir merge formatting
MirandaWood f71874b
fix: change slot overrides after merge
MirandaWood 110692f
chore: update timeouts, comment, grab custom error from ext lib
MirandaWood 389a596
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood dff8962
chore: post merge formatting
MirandaWood a01595d
chore: add leolib abi to error handling
MirandaWood 9a89e75
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 5f5a10d
chore: inc test timeout after sync
MirandaWood c8c8758
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 03f4ce1
chore: inc timeout
MirandaWood 7fd775f
chore: increase! those! timeouts!
MirandaWood a9bfda5
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood ba713cd
chore: header -> block_header to match merge
MirandaWood 2daaa48
chore: guess what.
MirandaWood c6cde5d
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood ec0d50d
chore: fixture + comment out slower test
MirandaWood be805b6
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 09bcff3
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 949090f
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood a74377b
chore: remove some warnings from blob code
MirandaWood 426f376
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood dc2955f
chore: post merge formatting
MirandaWood aa3d368
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 728d784
chore: remake constants after merge
MirandaWood 0332bb8
fix: bad merge
MirandaWood 59148e2
chore: proof fixture
MirandaWood 76da0d4
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood e8685ac
feat: reduce the number unconstrained boundary hops in bloblib (#10603)
TomAFrench 7827a73
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood e6fc5b5
fix: add temp brillig skip to run CI
MirandaWood c423c90
chore: update prover.tomls, ensure block-root is populated
MirandaWood f420a79
chore: add brillig gates skip to earthfile
MirandaWood 36efe51
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 313c3d8
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 448187e
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood 436b7d6
chore: reenable test
MirandaWood f096e25
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood b8699a2
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright 2024 Aztec Labs. | ||
| pragma solidity >=0.8.27; | ||
|
|
||
| import {Hash} from "@aztec/core/libraries/crypto/Hash.sol"; | ||
| import {Errors} from "@aztec/core/libraries/Errors.sol"; | ||
| import {Vm} from "forge-std/Vm.sol"; | ||
|
|
||
| library BlobLib { | ||
| /** | ||
| * @notice Get the blob base fee | ||
| * | ||
| * @dev If we are in a foundry test, we use the cheatcode to get the blob base fee. | ||
| * Otherwise, we use the `block.blobbasefee` | ||
| * | ||
| * @return uint256 - The blob base fee | ||
| */ | ||
| function getBlobBaseFee(address _vmAddress) public view returns (uint256) { | ||
| if (_vmAddress.code.length > 0) { | ||
| return Vm(_vmAddress).getBlobBaseFee(); | ||
| } | ||
| return block.blobbasefee; | ||
| } | ||
|
|
||
| /** | ||
| * @notice Validate an L2 block's blobs and return the hashed blobHashes and public inputs. | ||
| * Input bytes: | ||
| * input[:1] - num blobs in block | ||
| * input[1:] - 192 * num blobs of the above _blobInput | ||
| * @dev Marked as public to reduce Rollup.sol contract size | ||
| * @param _blobsInput - The above bytes to verify a blob | ||
| */ | ||
| function validateBlobs(bytes calldata _blobsInput, bool _checkBlob) | ||
| public | ||
| view | ||
| returns (bytes32 blobsHash, bytes32 blobPublicInputsHash) | ||
| { | ||
| // We cannot input the incorrect number of blobs below, as the blobsHash | ||
| // and epoch proof verification will fail. | ||
| uint8 numBlobs = uint8(_blobsInput[0]); | ||
| bytes32[] memory blobHashes = new bytes32[](numBlobs); | ||
| bytes memory blobPublicInputs; | ||
| for (uint256 i = 0; i < numBlobs; i++) { | ||
| // Add 1 for the numBlobs prefix | ||
| uint256 blobInputStart = i * 192 + 1; | ||
| // Since an invalid blob hash here would fail the consensus checks of | ||
| // the header, the `blobInput` is implicitly accepted by consensus as well. | ||
| blobHashes[i] = validateBlob(_blobsInput[blobInputStart:blobInputStart + 192], i, _checkBlob); | ||
| // We want to extract the 112 bytes we use for public inputs: | ||
| // * input[32:64] - z | ||
| // * input[64:96] - y | ||
| // * input[96:144] - commitment C | ||
| // Out of 192 bytes per blob. | ||
| blobPublicInputs = | ||
| abi.encodePacked(blobPublicInputs, _blobsInput[blobInputStart + 32:blobInputStart + 144]); | ||
| } | ||
| // Return the hash of all z, y, and Cs, so we can use them in proof verification later | ||
| blobPublicInputsHash = sha256(blobPublicInputs); | ||
| // Hash the EVM blob hashes for the block header | ||
| blobsHash = Hash.sha256ToField(abi.encodePacked(blobHashes)); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Validate a blob. | ||
| * Input bytes: | ||
| * input[:32] - versioned_hash | ||
| * input[32:64] - z | ||
| * input[64:96] - y | ||
| * input[96:144] - commitment C | ||
| * input[144:192] - proof (a commitment to the quotient polynomial q(X)) | ||
| * - This can be relaxed to happen at the time of `submitProof` instead | ||
| * @notice Apparently there is no guarantee that the blobs will be processed in the order sent | ||
| * so the use of blobhash(_blobNumber) may fail in production | ||
| * @param _blobInput - The above bytes to verify a blob | ||
| */ | ||
| function validateBlob(bytes calldata _blobInput, uint256 _blobNumber, bool _checkBlob) | ||
| internal | ||
| view | ||
| returns (bytes32 blobHash) | ||
| { | ||
| if (!_checkBlob) { | ||
| return bytes32(_blobInput[0:32]); | ||
| } | ||
| assembly { | ||
| blobHash := blobhash(_blobNumber) | ||
| } | ||
| require(blobHash == bytes32(_blobInput[0:32]), Errors.Rollup__InvalidBlobHash(blobHash)); | ||
|
|
||
| // Staticcall the point eval precompile https://eips.ethereum.org/EIPS/eip-4844#point-evaluation-precompile : | ||
| (bool success,) = address(0x0a).staticcall(_blobInput); | ||
| require(success, Errors.Rollup__InvalidBlobProof(blobHash)); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Converts a BLS12 field element from bytes32 to a nr BigNum type | ||
| * The nr bignum type for BLS12 fields is encoded as 3 nr fields - see blob_public_inputs.ts: | ||
| * firstLimb = last 15 bytes; | ||
| * secondLimb = bytes 2 -> 17; | ||
| * thirdLimb = first 2 bytes; | ||
| * Used when verifying epoch proofs to gather blob specific public inputs. | ||
| * @param _input - The field in bytes32 | ||
| */ | ||
| function bytes32ToBigNum(bytes32 _input) | ||
| internal | ||
| pure | ||
| returns (bytes32 firstLimb, bytes32 secondLimb, bytes32 thirdLimb) | ||
| { | ||
| firstLimb = bytes32(uint256(uint120(bytes15(_input << 136)))); | ||
| secondLimb = bytes32(uint256(uint120(bytes15(_input << 16)))); | ||
| thirdLimb = bytes32(uint256(uint16(bytes2(_input)))); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.