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
001c7c82
Commit
001c7c82
authored
2 years ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
add checks and improve formatting
parent
dd7b66e7
No related branches found
No related tags found
1 merge request
!168
gtest genesis new format
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
node/src/chain_spec/gtest_genesis.rs
+41
-22
41 additions, 22 deletions
node/src/chain_spec/gtest_genesis.rs
resources/gtest.json
+18
-13
18 additions, 13 deletions
resources/gtest.json
with
59 additions
and
35 deletions
node/src/chain_spec/gtest_genesis.rs
+
41
−
22
View file @
001c7c82
...
...
@@ -157,6 +157,8 @@ pub fn build_genesis(
let
mut
counter_cert
=
0u32
;
// counter for smith certifications
let
mut
counter_smith_cert
=
0u32
;
// track inactive identities
let
mut
inactive_identities
=
HashMap
::
<
u32
,
&
str
>
::
new
();
// declare variables to fill in genesis
// -------------------------------------
...
...
@@ -180,9 +182,9 @@ pub fn build_genesis(
let
mut
smith_certs_by_receiver
=
BTreeMap
::
new
();
// SIMPLE WALLETS //
for
(
pubkey
,
balance
)
in
genesis_data
.wallets
{
for
(
pubkey
,
balance
)
in
&
genesis_data
.wallets
{
// check existential deposit
if
balance
<
EXISTENTIAL_DEPOSIT
{
if
balance
<
&
EXISTENTIAL_DEPOSIT
{
log
::
warn!
(
"wallet {pubkey} has {balance} which is below {EXISTENTIAL_DEPOSIT}"
);
fatal
=
true
;
}
...
...
@@ -195,7 +197,7 @@ pub fn build_genesis(
pubkey
.clone
(),
GenesisAccountData
{
random_id
:
H256
(
blake2_256
(
&
(
wallet_index
,
&
pubkey
)
.encode
())),
balance
,
balance
:
*
balance
,
is_identity
:
false
,
},
);
...
...
@@ -252,7 +254,7 @@ pub fn build_genesis(
},
});
}
else
{
log
::
info!
(
"ignoring expired identity {
name
}"
);
inactive_identities
.insert
(
identity
.index
,
name
);
};
// insert the membershup data (only if not expired)
...
...
@@ -268,8 +270,8 @@ pub fn build_genesis(
// Technical Comittee //
// NOTE : when changing owner key, the technical committee is not changed
for
name
in
genesis_data
.technical_committee
{
if
let
Some
(
identity
)
=
&
genesis_data
.identities
.get
(
&
name
)
{
for
name
in
&
genesis_data
.technical_committee
{
if
let
Some
(
identity
)
=
&
genesis_data
.identities
.get
(
name
)
{
technical_committee_members
.push
(
identity
.owner_key
.clone
());
}
else
{
return
Err
(
format!
(
"Identity '{}' not exist"
,
name
));
...
...
@@ -292,14 +294,14 @@ pub fn build_genesis(
}
// SMITHS SUB-WOT //
for
(
name
,
smith_data
)
in
genesis_data
.smiths
{
for
(
name
,
smith_data
)
in
&
genesis_data
.smiths
{
let
identity
=
&
genesis_data
.identities
.get
(
&
name
)
.get
(
&
name
.clone
()
)
.ok_or
(
format!
(
"Identity '{}' not exist"
,
&
name
))
?
;
// Initial authorities and session keys
let
session_keys_bytes
=
if
let
Some
(
declared_session_keys
)
=
smith_data
.session_keys
{
let
session_keys_bytes
=
if
let
Some
(
declared_session_keys
)
=
&
smith_data
.session_keys
{
counter_online_authorities
+=
1
;
// insert authority as online
initial_authorities
.insert
(
identity
.index
,
(
identity
.owner_key
.clone
(),
true
));
...
...
@@ -392,31 +394,48 @@ pub fn build_genesis(
fatal
=
true
;
}
// some more checks
assert_eq!
(
identities
.len
(),
memberships
.len
());
assert_eq!
(
smith_memberships
.len
(),
initial_authorities
.len
());
assert_eq!
(
smith_memberships
.len
(),
session_keys_map
.len
());
assert_eq!
(
identity_index
.len
(),
identities
.len
()
+
inactive_identities
.len
()
);
assert_eq!
(
accounts
.len
(),
identity_index
.len
()
+
&
genesis_data
.wallets
.len
()
);
// no inactive tech comm
for
tech_com_member
in
&
genesis_data
.technical_committee
{
assert!
(
!
inactive_identities
.values
()
.any
(|
&
v
|
v
==
tech_com_member
));
}
// no inactive smith
for
(
smith
,
_
)
in
&
genesis_data
.smiths
{
assert!
(
!
inactive_identities
.values
()
.any
(|
&
v
|
v
==
smith
));
}
// give genesis info
log
::
info!
(
"inserted genesis with:
- {} accounts
- {} members in technical committee
- {} total identities
- {} active identities
- {} memberships
- {} smith memberships
- {} initial autorities
- {} accounts ({} identities, {} simple wallets)
- {} total identities ({} active, {} inactive)
- {} smiths
- {} initial online authorities
- {} session keys
- {} certifications
- {} smith certifications"
,
- {} smith certifications
- {} members in technical committee"
,
accounts
.len
(),
technical_committee_members
.len
(),
identity_index
.len
(),
&
genesis_data
.wallets
.len
(),
identity_index
.len
(),
identities
.len
(),
membership
s
.len
(),
inactive_identitie
s
.len
(),
smith_memberships
.len
(),
initial_authorities
.len
(),
counter_online_authorities
,
session_keys_map
.len
(),
counter_cert
,
counter_smith_cert
,
technical_committee_members
.len
(),
);
// check the logs to see all the fatal error preventing from starting gtest currency
...
...
This diff is collapsed.
Click to expand it.
resources/gtest.json
+
18
−
13
View file @
001c7c82
{
"first_ud"
:
10000
,
"first_ud_reeval"
:
100800
,
"initial_monetary_mass"
:
531
3
81
,
"initial_monetary_mass"
:
531
4
81
,
"identities"
:
{
"old_user1"
:
{
"index"
:
7777
,
"owner_key"
:
"5H
95G8bwuf4yyNNNa83hDhj7wpYaSRhZiGezZ9TDbyqNdAhY
"
,
"owner_key"
:
"5H
GjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw
"
,
"membership_expire_on"
:
0
,
"next_cert_issuable_on"
:
0
,
"balance"
:
12
,
...
...
@@ -15,7 +15,7 @@
},
"old_user2"
:
{
"index"
:
8888
,
"owner_key"
:
"5
H95G8bwuf4yyNNNa83hDhj7wpYaSRhZiGezZ9TDbyqNdAhY
"
,
"owner_key"
:
"5
CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL
"
,
"membership_expire_on"
:
0
,
"next_cert_issuable_on"
:
0
,
"balance"
:
12
,
...
...
@@ -25,7 +25,7 @@
},
"old_user3"
:
{
"index"
:
6666
,
"owner_key"
:
"5
H95G8bwuf4yyNNNa83hDhj7wpYaSRhZiGezZ9TDbyqNdAhY
"
,
"owner_key"
:
"5
Fxune7f71ZbpP2FoY3mhYcmM596Erhv1gRue4nsPwkxMR4n
"
,
"membership_expire_on"
:
0
,
"next_cert_issuable_on"
:
0
,
"balance"
:
12
,
...
...
@@ -35,7 +35,7 @@
},
"elois"
:
{
"index"
:
2
,
"owner_key"
:
"5
H95G8bwuf4yyNNNa83hDhj7wpYaSRhZiGezZ9TDbyqNdAhY
"
,
"owner_key"
:
"5
CUjxa4wVKMj3FqKdqAUf7zcEMr4MYAjXeWmUf44B41neLmJ
"
,
"membership_expire_on"
:
1000
,
"next_cert_issuable_on"
:
100
,
"balance"
:
10000
,
...
...
@@ -187,7 +187,7 @@
"Gamaliel"
:
{
"index"
:
3994
,
"owner_key"
:
"5DS9iWBXW56N7XbeVyyp6CB7m4LeE5fGJYrUR9HDSStT5JN9"
,
"membership_expire_on"
:
100
0
,
"membership_expire_on"
:
0
,
"next_cert_issuable_on"
:
100
,
"balance"
:
10000
,
"certs_received"
:
{
...
...
@@ -199,19 +199,21 @@
"kapis"
:
{
"index"
:
3883
,
"owner_key"
:
"5HJyyim1W8Y1UD8LAbBL7cQQLjGofMoD45RtRSAmhkFQxrvs"
,
"membership_expire_on"
:
1000
,
"membership_expire_on"
:
22
,
"next_cert_issuable_on"
:
100
,
"balance"
:
10000
,
"certs_received"
:
{
"DavidB"
:
100
,
"wellno1"
:
100
,
"Gamaliel"
:
100
"Gamaliel"
:
100
,
"HugoTrentesaux"
:
100
,
"elois"
:
100
}
},
"DavidB"
:
{
"index"
:
2277
,
"owner_key"
:
"5HKTDdXHj3MojiPRcEsVU9JaHyif5gg2br1sy3JZbsjuQebP"
,
"membership_expire_on"
:
100
0
,
"membership_expire_on"
:
0
,
"next_cert_issuable_on"
:
100
,
"balance"
:
10000
,
"certs_received"
:
{
...
...
@@ -223,7 +225,7 @@
"wellno1"
:
{
"index"
:
9999
,
"owner_key"
:
"5DyEZNkSuK5i8wZiXtvL63zqpye9zPBsPRauCjQkMuVzZYX7"
,
"membership_expire_on"
:
100
0
,
"membership_expire_on"
:
0
,
"next_cert_issuable_on"
:
100
,
"balance"
:
10000
,
"certs_received"
:
{
...
...
@@ -268,7 +270,8 @@
"cgeek"
,
"elois"
,
"HugoTrentesaux"
,
"poka"
"poka"
,
"tuxmain"
]
},
"cgeek"
:
{
...
...
@@ -303,7 +306,9 @@
"certs_received"
:
[
"elois"
,
"tuxmain"
,
"HugoTrentesaux"
"HugoTrentesaux"
,
"1000i100"
,
"vit"
]
}
},
...
...
@@ -313,7 +318,7 @@
"5C59KZ3X6AEt23FSLxsLvtXqN41SHyaWa5CQmXiYLUek3ECd"
:
24507
,
"5C5KjPbZfvwFXh24KkKEjeofCNng2tZM4YjJN8mMYhLAzn8H"
:
1042
,
"5C5VrnckbfuizDDFn9ubcQDEKSnRFbB3jfa5kMaQxmRFzLJX"
:
10800
,
"5C5YfjAyZnLPfyMQNreng5knFW87PRTVphRhPUXpWszF7sB9"
:
1
00
,
"5C5YfjAyZnLPfyMQNreng5knFW87PRTVphRhPUXpWszF7sB9"
:
2
00
,
"5C5YfjAyZnLPfyMQNreng5knFW87PRTVphRkQoupWszF7pte"
:
359592
},
"sudo_key"
:
"5Hm8sBbwuLAU99dBezvgtnRmZCrUy9mhqmbQMFyGTaeATYg7"
,
...
...
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