Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update precompiles utils
  • Loading branch information
mclyk committed Nov 23, 2022
commit 375cec31c59aeec3bb8814f8876c1e57bf965ebf
12 changes: 6 additions & 6 deletions precompiles/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,20 @@ pub struct RuntimeHelper<Runtime>(PhantomData<Runtime>);
impl<Runtime> RuntimeHelper<Runtime>
where
Runtime: pallet_evm::Config,
Runtime::Call: Dispatchable<PostInfo = PostDispatchInfo> + GetDispatchInfo,
Runtime::RuntimeCall: Dispatchable<PostInfo = PostDispatchInfo> + GetDispatchInfo,
{
/// Try to dispatch a Substrate call.
/// Return an error if there are not enough gas, or if the call fails.
/// If successful returns the used gas using the Runtime GasWeightMapping.
pub fn try_dispatch<Call>(
handle: &mut impl PrecompileHandleExt,
origin: <Runtime::Call as Dispatchable>::Origin,
origin: <Runtime::RuntimeCall as Dispatchable>::RuntimeOrigin,
call: Call,
) -> EvmResult<()>
where
Runtime::Call: From<Call>,
Runtime::RuntimeCall: From<Call>,
{
let call = Runtime::Call::from(call);
let call = Runtime::RuntimeCall::from(call);
let dispatch_info = call.get_dispatch_info();

// Make sure there is enough gas.
Expand Down Expand Up @@ -214,14 +214,14 @@ where
/// Cost of a Substrate DB write in gas.
pub fn db_write_gas_cost() -> u64 {
<Runtime as pallet_evm::Config>::GasWeightMapping::weight_to_gas(
<Runtime as frame_system::Config>::DbWeight::get().write,
<Runtime as frame_system::Config>::DbWeight::get().writes(1),
)
}

/// Cost of a Substrate DB read in gas.
pub fn db_read_gas_cost() -> u64 {
<Runtime as pallet_evm::Config>::GasWeightMapping::weight_to_gas(
<Runtime as frame_system::Config>::DbWeight::get().read,
<Runtime as frame_system::Config>::DbWeight::get().reads(1),
)
}
}
Expand Down