Skip to content

Commit

Permalink
merging sls fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kelemeno committed Sep 19, 2024
1 parent 17a8300 commit a4b8744
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 36 deletions.
15 changes: 8 additions & 7 deletions l1-contracts/contracts/bridgehub/Bridgehub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import {IChainTypeManager} from "../state-transition/IChainTypeManager.sol";
import {ReentrancyGuard} from "../common/ReentrancyGuard.sol";
import {DataEncoding} from "../common/libraries/DataEncoding.sol";
import {IZKChain} from "../state-transition/chain-interfaces/IZKChain.sol";
import {IMailbox} from "../state-transition/chain-interfaces/IMailbox.sol";

import {ETH_TOKEN_ADDRESS, TWO_BRIDGES_MAGIC_VALUE, BRIDGEHUB_MIN_SECOND_BRIDGE_ADDRESS, SETTLEMENT_LAYER_RELAY_SENDER, INTEROP_OPERATION_TX_TYPE} from "../common/Config.sol";
import {L2_MESSENGER} from "../common/L2ContractAddresses.sol";
import {BridgehubL2TransactionRequest, L2Message, L2Log, TxStatus} from "../common/Messaging.sol";
import {BridgehubL2TransactionRequest, L2CanonicalTransaction, L2Message, L2Log, TxStatus} from "../common/Messaging.sol";
import {L2ContractHelper} from "../common/libraries/L2ContractHelper.sol";
import {AddressAliasHelper} from "../vendor/AddressAliasHelper.sol";
import {IMessageRoot} from "./IMessageRoot.sol";
Expand Down Expand Up @@ -580,13 +581,13 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2StepUpgradeable, Paus
address refundRecipient = AddressAliasHelper.actualRefundRecipient(_refundRecipient, msg.sender);
_request.refundRecipient = refundRecipient;
address zkChain = zkChainMap.get(_chainId);
if (hyperchain != address(0)) {
if (zkChain != address(0)) {
canonicalTxHash = IZKChain(zkChain).bridgehubRequestL2Transaction(_request);
} else {
L2CanonicalTransaction memory transaction = L2CanonicalTransaction({
txType: INTEROP_OPERATION_TX_TYPE,
from: uint256(uint160(_request.secondBridgeAddress)),
to: uint256(uint160(outputRequest.l2Contract)),
from: uint256(uint160(_request.sender)),
to: uint256(uint160(_request.contractL2)),
gasLimit: _request.l2GasLimit,
gasPerPubdataByteLimit: _request.l2GasPerPubdataByteLimit,
maxFeePerGas: uint256(0), // todo change in the bootloader
Expand All @@ -595,16 +596,16 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2StepUpgradeable, Paus
nonce: uint256(0), //todo
value: _request.l2Value,
reserved: [_request.mintValue, uint256(uint160(refundRecipient)), 0, 0],
data: outputRequest.l2Calldata,
data: _request.l2Calldata,
signature: new bytes(0),
factoryDeps: L2ContractHelper.hashFactoryDeps(outputRequest.factoryDeps),
factoryDeps: L2ContractHelper.hashFactoryDeps(_request.factoryDeps),
paymasterInput: new bytes(0),
reservedDynamic: new bytes(0)
});
/// Fixme this does not have a unique hash atm.
canonicalTxHash = L2_MESSENGER.sendToL1(abi.encode(transaction));
// solhint-disable-next-line func-named-parameters
emit NewPriorityRequest(0, canonicalTxHash, 0, transaction, outputRequest.factoryDeps);
emit IMailbox.NewPriorityRequest(0, canonicalTxHash, 0, transaction, _request.factoryDeps);
}
}

Expand Down
15 changes: 0 additions & 15 deletions l1-contracts/contracts/bridgehub/IBridgehub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,6 @@ interface IBridgehub is IAssetHandler, IL1AssetHandler {
address sender
);

/// @notice New priority request event. Emitted when a transaction is sent L2->L2, same format as in Mailbox
/// @param txId Serial number of the priority operation
/// @param txHash keccak256 hash of encoded transaction representation
/// @param expirationTimestamp Timestamp up to which priority request should be processed
/// @param transaction The whole transaction structure that is requested to be executed on L2
/// @param factoryDeps An array of bytecodes that were shown in the L1 public data.
/// Will be marked as known bytecodes in L2
event NewPriorityRequest(
uint256 txId,
bytes32 txHash,
uint64 expirationTimestamp,
L2CanonicalTransaction transaction,
bytes[] factoryDeps
);

event SettlementLayerRegistered(uint256 indexed chainId, bool indexed isWhitelisted);

/// @notice Emitted when the bridging to the chain is started.
Expand Down
15 changes: 13 additions & 2 deletions l1-contracts/src.ts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ export const L2_BRIDGEHUB_ADDRESS = "0x0000000000000000000000000000000000010002"
export const L2_ASSET_ROUTER_ADDRESS = "0x0000000000000000000000000000000000010003";
export const L2_NATIVE_TOKEN_VAULT_ADDRESS = "0x0000000000000000000000000000000000010004";
export const L2_MESSAGE_ROOT_ADDRESS = "0x0000000000000000000000000000000000010005";
export const DEPLOYER_SYSTEM_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000008006";
export const EMPTY_STRING_KECCAK = "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470";

