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

feat: ZK as gateway token #3110

Open
wants to merge 84 commits into
base: sync-layer-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
d1144b5
some changes
kelemeno Sep 2, 2024
368d657
Merge branch 'sync-layer-stable' of github.com:matter-labs/zksync-era…
kelemeno Sep 2, 2024
30508cd
bump contracts
kelemeno Sep 3, 2024
e355e5c
chain.toml
kelemeno Sep 3, 2024
0357fc6
contracts.toml
kelemeno Sep 3, 2024
291972e
bump contracts with fixes
kelemeno Sep 4, 2024
679f8e7
config
kelemeno Sep 4, 2024
01d7391
Merge branch 'sync-layer-stable' of github.com:matter-labs/zksync-era…
kelemeno Sep 11, 2024
db05aba
fixes
kelemeno Sep 12, 2024
b90e9c8
bump contracts
kelemeno Sep 12, 2024
e8775c7
config
kelemeno Sep 12, 2024
644a076
contracts.ts config
kelemeno Sep 13, 2024
bd5ba3d
make CI slightly smaller
kelemeno Sep 13, 2024
886460f
typo
kelemeno Sep 13, 2024
037e7c6
contract env var error
kelemeno Sep 13, 2024
b6f0dfa
config
kelemeno Sep 13, 2024
1b261d9
contracts config
kelemeno Sep 13, 2024
eceb869
config
kelemeno Sep 13, 2024
16fbac8
Merge branch 'sync-layer-stable' of github.com:matter-labs/zksync-era…
kelemeno Sep 13, 2024
6b96da9
chain config
kelemeno Sep 13, 2024
8a06017
config
kelemeno Sep 13, 2024
0efee21
contracts fix
kelemeno Sep 13, 2024
d29dbbd
bump contracts
kelemeno Sep 13, 2024
6dc895f
fixes
kelemeno Sep 14, 2024
c4909f7
bump contracts
kelemeno Sep 14, 2024
2bfc739
contracts config
kelemeno Sep 14, 2024
23c7a87
bump contracts
kelemeno Sep 14, 2024
db612f8
fixed unit tests
kelemeno Sep 16, 2024
a94999d
bump contracts
kelemeno Sep 16, 2024
94edd3c
last test fix
kelemeno Sep 16, 2024
d0bd8a9
fmt
kelemeno Sep 16, 2024
170ae00
l2 native token tests
kelemeno Sep 18, 2024
5983a2e
Merge branch 'sync-layer-stable' of github.com:matter-labs/zksync-era…
kelemeno Sep 18, 2024
3b85806
Merge branch 'sync-layer-stable' of github.com:matter-labs/zksync-era…
kelemeno Sep 26, 2024
16735cf
bump contracts
kelemeno Sep 29, 2024
1ab4295
main gw->L1 migration changes
kelemeno Oct 1, 2024
3eaa189
GW->L1 migration config changes
kelemeno Oct 2, 2024
0ddb00f
Merge branch 'sync-layer-stable' of github.com:matter-labs/zksync-era…
kelemeno Oct 2, 2024
0557dde
fixed most tests
kelemeno Oct 2, 2024
b362e69
Merge branch 'sync-layer-stable' of github.com:matter-labs/zksync-era…
kelemeno Oct 2, 2024
327ee4d
small test fixes
kelemeno Oct 3, 2024
1a0919e
zks fmt
kelemeno Oct 3, 2024
bf85e75
undo test fixes for CI
kelemeno Oct 3, 2024
c4e2e71
comment out l2 tests
kelemeno Oct 3, 2024
12a903e
increase time
kelemeno Oct 3, 2024
affd930
make l2-erc20 test uncommenting work
kelemeno Oct 3, 2024
bfac316
linting
kelemeno Oct 3, 2024
a818916
feat: l2 native contract checks integration tests (#3010)
Raid5594 Oct 3, 2024
c71d11e
bump contracts
kelemeno Oct 3, 2024
fcde977
Merge branch 'sync-layer-stable' of github.com:matter-labs/zksync-era…
kelemeno Oct 3, 2024
0a00512
undo selectors
kelemeno Oct 3, 2024
2565ce7
(test)
Oct 8, 2024
ff3e64c
(feat): ZK token works as gateway base token
Oct 16, 2024
f5120ef
(merge): resolve conflicts
Oct 16, 2024
39d028a
(fix): remove extra wallets in config; add deployer address for base …
Oct 21, 2024
f956fed
(fix): remove unnecessary changes
Oct 21, 2024
15034a1
(fix): one test
Oct 21, 2024
23bbcef
(fix): formatting
Oct 21, 2024
2c109e9
Merge branch 'sync-layer-stable' into ra/zk-as-gateway-token
Raid5594 Oct 21, 2024
7131a38
(update): contracts formatting
Oct 21, 2024
c78124f
(fix): linting, add ZK token to CI
Oct 22, 2024
2481c02
(fix): order of CI actions
Oct 22, 2024
3358ef6
(update): contracts
Oct 22, 2024
ea1553a
(fix): update CI to use netstat instead of lsof
Oct 22, 2024
c9ccf9f
(fix): update scripts
Oct 22, 2024
2f136b8
(fix): distribution amounts
Oct 22, 2024
a4c1d90
(fix): fund chain governance with ZK token
Oct 23, 2024
a5b16d3
(fix): add right contracts commit
Oct 23, 2024
9bf74cc
(fix): switching off era sever test
Oct 23, 2024
a6e3193
(fix): killing the server
Oct 23, 2024
cfd58ef
(test): killing server
Oct 23, 2024
68a805e
(fix): test CI
Oct 23, 2024
fe16190
(fix): test CI
Oct 23, 2024
7364f73
(fix): test CI
Oct 23, 2024
6734edb
(fix): test CI
Oct 23, 2024
bbf7ab2
(fix): test CI
Oct 23, 2024
f924c06
(fix): test CI
Oct 23, 2024
93f461e
(fix): test CI
Oct 23, 2024
e246b1f
(fix): test CI
Oct 23, 2024
b0c0cf4
(fix): wrong place for install of lsof
Oct 23, 2024
b19f17d
(fix): test
Oct 23, 2024
e4d36f8
(fix): add sudo to permit action
Oct 23, 2024
abd6993
(fix): slight refactoring
Oct 25, 2024
7eaf96f
Merge remote-tracking branch 'origin/sync-layer-stable' into ra/zk-as…
Oct 31, 2024
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
70 changes: 70 additions & 0 deletions .github/scripts/gateway_zktoken.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
sudo rm -rf ./volumes && zk_supervisor clean containers && zk_inception up -o false
Raid5594 marked this conversation as resolved.
Show resolved Hide resolved

zk_inception ecosystem init --deploy-paymaster --deploy-erc20 \
--deploy-ecosystem --l1-rpc-url=http://localhost:8545 \
--server-db-url=postgres://postgres:notsecurepassword@localhost:5432 \
--server-db-name=zksync_server_localhost_era \
--prover-db-url=postgres://postgres:notsecurepassword@localhost:5432 \
--prover-db-name=zksync_prover_localhost_era \
--ignore-prerequisites --observability=false --skip-submodules-checkout \
--chain era \
--verbose

zk_inception server --ignore-prerequisites --chain era &> ./era.log &

sleep 20

zk_inception chain deploy-and-bridge-zk --chain era --verbose

# Define the path to the TOML file
TOML_FILE="contracts/l1-contracts/script-out/output-deploy-zk-token.toml"

# Extract the l1Address from the TOML file
zkL1Address=$(grep -A 1 "\[ZK.l1Address\]" "$TOML_FILE" | grep "l1Address" | awk -F' = ' '{print $2}' | tr -d '"' | tr -d ' ' | tr -d '\n')

# Check if the address starts with 0x and remove it
if [[ $zkL1Address == 0x* ]]; then
zkL1Address="${zkL1Address:2}"
fi

# Output the extracted and sliced l1Address (for debugging purposes)
echo "Sliced l1Address: $zkL1Address"

zk_inception chain create \
--chain-name gateway \
--chain-id 505 \
--prover-mode no-proofs \
--wallet-creation localhost \
--l1-batch-commit-data-generator-mode rollup \
--base-token-address $zkL1Address \
--base-token-price-nominator 1 \
--base-token-price-denominator 1 \
--set-as-default false \
--ignore-prerequisites --skip-submodules-checkout --skip-contract-compilation-override

zk_inception chain init \
--deploy-paymaster \
--l1-rpc-url=http://localhost:8545 \
--server-db-url=postgres://postgres:notsecurepassword@localhost:5432 \
--server-db-name=zksync_server_localhost_gateway \
--prover-db-url=postgres://postgres:notsecurepassword@localhost:5432 \
--prover-db-name=zksync_prover_localhost_gateway \
--chain gateway --skip-submodules-checkout

zk_inception chain convert-to-gateway --chain gateway --ignore-prerequisites

zk_inception server --ignore-prerequisites --chain gateway &> ./gateway.log &

sleep 20

zk_inception chain migrate-to-gateway --chain era --gateway-chain-name gateway

zk_inception chain migrate-from-gateway --chain era --gateway-chain-name gateway

zk_inception chain migrate-to-gateway --chain era --gateway-chain-name gateway

zk_inception server --ignore-prerequisites --chain era &> ./rollup.log &

sleep 20

# zk_supervisor test integration --no-deps --ignore-prerequisites --chain era
4 changes: 2 additions & 2 deletions etc/env/file_based/genesis.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
genesis_root: 0x526a5d3e384ff95a976283c79a976e0a2fb749e4631233f29d3765201efd937d
genesis_batch_commitment: 0xb9794246425fd654cf6a4c2e9adfdd48aaaf97bf3b8ba6bdc88e1d141bcfa5b3
genesis_root: 0xe530a48642477945b2ff4580ad62b8f83d529ee7eeb89a0b17072dfdc3ebf2eb
genesis_batch_commitment: 0xef2f911d6ea649c940a61106c056fc6895d9304fcb14f239d418e6f2776b16e7
genesis_rollup_leaf_index: 64
genesis_protocol_version: 25
default_aa_hash: 0x0100055d3993e14104994ca4d8cfa91beb9b544ee86894b45708b4824d832ff2
Expand Down
11 changes: 8 additions & 3 deletions zk_toolbox/crates/common/src/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ abigen!(
function symbol() external view returns (string)
function decimals() external view returns (uint8)
function mint(address to, uint256 amount)
function transfer(address to, uint256 amount)
]"
);

