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

feat: blobs. #9302

Merged
merged 90 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
d2544a9
feat: first blobs commit - ts + nr only - overflow err
MirandaWood Sep 25, 2024
9cefc9a
feat: hash blob in chunks, force native sim for block-root
MirandaWood Sep 27, 2024
df93cf5
feat: add ts blob class, use real blob in rollup, more tests
MirandaWood Oct 2, 2024
c5539eb
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Oct 4, 2024
5e92023
feat: post merge fixes, add sponge to epoch prover, cleanup
MirandaWood Oct 4, 2024
1d17855
fix: more merge fixes + cleanup
MirandaWood Oct 4, 2024
aff5e35
feat: purge txseffectshash from nr and ts
MirandaWood Oct 7, 2024
dfe722b
feat: publish blobs to L1, verify, test, a lot of cleanup
MirandaWood Oct 11, 2024
bc0678c
chore: fmt, test refactors + fixes
MirandaWood Oct 21, 2024
ad090f6
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Oct 21, 2024
bf98bbc
fix: multiple post merge fixes, refactor err logging, prover-coord te…
MirandaWood Oct 24, 2024
2cd7570
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Oct 24, 2024
8a8dcab
feat: reinstate bignum code after fix, post merge fixes and fmt
MirandaWood Oct 24, 2024
cc01696
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Oct 24, 2024
6f92b1f
chore: revert e2e prover coord fix in favour of master
MirandaWood Oct 24, 2024
233d3fd
feat: added custom existing sponge absorber to save gates, fmt
MirandaWood Oct 25, 2024
7c1749d
feat: tightly pack blobs, encode and decode with prefixes
MirandaWood Oct 29, 2024
247a49d
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Oct 29, 2024
8f3d10f
chore: post merge fixes, formatting
MirandaWood Oct 31, 2024
20674cf
fix: apply fix for public processor state (PR9634)
MirandaWood Nov 1, 2024
38725f8
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 1, 2024
77dcf8e
chore: update fixtures + fmt
MirandaWood Nov 1, 2024
580b1b2
feat: add blob check override, simulate txs
MirandaWood Nov 4, 2024
2166780
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 4, 2024
99ac96e
feat: update bignum, fmt, comments, small fixes
MirandaWood Nov 5, 2024
43bb5f0
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 5, 2024
88733fe
chore: post merge fix
MirandaWood Nov 5, 2024
37f7af4
chore: fix viem kzg (ty Mike), cleanup
MirandaWood Nov 6, 2024
9bb2c21
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 6, 2024
c667c50
feat: added total len to encoding, comments, tests, fmt
MirandaWood Nov 6, 2024
3a7a997
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 6, 2024
225ba00
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 6, 2024
27d839e
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 6, 2024
f241744
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 6, 2024
9c4c4da
chore: remove unused body calldata variable name
MirandaWood Nov 6, 2024
6cbab7e
chore: update hardcoded test val
MirandaWood Nov 6, 2024
deeb044
Update ci.yml
ludamad Nov 6, 2024
afe79e0
chore: cleanup, fmt
MirandaWood Nov 7, 2024
38796a0
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 7, 2024
e80ff6e
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 7, 2024
4c2477f
feat: address some comments
MirandaWood Nov 7, 2024
5dbd06c
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 7, 2024
899eea0
chore: post merge fixes, fmt
MirandaWood Nov 8, 2024
a662fe4
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 8, 2024
5b80e50
chore: post merge fixes, fmt
MirandaWood Nov 8, 2024
079aef8
feat: add blob hash to header
MirandaWood Nov 8, 2024
23092c6
chore: cleanup, remove unused tat
MirandaWood Nov 8, 2024
ad7bb09
refactor: block builders now add all txs at once
MirandaWood Nov 8, 2024
fd6b875
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 8, 2024
a367e6f
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 11, 2024
5e506ce
chore: post merge fixes, fmt, fixtures
MirandaWood Nov 11, 2024
a418c58
feat: delete neg_roots constants, calc instead, small runtime gains
MirandaWood Nov 11, 2024
c06c2ef
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 11, 2024
46d2b3d
feat: save some gates in sponge absorbing
MirandaWood Nov 12, 2024
3969035
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 12, 2024
f4267c5
chore: post merge fixes, fmt, fxitures
MirandaWood Nov 12, 2024
0e9b2c8
feat: save more gates
MirandaWood Nov 12, 2024
96157d0
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 12, 2024
fcbc6ce
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 13, 2024
bcf452e
chore: update constants post merge
MirandaWood Nov 13, 2024
9a67624
chore: rename tofields -> toBlobFields, remove unused code
MirandaWood Nov 13, 2024
76ccac1
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 14, 2024
526b4c6
chore: include contract class logs in blob, some renaming
MirandaWood Nov 14, 2024
862b1b2
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 15, 2024
3d46ec1
Merge remote-tracking branch 'origin' into mw/blob-circuit
MirandaWood Nov 16, 2024
f7cd700
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 18, 2024
512d1b0
feat: 1 blob -> 3 blobs (#10014)
MirandaWood Nov 19, 2024
222b5ae
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 19, 2024
1301c39
chore: make skipBlobCheck shared in sol tests
MirandaWood Nov 19, 2024
03cc903
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 19, 2024
2f7bfd6
chore: remove unec. conversion
MirandaWood Nov 19, 2024
3da7258
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 19, 2024
081f351
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 19, 2024
574f363
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 20, 2024
a7f4080
chore: post merge fixes + fmt
MirandaWood Nov 20, 2024
8b0c9c4
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 20, 2024
16e86b5
chore: post merge fixes, replay base rollup changes
MirandaWood Nov 20, 2024
b2d563d
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 20, 2024
b3b769a
fix: replace c-kzg so browser works (temp sol)
MirandaWood Nov 21, 2024
b6cac9f
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 21, 2024
21d23f3
chore: increase timeouts + fmt
MirandaWood Nov 21, 2024
893f1ec
feat: add back c-kzg (otherwise v slow), remove fns for browser
MirandaWood Nov 21, 2024
02abb31
chore: revert some timeouts, re add test
MirandaWood Nov 22, 2024
c78d8ec
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 22, 2024
20ef3c1
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 22, 2024
20e44cc
feat: address comments, renaming etc
MirandaWood Nov 22, 2024
e66454d
feat: remove txsdecoder
MirandaWood Nov 22, 2024
6b82d25
Merge remote-tracking branch 'origin/master' into mw/blob-circuit
MirandaWood Nov 22, 2024
b787de6
chore: post merge fix w/ sequencer changes
MirandaWood Nov 22, 2024
f76eaf6
chore: disable e2e_epoch due to teardown timeout
MirandaWood Nov 25, 2024
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
10 changes: 5 additions & 5 deletions barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define GAS_FEES_LENGTH 2
#define GAS_LENGTH 2
#define CALL_CONTEXT_LENGTH 5
#define CONTENT_COMMITMENT_LENGTH 4
#define CONTENT_COMMITMENT_LENGTH 3
#define CONTRACT_STORAGE_READ_LENGTH 3
#define CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH 3
#define GLOBAL_VARIABLES_LENGTH 9
Expand All @@ -31,13 +31,13 @@
#define PUBLIC_INNER_CALL_REQUEST_LENGTH 14
#define STATE_REFERENCE_LENGTH 8
#define TOTAL_FEES_LENGTH 1
#define HEADER_LENGTH 24
#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 691
#define PUBLIC_CONTEXT_INPUTS_LENGTH 42
#define HEADER_LENGTH 23
#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 690
#define PUBLIC_CONTEXT_INPUTS_LENGTH 41
#define AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS 86
#define AVM_PROOF_LENGTH_IN_FIELDS 3848
#define AVM_PUBLIC_COLUMN_MAX_SIZE 1024
#define AVM_PUBLIC_INPUTS_FLATTENED_SIZE 2739
#define AVM_PUBLIC_INPUTS_FLATTENED_SIZE 2738
#define MEM_TAG_FF 0
#define MEM_TAG_U1 1
#define MEM_TAG_U8 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,6 @@ bb::fr WorldState::compute_initial_archive(const StateReference& initial_state_r
0,
0,
0,
0,
// state reference - the initial state for all the trees (accept the archive tree)
initial_state_ref.at(MerkleTreeId::L1_TO_L2_MESSAGE_TREE).first,
initial_state_ref.at(MerkleTreeId::L1_TO_L2_MESSAGE_TREE).second,
Expand Down
1 change: 1 addition & 0 deletions l1-contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ src = 'src'
out = 'out'
libs = ['lib']
solc = "0.8.27"
evm_version = 'Cancun'

remappings = [
"@oz/=lib/openzeppelin-contracts/contracts/",
Expand Down
121 changes: 107 additions & 14 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
struct BlockLog {
bytes32 archive;
bytes32 blockHash;
// TODO(Miranda): Is this the best place to store some blob info?
MirandaWood marked this conversation as resolved.
Show resolved Hide resolved
bytes32 blobHash;
Slot slotNumber;
}

Expand Down Expand Up @@ -76,6 +78,17 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
// More direct approach would be storing keccak256(header) as well
mapping(uint256 blockNumber => BlockLog log) public blocks;

// TODO(Miranda): Below are temp solutions to get blobs working.
// Blob public inputs are stored when we publish blocks to link DA to a L1 blob. They are read and used
// when verifying an epoch proof to link DA to our L2 blocks.
struct BlobPublicInputs {
bytes32 z;
bytes32 y;
bytes32[2] c;
}

mapping(uint256 blockNumber => BlobPublicInputs) public blobPublicInputs;
MirandaWood marked this conversation as resolved.
Show resolved Hide resolved

bytes32 public vkTreeRoot;
bytes32 public protocolContractTreeRoot;

Expand Down Expand Up @@ -104,6 +117,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
blocks[0] = BlockLog({
archive: bytes32(Constants.GENESIS_ARCHIVE_ROOT),
blockHash: bytes32(0), // TODO(palla/prover): The first block does not have hash zero
blobHash: bytes32(0), // TODO(Miranda): think about whether having 0 here is insecure
slotNumber: Slot.wrap(0)
});
for (uint256 i = 0; i < _validators.length; i++) {
Expand Down Expand Up @@ -208,7 +222,9 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
* @param _archive - A root of the archive tree after the L2 block is applied
* @param _blockHash - The poseidon2 hash of the header added to the archive tree in the rollup circuit
* @param _signatures - Signatures from the validators
* // TODO(#9101): The below _body should be removed once we can extract blobs. It's only here so the archiver can extract tx effects.
* @param _body - The body of the L2 block
* @param blobInput - The blob evaluation KZG proof, challenge, and opening required for the precompile.
*/
function proposeAndClaim(
bytes calldata _header,
Expand All @@ -217,9 +233,10 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
bytes32[] memory _txHashes,
SignatureLib.Signature[] memory _signatures,
bytes calldata _body,
bytes calldata blobInput,
EpochProofQuoteLib.SignedEpochProofQuote calldata _quote
) external override(IRollup) {
propose(_header, _archive, _blockHash, _txHashes, _signatures, _body);
propose(_header, _archive, _blockHash, _txHashes, _signatures, _body, blobInput);
claimEpochProofRight(_quote);
}

Expand Down Expand Up @@ -272,6 +289,11 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
}
}

for (uint256 i = 0; i < _epochSize; i++) {
// free up gas (hopefully)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you are submitting the proof in the same transaction as you set the values originally you will be paying extra to do this. Cleaning it here is essentially doing like gas-tokens did back in the days before pricing was changed.
Would remove.

delete blobPublicInputs[previousBlockNumber + i + 1];
}

emit L2ProofVerified(endBlockNumber, _args[6]);
}

