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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
9565800e
Unverified
Commit
9565800e
authored
1 year ago
by
bgallois
Browse files
Options
Downloads
Patches
Plain Diff
remove transaction fees
parent
88c80b7d
No related branches found
No related tags found
No related merge requests found
Pipeline
#37146
passed
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
+50
-16
50 additions, 16 deletions
runtime/common/src/fees.rs
runtime/common/src/pallets_config.rs
+5
-4
5 additions, 4 deletions
runtime/common/src/pallets_config.rs
with
55 additions
and
20 deletions
runtime/common/src/fees.rs
+
50
−
16
View file @
9565800e
...
...
@@ -22,10 +22,11 @@
pub
use
frame_support
::
weights
::{
Weight
,
WeightToFee
};
use
sp_arithmetic
::
traits
::{
BaseArithmetic
,
Unsigned
};
use
sp_core
::
Get
;
#[cfg(not(feature
=
"constant-fees"
))]
use
{
crate
::
weights
::
extrinsic_weights
::
ExtrinsicBaseWeight
,
frame_support
::
pallet_prelude
::
DispatchClass
,
frame_support
::
weights
::{
WeightToFeeCoefficient
,
WeightToFeeCoefficients
,
WeightToFeePolynomial
,
},
...
...
@@ -35,18 +36,32 @@ use {
sp_runtime
::
SaturatedConversion
,
};
pub
struct
LengthToFeeImpl
<
T
>
(
sp_std
::
marker
::
PhantomData
<
T
>
);
pub
struct
LengthToFeeImpl
<
T
,
U
,
X
>
(
sp_std
::
marker
::
PhantomData
<
T
>
,
sp_std
::
marker
::
PhantomData
<
U
>
,
sp_std
::
marker
::
PhantomData
<
X
>
,
);
impl
<
T
>
WeightToFee
for
LengthToFeeImpl
<
T
>
impl
<
T
,
U
,
X
>
WeightToFee
for
LengthToFeeImpl
<
T
,
U
,
X
>
where
T
:
BaseArithmetic
+
From
<
u32
>
+
Copy
+
Unsigned
,
U
:
frame_system
::
Config
,
X
:
Get
<
Weight
>
,
{
type
Balance
=
T
;
#[cfg(not(feature
=
"constant-fees"
))]
fn
weight_to_fee
(
length_in_bytes
:
&
Weight
)
->
Self
::
Balance
{
let
current_block_weight
=
<
frame_system
::
Pallet
<
U
>>
::
block_weight
();
if
current_block_weight
.get
(
DispatchClass
::
Normal
)
.any_lt
(
X
::
get
())
{
0u32
.into
()
}
else
{
Self
::
Balance
::
saturated_from
(
length_in_bytes
.ref_time
()
/
100u64
)
}
}
#[cfg(feature
=
"constant-fees"
)]
fn
weight_to_fee
(
_length_in_bytes
:
&
Weight
)
->
Self
::
Balance
{
...
...
@@ -54,16 +69,34 @@ where
}
}
pub
struct
WeightToFeeImpl
<
T
>
(
sp_std
::
marker
::
PhantomData
<
T
>
);
pub
struct
WeightToFeeImpl
<
T
,
U
,
X
>
(
sp_std
::
marker
::
PhantomData
<
T
>
,
sp_std
::
marker
::
PhantomData
<
U
>
,
sp_std
::
marker
::
PhantomData
<
X
>
,
);
#[cfg(not(feature
=
"constant-fees"
))]
impl
<
T
>
WeightToFeePolynomial
for
WeightToFeeImpl
<
T
>
impl
<
T
,
U
,
X
>
WeightToFeePolynomial
for
WeightToFeeImpl
<
T
,
U
,
X
>
where
T
:
BaseArithmetic
+
From
<
u64
>
+
Copy
+
Unsigned
+
From
<
u32
>
+
MultiplyRational
,
U
:
frame_system
::
Config
,
X
:
Get
<
Weight
>
,
{
type
Balance
=
T
;
fn
polynomial
()
->
WeightToFeeCoefficients
<
Self
::
Balance
>
{
let
current_block_weight
=
<
frame_system
::
Pallet
<
U
>>
::
block_weight
();
if
current_block_weight
.get
(
DispatchClass
::
Normal
)
.any_lt
(
X
::
get
())
{
smallvec!
[
WeightToFeeCoefficient
{
degree
:
1
,
negative
:
false
,
coeff_frac
:
Perbill
::
zero
(),
coeff_integer
:
Self
::
Balance
::
zero
(),
}]
}
else
{
// The extrinsic base weight (smallest non-zero weight) is mapped to 5 cent
let
p
:
Self
::
Balance
=
5u64
.into
();
let
q
:
Self
::
Balance
=
Self
::
Balance
::
from
(
ExtrinsicBaseWeight
::
get
()
.ref_time
());
...
...
@@ -75,9 +108,10 @@ where
}]
}
}
}
#[cfg(feature
=
"constant-fees"
)]
impl
<
T
>
WeightToFee
for
WeightToFeeImpl
<
T
>
impl
<
T
,
U
,
X
>
WeightToFee
for
WeightToFeeImpl
<
T
,
U
,
X
>
where
T
:
BaseArithmetic
+
From
<
u32
>
+
Copy
+
Unsigned
,
{
...
...
This diff is collapsed.
Click to expand it.
runtime/common/src/pallets_config.rs
+
5
−
4
View file @
9565800e
...
...
@@ -191,16 +191,17 @@ macro_rules! pallets_config {
parameter_types!
{
pub
FeeMultiplier
:
Multiplier
=
Multiplier
::
one
();
pub
TargetWeight
:
Weight
=
Perbill
::
from_percent
(
10
)
*
BlockWeights
::
get
()
.max_block
;
}
impl
pallet_transaction_payment
::
Config
for
Runtime
{
type
FeeMultiplierUpdate
=
pallet_transaction_payment
::
ConstFeeMultiplier
<
FeeMultiplier
>
;
type
LengthToFee
=
common_runtime
::
fees
::
LengthToFeeImpl
<
Balance
>
;
type
LengthToFee
=
common_runtime
::
fees
::
LengthToFeeImpl
<
Balance
,
Self
,
TargetWeight
>
;
// does a filter on the call
type
OnChargeTransaction
=
OneshotAccount
;
type
OperationalFeeMultiplier
=
frame_support
::
traits
::
ConstU8
<
5
>
;
type
RuntimeEvent
=
RuntimeEvent
;
type
WeightToFee
=
common_runtime
::
fees
::
WeightToFeeImpl
<
Balance
>
;
type
WeightToFee
=
common_runtime
::
fees
::
WeightToFeeImpl
<
Balance
,
Self
,
TargetWeight
>
;
}
impl
pallet_oneshot_account
::
Config
for
Runtime
{
type
Currency
=
Balances
;
...
...
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