Skip to content

Commit e7d721a

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

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

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: 33 additions & 12 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};
@@ -11,11 +8,14 @@ use evm::ExitReason;
118
use evm::Opcode;
129
use sp_core::{sp_std::vec::Vec, H160, H256, U256};
1310

14-
use crate::Context;
11+
use crate::{Context, StepEventFilter};
1512

13+
/// EVM stack.
1614
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)]
1715
pub struct Stack {
16+
/// Data.
1817
pub data: Vec<H256>,
18+
/// Limit.
1919
pub limit: u64,
2020
}
2121

@@ -28,10 +28,14 @@ impl From<&evm::Stack> for Stack {
2828
}
2929
}
3030

31+
/// EVM memory.
3132
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)]
3233
pub struct Memory {
34+
/// Data.
3335
pub data: Vec<u8>,
36+
/// Effective length.
3437
pub effective_len: U256,
38+
/// Limit.
3539
pub limit: u64,
3640
}
3741

@@ -45,6 +49,7 @@ impl From<&evm::Memory> for Memory {
4549
}
4650
}
4751

52+
/// Capture represents the result of execution.
4853
#[derive(Clone, Copy, Debug, Eq, PartialEq, Encode, Decode)]
4954
pub enum Capture<E, T> {
5055
/// The machine has exited. It cannot be executed again.
@@ -54,41 +59,57 @@ pub enum Capture<E, T> {
5459
Trap(T),
5560
}
5661

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

65+
/// EVM runtime event.
5966
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)]
6067
pub enum RuntimeEvent {
68+
/// Step.
6169
Step {
70+
/// Context.
6271
context: Context,
63-
// This needs to be marshalled in the runtime no matter what.
72+
/// Opcode.
6473
opcode: Vec<u8>,
65-
// We can use ExitReason with `with-codec` feature,
74+
/// Position.
6675
position: Result<u64, ExitReason>,
76+
/// Stack.
6777
stack: Option<Stack>,
78+
/// Memory.
6879
memory: Option<Memory>,
6980
},
81+
/// Step result.
7082
StepResult {
83+
/// Result.
7184
result: Result<(), Capture<ExitReason, Trap>>,
85+
/// Return value.
7286
return_value: Vec<u8>,
7387
},
88+
/// Storage load.
7489
SLoad {
90+
/// Address.
7591
address: H160,
92+
/// Index.
7693
index: H256,
94+
/// Value.
7795
value: H256,
7896
},
97+
/// Storage store.
7998
SStore {
99+
/// Address.
80100
address: H160,
101+
/// Index.
81102
index: H256,
103+
/// Value.
82104
value: H256,
83105
},
84106
}
85107

86108
#[cfg(feature = "evm-tracing")]
87109
impl RuntimeEvent {
88-
pub fn from_evm_event(
89-
event: evm_runtime::tracing::Event<'_>,
90-
filter: crate::StepEventFilter,
91-
) -> Self {
110+
/// Obtain `RuntimeEvent` from [`evm_runtime::tracing::Event`] based on provided
111+
/// step event filter.
112+
pub fn from_evm_event(event: evm_runtime::tracing::Event<'_>, filter: StepEventFilter) -> Self {
92113
match event {
93114
evm_runtime::tracing::Event::Step {
94115
context,
@@ -149,7 +170,7 @@ impl RuntimeEvent {
149170
}
150171
}
151172

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

0 commit comments

Comments
 (0)