Expand Down Expand Up @@ -348,11 +370,10 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
SignatureLib.Signature[] memory _signatures,
bytes32 _digest,
Timestamp _currentTime,
bytes32 _txsEffectsHash,
MirandaWood marked this conversation as resolved.
Show resolved Hide resolved
DataStructures.ExecutionFlags memory _flags
) external view override(IRollup) {
HeaderLib.Header memory header = HeaderLib.decode(_header);
_validateHeader(header, _signatures, _digest, _currentTime, _txsEffectsHash, _flags);
_validateHeader(header, _signatures, _digest, _currentTime, _flags);
}

function nextEpochToClaim() external view override(IRollup) returns (Epoch) {
Expand Down Expand Up @@ -407,20 +428,25 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
* @param _archive - A root of the archive tree after the L2 block is applied
* @param _blockHash - The poseidon2 hash of the header added to the archive tree in the rollup circuit
* @param _signatures - Signatures from the validators
* // TODO(#9101): The below _body should be removed once we can extract blobs. It's only here so the archiver can extract tx effects.
* @param _body - The body of the L2 block
* @param blobInput - The blob evaluation KZG proof, challenge, and opening required for the precompile.
*/
function propose(
bytes calldata _header,
bytes32 _archive,
bytes32 _blockHash,
bytes32[] memory _txHashes,
SignatureLib.Signature[] memory _signatures,
bytes calldata _body
// TODO(#9101): Extract blobs from beacon chain => remove below body input
bytes calldata _body,
bytes calldata blobInput
) public override(IRollup) {
if (_canPrune()) {
_prune();
}
bytes32 txsEffectsHash = TxsDecoder.decode(_body);

bytes32 blobHash = _validateBlob(blobInput);
MirandaWood marked this conversation as resolved.
Show resolved Hide resolved

// Decode and validate header
HeaderLib.Header memory header = HeaderLib.decode(_header);
Expand All @@ -432,7 +458,6 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
_signatures: _signatures,
_digest: digest,
_currentTime: Timestamp.wrap(block.timestamp),
_txEffectsHash: txsEffectsHash,
_flags: DataStructures.ExecutionFlags({ignoreDA: false, ignoreSignatures: false})
});

