Skip to content

Commit 0992079

Browse files
committed
fix linter
1 parent 738d8f9 commit 0992079

9 files changed

Lines changed: 112 additions & 100 deletions

File tree

crates/ev-revm/src/factory.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ use alloy_evm::{
99
use alloy_primitives::{Address, U256};
1010
use ev_precompiles::mint::{MintPrecompile, MINT_PRECOMPILE_ADDR};
1111
use reth_evm_ethereum::EthEvmConfig;
12-
use reth_revm::revm::context_interface::journaled_state::JournalTr;
1312
use reth_revm::{
1413
inspector::NoOpInspector,
1514
revm::{
1615
context::{
1716
result::{EVMError, HaltReason},
1817
Evm as RevmEvm, FrameStack, TxEnv,
1918
},
20-
context_interface::result::InvalidTransaction,
19+
context_interface::{journaled_state::JournalTr, result::InvalidTransaction},
2120
handler::instructions::EthInstructions,
2221
interpreter::interpreter::EthInterpreter,
2322
precompile::{PrecompileSpecId, Precompiles},

crates/ev-revm/src/handler.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use crate::{
77
use reth_revm::{
88
inspector::{Inspector, InspectorEvmTr, InspectorHandler},
99
revm::{
10-
context::result::ExecutionResult,
11-
context::ContextSetters,
10+
context::{result::ExecutionResult, ContextSetters},
1211
context_interface::{
1312
result::HaltReason,
1413
transaction::{AccessListItemTr, TransactionType},
@@ -215,7 +214,7 @@ where
215214
init_and_floor_gas: &InitialAndFloorGas,
216215
) -> Result<FrameResult, Self::Error> {
217216
let calls = match evm.ctx().tx().batch_calls() {
218-
Some(calls) if calls.is_empty() => {
217+
Some([]) => {
219218
return Err(Self::Error::from_string(
220219
"evnode transaction must include at least one call".into(),
221220
));
@@ -231,7 +230,7 @@ where
231230
let mut total_refunded: i64 = 0;
232231
let mut last_result: Option<FrameResult> = None;
233232

234-
for call in calls.iter() {
233+
for call in &calls {
235234
let mut call_tx = base_tx.clone();
236235
call_tx.set_batch_call(call);
237236
evm.ctx_mut().set_tx(call_tx);
@@ -517,13 +516,14 @@ mod tests {
517516
inspector::NoOpInspector,
518517
revm::{
519518
context::Context,
520-
context_interface::result::ExecutionResult,
521-
context_interface::transaction::{AccessList, AccessListItem, TransactionType},
519+
context_interface::{
520+
result::ExecutionResult,
521+
transaction::{AccessList, AccessListItem, TransactionType},
522+
},
522523
database::{CacheDB, EmptyDB},
523524
handler::{EthFrame, FrameResult},
524525
interpreter::{CallOutcome, Gas, InstructionResult, InterpreterResult},
525-
primitives::hardfork::SpecId,
526-
primitives::KECCAK_EMPTY,
526+
primitives::{hardfork::SpecId, KECCAK_EMPTY},
527527
state::{AccountInfo, EvmState},
528528
},
529529
MainContext, State,
@@ -538,8 +538,10 @@ mod tests {
538538
type TestHandler = EvHandler<TestEvm, TestError, EthFrame<EthInterpreter>>;
539539

540540
use alloy_evm::{Evm, EvmEnv, EvmFactory};
541-
use reth_revm::revm::bytecode::Bytecode as RevmBytecode;
542-
use reth_revm::revm::context::{BlockEnv, CfgEnv, TxEnv};
541+
use reth_revm::revm::{
542+
bytecode::Bytecode as RevmBytecode,
543+
context::{BlockEnv, CfgEnv, TxEnv},
544+
};
543545

544546
const BASE_FEE: u64 = 100;
545547
const GAS_PRICE: u128 = 200;

crates/ev-revm/src/tx_env.rs

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@ use alloy_evm::{FromRecoveredTx, FromTxWithEncoded};
22
use alloy_primitives::{Address, Bytes, U256};
33
use ev_primitives::{Call, EvTxEnvelope};
44
use reth_evm::TransactionEnv;
5-
use reth_revm::revm::context::TxEnv;
6-
use reth_revm::revm::context_interface::either::Either;
7-
use reth_revm::revm::context_interface::transaction::{
8-
AccessList, AccessListItem, RecoveredAuthorization, SignedAuthorization,
9-
Transaction as RevmTransaction,
5+
use reth_revm::revm::{
6+
context::TxEnv,
7+
context_interface::{
8+
either::Either,
9+
transaction::{
10+
AccessList, AccessListItem, RecoveredAuthorization, SignedAuthorization,
11+
Transaction as RevmTransaction,
12+
},
13+
},
14+
handler::SystemCallTx,
15+
primitives::{Address as RevmAddress, Bytes as RevmBytes, TxKind, B256},
1016
};
11-
use reth_revm::revm::handler::SystemCallTx;
12-
use reth_revm::revm::primitives::{Address as RevmAddress, Bytes as RevmBytes, TxKind, B256};
1317

14-
/// Transaction environment wrapper that supports EvTxEnvelope conversions.
18+
/// Transaction environment wrapper that supports `EvTxEnvelope` conversions.
1519
#[derive(Clone, Debug, Default, PartialEq, Eq)]
1620
pub struct EvTxEnv {
1721
inner: TxEnv,
@@ -23,14 +27,13 @@ pub struct EvTxEnv {
2327

2428
impl EvTxEnv {
2529
/// Wrap a `TxEnv` with EV-specific metadata.
26-
pub fn new(inner: TxEnv) -> Self {
27-
let batch_value = inner.value;
30+
pub const fn new(inner: TxEnv) -> Self {
2831
Self {
32+
batch_value: inner.value,
2933
inner,
3034
sponsor: None,
3135
sponsor_signature_invalid: false,
3236
calls: Vec::new(),
33-
batch_value,
3437
}
3538
}
3639

@@ -198,16 +201,16 @@ impl TransactionEnv for EvTxEnv {
198201
}
199202
}
200203

201-
impl alloy_evm::ToTxEnv<EvTxEnv> for EvTxEnv {
202-
fn to_tx_env(&self) -> EvTxEnv {
204+
impl alloy_evm::ToTxEnv<Self> for EvTxEnv {
205+
fn to_tx_env(&self) -> Self {
203206
self.clone()
204207
}
205208
}
206209

207210
impl FromRecoveredTx<EvTxEnvelope> for EvTxEnv {
208211
fn from_recovered_tx(tx: &EvTxEnvelope, sender: Address) -> Self {
209212
match tx {
210-
EvTxEnvelope::Ethereum(inner) => EvTxEnv::new(TxEnv::from_recovered_tx(inner, sender)),
213+
EvTxEnvelope::Ethereum(inner) => Self::new(TxEnv::from_recovered_tx(inner, sender)),
211214
EvTxEnvelope::EvNode(ev) => {
212215
let (sponsor, sponsor_signature_invalid) =
213216
if let Some(signature) = ev.tx().fee_payer_signature.as_ref() {
@@ -222,29 +225,32 @@ impl FromRecoveredTx<EvTxEnvelope> for EvTxEnv {
222225
let batch_value = calls
223226
.iter()
224227
.fold(U256::ZERO, |acc, call| acc.saturating_add(call.value));
225-
let mut env = TxEnv::default();
226-
env.caller = sender;
227-
env.gas_limit = ev.tx().gas_limit;
228-
env.gas_price = ev.tx().max_fee_per_gas;
229-
env.kind = ev
230-
.tx()
231-
.calls
232-
.first()
233-
.map(|call| call.to)
234-
.unwrap_or(TxKind::Create);
235-
env.value = batch_value;
236-
env.data = ev
237-
.tx()
238-
.calls
239-
.first()
240-
.map(|call| call.input.clone())
241-
.unwrap_or_default();
242-
let mut tx_env = EvTxEnv::new(env);
243-
tx_env.sponsor = sponsor;
244-
tx_env.sponsor_signature_invalid = sponsor_signature_invalid;
245-
tx_env.calls = calls;
246-
tx_env.batch_value = batch_value;
247-
tx_env
228+
let env = TxEnv {
229+
caller: sender,
230+
gas_limit: ev.tx().gas_limit,
231+
gas_price: ev.tx().max_fee_per_gas,
232+
kind: ev
233+
.tx()
234+
.calls
235+
.first()
236+
.map(|call| call.to)
237+
.unwrap_or(TxKind::Create),
238+
value: batch_value,
239+
data: ev
240+
.tx()
241+
.calls
242+
.first()
243+
.map(|call| call.input.clone())
244+
.unwrap_or_default(),
245+
..Default::default()
246+
};
247+
Self {
248+
inner: env,
249+
sponsor,
250+
sponsor_signature_invalid,
251+
calls,
252+
batch_value,
253+
}
248254
}
249255
}
250256
}
@@ -262,7 +268,7 @@ impl SystemCallTx for EvTxEnv {
262268
system_contract_address: Address,
263269
data: Bytes,
264270
) -> Self {
265-
EvTxEnv::new(
271+
Self::new(
266272
TxEnv::builder()
267273
.caller(caller)
268274
.data(data)

crates/node/src/builder.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
use crate::config::EvolvePayloadBuilderConfig;
2-
use crate::executor::EvEvmConfig;
3-
use alloy_consensus::transaction::Transaction;
4-
use alloy_consensus::transaction::TxHashRef;
1+
use crate::{config::EvolvePayloadBuilderConfig, executor::EvEvmConfig};
2+
use alloy_consensus::transaction::{Transaction, TxHashRef};
53
use alloy_primitives::Address;
64
use ev_revm::EvTxEvmFactory;
75
use evolve_ev_reth::EvolvePayloadAttributes;

crates/node/src/executor.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
33
use alloy_consensus::{BlockHeader, Header};
44
use alloy_eips::Decodable2718;
5-
use alloy_evm::eth::spec::EthExecutorSpec;
6-
use alloy_evm::{FromRecoveredTx, FromTxWithEncoded};
5+
use alloy_evm::{eth::spec::EthExecutorSpec, FromRecoveredTx, FromTxWithEncoded};
76
use alloy_primitives::U256;
87
use alloy_rpc_types_engine::ExecutionData;
98
use ev_revm::{
@@ -35,15 +34,18 @@ use reth_revm::revm::{
3534
};
3635
use tracing::info;
3736

38-
use crate::evm_executor::{EvBlockExecutorFactory, EvReceiptBuilder};
39-
use crate::{config::EvolvePayloadBuilderConfig, EvolveNode};
37+
use crate::{
38+
config::EvolvePayloadBuilderConfig,
39+
evm_executor::{EvBlockExecutorFactory, EvReceiptBuilder},
40+
EvolveNode,
41+
};
4042
use ev_primitives::{EvPrimitives, EvTxEnvelope};
4143
use reth_evm_ethereum::{revm_spec, revm_spec_by_timestamp_and_block_number, EthBlockAssembler};
4244

4345
/// Type alias for the EV-aware EVM config we install into the node.
4446
pub type EvolveEvmConfig = EvEvmConfig<ChainSpec, EvTxEvmFactory>;
4547

46-
/// EVM config wired for EvPrimitives.
48+
/// EVM config wired for `EvPrimitives`.
4749
#[derive(Debug, Clone)]
4850
pub struct EvEvmConfig<C = ChainSpec, EvmFactory = EvTxEvmFactory> {
4951
/// Factory used to create block executors.
@@ -210,10 +212,7 @@ where
210212
}
211213
});
212214

213-
let mut gas_limit = parent.gas_limit;
214-
let mut basefee = None;
215-
216-
if self
215+
let (gas_limit, basefee) = if self
217216
.chain_spec()
218217
.fork(reth_ethereum_forks::EthereumHardfork::London)
219218
.transitions_at_block(parent.number + 1)
@@ -222,9 +221,13 @@ where
222221
.chain_spec()
223222
.base_fee_params_at_timestamp(attributes.timestamp)
224223
.elasticity_multiplier;
225-
gas_limit *= elasticity_multiplier as u64;
226-
basefee = Some(alloy_eips::eip1559::INITIAL_BASE_FEE);
227-
}
224+
(
225+
parent.gas_limit * elasticity_multiplier as u64,
226+
Some(alloy_eips::eip1559::INITIAL_BASE_FEE),
227+
)
228+
} else {
229+
(parent.gas_limit, None)
230+
};
228231

229232
let block_env = BlockEnv {
230233
number: U256::from(parent.number + 1),
@@ -407,10 +410,8 @@ where
407410

408411
let factory = EvTxEvmFactory::new(redirect, mint_precompile, contract_size_limit);
409412

410-
Ok(
411-
EvEvmConfig::new_with_evm_factory(chain_spec.clone(), factory)
412-
.with_extra_data(ctx.payload_builder_config().extra_data_bytes()),
413-
)
413+
Ok(EvEvmConfig::new_with_evm_factory(chain_spec, factory)
414+
.with_extra_data(ctx.payload_builder_config().extra_data_bytes()))
414415
}
415416

416417
/// Thin wrapper so we can plug the EV executor into the node components builder.

crates/node/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub mod executor;
2525
pub mod node;
2626
/// Payload service integration.
2727
pub mod payload_service;
28-
/// Payload types for EvPrimitives.
28+
/// Payload types for `EvPrimitives`.
2929
pub mod payload_types;
3030
/// RPC wiring for EvTxEnvelope support.
3131
pub mod rpc;

crates/node/src/payload_types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use reth_payload_builder::BlobSidecars;
1212
use reth_payload_primitives::BuiltPayload;
1313
use reth_primitives_traits::SealedBlock;
1414

15-
/// Built payload for EvPrimitives.
15+
/// Built payload for `EvPrimitives`.
1616
#[derive(Debug, Clone)]
1717
pub struct EvBuiltPayload {
1818
id: PayloadId,
@@ -76,7 +76,7 @@ impl EvBuiltPayload {
7676
self
7777
}
7878

79-
/// Converts this payload into an ExecutionPayloadEnvelopeV3.
79+
/// Converts this payload into an `ExecutionPayloadEnvelopeV3`.
8080
pub fn try_into_v3(self) -> Result<ExecutionPayloadEnvelopeV3, EvBuiltPayloadConversionError> {
8181
let Self {
8282
block,
@@ -104,15 +104,15 @@ impl EvBuiltPayload {
104104
})
105105
}
106106

107-
/// Converts this payload into an ExecutionPayloadEnvelopeV4.
107+
/// Converts this payload into an `ExecutionPayloadEnvelopeV4`.
108108
pub fn try_into_v4(self) -> Result<ExecutionPayloadEnvelopeV4, EvBuiltPayloadConversionError> {
109109
Ok(ExecutionPayloadEnvelopeV4 {
110110
execution_requests: self.requests.clone().unwrap_or_default(),
111111
envelope_inner: self.try_into()?,
112112
})
113113
}
114114

115-
/// Converts this payload into an ExecutionPayloadEnvelopeV5.
115+
/// Converts this payload into an `ExecutionPayloadEnvelopeV5`.
116116
pub fn try_into_v5(self) -> Result<ExecutionPayloadEnvelopeV5, EvBuiltPayloadConversionError> {
117117
let Self {
118118
block,

0 commit comments

Comments
 (0)