147 lines
7.4 KiB
Solidity
147 lines
7.4 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.8.13;
|
|
|
|
import "./../zksync/interfaces/IVerifier.sol";
|
|
import "../common/interfaces/IAllowList.sol";
|
|
import "./libraries/PriorityQueue.sol";
|
|
|
|
/// @notice Indicates whether an upgrade is initiated and if yes what type
|
|
/// @param None Upgrade is NOT initiated
|
|
/// @param Transparent Fully transparent upgrade is initiated, upgrade data is publicly known
|
|
/// @param Shadow Shadow upgrade is initiated, upgrade data is hidden
|
|
enum UpgradeState {
|
|
None,
|
|
Transparent,
|
|
Shadow
|
|
}
|
|
|
|
/// @dev Logically separated part of the storage structure, which is responsible for everything related to proxy
|
|
/// upgrades and diamond cuts
|
|
/// @param proposedUpgradeHash The hash of the current upgrade proposal, zero if there is no active proposal
|
|
/// @param state Indicates whether an upgrade is initiated and if yes what type
|
|
/// @param securityCouncil Address which has the permission to approve instant upgrades (expected to be a Gnosis
|
|
/// multisig)
|
|
/// @param approvedBySecurityCouncil Indicates whether the security council has approved the upgrade
|
|
/// @param proposedUpgradeTimestamp The timestamp when the upgrade was proposed, zero if there are no active proposals
|
|
/// @param currentProposalId The serial number of proposed upgrades, increments when proposing a new one
|
|
struct UpgradeStorage {
|
|
bytes32 proposedUpgradeHash;
|
|
UpgradeState state;
|
|
address securityCouncil;
|
|
bool approvedBySecurityCouncil;
|
|
uint40 proposedUpgradeTimestamp;
|
|
uint40 currentProposalId;
|
|
}
|
|
|
|
/// @dev The log passed from L2
|
|
/// @param l2ShardId The shard identifier, 0 - rollup, 1 - porter. All other values are not used but are reserved for
|
|
/// the future
|
|
/// @param isService A boolean flag that is part of the log along with `key`, `value`, and `sender` address.
|
|
/// This field is required formally but does not have any special meaning.
|
|
/// @param txNumberInBatch The L2 transaction number in the batch, in which the log was sent
|
|
/// @param sender The L2 address which sent the log
|
|
/// @param key The 32 bytes of information that was sent in the log
|
|
/// @param value The 32 bytes of information that was sent in the log
|
|
// Both `key` and `value` are arbitrary 32-bytes selected by the log sender
|
|
struct L2Log {
|
|
uint8 l2ShardId;
|
|
bool isService;
|
|
uint16 txNumberInBatch;
|
|
address sender;
|
|
bytes32 key;
|
|
bytes32 value;
|
|
}
|
|
|
|
/// @dev An arbitrary length message passed from L2
|
|
/// @notice Under the hood it is `L2Log` sent from the special system L2 contract
|
|
/// @param txNumberInBatch The L2 transaction number in the batch, in which the message was sent
|
|
/// @param sender The address of the L2 account from which the message was passed
|
|
/// @param data An arbitrary length message
|
|
struct L2Message {
|
|
uint16 txNumberInBatch;
|
|
address sender;
|
|
bytes data;
|
|
}
|
|
|
|
/// @notice Part of the configuration parameters of ZKP circuits
|
|
struct VerifierParams {
|
|
bytes32 recursionNodeLevelVkHash;
|
|
bytes32 recursionLeafLevelVkHash;
|
|
bytes32 recursionCircuitsSetVksHash;
|
|
}
|
|
|
|
/// @dev storing all storage variables for zkSync facets
|
|
/// NOTE: It is used in a proxy, so it is possible to add new variables to the end
|
|
/// but NOT to modify already existing variables or change their order.
|
|
/// NOTE: variables prefixed with '__DEPRECATED_' are deprecated and shouldn't be used.
|
|
/// Their presence is maintained for compatibility and to prevent storage collision.
|
|
struct AppStorage {
|
|
/// @dev Storage of variables needed for deprecated diamond cut facet
|
|
uint256[7] __DEPRECATED_diamondCutStorage;
|
|
/// @notice Address which will exercise critical changes to the Diamond Proxy (upgrades, freezing & unfreezing)
|
|
address governor;
|
|
/// @notice Address that the governor proposed as one that will replace it
|
|
address pendingGovernor;
|
|
/// @notice List of permitted validators
|
|
mapping(address => bool) validators;
|
|
/// @dev Verifier contract. Used to verify aggregated proof for batches
|
|
IVerifier verifier;
|
|
/// @notice Total number of executed batches i.e. batches[totalBatchesExecuted] points at the latest executed batch
|
|
/// (batch 0 is genesis)
|
|
uint256 totalBatchesExecuted;
|
|
/// @notice Total number of proved batches i.e. batches[totalBatchesProved] points at the latest proved batch
|
|
uint256 totalBatchesVerified;
|
|
/// @notice Total number of committed batches i.e. batches[totalBatchesCommitted] points at the latest committed
|
|
/// batch
|
|
uint256 totalBatchesCommitted;
|
|
/// @dev Stored hashed StoredBatch for batch number
|
|
mapping(uint256 => bytes32) storedBatchHashes;
|
|
/// @dev Stored root hashes of L2 -> L1 logs
|
|
mapping(uint256 => bytes32) l2LogsRootHashes;
|
|
/// @dev Container that stores transactions requested from L1
|
|
PriorityQueue.Queue priorityQueue;
|
|
/// @dev The smart contract that manages the list with permission to call contract functions
|
|
IAllowList allowList;
|
|
/// @notice Part of the configuration parameters of ZKP circuits. Used as an input for the verifier smart contract
|
|
VerifierParams verifierParams;
|
|
/// @notice Bytecode hash of bootloader program.
|
|
/// @dev Used as an input to zkp-circuit.
|
|
bytes32 l2BootloaderBytecodeHash;
|
|
/// @notice Bytecode hash of default account (bytecode for EOA).
|
|
/// @dev Used as an input to zkp-circuit.
|
|
bytes32 l2DefaultAccountBytecodeHash;
|
|
/// @dev Indicates that the porter may be touched on L2 transactions.
|
|
/// @dev Used as an input to zkp-circuit.
|
|
bool zkPorterIsAvailable;
|
|
/// @dev The maximum number of the L2 gas that a user can request for L1 -> L2 transactions
|
|
/// @dev This is the maximum number of L2 gas that is available for the "body" of the transaction, i.e.
|
|
/// without overhead for proving the batch.
|
|
uint256 priorityTxMaxGasLimit;
|
|
/// @dev Storage of variables needed for upgrade facet
|
|
UpgradeStorage __DEPRECATED_upgrades;
|
|
/// @dev A mapping L2 batch number => message number => flag.
|
|
/// @dev The L2 -> L1 log is sent for every withdrawal, so this mapping is serving as
|
|
/// a flag to indicate that the message was already processed.
|
|
/// @dev Used to indicate that eth withdrawal was already processed
|
|
mapping(uint256 => mapping(uint256 => bool)) isEthWithdrawalFinalized;
|
|
/// @dev The most recent withdrawal time and amount reset
|
|
uint256 __DEPRECATED_lastWithdrawalLimitReset;
|
|
/// @dev The accumulated withdrawn amount during the withdrawal limit window
|
|
uint256 __DEPRECATED_withdrawnAmountInWindow;
|
|
/// @dev A mapping user address => the total deposited amount by the user
|
|
mapping(address => uint256) totalDepositedAmountPerUser;
|
|
/// @dev Stores the protocol version. Note, that the protocol version may not only encompass changes to the
|
|
/// smart contracts, but also to the node behavior.
|
|
uint256 protocolVersion;
|
|
/// @dev Hash of the system contract upgrade transaction. If 0, then no upgrade transaction needs to be done.
|
|
bytes32 l2SystemContractsUpgradeTxHash;
|
|
/// @dev Batch number where the upgrade transaction has happened. If 0, then no upgrade transaction has happened
|
|
/// yet.
|
|
uint256 l2SystemContractsUpgradeBatchNumber;
|
|
/// @dev Address which will exercise non-critical changes to the Diamond Proxy (changing validator set & unfreezing)
|
|
address admin;
|
|
/// @notice Address that the governor or admin proposed as one that will replace admin role
|
|
address pendingAdmin;
|
|
}
|