Skip to content

Commit

Permalink
Revert zk fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Litteri authored and Ivan Litteri committed Jan 16, 2024
1 parent 7fe7979 commit 86bbbf3
Show file tree
Hide file tree
Showing 61 changed files with 7,752 additions and 7,936 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Scripts-Related Bug Report
about: Use this template for reporting script-related bugs. For contract-related bugs, see our security policy.
title: ''
title: ""
labels: bug
assignees: ''
assignees: ""
---

### 🐛 Script Bug Report
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Feature request
about: Use this template for requesting features
title: ''
title: ""
labels: feat
assignees: ''
assignees: ""
---

### 🌟 Feature Request
Expand Down
28 changes: 14 additions & 14 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module.exports = {
...require('@matterlabs/prettier-config'),
plugins: ['prettier-plugin-solidity'],
overrides: [
{
files: '*.sol',
options: {
bracketSpacing: false,
printWidth: 120,
singleQuote: false,
tabWidth: 4,
useTabs: false
}
}
]
...require("@matterlabs/prettier-config"),
plugins: ["prettier-plugin-solidity"],
overrides: [
{
files: "*.sol",
options: {
bracketSpacing: false,
printWidth: 120,
singleQuote: false,
tabWidth: 4,
useTabs: false,
},
},
],
};
52 changes: 23 additions & 29 deletions docs/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ See the [documentation](https://era.zksync.io/docs/dev/fundamentals/rollups.html
addresses.
- **Security council** - an address of the Gnosis multisig with the trusted owners that can decrease upgrade timelock.
- **Validator/Operator** - a privileged address that can commit/verify/execute L2 batches.
- **L2 batch (or just batch)** - An aggregation of multiple L2 blocks. Note, that while the API operates on L2 blocks,
the prove system operates on batches, which represent a single proved VM execution, which typically contains multiple
L2 blocks.
- **L2 batch (or just batch)** - An aggregation of multiple L2 blocks. Note, that while the API operates on L2 blocks, the prove system operates on batches, which represent a single proved VM execution, which typically contains multiple L2 blocks.
- **Facet** - implementation contract. The word comes from the EIP-2535.
- **Gas** - a unit that measures the amount of computational effort required to execute specific operations on the
zkSync Era network.
Expand All @@ -46,9 +44,9 @@ even an upgrade system is a separate facet that can be replaced.

One of the differences from the reference implementation is access freezability. Each of the facets has an associated
parameter that indicates if it is possible to freeze access to the facet. Privileged actors can freeze the **diamond**
(not a specific facet!) and all facets with the marker `isFreezable` should be inaccessible until the governor or its
owner unfreezes the diamond. Note that it is a very dangerous thing since the diamond proxy can freeze the upgrade
system and then the diamond will be frozen forever.
(not a specific facet!) and all facets with the marker `isFreezable` should be inaccessible until the governor or its owner
unfreezes the diamond. Note that it is a very dangerous thing since the diamond proxy can freeze the upgrade system and then
the diamond will be frozen forever.

#### DiamondInit

Expand All @@ -61,28 +59,28 @@ Implementation detail - function returns a magic value just like it is designed
#### GettersFacet

Separate facet, whose only function is providing `view` and `pure` methods. It also implements
[diamond loupe](https://eips.ethereum.org/EIPS/eip-2535#diamond-loupe) which makes managing facets easier. This contract
must never be frozen.
[diamond loupe](https://eips.ethereum.org/EIPS/eip-2535#diamond-loupe) which makes managing facets easier.
This contract must never be frozen.

#### AdminFacet

Controls changing the privileged addresses such as governor and validators or one of the system parameters (L2
bootloader bytecode hash, verifier address, verifier parameters, etc), and it also manages the freezing/unfreezing and
execution of upgrades in the diamond proxy.
bootloader bytecode hash, verifier address, verifier parameters, etc), and it also manages the freezing/unfreezing and execution of
upgrades in the diamond proxy.

#### Governance

This contract manages operations (calls with preconditions) for governance tasks. The contract allows for operations to
be scheduled, executed, and canceled with appropriate permissions and delays. It is used for managing and coordinating
upgrades and changes in all zkSync Era governed contracts.
This contract manages operations (calls with preconditions) for governance tasks. The contract allows for operations to be scheduled,
executed, and canceled with appropriate permissions and delays. It is used for managing and coordinating upgrades and changes in all
zkSync Era governed contracts.

Each upgrade consists of two steps:

- Upgrade Proposal - The governor can schedule upgrades in two different manners:
- Fully transparent data. All implementation contracts and migration contracts are known to the community. The
governor must wait for the timelock to execute the upgrade.
- Shadow upgrade. The governor only shows the commitment for the upgrade. The upgrade can be executed only with
security council approval without timelock.
- Fully transparent data. All implementation contracts and migration contracts are known to the community. The governor must wait
for the timelock to execute the upgrade.
- Shadow upgrade. The governor only shows the commitment for the upgrade. The upgrade can be executed only with security council
approval without timelock.
- Upgrade execution - perform the upgrade that was proposed.

#### MailboxFacet
Expand Down Expand Up @@ -120,7 +118,6 @@ function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Ad
l2Address = address(uint160(l1Address) + offset);
}
}
```

For most of the rollups the address aliasing needs to prevent cross-chain exploits that would otherwise be possible if
Expand Down Expand Up @@ -179,7 +176,6 @@ enum SystemLogKey {
NUMBER_OF_LAYER_1_TXS_KEY,
EXPECTED_SYSTEM_CONTRACT_UPGRADE_TX_HASH_KEY
}
```

