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

chore: Additional gateway server cleanup #3405

Open
wants to merge 24 commits into
base: sync-layer-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6253a7c
first round of cleanup
StanislavBreadless Dec 18, 2024
168faff
more clenaup
StanislavBreadless Dec 18, 2024
4f09340
same contracts as in sls
StanislavBreadless Dec 18, 2024
e8b245e
Merge branch 'sb-sync-main-sls' into sb-additional-server-cleanup
StanislavBreadless Dec 18, 2024
8f25cc6
Merge branch 'sb-sync-main-sls' into sb-additional-server-cleanup
StanislavBreadless Dec 19, 2024
e2ce995
use old admin
StanislavBreadless Dec 19, 2024
c8f4371
upd contracts
StanislavBreadless Dec 19, 2024
a59e48e
fix using old admin
StanislavBreadless Dec 19, 2024
227beac
fmt
StanislavBreadless Dec 19, 2024
9052bed
fix ci
StanislavBreadless Dec 19, 2024
16a3ddd
remove public inner field for l2chainid
StanislavBreadless Dec 19, 2024
4fc96db
correct setting token setter
StanislavBreadless Dec 19, 2024
dd4e254
upd contracts
StanislavBreadless Dec 19, 2024
78f8edd
Merge branch 'sync-layer-stable' into sb-additional-server-cleanup
StanislavBreadless Dec 19, 2024
7fb08cf
fmt
StanislavBreadless Dec 19, 2024
3f3436a
more cleanup
StanislavBreadless Dec 20, 2024
cf3dc83
upd contracts
StanislavBreadless Dec 20, 2024
133709a
fix zkstack
StanislavBreadless Dec 20, 2024
8b568b8
maybe fix ci
StanislavBreadless Dec 20, 2024
7c1b816
latest contracts
StanislavBreadless Dec 20, 2024
87e2b51
fix commitment
StanislavBreadless Dec 20, 2024
7036882
fix ci 2
StanislavBreadless Dec 20, 2024
068dfe6
try fix ci 3
StanislavBreadless Dec 20, 2024
757ef37
remove contracts unit tests
StanislavBreadless Dec 20, 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Build Prover FRI GPU & Circuit Prover GPU with builtin setup data

on:
workflow_call:
secrets:
inputs:
image_tag_suffix:
description: "Commit sha or git tag for Docker tag"
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/ci-core-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ jobs:
run: |
ci_run zkstack dev contracts

# - name: Contracts unit tests
# run: ci_run yarn l1-contracts test

- name: Download compilers for contract verifier tests
run: ci_run zkstack contract-verifier init --zksolc-version=v1.5.3 --zkvyper-version=v1.5.4 --solc-version=0.8.26 --vyper-version=v0.3.10 --era-vm-solc-version=0.8.26-1.0.1 --only --chain era

Expand All @@ -82,7 +79,7 @@ jobs:
ci_run zkstack dev test rust
# Benchmarks are not tested by `cargo nextest` unless specified explicitly, and even then `criterion` harness is incompatible
# with how `cargo nextest` runs tests. Thus, we run criterion-based benchmark tests manually.
# ci_run cargo test --release -p vm-benchmark --bench oneshot --bench batch
ci_run cargo test --release -p vm-benchmark --bench oneshot --bench batch

