Skip to content

Commit 6efba29

Browse files
committed
chore: unwrap bytes and replace import
1 parent 2b48fb1 commit 6efba29

File tree

11 files changed

+35
-38
lines changed

11 files changed

+35
-38
lines changed

crates/cast/bin/cmd/call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl CallArgs {
160160

161161
let trace = match executor.deploy(
162162
h160_to_b160(sender),
163-
code.into(),
163+
code.into_bytes().into(),
164164
u256_to_ru256(value.unwrap_or(U256::zero())),
165165
None,
166166
) {

crates/chisel/src/runner.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl ChiselRunner {
100100
// We don't care about deployment traces / logs here
101101
let DeployResult { address, .. } = self
102102
.executor
103-
.deploy(h160_to_b160(self.sender), bytecode.0, rU256::ZERO, None)
103+
.deploy(h160_to_b160(self.sender), bytecode.0.into(), rU256::ZERO, None)
104104
.map_err(|err| eyre::eyre!("Failed to deploy REPL contract:\n{}", err))?;
105105

106106
// Reset the sender's balance to the initial balance for calls.
@@ -147,7 +147,7 @@ impl ChiselRunner {
147147
let mut res = self.executor.call_raw(
148148
h160_to_b160(from),
149149
h160_to_b160(to),
150-
calldata.0.clone(),
150+
calldata.0.clone().into(),
151151
u256_to_ru256(value),
152152
)?;
153153
let mut gas_used = res.gas_used;
@@ -168,7 +168,7 @@ impl ChiselRunner {
168168
let res = self.executor.call_raw(
169169
h160_to_b160(from),
170170
h160_to_b160(to),
171-
calldata.0.clone(),
171+
calldata.0.clone().into(),
172172
u256_to_ru256(value),
173173
)?;
174174
match res.exit_reason {
@@ -208,7 +208,7 @@ impl ChiselRunner {
208208
res = self.executor.call_raw(
209209
h160_to_b160(from),
210210
h160_to_b160(to),
211-
calldata.0.clone(),
211+
calldata.0.clone().into(),
212212
u256_to_ru256(value),
213213
)?;
214214
}
@@ -218,15 +218,15 @@ impl ChiselRunner {
218218
res = self.executor.call_raw_committing(
219219
h160_to_b160(from),
220220
h160_to_b160(to),
221-
calldata.0.clone(),
221+
calldata.0.clone().into(),
222222
u256_to_ru256(value),
223223
)?;
224224
}
225225

226226
let RawCallResult { result, reverted, logs, traces, labels, chisel_state, .. } = res;
227227

228228
Ok(ChiselResult {
229-
returned: result,
229+
returned: result.0,
230230
success: !reverted,
231231
gas_used,
232232
logs,

crates/evm/src/executor/inspector/printer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bytes::Bytes;
1+
use alloy_primitives::Bytes;
22
use revm::{
33
interpreter::{opcode, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter},
44
primitives::Address,
@@ -38,7 +38,7 @@ impl<DB: Database> Inspector<DB> for TracePrinter {
3838
&mut self,
3939
_data: &mut EVMData<'_, DB>,
4040
inputs: &mut CallInputs,
41-
) -> (InstructionResult, Gas, alloy_primitives::Bytes) {
41+
) -> (InstructionResult, Gas, Bytes) {
4242
println!(
4343
"SM CALL: {:?},context:{:?}, is_static:{:?}, transfer:{:?}, input_size:{:?}",
4444
inputs.contract,
@@ -47,14 +47,14 @@ impl<DB: Database> Inspector<DB> for TracePrinter {
4747
inputs.transfer,
4848
inputs.input.len(),
4949
);
50-
(InstructionResult::Continue, Gas::new(0), alloy_primitives::Bytes::new())
50+
(InstructionResult::Continue, Gas::new(0), Bytes::new())
5151
}
5252

5353
fn create(
5454
&mut self,
5555
_data: &mut EVMData<'_, DB>,
5656
inputs: &mut CreateInputs,
57-
) -> (InstructionResult, Option<Address>, Gas, alloy_primitives::Bytes) {
57+
) -> (InstructionResult, Option<Address>, Gas, Bytes) {
5858
println!(
5959
"CREATE CALL: caller:{:?}, scheme:{:?}, value:{:?}, init_code:{:?}, gas:{:?}",
6060
inputs.caller,
@@ -63,6 +63,6 @@ impl<DB: Database> Inspector<DB> for TracePrinter {
6363
hex::encode(&inputs.init_code),
6464
inputs.gas_limit
6565
);
66-
(InstructionResult::Continue, None, Gas::new(0), alloy_primitives::Bytes(Bytes::new()))
66+
(InstructionResult::Continue, None, Gas::new(0), Bytes::new())
6767
}
6868
}

crates/evm/src/executor/mod.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pub use abi::{
1313
patch_hardhat_console_selector, HardhatConsoleCalls, CHEATCODE_ADDRESS, CONSOLE_ABI,
1414
HARDHAT_CONSOLE_ABI, HARDHAT_CONSOLE_ADDRESS,
1515
};
16+
use alloy_primitives::Bytes;
1617
use backend::FuzzBackendWrapper;
17-
use bytes::Bytes;
1818
use ethers::{
1919
abi::{Abi, Contract, Detokenize, Function, Tokenize},
2020
prelude::{decode_function_data, encode_function_data},
@@ -106,10 +106,7 @@ impl Executor {
106106
backend.insert_account_info(
107107
CHEATCODE_ADDRESS,
108108
revm::primitives::AccountInfo {
109-
code: Some(
110-
Bytecode::new_raw(alloy_primitives::Bytes(Bytes::from_static(&[0])))
111-
.to_checked(),
112-
),
109+
code: Some(Bytecode::new_raw(Bytes::from_static(&[0])).to_checked()),
113110
..Default::default()
114111
},
115112
);
@@ -404,7 +401,7 @@ impl Executor {
404401

405402
let result = match &out {
406403
Some(Output::Create(data, _)) => data.to_owned(),
407-
_ => alloy_primitives::Bytes(Bytes::default()),
404+
_ => Bytes::default(),
408405
};
409406

410407
let address = match exit_reason {
@@ -570,7 +567,7 @@ impl Executor {
570567
tx: TxEnv {
571568
caller,
572569
transact_to,
573-
data: alloy_primitives::Bytes(data),
570+
data,
574571
value,
575572
// As above, we set the gas price to 0.
576573
gas_price: U256::from(0),
@@ -772,7 +769,7 @@ fn convert_executed_result(
772769

773770
let result = match out {
774771
Some(Output::Call(ref data)) => data.to_owned(),
775-
_ => alloy_primitives::Bytes(Bytes::default()),
772+
_ => Bytes::default(),
776773
};
777774

778775
let InspectorData {
@@ -796,7 +793,7 @@ fn convert_executed_result(
796793
Ok(RawCallResult {
797794
exit_reason,
798795
reverted: !matches!(exit_reason, return_ok!()),
799-
result: result.0,
796+
result,
800797
gas_used,
801798
gas_refunded,
802799
stipend,

crates/evm/src/executor/snapshot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<T> Snapshots<T> {
3535
let mut to_revert = id.add(U256::from(1));
3636
while to_revert < self.id {
3737
self.snapshots.remove(&to_revert);
38-
to_revert = to_revert + U256::from(1);
38+
to_revert += U256::from(1);
3939
}
4040

4141
snapshot

crates/evm/src/fuzz/invariant/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl InvariantFuzzError {
110110
.call_raw_committing(
111111
h160_to_b160(*sender),
112112
h160_to_b160(*addr),
113-
bytes.0.clone(),
113+
bytes.0.clone().into(),
114114
U256::ZERO,
115115
)
116116
.expect("bad call to evm");
@@ -138,7 +138,7 @@ impl InvariantFuzzError {
138138
// Checks the invariant.
139139
if let Some(func) = &self.func {
140140
let error_call_result = executor
141-
.call_raw(CALLER, h160_to_b160(self.addr), func.0.clone(), U256::ZERO)
141+
.call_raw(CALLER, h160_to_b160(self.addr), func.0.clone().into(), U256::ZERO)
142142
.expect("bad call to evm");
143143

144144
traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap()));
@@ -176,15 +176,15 @@ impl InvariantFuzzError {
176176
.call_raw_committing(
177177
h160_to_b160(*sender),
178178
h160_to_b160(*addr),
179-
bytes.0.clone(),
179+
bytes.0.clone().into(),
180180
U256::ZERO,
181181
)
182182
.expect("bad call to evm");
183183

184184
// Checks the invariant. If we exit before the last call, all the better.
185185
if let Some(func) = &self.func {
186186
let error_call_result = executor
187-
.call_raw(CALLER, h160_to_b160(self.addr), func.0.clone(), U256::ZERO)
187+
.call_raw(CALLER, h160_to_b160(self.addr), func.0.clone().into(), U256::ZERO)
188188
.expect("bad call to evm");
189189

190190
if error_call_result.reverted {

crates/evm/src/fuzz/invariant/executor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl<'a> InvariantExecutor<'a> {
151151
.call_raw(
152152
h160_to_b160(*sender),
153153
h160_to_b160(*address),
154-
calldata.0.clone(),
154+
calldata.0.clone().into(),
155155
rU256::ZERO,
156156
)
157157
.expect("could not make raw evm call");

crates/evm/src/fuzz/invariant/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn replay_run(
124124
.call_raw_committing(
125125
h160_to_b160(*sender),
126126
h160_to_b160(*addr),
127-
bytes.0.clone(),
127+
bytes.0.clone().into(),
128128
U256::ZERO,
129129
)
130130
.expect("bad call to evm");

crates/evm/src/fuzz/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl<'a> FuzzedExecutor<'a> {
204204
.call_raw(
205205
h160_to_b160(self.sender),
206206
h160_to_b160(address),
207-
calldata.0.clone(),
207+
calldata.0.clone().into(),
208208
U256::ZERO,
209209
)
210210
.map_err(|_| TestCaseError::fail(FuzzError::FailedContractCall))?;

crates/forge/bin/cmd/script/runner.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl ScriptRunner {
6666
.filter_map(|code| {
6767
let DeployResult { traces, .. } = self
6868
.executor
69-
.deploy(h160_to_b160(self.sender), code.0.clone(), rU256::ZERO, None)
69+
.deploy(h160_to_b160(self.sender), code.0.clone().into(), rU256::ZERO, None)
7070
.expect("couldn't deploy library");
7171

7272
traces
@@ -83,7 +83,7 @@ impl ScriptRunner {
8383
..
8484
} = self
8585
.executor
86-
.deploy(CALLER, code.0, rU256::ZERO, None)
86+
.deploy(CALLER, code.0.into(), rU256::ZERO, None)
8787
.map_err(|err| eyre::eyre!("Failed to deploy script:\n{}", err))?;
8888

8989
traces.extend(constructor_traces.map(|traces| (TraceKind::Deployment, traces)));
@@ -217,7 +217,7 @@ impl ScriptRunner {
217217
} else if to.is_none() {
218218
let (address, gas_used, logs, traces, debug) = match self.executor.deploy(
219219
h160_to_b160(from),
220-
calldata.expect("No data for create transaction").0,
220+
calldata.expect("No data for create transaction").0.into(),
221221
u256_to_ru256(value.unwrap_or(U256::zero())),
222222
None,
223223
) {
@@ -271,7 +271,7 @@ impl ScriptRunner {
271271
let mut res = self.executor.call_raw(
272272
h160_to_b160(from),
273273
h160_to_b160(to),
274-
calldata.0.clone(),
274+
calldata.0.clone().into(),
275275
u256_to_ru256(value),
276276
)?;
277277
let mut gas_used = res.gas_used;
@@ -286,7 +286,7 @@ impl ScriptRunner {
286286
res = self.executor.call_raw_committing(
287287
h160_to_b160(from),
288288
h160_to_b160(to),
289-
calldata.0,
289+
calldata.0.into(),
290290
u256_to_ru256(value),
291291
)?;
292292
}
@@ -305,7 +305,7 @@ impl ScriptRunner {
305305
let breakpoints = res.cheatcodes.map(|cheats| cheats.breakpoints).unwrap_or_default();
306306

307307
Ok(ScriptResult {
308-
returned: result,
308+
returned: result.0,
309309
success: !reverted,
310310
gas_used,
311311
logs,
@@ -353,7 +353,7 @@ impl ScriptRunner {
353353
let res = self.executor.call_raw(
354354
h160_to_b160(from),
355355
h160_to_b160(to),
356-
calldata.0.clone(),
356+
calldata.0.clone().into(),
357357
u256_to_ru256(value),
358358
)?;
359359
match res.exit_reason {

0 commit comments

Comments
 (0)