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
effd4a97
Unverified
Commit
effd4a97
authored
5 months ago
by
bgallois
Browse files
Options
Downloads
Patches
Plain Diff
optimize TreasuryAccount
parent
e88b9a4b
No related branches found
No related tags found
1 merge request
!286
Refactore Runtime handlers and providers
Pipeline
#38574
passed
5 months ago
Stage: labels
Stage: quality
Stage: build
Stage: tests
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
runtime/common/src/handlers.rs
+12
-10
12 additions, 10 deletions
runtime/common/src/handlers.rs
runtime/common/src/pallets_config.rs
+10
-19
10 additions, 19 deletions
runtime/common/src/pallets_config.rs
with
22 additions
and
29 deletions
runtime/common/src/handlers.rs
+
12
−
10
View file @
effd4a97
...
...
@@ -182,22 +182,24 @@ impl<
}
}
type
CreditOf
<
Runtime
,
Balances
>
=
frame_support
::
traits
::
tokens
::
fungible
::
Credit
<
Runtime
,
Balances
>
;
pub
struct
HandleFees
<
Runtime
,
Balances
>
(
frame_support
::
pallet_prelude
::
PhantomData
<
Runtime
>
,
type
CreditOf
<
T
,
Balances
>
=
frame_support
::
traits
::
tokens
::
fungible
::
Credit
<
T
,
Balances
>
;
pub
struct
HandleFees
<
T
,
TreasuryAccount
,
Balances
>
(
frame_support
::
pallet_prelude
::
PhantomData
<
T
>
,
frame_support
::
pallet_prelude
::
PhantomData
<
TreasuryAccount
>
,
frame_support
::
pallet_prelude
::
PhantomData
<
Balances
>
,
);
impl
<
Runtime
,
Balances
>
frame_support
::
traits
::
OnUnbalanced
<
CreditOf
<
Runtime
::
AccountId
,
Balances
>>
for
HandleFees
<
Runtime
,
Balances
>
impl
<
T
,
TreasuryAccount
,
Balances
>
frame_support
::
traits
::
OnUnbalanced
<
CreditOf
<
T
::
AccountId
,
Balances
>>
for
HandleFees
<
T
,
TreasuryAccount
,
Balances
>
where
Runtime
:
pallet_treasury
::
Config
,
Balances
:
frame_support
::
traits
::
fungible
::
Balanced
<
Runtime
::
AccountId
>
,
T
:
frame_system
::
Config
,
TreasuryAccount
:
Get
<
T
::
AccountId
>
,
Balances
:
frame_support
::
traits
::
fungible
::
Balanced
<
T
::
AccountId
>
,
{
fn
on_nonzero_unbalanced
(
amount
:
CreditOf
<
Runtime
::
AccountId
,
Balances
>
)
{
fn
on_nonzero_unbalanced
(
amount
:
CreditOf
<
T
::
AccountId
,
Balances
>
)
{
// fee is moved to treasury
let
_
=
Balances
::
deposit
(
&
pallet_treasury
::
Pallet
::
<
Runtime
>
::
a
ccount
_id
(),
&
TreasuryA
ccount
::
get
(),
amount
.peek
(),
frame_support
::
traits
::
tokens
::
Precision
::
Exact
,
);
...
...
This diff is collapsed.
Click to expand it.
runtime/common/src/pallets_config.rs
+
10
−
19
View file @
effd4a97
...
...
@@ -105,30 +105,21 @@ macro_rules! pallets_config {
impl
pallet_duniter_account
::
Config
for
Runtime
{
// does currency adapter in any case, but adds "refund with quota" feature
type
InnerOnChargeTransaction
=
FungibleAdapter
<
Balances
,
HandleFees
<
Runtime
,
Balances
>>
;
FungibleAdapter
<
Balances
,
HandleFees
<
Runtime
,
TreasuryAccount
,
Balances
>>
;
type
Refund
=
Quota
;
type
RuntimeEvent
=
RuntimeEvent
;
type
WeightInfo
=
weights
::
pallet_duniter_account
::
WeightInfo
<
Runtime
>
;
}
// QUOTA //
pub
struct
TreasuryAccountId
;
impl
frame_support
::
pallet_prelude
::
Get
<
AccountId
>
for
TreasuryAccountId
{
fn
get
()
->
AccountId
{
// TODO optimize: make this a constant
// calling Treasury.account_id() actually requires computation
Treasury
::
account_id
()
}
}
parameter_types!
{
pub
const
ReloadRate
:
BlockNumber
=
1
*
HOURS
;
// faster than DAYS
pub
const
MaxQuota
:
Balance
=
1000
;
// 10 ĞD
pub
const
MaxNominators
:
u32
=
64
;
pub
TreasuryAccount
:
AccountId
=
Treasury
::
account_id
();
// TODO
}
pub
const
ReloadRate
:
BlockNumber
=
1
*
HOURS
;
// faster than DAYS
pub
const
MaxQuota
:
Balance
=
1000
;
// 10 ĞD
pub
const
MaxNominators
:
u32
=
64
;
pub
TreasuryAccount
:
AccountId
=
Treasury
::
account_id
();
}
impl
pallet_quota
::
Config
for
Runtime
{
type
MaxQuota
=
MaxQuota
;
type
RefundAccount
=
TreasuryAccount
Id
;
type
RefundAccount
=
TreasuryAccount
;
type
ReloadRate
=
ReloadRate
;
type
RuntimeEvent
=
RuntimeEvent
;
type
WeightInfo
=
weights
::
pallet_quota
::
WeightInfo
<
Runtime
>
;
...
...
@@ -163,7 +154,7 @@ macro_rules! pallets_config {
impl
pallet_balances
::
Config
for
Runtime
{
type
AccountStore
=
Account
;
type
Balance
=
Balance
;
type
DustRemoval
=
HandleFees
<
Runtime
,
Balances
>
;
type
DustRemoval
=
HandleFees
<
Runtime
,
TreasuryAccount
,
Balances
>
;
type
ExistentialDeposit
=
ExistentialDeposit
;
type
FreezeIdentifier
=
();
type
MaxFreezes
=
frame_support
::
pallet_prelude
::
ConstU32
<
0
>
;
...
...
@@ -323,7 +314,7 @@ macro_rules! pallets_config {
type
GetCurrentEpochIndex
=
GetCurrentEpochIndex
<
Self
>
;
type
MaxRequests
=
frame_support
::
traits
::
ConstU32
<
100
>
;
type
OnFilledRandomness
=
();
type
OnUnbalanced
=
HandleFees
<
Runtime
,
Balances
>
;
type
OnUnbalanced
=
HandleFees
<
Runtime
,
TreasuryAccount
,
Balances
>
;
type
ParentBlockRandomness
=
pallet_babe
::
ParentBlockRandomness
<
Self
>
;
type
RandomnessFromOneEpochAgo
=
pallet_babe
::
RandomnessFromOneEpochAgo
<
Self
>
;
type
RequestPrice
=
frame_support
::
traits
::
ConstU64
<
2_000
>
;
...
...
@@ -498,7 +489,7 @@ macro_rules! pallets_config {
type
EvaluationPrice
=
frame_support
::
traits
::
ConstU64
<
1000
>
;
type
MaxRefereeDistance
=
MaxRefereeDistance
;
type
MinAccessibleReferees
=
MinAccessibleReferees
;
type
OnUnbalanced
=
HandleFees
<
Runtime
,
Balances
>
;
type
OnUnbalanced
=
HandleFees
<
Runtime
,
TreasuryAccount
,
Balances
>
;
type
OnValidDistanceStatus
=
Wot
;
type
RuntimeEvent
=
RuntimeEvent
;
type
RuntimeHoldReason
=
RuntimeHoldReason
;
...
...
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