Skip to content

Commit

Permalink
update runtime apis
Browse files Browse the repository at this point in the history
  • Loading branch information
ukint-vs committed Mar 17, 2024
1 parent 97e6dad commit b0d5167
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 34 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions pallets/gear-voucher/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

use crate::*;
use common::{benchmarking, Origin};
use frame_benchmarking::{benchmarks, Zero};
use frame_benchmarking::benchmarks;
use frame_support::traits::Currency;
use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin};
use sp_runtime::traits::{One, UniqueSaturatedInto};
use sp_runtime::traits::{One, UniqueSaturatedInto, Zero};

pub(crate) type CurrencyOf<T> = <T as Config>::Currency;

Expand Down
8 changes: 4 additions & 4 deletions pallets/gear/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ use core_processor::{
configs::{BlockConfig, PageCosts, TESTS_MAX_PAGES_NUMBER},
Ext, ProcessExecutionContext, ProcessorContext, ProcessorExternalities,
};

use parity_scale_codec::Encode;

use frame_benchmarking::{benchmarks, whitelisted_caller};
use frame_support::{
codec::Encode,
traits::{Currency, Get, Hooks},
};
use frame_support::traits::{Currency, Get, Hooks};
use frame_system::{Pallet as SystemPallet, RawOrigin};
use gear_core::{
code::{Code, CodeAndId},
Expand Down
2 changes: 1 addition & 1 deletion pallets/gear/src/benchmarking/tests/lazy_pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use core::mem::size_of;
use ::alloc::{collections::BTreeSet, format};
use common::ProgramStorage;
use core_processor::Ext;
use frame_support::codec::MaxEncodedLen;
use parity_scale_codec::MaxEncodedLen;
use gear_core::{
memory::MemoryInterval,
pages::{PageNumber, PageU32Size},
Expand Down
2 changes: 1 addition & 1 deletion pallets/gear/src/benchmarking/tests/syscalls_integrity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use gear_core::ids::{CodeId, ReservationId};
use gear_core_errors::{ReplyCode, SuccessReplyReason};
use gear_wasm_instrument::syscalls::SyscallName;
use pallet_timestamp::Pallet as TimestampPallet;
use parity_scale_codec::Decode;
use parity_scale_codec::{Encode, Decode};
use test_syscalls::{Kind, WASM_BINARY as SYSCALLS_TEST_WASM_BINARY};

pub fn read_big_state<T>()
Expand Down
26 changes: 8 additions & 18 deletions runtime/common/src/apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,31 +229,21 @@ macro_rules! impl_runtime_apis_plus_common {
fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, TrackedStorageKey};

use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch};
use sp_storage::TrackedStorageKey;
use frame_system_benchmarking::Pallet as SystemBench;
use baseline::Pallet as BaselineBench;

impl frame_system_benchmarking::Config for Runtime {}
impl baseline::Config for Runtime {}

let whitelist: Vec<TrackedStorageKey> = vec![
// Block Number
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
// Total Issuance
hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
// Execution Phase
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
// Event Count
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
// System Events
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
];


use frame_support::traits::WhitelistedStorageKeys;
let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();

let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);
add_benchmarks!(params, batches);

Ok(batches)
}
}
Expand Down
2 changes: 2 additions & 0 deletions runtime/vara/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ sp-runtime.workspace = true
sp-session.workspace = true
sp-staking.workspace = true
sp-std.workspace = true
sp-storage.workspace = true
sp-transaction-pool.workspace = true
sp-version.workspace = true

Expand Down Expand Up @@ -188,6 +189,7 @@ std = [
"sp-session/std",
"sp-staking/std",
"sp-std/std",
"sp-storage/std",
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
Expand Down
17 changes: 9 additions & 8 deletions runtime/vara/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1336,14 +1336,15 @@ impl_runtime_apis_plus_common! {
// slot duration and expected target block time, for safely
// resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
sp_consensus_babe::BabeConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: BABE_GENESIS_EPOCH_CONFIG.c,
authorities: Babe::authorities().to_vec(),
randomness: Babe::randomness(),
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
}
let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
sp_consensus_babe::BabeConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: epoch_config.c,
authorities: Babe::authorities().to_vec(),
randomness: Babe::randomness(),
allowed_slots: epoch_config.allowed_slots,
}
}

fn current_epoch_start() -> sp_consensus_babe::Slot {
Expand Down

0 comments on commit b0d5167

Please sign in to comment.