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

Synclayer Batch Aggregation #470

Open
wants to merge 18 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 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
12 changes: 12 additions & 0 deletions l1-contracts/contracts/common/interfaces/IBatchAggregator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.24;

interface IBatchAggregator {
function commitBatch(
bytes calldata _totalL2ToL1PubdataAndStateDiffs,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need to send both compressed diffs and their uncompressed version? I think we should decide on what we want. I would rather send only uncompressed ones

uint256 chainId,
uint256 batchNumber
) external;
function returnBatchesAndClearState() external returns (bytes memory);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import {UnsafeBytes} from "../../../common/libraries/UnsafeBytes.sol";
import {L2_BOOTLOADER_ADDRESS, L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, L2_SYSTEM_CONTEXT_SYSTEM_CONTRACT_ADDR, L2_PUBDATA_CHUNK_PUBLISHER_ADDR} from "../../../common/L2ContractAddresses.sol";
import {PubdataPricingMode} from "../ZkSyncHyperchainStorage.sol";
import {IStateTransitionManager} from "../../IStateTransitionManager.sol";
import {IBatchAggregator} from "../../../common/interfaces/IBatchAggregator.sol";

// TODO: replace with actual system address
address constant BATCH_AGGREGATOR_ADDRESS = 0x0000000000000000000000000000000000009012;

// While formally the following import is not used, it is needed to inherit documentation from it
import {IZkSyncHyperchainBase} from "../../chain-interfaces/IZkSyncHyperchainBase.sol";
Expand All @@ -32,7 +36,7 @@ contract ExecutorFacet is ZkSyncHyperchainBase, IExecutor {
StoredBatchInfo memory _previousBatch,
CommitBatchInfo calldata _newBatch,
bytes32 _expectedSystemContractUpgradeTxHash
) internal view returns (StoredBatchInfo memory) {
) internal returns (StoredBatchInfo memory) {
require(_newBatch.batchNumber == _previousBatch.batchNumber + 1, "f"); // only commit next batch

uint8 pubdataSource = uint8(bytes1(_newBatch.pubdataCommitments[0]));
Expand Down Expand Up @@ -69,6 +73,14 @@ contract ExecutorFacet is ZkSyncHyperchainBase, IExecutor {
.pubdataCommitments
.length]
);
} else if (pubdataSource == uint8(PubdataSource.ForwardedMessage)) {
// Similar to Calldata, forwards packed pubdataCommitments of hyperchains to the lower layer
// Add batch to BatchAggregator
IBatchAggregator(BATCH_AGGREGATOR_ADDRESS).commitBatch(
_newBatch.pubdataCommitments,
s.chainId,
_newBatch.batchNumber
);
}

require(_previousBatch.batchHash == logOutput.previousBatchHash, "l");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ enum SystemLogKey {
/// @dev Enum used to determine the source of pubdata. At first we will support calldata and blobs but this can be extended.
enum PubdataSource {
Calldata,
Blob
Blob,
ForwardedMessage
}

struct LogProcessingOutput {
Expand Down
Loading
Loading