Skip to content

Commit

Permalink
Add debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Nov 1, 2023
1 parent dab26a6 commit 56f56f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions client/rpc/src/eth/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,8 @@ where
}
previous_highest = highest;
}
// ExitReason::Revert(_)
// | ExitReason::Error(ExitError::InvalidCode(_)) => {
ExitReason::Revert(_)
| ExitReason::Error(ExitError::InvalidCode(_)) |
ExitReason::Error(ExitError::OutOfGas) => {
lowest = mid;
}
Expand Down
10 changes: 9 additions & 1 deletion frame/evm/src/runner/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,10 @@ where
.try_record_proof_size_or_fail(ACCOUNT_CODES_METADATA_PROOF_SIZE)?;

if let Some(meta) = <AccountCodesMetadata<T>>::get(address) {
frame_support::log::debug!(target: "bear", "bear: --- record_external_operation, hit metadata: {:?}", meta.size);
weight_info.try_record_proof_size_or_fail(meta.size)?;
} else {
frame_support::log::debug!(target: "bear", "bear: --- record_external_operation, doesn't hit metadata");
// If it does not exist, try to record `create_contract_limit` first.
weight_info.try_record_proof_size_or_fail(size_limit)?;
let meta = Pallet::<T>::account_code_metadata(address);
Expand Down Expand Up @@ -1025,7 +1027,7 @@ where
_gas_cost: GasCost,
target: evm::gasometer::StorageTarget,
) -> Result<(), ExitError> {
frame_support::log::debug!(target: "bear", "bear: --- record_external_dynamic_opcode_cost, op: {:?}, target: {:?}", opcode, target);
// frame_support::log::debug!(target: "bear", "bear: --- record_external_dynamic_opcode_cost, op: {:?}, target: {:?}", opcode, target);

// If account code or storage slot is in the overlay it is already accounted for and early exit
let mut accessed_storage: Option<AccessedStorage> = match target {
Expand Down Expand Up @@ -1095,12 +1097,18 @@ where
weight_info.try_record_proof_size_or_fail(base_cost)?;

if let Some(meta) = <AccountCodesMetadata<T>>::get(address) {
frame_support::log::debug!(target: "bear", "bear: --- record_external_dynamic_opcode_cost, hit metadata: {:?}", meta.size);
weight_info.try_record_proof_size_or_fail(meta.size)?;
} else {
frame_support::log::debug!(target: "bear", "bear: --- record_external_dynamic_opcode_cost, doesn't hit metadata");
// If it does not exist, try to record `create_contract_limit` first.

// weight_info.try_record_proof_size_or_fail(self.proof_size_left)?;
weight_info.try_record_proof_size_or_fail(size_limit)?;

let meta = Pallet::<T>::account_code_metadata(address);
let actual_size = meta.size;

// Refund if applies
weight_info.refund_proof_size(size_limit.saturating_sub(actual_size));
}
Expand Down
2 changes: 1 addition & 1 deletion primitives/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl WeightInfo {
})
}
fn try_consume(&self, cost: u64, limit: u64, usage: u64) -> Result<u64, ExitError> {
frame_support::log::debug!(target: "bear", "bear: --- try_consume, original_usage: {:?}, cost: {:?}, after that: {:?}", usage, cost, usage + cost);
// frame_support::log::debug!(target: "bear", "bear: --- try_consume, original_usage: {:?}, cost: {:?}, after that: {:?}", usage, cost, usage + cost);
let usage = usage.checked_add(cost).ok_or(ExitError::OutOfGas)?;
if usage > limit {
frame_support::log::debug!(target: "bear", "bear: --- out of gas at try_consume, usage: {:?}, limit: {:?}", usage, limit);
Expand Down

0 comments on commit 56f56f9

Please sign in to comment.