Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c15cc41
Initial REVM runner integration
0xVolosnikov Feb 10, 2026
357a2a3
Clippy
0xVolosnikov Feb 10, 2026
6a0668c
Clippy
0xVolosnikov Feb 10, 2026
f5934e2
Typo
0xVolosnikov Feb 11, 2026
43beaee
Add more convenient conversion
0xVolosnikov Feb 11, 2026
8796014
Use new conversions
0xVolosnikov Feb 11, 2026
f1f2b56
Continue cleanup of conversions
0xVolosnikov Feb 11, 2026
123a15b
Copy storage_diff_comp and test it
0xVolosnikov Feb 12, 2026
52937ad
Cleanup conversions
0xVolosnikov Feb 12, 2026
1392d0b
Remove temp revm-runner integration
0xVolosnikov Feb 12, 2026
87b106f
Use ZKsyncTxRequest abstraction in tests
0xVolosnikov Feb 12, 2026
eed1ea9
Remove ethers from tests
0xVolosnikov Feb 12, 2026
d65451b
Fix compilation issues
0xVolosnikov Feb 12, 2026
15287bc
Update revm-precompiles in fuzzer
0xVolosnikov Feb 12, 2026
5688601
Clippy
0xVolosnikov Feb 12, 2026
78651a5
Fix tests
0xVolosnikov Feb 12, 2026
854dfa8
Clippy
0xVolosnikov Feb 12, 2026
c519a1d
Fmt
0xVolosnikov Feb 12, 2026
7077c56
Use ZKsyncTxEnvelope
0xVolosnikov Feb 12, 2026
2d44265
Update ZKsyncTxEnvelope usage
0xVolosnikov Feb 12, 2026
05fdaf6
Cleanup in tx envelopes
0xVolosnikov Feb 13, 2026
81bff5f
Clippy
0xVolosnikov Feb 13, 2026
13e2e2b
Style change
0xVolosnikov Feb 13, 2026
4c17924
Cleanup
0xVolosnikov Feb 13, 2026
ff99d15
Use L1TxBuilder pattern everywhere
0xVolosnikov Feb 13, 2026
d9342cd
Fix L1TxBuilder
0xVolosnikov Feb 13, 2026
ecc3143
Cleanup
0xVolosnikov Feb 13, 2026
10409d4
Cleanup in zksync tx
0xVolosnikov Feb 13, 2026
1934870
Renaming
0xVolosnikov Feb 13, 2026
808408f
Clippy
0xVolosnikov Feb 13, 2026
763bf1b
Remove revm runner
0xVolosnikov Feb 13, 2026
7090727
Cleanup
0xVolosnikov Feb 13, 2026
5bc0905
Re-enable risc-v run
0xVolosnikov Feb 13, 2026
4b86b7d
Move encoding to tests/common
0xVolosnikov Feb 13, 2026
e683d0c
Update service tx tests
0xVolosnikov Feb 13, 2026
142b38e
Fix compilation issues
0xVolosnikov Feb 18, 2026
ddf1dfe
Merge branch 'dev' into vv-testing-refactoring-tx-unification
0xVolosnikov Feb 18, 2026
48ec188
Fix after merging dev
0xVolosnikov Feb 18, 2026
4998b5d
Fix fuzzer compilation
0xVolosnikov Feb 18, 2026
4e2ae9c
Fix after merge
0xVolosnikov Feb 18, 2026
67354af
Clippy
0xVolosnikov Feb 18, 2026
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ members = [
"supporting_crates/solidity_abi",
"supporting_crates/solidity_abi_derive",
"basic_system/src/system_implementation/ethereum_storage_model/supporting_crates/cc-traits",
"tests/common",
"tests/rig",
"tests/instances/transactions",
"tests/instances/erc20",
Expand Down
2 changes: 2 additions & 0 deletions api/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ pub fn set_properties_code(account: &mut AccountProperties, evm_code: &[u8]) ->
///
/// Internal tx encoding method.
///
/// TODO: cleanup
///
#[allow(clippy::too_many_arguments)]
pub fn encode_tx(
tx_type: u8,
Expand Down
30 changes: 15 additions & 15 deletions forward_system/src/run/convert.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::run::convert_alloy::{FromAlloy, IntoAlloy};
use alloy::consensus::{Header, Sealed};
use alloy::primitives::Log;
use basic_bootloader::bootloader::block_header::BlockHeader;
use ruint::aliases::B160;
use zk_ee::common_structs::GenericEventContent;
use zk_ee::system::metadata::zk_metadata::{BlockHashes, BlockMetadataFromOracle};
use zk_ee::types_config::EthereumIOTypesConfig;
Expand All @@ -26,7 +26,7 @@ impl FromInterface<BlockContext> for BlockMetadataFromOracle {
eip1559_basefee: value.eip1559_basefee,
pubdata_price: value.pubdata_price,
native_price: value.native_price,
coinbase: B160::from_be_bytes(value.coinbase.0 .0),
coinbase: ruint::aliases::B160::from_alloy(value.coinbase),
gas_limit: value.gas_limit,
pubdata_limit: value.pubdata_limit,
mix_hash: value.mix_hash,
Expand Down Expand Up @@ -54,7 +54,7 @@ impl IntoInterface<InvalidTransaction>
basic_bootloader::bootloader::errors::InvalidTransaction::NonceTooHigh { tx, state } => { InvalidTransaction::NonceTooHigh { tx, state } }
basic_bootloader::bootloader::errors::InvalidTransaction::NonceTooLow { tx, state } => { InvalidTransaction::NonceTooLow { tx, state } }
basic_bootloader::bootloader::errors::InvalidTransaction::MalleableSignature => { InvalidTransaction::MalleableSignature }
basic_bootloader::bootloader::errors::InvalidTransaction::IncorrectFrom { tx, recovered } => { InvalidTransaction::IncorrectFrom { tx: tx.to_be_bytes().into(), recovered: recovered.to_be_bytes().into() } }
basic_bootloader::bootloader::errors::InvalidTransaction::IncorrectFrom { tx, recovered } => { InvalidTransaction::IncorrectFrom { tx: tx.into_alloy(), recovered: recovered.into_alloy() } }
basic_bootloader::bootloader::errors::InvalidTransaction::CreateInitCodeSizeLimit => { InvalidTransaction::CreateInitCodeSizeLimit }
basic_bootloader::bootloader::errors::InvalidTransaction::InvalidChainId => { InvalidTransaction::InvalidChainId }
basic_bootloader::bootloader::errors::InvalidTransaction::AccessListNotSupported => { InvalidTransaction::AccessListNotSupported }
Expand Down Expand Up @@ -90,8 +90,8 @@ impl IntoInterface<InvalidTransaction>
impl IntoInterface<Log> for &GenericEventContent<4, EthereumIOTypesConfig> {
fn into_interface(self) -> Log {
Log::new(
self.address.to_be_bytes().into(),
self.topics.iter().map(|t| t.as_u8_array().into()).collect(),
self.address.into_alloy(),
self.topics.iter().map(|t| t.into_alloy()).collect(),
self.data.as_slice().to_vec().into(),
)
.unwrap()
Expand All @@ -104,9 +104,9 @@ impl IntoInterface<L2ToL1Log> for zk_ee::common_structs::L2ToL1Log {
l2_shard_id: self.l2_shard_id,
is_service: self.is_service,
tx_number_in_block: self.tx_number_in_block,
sender: self.sender.to_be_bytes().into(),
key: self.key.as_u8_array().into(),
value: self.value.as_u8_array().into(),
sender: self.sender.into_alloy(),
key: self.key.into_alloy(),
value: self.value.into_alloy(),
}
}
}
Expand All @@ -115,20 +115,20 @@ impl IntoInterface<Sealed<Header>> for BlockHeader {
fn into_interface(self) -> Sealed<Header> {
let hash = self.hash();
let header = Header {
parent_hash: self.parent_hash.as_u8_array().into(),
ommers_hash: self.ommers_hash.as_u8_array().into(),
beneficiary: self.beneficiary.to_be_bytes().into(),
state_root: self.state_root.as_u8_array().into(),
transactions_root: self.transactions_root.as_u8_array().into(),
receipts_root: self.receipts_root.as_u8_array().into(),
parent_hash: self.parent_hash.into_alloy(),
ommers_hash: self.ommers_hash.into_alloy(),
beneficiary: self.beneficiary.into_alloy(),
state_root: self.state_root.into_alloy(),
transactions_root: self.transactions_root.into_alloy(),
receipts_root: self.receipts_root.into_alloy(),
logs_bloom: self.logs_bloom.into(),
difficulty: self.difficulty,
number: self.number,
gas_limit: self.gas_limit,
gas_used: self.gas_used,
timestamp: self.timestamp,
extra_data: self.extra_data.to_vec().into(),
mix_hash: self.mix_hash.as_u8_array().into(),
mix_hash: self.mix_hash.into_alloy(),
nonce: self.nonce.into(),
base_fee_per_gas: Some(self.base_fee_per_gas),
withdrawals_root: None,
Expand Down
76 changes: 76 additions & 0 deletions forward_system/src/run/convert_alloy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/// Generic conversion trait for converting values into Alloy primitives.
pub trait IntoAlloy<T> {
/// Performs conversion into an Alloy type.
#[must_use]
fn into_alloy(self) -> T;
}

/// Generic conversion trait for converting values from Alloy primitives.
pub trait FromAlloy<T> {
/// Performs conversion from an Alloy type.
#[must_use]
fn from_alloy(from: T) -> Self;
}

impl IntoAlloy<alloy::primitives::Address> for ruint::aliases::B160 {
#[inline]
fn into_alloy(self) -> alloy::primitives::Address {
alloy::primitives::Address::from(self.to_be_bytes())
}
}

impl IntoAlloy<alloy::primitives::Address> for &ruint::aliases::B160 {
#[inline]
fn into_alloy(self) -> alloy::primitives::Address {
alloy::primitives::Address::from(self.to_be_bytes())
}
}

impl FromAlloy<alloy::primitives::Address> for ruint::aliases::B160 {
#[inline]
fn from_alloy(from: alloy::primitives::Address) -> ruint::aliases::B160 {
ruint::aliases::B160::from_be_bytes(from.0.into())
}
}

impl FromAlloy<&alloy::primitives::Address> for ruint::aliases::B160 {
#[inline]
fn from_alloy(from: &alloy::primitives::Address) -> ruint::aliases::B160 {
ruint::aliases::B160::from_be_bytes(from.0.into())
}
}

impl IntoAlloy<alloy::primitives::B256> for zk_ee::utils::Bytes32 {
#[inline]
fn into_alloy(self) -> alloy::primitives::B256 {
alloy::primitives::B256::from(self.as_u8_array())
}
}

impl IntoAlloy<alloy::primitives::B256> for &zk_ee::utils::Bytes32 {
#[inline]
fn into_alloy(self) -> alloy::primitives::B256 {
alloy::primitives::B256::from(self.as_u8_array())
}
}

impl FromAlloy<alloy::primitives::B256> for zk_ee::utils::Bytes32 {
#[inline]
fn from_alloy(from: alloy::primitives::B256) -> zk_ee::utils::Bytes32 {
zk_ee::utils::Bytes32::from(from.0)
}
}

impl FromAlloy<&alloy::primitives::B256> for zk_ee::utils::Bytes32 {
#[inline]
fn from_alloy(from: &alloy::primitives::B256) -> zk_ee::utils::Bytes32 {
zk_ee::utils::Bytes32::from(from.0)
}
}

impl FromAlloy<&alloy::primitives::B256> for ruint::aliases::B256 {
#[inline]
fn from_alloy(from: &alloy::primitives::B256) -> ruint::aliases::B256 {
ruint::aliases::B256::from_be_bytes(from.0)
}
}
1 change: 1 addition & 0 deletions forward_system/src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod tx_result_callback;
mod tx_source;

pub mod convert;
pub mod convert_alloy;
mod interface_impl;
pub mod query_processors;
pub mod result_keeper;
Expand Down
13 changes: 7 additions & 6 deletions forward_system/src/run/output.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Includes code adapted from https://github.com/bluealloy/revm/blob/fb80087996dfbd6c74eaf308538cfa707ecb763c/crates/context/interface/src/result.rs

use crate::run::convert::IntoInterface;
use crate::run::convert_alloy::IntoAlloy;
use crate::run::result_keeper::ForwardRunningResultKeeper;
use crate::run::TxResultCallback;
use alloy::primitives::Address;
Expand Down Expand Up @@ -35,10 +36,10 @@ impl StorageWriteExt for StorageWrite {
fn new(address: B160, key: Bytes32, value: Bytes32) -> StorageWrite {
let flat_key = derive_flat_storage_key(&address, &key);
StorageWrite {
key: flat_key.as_u8_array().into(),
value: value.as_u8_array().into(),
account: address.to_be_bytes().into(),
account_key: key.as_u8_array().into(),
key: flat_key.into_alloy(),
value: value.into_alloy(),
account: address.into_alloy(),
account_key: key.into_alloy(),
}
}
}
Expand Down Expand Up @@ -131,7 +132,7 @@ impl<TR: TxResultCallback>
.collect();
let published_preimages = new_preimages
.into_iter()
.map(|(hash, data, _)| (hash.as_u8_array().into(), data))
.map(|(hash, data, _)| (hash.into_alloy(), data))
.collect();

Self {
Expand Down Expand Up @@ -182,7 +183,7 @@ pub fn extract_account_diffs(
address: Address::from_slice(&key.as_u8_array_ref()[12..]),
nonce: properties.nonce,
balance: properties.balance,
bytecode_hash: properties.bytecode_hash.as_u8_array().into(),
bytecode_hash: properties.bytecode_hash.into_alloy(),
});
} else {
unreachable!();
Expand Down
3 changes: 2 additions & 1 deletion forward_system/src/run/preimage_source.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::run::convert_alloy::IntoAlloy;
use zk_ee::utils::Bytes32;

pub trait PreimageSource: 'static {
Expand All @@ -6,6 +7,6 @@ pub trait PreimageSource: 'static {

impl<T: zksync_os_interface::traits::PreimageSource> PreimageSource for T {
fn get_preimage(&mut self, hash: Bytes32) -> Option<Vec<u8>> {
self.get_preimage(hash.as_u8_array().into())
self.get_preimage(hash.into_alloy())
}
}
3 changes: 2 additions & 1 deletion forward_system/src/run/query_processors/tx_data.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use crate::run::convert_alloy::FromAlloy;
use crate::run::NextTxResponse;
use crate::run::TxSource;
use basic_bootloader::bootloader::transaction::TxEncodingFormat;
Expand Down Expand Up @@ -80,7 +81,7 @@ impl<TS: TxSource, M: MemorySource> OracleQueryProcessor<M> for TxDataResponder<
assert_ne!(next_tx_len, 0);
self.next_tx = Some(next_tx);
self.next_tx_format = Some(TxEncodingFormat::Rlp);
self.next_tx_from = Some(B160::from_be_bytes(from.0 .0));
self.next_tx_from = Some(B160::from_alloy(from));
next_tx_len
}
}
Expand Down
3 changes: 2 additions & 1 deletion forward_system/src/run/result_keeper.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::run::convert_alloy::IntoAlloy;
use crate::run::TxResultCallback;
use basic_bootloader::bootloader::result_keeper::{ResultKeeperExt, TxProcessingOutput};
use ruint::aliases::B160;
Expand Down Expand Up @@ -104,7 +105,7 @@ impl<TR: TxResultCallback, T: 'static + Sized> ResultKeeperExt<EthereumIOTypesCo
let owned_result = tx_result.map(|output| TxProcessingOutputOwned {
status: output.status,
output: output.output.to_vec(),
contract_address: output.contract_address.map(|a| a.to_be_bytes().into()),
contract_address: output.contract_address.map(IntoAlloy::into_alloy),
gas_used: output.gas_used,
gas_refunded: output.gas_refunded,
computational_native_used: output.computational_native_used,
Expand Down
34 changes: 16 additions & 18 deletions forward_system/src/run/tracing_impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::run::convert_alloy::IntoAlloy;
use alloy::primitives::{Address, U256};
use std::marker::PhantomData;
use zk_ee::execution_environment_type::ExecutionEnvironmentType;
Expand Down Expand Up @@ -96,9 +97,9 @@ impl<'a, T: zksync_os_interface::tracing::EvmTracer, S: EthereumLikeTypes> Trace
) {
self.0.on_storage_read(
is_transient,
address.to_be_bytes().into(),
key.as_u8_array().into(),
value.as_u8_array().into(),
address.into_alloy(),
key.into_alloy(),
value.into_alloy(),
)
}

Expand All @@ -112,9 +113,9 @@ impl<'a, T: zksync_os_interface::tracing::EvmTracer, S: EthereumLikeTypes> Trace
) {
self.0.on_storage_write(
is_transient,
address.to_be_bytes().into(),
key.as_u8_array().into(),
value.as_u8_array().into(),
address.into_alloy(),
key.into_alloy(),
value.into_alloy(),
)
}

Expand All @@ -127,9 +128,9 @@ impl<'a, T: zksync_os_interface::tracing::EvmTracer, S: EthereumLikeTypes> Trace
new_observable_bytecode_length: u32,
) {
self.0.on_bytecode_change(
address.to_be_bytes().into(),
address.into_alloy(),
new_raw_bytecode,
new_internal_bytecode_hash.as_u8_array().into(),
new_internal_bytecode_hash.into_alloy(),
new_observable_bytecode_length,
)
}
Expand All @@ -142,11 +143,8 @@ impl<'a, T: zksync_os_interface::tracing::EvmTracer, S: EthereumLikeTypes> Trace
data: &[u8],
) {
self.0.on_event(
address.to_be_bytes().into(),
topics
.iter()
.map(|b| b.as_u8_array().into())
.collect::<Vec<_>>(),
(*address).into_alloy(),
topics.iter().map(|b| b.into_alloy()).collect::<Vec<_>>(),
data,
)
}
Expand Down Expand Up @@ -201,7 +199,7 @@ impl<'a, T: zksync_os_interface::tracing::EvmTracer, S: EthereumLikeTypes> EvmTr
frame_state: &impl EvmFrameInterface<S>,
) {
self.0.on_selfdestruct(
beneficiary.to_be_bytes().into(),
beneficiary.into_alloy(),
token_value,
EvmFrameInterfaceWrapped::from(frame_state),
)
Expand All @@ -224,11 +222,11 @@ impl<'a, 'b, S: EthereumLikeTypes> EvmRequest
}

fn caller(&self) -> Address {
self.0.external_call.caller.to_be_bytes().into()
self.0.external_call.caller.into_alloy()
}

fn callee(&self) -> Address {
self.0.external_call.callee.to_be_bytes().into()
self.0.external_call.callee.into_alloy()
}

fn modifier(&self) -> zksync_os_interface::tracing::CallModifier {
Expand Down Expand Up @@ -276,11 +274,11 @@ impl<'a, S: EthereumLikeTypes, T: EvmFrameInterface<S>>
}

fn caller(&self) -> Address {
self.inner.caller().to_be_bytes().into()
self.inner.caller().into_alloy()
}

fn address(&self) -> Address {
self.inner.address().to_be_bytes().into()
self.inner.address().into_alloy()
}

fn calldata(&self) -> &[u8] {
Expand Down
3 changes: 2 additions & 1 deletion forward_system/src/run/tree.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::run::convert_alloy::{FromAlloy, IntoAlloy};
use basic_system::system_implementation::flat_storage_model::LeafProof as GenericLeafProof;
use basic_system::system_implementation::flat_storage_model::*;
use zk_ee::utils::Bytes32;
Expand All @@ -19,7 +20,7 @@ pub trait ReadStorageTree: ReadStorage {

impl<T: zksync_os_interface::traits::ReadStorage> ReadStorage for T {
fn read(&mut self, key: Bytes32) -> Option<Bytes32> {
self.read(key.as_u8_array().into()).map(|v| v.0.into())
self.read(key.into_alloy()).map(Bytes32::from_alloy)
}
}

Expand Down
19 changes: 19 additions & 0 deletions tests/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "zksync_os_tests_common"
version.workspace = true
edition.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true
categories.workspace = true

[dependencies]
alloy = { version = "1", default-features = false, features = [
"serde",
"serde-bincode-compat",
] }
ruint = { workspace = true, default-features = false }

zksync_os_interface = { workspace = true, default-features = false }
1 change: 1 addition & 0 deletions tests/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod zksync_tx;
Loading
Loading