Skip to content

Commit 25340f5

Browse files
Fix clippy at primitives-evm-tracing-events runtime mod
1 parent b35dca6 commit 25340f5

2 files changed

Lines changed: 35 additions & 12 deletions

File tree

crates/primitives-evm-tracing-events/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub use self::evm::EvmEvent;
1717

1818
environmental::environmental!(listener: dyn Listener + 'static);
1919

20-
/// Sets up `listener` environment.
20+
/// Run closure with provided listener.
2121
pub fn using<R, F: FnOnce() -> R>(l: &mut (dyn Listener + 'static), f: F) -> R {
2222
listener::using(l, f)
2323
}

crates/primitives-evm-tracing-events/src/runtime.rs

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
//! EVM runtime events definitions.
22
3-
// TODO: fix clippy.
4-
#![allow(missing_docs)]
5-
63
extern crate alloc;
74

85
use codec::{Decode, Encode};
@@ -12,10 +9,15 @@ use evm::Opcode;
129
use sp_core::{sp_std::vec::Vec, H160, H256, U256};
1310

1411
use crate::Context;
12+
#[cfg(feature = "evm-tracing")]
13+
use crate::StepEventFilter;
1514

15+
/// EVM stack.
1616
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)]
1717
pub struct Stack {
18+
/// Data.
1819
pub data: Vec<H256>,
20+
/// Limit.
1921
pub limit: u64,
2022
}
2123

@@ -28,10 +30,14 @@ impl From<&evm::Stack> for Stack {
2830
}
2931
}
3032

33+
/// EVM memory.
3134
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)]
3235
pub struct Memory {
36+
/// Data.
3337
pub data: Vec<u8>,
38+
/// Effective length.
3439
pub effective_len: U256,
40+
/// Limit.
3541
pub limit: u64,
3642
}
3743

@@ -45,6 +51,7 @@ impl From<&evm::Memory> for Memory {
4551
}
4652
}
4753

54+
/// Capture represents the result of execution.
4855
#[derive(Clone, Copy, Debug, Eq, PartialEq, Encode, Decode)]
4956
pub enum Capture<E, T> {
5057
/// The machine has exited. It cannot be executed again.
@@ -54,41 +61,57 @@ pub enum Capture<E, T> {
5461
Trap(T),
5562
}
5663

57-
pub type Trap = Vec<u8>; // Should hold the marshalled Opcode.
64+
/// A type alias representing trap data. Should hold the marshalled `Opcode`.
65+
pub type Trap = Vec<u8>;
5866

67+
/// EVM runtime event.
5968
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)]
6069
pub enum RuntimeEvent {
70+
/// Step.
6171
Step {
72+
/// Context.
6273
context: Context,
63-
// This needs to be marshalled in the runtime no matter what.
74+
/// Opcode.
6475
opcode: Vec<u8>,
65-
// We can use ExitReason with `with-codec` feature,
76+
/// Position.
6677
position: Result<u64, ExitReason>,
78+
/// Stack.
6779
stack: Option<Stack>,
80+
/// Memory.
6881
memory: Option<Memory>,
6982
},
83+
/// Step result.
7084
StepResult {
85+
/// Result.
7186
result: Result<(), Capture<ExitReason, Trap>>,
87+
/// Return value.
7288
return_value: Vec<u8>,
7389
},
90+
/// Storage load.
7491
SLoad {
92+
/// Address.
7593
address: H160,
94+
/// Index.
7695
index: H256,
96+
/// Value.
7797
value: H256,
7898
},
99+
/// Storage store.
79100
SStore {
101+
/// Address.
80102
address: H160,
103+
/// Index.
81104
index: H256,
105+
/// Value.
82106
value: H256,
83107
},
84108
}
85109

86110
#[cfg(feature = "evm-tracing")]
87111
impl RuntimeEvent {
88-
pub fn from_evm_event(
89-
event: evm_runtime::tracing::Event<'_>,
90-
filter: crate::StepEventFilter,
91-
) -> Self {
112+
/// Obtain `RuntimeEvent` from [`evm_runtime::tracing::Event`] based on provided
113+
/// step event filter.
114+
pub fn from_evm_event(event: evm_runtime::tracing::Event<'_>, filter: StepEventFilter) -> Self {
92115
match event {
93116
evm_runtime::tracing::Event::Step {
94117
context,
@@ -149,7 +172,7 @@ impl RuntimeEvent {
149172
}
150173
}
151174

152-
/// Converts an Opcode into its name, stored in a `Vec<u8>`.
175+
/// Converts an `Opcode` into its name, stored in a `Vec<u8>`.
153176
#[cfg(feature = "evm-tracing")]
154177
pub fn opcodes_string(opcode: Opcode) -> Vec<u8> {
155178
let tmp;

0 commit comments

Comments
 (0)