Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gshep committed Jun 16, 2022
1 parent c2c4cf1 commit 88c16b5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
1 change: 1 addition & 0 deletions pallets/gear/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use sp_std::vec::Vec;

sp_api::decl_runtime_apis! {
pub trait GearApi {
#[allow(clippy::too_many_arguments)]
fn calculate_gas_info(source: H256, kind: HandleKind, payload: Vec<u8>, value: u128, allow_other_panics: bool,) -> Result<GasInfo, Vec<u8>>;
}
}
2 changes: 2 additions & 0 deletions pallets/gear/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

//! RPC interface for the gear module.
#![allow(clippy::too_many_arguments)]

use gear_common::Origin;
use gear_core::ids::{MessageId, ProgramId};
use jsonrpsee::{
Expand Down
67 changes: 32 additions & 35 deletions pallets/gear/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,16 @@ where
Message::new(
root_message_id,
ProgramId::from_origin(source),
ProgramId::from_origin(dest),
dest,
payload,
Some(u64::MAX),
value,
None,
),
),
HandleKind::Reply(msg_id, exit_code) => {
let msg = MailboxOf::<T>::remove(
<T::AccountId as Origin>::from_origin(source),
MessageId::from_origin(msg_id),
)
.map_err(|_| "Internal error: unable to find message in mailbox")?;
let msg = MailboxOf::<T>::remove(<T::AccountId as Origin>::from_origin(source), msg_id)
.map_err(|_| "Internal error: unable to find message in mailbox")?;
Dispatch::new(
DispatchKind::Reply,
Message::new(
Expand Down Expand Up @@ -427,7 +424,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -513,7 +510,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -566,7 +563,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -607,7 +604,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -648,7 +645,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -689,7 +686,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -731,7 +728,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;

}: {
core_processor::process::<
Expand Down Expand Up @@ -773,7 +770,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -814,7 +811,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -867,7 +864,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -931,7 +928,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -999,7 +996,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![0xff; (n * 1024) as usize], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![0xff; (n * 1024) as usize], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1052,7 +1049,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1105,7 +1102,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1159,7 +1156,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1225,7 +1222,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1291,7 +1288,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1368,7 +1365,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 10000000u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 10000000u32.into())?;
}: {

let journal = core_processor::process::<
Expand Down Expand Up @@ -1447,7 +1444,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 10000000u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 10000000u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1515,7 +1512,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 10000000u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 10000000u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1581,7 +1578,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 10000000u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 10000000u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1639,7 +1636,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Reply(msg_id.into_origin(), 0), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Reply(msg_id, 0), vec![], 0u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1695,7 +1692,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1753,7 +1750,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Reply(msg_id.into_origin(), 0), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Reply(msg_id, 0), vec![], 0u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1818,7 +1815,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1873,7 +1870,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1928,7 +1925,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -1998,7 +1995,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down Expand Up @@ -2086,7 +2083,7 @@ benchmarks! {
program_id,
gas_allowance,
outgoing_limit,
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(instance.addr), vec![], 0u32.into())?;
} = prepare::<T>(instance.caller.into_origin(), HandleKind::Handle(ProgramId::from_origin(instance.addr)), vec![], 0u32.into())?;
}: {
let journal = core_processor::process::<
ext::LazyPagesExt,
Expand Down
4 changes: 2 additions & 2 deletions pallets/gear/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ pub mod pallet {

QueueOf::<T>::iter()
.next()
.ok_or(b"Internal error: failed to get last message".to_vec())
.ok_or_else(|| b"Internal error: failed to get last message".to_vec())
.and_then(|queued| {
queued
.map_err(|_| {
Expand All @@ -648,7 +648,7 @@ pub mod pallet {

QueueOf::<T>::iter()
.next()
.ok_or(b"Internal error: failed to get last message".to_vec())
.ok_or_else(|| b"Internal error: failed to get last message".to_vec())
.and_then(|queued| {
queued
.map_err(|_| {
Expand Down

0 comments on commit 88c16b5

Please sign in to comment.