Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulksnv committed Dec 9, 2023
1 parent 06922dc commit b15b528
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frame/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]
ethereum = { workspace = true, features = ["with-codec"] }
ethereum-types = { workspace = true }
evm = { workspace = true, features = ["with-codec"] }
log = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-info = { workspace = true }
# Substrate
Expand Down Expand Up @@ -47,6 +48,7 @@ std = [
"ethereum/std",
"evm/std",
"ethereum-types/std",
"log/std",
"rlp/std",
"scale-codec/std",
"scale-info/std",
Expand Down
51 changes: 45 additions & 6 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,16 @@ pub mod pallet {

impl<T: Config> Pallet<T> {
pub fn transaction_weight(transaction_data: &TransactionData) -> (Option<Weight>, Option<u64>) {
match <T as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
let ret = <T as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
transaction_data.gas_limit.unique_saturated_into(),
true,
) {
);
log::debug!(
target: "evm",
"EthereumPallet::transaction_weight(): ret = {:?}, proof_size_base_cost = {:?}",
ret, transaction_data.proof_size_base_cost
);
match ret {
weight_limit if weight_limit.proof_size() > 0 => (
Some(weight_limit),
Some(transaction_data.proof_size_base_cost.unwrap_or_default()),
Expand Down Expand Up @@ -723,6 +729,7 @@ impl<T: Config> Pallet<T> {
let is_transactional = true;
let validate = false;


let (
input,
value,
Expand Down Expand Up @@ -785,6 +792,13 @@ impl<T: Config> Pallet<T> {

match action {
ethereum::TransactionAction::Call(target) => {
log::debug!(
target: "evm",
"PalletEthereum::execute()::call: value={}, gas_limit={}, max_fee_per_gas={:?} \
max_priority_fee_per_gas={:?}, nonce={:?}, is_transactional={}, weight_limit={:?}, proof_size_base_cost={:?}",
value, gas_limit, max_fee_per_gas, max_priority_fee_per_gas, nonce,
is_transactional, weight_limit, proof_size_base_cost
);
let res = match T::Runner::call(
from,
target,
Expand All @@ -803,19 +817,35 @@ impl<T: Config> Pallet<T> {
) {
Ok(res) => res,
Err(e) => {
return Err(DispatchErrorWithPostInfo {
let ret = Err(DispatchErrorWithPostInfo {
post_info: PostDispatchInfo {
actual_weight: Some(e.weight),
pays_fee: Pays::Yes,
},
error: e.error.into(),
})
});
log::debug!(
target: "evm",
"PalletEthereum::execute()::call: err = {ret:?}"
);
return ret;
}
};
log::debug!(
target: "evm",
"PalletEthereum::execute()::call: res = {res:?}"
);

Ok((Some(target), None, CallOrCreateInfo::Call(res)))
}
ethereum::TransactionAction::Create => {
log::debug!(
target: "evm",
"PalletEthereum::execute()::create: value={}, gas_limit={}, max_fee_per_gas={:?} \
max_priority_fee_per_gas={:?}, nonce={:?}, is_transactional={}, weight_limit={:?}, proof_size_base_cost={:?}",
value, gas_limit, max_fee_per_gas, max_priority_fee_per_gas, nonce,
is_transactional, weight_limit, proof_size_base_cost
);
let res = match T::Runner::create(
from,
input,
Expand All @@ -833,15 +863,24 @@ impl<T: Config> Pallet<T> {
) {
Ok(res) => res,
Err(e) => {
return Err(DispatchErrorWithPostInfo {
let ret = Err(DispatchErrorWithPostInfo {
post_info: PostDispatchInfo {
actual_weight: Some(e.weight),
pays_fee: Pays::Yes,
},
error: e.error.into(),
})
});
log::debug!(
target: "evm",
"PalletEthereum::execute()::create: err = {ret:?}"
);
return ret;
}
};
log::debug!(
target: "evm",
"PalletEthereum::execute()::create = {res:?}"
);

Ok((None, Some(res.value), CallOrCreateInfo::Create(res)))
}
Expand Down

0 comments on commit b15b528

Please sign in to comment.