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
f453e52d
Commit
f453e52d
authored
2 years ago
by
bgallois
Committed by
Pascal Engélibert
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(pallet_oneshot_account): add weights info
parent
ea5582f9
No related branches found
No related tags found
1 merge request
!153
Oneshot account pallet benchmark
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pallets/oneshot-account/src/lib.rs
+7
-3
7 additions, 3 deletions
pallets/oneshot-account/src/lib.rs
pallets/oneshot-account/src/mock.rs
+1
-0
1 addition, 0 deletions
pallets/oneshot-account/src/mock.rs
with
8 additions
and
3 deletions
pallets/oneshot-account/src/lib.rs
+
7
−
3
View file @
f453e52d
...
@@ -21,10 +21,12 @@ mod check_nonce;
...
@@ -21,10 +21,12 @@ mod check_nonce;
#[cfg(test)]
#[cfg(test)]
mod
mock
;
mod
mock
;
mod
types
;
mod
types
;
pub
mod
weights
;
pub
use
check_nonce
::
CheckNonce
;
pub
use
check_nonce
::
CheckNonce
;
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
::{
use
frame_support
::
traits
::{
...
@@ -56,6 +58,8 @@ pub mod pallet {
...
@@ -56,6 +58,8 @@ pub mod pallet {
type
Currency
:
Currency
<
Self
::
AccountId
>
;
type
Currency
:
Currency
<
Self
::
AccountId
>
;
type
InnerOnChargeTransaction
:
OnChargeTransaction
<
Self
>
;
type
InnerOnChargeTransaction
:
OnChargeTransaction
<
Self
>
;
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 //
...
@@ -127,7 +131,7 @@ pub mod pallet {
...
@@ -127,7 +131,7 @@ pub mod pallet {
/// - `balance`: The balance to be transfered to this oneshot account.
/// - `balance`: The balance to be transfered to this oneshot account.
///
///
/// Origin account is kept alive.
/// Origin account is kept alive.
#[pallet::weight(
500_000_000
)]
#[pallet::weight(
T::WeightInfo::create_oneshot_account()
)]
pub
fn
create_oneshot_account
(
pub
fn
create_oneshot_account
(
origin
:
OriginFor
<
T
>
,
origin
:
OriginFor
<
T
>
,
dest
:
<
T
::
Lookup
as
StaticLookup
>
::
Source
,
dest
:
<
T
::
Lookup
as
StaticLookup
>
::
Source
,
...
@@ -165,7 +169,7 @@ pub mod pallet {
...
@@ -165,7 +169,7 @@ pub mod pallet {
/// - `block_height`: Must be a recent block number. The limit is `BlockHashCount` in the past. (this is to prevent replay attacks)
/// - `block_height`: Must be a recent block number. The limit is `BlockHashCount` in the past. (this is to prevent replay attacks)
/// - `dest`: The destination account.
/// - `dest`: The destination account.
/// - `dest_is_oneshot`: If set to `true`, then a oneshot account is created at `dest`. Else, `dest` has to be an existing account.
/// - `dest_is_oneshot`: If set to `true`, then a oneshot account is created at `dest`. Else, `dest` has to be an existing account.
#[pallet::weight(
500_000_000
)]
#[pallet::weight(
T::WeightInfo::consume_oneshot_account()
)]
pub
fn
consume_oneshot_account
(
pub
fn
consume_oneshot_account
(
origin
:
OriginFor
<
T
>
,
origin
:
OriginFor
<
T
>
,
block_height
:
T
::
BlockNumber
,
block_height
:
T
::
BlockNumber
,
...
@@ -223,7 +227,7 @@ pub mod pallet {
...
@@ -223,7 +227,7 @@ pub mod pallet {
/// - `dest2`: The second destination account.
/// - `dest2`: The second destination account.
/// - `dest2_is_oneshot`: If set to `true`, then a oneshot account is created at `dest2`. Else, `dest2` has to be an existing account.
/// - `dest2_is_oneshot`: If set to `true`, then a oneshot account is created at `dest2`. Else, `dest2` has to be an existing account.
/// - `balance1`: The amount transfered to `dest`, the leftover being transfered to `dest2`.
/// - `balance1`: The amount transfered to `dest`, the leftover being transfered to `dest2`.
#[pallet::weight(
500_000_000
)]
#[pallet::weight(
T::WeightInfo::consume_oneshot_account_with_remaining()
)]
pub
fn
consume_oneshot_account_with_remaining
(
pub
fn
consume_oneshot_account_with_remaining
(
origin
:
OriginFor
<
T
>
,
origin
:
OriginFor
<
T
>
,
block_height
:
T
::
BlockNumber
,
block_height
:
T
::
BlockNumber
,
...
...
This diff is collapsed.
Click to expand it.
pallets/oneshot-account/src/mock.rs
+
1
−
0
View file @
f453e52d
...
@@ -104,6 +104,7 @@ impl pallet_oneshot_account::Config for Test {
...
@@ -104,6 +104,7 @@ impl pallet_oneshot_account::Config for Test {
type
Currency
=
Balances
;
type
Currency
=
Balances
;
type
InnerOnChargeTransaction
=
CurrencyAdapter
<
Balances
,
HandleFees
>
;
type
InnerOnChargeTransaction
=
CurrencyAdapter
<
Balances
,
HandleFees
>
;
type
RuntimeEvent
=
RuntimeEvent
;
type
RuntimeEvent
=
RuntimeEvent
;
type
WeightInfo
=
();
}
}
pub
struct
HandleFees
;
pub
struct
HandleFees
;
...
...
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