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
2f875f47
Unverified
Commit
2f875f47
authored
2 months ago
by
bgallois
Browse files
Options
Downloads
Patches
Plain Diff
allocate quota for membership instead of identity fix...
allocate quota for membership instead of identity fix
#247
parent
e512f2c3
No related branches found
No related tags found
No related merge requests found
Pipeline
#39823
failed
2 months ago
Stage: labels
Stage: quality
Stage: build
Stage: tests
Stage: deploy
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Cargo.lock
+1
-0
1 addition, 0 deletions
Cargo.lock
pallets/quota/Cargo.toml
+4
-1
4 additions, 1 deletion
pallets/quota/Cargo.toml
pallets/quota/src/lib.rs
+14
-14
14 additions, 14 deletions
pallets/quota/src/lib.rs
runtime/common/src/handlers.rs
+14
-14
14 additions, 14 deletions
runtime/common/src/handlers.rs
with
33 additions
and
29 deletions
Cargo.lock
+
1
−
0
View file @
2f875f47
...
...
@@ -9550,6 +9550,7 @@ dependencies = [
"scale-info",
"sp-core",
"sp-io",
"sp-membership",
"sp-runtime",
]
...
...
This diff is collapsed.
Click to expand it.
pallets/quota/Cargo.toml
+
4
−
1
View file @
2f875f47
...
...
@@ -16,6 +16,7 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks"
,
"pallet-balances/runtime-benchmarks"
,
"pallet-identity/runtime-benchmarks"
,
"sp-membership/runtime-benchmarks"
,
"sp-runtime/runtime-benchmarks"
,
]
try-runtime
=
[
...
...
@@ -23,8 +24,8 @@ try-runtime = [
"frame-system/try-runtime"
,
"pallet-balances/runtime-benchmarks"
,
"pallet-balances/try-runtime"
,
"pallet-identity/runtime-benchmarks"
,
"pallet-identity/try-runtime"
,
"sp-membership/try-runtime"
,
"sp-runtime/try-runtime"
,
]
std
=
[
...
...
@@ -34,6 +35,7 @@ std = [
"frame-system/std"
,
"pallet-balances/std"
,
"pallet-identity/std"
,
"sp-membership/std"
,
"scale-info/std"
,
"sp-core/std"
,
"sp-io/std"
,
...
...
@@ -50,6 +52,7 @@ frame-support = { workspace = true }
frame-system
=
{
workspace
=
true
}
pallet-balances
=
{
workspace
=
true
}
pallet-identity
=
{
workspace
=
true
}
sp-membership
=
{
workspace
=
true
}
scale-info
=
{
workspace
=
true
,
features
=
[
"derive"
]
}
sp-core
=
{
workspace
=
true
}
sp-runtime
=
{
workspace
=
true
}
...
...
This diff is collapsed.
Click to expand it.
pallets/quota/src/lib.rs
+
14
−
14
View file @
2f875f47
...
...
@@ -360,17 +360,20 @@ impl<T: Config> RefundFee<T> for Pallet<T> {
/// Checks if an identity is eligible for a refund.
///
/// This function returns `true` for all identities, regardless of their status.
/// If the identity has no quotas or has been deleted, the refund request is still queued,
/// but when handled, no refund will be issued (and `NoQuotaForIdty` may be raised).
fn
is_eligible_for_refund
<
T
:
pallet_identity
::
Config
>
(
_identity
:
IdtyId
<
T
>
)
->
bool
{
true
/// This function returns `true` only if the identity exists and has a status of `Member`.
/// If the identity does not exist or has a different status, it returns `false`, and the refund request will not be processed.
///
fn
is_eligible_for_refund
<
T
:
pallet_identity
::
Config
>
(
idty_index
:
IdtyId
<
T
>
)
->
bool
{
pallet_identity
::
Identities
::
<
T
>
::
get
(
idty_index
)
.map_or_else
(
||
false
,
|
id
|
id
.status
==
pallet_identity
::
IdtyStatus
::
Member
,
)
}
/// Implementing the on new
identity
event handler for the pallet.
impl
<
T
:
Config
>
pallet_identity
::
traits
::
OnNewIdty
<
T
>
for
Pallet
<
T
>
{
/// Implementing the on new
membership
event handler for the pallet.
impl
<
T
:
Config
>
sp_membership
::
traits
::
OnNew
Membership
<
Idty
Id
<
T
>
>
for
Pallet
<
T
>
{
/// This implementation initializes the identity quota for the newly created identity.
fn
on_created
(
idty_index
:
&
IdtyId
<
T
>
,
_creator
:
&
T
::
IdtyIndex
)
{
fn
on_created
(
idty_index
:
&
IdtyId
<
T
>
)
{
IdtyQuota
::
<
T
>
::
insert
(
idty_index
,
Quota
{
...
...
@@ -379,10 +382,12 @@ impl<T: Config> pallet_identity::traits::OnNewIdty<T> for Pallet<T> {
},
);
}
fn
on_renewed
(
_idty_index
:
&
IdtyId
<
T
>
)
{}
}
/// Implementing the on remove identity event handler for the pallet.
impl
<
T
:
Config
>
pallet_identity
::
traits
::
OnRemoveIdty
<
T
>
for
Pallet
<
T
>
{
impl
<
T
:
Config
>
sp_membership
::
traits
::
OnRemove
Membership
<
Idty
Id
<
T
>
>
for
Pallet
<
T
>
{
/// This implementation removes the identity quota associated with the removed identity.
fn
on_removed
(
idty_id
:
&
IdtyId
<
T
>
)
->
Weight
{
let
mut
weight
=
Weight
::
zero
();
...
...
@@ -394,9 +399,4 @@ impl<T: Config> pallet_identity::traits::OnRemoveIdty<T> for Pallet<T> {
add_db_reads_writes
(
1
,
1
);
weight
}
/// This implementation removes the identity quota associated with the removed identity.
fn
on_revoked
(
idty_id
:
&
IdtyId
<
T
>
)
->
Weight
{
Self
::
on_removed
(
idty_id
)
}
}
This diff is collapsed.
Click to expand it.
runtime/common/src/handlers.rs
+
14
−
14
View file @
2f875f47
...
...
@@ -38,33 +38,28 @@ where
/// Runtime handler for OnNewIdty, calling all implementations of
/// OnNewIdty and implementing logic at the runtime level.
pub
struct
OnNewIdtyHandler
<
Runtime
>
(
core
::
marker
::
PhantomData
<
Runtime
>
);
impl
<
Runtime
:
pallet_duniter_wot
::
Config
+
pallet_
quota
::
Config
>
pallet_identity
::
traits
::
OnNewIdty
<
Runtime
>
for
OnNewIdtyHandler
<
Runtime
>
impl
<
Runtime
:
pallet_duniter_wot
::
Config
>
pallet_
identity
::
traits
::
OnNewIdty
<
Runtime
>
for
OnNewIdtyHandler
<
Runtime
>
{
fn
on_created
(
idty_index
:
&
IdtyIndex
,
creator
:
&
IdtyIndex
)
{
pallet_duniter_wot
::
Pallet
::
<
Runtime
>
::
on_created
(
idty_index
,
creator
);
pallet_quota
::
Pallet
::
<
Runtime
>
::
on_created
(
idty_index
,
creator
);
}
}
/// Runtime handler for OnRemoveIdty, calling all implementations of
/// OnRemoveIdty and implementing logic at the runtime level.
pub
struct
OnRemoveIdtyHandler
<
Runtime
>
(
core
::
marker
::
PhantomData
<
Runtime
>
);
impl
<
Runtime
:
pallet_duniter_wot
::
Config
+
pallet_quota
::
Config
+
pallet_duniter_account
::
Config
,
>
pallet_identity
::
traits
::
OnRemoveIdty
<
Runtime
>
for
OnRemoveIdtyHandler
<
Runtime
>
impl
<
Runtime
:
pallet_duniter_wot
::
Config
+
pallet_duniter_account
::
Config
>
pallet_identity
::
traits
::
OnRemoveIdty
<
Runtime
>
for
OnRemoveIdtyHandler
<
Runtime
>
{
fn
on_removed
(
idty_index
:
&
IdtyIndex
)
->
Weight
{
pallet_duniter_wot
::
Pallet
::
<
Runtime
>
::
on_removed
(
idty_index
)
.saturating_add
(
pallet_quota
::
Pallet
::
<
Runtime
>
::
on_removed
(
idty_index
))
}
fn
on_revoked
(
idty_index
:
&
IdtyIndex
)
->
Weight
{
pallet_duniter_wot
::
Pallet
::
<
Runtime
>
::
on_revoked
(
idty_index
)
.saturating_add
(
pallet_duniter_account
::
Pallet
::
<
Runtime
>
::
on_revoked
(
idty_index
,
))
.saturating_add
(
pallet_quota
::
Pallet
::
<
Runtime
>
::
on_revoked
(
idty_index
))
pallet_duniter_wot
::
Pallet
::
<
Runtime
>
::
on_revoked
(
idty_index
)
.saturating_add
(
pallet_duniter_account
::
Pallet
::
<
Runtime
>
::
on_revoked
(
idty_index
),
)
}
}
...
...
@@ -75,13 +70,16 @@ impl<
Runtime
:
frame_system
::
Config
<
AccountId
=
AccountId
>
+
pallet_identity
::
Config
<
IdtyData
=
IdtyData
,
IdtyIndex
=
IdtyIndex
>
+
pallet_duniter_wot
::
Config
+
pallet_universal_dividend
::
Config
,
+
pallet_universal_dividend
::
Config
+
pallet_quota
::
Config
,
>
sp_membership
::
traits
::
OnNewMembership
<
IdtyIndex
>
for
OnNewMembershipHandler
<
Runtime
>
{
fn
on_created
(
idty_index
:
&
IdtyIndex
)
{
// duniter-wot related actions
pallet_duniter_wot
::
Pallet
::
<
Runtime
>
::
on_created
(
idty_index
);
pallet_quota
::
Pallet
::
<
Runtime
>
::
on_created
(
idty_index
);
// When main membership is acquired, it starts getting right to UD.
pallet_identity
::
Identities
::
<
Runtime
>
::
mutate_exists
(
idty_index
,
|
idty_val_opt
|
{
if
let
Some
(
ref
mut
idty_val
)
=
idty_val_opt
{
...
...
@@ -107,6 +105,7 @@ impl<
+
pallet_identity
::
Config
<
IdtyData
=
IdtyData
,
IdtyIndex
=
IdtyIndex
>
+
pallet_smith_members
::
Config
<
IdtyIndex
=
IdtyIndex
>
+
pallet_duniter_wot
::
Config
+
pallet_quota
::
Config
+
pallet_universal_dividend
::
Config
,
>
sp_membership
::
traits
::
OnRemoveMembership
<
IdtyIndex
>
for
OnRemoveMembershipHandler
<
Runtime
>
{
...
...
@@ -127,7 +126,8 @@ impl<
}
}
});
weight
+=
Runtime
::
DbWeight
::
get
()
.reads_writes
(
1
,
1
);
weight
.saturating_add
(
pallet_quota
::
Pallet
::
<
Runtime
>
::
on_removed
(
idty_index
));
weight
.saturating_add
(
Runtime
::
DbWeight
::
get
()
.reads_writes
(
1
,
1
));
// When membership is removed, also remove from smith member.
weight
.saturating_add
(
...
...
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