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: Kl split-asset-router-support #2790

Merged
merged 33 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 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
c4c01dc
timeout increase
kelemeno Sep 17, 2024
3ed4e61
cut down ci
kelemeno Sep 17, 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
7 changes: 2 additions & 5 deletions .github/workflows/ci-core-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ jobs:
- name: Prepare the server to be the synclayer
run: |
ci_run zk dev2 supply-rich-wallets
ci_run zk contract build --zkSync
ci_run zk contract prepare-sync-layer
ci_run zk contract register-sync-layer-counterpart

Expand All @@ -258,10 +257,8 @@ jobs:
ci_run zk config prepare-l1-hyperchain --env-name test-chain --chain-id 320
ci_run zk env test-chain
ci_run zk config compile test-chain --diff 5
ci_run zk init hyper
ci_run zk server --time-to-live 120 &>server2.log
sleep 120
ci_run zk server --tx-aggregation-paused --time-to-live 60 &>server2.log
ci_run zk init hyper --skip-contract-compilation-override

ci_run zk contract migrate-to-sync-layer
ci_run zk contract prepare-sync-layer-validators
ci_run zk contract update-config-for-sync-layer
Expand Down
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 451 files
8 changes: 8 additions & 0 deletions core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ pub(crate) struct RemoteENConfig {
// a different name, with names adapted only for consistency.
pub l1_shared_bridge_proxy_addr: Option<Address>,
pub l2_shared_bridge_addr: Option<Address>,
pub l2_legacy_shared_bridge_addr: Option<Address>,
pub l1_erc20_bridge_proxy_addr: Option<Address>,
pub l2_erc20_bridge_addr: Option<Address>,
pub l1_weth_bridge_addr: Option<Address>,
Expand Down Expand Up @@ -138,6 +139,10 @@ impl RemoteENConfig {
.get_native_token_vault_proxy_addr()
.rpc_context("get_native_token_vault")
.await?;
let l2_legacy_shared_bridge_addr = client
.get_legacy_shared_bridge()
.rpc_context("get_legacy_shared_bridge")
.await?;
let genesis = client.genesis_config().rpc_context("genesis").await.ok();
let ecosystem_contracts = client
.get_ecosystem_contracts()
Expand Down Expand Up @@ -203,6 +208,7 @@ impl RemoteENConfig {
l2_erc20_bridge_addr: l2_erc20_default_bridge,
l1_shared_bridge_proxy_addr: bridges.l1_shared_default_bridge,
l2_shared_bridge_addr: l2_erc20_shared_bridge,
l2_legacy_shared_bridge_addr,
l1_weth_bridge_addr: bridges.l1_weth_bridge,
l2_weth_bridge_addr: bridges.l2_weth_bridge,
base_token_addr,
Expand Down Expand Up @@ -234,6 +240,7 @@ impl RemoteENConfig {
l1_shared_bridge_proxy_addr: Some(Address::repeat_byte(5)),
l1_weth_bridge_addr: None,
l2_shared_bridge_addr: Some(Address::repeat_byte(6)),
l2_legacy_shared_bridge_addr: Some(Address::repeat_byte(7)),
l1_batch_commit_data_generator_mode: L1BatchCommitmentMode::Rollup,
dummy_verifier: true,
l2_native_token_vault_proxy_addr: Some(Address::repeat_byte(7)),
Expand Down Expand Up @@ -1421,6 +1428,7 @@ impl From<&ExternalNodeConfig> for InternalApiConfig {
dummy_verifier: config.remote.dummy_verifier,
l1_batch_commit_data_generator_mode: config.remote.l1_batch_commit_data_generator_mode,
l2_native_token_vault_proxy_addr: config.remote.l2_native_token_vault_proxy_addr,
l2_legacy_shared_bridge_addr: config.remote.l2_legacy_shared_bridge_addr,
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions core/bin/external_node/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ impl ExternalNodeBuilder {
.remote
.l2_native_token_vault_proxy_addr
.expect("L2 native token vault proxy address is not set"),
self.config
.remote
.l2_legacy_shared_bridge_addr
.expect("L2 legacy shared bridge address is not set"),
self.config.optional.l2_block_seal_queue_capacity,
)
.with_pre_insert_txs(true) // EN requires txs to be pre-inserted.
Expand Down
3 changes: 3 additions & 0 deletions core/bin/zksync_server/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ impl MainNodeBuilder {
self.contracts_config
.l2_native_token_vault_proxy_addr
.context("L2 native token vault proxy address")?,
self.contracts_config
.l2_legacy_shared_bridge_addr
.context("L2 legacy shared bridge address")?,
sk_config.l2_block_seal_queue_capacity,
)
.with_protective_reads_persistence_enabled(sk_config.protective_reads_persistence_enabled);
Expand Down
4 changes: 4 additions & 0 deletions core/lib/basic_types/src/protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ impl ProtocolVersionId {
self <= &Self::Version22
}

pub fn is_pre_gateway(&self) -> bool {
self <= &Self::Version24
}

pub fn is_1_4_0(&self) -> bool {
self >= &ProtocolVersionId::Version18 && self < &ProtocolVersionId::Version20
}
Expand Down
2 changes: 2 additions & 0 deletions core/lib/config/src/configs/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct ContractsConfig {
pub validator_timelock_addr: Address,
pub l1_shared_bridge_proxy_addr: Option<Address>,
pub l2_shared_bridge_addr: Option<Address>,
pub l2_legacy_shared_bridge_addr: Option<Address>,
pub l1_erc20_bridge_proxy_addr: Option<Address>,
pub l2_erc20_bridge_addr: Option<Address>,
pub l1_weth_bridge_proxy_addr: Option<Address>,
Expand Down Expand Up @@ -61,6 +62,7 @@ impl ContractsConfig {
l2_erc20_bridge_addr: Some(Address::repeat_byte(0x0c)),
l1_shared_bridge_proxy_addr: Some(Address::repeat_byte(0x0e)),
l2_shared_bridge_addr: Some(Address::repeat_byte(0x0f)),
l2_legacy_shared_bridge_addr: Some(Address::repeat_byte(0x10)),
l1_weth_bridge_proxy_addr: Some(Address::repeat_byte(0x0b)),
l2_weth_bridge_addr: Some(Address::repeat_byte(0x0c)),
l2_testnet_paymaster_addr: Some(Address::repeat_byte(0x11)),
Expand Down
1 change: 1 addition & 0 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ impl Distribution<configs::ContractsConfig> for EncodeDist {
l2_erc20_bridge_addr: self.sample_opt(|| rng.gen()),
l1_shared_bridge_proxy_addr: self.sample_opt(|| rng.gen()),
l2_shared_bridge_addr: self.sample_opt(|| rng.gen()),
l2_legacy_shared_bridge_addr: self.sample_opt(|| rng.gen()),
l1_weth_bridge_proxy_addr: self.sample_opt(|| rng.gen()),
l2_weth_bridge_addr: self.sample_opt(|| rng.gen()),
l2_testnet_paymaster_addr: self.sample_opt(|| rng.gen()),
Expand Down
4 changes: 2 additions & 2 deletions core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ const FORGE_PATH_PREFIX: &str = "contracts/l1-contracts/out";
const BRIDGEHUB_CONTRACT_FILE: (&str, &str) = ("bridgehub", "IBridgehub.sol/IBridgehub.json");
const STATE_TRANSITION_CONTRACT_FILE: (&str, &str) = (
"state-transition",
"IStateTransitionManager.sol/IStateTransitionManager.json",
"IChainTypeManager.sol/IChainTypeManager.json",
);
const ZKSYNC_HYPERCHAIN_CONTRACT_FILE: (&str, &str) = (
"state-transition/chain-interfaces",
"IZkSyncHyperchain.sol/IZkSyncHyperchain.json",
"IZKChain.sol/IZKChain.json",
);
const DIAMOND_INIT_CONTRACT_FILE: (&str, &str) = (
"state-transition",
Expand Down
2 changes: 2 additions & 0 deletions core/lib/env_config/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ mod tests {
l2_native_token_vault_proxy_addr: Some(addr(
"0xfc073319977e314f251eae6ae6be76b0b3baeecf",
)),
l2_legacy_shared_bridge_addr: Some(addr("0x8656770FA78c830456B00B4fFCeE6b1De0e1b888")),
chain_admin_addr: Some(addr("0xdd6fa5c14e7550b4caf2aa2818d24c69cbc347ff")),
l2_da_validator_addr: Some(addr("0xed6fa5c14e7550b4caf2aa2818d24c69cbc347ff")),
}
Expand Down Expand Up @@ -130,6 +131,7 @@ CONTRACTS_USER_FACING_DIAMOND_PROXY_ADDR="0xF00B988a98Ca742e7958DeF9F7823b590871
CONTRACTS_L2_NATIVE_TOKEN_VAULT_PROXY_ADDR="0xfc073319977e314f251eae6ae6be76b0b3baeecf"
CONTRACTS_L2_DA_VALIDATOR_ADDR="0xed6fa5c14e7550b4caf2aa2818d24c69cbc347ff"
CONTRACTS_CHAIN_ADMIN_ADDR="0xdd6fa5c14e7550b4caf2aa2818d24c69cbc347ff"
CONTRACTS_L2_LEGACY_SHARED_BRIDGE_ADDR="0x8656770FA78c830456B00B4fFCeE6b1De0e1b888"
"#;
lock.set_env(config);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use zksync_types::{
commitment::{L1BatchCommitmentMode, L1BatchWithMetadata},
ethabi::Token,
ethabi::{encode, Token},
pubdata_da::PubdataDA,
};

use crate::{
i_executor::structures::{CommitBatchInfo, StoredBatchInfo},
Tokenizable, Tokenize,
i_executor::structures::{CommitBatchInfo, StoredBatchInfo, SUPPORTED_ENCODING_VERSION},
Tokenizable,
};

/// Input required to encode `commitBatches` call for a contract
#[derive(Debug)]
pub struct CommitBatches<'a> {
Expand All @@ -18,15 +17,33 @@ pub struct CommitBatches<'a> {
pub mode: L1BatchCommitmentMode,
}

impl Tokenize for CommitBatches<'_> {
fn into_tokens(self) -> Vec<Token> {
impl CommitBatches<'_> {
pub fn into_tokens(self, pre_gateway: bool) -> Vec<Token> {
let stored_batch_info = StoredBatchInfo::from(self.last_committed_l1_batch).into_token();
let l1_batches_to_commit = self
let l1_batches_to_commit: Vec<Token> = self
.l1_batches
.iter()
.map(|batch| CommitBatchInfo::new(self.mode, batch, self.pubdata_da).into_token())
.collect();

vec![stored_batch_info, Token::Array(l1_batches_to_commit)]
let encoded_data = encode(&[
stored_batch_info.clone(),
Token::Array(l1_batches_to_commit.clone()),
]);
let commit_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
.concat()
.to_vec();
if pre_gateway {
vec![stored_batch_info, Token::Array(l1_batches_to_commit)]
} else {
vec![
Token::Uint((self.last_committed_l1_batch.header.number.0 + 1).into()),
Token::Uint(
(self.last_committed_l1_batch.header.number.0 + self.l1_batches.len() as u32)
.into(),
),
Token::Bytes(commit_data),
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use zksync_types::{
commitment::{L1BatchWithMetadata, PriorityOpsMerkleProof},
ethabi::Token,
ethabi::{encode, Token},
};

use crate::{i_executor::structures::StoredBatchInfo, Tokenizable, Tokenize};
use crate::{
i_executor::structures::{StoredBatchInfo, SUPPORTED_ENCODING_VERSION},
Tokenizable, Tokenize,
};

/// Input required to encode `executeBatches` call.
#[derive(Debug, Clone)]
Expand All @@ -14,7 +17,7 @@ pub struct ExecuteBatches {

impl Tokenize for &ExecuteBatches {
fn into_tokens(self) -> Vec<Token> {
vec![
let encoded_data = encode(&[
Token::Array(
self.l1_batches
.iter()
Expand All @@ -27,6 +30,15 @@ impl Tokenize for &ExecuteBatches {
.map(|proof| proof.into_token())
.collect(),
),
]);
let commit_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
.concat()
.to_vec();

vec![
Token::Uint((self.l1_batches[0].header.number.0).into()),
Token::Uint((self.l1_batches[self.l1_batches.len() - 1].header.number.0).into()),
Token::Bytes(commit_data),
]
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
use crypto_codegen::serialize_proof;
use zksync_prover_interface::outputs::L1BatchProofForL1;
use zksync_types::{commitment::L1BatchWithMetadata, ethabi::Token, U256};
use zksync_types::{
commitment::L1BatchWithMetadata,
ethabi::{encode, Token},
U256,
};

use crate::{i_executor::structures::StoredBatchInfo, Tokenizable, Tokenize};
use crate::{
i_executor::structures::{StoredBatchInfo, SUPPORTED_ENCODING_VERSION},
Tokenizable, Tokenize,
};

/// Input required to encode `proveBatches` call.
#[derive(Debug, Clone)]
Expand All @@ -15,7 +22,7 @@ pub struct ProveBatches {

impl Tokenize for &ProveBatches {
fn into_tokens(self) -> Vec<Token> {
let prev_l1_batch = StoredBatchInfo::from(&self.prev_l1_batch).into_token();
let prev_l1_batch_info = StoredBatchInfo::from(&self.prev_l1_batch).into_token();
let batches_arg = self
.l1_batches
.iter()
Expand All @@ -42,26 +49,46 @@ impl Tokenize for &ProveBatches {
.unwrap()
.is_pre_boojum()
{
Token::Array(
aggregation_result_coords
.iter()
.map(|bytes| Token::Uint(U256::from_big_endian(bytes)))
.collect(),
)
aggregation_result_coords
.iter()
.map(|bytes| Token::Uint(U256::from_big_endian(bytes)))
.collect()
} else {
Token::Array(Vec::new())
Vec::new()
};
let proof_input = Token::Tuple(vec![
aggregation_result_coords,
Token::Array(proof.into_iter().map(Token::Uint).collect()),
]);
let proof_input = Token::Array(
[
aggregation_result_coords,
proof.into_iter().map(Token::Uint).collect(),
]
.concat()
.to_vec(),
); // todo this changed, might have to be debugged.

let encoded_data = encode(&[prev_l1_batch_info, batches_arg, proof_input]);
let commit_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
.concat()
.to_vec();

vec![prev_l1_batch, batches_arg, proof_input]
vec![
Token::Uint((self.prev_l1_batch.header.number.0 + 1).into()),
Token::Uint(
(self.prev_l1_batch.header.number.0 + self.l1_batches.len() as u32).into(),
),
Token::Bytes(commit_data),
]
} else {
let encoded_data = encode(&[prev_l1_batch_info, batches_arg, Token::Array(vec![])]);
let commit_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
.concat()
.to_vec();

vec![
prev_l1_batch,
batches_arg,
Token::Tuple(vec![Token::Array(vec![]), Token::Array(vec![])]),
Token::Uint((self.prev_l1_batch.header.number.0 + 1).into()),
Token::Uint(
(self.prev_l1_batch.header.number.0 + self.l1_batches.len() as u32).into(),
),
Token::Bytes(commit_data),
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use zksync_types::{
pre_boojum_serialize_commitments, serialize_commitments, L1BatchCommitmentMode,
L1BatchWithMetadata,
},
ethabi::Token,
ethabi::{ParamType, Token},
pubdata_da::PubdataDA,
web3::{contract::Error as ContractError, keccak256},
ProtocolVersionId, H256, U256,
Expand Down Expand Up @@ -42,6 +42,21 @@ impl<'a> CommitBatchInfo<'a> {
}
}

pub fn schema() -> ParamType {
ParamType::Tuple(vec![
ParamType::Uint(64), // `batch_number`
ParamType::Uint(64), // `timestamp`
ParamType::Uint(64), // `index_repeated_storage_changes`
ParamType::FixedBytes(32), // `new_state_root`
ParamType::Uint(256), // `numberOfLayer1Txs`
ParamType::FixedBytes(32), // `priorityOperationsHash`
ParamType::FixedBytes(32), // `bootloaderHeapInitialContentsHash`
ParamType::FixedBytes(32), // `eventsQueueStateHash`
ParamType::Bytes, // `systemLogs`
ParamType::Bytes, // `operatorDAInput`
])
}

fn base_tokens(&self) -> Vec<Token> {
if self
.l1_batch_with_metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

mod commit_batch_info;
mod stored_batch_info;
pub const SUPPORTED_ENCODING_VERSION: u8 = 0;

pub use self::{commit_batch_info::CommitBatchInfo, stored_batch_info::StoredBatchInfo};
Loading
Loading