Expand All @@ -441,9 +466,25 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
blocks[blockNumber] = BlockLog({
archive: _archive,
blockHash: _blockHash,
blobHash: blobHash,
MirandaWood marked this conversation as resolved.
Show resolved Hide resolved
slotNumber: Slot.wrap(header.globalVariables.slotNumber)
});

// Blob public inputs structure:
// * input[32:64] - z
// * input[64:96] - y
// * input[96:144] - commitment C
blobPublicInputs[blockNumber] = BlobPublicInputs({
z: bytes32(blobInput[32:64]),
y: bytes32(blobInput[64:96]),
// To fit into 2 fields, the commitment is split into 31 and 17 byte numbers
// I don't know best to left pad, sorry, am tired
c: [
bytes32(uint256(uint248(bytes31(blobInput[96:127])))),
bytes32(uint256(uint136(bytes17(blobInput[127:144]))))
]
});

// @note The block number here will always be >=1 as the genesis block is at 0
bytes32 inHash = INBOX.consume(blockNumber);
require(
Expand Down Expand Up @@ -550,7 +591,8 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
// fees: [FeeRecipient; Constants.AZTEC_EPOCH_DURATION],
// vk_tree_root: Field,
// protocol_contract_tree_root: Field,
// prover_id: Field
// prover_id: Field,
// blob_public_inputs: [BlobPublicInputs; Constants.AZTEC_EPOCH_DURATION], // <--This will be reduced to 1 if/when we implement multi-opening for blob verification
// }

// previous_archive.root: the previous archive tree root
Expand Down Expand Up @@ -598,6 +640,16 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
// prover_id: id of current epoch's prover
publicInputs[feesEnd + 2] = _args[6];

// blob_public_inputs
for (uint256 i = 0; i < Constants.AZTEC_EPOCH_DURATION; i++) {
uint256 j = feesEnd + 3 + i * 6;
publicInputs[j] = blobPublicInputs[previousBlockNumber + i + 1].z;
(publicInputs[j + 1], publicInputs[j + 2], publicInputs[j + 3]) =
bytes32ToBigNum(blobPublicInputs[previousBlockNumber + i + 1].y);
publicInputs[j + 4] = blobPublicInputs[previousBlockNumber + i + 1].c[0];
publicInputs[j + 5] = blobPublicInputs[previousBlockNumber + i + 1].c[1];
}

// the block proof is recursive, which means it comes with an aggregation object
// this snippet copies it into the public inputs needed for verification
// it also guards against empty _aggregationObject used with mocked proofs
Expand All @@ -607,7 +659,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
assembly {
part := calldataload(add(_aggregationObject.offset, mul(i, 32)))
}
publicInputs[i + feesEnd + 3] = part;
publicInputs[i + Constants.ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH] = part;
}

