Skip to content

Commit

Permalink
Mirrors branch jms-vm-version from private at 09453a34e8c66a8ea67f2f2…
Browse files Browse the repository at this point in the history
…b459c7a6d8b3ecae8
  • Loading branch information
shahar4 committed Oct 2, 2023
1 parent e806bf5 commit 3b09ee6
Show file tree
Hide file tree
Showing 130 changed files with 10,373 additions and 561 deletions.
182 changes: 131 additions & 51 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion core/bin/storage_logs_dedup_migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "storage_logs_dedup_migration"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"

[[bin]]
name = "storage_logs_dedup_migration"
Expand Down
3 changes: 1 addition & 2 deletions core/bin/verification_key_generator_and_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "zksync_verification_key_generator_and_server"
version = "0.1.0"
edition = "2018"
license = "MIT OR Apache-2.0"

[lib]
name = "zksync_verification_key_server"
Expand All @@ -24,7 +23,7 @@ path = "src/commitment_generator.rs"
zksync_types = { path = "../../lib/types" }
zksync_prover_utils = { path = "../../lib/prover_utils" }
vlog = { path = "../../lib/vlog" }
circuit_testing = { git = "https://github.com/matter-labs/era-circuit_testing.git", branch = "main" }
circuit_testing = { git = "https://github.com/matter-labs/circuit_testing.git", branch = "main" }
itertools = "0.10.5"
bincode = "1.3.3"

