revm_handler/
execution.rs1use context::{ContextTr, Database, JournalTr};
2use context_interface::Transaction;
3use interpreter::{
4 CallInput, CallInputs, CallScheme, CallValue, CreateInputs, CreateScheme, FrameInput,
5};
6use primitives::TxKind;
7use state::Bytecode;
8use std::boxed::Box;
9
10#[inline]
12pub fn create_init_frame<CTX: ContextTr>(
13 ctx: &mut CTX,
14 gas_limit: u64,
15 reservoir: u64,
16) -> Result<FrameInput, <<CTX::Journal as JournalTr>::Database as Database>::Error> {
17 let (tx, journal) = ctx.tx_journal_mut();
18 let input = tx.input().clone();
19
20 match tx.kind() {
21 TxKind::Call(target_address) => {
22 let account = &journal.load_account_with_code(target_address)?.info;
23
24 let known_bytecode = if let Some(delegated_address) =
25 account.code.as_ref().and_then(Bytecode::eip7702_address)
26 {
27 let account = &journal.load_account_with_code(delegated_address)?.info;
28 (
29 account.code_hash(),
30 account.code.clone().unwrap_or_default(),
31 )
32 } else {
33 (
34 account.code_hash(),
35 account.code.clone().unwrap_or_default(),
36 )
37 };
38 Ok(FrameInput::Call(Box::new(CallInputs {
39 input: CallInput::Bytes(input),
40 gas_limit,
41 target_address,
42 bytecode_address: target_address,
43 known_bytecode,
44 caller: tx.caller(),
45 value: CallValue::Transfer(tx.value()),
46 scheme: CallScheme::Call,
47 is_static: false,
48 return_memory_offset: 0..0,
49 reservoir,
50 })))
51 }
52 TxKind::Create => Ok(FrameInput::Create(Box::new(CreateInputs::new(
53 tx.caller(),
54 CreateScheme::Create,
55 tx.value(),
56 input,
57 gas_limit,
58 reservoir,
59 )))),
60 }
61}