Skip to content

Commit b27dfc5

Browse files
authored
feat: Add stack to tracer wrapper (#402)
## What ❔ Pass an EVM stack to the tracers ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- The `Why` has to be clear to non-Matter Labs entities running their own ZK Chain --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Is this a breaking change? - [ ] Yes - [X] No ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [X] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [X] Code has been formatted.
1 parent 45adae4 commit b27dfc5

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ keywords = ["blockchain", "zksync", "zk", "risc-v"]
5757
categories = ["cryptography"]
5858

5959
[workspace.dependencies]
60-
zksync_os_evm_errors = { version = "0.0.9", default-features = false }
61-
zksync_os_interface = { version = "0.0.9"}
60+
zksync_os_evm_errors = { version = "0.0.10", default-features = false }
61+
zksync_os_interface = { version = "0.0.10"}
6262

6363
risc_v_simulator = { git = "https://github.com/matter-labs/zksync-airbender", tag = "v0.4.3"}
6464
blake2s_u32 = { git = "https://github.com/matter-labs/zksync-airbender", tag = "v0.4.3"}

forward_system/src/run/tracing_impl.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,24 @@ struct ExecutionEnvironmentLaunchParamsWrapped<'a, 'b, S: EthereumLikeTypes>(
2323
/// Wrapper around [`EvmFrameInterface`] to make it compatible with interface tracing API.
2424
struct EvmFrameInterfaceWrapped<'a, S: EthereumLikeTypes, T: EvmFrameInterface<S>> {
2525
inner: &'a T,
26+
stack_wrapper: EvmStackInterfaceWrapped<'a>,
2627
_phantom: PhantomData<S>,
2728
}
2829

29-
impl<'a, S: EthereumLikeTypes, T: EvmFrameInterface<S>> From<&'a T>
30+
/// Wrapper around internal [`EvmStackInterface`] to make it compatible with interface tracing API.
31+
struct EvmStackInterfaceWrapped<'a> {
32+
inner: &'a dyn zk_ee::system::evm::EvmStackInterface,
33+
}
34+
35+
impl<'a, S: EthereumLikeTypes + 'a, T: EvmFrameInterface<S>> From<&'a T>
3036
for EvmFrameInterfaceWrapped<'a, S, T>
3137
{
3238
fn from(value: &'a T) -> Self {
3339
Self {
3440
inner: value,
41+
stack_wrapper: EvmStackInterfaceWrapped {
42+
inner: value.stack(),
43+
},
3544
_phantom: PhantomData,
3645
}
3746
}
@@ -305,4 +314,22 @@ impl<'a, S: EthereumLikeTypes, T: EvmFrameInterface<S>>
305314
fn is_constructor(&self) -> bool {
306315
self.inner.is_constructor()
307316
}
317+
318+
fn stack(&self) -> &impl zksync_os_interface::tracing::EvmStackInterface {
319+
&self.stack_wrapper
320+
}
321+
}
322+
323+
impl<'a> zksync_os_interface::tracing::EvmStackInterface for EvmStackInterfaceWrapped<'a> {
324+
fn to_slice(&self) -> &[U256] {
325+
self.inner.to_slice()
326+
}
327+
328+
fn len(&self) -> usize {
329+
self.inner.len()
330+
}
331+
332+
fn peek_n(&self, index: usize) -> Result<&U256, EvmError> {
333+
self.inner.peek_n(index)
334+
}
308335
}

0 commit comments

Comments
 (0)