Skip to content
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
466 changes: 233 additions & 233 deletions AllContractsHashes.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ error InvalidBuiltInContractMessage(uint256 logCount, uint256 msgCount, bytes32
error InvalidCanonicalTxHash(bytes32);
// 0x05208b6d
error InvalidChainMigrationNumber(uint256, uint256);
// 0x24ef4f8a
error InvalidEmptyMessageRoot(bytes32 expectedMessageRoot, bytes32 providedMessageRoot);
// 0xe0c8f0c6
error InvalidEmptyMultichainBatchRoot(bytes32 expectedMultichainBatchRoot, bytes32 providedMultichainBatchRoot);
// 0x768dc598
error InvalidFeeRecipient();
// 0x532a43fc
Expand Down
28 changes: 14 additions & 14 deletions l1-contracts/contracts/bridge/asset-tracker/GWAssetTracker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import {
InvalidInteropChainId,
InvalidL2ShardId,
InvalidServiceLog,
InvalidEmptyMessageRoot,
InvalidEmptyMultichainBatchRoot,
RegisterNewTokenNotAllowed,
InvalidFeeRecipient,
SettlementFeePayerNotAgreed
Expand Down Expand Up @@ -114,8 +114,8 @@ contract GWAssetTracker is AssetTrackerBase, IGWAssetTracker {
/// On such chains, it is responsible for sending withdrawal messages.
mapping(uint256 chainId => address legacySharedBridgeAddress) internal legacySharedBridgeAddress;

/// @notice Empty messageRoot calculated for specific chain.
mapping(uint256 chainId => bytes32 emptyMessageRoot) internal emptyMessageRoot;
/// @notice Empty multichainBatchRoot calculated for specific chain.
mapping(uint256 chainId => bytes32 emptyMultichainBatchRoot) internal emptyMultichainBatchRoot;

/// @notice Gateway settlement fee per interop operation in ZK tokens.
/// @dev Set by gateway governance, paid by chain operators during settlement.
Expand Down Expand Up @@ -355,12 +355,12 @@ contract GWAssetTracker is AssetTrackerBase, IGWAssetTracker {
reconstructedLogsTree.extendUntilEnd();
bytes32 localLogsRootHash = reconstructedLogsTree.root();

bytes32 emptyMessageRootForChain = _getEmptyMessageRoot(_processLogsInputs.chainId);
bytes32 expectedEmptyMultichainBatchRoot = _getEmptyMultichainBatchRoot(_processLogsInputs.chainId);
require(
_processLogsInputs.messageRoot == emptyMessageRootForChain,
InvalidEmptyMessageRoot(emptyMessageRootForChain, _processLogsInputs.messageRoot)
_processLogsInputs.multichainBatchRoot == expectedEmptyMultichainBatchRoot,
InvalidEmptyMultichainBatchRoot(expectedEmptyMultichainBatchRoot, _processLogsInputs.multichainBatchRoot)
);
bytes32 chainBatchRootHash = keccak256(bytes.concat(localLogsRootHash, _processLogsInputs.messageRoot));
bytes32 chainBatchRootHash = keccak256(bytes.concat(localLogsRootHash, _processLogsInputs.multichainBatchRoot));

if (chainBatchRootHash != _processLogsInputs.chainBatchRoot) {
revert ReconstructionMismatch(chainBatchRootHash, _processLogsInputs.chainBatchRoot);
Expand Down Expand Up @@ -420,10 +420,10 @@ contract GWAssetTracker is AssetTrackerBase, IGWAssetTracker {
emit GatewaySettlementFeesCollected(_chainId, _settlementFeePayer, totalFee, _chargeableInteropCount);
}

function _getEmptyMessageRoot(uint256 _chainId) internal returns (bytes32) {
bytes32 savedEmptyMessageRoot = emptyMessageRoot[_chainId];
if (savedEmptyMessageRoot != bytes32(0)) {
return savedEmptyMessageRoot;
function _getEmptyMultichainBatchRoot(uint256 _chainId) internal returns (bytes32) {
bytes32 savedEmptyMultichainBatchRoot = emptyMultichainBatchRoot[_chainId];
if (savedEmptyMultichainBatchRoot != bytes32(0)) {
return savedEmptyMultichainBatchRoot;
}
FullMerkleMemory.FullTree memory sharedTree;
sharedTree.createTree(1);
Expand All @@ -434,10 +434,10 @@ contract GWAssetTracker is AssetTrackerBase, IGWAssetTracker {
chainTree.createTree(1);
bytes32 initialChainTreeHash = chainTree.setup(CHAIN_TREE_EMPTY_ENTRY_HASH);
bytes32 leafHash = MessageHashing.chainIdLeafHash(initialChainTreeHash, _chainId);
bytes32 emptyMessageRootCalculated = sharedTree.pushNewLeaf(leafHash);
bytes32 emptyMultichainBatchRootCalculated = sharedTree.pushNewLeaf(leafHash);

emptyMessageRoot[_chainId] = emptyMessageRootCalculated;
return emptyMessageRootCalculated;
emptyMultichainBatchRoot[_chainId] = emptyMultichainBatchRootCalculated;
return emptyMultichainBatchRootCalculated;
}

/// @notice Handles potential failed deposits. Not all L1->L2 txs are deposits.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ contract ExecutorFacet is ZKChainBase, IExecutor {
InteropRoot[][] memory dependencyRoots,
L2Log[][] memory logs,
bytes[][] memory messages,
bytes32[] memory messageRoots,
bytes32[] memory multichainBatchRoots,
address settlementFeePayer
) = BatchDecoder.decodeAndCheckExecuteData(_executeData, _processFrom, _processTo);
uint256 nBatches = batchesData.length;
Expand All @@ -177,12 +177,17 @@ contract ExecutorFacet is ZKChainBase, IExecutor {
if (block.chainid == L1_CHAIN_ID) {
require(logs.length == 0, InvalidBatchesDataLength(0, logs.length));
require(messages.length == 0, InvalidBatchesDataLength(0, messages.length));
require(multichainBatchRoots.length == 0, InvalidBatchesDataLength(0, multichainBatchRoots.length));
} else {
require(batchesData.length == logs.length, InvalidBatchesDataLength(batchesData.length, logs.length));
require(
batchesData.length == messages.length,
InvalidBatchesDataLength(batchesData.length, messages.length)
);
require(
batchesData.length == multichainBatchRoots.length,
InvalidBatchesDataLength(batchesData.length, multichainBatchRoots.length)
);
}

// Interop is only allowed on GW currently, so we go through the Asset Tracker when on Gateway.
Expand All @@ -197,7 +202,7 @@ contract ExecutorFacet is ZKChainBase, IExecutor {
chainId: s.chainId,
batchNumber: batchesData[i].batchNumber,
chainBatchRoot: batchesData[i].l2LogsTreeRoot,
messageRoot: messageRoots[i],
multichainBatchRoot: multichainBatchRoots[i],
settlementFeePayer: settlementFeePayer
});
GW_ASSET_TRACKER.processLogsAndMessages(processLogsInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ uint256 constant MAX_LOG_KEY = uint256(type(SystemLogKey).max);
/// @param chainId The chain ID of the settling chain.
/// @param batchNumber The batch number being processed.
/// @param chainBatchRoot The batch root hash for verification.
/// @param messageRoot The message root hash for verification.
/// @param multichainBatchRoot The multichain batch root for chain for verification.
/// @param settlementFeePayer Address that pays gateway settlement fees for interop calls in this batch.
///
/// @dev Settlement Fee Payer Requirements:
Expand All @@ -51,7 +51,7 @@ struct ProcessLogsInput {
uint256 chainId;
uint256 batchNumber;
bytes32 chainBatchRoot;
bytes32 messageRoot;
bytes32 multichainBatchRoot;
address settlementFeePayer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ library BatchDecoder {
/// @return dependencyRoots Interop dependency roots for each batch.
/// @return logs L2 logs for each batch.
/// @return messages L2 messages for each batch.
/// @return messageRoots Message roots for each batch.
/// @return multichainBatchRoots Multichain batch roots for chain for each batch.
/// @return settlementFeePayer Address that pays gateway settlement fees.
function _decodeExecuteData(
bytes calldata _executeData
Expand All @@ -256,7 +256,7 @@ library BatchDecoder {
InteropRoot[][] memory dependencyRoots,
L2Log[][] memory logs,
bytes[][] memory messages,
bytes32[] memory messageRoots,
bytes32[] memory multichainBatchRoots,
address settlementFeePayer
)
{
Expand All @@ -266,8 +266,15 @@ library BatchDecoder {

uint8 encodingVersion = uint8(_executeData[0]);
if (encodingVersion == SUPPORTED_ENCODING_VERSION) {
(executeData, priorityOpsData, dependencyRoots, logs, messages, messageRoots, settlementFeePayer) = abi
.decode(
(
executeData,
priorityOpsData,
dependencyRoots,
logs,
messages,
multichainBatchRoots,
settlementFeePayer
) = abi.decode(
_executeData[1:],
(
IExecutor.StoredBatchInfo[],
Expand Down Expand Up @@ -295,7 +302,7 @@ library BatchDecoder {
/// @return dependencyRoots Interop dependency roots for each batch.
/// @return logs L2 logs for each batch.
/// @return messages L2 messages for each batch.
/// @return messageRoots Message roots for each batch.
/// @return multichainBatchRoots Multichain batch roots for chain for each batch.
/// @return settlementFeePayer Address that pays gateway settlement fees.
function decodeAndCheckExecuteData(
bytes calldata _executeData,
Expand All @@ -310,7 +317,7 @@ library BatchDecoder {
InteropRoot[][] memory dependencyRoots,
L2Log[][] memory logs,
bytes[][] memory messages,
bytes32[] memory messageRoots,
bytes32[] memory multichainBatchRoots,
address settlementFeePayer
)
{
Expand All @@ -320,7 +327,7 @@ library BatchDecoder {
dependencyRoots,
logs,
messages,
messageRoots,
multichainBatchRoots,
settlementFeePayer
) = _decodeExecuteData(_executeData);

Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/selectors
Original file line number Diff line number Diff line change
Expand Up @@ -3674,7 +3674,7 @@ GWAssetTracker
|----------+-------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
| Error | InvalidChainMigrationNumber(uint256,uint256) | 0x05208b6d |
|----------+-------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
| Error | InvalidEmptyMessageRoot(bytes32,bytes32) | 0x24ef4f8a |
| Error | InvalidEmptyMultichainBatchRoot(bytes32,bytes32) | 0xe0c8f0c6 |
|----------+-------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
| Error | InvalidFeeRecipient() | 0x768dc598 |
|----------+-------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
Expand Down
Loading
Loading