Expand Down Expand Up @@ -97,17 +98,21 @@ pub async fn mint_token(
let contract = TokenContract::new(token_address, client);

let mut pending_calls = vec![];
for address in addresses {
let mut pending_txs = vec![];
for address in addresses.clone() {
pending_calls.push(contract.mint(address, amount.into()));
}

let mut pending_txs = vec![];
for address in addresses {
pending_calls.push(contract.transfer(address, amount.into()));
}

for call in &pending_calls {
let call = call.send().await;
match call {
// It's safe to set such low number of confirmations and low interval for localhost
Ok(call) => pending_txs.push(call.confirmations(3).interval(Duration::from_millis(30))),
Err(e) => logger::error(format!("Minting is not successful {e}")),
Err(e) => logger::error(format!("Minting or transfer is not successful {e}")),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of this approach, as either minting or transfer will fail every time

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ impl Default for Erc20DeploymentConfig {
implementation: String::from("TestnetERC20Token.sol"),
mint: U256::from_str("9000000000000000000000").unwrap(),
},
Erc20DeploymentTokensConfig {
name: String::from("ZK"),
symbol: String::from("ZK"),
decimals: 8,
implementation: String::from("TestnetERC20Token.sol"),
mint: U256::from_str("9000000000000000000000").unwrap(),
},
],
}
}
Expand Down
6 changes: 6 additions & 0 deletions zk_toolbox/crates/config/src/forge_interface/script_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ pub const GATEWAY_PREPARATION: ForgeScriptParams = ForgeScriptParams {
output: "script-out/output-gateway-preparation-l1.toml",
script_path: "deploy-scripts/GatewayPreparation.s.sol",
};

pub const ZK_PREPARATION: ForgeScriptParams = ForgeScriptParams {
input: "script-config/config-deploy-zk.toml",
output: "script-out/output-deploy-zk-token.toml",
script_path: "deploy-scripts/DeployZKAndBridgeToL1.s.sol",
};
8 changes: 7 additions & 1 deletion zk_toolbox/crates/zk_inception/src/commands/chain/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ pub async fn mint_base_token(
let wallets = ecosystem_config.get_wallets()?;
let chain_wallets = chain_config.get_wallets_config()?;
let base_token = &chain_config.base_token;
let addresses = vec![wallets.governor.address, chain_wallets.governor.address];
let addresses = vec![
wallets.governor.address,
wallets.deployer.unwrap().address,
chain_wallets.governor.address,
chain_wallets.deployer.unwrap().address,
];

let amount = AMOUNT_FOR_DISTRIBUTION_TO_WALLETS * base_token.nominator as u128
/ base_token.denominator as u128;
common::ethereum::mint_token(
Expand Down
Loading
Loading