From 2ed9ca97f79e9165436655886aa8da1fb553e84b Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Sat, 27 Jan 2024 22:36:45 +0100
Subject: [PATCH] fix(#162): also make Genesis identity expire at the time
 expected by G1

---
 node/src/chain_spec/gdev.rs             | 4 +++-
 node/src/chain_spec/gen_genesis_data.rs | 7 +++++++
 node/src/chain_spec/gtest.rs            | 4 +++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/node/src/chain_spec/gdev.rs b/node/src/chain_spec/gdev.rs
index 421e4047f..1ea45a67a 100644
--- a/node/src/chain_spec/gdev.rs
+++ b/node/src/chain_spec/gdev.rs
@@ -338,6 +338,7 @@ fn genesis_data_to_gdev_genesis_conf(
                          name,
                          owner_key,
                          status,
+                         expires_on,
                          revokes_on,
                      }| GenesisIdty {
                         index: idty_index,
@@ -351,7 +352,8 @@ fn genesis_data_to_gdev_genesis_conf(
                                 IdtyStatus::Unconfirmed | IdtyStatus::Unvalidated => {
                                     panic!("Unconfirmed or Unvalidated identity in genesis")
                                 }
-                                IdtyStatus::Member | IdtyStatus::Revoked => 0,
+                                IdtyStatus::Member => expires_on.expect("must have expires_on set"),
+                                IdtyStatus::Revoked => 0,
                                 IdtyStatus::NotMember => {
                                     revokes_on.expect("must have revokes_on set")
                                 }
diff --git a/node/src/chain_spec/gen_genesis_data.rs b/node/src/chain_spec/gen_genesis_data.rs
index cd2caf6c3..c0d547519 100644
--- a/node/src/chain_spec/gen_genesis_data.rs
+++ b/node/src/chain_spec/gen_genesis_data.rs
@@ -93,6 +93,7 @@ pub struct GenesisIdentity {
     pub name: String,
     pub owner_key: AccountId,
     pub status: IdtyStatus,
+    pub expires_on: Option<u32>,
     pub revokes_on: Option<u32>,
 }
 
@@ -1473,6 +1474,11 @@ fn feed_identities(
             owner_key: identity.owner_key.clone(),
             // but expired identities will just have their pseudonym reserved in the storage
             status,
+            expires_on: if status == IdtyStatus::Member {
+                Some(identity.membership_expire_on)
+            } else {
+                None
+            },
             revokes_on: if status == IdtyStatus::NotMember {
                 Some(identity.membership_revokes_on)
             } else {
@@ -1727,6 +1733,7 @@ where
             name: String::from_utf8(name.0.clone()).unwrap(),
             owner_key: owner_key.clone(),
             status: IdtyStatus::Member,
+            expires_on: Some(common_parameters.membership_membership_period),
             revokes_on: None,
         })
         .collect();
diff --git a/node/src/chain_spec/gtest.rs b/node/src/chain_spec/gtest.rs
index 84e96fb18..2b0ff5c78 100644
--- a/node/src/chain_spec/gtest.rs
+++ b/node/src/chain_spec/gtest.rs
@@ -286,6 +286,7 @@ fn genesis_data_to_gtest_genesis_conf(
                          name,
                          owner_key,
                          status,
+                         expires_on,
                          revokes_on,
                      }| GenesisIdty {
                         index: idty_index,
@@ -299,7 +300,8 @@ fn genesis_data_to_gtest_genesis_conf(
                                 IdtyStatus::Unconfirmed | IdtyStatus::Unvalidated => {
                                     panic!("Unconfirmed or Unvalidated identity in genesis")
                                 }
-                                IdtyStatus::Member | IdtyStatus::Revoked => 0,
+                                IdtyStatus::Member => expires_on.expect("must have expires_on set"),
+                                IdtyStatus::Revoked => 0,
                                 IdtyStatus::NotMember => {
                                     revokes_on.expect("must have revokes_on set")
                                 }
-- 
GitLab