When a batch is committed, we process L2 -> L1 system logs. Here are the invariants that are expected there:
Expand Down Expand Up @@ -252,16 +248,15 @@ investigation and mitigation before resuming normal operations.
It is a temporary solution to prevent any significant impact of the validator hot key leakage, while the network is in
the Alpha stage.

This contract consists of four main functions `commitBatches`, `proveBatches`, `executeBatches`, and `revertBatches`,
that can be called only by the validator.
This contract consists of four main functions `commitBatches`, `proveBatches`, `executeBatches`, and `revertBatches`, that
can be called only by the validator.

When the validator calls `commitBatches`, the same calldata will be propogated to the zkSync contract (`DiamondProxy`
through `call` where it invokes the `ExecutorFacet` through `delegatecall`), and also a timestamp is assigned to these
batches to track the time these batches are commited by the validator to enforce a delay between committing and
execution of batches. Then, the validator can prove the already commited batches regardless of the mentioned timestamp,
and again the same calldata (related to the `proveBatches` function) will be propogated to the zkSync contract. After,
the `delay` is elapsed, the validator is allowed to call `executeBatches` to propogate the same calldata to zkSync
contract.
When the validator calls `commitBatches`, the same calldata will be propogated to the zkSync contract (`DiamondProxy` through
`call` where it invokes the `ExecutorFacet` through `delegatecall`), and also a timestamp is assigned to these batches to track
the time these batches are commited by the validator to enforce a delay between committing and execution of batches. Then, the
validator can prove the already commited batches regardless of the mentioned timestamp, and again the same calldata (related
to the `proveBatches` function) will be propogated to the zkSync contract. After, the `delay` is elapsed, the validator
is allowed to call `executeBatches` to propogate the same calldata to zkSync contract.

#### Allowlist

