Skip to content

Commit 738d8f9

Browse files
committed
fix lint
1 parent 9e61d28 commit 738d8f9

22 files changed

Lines changed: 519 additions & 246 deletions

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth.git", tag =
4848
reth-network = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.8.4" }
4949
reth-network-types = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.8.4" }
5050
reth-chain-state = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.8.4" }
51+
reth-db-api = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.8.4" }
5152
reth-ethereum = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.8.4" }
5253
reth-ethereum-cli = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.8.4" }
5354
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.8.4" }
@@ -119,6 +120,9 @@ alloy-genesis = { version = "1.0.37", default-features = false }
119120
alloy-rpc-types-txpool = { version = "1.0.37", default-features = false }
120121
alloy-sol-types = { version = "1.3.1", default-features = false }
121122

123+
# Utility dependencies
124+
bytes = "1.10.1"
125+
122126
revm-inspector = { version = "10.0.1" }
123127
# Core dependencies
124128
eyre = "0.6"

crates/ev-primitives/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ alloy-consensus = { workspace = true }
1010
alloy-eips = { workspace = true, features = ["serde"] }
1111
alloy-primitives = { workspace = true, features = ["k256", "rlp", "serde"] }
1212
alloy-rlp = { workspace = true, features = ["derive"] }
13+
bytes = { workspace = true }
1314
reth-codecs = { workspace = true }
15+
reth-db-api = { workspace = true }
1416
reth-ethereum-primitives = { workspace = true }
1517
reth-primitives-traits = { workspace = true, features = ["serde-bincode-compat"] }
1618
serde = { workspace = true, features = ["derive"] }

crates/ev-primitives/src/tx.rs

Lines changed: 79 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ use reth_codecs::{
1212
txtype::COMPACT_EXTENDED_IDENTIFIER_FLAG,
1313
Compact,
1414
};
15+
use reth_db_api::{
16+
table::{Compress, Decompress},
17+
DatabaseError,
18+
};
1519
use reth_primitives_traits::{InMemorySize, SignedTransaction};
1620
use std::vec::Vec;
1721

@@ -21,7 +25,17 @@ pub const EVNODE_TX_TYPE_ID: u8 = 0x76;
2125
pub const EVNODE_SPONSOR_DOMAIN: u8 = 0x78;
2226