Expand Down
2 changes: 1 addition & 1 deletion core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub struct SystemContractsRepo {
impl SystemContractsRepo {
/// Returns the default system contracts repo with directory based on the ZKSYNC_HOME environment variable.
pub fn from_env() -> Self {
let zksync_home = std::env::var("ZKSYNC_HOME").unwrap_or_else(|_| ".".into());
let zksync_home = std::env::var("ZKSYNC_HOME").expect("ZKSYNC_HOME env variable not set.");
let zksync_home = PathBuf::from(zksync_home);
SystemContractsRepo {
root: zksync_home.join("etc/system-contracts"),
Expand Down
12 changes: 6 additions & 6 deletions core/lib/dal/src/models/storage_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,21 +363,21 @@ impl StorageBlockDetails {
.map(|hash| H256::from_str(hash).expect("Incorrect commit_tx hash")),
committed_at: self
.committed_at
.map(|committed_at| DateTime::from_naive_utc_and_offset(committed_at, Utc)),
.map(|committed_at| DateTime::<Utc>::from_utc(committed_at, Utc)),
prove_tx_hash: self
.prove_tx_hash
.as_deref()
.map(|hash| H256::from_str(hash).expect("Incorrect prove_tx hash")),
proven_at: self
.proven_at
.map(|proven_at| DateTime::<Utc>::from_naive_utc_and_offset(proven_at, Utc)),
.map(|proven_at| DateTime::<Utc>::from_utc(proven_at, Utc)),
execute_tx_hash: self
.execute_tx_hash
.as_deref()
.map(|hash| H256::from_str(hash).expect("Incorrect execute_tx hash")),
executed_at: self
.executed_at
.map(|executed_at| DateTime::<Utc>::from_naive_utc_and_offset(executed_at, Utc)),
.map(|executed_at| DateTime::<Utc>::from_utc(executed_at, Utc)),
l1_gas_price: self.l1_gas_price as u64,
l2_fair_gas_price: self.l2_fair_gas_price as u64,
base_system_contracts_hashes: convert_base_system_contracts_hashes(
Expand Down Expand Up @@ -439,21 +439,21 @@ impl From<StorageL1BatchDetails> for api::L1BatchDetails {
.map(|hash| H256::from_str(hash).expect("Incorrect commit_tx hash")),
committed_at: details
.committed_at
.map(|committed_at| DateTime::<Utc>::from_naive_utc_and_offset(committed_at, Utc)),
.map(|committed_at| DateTime::<Utc>::from_utc(committed_at, Utc)),
prove_tx_hash: details
.prove_tx_hash
.as_deref()
.map(|hash| H256::from_str(hash).expect("Incorrect prove_tx hash")),
proven_at: details
.proven_at
.map(|proven_at| DateTime::<Utc>::from_naive_utc_and_offset(proven_at, Utc)),
.map(|proven_at| DateTime::<Utc>::from_utc(proven_at, Utc)),
execute_tx_hash: details
.execute_tx_hash
.as_deref()
.map(|hash| H256::from_str(hash).expect("Incorrect execute_tx hash")),
executed_at: details
.executed_at
.map(|executed_at| DateTime::<Utc>::from_naive_utc_and_offset(executed_at, Utc)),
.map(|executed_at| DateTime::<Utc>::from_utc(executed_at, Utc)),
l1_gas_price: details.l1_gas_price as u64,
l2_fair_gas_price: details.l2_fair_gas_price as u64,
base_system_contracts_hashes: convert_base_system_contracts_hashes(
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/models/storage_prover_job_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct StorageProverJobInfo {
impl From<StorageProverJobInfo> for ProverJobInfo {
fn from(x: StorageProverJobInfo) -> Self {
fn nt2d(nt: NaiveDateTime) -> DateTime<Utc> {
DateTime::from_naive_utc_and_offset(nt, Utc)
DateTime::from_utc(nt, Utc)
}

let status = match ProverJobStatus::from_str(x.status.as_str())
Expand Down
6 changes: 3 additions & 3 deletions core/lib/dal/src/models/storage_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ impl StorageSyncBlock {
.map(|hash| H256::from_str(hash).expect("Incorrect commit_tx hash")),
committed_at: self
.committed_at
.map(|committed_at| DateTime::<Utc>::from_naive_utc_and_offset(committed_at, Utc)),
.map(|committed_at| DateTime::<Utc>::from_utc(committed_at, Utc)),
prove_tx_hash: self
.prove_tx_hash
.as_deref()
.map(|hash| H256::from_str(hash).expect("Incorrect prove_tx hash")),
proven_at: self
.proven_at
.map(|proven_at| DateTime::<Utc>::from_naive_utc_and_offset(proven_at, Utc)),
.map(|proven_at| DateTime::<Utc>::from_utc(proven_at, Utc)),
execute_tx_hash: self
.execute_tx_hash
.as_deref()
.map(|hash| H256::from_str(hash).expect("Incorrect execute_tx hash")),
executed_at: self
.executed_at
.map(|executed_at| DateTime::<Utc>::from_naive_utc_and_offset(executed_at, Utc)),
.map(|executed_at| DateTime::<Utc>::from_utc(executed_at, Utc)),
l1_gas_price: self.l1_gas_price as u64,
l2_fair_gas_price: self.l2_fair_gas_price as u64,
// TODO (SMA-1635): Make these filed non optional in database
Expand Down
4 changes: 2 additions & 2 deletions core/lib/dal/src/models/storage_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl From<StorageTokenPrice> for Option<TokenPrice> {
match (&price.usd_price, price.usd_price_updated_at) {
(Some(usd_price), Some(updated_at)) => Some(TokenPrice {
usd_price: big_decimal_to_ratio(usd_price).unwrap(),
last_updated: DateTime::<Utc>::from_naive_utc_and_offset(updated_at, Utc),
last_updated: DateTime::<Utc>::from_utc(updated_at, Utc),
}),
(None, None) => None,
_ => {
Expand Down Expand Up @@ -62,7 +62,7 @@ impl From<StorageTokenMarketVolume> for Option<TokenMarketVolume> {
.as_ref()
.map(|volume| TokenMarketVolume {
market_volume: big_decimal_to_ratio(volume).unwrap(),
last_updated: DateTime::<Utc>::from_naive_utc_and_offset(
last_updated: DateTime::<Utc>::from_utc(
market_volume
.market_volume_updated_at
.expect("If `market_volume` is Some then `updated_at` must be Some"),
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/models/storage_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ impl From<StorageTransactionDetails> for TransactionDetails {
bigdecimal_to_u256(tx_details.gas_per_pubdata_limit.unwrap_or_default());

let initiator_address = H160::from_slice(tx_details.initiator_address.as_slice());
let received_at = DateTime::<Utc>::from_naive_utc_and_offset(tx_details.received_at, Utc);
let received_at = DateTime::<Utc>::from_utc(tx_details.received_at, Utc);

let eth_commit_tx_hash = tx_details
.eth_commit_tx_hash
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/models/storage_witness_job_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct StorageWitnessJobInfo {
impl From<StorageWitnessJobInfo> for WitnessJobInfo {
fn from(x: StorageWitnessJobInfo) -> Self {
fn nt2d(nt: NaiveDateTime) -> DateTime<Utc> {
DateTime::from_naive_utc_and_offset(nt, Utc)
DateTime::from_utc(nt, Utc)
}

let status =
Expand Down
1 change: 0 additions & 1 deletion core/lib/db_test_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "db_test_macro"
version = "0.1.0"
authors = ["The Matter Labs Team <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"

[lib]
proc-macro = true
Expand Down
1 change: 1 addition & 0 deletions core/lib/multivm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ vm_m5 = { path = "../../multivm_deps/vm_m5" }
vm_m6 = { path = "../../multivm_deps/vm_m6" }
vm_1_3_2 = { path = "../../multivm_deps/vm_1_3_2" }
vm_latest = { path = "../vm", package = "vm" }
vm_virtual_blocks = { path = "../../multivm_deps/vm_virtual_blocks" }

zksync_types = { path = "../types" }
zksync_state = { path = "../state" }
Expand Down
6 changes: 3 additions & 3 deletions core/lib/multivm/src/glue/block_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ impl BlockProperties {
};
Self::Vm1_3_2(inner)
}
VmVersion::VmVirtualBlocks => {
VmVersion::VmVirtualBlocks | VmVersion::VmTimelessHistory => {
unreachable!(
"Vm with virtual blocks has another initialization logic, \
so it's not required to have BlockProperties for it"
"VmVirtualBlocks and VmTimelessHistory have different initialization logic,\
so it's not required to have BlockProperties for them"
)
}
}
Expand Down
45 changes: 25 additions & 20 deletions core/lib/multivm/src/glue/history_mode.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
use crate::glue::{GlueFrom, GlueInto};

pub trait HistoryMode: Default + GlueInto<Self::VmM6Mode> + GlueInto<Self::Vm1_3_2Mode> {
pub trait HistoryMode:
Default
+ GlueInto<Self::VmM6Mode>
+ GlueInto<Self::Vm1_3_2Mode>
+ GlueInto<Self::VmVirtualBlocksMode>
{
type VmM6Mode: vm_m6::HistoryMode;
type Vm1_3_2Mode: vm_1_3_2::HistoryMode;
type VmVirtualBlocksMode: vm_1_3_2::HistoryMode;
type VmVirtualBlocksMode: vm_virtual_blocks::HistoryMode;
}

impl GlueFrom<vm_1_3_2::HistoryEnabled> for vm_m6::HistoryEnabled {
fn glue_from(_: vm_1_3_2::HistoryEnabled) -> Self {
impl GlueFrom<vm_virtual_blocks::HistoryEnabled> for vm_m6::HistoryEnabled {
fn glue_from(_: vm_virtual_blocks::HistoryEnabled) -> Self {
Self
}
}

// impl GlueFrom<vm_1_3_2::HistoryEnabled> for vm_1_3_2::HistoryEnabled {
// fn glue_from(_: vm_1_3_2::HistoryEnabled) -> Self {
// Self
// }
// }
impl GlueFrom<vm_virtual_blocks::HistoryEnabled> for vm_1_3_2::HistoryEnabled {
fn glue_from(_: vm_virtual_blocks::HistoryEnabled) -> Self {
Self
}
}

impl GlueFrom<vm_1_3_2::HistoryDisabled> for vm_m6::HistoryDisabled {
fn glue_from(_: vm_1_3_2::HistoryDisabled) -> Self {
impl GlueFrom<vm_virtual_blocks::HistoryDisabled> for vm_m6::HistoryDisabled {
fn glue_from(_: vm_virtual_blocks::HistoryDisabled) -> Self {
Self
}
}

// impl GlueFrom<vm_1_3_2::HistoryDisabled> for vm_1_3_2::HistoryDisabled {
// fn glue_from(_: vm_1_3_2::HistoryDisabled) -> Self {
// Self
// }
// }
impl GlueFrom<vm_virtual_blocks::HistoryDisabled> for vm_1_3_2::HistoryDisabled {
fn glue_from(_: vm_virtual_blocks::HistoryDisabled) -> Self {
Self
}
}

impl HistoryMode for vm_1_3_2::HistoryEnabled {
impl HistoryMode for vm_virtual_blocks::HistoryEnabled {
type VmM6Mode = vm_m6::HistoryEnabled;
type Vm1_3_2Mode = vm_1_3_2::HistoryEnabled;
type VmVirtualBlocksMode = vm_1_3_2::HistoryEnabled;
type VmVirtualBlocksMode = vm_virtual_blocks::HistoryEnabled;
}

impl HistoryMode for vm_1_3_2::HistoryDisabled {
impl HistoryMode for vm_virtual_blocks::HistoryDisabled {
type VmM6Mode = vm_m6::HistoryDisabled;
type Vm1_3_2Mode = vm_1_3_2::HistoryDisabled;
type VmVirtualBlocksMode = vm_1_3_2::HistoryDisabled;
type VmVirtualBlocksMode = vm_virtual_blocks::HistoryDisabled;
}
16 changes: 15 additions & 1 deletion core/lib/multivm/src/glue/init_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ impl<'a, S: ReadStorage, H: HistoryMode> VmInstance<'a, S, H> {
}
}
VmInstanceData::VmVirtualBlocks(data) => {
let vm = vm_latest::Vm::new(
let vm = vm_virtual_blocks::Vm::new(
l1_batch_env.glue_into(),
system_env.clone(),
data.storage_view.clone(),
H::VmVirtualBlocksMode::default(),
);
let vm = VmInstanceVersion::VmVirtualBlocks(Box::new(vm));
Self {
Expand All @@ -81,6 +82,19 @@ impl<'a, S: ReadStorage, H: HistoryMode> VmInstance<'a, S, H> {
last_tx_compressed_bytecodes: vec![],
}
}
VmInstanceData::VmTimelessHistory(storage_view) => {
let vm = vm_latest::Vm::new(
l1_batch_env.glue_into(),
system_env.clone(),
storage_view.clone(),
);
let vm = VmInstanceVersion::VmTimelessHistory(Box::new(vm));
Self {
vm,
system_env,
last_tx_compressed_bytecodes: vec![],
}
}
}
}
}
7 changes: 2 additions & 5 deletions core/lib/multivm/src/glue/oracle_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ where
let oracle_tools = vm_m6::OracleTools::new(state, history.glue_into());
OracleTools::M6(oracle_tools)
}
VmVersion::Vm1_3_2 => {
panic!("oracle tools for vm1.3.2 do not exist")
}
VmVersion::VmVirtualBlocks => {
panic!("oracle tools for VmVirtualBlocks do not exist")
_ => {
panic!("Oracle tools for post vm1_3_2 don't exist")
}
}
}
Expand Down
47 changes: 47 additions & 0 deletions core/lib/multivm/src/glue/tracer/implementations.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use crate::glue::tracer::IntoVmVirtualBlocksTracer;
use vm_latest::{CallTracer, StorageInvocations, ValidationTracer};
use zksync_state::WriteStorage;

impl<S, H> IntoVmVirtualBlocksTracer<S, H> for StorageInvocations
where
H: vm_virtual_blocks::HistoryMode,
S: WriteStorage,
{
fn vm_virtual_blocks(&self) -> Box<dyn vm_virtual_blocks::VmTracer<S, H>> {
Box::new(vm_virtual_blocks::StorageInvocations::new(self.limit))
}
}

impl<S, H> IntoVmVirtualBlocksTracer<S, H> for CallTracer
where
H: vm_virtual_blocks::HistoryMode + 'static,
S: WriteStorage,
{
fn vm_virtual_blocks(&self) -> Box<dyn vm_virtual_blocks::VmTracer<S, H>> {
Box::new(vm_virtual_blocks::CallTracer::new(
self.result.clone(),
H::default(),
))
}
}

impl<S, H> IntoVmVirtualBlocksTracer<S, H> for ValidationTracer
where
H: vm_virtual_blocks::HistoryMode + 'static,
S: WriteStorage,
{
fn vm_virtual_blocks(&self) -> Box<dyn vm_virtual_blocks::VmTracer<S, H>> {
let params = self.params();
Box::new(vm_virtual_blocks::ValidationTracer::new(
vm_virtual_blocks::ValidationTracerParams {
user_address: params.user_address,
paymaster_address: params.paymaster_address,
trusted_slots: params.trusted_slots,
trusted_addresses: params.trusted_addresses,
trusted_address_slots: params.trusted_address_slots,
computational_gas_limit: params.computational_gas_limit,
},
self.result.clone(),
))
}
}
Loading

0 comments on commit 3b09ee6

Please sign in to comment.