Skip to content
Snippets Groups Projects
Unverified Commit 7314ddce authored by tgmichel's avatar tgmichel Committed by GitHub
Browse files

evm: Add executor logs to execute_evm response (#7048)

* evm: Add executor logs to execute_evm response

* Return logs on estimate gas

* Cleanup
parent f778556b
Branches
Tags
No related merge requests found
...@@ -337,10 +337,10 @@ decl_module! { ...@@ -337,10 +337,10 @@ decl_module! {
nonce, nonce,
true, true,
)? { )? {
(ExitReason::Succeed(_), _, _) => { (ExitReason::Succeed(_), _, _, _) => {
Module::<T>::deposit_event(Event::<T>::Executed(target)); Module::<T>::deposit_event(Event::<T>::Executed(target));
}, },
(_, _, _) => { (_, _, _, _) => {
Module::<T>::deposit_event(Event::<T>::ExecutedFailed(target)); Module::<T>::deposit_event(Event::<T>::ExecutedFailed(target));
}, },
} }
...@@ -371,10 +371,10 @@ decl_module! { ...@@ -371,10 +371,10 @@ decl_module! {
nonce, nonce,
true, true,
)? { )? {
(ExitReason::Succeed(_), create_address, _) => { (ExitReason::Succeed(_), create_address, _, _) => {
Module::<T>::deposit_event(Event::<T>::Created(create_address)); Module::<T>::deposit_event(Event::<T>::Created(create_address));
}, },
(_, create_address, _) => { (_, create_address, _, _) => {
Module::<T>::deposit_event(Event::<T>::CreatedFailed(create_address)); Module::<T>::deposit_event(Event::<T>::CreatedFailed(create_address));
}, },
} }
...@@ -406,10 +406,10 @@ decl_module! { ...@@ -406,10 +406,10 @@ decl_module! {
nonce, nonce,
true, true,
)? { )? {
(ExitReason::Succeed(_), create_address, _) => { (ExitReason::Succeed(_), create_address, _, _) => {
Module::<T>::deposit_event(Event::<T>::Created(create_address)); Module::<T>::deposit_event(Event::<T>::Created(create_address));
}, },
(_, create_address, _) => { (_, create_address, _, _) => {
Module::<T>::deposit_event(Event::<T>::CreatedFailed(create_address)); Module::<T>::deposit_event(Event::<T>::CreatedFailed(create_address));
}, },
} }
...@@ -485,7 +485,7 @@ impl<T: Trait> Module<T> { ...@@ -485,7 +485,7 @@ impl<T: Trait> Module<T> {
gas_price: U256, gas_price: U256,
nonce: Option<U256>, nonce: Option<U256>,
apply_state: bool, apply_state: bool,
) -> Result<(ExitReason, H160, U256), Error<T>> { ) -> Result<(ExitReason, H160, U256, Vec<Log>), Error<T>> {
Self::execute_evm( Self::execute_evm(
source, source,
value, value,
...@@ -517,7 +517,7 @@ impl<T: Trait> Module<T> { ...@@ -517,7 +517,7 @@ impl<T: Trait> Module<T> {
gas_price: U256, gas_price: U256,
nonce: Option<U256>, nonce: Option<U256>,
apply_state: bool, apply_state: bool,
) -> Result<(ExitReason, H160, U256), Error<T>> { ) -> Result<(ExitReason, H160, U256, Vec<Log>), Error<T>> {
let code_hash = H256::from_slice(Keccak256::digest(&init).as_slice()); let code_hash = H256::from_slice(Keccak256::digest(&init).as_slice());
Self::execute_evm( Self::execute_evm(
source, source,
...@@ -551,7 +551,7 @@ impl<T: Trait> Module<T> { ...@@ -551,7 +551,7 @@ impl<T: Trait> Module<T> {
gas_price: U256, gas_price: U256,
nonce: Option<U256>, nonce: Option<U256>,
apply_state: bool, apply_state: bool,
) -> Result<(ExitReason, Vec<u8>, U256), Error<T>> { ) -> Result<(ExitReason, Vec<u8>, U256, Vec<Log>), Error<T>> {
Self::execute_evm( Self::execute_evm(
source, source,
value, value,
...@@ -578,7 +578,7 @@ impl<T: Trait> Module<T> { ...@@ -578,7 +578,7 @@ impl<T: Trait> Module<T> {
nonce: Option<U256>, nonce: Option<U256>,
apply_state: bool, apply_state: bool,
f: F, f: F,
) -> Result<(ExitReason, R, U256), Error<T>> where ) -> Result<(ExitReason, R, U256, Vec<Log>), Error<T>> where
F: FnOnce(&mut StackExecutor<Backend<T>>) -> (ExitReason, R), F: FnOnce(&mut StackExecutor<Backend<T>>) -> (ExitReason, R),
{ {
...@@ -627,11 +627,19 @@ impl<T: Trait> Module<T> { ...@@ -627,11 +627,19 @@ impl<T: Trait> Module<T> {
); );
executor.deposit(source, total_fee.saturating_sub(actual_fee)); executor.deposit(source, total_fee.saturating_sub(actual_fee));
let (values, logs) = executor.deconstruct();
let logs_data = logs.into_iter().map(|x| x ).collect::<Vec<_>>();
let logs_result = logs_data.clone().into_iter().map(|it| {
Log {
address: it.address,
topics: it.topics,
data: it.data
}
}).collect();
if apply_state { if apply_state {
let (values, logs) = executor.deconstruct(); backend.apply(values, logs_data, true);
backend.apply(values, logs, true);
} }
Ok((retv, reason, used_gas)) Ok((retv, reason, used_gas, logs_result))
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment