Skip to content

Fee Adjustment Tests #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
41 changes: 3 additions & 38 deletions sugondat-chain/runtimes/sugondat-kusama/src/fee_adjustment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,9 @@ where
let max_multiplier = MaximumMultiplierBlockSize::get();
let previous_len_multiplier = previous_len_multiplier.max(min_multiplier);

// Pick the limiting dimension. (from TargetedFeeAdjustment::convert)
//
// In this case it is the length of all extrinsic, always
// The limiting dimension is the length of all extrinsic
let (normal_limiting_dimension, max_limiting_dimension) = (
<frame_system::Pallet<T>>::all_extrinsics_len(),
<frame_system::Pallet<T>>::all_extrinsics_len().min(MAXIMUM_BLOCK_LENGTH),
MAXIMUM_BLOCK_LENGTH as u64,
);

Expand Down Expand Up @@ -197,7 +195,7 @@ impl<T: frame_system::Config> sp_weights::WeightToFee for BlobsLengthToFee<T> {
#[cfg(test)]
mod tests {
use super::*;
use crate::{MaxBlobSize, Runtime};
use crate::Runtime;
use sp_runtime::BuildStorage;

fn new_test_ext() -> sp_io::TestExternalities {
Expand Down Expand Up @@ -225,37 +223,4 @@ mod tests {
);
});
}

#[test]
fn test_blobs_fee_adjustment_convert() {
use codec::Encode;
use sp_core::twox_128;

for len in (0..MaxBlobSize::get()).into_iter().step_by(100) {
new_test_ext().execute_with(|| {
// AllExtrinsicsLen is a private storage value of the system pallet
// so the key must be manually constructed
sp_io::storage::set(
&[twox_128(b"System"), twox_128(b"AllExtrinsicsLen")].concat(),
&len.encode(),
);

let fee_multiplier = Multiplier::saturating_from_rational(7, 8);

let new_fee_multiplier = BlobsFeeAdjustment::<Runtime>::convert(fee_multiplier);

// fee_multiplier should follow the standard behavior
let expected_fee_multiplier = TargetedFeeAdjustment::<
Runtime,
TargetBlockFullness,
AdjustmentVariableBlockFullness,
MinimumMultiplierBlockFullness,
MaximumMultiplierBlockFullness,
>::convert(fee_multiplier);
assert_eq!(new_fee_multiplier, expected_fee_multiplier);

// TODO: Ensure length multiplier is update properly
});
}
}
}
Loading