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
a89130eb
Unverified
Commit
a89130eb
authored
10 months ago
by
bgallois
Browse files
Options
Downloads
Patches
Plain Diff
add extrinsic length limit
parent
8779d52b
No related branches found
No related tags found
No related merge requests found
Pipeline
#38005
failed
10 months ago
Stage: labels
Stage: quality
Stage: build
Stage: tests
Stage: deploy
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
runtime/common/src/fees.rs
+6
-3
6 additions, 3 deletions
runtime/common/src/fees.rs
with
6 additions
and
3 deletions
runtime/common/src/fees.rs
+
6
−
3
View file @
a89130eb
...
@@ -61,8 +61,8 @@ where
...
@@ -61,8 +61,8 @@ where
/// Function to convert weight to fee when "constant-fees" feature is not enabled.
/// Function to convert weight to fee when "constant-fees" feature is not enabled.
///
///
/// This function calculates the fee based on the length of the transaction in bytes.
/// This function calculates the fee based on the length of the transaction in bytes.
/// If the current block weight and length are less than a fraction of the max block weight and length
and
the fee multiplier is one,
/// If the current block weight and length are less than a fraction of the max block weight and length
,
the fee multiplier is one,
///
it returns a zero fee
. Otherwise, it calculates the fee based on the length in bytes.
///
and the extrinsic length is less than 256 bytes, no fees are applied
. Otherwise, it calculates the fee based on the length in bytes.
#[cfg(not(feature
=
"constant-fees"
))]
#[cfg(not(feature
=
"constant-fees"
))]
fn
weight_to_fee
(
length_in_bytes
:
&
Weight
)
->
Self
::
Balance
{
fn
weight_to_fee
(
length_in_bytes
:
&
Weight
)
->
Self
::
Balance
{
let
weights
=
Runtime
::
BlockWeights
::
get
();
let
weights
=
Runtime
::
BlockWeights
::
get
();
...
@@ -76,16 +76,19 @@ where
...
@@ -76,16 +76,19 @@ where
let
length
=
Runtime
::
BlockLength
::
get
();
let
length
=
Runtime
::
BlockLength
::
get
();
let
normal_max_length
=
*
length
.max
.get
(
DispatchClass
::
Normal
)
as
u64
;
let
normal_max_length
=
*
length
.max
.get
(
DispatchClass
::
Normal
)
as
u64
;
let
current_block_length
=
<
frame_system
::
Pallet
<
Runtime
>>
::
all_extrinsics_len
()
as
u64
;
let
current_block_length
=
<
frame_system
::
Pallet
<
Runtime
>>
::
all_extrinsics_len
()
as
u64
;
// One remark extrinsic overhead is approximately 110 bytes
let
max_extrinsic_length
=
256
;
if
current_block_weight
if
current_block_weight
.get
(
DispatchClass
::
Normal
)
.get
(
DispatchClass
::
Normal
)
.all_lt
(
Target
::
get
()
*
normal_max_weight
)
.all_lt
(
Target
::
get
()
*
normal_max_weight
)
&&
current_block_length
<
(
Target
::
get
()
*
normal_max_length
)
&&
current_block_length
<
(
Target
::
get
()
*
normal_max_length
)
&&
fee_multiplier
.is_one
()
&&
fee_multiplier
.is_one
()
&&
length_in_bytes
.ref_time
()
<
max_extrinsic_length
{
{
0u32
.into
()
0u32
.into
()
}
else
{
}
else
{
Self
::
Balance
::
saturated_from
(
length_in_bytes
.ref_time
()
/
10
0
u64
)
Self
::
Balance
::
saturated_from
(
length_in_bytes
.ref_time
()
/
10u64
)
}
}
}
}
...
...
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