diff --git a/end2end-tests/cucumber-genesis/default.json b/end2end-tests/cucumber-genesis/default.json index 7a978091070b4cf42720b9a07c2ae6eb99d728e7..b23ed7e91be4333a96ff708ceab0ea9e201a0b76 100644 --- a/end2end-tests/cucumber-genesis/default.json +++ b/end2end-tests/cucumber-genesis/default.json @@ -23,7 +23,6 @@ "cert_period": 15, "cert_max_by_issuer": 10, "cert_min_received_cert_to_issue_cert": 2, - "cert_renewable_period": 50, "cert_validity_period": 1000, "idty_confirm_period": 40, "idty_creation_period": 50, @@ -35,7 +34,6 @@ "smith_cert_period": 15, "smith_cert_max_by_issuer": 8, "smith_cert_min_received_cert_to_issue_cert": 2, - "smith_cert_renewable_period": 50, "smith_cert_validity_period": 1000, "smith_membership_period": 1000, "smith_membership_renewable_period": 20, diff --git a/end2end-tests/cucumber-genesis/wot.json b/end2end-tests/cucumber-genesis/wot.json index 988e6857f07b387758e082040a684a2f255029db..72e61ebcdee1e733ac20eded498ba85e769b00a5 100644 --- a/end2end-tests/cucumber-genesis/wot.json +++ b/end2end-tests/cucumber-genesis/wot.json @@ -28,7 +28,6 @@ "cert_period": 15, "cert_max_by_issuer": 10, "cert_min_received_cert_to_issue_cert": 2, - "cert_renewable_period": 50, "cert_validity_period": 1000, "idty_confirm_period": 40, "idty_creation_period": 50, @@ -40,7 +39,6 @@ "smith_cert_period": 15, "smith_cert_max_by_issuer": 8, "smith_cert_min_received_cert_to_issue_cert": 2, - "smith_cert_renewable_period": 50, "smith_cert_validity_period": 1000, "smith_membership_period": 1000, "smith_membership_renewable_period": 20, diff --git a/node/src/chain_spec/gdev.rs b/node/src/chain_spec/gdev.rs index b31c4f7dadcbed69d590e0f2bad61c35b18106ae..9d44f49c1ee48fca24680c2e96be2c667e349acb 100644 --- a/node/src/chain_spec/gdev.rs +++ b/node/src/chain_spec/gdev.rs @@ -309,7 +309,6 @@ fn gen_genesis_for_local_chain( cert_period: 15, cert_max_by_issuer: 10, cert_min_received_cert_to_issue_cert: 2, - cert_renewable_period: 50, cert_validity_period, idty_confirm_period: 40, idty_creation_period: 50, @@ -321,7 +320,6 @@ fn gen_genesis_for_local_chain( smith_cert_period: 15, smith_cert_max_by_issuer: 8, smith_cert_min_received_cert_to_issue_cert: 2, - smith_cert_renewable_period: 50, smith_cert_validity_period: 1_000, smith_membership_period, smith_membership_renewable_period: 50, diff --git a/pallets/certification/src/lib.rs b/pallets/certification/src/lib.rs index cc577701fe7bda364934bf578ea1d8aa4dd48e1b..5d333e7be2ba64ecc213e091f28df384c832d867 100644 --- a/pallets/certification/src/lib.rs +++ b/pallets/certification/src/lib.rs @@ -83,9 +83,6 @@ pub mod pallet { /// Handler for Removed event type OnRemovedCert: OnRemovedCert<Self::IdtyIndex>; #[pallet::constant] - /// Duration after which a certification is renewable - type CertRenewablePeriod: Get<Self::BlockNumber>; - #[pallet::constant] /// Duration of validity of a certification type ValidityPeriod: Get<Self::BlockNumber>; } @@ -169,15 +166,11 @@ pub mod pallet { } } } - let renewable_on = removable_on.saturating_sub( - T::ValidityPeriod::get().saturating_sub(T::CertRenewablePeriod::get()), - ); <StorageCertsByIssuer<T, I>>::insert( issuer, receiver, CertValue { - renewable_on, removable_on: *removable_on, }, ); @@ -274,8 +267,6 @@ pub mod pallet { NotEnoughCertReceived, /// This identity has already issued a certification too recently NotRespectCertPeriod, - /// This certification has already been issued or renewed recently - NotRespectRenewablePeriod, /// Receiver not found ReceiverNotFound, } @@ -302,7 +293,7 @@ pub mod pallet { let block_number = frame_system::pallet::Pallet::<T>::block_number(); - let create = if verify_rules { + if verify_rules { let issuer_idty_cert_meta = <StorageIdtyCertMeta<T, I>>::get(issuer); if issuer_idty_cert_meta.received_count == 0 { return Err(Error::<T, I>::IdtyMustReceiveCertsBeforeCanIssue.into()); @@ -317,22 +308,9 @@ pub mod pallet { } else if issuer_idty_cert_meta.issued_count >= T::MaxByIssuer::get() { return Err(Error::<T, I>::IssuedTooManyCert.into()); } - - // Verify rule CertRenewablePeriod - if let Ok(CertValue { renewable_on, .. }) = - <StorageCertsByIssuer<T, I>>::try_get(issuer, receiver) - { - if renewable_on > block_number { - return Err(Error::<T, I>::NotRespectRenewablePeriod.into()); - } - false - } else { - true - } - } else { - !StorageCertsByIssuer::<T, I>::contains_key(issuer, receiver) }; + let create = !StorageCertsByIssuer::<T, I>::contains_key(issuer, receiver); Self::do_add_cert(block_number, create, issuer, receiver) } /// Add a new certification or renew an existing one @@ -370,18 +348,7 @@ pub mod pallet { return Err(Error::<T, I>::IssuedTooManyCert.into()); } - // Verify rule CertRenewablePeriod - let create = if let Ok(CertValue { renewable_on, .. }) = - <StorageCertsByIssuer<T, I>>::try_get(issuer, receiver) - { - if renewable_on > block_number { - return Err(Error::<T, I>::NotRespectRenewablePeriod.into()); - } - false - } else { - true - }; - + let create = !StorageCertsByIssuer::<T, I>::contains_key(issuer, receiver); Self::do_add_cert(block_number, create, issuer, receiver) } @@ -439,7 +406,6 @@ pub mod pallet { // Write StorageCertsRemovableOn and StorageCertsByIssuer let cert_value = CertValue { - renewable_on: block_number + T::CertRenewablePeriod::get(), removable_on: block_number + T::ValidityPeriod::get(), }; <StorageCertsRemovableOn<T, I>>::append(cert_value.removable_on, (issuer, receiver)); diff --git a/pallets/certification/src/mock.rs b/pallets/certification/src/mock.rs index b3380463741ae82f712159c7eb2b7baccd2bd125..96a46725781f23b20efad2c7e9499a095fd2c2b7 100644 --- a/pallets/certification/src/mock.rs +++ b/pallets/certification/src/mock.rs @@ -94,7 +94,6 @@ impl frame_support::traits::EnsureOrigin<(Origin, IdtyIndex, IdtyIndex)> for Ens parameter_types! { pub const MaxByIssuer: u32 = 3; pub const MinReceivedCertToBeAbleToIssueCert: u32 = 2; - pub const RenewablePeriod: BlockNumber = 4; pub const CertPeriod: u64 = 2; pub const ValidityPeriod: u64 = 10; } @@ -109,7 +108,6 @@ impl pallet_certification::Config for Test { type MinReceivedCertToBeAbleToIssueCert = MinReceivedCertToBeAbleToIssueCert; type OnNewcert = (); type OnRemovedCert = (); - type CertRenewablePeriod = RenewablePeriod; type ValidityPeriod = ValidityPeriod; } diff --git a/pallets/certification/src/tests.rs b/pallets/certification/src/tests.rs index 64b77fb2a39ca18b6c8e7f17dbd5ef6a89d5b6d8..25998c16b86884f4011a11052a2799a180efe65d 100644 --- a/pallets/certification/src/tests.rs +++ b/pallets/certification/src/tests.rs @@ -115,11 +115,6 @@ fn test_genesis_build() { DefaultCertification::certs_removable_on(3), Some(vec![(2, 1)]), ); - // Cert 2->0 cannot be renewed before #5 - assert_eq!( - DefaultCertification::add_cert(Origin::signed(2), 0), - Err(Error::<Test, _>::NotRespectRenewablePeriod.into()) - ); run_to_block(3); // Cert 2->1 must have expired @@ -162,31 +157,3 @@ fn test_cert_period() { assert_ok!(DefaultCertification::add_cert(Origin::signed(0), 3)); }); } - -#[test] -fn test_renewable_period() { - new_test_ext(DefaultCertificationConfig { - apply_cert_period_at_genesis: true, - certs_by_issuer: btreemap![ - 0 => btreemap![1 => 10], - 2 => btreemap![0 => 10], - 3 => btreemap![0 => 10], - ], - }) - .execute_with(|| { - run_to_block(CertPeriod::get()); - assert_eq!( - DefaultCertification::add_cert(Origin::signed(0), 1), - Err(Error::<Test, _>::NotRespectRenewablePeriod.into()) - ); - run_to_block(RenewablePeriod::get()); - assert_ok!(DefaultCertification::add_cert(Origin::signed(0), 1)); - run_to_block(RenewablePeriod::get() + CertPeriod::get()); - assert_eq!( - DefaultCertification::add_cert(Origin::signed(0), 1), - Err(Error::<Test, _>::NotRespectRenewablePeriod.into()) - ); - run_to_block((2 * RenewablePeriod::get()) + 1); - assert_ok!(DefaultCertification::add_cert(Origin::signed(0), 1)); - }); -} diff --git a/pallets/certification/src/types.rs b/pallets/certification/src/types.rs index d1b858f9f25abc7ff855eb2b42b196dd36c608a2..4d2534c57314e762d4e9e1f45023dc683ffc7321 100644 --- a/pallets/certification/src/types.rs +++ b/pallets/certification/src/types.rs @@ -22,7 +22,6 @@ use scale_info::TypeInfo; #[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)] pub struct CertValue<BlockNumber> { - pub renewable_on: BlockNumber, pub removable_on: BlockNumber, } diff --git a/pallets/duniter-test-parameters/src/lib.rs b/pallets/duniter-test-parameters/src/lib.rs index b72c113419c66b2fc3a2bf697e80964f0d15f4d1..9a3a6f402ec1975b64381e3d4fb51595194b1bb8 100644 --- a/pallets/duniter-test-parameters/src/lib.rs +++ b/pallets/duniter-test-parameters/src/lib.rs @@ -40,7 +40,6 @@ pub mod types { pub cert_period: BlockNumber, pub cert_max_by_issuer: CertCount, pub cert_min_received_cert_to_issue_cert: CertCount, - pub cert_renewable_period: BlockNumber, pub cert_validity_period: BlockNumber, pub idty_confirm_period: BlockNumber, pub idty_creation_period: BlockNumber, @@ -52,7 +51,6 @@ pub mod types { pub smith_cert_period: BlockNumber, pub smith_cert_max_by_issuer: CertCount, pub smith_cert_min_received_cert_to_issue_cert: CertCount, - pub smith_cert_renewable_period: BlockNumber, pub smith_cert_validity_period: BlockNumber, pub smith_membership_period: BlockNumber, pub smith_membership_renewable_period: BlockNumber, diff --git a/pallets/duniter-wot/src/mock.rs b/pallets/duniter-wot/src/mock.rs index 9a8be581756680aaf58430d297b191383f081edd..5e7ac0454bcb0a0a00a75fc3c6948769572cdd20 100644 --- a/pallets/duniter-wot/src/mock.rs +++ b/pallets/duniter-wot/src/mock.rs @@ -154,7 +154,6 @@ impl pallet_membership::Config<Instance1> for Test { parameter_types! { pub const MaxByIssuer: u8 = 8; pub const MinReceivedCertToBeAbleToIssueCert: u32 = 2; - pub const CertRenewablePeriod: u64 = 4; pub const CertPeriod: u64 = 2; pub const ValidityPeriod: u64 = 20; } @@ -169,7 +168,6 @@ impl pallet_certification::Config<Instance1> for Test { type MinReceivedCertToBeAbleToIssueCert = MinReceivedCertToBeAbleToIssueCert; type OnNewcert = DuniterWot; type OnRemovedCert = DuniterWot; - type CertRenewablePeriod = CertRenewablePeriod; type ValidityPeriod = ValidityPeriod; } @@ -213,7 +211,6 @@ impl pallet_membership::Config<Instance2> for Test { parameter_types! { pub const SmithsMaxByIssuer: u8 = 8; pub const SmithsMinReceivedCertToBeAbleToIssueCert: u32 = 2; - pub const SmithsCertRenewablePeriod: u64 = 4; pub const SmithsCertPeriod: u64 = 2; pub const SmithsValidityPeriod: u64 = 10; } @@ -228,7 +225,6 @@ impl pallet_certification::Config<Instance2> for Test { type MinReceivedCertToBeAbleToIssueCert = SmithsMinReceivedCertToBeAbleToIssueCert; type OnNewcert = SmithsSubWot; type OnRemovedCert = SmithsSubWot; - type CertRenewablePeriod = SmithsCertRenewablePeriod; type ValidityPeriod = SmithsValidityPeriod; } diff --git a/resources/gdev.json b/resources/gdev.json index aba51b9128eed74ae6d82d12c4812aeaf7580842..f0be34c7eabba4f47e4e0ce3014f62956933163c 100644 --- a/resources/gdev.json +++ b/resources/gdev.json @@ -137,7 +137,6 @@ "cert_period": 14400, "cert_max_by_issuer": 100, "cert_min_received_cert_to_issue_cert": 5, - "cert_renewable_period": 172800, "cert_validity_period": 2102400, "idty_confirm_period": 14400, "idty_creation_period": 14400, @@ -149,7 +148,6 @@ "smith_cert_period": 14400, "smith_cert_max_by_issuer": 12, "smith_cert_min_received_cert_to_issue_cert": 3, - "smith_cert_renewable_period": 172800, "smith_cert_validity_period": 2102400, "smith_membership_period": 1051200, "smith_membership_renewable_period": 172800, diff --git a/resources/metadata.scale b/resources/metadata.scale index 1f01cc4a16551841453d80d1d36da2e23037db3f..03a32f390272d496544efb76a0d62d77f0ffc50a 100644 Binary files a/resources/metadata.scale and b/resources/metadata.scale differ diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 510c6e237c382cba2a8482171e32ebcef32e135d..93050373d78d913061bca4a7bb36f5ee28d7ce69 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -461,7 +461,6 @@ macro_rules! pallets_config { type MinReceivedCertToBeAbleToIssueCert = MinReceivedCertToBeAbleToIssueCert; type OnNewcert = Wot; type OnRemovedCert = Wot; - type CertRenewablePeriod = CertRenewablePeriod; type ValidityPeriod = ValidityPeriod; } @@ -499,7 +498,6 @@ macro_rules! pallets_config { type MinReceivedCertToBeAbleToIssueCert = SmithMinReceivedCertToBeAbleToIssueCert; type OnNewcert = SmithsSubWot; type OnRemovedCert = SmithsSubWot; - type CertRenewablePeriod = SmithCertRenewablePeriod; type ValidityPeriod = SmithValidityPeriod; } diff --git a/runtime/g1/src/parameters.rs b/runtime/g1/src/parameters.rs index 44e8ced87dc87f4e613f7a978ad1966525a9524d..62ba9ada4aaeafa3872e715fde7e53ae13968e8e 100644 --- a/runtime/g1/src/parameters.rs +++ b/runtime/g1/src/parameters.rs @@ -119,7 +119,6 @@ parameter_types! { pub const CertPeriod: BlockNumber = 5 * DAYS; pub const MaxByIssuer: u32 = 100; pub const MinReceivedCertToBeAbleToIssueCert: u32 = 5; - pub const CertRenewablePeriod: BlockNumber = 6 * MONTHS; pub const ValidityPeriod: BlockNumber = 2 * YEARS; } diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index 99f886d165d862b0a652f53d2399bb63a71b7816..80c84ed2263575222565956b37473db4b82cae16 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -227,7 +227,6 @@ common_runtime::pallets_config! { pub type MaxByIssuer = pallet_duniter_test_parameters::CertMaxByIssuer<Runtime>; pub type MinReceivedCertToBeAbleToIssueCert = pallet_duniter_test_parameters::CertMinReceivedCertToIssueCert<Runtime>; - pub type CertRenewablePeriod = pallet_duniter_test_parameters::CertRenewablePeriod<Runtime>; pub type ValidityPeriod = pallet_duniter_test_parameters::CertValidityPeriod<Runtime>; pub type ConfirmPeriod = pallet_duniter_test_parameters::IdtyConfirmPeriod<Runtime>; pub type IdtyCreationPeriod = pallet_duniter_test_parameters::IdtyCreationPeriod<Runtime>; @@ -247,8 +246,6 @@ common_runtime::pallets_config! { pub type SmithMaxByIssuer = pallet_duniter_test_parameters::SmithCertMaxByIssuer<Runtime>; pub type SmithMinReceivedCertToBeAbleToIssueCert = pallet_duniter_test_parameters::SmithCertMinReceivedCertToIssueCert<Runtime>; - pub type SmithCertRenewablePeriod = - pallet_duniter_test_parameters::SmithCertRenewablePeriod<Runtime>; pub type SmithValidityPeriod = pallet_duniter_test_parameters::SmithCertValidityPeriod<Runtime>; pub type SmithMembershipPeriod = pallet_duniter_test_parameters::SmithMembershipPeriod<Runtime>; pub type SmithPendingMembershipPeriod = diff --git a/runtime/gdev/tests/common/mod.rs b/runtime/gdev/tests/common/mod.rs index 4bcb9d45a239cab966d1ea3a90c8674c5c3c6207..16bd159b3143e920fda2bcb47a6eb8a2eef4b9be 100644 --- a/runtime/gdev/tests/common/mod.rs +++ b/runtime/gdev/tests/common/mod.rs @@ -99,7 +99,6 @@ impl ExtBuilder { cert_period: 15, cert_max_by_issuer: 10, cert_min_received_cert_to_issue_cert: 2, - cert_renewable_period: 50, cert_validity_period: 10_000, idty_confirm_period: 40, idty_creation_period: 50, @@ -111,7 +110,6 @@ impl ExtBuilder { smith_cert_period: 15, smith_cert_max_by_issuer: 8, smith_cert_min_received_cert_to_issue_cert: 2, - smith_cert_renewable_period: 50, smith_cert_validity_period: 1_000, smith_membership_period: 1_000, smith_membership_renewable_period: 50, diff --git a/runtime/gtest/src/parameters.rs b/runtime/gtest/src/parameters.rs index 8193b10c417e764f720a63355b36f8ebbbd96e47..8b9fbd05fa5b09ad257dcf00872c0c0ba99c191c 100644 --- a/runtime/gtest/src/parameters.rs +++ b/runtime/gtest/src/parameters.rs @@ -119,7 +119,6 @@ parameter_types! { parameter_types! { pub const CertPeriod: BlockNumber = DAYS; pub const MaxByIssuer: u32 = 100; - pub const CertRenewablePeriod: BlockNumber = 12 * DAYS; pub const ValidityPeriod: BlockNumber = 146 * DAYS; }