mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 16:57:58 +00:00
Adds debug logs to EVM frame (#6887)
This commit is contained in:
@@ -6,7 +6,7 @@ use codec::{Encode, Decode};
|
||||
use sp_core::{U256, H256, H160};
|
||||
use sp_runtime::traits::UniqueSaturatedInto;
|
||||
use frame_support::traits::Get;
|
||||
use frame_support::storage::{StorageMap, StorageDoubleMap};
|
||||
use frame_support::{debug, storage::{StorageMap, StorageDoubleMap}};
|
||||
use sha3::{Keccak256, Digest};
|
||||
use evm::backend::{Backend as BackendT, ApplyBackend, Apply};
|
||||
use crate::{Trait, AccountStorages, AccountCodes, Module, Event};
|
||||
@@ -147,6 +147,12 @@ impl<'vicinity, T: Trait> ApplyBackend for Backend<'vicinity, T> {
|
||||
});
|
||||
|
||||
if let Some(code) = code {
|
||||
debug::debug!(
|
||||
target: "evm",
|
||||
"Inserting code ({} bytes) at {:?}",
|
||||
code.len(),
|
||||
address
|
||||
);
|
||||
AccountCodes::insert(address, code);
|
||||
}
|
||||
|
||||
@@ -156,8 +162,21 @@ impl<'vicinity, T: Trait> ApplyBackend for Backend<'vicinity, T> {
|
||||
|
||||
for (index, value) in storage {
|
||||
if value == H256::default() {
|
||||
debug::debug!(
|
||||
target: "evm",
|
||||
"Removing storage for {:?} [index: {:?}]",
|
||||
address,
|
||||
index
|
||||
);
|
||||
AccountStorages::remove(address, index);
|
||||
} else {
|
||||
debug::debug!(
|
||||
target: "evm",
|
||||
"Updating storage for {:?} [index: {:?}, value: {:?}]",
|
||||
address,
|
||||
index,
|
||||
value
|
||||
);
|
||||
AccountStorages::insert(address, index, value);
|
||||
}
|
||||
}
|
||||
@@ -167,12 +186,26 @@ impl<'vicinity, T: Trait> ApplyBackend for Backend<'vicinity, T> {
|
||||
}
|
||||
},
|
||||
Apply::Delete { address } => {
|
||||
debug::debug!(
|
||||
target: "evm",
|
||||
"Deleting account at {:?}",
|
||||
address
|
||||
);
|
||||
Module::<T>::remove_account(&address)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
for log in logs {
|
||||
debug::trace!(
|
||||
target: "evm",
|
||||
"Inserting log for {:?}, topics ({}) {:?}, data ({}): {:?}]",
|
||||
log.address,
|
||||
log.topics.len(),
|
||||
log.topics,
|
||||
log.data.len(),
|
||||
log.data
|
||||
);
|
||||
Module::<T>::deposit_event(Event::<T>::Log(Log {
|
||||
address: log.address,
|
||||
topics: log.topics,
|
||||
|
||||
@@ -32,7 +32,7 @@ use sp_std::vec::Vec;
|
||||
use codec::{Encode, Decode};
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Serialize, Deserialize};
|
||||
use frame_support::{ensure, decl_module, decl_storage, decl_event, decl_error};
|
||||
use frame_support::{debug, ensure, decl_module, decl_storage, decl_event, decl_error};
|
||||
use frame_support::weights::{Weight, Pays};
|
||||
use frame_support::traits::{Currency, ExistenceRequirement, Get};
|
||||
use frame_support::dispatch::DispatchResultWithPostInfo;
|
||||
@@ -617,6 +617,16 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
let used_gas = U256::from(executor.used_gas());
|
||||
let actual_fee = executor.fee(gas_price);
|
||||
debug::debug!(
|
||||
target: "evm",
|
||||
"Execution {:?} [source: {:?}, value: {}, gas_limit: {}, used_gas: {}, actual_fee: {}]",
|
||||
retv,
|
||||
source,
|
||||
value,
|
||||
gas_limit,
|
||||
used_gas,
|
||||
actual_fee
|
||||
);
|
||||
executor.deposit(source, total_fee.saturating_sub(actual_fee));
|
||||
|
||||
if apply_state {
|
||||
|
||||
Reference in New Issue
Block a user