diff --git a/crates/handler/src/frame.rs b/crates/handler/src/frame.rs index 56416f08d0..823ec568df 100644 --- a/crates/handler/src/frame.rs +++ b/crates/handler/src/frame.rs @@ -361,126 +361,6 @@ impl EthFrame { Ok(ItemOrResult::Item(this.consume())) } - /* - /// Make create frame. - #[inline] - pub fn make_eofcreate_frame( - mut this: OutFrame<'_, Self>, - evm: &mut EVM, - depth: usize, - memory: SharedMemory, - inputs: Box, - ) -> Result, ERROR> { - let context = evm.ctx(); - let spec = context.cfg().spec().into(); - let return_error = |e| { - Ok(ItemOrResult::Result(FrameResult::EOFCreate( - CreateOutcome { - result: InterpreterResult { - result: e, - gas: Gas::new(inputs.gas_limit), - output: Bytes::new(), - }, - address: None, - }, - ))) - }; - - let (input, initcode, created_address) = match &inputs.kind { - EOFCreateKind::Opcode { - initcode, - input, - created_address, - } => (input.clone(), initcode.clone(), Some(*created_address)), - EOFCreateKind::Tx { .. } => { - // Decode eof and init code. - // TODO : Handle inc_nonce handling more gracefully. - // let Ok((eof, input)) = Eof::decode_dangling(initdata.clone()) else { - // context.journal_mut().inc_account_nonce(inputs.caller)?; - // return return_error(InstructionResult::InvalidEOFInitCode); - // }; - - // if eof.validate().is_err() { - // // TODO : (EOF) New error type. - // context.journal_mut().inc_account_nonce(inputs.caller)?; - // return return_error(InstructionResult::InvalidEOFInitCode); - // } - - // // Use nonce from tx to calculate address. - // let tx = context.tx(); - // let create_address = tx.caller().create(tx.nonce()); - unreachable!("EOF is disabled"); - //(CallInput::Bytes(input), eof, Some(create_address)) - } - }; - - // Check depth - if depth > CALL_STACK_LIMIT as usize { - return return_error(InstructionResult::CallTooDeep); - } - - // Fetch balance of caller. - let caller = context.journal_mut().load_account(inputs.caller)?.data; - - // Check if caller has enough balance to send to the created contract. - if caller.info.balance < inputs.value { - return return_error(InstructionResult::OutOfFunds); - } - - // Increase nonce of caller and check if it overflows - let Some(new_nonce) = caller.info.nonce.checked_add(1) else { - // Can't happen on mainnet. - return return_error(InstructionResult::Return); - }; - caller.info.nonce = new_nonce; - context - .journal_mut() - .nonce_bump_journal_entry(inputs.caller); - - let old_nonce = new_nonce - 1; - - let created_address = created_address.unwrap_or_else(|| inputs.caller.create(old_nonce)); - - // Load account so it needs to be marked as warm for access list. - context.journal_mut().load_account(created_address)?; - - // Create account, transfer funds and make the journal checkpoint. - let checkpoint = match context.journal_mut().create_account_checkpoint( - inputs.caller, - created_address, - inputs.value, - spec, - ) { - Ok(checkpoint) => checkpoint, - Err(e) => return return_error(e.into()), - }; - - let interpreter_input = InputsImpl { - target_address: created_address, - caller_address: inputs.caller, - bytecode_address: None, - input, - call_value: inputs.value, - }; - - let gas_limit = inputs.gas_limit; - this.get(EthFrame::invalid).clear( - FrameData::EOFCreate(EOFCreateFrame { created_address }), - FrameInput::EOFCreate(inputs), - depth, - memory, - ExtBytecode::new(Bytecode::Eof(initcode)), - interpreter_input, - false, - true, - spec, - gas_limit, - checkpoint, - ); - Ok(ItemOrResult::Item(this.consume())) - } - */ - /// Initializes a frame with the given context and precompiles. pub fn init_with_context< CTX: ContextTr, @@ -727,47 +607,3 @@ pub fn return_create( interpreter_result.result = InstructionResult::Return; } - -/* -pub fn return_eofcreate( - journal: &mut JOURNAL, - checkpoint: JournalCheckpoint, - interpreter_result: &mut InterpreterResult, - address: Address, - max_code_size: usize, -) { - // Note we still execute RETURN opcode and return the bytes. - // In EOF those opcodes should abort execution. - // - // In RETURN gas is still protecting us from ddos and in oog, - // behaviour will be same as if it failed on return. - // - // Bytes of RETURN will drained in `insert_eofcreate_outcome`. - if interpreter_result.result != InstructionResult::ReturnContract { - journal.checkpoint_revert(checkpoint); - return; - } - - if interpreter_result.output.len() > max_code_size { - journal.checkpoint_revert(checkpoint); - interpreter_result.result = InstructionResult::CreateContractSizeLimit; - return; - } - - // Deduct gas for code deployment. - let gas_for_code = interpreter_result.output.len() as u64 * gas::CODEDEPOSIT; - if !interpreter_result.gas.record_cost(gas_for_code) { - journal.checkpoint_revert(checkpoint); - interpreter_result.result = InstructionResult::OutOfGas; - return; - } - - journal.checkpoint_commit(); - - // Decode bytecode has a performance hit, but it has reasonable restrains. - let bytecode = Eof::decode(interpreter_result.output.clone()).expect("Eof is already verified"); - - // Eof bytecode is going to be hashed. - journal.set_code(address, Bytecode::Eof(Arc::new(bytecode))); -} - */ diff --git a/crates/handler/src/validation.rs b/crates/handler/src/validation.rs index 52cb0fbb3d..241022bf9f 100644 --- a/crates/handler/src/validation.rs +++ b/crates/handler/src/validation.rs @@ -195,32 +195,6 @@ pub fn validate_tx_env( return Err(InvalidTransaction::EmptyAuthorizationList); } } - /* // TODO(EOF) EOF removed from spec. - TransactionType::Eip7873 => { - // Check if EIP-7873 transaction is enabled. - if !spec_id.is_enabled_in(SpecId::OSAKA) { - return Err(InvalidTransaction::Eip7873NotSupported); - } - // validate chain id - if Some(context.cfg().chain_id()) != tx.chain_id() { - return Err(InvalidTransaction::InvalidChainId); - } - - // validate initcodes. - validate_eip7873_initcodes(tx.initcodes())?; - - // InitcodeTransaction is invalid if the to is nil. - if tx.kind().is_create() { - return Err(InvalidTransaction::Eip7873MissingTarget); - } - - validate_priority_fee_tx( - tx.max_fee_per_gas(), - tx.max_priority_fee_per_gas().unwrap_or_default(), - base_fee, - )?; - } - */ TransactionType::Custom => { // Custom transaction type check is not done here. } @@ -243,44 +217,6 @@ pub fn validate_tx_env( Ok(()) } -/* TODO(EOF) -/// Validate Initcode Transaction initcode list, return error if any of the following conditions are met: -/// * there are zero entries in initcodes, or if there are more than MAX_INITCODE_COUNT entries. -/// * any entry in initcodes is zero length, or if any entry exceeds MAX_INITCODE_SIZE. -/// * the to is nil. -pub fn validate_eip7873_initcodes(initcodes: &[Bytes]) -> Result<(), InvalidTransaction> { - let mut i = 0; - for initcode in initcodes { - // InitcodeTransaction is invalid if any entry in initcodes is zero length - if initcode.is_empty() { - return Err(InvalidTransaction::Eip7873EmptyInitcode { i }); - } - - // or if any entry exceeds MAX_INITCODE_SIZE. - if initcode.len() > MAX_INITCODE_SIZE { - return Err(InvalidTransaction::Eip7873InitcodeTooLarge { - i, - size: initcode.len(), - }); - } - - i += 1; - } - - // InitcodeTransaction is invalid if there are zero entries in initcodes, - if i == 0 { - return Err(InvalidTransaction::Eip7873EmptyInitcodeList); - } - - // or if there are more than MAX_INITCODE_COUNT entries. - if i > MAX_INITCODE_COUNT { - return Err(InvalidTransaction::Eip7873TooManyInitcodes { size: i }); - } - - Ok(()) -} -*/ - /// Validate initial transaction gas. pub fn validate_initial_tx_gas( tx: impl Transaction,