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
f80a9dcc
Commit
f80a9dcc
authored
Jan 23, 2024
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
fix(
#162
): replace `active` by actual identity status
parent
55d51237
No related branches found
No related tags found
No related merge requests found
Pipeline
#35572
failed
Jan 23, 2024
Stage: labels
Stage: quality
Stage: build
Stage: tests
Changes
3
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
node/src/chain_spec/gdev.rs
+18
-5
18 additions, 5 deletions
node/src/chain_spec/gdev.rs
node/src/chain_spec/gen_genesis_data.rs
+43
-15
43 additions, 15 deletions
node/src/chain_spec/gen_genesis_data.rs
node/src/chain_spec/gtest.rs
+17
-4
17 additions, 4 deletions
node/src/chain_spec/gtest.rs
with
78 additions
and
24 deletions
node/src/chain_spec/gdev.rs
+
18
−
5
View file @
f80a9dcc
...
...
@@ -281,7 +281,7 @@ fn genesis_data_to_gdev_genesis_conf(
initial_monetary_mass
,
memberships
,
parameters
,
common_parameters
:
_
,
common_parameters
,
session_keys_map
,
initial_smiths
,
sudo_key
,
...
...
@@ -337,17 +337,30 @@ fn genesis_data_to_gdev_genesis_conf(
name
,
owner_key
,
old_owner_key
,
active
,
status
,
}|
GenesisIdty
{
index
:
idty_index
,
name
:
common_runtime
::
IdtyName
::
from
(
name
.as_str
()),
value
:
common_runtime
::
IdtyValue
{
data
:
IdtyData
::
new
(),
next_creatable_identity_on
:
0
,
old_owner_key
:
old_owner_key
.map
(|
address
|
(
address
,
0
)),
old_owner_key
:
old_owner_key
.
clone
()
.
map
(|
address
|
(
address
,
0
)),
owner_key
,
next_scheduled
:
if
active
{
0
}
else
{
2
},
status
:
IdtyStatus
::
Member
,
next_scheduled
:
match
status
{
IdtyStatus
::
Unconfirmed
|
IdtyStatus
::
Unvalidated
=>
{
panic!
(
"Unconfirmed or Unvalidated identity in genesis"
)
}
IdtyStatus
::
Member
|
IdtyStatus
::
Revoked
=>
0
,
// To avoid fetching from G1 the actual elapsed time, we set a fixed value for all identities.
// TODO: check the quantity of concerned members
IdtyStatus
::
NotMember
=>
{
common_parameters
.clone
()
.unwrap
()
.membership_membership_period
}
},
status
,
},
},
)
...
...
This diff is collapsed.
Click to expand it.
node/src/chain_spec/gen_genesis_data.rs
+
43
−
15
View file @
f80a9dcc
...
...
@@ -93,7 +93,7 @@ pub struct GenesisIdentity {
pub
name
:
String
,
pub
owner_key
:
AccountId
,
pub
old_owner_key
:
Option
<
AccountId
>
,
pub
active
:
bool
,
pub
status
:
IdtyStatus
,
}
#[derive(Deserialize,
Serialize)]
...
...
@@ -178,6 +178,8 @@ struct IdentityV1 {
old_owner_key
:
Option
<
PubkeyV1
>
,
/// timestamp at which the membership is set to expire (0 for expired members)
membership_expire_on
:
TimestampV1
,
/// whether the identity is revoked (manually or automatically)
revoked
:
bool
,
/// timestamp at which the next cert can be emitted
next_cert_issuable_on
:
TimestampV1
,
// TODO: unused?
/// balance of the account of this identity
...
...
@@ -197,6 +199,8 @@ struct IdentityV2 {
old_owner_key
:
Option
<
AccountId
>
,
/// block at which the membership is set to expire (0 for expired members)
membership_expire_on
:
u32
,
/// whether the identity is revoked (manually or automatically)
revoked
:
bool
,
/// block at which the next cert can be emitted
next_cert_issuable_on
:
u32
,
/// balance of the account of this identity
...
...
@@ -244,7 +248,7 @@ struct GenesisInfo<'a> {
genesis_timestamp
:
u64
,
accounts
:
&
'a
BTreeMap
<
AccountId32
,
GenesisAccountData
<
u64
,
u32
>>
,
genesis_data_wallets_count
:
&
'a
usize
,
inactive_identities
:
&
'a
HashMap
<
u32
,
String
>
,
inactive_identities
:
&
'a
HashMap
<
u32
,
(
String
,
IdtyStatus
)
>
,
identities
:
&
'a
Vec
<
GenesisIdentity
>
,
identity_index
:
&
'a
HashMap
<
u32
,
String
>
,
initial_smiths
:
&
'a
BTreeMap
<
u32
,
(
bool
,
Vec
<
u32
>
)
>
,
...
...
@@ -314,7 +318,7 @@ where
// track identity index
let
mut
identity_index
=
HashMap
::
new
();
// track inactive identities
let
mut
inactive_identities
=
HashMap
::
<
u32
,
String
>
::
new
();
let
mut
inactive_identities
=
HashMap
::
<
u32
,
(
String
,
IdtyStatus
)
>
::
new
();
// declare variables to fill in genesis
// -------------------------------------
...
...
@@ -749,7 +753,7 @@ fn dump_genesis_info(info: GenesisInfo) {
"prepared genesis with:
- {} as genesis timestamp
- {} accounts ({} identities, {} simple wallets)
- {} total identities ({}
active
, {} inactive)
- {} total identities ({}
members
, {} inactive
s, {} revoked
)
- {} smiths
- {} initial online authorities
- {} certifications
...
...
@@ -761,7 +765,14 @@ fn dump_genesis_info(info: GenesisInfo) {
info
.genesis_data_wallets_count
,
info
.identity_index
.len
(),
info
.identities
.len
()
-
info
.inactive_identities
.len
(),
info
.inactive_identities
.len
(),
info
.inactive_identities
.iter
()
.filter
(|(
_
,
(
_
,
status
))|
*
status
==
IdtyStatus
::
NotMember
)
.count
(),
info
.inactive_identities
.iter
()
.filter
(|(
_
,
(
_
,
status
))|
*
status
==
IdtyStatus
::
Revoked
)
.count
(),
info
.initial_smiths
.len
(),
info
.counter_online_authorities
,
info
.counter_cert
,
...
...
@@ -1026,13 +1037,15 @@ fn get_best_diviser(ms_value: f32) -> f32 {
}
fn
smiths_and_technical_committee_checks
(
inactive_identities
:
&
HashMap
<
u32
,
String
>
,
inactive_identities
:
&
HashMap
<
u32
,
(
String
,
IdtyStatus
)
>
,
technical_committee
:
&
Vec
<
String
>
,
smiths
:
&
Vec
<
SmithData
>
,
)
{
// no inactive tech comm
for
tech_com_member
in
technical_committee
{
let
inactive_commitee_member
=
inactive_identities
.values
()
.any
(|
v
|
v
==
tech_com_member
);
let
inactive_commitee_member
=
inactive_identities
.values
()
.any
(|(
name
,
_
)|
name
==
tech_com_member
);
if
inactive_commitee_member
{
log
::
error!
(
"{} is an inactive technical commitee member"
,
...
...
@@ -1045,11 +1058,11 @@ fn smiths_and_technical_committee_checks(
for
SmithData
{
name
:
smith
,
..
}
in
smiths
{
let
inactive_smiths
:
Vec
<
_
>
=
inactive_identities
.values
()
.filter
(|
v
|
*
v
==
smith
)
.filter
(|
(
name
,
_
)|
name
==
smith
)
.collect
();
inactive_smiths
.iter
()
.for_each
(|
s
|
log
::
warn!
(
"Smith {} is inactive"
,
s
));
.for_each
(|
(
name
,
_
)
|
log
::
warn!
(
"Smith {} is inactive"
,
name
));
assert_eq!
(
inactive_smiths
.len
(),
0
);
}
}
...
...
@@ -1297,6 +1310,7 @@ fn genesis_data_to_identities_v2(
i
.membership_expire_on
,
genesis_timestamp
,
),
revoked
:
i
.revoked
,
next_cert_issuable_on
:
timestamp_to_relative_blocs
(
i
.next_cert_issuable_on
,
genesis_timestamp
,
...
...
@@ -1338,6 +1352,7 @@ fn make_authority_exist<SessionKeys: Encode, SKP: SessionKeysProvider<SessionKey
balance
:
common_parameters
.balances_existential_deposit
,
certs_received
:
HashMap
::
new
(),
membership_expire_on
:
common_parameters
.membership_membership_period
,
revoked
:
false
,
old_owner_key
:
None
,
next_cert_issuable_on
:
0
,
},
...
...
@@ -1386,7 +1401,7 @@ fn feed_identities(
accounts
:
&
mut
BTreeMap
<
AccountId32
,
GenesisAccountData
<
u64
,
u32
>>
,
identity_index
:
&
mut
HashMap
<
u32
,
String
>
,
monetary_mass
:
&
mut
u64
,
inactive_identities
:
&
mut
HashMap
<
u32
,
String
>
,
inactive_identities
:
&
mut
HashMap
<
u32
,
(
String
,
IdtyStatus
)
>
,
memberships
:
&
mut
BTreeMap
<
u32
,
MembershipData
>
,
identities_v2
:
&
HashMap
<
String
,
IdentityV2
>
,
)
->
Result
<
(
bool
,
Vec
<
GenesisIdentity
>
),
String
>
{
...
...
@@ -1453,19 +1468,32 @@ fn feed_identities(
let
expired
=
identity
.membership_expire_on
==
0
;
// only add the identity if not expired
if
expired
{
inactive_identities
.insert
(
identity
.index
,
name
.clone
());
inactive_identities
.insert
(
identity
.index
,
(
name
.clone
(),
if
identity
.revoked
{
IdtyStatus
::
Revoked
}
else
{
IdtyStatus
::
NotMember
},
),
);
};
identities
.push
(
GenesisIdentity
{
// N.B.: every **non-expired** identity on Genesis is considered to have:
// - removable_on: 0,
// - next_creatable_identity_on: 0,
// - status: IdtyStatus::Validated,
idty_index
:
identity
.index
,
name
:
name
.to_owned
()
.clone
(),
owner_key
:
identity
.owner_key
.clone
(),
old_owner_key
:
identity
.old_owner_key
.clone
(),
// but expired identities will just have their pseudonym reserved in the storage
active
:
!
expired
,
status
:
match
(
identity
.revoked
,
expired
)
{
(
true
,
_
)
=>
IdtyStatus
::
Revoked
,
(
false
,
true
)
=>
IdtyStatus
::
NotMember
,
(
false
,
false
)
=>
IdtyStatus
::
Member
,
},
});
// insert the membershup data (only if not expired)
...
...
@@ -1716,7 +1744,7 @@ where
name
:
String
::
from_utf8
(
name
.0
.clone
())
.unwrap
(),
owner_key
:
owner_key
.clone
(),
old_owner_key
:
None
,
active
:
true
,
status
:
IdtyStatus
::
Member
,
})
.collect
();
...
...
@@ -1746,7 +1774,7 @@ where
.collect
();
let
genesis_data_wallets_count
=
0
;
let
inactive_identities
=
HashMap
::
new
();
let
inactive_identities
:
HashMap
<
u32
,
(
String
,
IdtyStatus
)
>
=
HashMap
::
new
();
let
initial_smiths_wot
:
BTreeMap
<
u32
,
(
bool
,
Vec
<
u32
>
)
>
=
clique_smith_wot
(
initial_smiths_len
);
let
counter_smith_cert
=
initial_smiths_wot
...
...
This diff is collapsed.
Click to expand it.
node/src/chain_spec/gtest.rs
+
17
−
4
View file @
f80a9dcc
...
...
@@ -231,7 +231,7 @@ fn genesis_data_to_gtest_genesis_conf(
initial_monetary_mass
,
memberships
,
parameters
:
_
,
common_parameters
:
_
,
common_parameters
,
session_keys_map
,
initial_smiths
,
sudo_key
,
...
...
@@ -285,7 +285,7 @@ fn genesis_data_to_gtest_genesis_conf(
name
,
owner_key
,
old_owner_key
,
active
,
status
,
}|
GenesisIdty
{
index
:
idty_index
,
name
:
common_runtime
::
IdtyName
::
from
(
name
.as_str
()),
...
...
@@ -294,8 +294,21 @@ fn genesis_data_to_gtest_genesis_conf(
next_creatable_identity_on
:
0
,
old_owner_key
:
old_owner_key
.clone
()
.map
(|
address
|
(
address
,
0
)),
owner_key
,
next_scheduled
:
if
active
{
0
}
else
{
2
},
status
:
IdtyStatus
::
Member
,
next_scheduled
:
match
status
{
IdtyStatus
::
Unconfirmed
|
IdtyStatus
::
Unvalidated
=>
{
panic!
(
"Unconfirmed or Unvalidated identity in genesis"
)
}
IdtyStatus
::
Member
|
IdtyStatus
::
Revoked
=>
0
,
// To avoid fetching from G1 the actual elapsed time, we set a fixed value for all identities.
// TODO: check the quantity of concerned members
IdtyStatus
::
NotMember
=>
{
common_parameters
.clone
()
.unwrap
()
.membership_membership_period
}
},
status
,
},
},
)
...
...
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
sign in
to comment