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
77a4185f
Commit
77a4185f
authored
2 years ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
tuxmain review
parent
001c7c82
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.rs
+3
-3
3 additions, 3 deletions
node/src/chain_spec/gtest.rs
node/src/chain_spec/gtest_genesis.rs
+111
-81
111 additions, 81 deletions
node/src/chain_spec/gtest_genesis.rs
with
114 additions
and
84 deletions
node/src/chain_spec/gtest.rs
+
3
−
3
View file @
77a4185f
...
...
@@ -95,7 +95,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> {
// return chainspecs
Ok
(
ChainSpec
::
from_genesis
(
// Name
"Ğ
t
est Development"
,
"Ğ
T
est Development"
,
// ID
"gtest_dev"
,
// chain type
...
...
@@ -139,7 +139,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> {
// generated genesis
Ok
(
ChainSpec
::
from_genesis
(
// Name
"Ğ
t
est Development"
,
"Ğ
T
est Development"
,
// ID
"gtest_dev"
,
// chain type
...
...
@@ -192,7 +192,7 @@ pub fn local_testnet_config(
Ok
(
ChainSpec
::
from_genesis
(
// Name
"Ğ
t
est Local Testnet"
,
"Ğ
T
est Local Testnet"
,
// ID
"gtest_local"
,
ChainType
::
Local
,
...
...
This diff is collapsed.
Click to expand it.
node/src/chain_spec/gtest_genesis.rs
+
111
−
81
View file @
77a4185f
...
...
@@ -185,7 +185,7 @@ pub fn build_genesis(
for
(
pubkey
,
balance
)
in
&
genesis_data
.wallets
{
// check existential deposit
if
balance
<
&
EXISTENTIAL_DEPOSIT
{
log
::
warn!
(
"wallet {pubkey} has {balance} which is below {EXISTENTIAL_DEPOSIT}"
);
log
::
warn!
(
"wallet {pubkey} has {balance}
cǦT
which is below {EXISTENTIAL_DEPOSIT}"
);
fatal
=
true
;
}
...
...
@@ -193,6 +193,7 @@ pub fn build_genesis(
monetary_mass
+=
balance
;
wallet_index
+=
1
;
// json prevents duplicate wallets
accounts
.insert
(
pubkey
.clone
(),
GenesisAccountData
{
...
...
@@ -210,7 +211,33 @@ pub fn build_genesis(
return
Err
(
format!
(
"Identity name '{}' is invalid"
,
&
name
));
}
// check existential deposit
if
identity
.balance
<
EXISTENTIAL_DEPOSIT
{
if
identity
.membership_expire_on
!=
0
{
log
::
warn!
(
"expired identity {name} has {} cǦT which is below {EXISTENTIAL_DEPOSIT}"
,
identity
.balance
);
fatal
=
true
;
}
else
{
// member identities can still be below existential deposit thanks to sufficient
log
::
info!
(
"identity {name} has {} cǦT which is below {EXISTENTIAL_DEPOSIT}"
,
identity
.balance
);
}
}
// Money
// check that wallet with same owner_key does not exist
if
accounts
.get
(
&
identity
.owner_key
)
.is_some
()
{
log
::
warn!
(
"{name} owner_key {} already exists as a simple wallet"
,
identity
.owner_key
);
fatal
=
true
;
}
// insert as an account
accounts
.insert
(
identity
.owner_key
.clone
(),
GenesisAccountData
{
...
...
@@ -274,7 +301,8 @@ pub fn build_genesis(
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
));
log
::
error!
(
"Identity '{}' does not exist"
,
name
);
fatal
=
true
;
}
}
...
...
@@ -282,24 +310,21 @@ pub fn build_genesis(
for
(
_
,
identity
)
in
&
genesis_data
.identities
{
let
mut
certs
=
BTreeMap
::
new
();
for
(
issuer
,
expire_on
)
in
&
identity
.certs_received
{
let
issuer_index
=
&
genesis_data
.identities
.get
(
issuer
)
.ok_or
(
format!
(
"Identity '{}' not exist"
,
issuer
))
?
.index
;
certs
.insert
(
*
issuer_index
,
Some
(
expire_on
.clone
()));
if
let
Some
(
issuer
)
=
&
genesis_data
.identities
.get
(
issuer
)
{
certs
.insert
(
issuer
.index
,
Some
(
expire_on
.clone
()));
counter_cert
+=
1
;
}
else
{
log
::
error!
(
"Identity '{}' does not exist"
,
issuer
);
fatal
=
true
;
};
}
certs_by_receiver
.insert
(
identity
.index
,
certs
);
}
// SMITHS SUB-WOT //
for
(
name
,
smith_data
)
in
&
genesis_data
.smiths
{
let
identity
=
&
genesis_data
.identities
.get
(
&
name
.clone
())
.ok_or
(
format!
(
"Identity '{}' not exist"
,
&
name
))
?
;
// check that smith exists
if
let
Some
(
identity
)
=
&
genesis_data
.identities
.get
(
&
name
.clone
())
{
// Initial authorities and session keys
let
session_keys_bytes
=
if
let
Some
(
declared_session_keys
)
=
&
smith_data
.session_keys
{
counter_online_authorities
+=
1
;
...
...
@@ -348,6 +373,10 @@ pub fn build_genesis(
expire_on
:
GENESIS_SMITH_MEMBERSHIP_EXPIRE_ON
,
},
);
}
else
{
log
::
error!
(
"Smith '{}' does not correspond to exising identity"
,
&
name
);
fatal
=
true
;
}
}
// Verify certifications coherence (can be ignored for old users)
...
...
@@ -394,30 +423,9 @@ 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!
(
"
insert
ed genesis with:
"
prepar
ed genesis with:
- {} accounts ({} identities, {} simple wallets)
- {} total identities ({} active, {} inactive)
- {} smiths
...
...
@@ -438,8 +446,30 @@ pub fn build_genesis(
technical_committee_members
.len
(),
);
// 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
));
}
// check the logs to see all the fatal error preventing from starting gtest currency
if
fatal
{
log
::
error!
(
"some previously logged error prevent from building a sane genesis"
);
panic!
();
}
...
...
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