-
Notifications
You must be signed in to change notification settings - Fork 82
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: Adding (experimental) zkos support #534
Changes from 17 commits
ec43b7b
335e517
43ea953
fe9ba56
a5fe970
0135ab3
950bd16
c056f79
4c7e85d
75abde3
b660e23
d787a7d
73e04c9
a53b3b3
cb8bdbf
7214f87
0cd8a0d
d9ec694
0f947cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg_attr(feature = "zkos", feature(allocator_api))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, we are using stable rust now, is this absolutely necessary for zkos? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes :-( |
||
//! anvil-zksync | ||
//! | ||
//! The `anvil-zksync` crate provides an in-memory node designed primarily for local testing. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,13 +36,17 @@ use std::sync::Arc; | |
use tokio::sync::RwLock; | ||
use zksync_contracts::BaseSystemContracts; | ||
use zksync_multivm::interface::storage::{ReadStorage, StoragePtr}; | ||
#[cfg(not(feature = "zkos"))] | ||
use zksync_multivm::interface::VmFactory; | ||
use zksync_multivm::interface::{ | ||
ExecutionResult, InspectExecutionMode, L1BatchEnv, L2BlockEnv, TxExecutionMode, VmFactory, | ||
VmInterface, | ||
ExecutionResult, InspectExecutionMode, L1BatchEnv, L2BlockEnv, TxExecutionMode, VmInterface, | ||
}; | ||
use zksync_multivm::tracers::CallTracer; | ||
use zksync_multivm::utils::{get_batch_base_fee, get_max_batch_gas_limit}; | ||
use zksync_multivm::vm_latest::{HistoryDisabled, ToTracerPointer, Vm}; | ||
#[cfg(not(feature = "zkos"))] | ||
use zksync_multivm::vm_latest::Vm; | ||
|
||
use zksync_multivm::vm_latest::{HistoryDisabled, ToTracerPointer}; | ||
use zksync_multivm::VmVersion; | ||
use zksync_types::api::{Block, DebugCall, TransactionReceipt, TransactionVariant}; | ||
use zksync_types::block::unpack_block_info; | ||
|
@@ -306,6 +310,18 @@ impl InMemoryNode { | |
Ok(()) | ||
} | ||
|
||
/// Whether it accepts the transactions that have 'null' as target. | ||
/// This is used only when EVM emulator is enabled, or we're running in zkos mode. | ||
pub fn allow_no_target(&self) -> bool { | ||
#[cfg(feature = "zkos")] | ||
return true; | ||
#[cfg(not(feature = "zkos"))] | ||
self.system_contracts | ||
.contracts_for_l2_call() | ||
.evm_emulator | ||
.is_some() | ||
} | ||
|
||
/// Applies multiple transactions across multiple blocks. All transactions are expected to be | ||
/// executable. Note that on error this method may leave node in partially applied state (i.e. | ||
/// some txs have been applied while others have not). | ||
|
@@ -381,7 +397,17 @@ impl InMemoryNode { | |
let system_env = inner.create_system_env(base_contracts, execution_mode); | ||
|
||
let storage = StorageView::new(&inner.fork_storage).into_rc_ptr(); | ||
|
||
#[cfg(not(feature = "zkos"))] | ||
let mut vm: Vm<_, HistoryDisabled> = Vm::new(batch_env, system_env, storage); | ||
#[cfg(feature = "zkos")] | ||
let mut vm: super::zkos::ZKOsVM<_, HistoryDisabled> = super::zkos::ZKOsVM::new( | ||
batch_env, | ||
system_env, | ||
storage, | ||
// TODO: this might be causing a deadlock.. check.. | ||
&inner.fork_storage.inner.read().unwrap().raw_storage, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am in the process of getting rid of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, short term, I need a way to iterate over all elements from the storage. |
||
); | ||
|
||
// We must inject *some* signature (otherwise bootloader code fails to generate hash). | ||
if l2_tx.common_data.signature.is_empty() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually needed? We purposefully got rid of it in favour of
zksync_types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using a bunch of methods from there (mostly to move things between u256 and h256) -- but as we have 'todo' Ican remove it for now.