2327
/// Single call entry in an EvNode transaction.
24-
#[derive(Clone, Debug, PartialEq, Eq, Hash, RlpEncodable, RlpDecodable, serde::Serialize, serde::Deserialize)]
28+
#[derive(
29+
Clone,
30+
Debug,
31+
PartialEq,
32+
Eq,
33+
Hash,
34+
RlpEncodable,
35+
RlpDecodable,
36+
serde::Serialize,
37+
serde::Deserialize,
38+
)]
2539
pub struct Call {
2640
/// Destination (CALL or CREATE).
2741
pub to: TxKind,
@@ -82,7 +96,10 @@ impl EvNodeTransaction {
8296
}
8397

8498
/// Recovers the executor address from the provided signature.
85-
pub fn recover_executor(&self, signature: &Signature) -> Result<Address, alloy_primitives::SignatureError> {
99+
pub fn recover_executor(
100+
&self,
101+
signature: &Signature,
102+
) -> Result<Address, alloy_primitives::SignatureError> {
86103
signature.recover_address_from_prehash(&self.executor_signing_hash())
87104
}
88105

@@ -101,14 +118,25 @@ impl EvNodeTransaction {
101118

102119
fn encoded_payload(&self, fee_payer_signature: Option<&Signature>) -> Vec<u8> {
103120
let payload_len = self.payload_fields_length(fee_payer_signature);
104-
let mut out = Vec::with_capacity(Header { list: true, payload_length: payload_len }.length_with_payload());
105-
Header { list: true, payload_length: payload_len }.encode(&mut out);
121+
let mut out = Vec::with_capacity(
122+
Header {
123+
list: true,
124+
payload_length: payload_len,
125+
}
126+
.length_with_payload(),
127+
);
128+
Header {
129+
list: true,
130+
payload_length: payload_len,
131+
}
132+
.encode(&mut out);
106133
self.encode_payload_fields(&mut out, fee_payer_signature);
107134
out
108135
}
109136

110137
fn encoded_payload_with_executor(&self, executor: Address) -> Vec<u8> {
111-
let mut out = Vec::with_capacity(self.payload_fields_length(self.fee_payer_signature.as_ref()) + 32);
138+
let mut out =
139+
Vec::with_capacity(self.payload_fields_length(self.fee_payer_signature.as_ref()) + 32);
112140
out.extend_from_slice(executor.as_slice());
113141
self.encode_payload_fields(&mut out, self.fee_payer_signature.as_ref());
114142
out
@@ -139,7 +167,7 @@ impl EvNodeTransaction {
139167

140168
impl Transaction for EvNodeTransaction {
141169
fn chain_id(&self) -> Option<alloy_primitives::ChainId> {
142-
Some(self.chain_id.into())
170+
Some(self.chain_id)
143171
}
144172

145173
fn nonce(&self) -> u64 {
@@ -189,7 +217,9 @@ impl Transaction for EvNodeTransaction {
189217
}
190218

191219
fn kind(&self) -> TxKind {
192-
self.first_call().map(|call| call.to).unwrap_or(TxKind::Create)
220+
self.first_call()
221+
.map(|call| call.to)
222+
.unwrap_or(TxKind::Create)
193223
}
194224

195225
fn is_create(&self) -> bool {
@@ -228,18 +258,26 @@ impl alloy_eips::Typed2718 for EvNodeTransaction {
228258

229259
impl SignableTransaction<Signature> for EvNodeTransaction {
230260
fn set_chain_id(&mut self, chain_id: alloy_primitives::ChainId) {
231-
self.chain_id = chain_id.into();
261+
self.chain_id = chain_id;
232262
}
233263

234264
fn encode_for_signing(&self, out: &mut dyn BufMut) {
235265
out.put_u8(EVNODE_TX_TYPE_ID);
236266
let payload_len = self.payload_fields_length(None);
237-
Header { list: true, payload_length: payload_len }.encode(out);
267+
Header {
268+
list: true,
269+
payload_length: payload_len,
270+
}
271+
.encode(out);
238272
self.encode_payload_fields(out, None);
239273
}
240274

241275
fn payload_len_for_signature(&self) -> usize {
242-
1 + Header { list: true, payload_length: self.payload_fields_length(None) }.length_with_payload()
276+
1 + Header {
277+
list: true,
278+
payload_length: self.payload_fields_length(None),
279+
}
280+
.length_with_payload()
243281
}
244282
}
245283

@@ -272,7 +310,11 @@ impl RlpEcdsaDecodableTx for EvNodeTransaction {
272310

273311
impl Encodable for EvNodeTransaction {
274312
fn length(&self) -> usize {
275-
Header { list: true, payload_length: self.rlp_encoded_fields_length() }.length_with_payload()
313+
Header {
314+
list: true,
315+
payload_length: self.rlp_encoded_fields_length(),
316+
}
317+
.length_with_payload()
276318
}
277319

278320
fn encode(&self, out: &mut dyn BufMut) {
@@ -418,8 +460,9 @@ impl FromTxCompact for EvTxEnvelope {
418460
{
419461
match tx_type {
420462
EvTxType::Ethereum(inner) => {
421-
let (tx, buf) =
422-
reth_ethereum_primitives::TransactionSigned::from_tx_compact(buf, inner, signature);
463+
let (tx, buf) = reth_ethereum_primitives::TransactionSigned::from_tx_compact(
464+
buf, inner, signature,
465+
);
423466
(Self::Ethereum(tx), buf)
424467
}
425468
EvTxType::EvNode => {
@@ -459,6 +502,21 @@ impl SignedTransaction for EvTxEnvelope {}
459502

460503
impl reth_primitives_traits::serde_bincode_compat::RlpBincode for EvTxEnvelope {}
461504

505+
impl Compress for EvTxEnvelope {
506+
type Compressed = Vec<u8>;
507+
508+
fn compress_to_buf<B: bytes::BufMut + AsMut<[u8]>>(&self, buf: &mut B) {
509+
let _ = Compact::to_compact(self, buf);
510+
}
511+
}
512+
513+
impl Decompress for EvTxEnvelope {
514+
fn decompress(value: &[u8]) -> Result<Self, DatabaseError> {
515+
let (obj, _) = Compact::from_compact(value, value.len());
516+
Ok(obj)
517+
}
518+
}
519+
462520
fn optional_signature_length(value: Option<&Signature>) -> usize {
463521
match value {
464522
Some(sig) => sig.as_bytes().as_slice().length(),
@@ -478,7 +536,9 @@ fn decode_optional_signature(buf: &mut &[u8]) -> alloy_rlp::Result<Option<Signat
478536
if bytes.is_empty() {
479537
return Ok(None);
480538
}
481-
let raw: [u8; 65] = bytes.try_into().map_err(|_| alloy_rlp::Error::UnexpectedLength)?;
539+
let raw: [u8; 65] = bytes
540+
.try_into()
541+
.map_err(|_| alloy_rlp::Error::UnexpectedLength)?;
482542
Signature::from_raw_array(&raw)
483543
.map(Some)
484544
.map_err(|_| alloy_rlp::Error::Custom("invalid signature bytes"))
@@ -502,7 +562,11 @@ mod tests {
502562
max_priority_fee_per_gas: 1,
503563
max_fee_per_gas: 2,
504564
gas_limit: 30_000,
505-
calls: vec![Call { to: TxKind::Create, value: U256::from(1), input: Bytes::new() }],
565+
calls: vec![Call {
566+
to: TxKind::Create,
567+
value: U256::from(1),
568+
input: Bytes::new(),
569+
}],
506570
access_list: AccessList::default(),
507571
fee_payer_signature: None,
508572
}

crates/ev-revm/src/api/exec.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
//! Execution traits for [`EvEvm`], mirroring the Reth mainnet implementations
22
//! while inserting the EV-specific handler that redirects the base fee.
33
4-
use crate::{evm::EvEvm, handler::EvHandler, tx_env::{BatchCallsTx, SponsorPayerTx}};
4+
use crate::{
5+
evm::EvEvm,
6+
handler::EvHandler,
7+
tx_env::{BatchCallsTx, SponsorPayerTx},
8+
};
59
use alloy_primitives::{Address, Bytes};
610
use reth_revm::revm::{
711
context::{result::ExecResultAndState, ContextSetters},
@@ -75,8 +79,7 @@ where
7579
Db: DatabaseCommit,
7680
Journal: JournalTr<State = EvmState>,
7781
Tx: SponsorPayerTx + BatchCallsTx,
78-
>
79-
+ ContextSetters,
82+
> + ContextSetters,
8083
<CTX as ContextTr>::Tx: Clone,
8184
PRECOMP: PrecompileProvider<CTX, Output = InterpreterResult>,
8285
{
@@ -87,8 +90,10 @@ where
8790

8891
impl<CTX, INSP, PRECOMP> InspectEvm for EvEvm<CTX, INSP, PRECOMP>
8992
where
90-
CTX: ContextTr<Journal: JournalTr<State = EvmState> + JournalExt, Tx: SponsorPayerTx + BatchCallsTx>
91-
+ ContextSetters,
93+
CTX: ContextTr<
94+
Journal: JournalTr<State = EvmState> + JournalExt,
95+
Tx: SponsorPayerTx + BatchCallsTx,
96+
> + ContextSetters,
9297
<CTX as ContextTr>::Tx: Clone,
9398
INSP: Inspector<CTX, EthInterpreter>,
9499
PRECOMP: PrecompileProvider<CTX, Output = InterpreterResult>,
@@ -114,8 +119,7 @@ where
114119
Journal: JournalTr<State = EvmState> + JournalExt,
115120
Db: DatabaseCommit,
116121
Tx: SponsorPayerTx + BatchCallsTx,
117-
>
118-
+ ContextSetters,
122+
> + ContextSetters,
119123
<CTX as ContextTr>::Tx: Clone,
120124
INSP: Inspector<CTX, EthInterpreter>,
121125
PRECOMP: PrecompileProvider<CTX, Output = InterpreterResult>,
@@ -124,8 +128,10 @@ where
124128

125129
impl<CTX, INSP, PRECOMP> SystemCallEvm for EvEvm<CTX, INSP, PRECOMP>
126130
where
127-
CTX: ContextTr<Journal: JournalTr<State = EvmState>, Tx: SystemCallTx + SponsorPayerTx + BatchCallsTx>
128-
+ ContextSetters,
131+
CTX: ContextTr<
132+
Journal: JournalTr<State = EvmState>,
133+
Tx: SystemCallTx + SponsorPayerTx + BatchCallsTx,
134+
> + ContextSetters,
129135
<CTX as ContextTr>::Tx: Clone,
130136
PRECOMP: PrecompileProvider<CTX, Output = InterpreterResult>,
131137
{
@@ -154,8 +160,7 @@ where
154160
CTX: ContextTr<
155161
Journal: JournalTr<State = EvmState> + JournalExt,
156162
Tx: SystemCallTx + SponsorPayerTx + BatchCallsTx,
157-
>
158-
+ ContextSetters,
163+
> + ContextSetters,
159164
<CTX as ContextTr>::Tx: Clone,
160165
INSP: Inspector<CTX, EthInterpreter>,
161166
PRECOMP: PrecompileProvider<CTX, Output = InterpreterResult>,

crates/ev-revm/src/factory.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ 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;
1213
use reth_revm::{
1314
inspector::NoOpInspector,
1415
revm::{
@@ -20,11 +21,10 @@ use reth_revm::{
2021
handler::instructions::EthInstructions,
2122
interpreter::interpreter::EthInterpreter,
2223
precompile::{PrecompileSpecId, Precompiles},
23-
Context, Inspector,
2424
primitives::hardfork::SpecId,
25+
Context, Inspector,
2526
},
2627
};
27-
use reth_revm::revm::context_interface::journaled_state::JournalTr;
2828
use std::sync::Arc;
2929

3030
/// Settings for enabling the base-fee redirect at a specific block height.
@@ -227,7 +227,12 @@ pub struct EvTxEvmFactory {
227227
contract_size_limit: Option<ContractSizeLimitSettings>,
228228
}
229229

230-
type EvEvmContext<DB> = Context<reth_revm::revm::context::BlockEnv, EvTxEnv, reth_revm::revm::context::CfgEnv<SpecId>, DB>;
230+
type EvEvmContext<DB> = Context<
231+
reth_revm::revm::context::BlockEnv,
232+
EvTxEnv,
233+
reth_revm::revm::context::CfgEnv<SpecId>,
234+
DB,
235+
>;
231236
type EvRevmEvm<DB, I> = RevmEvm<
232237
EvEvmContext<DB>,
233238
I,
@@ -237,12 +242,17 @@ type EvRevmEvm<DB, I> = RevmEvm<
237242
>;
238243

239244
impl EvTxEvmFactory {
245+
/// Creates a new EV EVM factory with optional redirect and precompile settings.
240246
pub const fn new(
241247
redirect: Option<BaseFeeRedirectSettings>,
242248
mint_precompile: Option<MintPrecompileSettings>,
243249
contract_size_limit: Option<ContractSizeLimitSettings>,
244250
) -> Self {
245-
Self { redirect, mint_precompile, contract_size_limit }
251+
Self {
252+
redirect,
253+
mint_precompile,
254+
contract_size_limit,
255+
}
246256
}
247257

248258
fn contract_size_limit_for_block(&self, block_number: U256) -> Option<usize> {
@@ -291,9 +301,9 @@ impl EvTxEvmFactory {
291301
env: EvmEnv<SpecId>,
292302
inspector: I,
293303
) -> EvRevmEvm<DB, I> {
294-
let precompiles = PrecompilesMap::from_static(Precompiles::new(PrecompileSpecId::from_spec_id(
295-
env.cfg_env.spec,
296-
)));
304+
let precompiles = PrecompilesMap::from_static(Precompiles::new(
305+
PrecompileSpecId::from_spec_id(env.cfg_env.spec),
306+
));
297307

298308
let mut journaled_state = reth_revm::revm::Journal::new(db);
299309
journaled_state.set_spec_id(env.cfg_env.spec);

0 commit comments

Comments
 (0)