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
92d5e8f6
Unverified
Commit
92d5e8f6
authored
2 years ago
by
bgallois
Browse files
Options
Downloads
Patches
Plain Diff
feat(pallet_duniter_account): add weights info
parent
483a1570
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!140
Duniter-account pallet benchmark
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pallets/duniter-account/src/lib.rs
+16
-5
16 additions, 5 deletions
pallets/duniter-account/src/lib.rs
pallets/duniter-account/src/weights.rs
+91
-0
91 additions, 0 deletions
pallets/duniter-account/src/weights.rs
with
107 additions
and
5 deletions
pallets/duniter-account/src/lib.rs
+
16
−
5
View file @
92d5e8f6
...
@@ -20,9 +20,11 @@
...
@@ -20,9 +20,11 @@
mod
benchmarking
;
mod
benchmarking
;
mod
types
;
mod
types
;
pub
mod
weights
;
pub
use
pallet
::
*
;
pub
use
pallet
::
*
;
pub
use
types
::
*
;
pub
use
types
::
*
;
pub
use
weights
::
WeightInfo
;
use
frame_support
::
pallet_prelude
::
*
;
use
frame_support
::
pallet_prelude
::
*
;
use
frame_support
::
traits
::{
OnUnbalanced
,
StoredMap
};
use
frame_support
::
traits
::{
OnUnbalanced
,
StoredMap
};
...
@@ -61,6 +63,8 @@ pub mod pallet {
...
@@ -61,6 +63,8 @@ pub mod pallet {
type
NewAccountPrice
:
Get
<
Self
::
Balance
>
;
type
NewAccountPrice
:
Get
<
Self
::
Balance
>
;
/// The overarching event type.
/// The overarching event type.
type
RuntimeEvent
:
From
<
Event
<
Self
>>
+
IsType
<<
Self
as
frame_system
::
Config
>
::
RuntimeEvent
>
;
type
RuntimeEvent
:
From
<
Event
<
Self
>>
+
IsType
<<
Self
as
frame_system
::
Config
>
::
RuntimeEvent
>
;
/// Type representing the weight of this pallet
type
WeightInfo
:
WeightInfo
;
}
}
// STORAGE //
// STORAGE //
...
@@ -162,7 +166,9 @@ pub mod pallet {
...
@@ -162,7 +166,9 @@ pub mod pallet {
H256
(
T
::
AccountIdToSalt
::
convert
(
account_id
.clone
())),
H256
(
T
::
AccountIdToSalt
::
convert
(
account_id
.clone
())),
);
);
PendingRandomIdAssignments
::
<
T
>
::
insert
(
request_id
,
account_id
);
PendingRandomIdAssignments
::
<
T
>
::
insert
(
request_id
,
account_id
);
total_weight
+=
Weight
::
from_ref_time
(
100_000
);
total_weight
+=
<
T
as
pallet
::
Config
>
::
WeightInfo
::
on_initialize_sufficient
(
T
::
MaxNewAccountsPerBlock
::
get
(),
);
}
else
{
}
else
{
// If the account is not self-sufficient, it must pay the account creation fees
// If the account is not self-sufficient, it must pay the account creation fees
let
account_data
=
frame_system
::
Pallet
::
<
T
>
::
get
(
&
account_id
);
let
account_data
=
frame_system
::
Pallet
::
<
T
>
::
get
(
&
account_id
);
...
@@ -198,7 +204,10 @@ pub mod pallet {
...
@@ -198,7 +204,10 @@ pub mod pallet {
H256
(
T
::
AccountIdToSalt
::
convert
(
account_id
.clone
())),
H256
(
T
::
AccountIdToSalt
::
convert
(
account_id
.clone
())),
);
);
PendingRandomIdAssignments
::
<
T
>
::
insert
(
request_id
,
account_id
);
PendingRandomIdAssignments
::
<
T
>
::
insert
(
request_id
,
account_id
);
total_weight
+=
Weight
::
from_ref_time
(
200_000
);
total_weight
+=
<
T
as
pallet
::
Config
>
::
WeightInfo
::
on_initialize_with_balance
(
T
::
MaxNewAccountsPerBlock
::
get
(),
);
}
}
}
else
{
}
else
{
// The charges could not be deducted, we must destroy the account
// The charges could not be deducted, we must destroy the account
...
@@ -213,7 +222,9 @@ pub mod pallet {
...
@@ -213,7 +222,9 @@ pub mod pallet {
T
::
OnUnbalanced
::
on_unbalanced
(
pallet_balances
::
NegativeImbalance
::
new
(
T
::
OnUnbalanced
::
on_unbalanced
(
pallet_balances
::
NegativeImbalance
::
new
(
balance_to_suppr
,
balance_to_suppr
,
));
));
total_weight
+=
Weight
::
from_ref_time
(
300_000
);
total_weight
+=
<
T
as
pallet
::
Config
>
::
WeightInfo
::
on_initialize_no_balance
(
T
::
MaxNewAccountsPerBlock
::
get
(),
);
}
}
}
}
}
}
...
@@ -236,9 +247,9 @@ where
...
@@ -236,9 +247,9 @@ where
who
:
account_id
,
who
:
account_id
,
random_id
:
randomness
,
random_id
:
randomness
,
});
});
Weight
::
from_ref_time
(
200_000
)
<
T
as
pallet
::
Config
>
::
WeightInfo
::
on_filled_randomness_pending
(
)
}
else
{
}
else
{
Weight
::
from_ref_time
(
100_000
)
<
T
as
pallet
::
Config
>
::
WeightInfo
::
on_filled_randomness_no_pending
(
)
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
pallets/duniter-account/src/weights.rs
0 → 100644
+
91
−
0
View file @
92d5e8f6
// Copyright 2021-2023 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Duniter-v2S is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
#![allow(clippy::unnecessary_cast)]
use
frame_support
::
weights
::{
constants
::
RocksDbWeight
,
Weight
};
/// Weight functions needed for pallet_universal_dividend.
pub
trait
WeightInfo
{
fn
on_initialize_sufficient
(
i
:
u32
)
->
Weight
;
fn
on_initialize_with_balance
(
i
:
u32
)
->
Weight
;
fn
on_initialize_no_balance
(
i
:
u32
)
->
Weight
;
fn
on_filled_randomness_pending
()
->
Weight
;
fn
on_filled_randomness_no_pending
()
->
Weight
;
}
// Insecure weights implementation, use it for tests only!
impl
WeightInfo
for
()
{
// Storage: Account PendingNewAccounts (r:1 w:0)
// Storage: ProvideRandomness RequestIdProvider (r:1 w:1)
// Storage: ProvideRandomness RequestsIds (r:1 w:1)
// Storage: ProvideRandomness CounterForRequestsIds (r:1 w:1)
// Storage: Babe EpochIndex (r:1 w:0)
// Storage: ProvideRandomness NexEpochHookIn (r:1 w:0)
// Storage: ProvideRandomness RequestsReadyAtEpoch (r:1 w:1)
// Storage: Account PendingRandomIdAssignments (r:0 w:1)
/// The range of component `i` is `[0, 1]`.
fn
on_initialize_sufficient
(
i
:
u32
)
->
Weight
{
// Minimum execution time: 12_958 nanoseconds.
Weight
::
from_ref_time
(
14_907_902
as
u64
)
// Standard Error: 550_025
.saturating_add
(
Weight
::
from_ref_time
(
79_482_297
as
u64
)
.saturating_mul
(
i
as
u64
))
.saturating_add
(
RocksDbWeight
::
get
()
.reads
(
1
as
u64
))
.saturating_add
(
RocksDbWeight
::
get
()
.reads
((
6
as
u64
)
.saturating_mul
(
i
as
u64
)))
.saturating_add
(
RocksDbWeight
::
get
()
.writes
((
6
as
u64
)
.saturating_mul
(
i
as
u64
)))
}
// Storage: Account PendingNewAccounts (r:1 w:0)
// Storage: ProvideRandomness RequestIdProvider (r:1 w:1)
// Storage: ProvideRandomness RequestsIds (r:1 w:1)
// Storage: ProvideRandomness CounterForRequestsIds (r:1 w:1)
// Storage: Babe EpochIndex (r:1 w:0)
// Storage: ProvideRandomness NexEpochHookIn (r:1 w:0)
// Storage: ProvideRandomness RequestsReadyAtEpoch (r:1 w:1)
// Storage: Account PendingRandomIdAssignments (r:0 w:1)
/// The range of component `i` is `[0, 1]`.
fn
on_initialize_with_balance
(
i
:
u32
)
->
Weight
{
// Minimum execution time: 12_965 nanoseconds.
Weight
::
from_ref_time
(
16_754_718
as
u64
)
// Standard Error: 1_790_537
.saturating_add
(
Weight
::
from_ref_time
(
164_043_481
as
u64
)
.saturating_mul
(
i
as
u64
))
.saturating_add
(
RocksDbWeight
::
get
()
.reads
(
1
as
u64
))
.saturating_add
(
RocksDbWeight
::
get
()
.reads
((
6
as
u64
)
.saturating_mul
(
i
as
u64
)))
.saturating_add
(
RocksDbWeight
::
get
()
.writes
((
6
as
u64
)
.saturating_mul
(
i
as
u64
)))
}
// Storage: Account PendingNewAccounts (r:1 w:0)
/// The range of component `i` is `[0, 1]`.
fn
on_initialize_no_balance
(
i
:
u32
)
->
Weight
{
// Minimum execution time: 12_912 nanoseconds.
Weight
::
from_ref_time
(
13_846_469
as
u64
)
// Standard Error: 115_598
.saturating_add
(
Weight
::
from_ref_time
(
67_524_530
as
u64
)
.saturating_mul
(
i
as
u64
))
.saturating_add
(
RocksDbWeight
::
get
()
.reads
(
1
as
u64
))
.saturating_add
(
RocksDbWeight
::
get
()
.writes
((
1
as
u64
)
.saturating_mul
(
i
as
u64
)))
}
// Storage: Account PendingRandomIdAssignments (r:1 w:1)
fn
on_filled_randomness_pending
()
->
Weight
{
// Minimum execution time: 66_963 nanoseconds.
Weight
::
from_ref_time
(
69_757_000
as
u64
)
.saturating_add
(
RocksDbWeight
::
get
()
.reads
(
1
as
u64
))
.saturating_add
(
RocksDbWeight
::
get
()
.writes
(
1
as
u64
))
}
// Storage: Account PendingRandomIdAssignments (r:1 w:0)
fn
on_filled_randomness_no_pending
()
->
Weight
{
// Minimum execution time: 16_088 nanoseconds.
Weight
::
from_ref_time
(
27_963_000
as
u64
)
.saturating_add
(
RocksDbWeight
::
get
()
.reads
(
1
as
u64
))
}
}
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