-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vm): Check protocol version for fast VM (#3080)
## What ❔ Fixes a regression introduced by #2915: The protocol version is now not checked before instantiating a fast VM. ## Why ❔ Without this check, fast VM can be used with old protocol versions, which most likely will cause divergencies. ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk_supervisor fmt` and `zk_supervisor lint`.
- Loading branch information
Showing
8 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ pub mod batch; | |
pub mod oneshot; | ||
mod shared; | ||
pub mod storage; | ||
#[cfg(test)] | ||
mod testonly; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use once_cell::sync::Lazy; | ||
use zksync_contracts::BaseSystemContracts; | ||
use zksync_multivm::{ | ||
interface::{L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode}, | ||
vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT, | ||
}; | ||
use zksync_types::{ | ||
block::L2BlockHasher, fee_model::BatchFeeInput, vm::FastVmMode, Address, L1BatchNumber, | ||
L2BlockNumber, L2ChainId, ProtocolVersionId, H256, ZKPORTER_IS_AVAILABLE, | ||
}; | ||
|
||
static BASE_SYSTEM_CONTRACTS: Lazy<BaseSystemContracts> = | ||
Lazy::new(BaseSystemContracts::load_from_disk); | ||
|
||
pub(crate) const FAST_VM_MODES: [FastVmMode; 3] = | ||
[FastVmMode::Old, FastVmMode::New, FastVmMode::Shadow]; | ||
|
||
pub(crate) fn default_system_env(execution_mode: TxExecutionMode) -> SystemEnv { | ||
SystemEnv { | ||
zk_porter_available: ZKPORTER_IS_AVAILABLE, | ||
version: ProtocolVersionId::latest(), | ||
base_system_smart_contracts: BASE_SYSTEM_CONTRACTS.clone(), | ||
bootloader_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, | ||
execution_mode, | ||
default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, | ||
chain_id: L2ChainId::default(), | ||
} | ||
} | ||
|
||
pub(crate) fn default_l1_batch_env(number: u32) -> L1BatchEnv { | ||
L1BatchEnv { | ||
previous_batch_hash: Some(H256::zero()), | ||
number: L1BatchNumber(number), | ||
timestamp: number.into(), | ||
fee_account: Address::repeat_byte(0x22), | ||
enforced_base_fee: None, | ||
first_l2_block: L2BlockEnv { | ||
number, | ||
timestamp: number.into(), | ||
prev_block_hash: L2BlockHasher::legacy_hash(L2BlockNumber(number - 1)), | ||
max_virtual_blocks_to_create: 1, | ||
}, | ||
fee_input: BatchFeeInput::sensible_l1_pegged_default(), | ||
} | ||
} |