Skip to content

Commit

Permalink
style: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwht committed Mar 7, 2024
1 parent d25fa7d commit 59e4e99
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions runtime/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ where
// reference: https://github.com/paritytech/polkadot-sdk/blob/117a9433dac88d5ac00c058c9b39c511d47749d2/substrate/frame/contracts/src/wasm/runtime.rs#L2159
let base_weight: Weight = contract_host_weight.return_per_byte.saturating_mul(len.into());

// debug_message weight is a good approximation of the additional overhead of going
// from contract layer to substrate layer.
// debug_message weight is a good approximation of the additional overhead of going
// from contract layer to substrate layer.
// reference: https://github.com/paritytech/ink-examples/blob/b8d2caa52cf4691e0ddd7c919e4462311deb5ad0/psp22-extension/runtime/psp22-extension-example.rs#L236
let overhead = contract_host_weight.debug_message;
let overhead = contract_host_weight.debug_message;

let charged_weight = env.charge_weight(base_weight.saturating_add(overhead))?;
log::debug!(target:LOG_TARGET, "{} charged weight: {:?}", LOG_PREFIX, charged_weight);
Expand Down Expand Up @@ -149,7 +149,10 @@ where
// To be conservative, we charge the weight for reading the input bytes.
// However, charge weight is not strictly necessary here as reading a fixed value's weight is included in the contract call.
// Source: https://github.com/paritytech/polkadot-sdk/blob/117a9433dac88d5ac00c058c9b39c511d47749d2/substrate/frame/contracts/src/wasm/runtime.rs#L563
let base_weight: Weight = ContractSchedule::<T>::get().host_fn_weights.return_per_byte.saturating_mul(env.in_len().into());
let base_weight: Weight = ContractSchedule::<T>::get()
.host_fn_weights
.return_per_byte
.saturating_mul(env.in_len().into());
let charged_weight = env.charge_weight(base_weight)?;

log::debug!(target:LOG_TARGET, "{} charged weight: {:?}", LOG_PREFIX, charged_weight);
Expand All @@ -159,7 +162,8 @@ where
let result = match key {
ParachainSystemKeys::LastRelayChainBlockNumber => {
env.charge_weight(T::DbWeight::get().reads(1_u64))?;
let relay_block_num: BlockNumber = cumulus_pallet_parachain_system::Pallet::<T>::last_relay_block_number();
let relay_block_num: BlockNumber =
cumulus_pallet_parachain_system::Pallet::<T>::last_relay_block_number();
log::debug!(
target:LOG_TARGET,
"{} last relay chain block number is: {:?}.", LOG_PREFIX, relay_block_num
Expand Down

0 comments on commit 59e4e99

Please sign in to comment.