return publicInputs;
Expand Down Expand Up @@ -777,10 +829,9 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
SignatureLib.Signature[] memory _signatures,
bytes32 _digest,
Timestamp _currentTime,
bytes32 _txEffectsHash,
DataStructures.ExecutionFlags memory _flags
) internal view {
_validateHeaderForSubmissionBase(_header, _currentTime, _txEffectsHash, _flags);
_validateHeaderForSubmissionBase(_header, _currentTime, _flags);
_validateHeaderForSubmissionSequencerSelection(
Slot.wrap(_header.globalVariables.slotNumber), _signatures, _digest, _currentTime, _flags
);
Expand Down Expand Up @@ -837,15 +888,14 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
* - The last archive root in the header MUST match the current archive
* - The slot MUST be larger than the slot of the previous block (ensures single block per slot)
* - The timestamp MUST be equal to GENESIS_TIME + slot * SLOT_DURATION
* - The `txsEffectsHash` of the header must match the computed `_txsEffectsHash`
* - The `blobHash` of the block must match the computed `_blobHash`
* - This can be relaxed to happen at the time of `submitProof` instead
*
* @param _header - The header to validate
*/
function _validateHeaderForSubmissionBase(
HeaderLib.Header memory _header,
Timestamp _currentTime,
MirandaWood marked this conversation as resolved.
Show resolved Hide resolved
bytes32 _txsEffectsHash,
DataStructures.ExecutionFlags memory _flags
) internal view {
require(
Expand Down Expand Up @@ -890,9 +940,52 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
require(timestamp <= _currentTime, Errors.Rollup__TimestampInFuture(_currentTime, timestamp));

// Check if the data is available
// TODO(Miranda): either add blobhash to the header or find a way of validating it here
MirandaWood marked this conversation as resolved.
Show resolved Hide resolved
require(
_flags.ignoreDA || _header.contentCommitment.txsEffectsHash == _txsEffectsHash,
Errors.Rollup__UnavailableTxs(_header.contentCommitment.txsEffectsHash)
_flags.ignoreDA || 1 == 1, // _header.blobHash == _blobHash,
MirandaWood marked this conversation as resolved.
Show resolved Hide resolved
Errors.Rollup__UnavailableTxs(bytes32(_header.globalVariables.blockNumber))
);
}

/**
* @notice Validate an L2 block's blob. TODO: edit for multiple blobs per block
* 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
*
* @param blobInput - The above bytes to verify a blob
*/
function _validateBlob(bytes calldata blobInput) internal view returns (bytes32 blobHash) {
assembly {
blobHash := blobhash(0)
}
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 public inputs.
* @param input - The field in bytes32
*/
function bytes32ToBigNum(bytes32 input)
MirandaWood marked this conversation as resolved.
Show resolved Hide resolved
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))));
}
}
5 changes: 3 additions & 2 deletions l1-contracts/src/core/interfaces/IRollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ interface IRollup {
bytes32 _blockHash,
bytes32[] memory _txHashes,
SignatureLib.Signature[] memory _signatures,
bytes calldata _body
bytes calldata _body,
bytes calldata blobInput
) external;

function proposeAndClaim(
Expand All @@ -50,6 +51,7 @@ interface IRollup {
bytes32[] memory _txHashes,
SignatureLib.Signature[] memory _signatures,
bytes calldata _body,
bytes calldata blobInput,
EpochProofQuoteLib.SignedEpochProofQuote calldata _quote
) external;

Expand All @@ -68,7 +70,6 @@ interface IRollup {
SignatureLib.Signature[] memory _signatures,
bytes32 _digest,
Timestamp _currentTime,
bytes32 _txsEffecstHash,
DataStructures.ExecutionFlags memory _flags
) external view;

Expand Down
Loading