Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
8 changes: 6 additions & 2 deletions runtimes/bulletin-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use parachains_common::{
impls::DealWithFees,
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
AccountId, AuraId, Balance, BlockNumber, Hash, Header, Nonce, Signature,
AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO,
AVERAGE_ON_INITIALIZE_RATIO,
};
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use sp_api::impl_runtime_apis;
Expand Down Expand Up @@ -171,10 +171,14 @@ pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}

/// We allow for 90% of the block to be consumed by normal transactions.
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(90);

parameter_types! {
pub const Version: RuntimeVersion = VERSION;
// 10 MiB (allows 9 MiB for normal transactions with 90% NORMAL_DISPATCH_RATIO)
pub RuntimeBlockLength: BlockLength =
BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
BlockLength::max_with_normal_ratio(10 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
.base_block(BlockExecutionWeight::get())
.for_class(DispatchClass::all(), |weights| {
Expand Down
33 changes: 28 additions & 5 deletions runtimes/bulletin-westend/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ use xcm_runtime_apis::conversions::LocationToAccountHelper;

const ALICE: [u8; 32] = [1u8; 32];

/// Advance to the next block for testing transaction storage.
fn advance_block() {
use bulletin_westend_runtime::TransactionStorage;
use frame_support::traits::{OnFinalize, OnInitialize};

let current = frame_system::Pallet::<Runtime>::block_number();

TransactionStorage::on_finalize(current);
System::on_finalize(current);

let next = current + 1;
System::set_block_number(next);

frame_system::BlockWeight::<Runtime>::kill();
frame_system::AllExtrinsicsLen::<Runtime>::kill();

System::on_initialize(next);
TransactionStorage::on_initialize(next);
}

fn construct_extrinsic(
sender: sp_core::sr25519::Pair,
call: RuntimeCall,
Expand Down Expand Up @@ -105,11 +125,11 @@ fn transaction_storage_runtime_sizes() {
let who: AccountId = account.to_account_id();
#[allow(clippy::identity_op)]
let sizes: [usize; 5] = [
2000, // 2 KB
256 * 1024, // 256 KB
512 * 1024, // 512 KB
1 * 1024 * 1024, // 1 MB
(3 * 1024 * 1024) / 2, // 1.5 MB
2000, // 2 KB
1 * 1024 * 1024, // 1 MB
4 * 1024 * 1024, // 4 MB
6 * 1024 * 1024, // 6 MB
8 * 1024 * 1024, // 8 MB
];
let total_bytes: u64 = sizes.iter().map(|s| *s as u64).sum();

Expand All @@ -131,6 +151,9 @@ fn transaction_storage_runtime_sizes() {

// store data via signed extrinsics (ValidateSigned consumes authorization)
for (index, size) in sizes.into_iter().enumerate() {
// Advance to a new block for each store
advance_block();

tracing::info!("Storing data with size: {size} and index: {index}");
let res = construct_and_apply_extrinsic(
account.pair(),
Expand Down