Expand Down Expand Up @@ -312,7 +307,6 @@ struct Deposit {
bool depositLimitation;
uint256 depositCap;
}
```

Currently, the limit is used only for blocking deposits of the specific token (turning on the limitation and setting the
Expand Down
186 changes: 93 additions & 93 deletions l1-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,121 +1,121 @@
import '@nomiclabs/hardhat-ethers';
import '@nomiclabs/hardhat-etherscan';
import '@nomiclabs/hardhat-solpp';
import '@nomiclabs/hardhat-waffle';
import 'hardhat-contract-sizer';
import 'hardhat-gas-reporter';
import 'hardhat-typechain';
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from 'hardhat/builtin-tasks/task-names';
import { task } from 'hardhat/config';
import 'solidity-coverage';
import { getNumberFromEnv } from './scripts/utils';
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-solpp";
import "@nomiclabs/hardhat-waffle";
import "hardhat-contract-sizer";
import "hardhat-gas-reporter";
import "hardhat-typechain";
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names";
import { task } from "hardhat/config";
import "solidity-coverage";
import { getNumberFromEnv } from "./scripts/utils";

// If no network is specified, use the default config
if (!process.env.CHAIN_ETH_NETWORK) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('dotenv').config();
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("dotenv").config();
}

// eslint-disable-next-line @typescript-eslint/no-var-requires
const systemParams = require('../SystemConfig.json');
const systemParams = require("../SystemConfig.json");

const PRIORITY_TX_MAX_GAS_LIMIT = getNumberFromEnv('CONTRACTS_PRIORITY_TX_MAX_GAS_LIMIT');
const DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT = getNumberFromEnv('CONTRACTS_DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT');
const PRIORITY_TX_MAX_GAS_LIMIT = getNumberFromEnv("CONTRACTS_PRIORITY_TX_MAX_GAS_LIMIT");
const DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT = getNumberFromEnv("CONTRACTS_DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT");

const prodConfig = {
UPGRADE_NOTICE_PERIOD: 0,
// PRIORITY_EXPIRATION: 101,
// NOTE: Should be greater than 0, otherwise zero approvals will be enough to make an instant upgrade!
SECURITY_COUNCIL_APPROVALS_FOR_EMERGENCY_UPGRADE: 1,
PRIORITY_TX_MAX_GAS_LIMIT,
DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT,
DUMMY_VERIFIER: false
UPGRADE_NOTICE_PERIOD: 0,
// PRIORITY_EXPIRATION: 101,
// NOTE: Should be greater than 0, otherwise zero approvals will be enough to make an instant upgrade!
SECURITY_COUNCIL_APPROVALS_FOR_EMERGENCY_UPGRADE: 1,
PRIORITY_TX_MAX_GAS_LIMIT,
DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT,
DUMMY_VERIFIER: false,
};
const testnetConfig = {
UPGRADE_NOTICE_PERIOD: 0,
// PRIORITY_EXPIRATION: 101,
// NOTE: Should be greater than 0, otherwise zero approvals will be enough to make an instant upgrade!
SECURITY_COUNCIL_APPROVALS_FOR_EMERGENCY_UPGRADE: 1,
PRIORITY_TX_MAX_GAS_LIMIT,
DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT,
DUMMY_VERIFIER: true
UPGRADE_NOTICE_PERIOD: 0,
// PRIORITY_EXPIRATION: 101,
// NOTE: Should be greater than 0, otherwise zero approvals will be enough to make an instant upgrade!
SECURITY_COUNCIL_APPROVALS_FOR_EMERGENCY_UPGRADE: 1,
PRIORITY_TX_MAX_GAS_LIMIT,
DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT,
DUMMY_VERIFIER: true,
};
const testConfig = {
UPGRADE_NOTICE_PERIOD: 0,
PRIORITY_EXPIRATION: 101,
SECURITY_COUNCIL_APPROVALS_FOR_EMERGENCY_UPGRADE: 2,
PRIORITY_TX_MAX_GAS_LIMIT,
DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT,
DUMMY_VERIFIER: true
UPGRADE_NOTICE_PERIOD: 0,
PRIORITY_EXPIRATION: 101,
SECURITY_COUNCIL_APPROVALS_FOR_EMERGENCY_UPGRADE: 2,
PRIORITY_TX_MAX_GAS_LIMIT,
DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT,
DUMMY_VERIFIER: true,
};
const localConfig = {
...prodConfig,
DUMMY_VERIFIER: true
...prodConfig,
DUMMY_VERIFIER: true,
};

const contractDefs = {
sepolia: testnetConfig,
rinkeby: testnetConfig,
ropsten: testnetConfig,
goerli: testnetConfig,
mainnet: prodConfig,
test: testConfig,
localhost: localConfig
sepolia: testnetConfig,
rinkeby: testnetConfig,
ropsten: testnetConfig,
goerli: testnetConfig,
mainnet: prodConfig,
test: testConfig,
localhost: localConfig,
};

export default {
defaultNetwork: 'env',
solidity: {
version: '0.8.20',
settings: {
optimizer: {
enabled: true,
runs: 9999999
},
outputSelection: {
'*': {
'*': ['storageLayout']
}
}
}
},
contractSizer: {
runOnCompile: false,
except: ['dev-contracts', 'zksync/upgrade-initializers', 'zksync/libraries', 'common/libraries']
},
paths: {
sources: './contracts'
defaultNetwork: "env",
solidity: {
version: "0.8.20",
settings: {
optimizer: {
enabled: true,
runs: 9999999,
},
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
solpp: {
defs: (() => {
const defs = process.env.CONTRACT_TESTS ? contractDefs.test : contractDefs[process.env.CHAIN_ETH_NETWORK];
},
contractSizer: {
runOnCompile: false,
except: ["dev-contracts", "zksync/upgrade-initializers", "zksync/libraries", "common/libraries"],
},
paths: {
sources: "./contracts",
},
solpp: {
defs: (() => {
const defs = process.env.CONTRACT_TESTS ? contractDefs.test : contractDefs[process.env.CHAIN_ETH_NETWORK];

return {
...systemParams,
...defs
};
})()
},
networks: {
env: {
url: process.env.ETH_CLIENT_WEB3_URL?.split(',')[0]
},
hardhat: {
allowUnlimitedContractSize: false,
forking: {
url: 'https://eth-goerli.g.alchemy.com/v2/' + process.env.ALCHEMY_KEY,
enabled: process.env.TEST_CONTRACTS_FORK === '1'
}
}
return {
...systemParams,
...defs,
};
})(),
},
networks: {
env: {
url: process.env.ETH_CLIENT_WEB3_URL?.split(",")[0],
},
etherscan: {
apiKey: process.env.MISC_ETHERSCAN_API_KEY
hardhat: {
allowUnlimitedContractSize: false,
forking: {
url: "https://eth-goerli.g.alchemy.com/v2/" + process.env.ALCHEMY_KEY,
enabled: process.env.TEST_CONTRACTS_FORK === "1",
},
},
gasReporter: {
enabled: true
}
},
etherscan: {
apiKey: process.env.MISC_ETHERSCAN_API_KEY,
},
gasReporter: {
enabled: true,
},
};

task('solpp', 'Preprocess Solidity source files').setAction(async (_, hre) =>
hre.run(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS)
task("solpp", "Preprocess Solidity source files").setAction(async (_, hre) =>
hre.run(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS)
);
Loading

0 comments on commit 86bbbf3

Please sign in to comment.