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

Zk merge main #266

Merged
merged 10 commits into from
Mar 13, 2024
2 changes: 1 addition & 1 deletion .github/workflows/build-release-manual.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ inputs.commit }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/buld-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
with:
tag_name: ${{ steps.init.outputs.release_tag }}
fail_on_unmatched_files: true
target_commitish: ${{env.GITHUB_SHA}}
target_commitish: ${{ github.sha }}
body: ""
files: |
l1-contracts.tar.gz
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/l1-contracts-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
Expand All @@ -63,7 +63,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/l2-contracts-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
Expand All @@ -63,7 +63,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nodejs-license.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: |
DIRS=$(find -not \( -path \*node_modules -prune \) -type f -name yarn.lock | xargs dirname | awk -v RS='' -v OFS='","' 'NF { $1 = $1; print "\"" $0 "\"" }')
echo "matrix=[${DIRS}]" >> $GITHUB_OUTPUT
Expand All @@ -44,7 +44,7 @@ jobs:
dir: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Checkout latest code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/system-contracts-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
Expand All @@ -59,7 +59,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
Expand Down
1 change: 1 addition & 0 deletions l1-contracts/.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ CONTRACTS_CREATE2_FACTORY_ADDR=0x0000000000000000000000000000000000000000
CONTRACTS_VALIDATOR_TIMELOCK_ADDR=0x0000000000000000000000000000000000000000
CONTRACTS_VALIDATOR_TIMELOCK_EXECUTION_DELAY=0
ETH_SENDER_SENDER_OPERATOR_COMMIT_ETH_ADDR=0x0000000000000000000000000000000000000000
ETH_SENDER_SENDER_OPERATOR_BLOBS_ETH_ADDR=0x0000000000000000000000000000000000000001
CONTRACTS_SHARED_BRIDGE_UPGRADE_STORAGE_SWITCH=0
8 changes: 4 additions & 4 deletions l1-contracts/contracts/state-transition/Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ contract Verifier is IVerifier {
function _loadVerificationKey() internal pure virtual {
assembly {
// gate setup commitments
mstore(VK_GATE_SETUP_0_X_SLOT, 0x281bdd74b0e5ce559019f68453b8ccdbc07ef97554fb9f47fc87a86f6720d9c4)
mstore(VK_GATE_SETUP_0_Y_SLOT, 0x07ed1e84e05b9e4e69ce8eed39601a0605adf9abe15f9c9ed13f642bf8c31dfb)
mstore(VK_GATE_SETUP_0_X_SLOT, 0x03efa4fe0a5d7aa3d98e8becb5058987dddca95ecbe29b624ad274553bf9dd8e)
mstore(VK_GATE_SETUP_0_Y_SLOT, 0x24fb07eb5f0e62013938eb1dcae0aba367a7150a40a9ab2e1ae15e06bbe43853)
mstore(VK_GATE_SETUP_1_X_SLOT, 0x04659caf7b05471ba5ba85b1ab62267aa6c456836e625f169f7119d55b9462d2)
mstore(VK_GATE_SETUP_1_Y_SLOT, 0x0ea63403692148d2ad22189a1e5420076312f4d46e62036a043a6b0b84d5b410)
mstore(VK_GATE_SETUP_2_X_SLOT, 0x0e6696d09d65fce1e42805be03fca1f14aea247281f688981f925e77d4ce2291)
Expand All @@ -295,8 +295,8 @@ contract Verifier is IVerifier {
mstore(VK_GATE_SETUP_4_Y_SLOT, 0x22e404bc91350f3bc7daad1d1025113742436983c85eac5ab7b42221a181b81e)
mstore(VK_GATE_SETUP_5_X_SLOT, 0x0d9b29613037a5025655c82b143d2b7449c98f3aea358307c8529249cc54f3b9)
mstore(VK_GATE_SETUP_5_Y_SLOT, 0x15b3c4c946ad1babfc4c03ff7c2423fd354af3a9305c499b7fb3aaebe2fee746)
mstore(VK_GATE_SETUP_6_X_SLOT, 0x2b0287845b812b668358980e3fd51479ecd86402156fb329551f0ced5b78ff32)
mstore(VK_GATE_SETUP_6_Y_SLOT, 0x08976d4177ca333c0cffd19dda4b8ff6b65f049453235396a42151352d97a509)
mstore(VK_GATE_SETUP_6_X_SLOT, 0x1c541b6423211b65e42c1a52d0c8a07bf631fbf24606a4135e9e486f2bb9bb06)
mstore(VK_GATE_SETUP_6_Y_SLOT, 0x057be8e4f2db0b66a9134809a33bae06d380c386fdce322e837d11a22ce0f9a9)
mstore(VK_GATE_SETUP_7_X_SLOT, 0x283344a1ab3e55ecfd904d0b8e9f4faea338df5a4ead2fa9a42f0e103da40abc)
mstore(VK_GATE_SETUP_7_Y_SLOT, 0x223b37b83b9687512d322993edd70e508dd80adb10bcf7321a3cc8a44c269521)

Expand Down
30 changes: 22 additions & 8 deletions l1-contracts/src.ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,10 @@ export class Deployer {
}
this.chainId = parseInt(chainId, 16);

const validatorAddress = getAddressFromEnv("ETH_SENDER_SENDER_OPERATOR_COMMIT_ETH_ADDR");
const validatorOneAddress = getAddressFromEnv("ETH_SENDER_SENDER_OPERATOR_COMMIT_ETH_ADDR");
const validatorTwoAddress = getAddressFromEnv("ETH_SENDER_SENDER_OPERATOR_BLOBS_ETH_ADDR");
const validatorTimelock = this.validatorTimelock(this.deployWallet);
const tx2 = await validatorTimelock.addValidator(chainId, validatorAddress, {
const tx2 = await validatorTimelock.addValidator(chainId, validatorOneAddress, {
gasPrice,
nonce,
gasLimit,
Expand All @@ -685,18 +686,30 @@ export class Deployer {
console.log(`Validator registered, gas used: ${receipt2.gasUsed.toString()}`);
}

const diamondProxy = this.stateTransitionContract(this.deployWallet);
const tx3 = await diamondProxy.setTokenMultiplier(1, 1);
nonce++;

const tx3 = await validatorTimelock.addValidator(chainId, validatorTwoAddress, {
gasPrice,
nonce,
gasLimit,
});
const receipt3 = await tx3.wait();
if (this.verbose) {
console.log(`BaseTokenMultiplier set, gas used: ${receipt3.gasUsed.toString()}`);
console.log(`Validator registered, gas used: ${receipt3.gasUsed.toString()}`);
}

const diamondProxy = this.stateTransitionContract(this.deployWallet);
const tx4 = await diamondProxy.setTokenMultiplier(1, 1);
const receipt4 = await tx4.wait();
if (this.verbose) {
console.log(`BaseTokenMultiplier set, gas used: ${receipt4.gasUsed.toString()}`);
}

if (validiumMode) {
const tx4 = await diamondProxy.setValidiumMode(PubdataPricingMode.Validium);
const receipt4 = await tx4.wait();
const tx5 = await diamondProxy.setValidiumMode(PubdataPricingMode.Validium);
const receipt5 = await tx5.wait();
if (this.verbose) {
console.log(`Validium mode set, gas used: ${receipt4.gasUsed.toString()}`);
console.log(`Validium mode set, gas used: ${receipt5.gasUsed.toString()}`);
}
}
}
Expand All @@ -723,6 +736,7 @@ export class Deployer {
public async deployValidatorTimelock(create2Salt: string, ethTxOptions: ethers.providers.TransactionRequest) {
ethTxOptions.gasLimit ??= 10_000_000;
const executionDelay = getNumberFromEnv("CONTRACTS_VALIDATOR_TIMELOCK_EXECUTION_DELAY");

const contractAddress = await this.deployViaCreate2(
"ValidatorTimelock",
[this.ownerAddress, executionDelay],
Expand Down
32 changes: 16 additions & 16 deletions l1-contracts/test/test_config/constant/hardhat.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,96 +3,96 @@
"name": "DAI",
"symbol": "DAI",
"decimals": 18,
"address": "0x3c138Dd13EC52C1Ea7e73c8DD16EF6D0593bDcf3"
"address": "0x0F3934f734e62Daa87715B3E4640eFDB89246571"
},
{
"name": "wBTC",
"symbol": "wBTC",
"decimals": 8,
"address": "0x76258E6b9F71d45BCeAA0CC6514B910d7D8aC807"
"address": "0x421e18B8c90Fe0e4AA6f049d6D5fdbA3093b698C"
},
{
"name": "BAT",
"symbol": "BAT",
"decimals": 18,
"address": "0xc7fc371d3340337407bDfE48e2113085DD89FFe2"
"address": "0x94f0779546Ed463dABBa2f71aB10410e9C8A839D"
},
{
"name": "GNT",
"symbol": "GNT",
"decimals": 18,
"address": "0xAAFc93A3E06857a40d82fB61F038288dCDfcE7eF"
"address": "0xE3D1be6c892D4f7b09c3940b67741104c2FFB34b"
},
{
"name": "MLTT",
"symbol": "MLTT",
"decimals": 18,
"address": "0x0F3934f734e62Daa87715B3E4640eFDB89246571"
"address": "0x632655228439172CC496A17c0ceA170917FebE18"
},
{
"name": "DAIK",
"symbol": "DAIK",
"decimals": 18,
"address": "0x421e18B8c90Fe0e4AA6f049d6D5fdbA3093b698C"
"address": "0x211e762c89e588AfB3ec50b0017Cd5250bBb111A"
},
{
"name": "wBTCK",
"symbol": "wBTCK",
"decimals": 8,
"address": "0x94f0779546Ed463dABBa2f71aB10410e9C8A839D"
"address": "0xEFc9af2B75706c223C1Af2e4dEaBDfeE46f8Bf85"
},
{
"name": "BATK",
"symbol": "BATS",
"decimals": 18,
"address": "0xE3D1be6c892D4f7b09c3940b67741104c2FFB34b"
"address": "0x41a0577764aDdc7B86149884324e1E53A5EE82C6"
},
{
"name": "GNTK",
"symbol": "GNTS",
"decimals": 18,
"address": "0x632655228439172CC496A17c0ceA170917FebE18"
"address": "0xc21042CA11b84072229b91750805Fd611290ecF8"
},
{
"name": "MLTTK",
"symbol": "MLTTS",
"decimals": 18,
"address": "0x211e762c89e588AfB3ec50b0017Cd5250bBb111A"
"address": "0xe1630b33Dcad7d2376FDA96cd19F2A3A633E60ce"
},
{
"name": "DAIL",
"symbol": "DAIL",
"decimals": 18,
"address": "0xEFc9af2B75706c223C1Af2e4dEaBDfeE46f8Bf85"
"address": "0xE982e1ff2d8972B09aCF7728E8b5e23149bd74eb"
},
{
"name": "wBTCL",
"symbol": "wBTCP",
"decimals": 8,
"address": "0x41a0577764aDdc7B86149884324e1E53A5EE82C6"
"address": "0x6ca4A813AcAcfF0CA91746a759D0ffD4420eF160"
},
{
"name": "BATL",
"symbol": "BATW",
"decimals": 18,
"address": "0xc21042CA11b84072229b91750805Fd611290ecF8"
"address": "0xA16cABea54068663d9295Fc63093724ed97a1aF7"
},
{
"name": "GNTL",
"symbol": "GNTW",
"decimals": 18,
"address": "0xe1630b33Dcad7d2376FDA96cd19F2A3A633E60ce"
"address": "0x11da4a6F691E170439E88505d45f9800751e6AAd"
},
{
"name": "MLTTL",
"symbol": "MLTTW",
"decimals": 18,
"address": "0xE982e1ff2d8972B09aCF7728E8b5e23149bd74eb"
"address": "0x27D1cd196aB20961c6345a4FB2715C98856Aa2c6"
},
{
"name": "Wrapped Ether",
"symbol": "WETH",
"decimals": 18,
"address": "0x6ca4A813AcAcfF0CA91746a759D0ffD4420eF160"
"address": "0xa578622084d27E5c9D1590556ac9504DcC0503a2"
}
]
12 changes: 9 additions & 3 deletions l2-contracts/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ export const testConfigPath = path.join(process.env.ZKSYNC_HOME as string, "etc/
export const ethTestConfig = JSON.parse(fs.readFileSync(`${testConfigPath}/eth.json`, { encoding: "utf-8" }));

export function applyL1ToL2Alias(address: string): string {
return ethers.utils.hexlify(ethers.BigNumber.from(address).add(L1_TO_L2_ALIAS_OFFSET).mod(ADDRESS_MODULO));
return ethers.utils.hexZeroPad(
ethers.utils.hexlify(ethers.BigNumber.from(address).add(L1_TO_L2_ALIAS_OFFSET).mod(ADDRESS_MODULO)),
20
);
}

export function unapplyL1ToL2Alias(address: string): string {
// We still add ADDRESS_MODULO to avoid negative numbers
return ethers.utils.hexlify(
ethers.BigNumber.from(address).sub(L1_TO_L2_ALIAS_OFFSET).add(ADDRESS_MODULO).mod(ADDRESS_MODULO)
return ethers.utils.hexZeroPad(
ethers.utils.hexlify(
ethers.BigNumber.from(address).sub(L1_TO_L2_ALIAS_OFFSET).add(ADDRESS_MODULO).mod(ADDRESS_MODULO)
),
20
);
}

Expand Down
2 changes: 1 addition & 1 deletion tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
To generate the verifier from the scheduler key in 'data' directory, just run:

```shell
cargo run --bin zksync_verifier_contract_generator --release -- --input_path data/scheduler_key.json --output_path ../l1-contracts/contracts/state-transition/Verifier.sol
cargo run --bin zksync_verifier_contract_generator --release -- --input_path ../../prover/vk_setup_data_generator_server_fri/data/snark_verification_scheduler_key.json --output_path ../l1-contracts/contracts/zksync/Verifier.sol
```
Loading
Loading