Skip to content

Commit

Permalink
Fixup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neopallium committed Dec 12, 2022
1 parent d8aa114 commit 1226778
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion pallets/contracts/src/chain_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,9 @@ where
&mut self,
env: ce::Environment<E, ce::InitState>,
) -> ce::Result<ce::RetVal> {
let ext_id = ((env.ext_id() as u32) << 16) + env.func_id() as u32;
// Decode chain extension id.
let func_id = FuncId::try_from(((env.ext_id() as u32) << 16) + env.func_id() as u32);
let func_id = FuncId::try_from(ext_id);

trace!(
target: "runtime",
Expand Down
13 changes: 6 additions & 7 deletions pallets/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@
pub mod benchmarking;

pub mod chain_extension;
pub use chain_extension::ExtrinsicId;
pub use chain_extension::{ExtrinsicId, PolymeshExtension};

use frame_support::{
decl_error, decl_event, decl_module, decl_storage,
dispatch::{
DispatchError, DispatchErrorWithPostInfo, DispatchResult, DispatchResultWithPostInfo,
},
ensure,
log::trace,
traits::Get,
weights::Weight,
};
Expand Down Expand Up @@ -130,7 +129,7 @@ macro_rules! cost {

macro_rules! cost_batched {
($name:ident) => {
cost!($name) / Weight::from(CHAIN_EXTENSION_BATCH_SIZE)
cost!($name) / u64::from(CHAIN_EXTENSION_BATCH_SIZE)
};
}

Expand Down Expand Up @@ -193,19 +192,19 @@ pub trait WeightInfo {
fn hash_twox_64(r: u32) -> Weight {
let per_byte = cost_byte_batched!(chain_extension_hash_twox_64_per_kb);
cost_batched!(chain_extension_hash_twox_64)
.saturating_add(per_byte.saturating_mul(r as Weight))
.saturating_add(per_byte.saturating_mul(r as u64))
}

fn hash_twox_128(r: u32) -> Weight {
let per_byte = cost_byte_batched!(chain_extension_hash_twox_128_per_kb);
cost_batched!(chain_extension_hash_twox_128)
.saturating_add(per_byte.saturating_mul(r as Weight))
.saturating_add(per_byte.saturating_mul(r as u64))
}

fn hash_twox_256(r: u32) -> Weight {
let per_byte = cost_byte_batched!(chain_extension_hash_twox_256_per_kb);
cost_batched!(chain_extension_hash_twox_256)
.saturating_add(per_byte.saturating_mul(r as Weight))
.saturating_add(per_byte.saturating_mul(r as u64))
}

fn call_runtime(in_len: u32) -> Weight {
Expand Down Expand Up @@ -391,7 +390,7 @@ where
{
/// Instantiates a contract using `code` as the WASM code blob.
fn base_update_call_runtime_whitelist(
origin: T::Origin,
origin: T::RuntimeOrigin,
updates: Vec<(ExtrinsicId, bool)>,
) -> DispatchResult {
ensure_root(origin)?;
Expand Down

0 comments on commit 1226778

Please sign in to comment.