Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
gui1117 committed Dec 30, 2024
1 parent 830507d commit 3af64d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 6 additions & 3 deletions cumulus/pallets/weight-reclaim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ where
let extrinsic_len = frame_system::AllExtrinsicsLen::<T>::get().unwrap_or(0);
let node_side_pov_size = proof_size_after_dispatch.saturating_add(extrinsic_len.into());
let block_weight_proof_size = current_weight.total().proof_size();
let pov_size_missing_from_node = node_side_pov_size.saturating_sub(block_weight_proof_size);
let pov_size_missing_from_node =
node_side_pov_size.saturating_sub(block_weight_proof_size);
if pov_size_missing_from_node > 0 {
log::warn!(
target: LOG_TARGET,
Expand All @@ -248,7 +249,8 @@ where
{block_weight_proof_size}, missing: {pov_size_missing_from_node}. Setting to \
node-side proof size."
);
current_weight.accrue(Weight::from_parts(0, pov_size_missing_from_node), info.class);
current_weight
.accrue(Weight::from_parts(0, pov_size_missing_from_node), info.class);
}

pov_size_missing_from_node
Expand All @@ -257,7 +259,8 @@ where
// The saturation will happen if the pre-dispatch weight is underestimating the proof
// size or if the node-side proof size is higher than expected.
// In this case the extrinsic proof size weight reclaimed is 0 and not a negative reclaim.
let accurate_unspent = info.total_weight()
let accurate_unspent = info
.total_weight()
.saturating_sub(accurate_weight)
.saturating_sub(Weight::from_parts(0, pov_size_missing_from_node));
frame_system::ExtrinsicWeightReclaimed::<T>::put(accurate_unspent);
Expand Down
8 changes: 3 additions & 5 deletions cumulus/pallets/weight-reclaim/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,10 +931,8 @@ fn test_pov_missing_from_node_reclaim() {
let node_post_dispatch = node_pre_dispatch + node_diff;

// Initialize the test.
let mut test_ext = setup_test_externalities(&[
node_pre_dispatch as usize,
node_post_dispatch as usize,
]);
let mut test_ext =
setup_test_externalities(&[node_pre_dispatch as usize, node_post_dispatch as usize]);

test_ext.execute_with(|| {
set_current_storage_weight(block_pre_dispatch);
Expand All @@ -950,7 +948,7 @@ fn test_pov_missing_from_node_reclaim() {

// Execute the transaction.
let tx_ext = StorageWeightReclaim::<Test, frame_system::CheckWeight<Test>>::new(
frame_system::CheckWeight::new()
frame_system::CheckWeight::new(),
);
let (pre, _) = tx_ext
.validate_and_prepare(ALICE_ORIGIN.clone().into(), CALL, &info, len as usize, 0)
Expand Down

0 comments on commit 3af64d3

Please sign in to comment.