loadtest:
runs-on: [ matterlabs-ci-runner-high-performance ]
Expand Down
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 34 files
+0 −65 contracts-review-prep.md
+4 −4 da-contracts/contracts/CalldataDA.sol
+7 −10 da-contracts/contracts/DAContractsErrors.sol
+1 −1 da-contracts/contracts/RollupL1DAValidator.sol
+0 −17 gas-bound-caller/hardhat.config.ts
+11 −4 l1-contracts/contracts/bridge/L1Nullifier.sol
+1 −1 l1-contracts/contracts/bridge/asset-router/AssetRouterBase.sol
+7 −1 l1-contracts/contracts/bridge/asset-router/L1AssetRouter.sol
+3 −4 l1-contracts/contracts/bridge/ntv/NativeTokenVault.sol
+5 −1 l1-contracts/contracts/bridgehub/CTMDeploymentTracker.sol
+4 −0 l1-contracts/contracts/common/L1ContractErrors.sol
+2 −0 l1-contracts/contracts/governance/ChainAdmin.sol
+86 −0 l1-contracts/contracts/governance/ChainAdminSingleOwner.sol
+37 −0 l1-contracts/contracts/governance/IChainAdminSingleOwner.sol
+8 −14 l1-contracts/contracts/state-transition/L1StateTransitionErrors.sol
+5 −5 l1-contracts/contracts/state-transition/data-availability/CalldataDA.sol
+3 −3 l1-contracts/contracts/state-transition/data-availability/CalldataDAGateway.sol
+2 −2 l1-contracts/contracts/state-transition/libraries/PriorityTree.sol
+22 −0 l1-contracts/deploy-scripts/AcceptAdmin.s.sol
+0 −4 l1-contracts/deploy-scripts/DeployL1.s.sol
+0 −15 l1-contracts/deploy-scripts/DeployL2Contracts.sol
+28 −4 l1-contracts/deploy-scripts/DeployUtils.s.sol
+2 −0 l1-contracts/deploy-scripts/GatewayCTMFromL1.s.sol
+4 −2 l1-contracts/deploy-scripts/GatewayPreparation.s.sol
+29 −5 l1-contracts/deploy-scripts/RegisterZKChain.s.sol
+5 −2 l1-contracts/deploy-scripts/Utils.sol
+1 −4 l1-contracts/deploy-scripts/upgrade/ChainUpgrade.s.sol
+7 −35 l1-contracts/deploy-scripts/upgrade/EcosystemUpgrade.s.sol
+6 −9 l1-contracts/test/foundry/l1/da-contracts-imports/DAContractsErrors.sol
+6 −30 l1-contracts/test/foundry/l1/integration/L1GatewayTests.t.sol
+2 −2 l1-contracts/test/foundry/l1/unit/concrete/Executor/Committing.t.sol
+9 −7 l1-contracts/test/foundry/l1/unit/concrete/state-transition/data-availability/CalldataDA.t.sol
+2 −2 l1-contracts/test/foundry/l1/unit/concrete/state-transition/data-availability/RelayedSLDAValidator.t.sol
+2 −2 l1-contracts/test/foundry/l1/unit/concrete/state-transition/libraries/PriorityTree/PriorityTree.t.sol
20 changes: 0 additions & 20 deletions core/bin/zksync_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ struct Cli {
/// Generate genesis block for the first contract deployment using temporary DB.
#[arg(long)]
genesis: bool,
/// FIXME: dangerous option. Should be decided within the team.
#[arg(long)]
clear_l1_txs_history: bool,
/// Comma-separated list of components to launch.
#[arg(
long,
Expand Down Expand Up @@ -170,23 +167,6 @@ fn main() -> anyhow::Result<()> {
.clone()
.context("observability config")?;

// // FIXME: don't merge this into prod
// if opt.clear_l1_txs_history {
// println!("Clearing L1 txs history!");

// let tokio_runtime = tokio::runtime::Builder::new_multi_thread()
// .enable_all()
// .build()?;

// tokio_runtime.block_on(async move {
// let database_secrets = secrets.database.clone().context("DatabaseSecrets").unwrap();
// delete_l1_txs_history(&database_secrets).await.unwrap();
// });

// println!("Complete!");
// return Ok(());
// }

let node = MainNodeBuilder::new(
configs,
wallets,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/basic_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl TryFrom<U256> for AccountTreeId {

/// ChainId in the ZKsync network.
#[derive(Copy, Clone, Debug, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct L2ChainId(pub u64);
pub struct L2ChainId(u64);

impl<'de> Deserialize<'de> for L2ChainId {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
Expand Down
13 changes: 5 additions & 8 deletions core/lib/basic_types/src/protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,15 @@ pub enum ProtocolVersionId {
Version25,
Version26,
Version27,
Version28,
}

impl ProtocolVersionId {
pub const fn latest() -> Self {
Self::Version27
Self::Version26
}

pub const fn next() -> Self {
Self::Version28
Self::Version27
}

pub fn try_from_packed_semver(packed_semver: U256) -> Result<Self, String> {
Expand Down Expand Up @@ -123,9 +122,8 @@ impl ProtocolVersionId {
ProtocolVersionId::Version23 => VmVersion::Vm1_5_0SmallBootloaderMemory,
ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version25 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version26 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version26 => VmVersion::VmGateway,
ProtocolVersionId::Version27 => VmVersion::VmGateway,
ProtocolVersionId::Version28 => VmVersion::VmGateway,
}
}

Expand Down Expand Up @@ -188,7 +186,7 @@ impl ProtocolVersionId {
}

pub const fn gateway_upgrade() -> Self {
ProtocolVersionId::Version27
ProtocolVersionId::Version26
}
}

Expand Down Expand Up @@ -293,9 +291,8 @@ impl From<ProtocolVersionId> for VmVersion {
ProtocolVersionId::Version23 => VmVersion::Vm1_5_0SmallBootloaderMemory,
ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version25 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version26 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version26 => VmVersion::VmGateway,
ProtocolVersionId::Version27 => VmVersion::VmGateway,
ProtocolVersionId::Version28 => VmVersion::VmGateway,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/lib/basic_types/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum VmVersion {
impl VmVersion {
/// Returns the latest supported VM version.
pub const fn latest() -> VmVersion {
Self::Vm1_5_0IncreasedBootloaderMemory
Self::VmGateway
}
}

Expand Down
5 changes: 1 addition & 4 deletions core/lib/config/src/configs/eth_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ impl EthConfig {
pubdata_sending_mode: PubdataSendingMode::Calldata,
tx_aggregation_paused: false,
tx_aggregation_only_prove_and_execute: false,
ignore_db_nonce: None,
priority_tree_start_index: Some(0),
time_in_mempool_in_l1_blocks_cap: 1800,
}),
Expand Down Expand Up @@ -94,7 +93,7 @@ pub struct SenderConfig {
pub max_txs_in_flight: u64,
/// The mode in which proofs are sent.
pub proof_sending_mode: ProofSendingMode,

/// Note, that it is used only for L1 transactions
pub max_aggregated_tx_gas: u32,
pub max_eth_tx_data_size: usize,
pub max_aggregated_blocks_to_commit: u32,
Expand All @@ -119,8 +118,6 @@ pub struct SenderConfig {
/// special mode specifically for gateway migration to decrease number of non-executed batches
#[serde(default = "SenderConfig::default_tx_aggregation_only_prove_and_execute")]
pub tx_aggregation_only_prove_and_execute: bool,
/// Used to ignore db nonce check for sender and only use the RPC one.
pub ignore_db_nonce: Option<bool>,
/// Index of the priority operation to start building the `PriorityMerkleTree` from.
pub priority_tree_start_index: Option<usize>,
/// Cap of time in mempool for price calculations
Expand Down
2 changes: 1 addition & 1 deletion core/lib/config/src/configs/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct GatewayChainConfig {
pub validator_timelock_addr: Address,
pub multicall3_addr: Address,
pub diamond_proxy_addr: Address,
// FIXME: there is no "governnace" for a chain, only an admin, we
// TODO: there is no "governace" for a chain, only an admin, we
// need to figure out what we mean here
pub chain_admin_addr: Option<Address>,
pub governance_addr: Address,
Expand Down
1 change: 0 additions & 1 deletion core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ impl Distribution<configs::eth_sender::SenderConfig> for EncodeDist {
pubdata_sending_mode: PubdataSendingMode::Calldata,
tx_aggregation_paused: false,
tx_aggregation_only_prove_and_execute: false,
ignore_db_nonce: None,
priority_tree_start_index: self.sample(rng),
time_in_mempool_in_l1_blocks_cap: self.sample(rng),
}
Expand Down
10 changes: 6 additions & 4 deletions core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,9 @@ impl BaseSystemContracts {
}

pub fn playground_gateway() -> Self {
// TODO: the value should be taken from the `multivm_bootloaders` folder
let bootloader_bytecode = read_bootloader_code("playground_batch");
let bootloader_bytecode = read_zbin_bytecode(
"etc/multivm_bootloaders/vm_gateway/playground_batch.yul/playground_batch.yul.zbin",
);
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

Expand Down Expand Up @@ -586,8 +587,9 @@ impl BaseSystemContracts {
}

pub fn estimate_gas_gateway() -> Self {
// TODO: the value should be taken from the `multivm_bootloaders` folder
let bootloader_bytecode = read_bootloader_code("fee_estimate");
let bootloader_bytecode = read_zbin_bytecode(
"etc/multivm_bootloaders/vm_gateway/fee_estimate.yul/fee_estimate.yul.zbin",
);
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

Expand Down
32 changes: 0 additions & 32 deletions core/lib/dal/src/transactions_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,38 +57,6 @@ pub struct TransactionsDal<'c, 'a> {
}

impl TransactionsDal<'_, '_> {
/// FIXME: remove this function in prod
pub async fn erase_l1_txs_history(&mut self) -> DalResult<()> {
sqlx::query!(
r#"
UPDATE transactions
SET
l1_block_number = 0
WHERE
l1_block_number IS NOT NULL;
"#
)
.instrument("erase_l1_txs_history")
.execute(self.storage)
.await?;

// We need this to ensure that the operators' nonce is not too high.
sqlx::query!(
r#"
UPDATE eth_txs
SET
nonce = 0
WHERE
nonce IS NOT NULL;
"#
)
.instrument("erase_l1_txs_history")
.execute(self.storage)
.await?;

Ok(())
}

pub async fn insert_transaction_l1(
&mut self,
tx: &L1Tx,
Expand Down
1 change: 0 additions & 1 deletion core/lib/env_config/src/eth_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ mod tests {
pubdata_sending_mode: PubdataSendingMode::Calldata,
tx_aggregation_only_prove_and_execute: false,
tx_aggregation_paused: false,
ignore_db_nonce: None,
priority_tree_start_index: None,
time_in_mempool_in_l1_blocks_cap: 2000,
}),
Expand Down
13 changes: 3 additions & 10 deletions core/lib/mini_merkle_tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,9 @@ pub trait HashEmptySubtree<L>: 'static + Send + Sync + Hasher<Hash = H256> {
/// Returns the hash of an empty subtree with the given depth.
/// Implementations are encouraged to cache the returned values.
fn empty_subtree_hash(&self, depth: usize) -> H256 {
// static EMPTY_TREE_HASHES: OnceCell<Vec<H256>> = OnceCell::new();
// EMPTY_TREE_HASHES.get_or_init(||

compute_empty_tree_hashes(self.empty_leaf_hash())[depth] //)[depth]
// We do not cache by default since then the cached values would be preserved
// for all implementations which is not correct for different leaves.
compute_empty_tree_hashes(self.empty_leaf_hash())[depth]
}

/// Returns an empty hash
Expand All @@ -352,12 +351,6 @@ impl HashEmptySubtree<[u8; 96]> for KeccakHasher {
}
}

// impl HashEmptySubtree<H256> for KeccakHasher {
// fn empty_leaf_hash(&self) -> H256 {
// self.hash_bytes(&self.0)
// }
// }

fn compute_empty_tree_hashes(empty_leaf_hash: H256) -> Vec<H256> {
iter::successors(Some(empty_leaf_hash), |hash| {
Some(KeccakHasher.compress(hash, hash))
Expand Down
111 changes: 0 additions & 111 deletions core/lib/multivm/src/versions/vm_latest/tests/constants.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
// use ethabi::Token;
// use itertools::Itertools;
// use zksync_types::{
// get_immutable_key, get_l2_message_root_init_logs, AccountTreeId, StorageKey, StorageLog,
// StorageLogKind, H256, IMMUTABLE_SIMULATOR_STORAGE_ADDRESS, L2_BRIDGEHUB_ADDRESS,
// L2_MESSAGE_ROOT_ADDRESS,
// };

// use crate::{
// // interface::{TxExecutionMode, VmExecutionMode, VmInterface},
// vm_latest::{
// tests::{
// tester::{DeployContractsTx, TxType, VmTesterBuilder},
// utils::read_message_root,
// },
// HistoryEnabled,
// },
// vm_m5::storage::Storage,
// };
/// Some of the constants of the system are implicitly calculated, but they may affect the code and so
/// we added additional checks on them to keep any unwanted changes of those apparent.
#[test]
Expand All @@ -26,95 +7,3 @@ fn test_that_bootloader_encoding_space_is_large_enoguh() {
);
assert!(encoding_space >= 330000, "Bootloader tx space is too small");
}

// Test that checks that the initial logs for the L2 Message Root are correct
// #[test]
// fn test_l2_message_root_init_logs() {
// let mut vm = VmTesterBuilder::new(HistoryEnabled)
// .with_empty_in_memory_storage()
// .with_execution_mode(TxExecutionMode::VerifyExecute)
// .with_random_rich_accounts(1)
// .build();

// let message_root_bytecode = read_message_root();
// let account = &mut vm.rich_accounts[0];
// let DeployContractsTx { tx, address, .. } = account.get_deploy_tx(
// &message_root_bytecode,
// Some(&[Token::Address(L2_BRIDGEHUB_ADDRESS)]),
// TxType::L2,
// );

// vm.vm.push_transaction(tx);
// let result = vm.vm.execute(VmExecutionMode::OneTx);
// assert!(!result.result.is_failed(), "Transaction wasn't successful");

// // That's the only key in the immutable simulator that should be changed. It depends on the address
// // of the deployed contract, so we check that the way it was generated for a random deployed contract is the same.
// let expected_change_immutable_key = get_immutable_key(&address, H256::zero());
// let expected_genesis_immutable_key = get_immutable_key(&L2_MESSAGE_ROOT_ADDRESS, H256::zero());

// let mut expected_init_logs = get_l2_message_root_init_logs()
// .into_iter()
// .map(|x| StorageLog {
// // We unify all the logs to all have the same kind
// kind: StorageLogKind::InitialWrite,
// key: x.key,
// value: x.value,
// })
// .collect::<Vec<_>>();

// let ordering = |a: &StorageLog, b: &StorageLog| match a.key.cmp(&b.key) {
// std::cmp::Ordering::Equal => a.value.cmp(&b.value),
// other => other,
// };

// expected_init_logs.sort_by(ordering);

// let correct_init_logs = vm
// .vm
// .storage
// .borrow_mut()
// .get_modified_storage_keys()
// .iter()
// .filter_map(|(&storage_key, &value)| {
// if *storage_key.address() == address {
// Some(StorageLog {
// kind: StorageLogKind::InitialWrite,
// key: StorageKey::new(
// // Note, that it in the end we will compare those with the genesis logs that
// // have the `L2_MESSAGE_ROOT_ADDRESS` as the address
// AccountTreeId::new(L2_MESSAGE_ROOT_ADDRESS),
// *storage_key.key(),
// ),
// value,
// })
// } else if *storage_key.address() == IMMUTABLE_SIMULATOR_STORAGE_ADDRESS {
// assert!(
// *storage_key.key() == expected_change_immutable_key,
// "Incorrect immutable key has been changed"
// );

// Some(StorageLog {
// kind: StorageLogKind::InitialWrite,
// key: StorageKey::new(
// AccountTreeId::new(IMMUTABLE_SIMULATOR_STORAGE_ADDRESS),
// // For comparison to work, we replace the immutable key with the one that is used for genesis
// expected_genesis_immutable_key,
// ),
// value,
// })
// } else {
// None
// }
// })
// .sorted_by(ordering)
// .collect::<Vec<_>>();

// assert_eq!(expected_init_logs, correct_init_logs);

// let batch_result = vm.vm.execute(VmExecutionMode::Batch);
// assert!(
// !batch_result.result.is_failed(),
// "Transaction wasn't successful"
// );
// }
1 change: 0 additions & 1 deletion core/lib/protobuf_config/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ impl ProtoRepr for proto::Sender {
.parse(),
tx_aggregation_only_prove_and_execute: self.tx_aggregation_paused.unwrap_or(false),
tx_aggregation_paused: self.tx_aggregation_only_prove_and_execute.unwrap_or(false),
ignore_db_nonce: None,
priority_tree_start_index: self.priority_op_start_index.map(|x| x as usize),
time_in_mempool_in_l1_blocks_cap: self
.time_in_mempool_in_l1_blocks_cap
Expand Down
Loading
Loading