export const HYPERCHAIN_COMMITMENT_ABI_STRING =
"tuple(uint256 totalBatchesExecuted, uint256 totalBatchesVerified, uint256 totalBatchesCommitted, bytes32 l2SystemContractsUpgradeTxHash, uint256 l2SystemContractsUpgradeBatchNumber, bytes32[] batchHashes, tuple(uint256 nextLeafIndex, uint256 startIndex, uint256 unprocessedIndex, bytes32[] sides) priorityTree)";
export const STORED_BATCH_INFO_ABI_STRING =
"tuple(uint64 batchNumber, bytes32 batchHash, uint64 indexRepeatedStorageChanges, uint256 numberOfLayer1Txs, bytes32 priorityOperationsHash, bytes32 l2LogsTreeRoot, uint256 timestamp, bytes32 commitment)";
export const COMMIT_BATCH_INFO_ABI_STRING =
"tuple(uint64 batchNumber, uint64 timestamp, uint64 indexRepeatedStorageChanges, bytes32 newStateRoot, uint256 numberOfLayer1Txs, bytes32 priorityOperationsHash, bytes32 bootloaderHeapInitialContentsHash, bytes32 eventsQueueStateHash, bytes systemLogs, bytes operatorDAInput)";
export const PRIORITY_OPS_BATCH_INFO_ABI_STRING =
"tuple(bytes32[] leftPath, bytes32[] rightPath, bytes32[] itemHashes)";
export const DIAMOND_CUT_DATA_ABI_STRING =
"tuple(tuple(address facet, uint8 action, bool isFreezable, bytes4[] selectors)[] facetCuts, address initAddress, bytes initCalldata)";
export const FORCE_DEPLOYMENT_ABI_STRING =
"tuple(bytes32 bytecodeHash, address newAddress, bool callConstructor, uint256 value, bytes input)[]";
export const HYPERCHAIN_COMMITMENT_ABI_STRING =
"tuple(uint256 totalBatchesExecuted, uint256 totalBatchesVerified, uint256 totalBatchesCommitted, bytes32 l2SystemContractsUpgradeTxHash, uint256 l2SystemContractsUpgradeBatchNumber, bytes32[] batchHashes, tuple(uint256 nextLeafIndex, uint256 startIndex, uint256 unprocessedIndex, bytes32[] sides) priorityTree)";
export const BRIDGEHUB_CTM_ASSET_DATA_ABI_STRING = "tuple(uint256 chainId, bytes ctmData, bytes chainData)";
export const FIXED_FORCE_DEPLOYMENTS_DATA_ABI_STRING =
"tuple(uint256 l1ChainId, uint256 eraChainId, address l1AssetRouter, bytes32 l2TokenProxyBytecodeHash, address aliasedL1Governance, uint256 maxNumberOfZKChains, bytes32 bridgehubBytecodeHash, bytes32 l2AssetRouterBytecodeHash, bytes32 l2NtvBytecodeHash, bytes32 messageRootBytecodeHash)";
export const ADDITIONAL_FORCE_DEPLOYMENTS_DATA_ABI_STRING = "tuple(bytes32 baseTokenAssetId, address l2Weth)";
10 changes: 2 additions & 8 deletions l1-contracts/src.ts/deploy-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ import { ethers } from "ethers";
import { Interface } from "ethers/lib/utils";
import { SingletonFactoryFactory } from "../typechain";

import {
encodeNTVAssetId,
getAddressFromEnv,
getNumberFromEnv,
REQUIRED_L2_GAS_PRICE_PER_PUBDATA,
DEPLOYER_SYSTEM_CONTRACT_ADDRESS,
ADDRESS_ONE,
} from "./utils";
import { encodeNTVAssetId, getAddressFromEnv, getNumberFromEnv } from "./utils";
import { REQUIRED_L2_GAS_PRICE_PER_PUBDATA, DEPLOYER_SYSTEM_CONTRACT_ADDRESS, ADDRESS_ONE } from "./constants";
import { IBridgehubFactory } from "../typechain/IBridgehubFactory";
import { IERC20Factory } from "../typechain/IERC20Factory";

Expand Down
8 changes: 6 additions & 2 deletions l1-contracts/test/unit_tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ import type { ExecutorFacet } from "../../typechain";

import type { FeeParams, L2CanonicalTransaction } from "../../src.ts/utils";
import { PubdataPricingMode } from "../../src.ts/utils";
import { ADDRESS_ONE, EMPTY_STRING_KECCAK, STORED_BATCH_INFO_ABI_STRING,
import {
ADDRESS_ONE,
EMPTY_STRING_KECCAK,
STORED_BATCH_INFO_ABI_STRING,
COMMIT_BATCH_INFO_ABI_STRING,
PRIORITY_OPS_BATCH_INFO_ABI_STRING, } from "../../src.ts/constants";
PRIORITY_OPS_BATCH_INFO_ABI_STRING,
} from "../../src.ts/constants";

import { packSemver } from "../../scripts/utils";
import { keccak256, hexConcat, defaultAbiCoder } from "ethers/lib/utils";
Expand Down
1 change: 0 additions & 1 deletion l2-contracts/contracts/L2ContractHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ address constant DEPLOYER_SYSTEM_CONTRACT = address(SYSTEM_CONTRACTS_OFFSET + 0x

address constant L2_BRIDGEHUB_ADDRESS = address(USER_CONTRACTS_OFFSET + 0x02);


IL2Messenger constant L2_MESSENGER = IL2Messenger(address(SYSTEM_CONTRACTS_OFFSET + 0x08));

IBaseToken constant L2_BASE_TOKEN_ADDRESS = IBaseToken(address(SYSTEM_CONTRACTS_OFFSET + 0x0a));
Expand Down
1 change: 0 additions & 1 deletion system-contracts/contracts/L2MessageRootStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

pragma solidity 0.8.20;


/**
* @author Matter Labs
* @custom:security-contact [email protected]
Expand Down

0 comments on commit a4b8744

Please sign in to comment.