Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return deployed bytecode on eth_call contract creation #2119

Merged
merged 4 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ain-evm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl EVMHandler {
)
.map_err(|e| anyhow!("------ Could not restore backend {}", e))?;
Ok(AinExecutor::new(&mut backend).call(ExecutorContext {
caller,
caller: caller.unwrap_or_default(),
to,
value,
data,
Expand Down
32 changes: 19 additions & 13 deletions lib/ain-evm/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use crate::{
use ethereum::{EIP658ReceiptData, Log, ReceiptV3};
use ethereum_types::{Bloom, U256};
use evm::{
backend::ApplyBackend,
backend::{ApplyBackend, Backend},
executor::stack::{MemoryStackState, StackExecutor, StackSubstateMetadata},
Config, ExitReason,
Config, CreateScheme, ExitReason,
};
use log::trace;
use primitive_types::{H160, H256};
Expand Down Expand Up @@ -58,20 +58,26 @@ impl<'backend> Executor for AinExecutor<'backend> {

let (exit_reason, data) = match ctx.to {
Some(address) => executor.transact_call(
ctx.caller.unwrap_or_default(),
ctx.caller,
address,
ctx.value,
ctx.data.to_vec(),
ctx.gas_limit,
access_list,
),
None => executor.transact_create(
ctx.caller.unwrap_or_default(),
ctx.value,
ctx.data.to_vec(),
ctx.gas_limit,
access_list,
),
None => {
let contract_address =
executor.create_address(CreateScheme::Legacy { caller: ctx.caller });
let (exit_reason, _) = executor.transact_create(
ctx.caller,
ctx.value,
ctx.data.to_vec(),
ctx.gas_limit,
access_list,
);
let code = executor.state().code(contract_address);
(exit_reason, code)
}
};

TxResponse {
Expand All @@ -90,7 +96,7 @@ impl<'backend> Executor for AinExecutor<'backend> {
self.backend.vicinity
);
let ctx = ExecutorContext {
caller: Some(signed_tx.sender),
caller: signed_tx.sender,
to: signed_tx.to(),
value: signed_tx.value(),
data: signed_tx.data(),
Expand All @@ -114,15 +120,15 @@ impl<'backend> Executor for AinExecutor<'backend> {

let (exit_reason, data) = match ctx.to {
Some(address) => executor.transact_call(
ctx.caller.unwrap_or_default(),
ctx.caller,
address,
ctx.value,
ctx.data.to_vec(),
ctx.gas_limit,
access_list,
),
None => executor.transact_create(
ctx.caller.unwrap_or_default(),
ctx.caller,
ctx.value,
ctx.data.to_vec(),
ctx.gas_limit,
Expand Down
2 changes: 1 addition & 1 deletion lib/ain-evm/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use primitive_types::{H160, U256};

#[derive(Debug)]
pub struct ExecutorContext<'a> {
pub caller: Option<H160>,
pub caller: H160,
pub to: Option<H160>,
pub value: U256,
pub data: &'a [u8],
Expand Down