Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
2bdecf86
Unverified
Commit
2bdecf86
authored
1 year ago
by
bgallois
Browse files
Options
Downloads
Patches
Plain Diff
fix FeeMultiplier minimum
parent
f8e51fa3
Branches
Branches containing commit
No related tags found
1 merge request
!268
Fix #232
Pipeline
#37182
failed
1 year ago
Stage: labels
Stage: quality
Stage: build
Stage: tests
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
runtime/common/src/fees.rs
+6
-6
6 additions, 6 deletions
runtime/common/src/fees.rs
runtime/gdev/tests/fee_tests.rs
+4
-7
4 additions, 7 deletions
runtime/gdev/tests/fee_tests.rs
with
10 additions
and
13 deletions
runtime/common/src/fees.rs
+
6
−
6
View file @
2bdecf86
...
...
@@ -25,7 +25,7 @@ use pallet_transaction_payment::{Multiplier, MultiplierUpdate};
use
sp_arithmetic
::
traits
::{
BaseArithmetic
,
Unsigned
};
use
sp_core
::
Get
;
use
sp_runtime
::{
traits
::{
Convert
,
Zero
},
traits
::{
Convert
,
One
},
Perquintill
,
};
#[cfg(not(feature
=
"constant-fees"
))]
...
...
@@ -78,7 +78,7 @@ where
if
current_block_weight
.get
(
DispatchClass
::
Normal
)
.all_lt
(
X
::
get
()
*
normal_max_weight
)
&&
fee_multiplier
.is_
zero
()
&&
fee_multiplier
.is_
one
()
{
0u32
.into
()
}
else
{
...
...
@@ -133,7 +133,7 @@ where
if
current_block_weight
.get
(
DispatchClass
::
Normal
)
.all_lt
(
X
::
get
()
*
normal_max_weight
)
&&
fee_multiplier
.is_
zero
()
&&
fee_multiplier
.is_
one
()
{
smallvec!
[
WeightToFeeCoefficient
{
degree
:
1
,
...
...
@@ -189,7 +189,7 @@ where
X
:
Get
<
Multiplier
>
,
{
fn
min
()
->
Multiplier
{
0
.into
()
1
.into
()
}
fn
max
()
->
Multiplier
{
...
...
@@ -215,7 +215,7 @@ where
/// Function to convert the previous fee multiplier to a new fee multiplier.
///
/// This function adjusts the fee multiplier based on the current block weight and target block fullness.
/// - If the current block weight is less than the target, it decreases the multiplier by one, with a minimum of
zero
.
/// - If the current block weight is less than the target, it decreases the multiplier by one, with a minimum of
one
.
/// - If the current block weight is more than the target, it increases the multiplier by one, up to the maximum multiplier.
#[cfg(not(feature
=
"constant-fees"
))]
fn
convert
(
previous
:
Multiplier
)
->
Multiplier
{
...
...
@@ -235,7 +235,7 @@ where
// If the current block weight is less than the target, keep the
// multiplier at the minimum or decrease it by one to slowly
// return to the minimum.
previous
.saturating_sub
(
1
.into
())
.max
(
0
.into
())
previous
.saturating_sub
(
1
.into
())
.max
(
1
.into
())
}
else
{
// If the current block weight is more than the target, increase
// the multiplier by one.
...
...
This diff is collapsed.
Click to expand it.
runtime/gdev/tests/fee_tests.rs
+
4
−
7
View file @
2bdecf86
...
...
@@ -33,7 +33,6 @@ fn test_fees_empty() {
])
.build
()
.execute_with
(||
{
run_to_block
(
2
);
let
call
=
RuntimeCall
::
Balances
(
BalancesCall
::
transfer_allow_death
{
dest
:
AccountKeyring
::
Eve
.to_account_id
()
.into
(),
value
:
500
,
...
...
@@ -62,7 +61,6 @@ fn test_fees_full() {
])
.build
()
.execute_with
(||
{
run_to_block
(
2
);
let
mut
transactions
=
0u64
;
let
weights
=
BlockWeights
::
get
();
let
normal_max_weight
=
weights
...
...
@@ -132,15 +130,14 @@ fn test_fees_multiplier() {
.max_total
.unwrap_or
(
weights
.max_block
);
run_to_block
(
2
);
assert_eq!
(
pallet_transaction_payment
::
Pallet
::
<
Runtime
>
::
next_fee_multiplier
(),
0
.into
()
1
.into
()
);
// If the block weight is over the target and the previous block was also over the target,
// the fee multiplier is increased by one, up to the MaxMultiplier.
let
mut
current
=
0u128
;
for
i
in
3
..
20u128
{
for
i
in
1
..
20u128
{
System
::
set_block_consumed_resources
(
Target
::
get
()
*
normal_max_weight
,
100_usize
);
run_to_block
(
i
as
u32
);
current
+=
1
;
...
...
@@ -151,11 +148,11 @@ fn test_fees_multiplier() {
}
// If the block weight is under the target and the previous block was also under the target,
// the fee multiplier is decreased by one, down to the
0
.
// the fee multiplier is decreased by one, down to the
one
.
let
mut
current
=
10u128
;
for
i
in
20
..
50u32
{
run_to_block
(
i
);
current
=
current
.saturating_sub
(
1
);
current
=
current
.saturating_sub
(
1
)
.max
(
1u128
.into
())
;
assert_eq!
(
pallet_transaction_payment
::
Pallet
::
<
Runtime
>
::
next_fee_multiplier
(),
current
.into
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment