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
7b2a06f8
Commit
7b2a06f8
authored
1 year ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
add benchmark
parent
f1f91e4a
No related branches found
No related tags found
1 merge request
!215
refac membership
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pallets/identity/src/benchmarking.rs
+34
-0
34 additions, 0 deletions
pallets/identity/src/benchmarking.rs
with
34 additions
and
0 deletions
pallets/identity/src/benchmarking.rs
+
34
−
0
View file @
7b2a06f8
...
...
@@ -123,6 +123,8 @@ benchmarks! {
T
::
AccountId
:
From
<
AccountId32
>
,
T
::
IdtyIndex
:
From
<
u32
>
,
}
// create identity
create_identity
{
let
caller
:
T
::
AccountId
=
Identities
::
<
T
>
::
get
(
T
::
IdtyIndex
::
one
())
.unwrap
()
.owner_key
;
// Alice
let
caller_origin
:
<
T
as
frame_system
::
Config
>
::
RuntimeOrigin
=
RawOrigin
::
Signed
(
caller
.clone
())
.into
();
...
...
@@ -134,6 +136,7 @@ benchmarks! {
assert_has_event
::
<
T
>
(
Event
::
<
T
>
::
IdtyCreated
{
idty_index
:
idty_index
.unwrap
(),
owner_key
:
owner_key
}
.into
());
}
// confirm identity
confirm_identity
{
let
caller
:
T
::
AccountId
=
Identities
::
<
T
>
::
get
(
T
::
IdtyIndex
::
one
())
.unwrap
()
.owner_key
;
let
caller_origin
:
<
T
as
frame_system
::
Config
>
::
RuntimeOrigin
=
RawOrigin
::
Signed
(
caller
.clone
())
.into
();
...
...
@@ -146,6 +149,7 @@ benchmarks! {
assert_has_event
::
<
T
>
(
Event
::
<
T
>
::
IdtyConfirmed
{
idty_index
:
idty_index
.unwrap
(),
owner_key
:
owner_key
,
name
:
IdtyName
(
"new_identity"
.into
())
}
.into
());
}
// change owner key
change_owner_key
{
let
old_key
:
T
::
AccountId
=
account
(
"new_identity"
,
2
,
SEED
);
let
account
:
Account
<
T
>
=
create_one_identity
(
old_key
.clone
())
?
;
...
...
@@ -183,6 +187,7 @@ benchmarks! {
assert!
(
IdentityIndexOf
::
<
T
>
::
get
(
&
caller
)
.unwrap
()
==
account
.index
,
"Owner key not changed"
);
}
// revoke identity
revoke_identity
{
let
old_key
:
T
::
AccountId
=
account
(
"new_identity"
,
2
,
SEED
);
let
account
:
Account
<
T
>
=
create_one_identity
(
old_key
.clone
())
?
;
...
...
@@ -234,6 +239,7 @@ benchmarks! {
}
}
// fix sufficients identity
fix_sufficients
{
let
new_identity
:
T
::
AccountId
=
account
(
"Bob"
,
2
,
SEED
);
let
account
:
Account
<
T
>
=
create_one_identity
(
new_identity
)
?
;
...
...
@@ -243,6 +249,7 @@ benchmarks! {
assert!
(
sufficient
<
frame_system
::
Pallet
::
<
T
>
::
sufficients
(
&
account
.key
),
"Sufficient not incremented"
);
}
// link account
link_account
{
let
alice_origin
=
RawOrigin
::
Signed
(
Identities
::
<
T
>
::
get
(
T
::
IdtyIndex
::
one
())
.unwrap
()
.owner_key
);
let
bob_public
=
sr25519_generate
(
0
.into
(),
None
);
...
...
@@ -253,9 +260,32 @@ benchmarks! {
)
.encode
();
let
signature
=
sr25519_sign
(
0
.into
(),
&
bob_public
,
&
payload
)
.unwrap
()
.into
();
}:
_
<
T
::
RuntimeOrigin
>
(
alice_origin
.into
(),
bob
,
signature
)
// Base weight of an empty initialize
on_initialize
{
}:
{
Pallet
::
<
T
>
::
on_initialize
(
BlockNumberFor
::
<
T
>
::
zero
());}
// --- do revoke identity
do_revoke_identity_noop
{
let
idty_index
:
T
::
IdtyIndex
=
0u32
.into
();
assert!
(
Identities
::
<
T
>
::
get
(
idty_index
)
.is_none
());
}:
{
Pallet
::
<
T
>
::
do_revoke_identity
(
idty_index
,
RevocationReason
::
Root
);}
do_revoke_identity
{
let
idty_index
:
T
::
IdtyIndex
=
1u32
.into
();
let
new_identity
:
T
::
AccountId
=
account
(
"Bob"
,
2
,
SEED
);
assert!
(
Identities
::
<
T
>
::
get
(
idty_index
)
.is_some
());
Identities
::
<
T
>
::
mutate
(
idty_index
,
|
id
|
{
if
let
Some
(
id
)
=
id
{
id
.old_owner_key
=
Some
((
new_identity
,
BlockNumberFor
::
<
T
>
::
zero
()));
}
});
assert!
(
Identities
::
<
T
>
::
get
(
idty_index
)
.unwrap
()
.old_owner_key
.is_some
());
}:
{
Pallet
::
<
T
>
::
do_revoke_identity
(
idty_index
,
RevocationReason
::
Root
);}
verify
{
assert_has_event
::
<
T
>
(
Event
::
<
T
>
::
IdtyRevoked
{
idty_index
,
reason
:
RevocationReason
::
Root
}
.into
());
}
// --- do remove identity
do_remove_identity_noop
{
let
idty_index
:
T
::
IdtyIndex
=
0u32
.into
();
assert!
(
Identities
::
<
T
>
::
get
(
idty_index
)
.is_none
());
...
...
@@ -274,15 +304,19 @@ benchmarks! {
verify
{
assert_has_event
::
<
T
>
(
Event
::
<
T
>
::
IdtyRemoved
{
idty_index
,
reason
:
RemovalReason
::
Revoked
}
.into
());
}
// --- prune identities
prune_identities_noop
{
assert!
(
IdentityChangeSchedule
::
<
T
>
::
try_get
(
T
::
BlockNumber
::
zero
())
.is_err
());
}:
{
Pallet
::
<
T
>
::
prune_identities
(
T
::
BlockNumber
::
zero
());}
prune_identities_none
{
let
idty_index
:
T
::
IdtyIndex
=
100u32
.into
();
IdentityChangeSchedule
::
<
T
>
::
append
(
T
::
BlockNumber
::
zero
(),
idty_index
);
assert!
(
IdentityChangeSchedule
::
<
T
>
::
try_get
(
T
::
BlockNumber
::
zero
())
.is_ok
());
assert!
(
<
Identities
<
T
>>
::
try_get
(
idty_index
)
.is_err
());
}:
{
Pallet
::
<
T
>
::
prune_identities
(
T
::
BlockNumber
::
zero
());}
prune_identities_err
{
let
idty_index
:
T
::
IdtyIndex
=
100u32
.into
();
create_dummy_identity
::
<
T
>
(
100u32
)
?
;
...
...
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