Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Oppen committed Jan 12, 2024
1 parent 22c7164 commit 573975a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 21 deletions.
5 changes: 2 additions & 3 deletions core/lib/multivm/src/versions/vm_latest/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ const INITIAL_BASE_PAGE: u32 = 8;
pub const BOOTLOADER_HEAP_PAGE: u32 = heap_page_from_base(MemoryPage(INITIAL_BASE_PAGE)).0;
pub const BLOCK_OVERHEAD_GAS: u32 = 1200000;
pub const BLOCK_OVERHEAD_L1_GAS: u32 = 1000000;
pub const L1_GAS_PER_PUBDATA_BYTE: u32 = match core::option_env!("ETH_SENDER_SENDER_VALIDIUM_MODE")
{
pub const L1_GAS_PER_PUBDATA_BYTE: u32 = match core::option_env!("VALIDIUM_MODE") {
Some(_) => 0,
_ => zksync_system_constants::L1_GAS_PER_PUBDATA_BYTE,
};
pub const BLOCK_OVERHEAD_PUBDATA: u32 = match core::option_env!("ETH_SENDER_SENDER_VALIDIUM_MODE") {
pub const BLOCK_OVERHEAD_PUBDATA: u32 = match core::option_env!("VALIDIUM_MODE") {
Some(_) => 0,
_ => BLOCK_OVERHEAD_L1_GAS / L1_GAS_PER_PUBDATA_BYTE,
};
Expand Down
7 changes: 0 additions & 7 deletions core/lib/multivm/src/versions/vm_latest/old_vm/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use zk_evm_1_4_0::{
},
};
use zksync_state::WriteStorage;
use zksync_system_constants::L1_GAS_PER_PUBDATA_BYTE;
use zksync_types::{Address, U256};

use crate::vm_latest::{
Expand Down Expand Up @@ -96,12 +95,6 @@ pub(crate) fn precompile_calls_count_after_timestamp(
sorted_timestamps.len() - sorted_timestamps.partition_point(|t| *t < from_timestamp)
}

pub(crate) fn eth_price_per_pubdata_byte(l1_gas_price: u64) -> u64 {
// This value will typically be a lot less than u64
// unless the gas price on L1 goes beyond tens of millions of gwei
l1_gas_price * (L1_GAS_PER_PUBDATA_BYTE as u64)
}

pub(crate) fn vm_may_have_ended_inner<S: WriteStorage, H: HistoryMode>(
vm: &ZkSyncVmState<S, H>,
) -> Option<VmExecutionResult> {
Expand Down
6 changes: 2 additions & 4 deletions core/lib/multivm/src/versions/vm_latest/tracers/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,15 @@ use crate::{
vm_latest::{
bootloader_state::BootloaderState,
constants::{BOOTLOADER_HEAP_PAGE, OPERATOR_REFUNDS_OFFSET, TX_GAS_LIMIT_OFFSET},
old_vm::{
events::merge_events, history_recorder::HistoryMode, memory::SimpleMemory,
utils::eth_price_per_pubdata_byte,
},
old_vm::{events::merge_events, history_recorder::HistoryMode, memory::SimpleMemory},
tracers::{
traits::VmTracer,
utils::{
gas_spent_on_bytecodes_and_long_messages_this_opcode, get_vm_hook_params, VmHook,
},
},
types::internals::ZkSyncVmState,
utils::fee::eth_price_per_pubdata_byte,
},
};

Expand Down
8 changes: 7 additions & 1 deletion core/lib/multivm/src/versions/vm_latest/utils/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
use zksync_system_constants::MAX_GAS_PER_PUBDATA_BYTE;
use zksync_utils::ceil_div;

use crate::vm_latest::old_vm::utils::eth_price_per_pubdata_byte;
use crate::vm_latest::constants::L1_GAS_PER_PUBDATA_BYTE;

pub(crate) fn eth_price_per_pubdata_byte(l1_gas_price: u64) -> u64 {
// This value will typically be a lot less than u64
// unless the gas price on L1 goes beyond tens of millions of gwei
l1_gas_price * (L1_GAS_PER_PUBDATA_BYTE as u64)
}

/// Calculates the amount of gas required to publish one byte of pubdata
pub fn base_fee_to_gas_per_pubdata(l1_gas_price: u64, base_fee: u64) -> u64 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ const INITIAL_BASE_PAGE: u32 = 8;
pub const BOOTLOADER_HEAP_PAGE: u32 = heap_page_from_base(MemoryPage(INITIAL_BASE_PAGE)).0;
pub const BLOCK_OVERHEAD_GAS: u32 = 1200000;
pub const BLOCK_OVERHEAD_L1_GAS: u32 = 1000000;
pub const L1_GAS_PER_PUBDATA_BYTE: u32 = match core::option_env!("ETH_SENDER_SENDER_VALIDIUM_MODE")
{
pub const L1_GAS_PER_PUBDATA_BYTE: u32 = match core::option_env!("VALIDIUM_MODE") {
Some(_) => 0,
_ => zksync_system_constants::L1_GAS_PER_PUBDATA_BYTE,
};
pub const BLOCK_OVERHEAD_PUBDATA: u32 = match core::option_env!("ETH_SENDER_SENDER_VALIDIUM_MODE") {
pub const BLOCK_OVERHEAD_PUBDATA: u32 = match core::option_env!("VALIDIUM_MODE") {
Some(_) => 0,
_ => BLOCK_OVERHEAD_L1_GAS / L1_GAS_PER_PUBDATA_BYTE,
};
Expand Down
5 changes: 2 additions & 3 deletions core/lib/multivm/src/versions/vm_virtual_blocks/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ const INITIAL_BASE_PAGE: u32 = 8;
pub const BOOTLOADER_HEAP_PAGE: u32 = heap_page_from_base(MemoryPage(INITIAL_BASE_PAGE)).0;
pub(crate) const BLOCK_OVERHEAD_GAS: u32 = 1200000;
pub(crate) const BLOCK_OVERHEAD_L1_GAS: u32 = 1000000;
pub const L1_GAS_PER_PUBDATA_BYTE: u32 = match core::option_env!("ETH_SENDER_SENDER_VALIDIUM_MODE")
{
pub const L1_GAS_PER_PUBDATA_BYTE: u32 = match core::option_env!("VALIDIUM_MODE") {
Some(_) => 0,
_ => zksync_system_constants::L1_GAS_PER_PUBDATA_BYTE,
};
pub const BLOCK_OVERHEAD_PUBDATA: u32 = match core::option_env!("ETH_SENDER_SENDER_VALIDIUM_MODE") {
pub const BLOCK_OVERHEAD_PUBDATA: u32 = match core::option_env!("VALIDIUM_MODE") {
Some(_) => 0,
_ => BLOCK_OVERHEAD_L1_GAS / L1_GAS_PER_PUBDATA_BYTE,
};
Expand Down
1 change: 1 addition & 0 deletions infrastructure/zk/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export async function init(initArgs: InitArgs = DEFAULT_ARGS) {
if (validiumMode) {
await announced('Setting up validium mode to true');
process.env.ETH_SENDER_SENDER_VALIDIUM_MODE = 'true';
process.env.VALIDIUM_MODE = 'true';
} else {
await announced('Setting up validium mode to false');
process.env.ETH_SENDER_SENDER_VALIDIUM_MODE = 'false';
Expand Down

0 comments on commit 573975a

Please sign in to comment.