From d9331f97c11571daacb8dfd4b0a966092d714ed3 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Thu, 5 Dec 2024 13:28:22 -0500 Subject: [PATCH 1/6] Hot fix for reshare issue --- pallets/propagation/src/lib.rs | 4 ++-- pallets/propagation/src/tests.rs | 2 +- pallets/staking/src/lib.rs | 2 +- runtime/src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pallets/propagation/src/lib.rs b/pallets/propagation/src/lib.rs index e7542c891..2b4a22f26 100644 --- a/pallets/propagation/src/lib.rs +++ b/pallets/propagation/src/lib.rs @@ -158,11 +158,11 @@ pub mod pallet { /// Submits a request to do a key refresh on the signers parent key. pub fn post_reshare(block_number: BlockNumberFor) -> Result<(), http::Error> { let reshare_data = pallet_staking_extension::Pallet::::reshare_data(); - if reshare_data.block_number != block_number { + if reshare_data.block_number != block_number + sp_runtime::traits::One::one() { return Ok(()); } - let deadline = sp_io::offchain::timestamp().add(Duration::from_millis(2_000)); + let deadline = sp_io::offchain::timestamp().add(Duration::from_millis(10_000)); let kind = sp_core::offchain::StorageKind::PERSISTENT; let from_local = sp_io::offchain::local_storage_get(kind, b"reshare_validators") .unwrap_or_else(|| b"http://localhost:3001/validator/reshare".to_vec()); diff --git a/pallets/propagation/src/tests.rs b/pallets/propagation/src/tests.rs index d01559a5a..770bc6f24 100644 --- a/pallets/propagation/src/tests.rs +++ b/pallets/propagation/src/tests.rs @@ -88,7 +88,7 @@ fn knows_how_to_mock_several_http_calls() { // doesn't trigger no reshare block Propagation::post_reshare(7).unwrap(); pallet_staking_extension::ReshareData::::put(ReshareInfo { - block_number: 7, + block_number: 8, new_signer: 1u64.encode(), }); // now triggers diff --git a/pallets/staking/src/lib.rs b/pallets/staking/src/lib.rs index 16bd2c23e..396a2d83c 100644 --- a/pallets/staking/src/lib.rs +++ b/pallets/staking/src/lib.rs @@ -746,7 +746,7 @@ pub mod pallet { // trigger reshare at next block let current_block_number = >::block_number(); let reshare_info = ReshareInfo { - block_number: current_block_number + sp_runtime::traits::One::one(), + block_number: current_block_number - sp_runtime::traits::One::one(), new_signer, }; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 19f4c6e8a..05cd7e18b 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -208,7 +208,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // We update this if the runtime behaviour has changed. When this happens we set the // `impl_version` to `0`. #[allow(clippy::zero_prefixed_literal)] - spec_version: 00_03_00, + spec_version: 00_04_00, // We only bump this if the runtime behaviour remains unchanged, but the implementations details // have changed. From 0a2d4b97c234ba85e92f77d0829732e3b6810d78 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Thu, 5 Dec 2024 13:53:46 -0500 Subject: [PATCH 2/6] fix --- pallets/propagation/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/propagation/src/lib.rs b/pallets/propagation/src/lib.rs index 2b4a22f26..885ea5244 100644 --- a/pallets/propagation/src/lib.rs +++ b/pallets/propagation/src/lib.rs @@ -158,7 +158,7 @@ pub mod pallet { /// Submits a request to do a key refresh on the signers parent key. pub fn post_reshare(block_number: BlockNumberFor) -> Result<(), http::Error> { let reshare_data = pallet_staking_extension::Pallet::::reshare_data(); - if reshare_data.block_number != block_number + sp_runtime::traits::One::one() { + if reshare_data.block_number + sp_runtime::traits::One::one() != block_number { return Ok(()); } From 818438d11288de3b3908cc6d83d5caa0839bf022 Mon Sep 17 00:00:00 2001 From: JesseAbram <33698952+JesseAbram@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:24:19 -0800 Subject: [PATCH 3/6] Update runtime/src/lib.rs Co-authored-by: Hernando Castano --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 05cd7e18b..ab3318bdd 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -208,7 +208,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // We update this if the runtime behaviour has changed. When this happens we set the // `impl_version` to `0`. #[allow(clippy::zero_prefixed_literal)] - spec_version: 00_04_00, + spec_version: 00_03_01, // We only bump this if the runtime behaviour remains unchanged, but the implementations details // have changed. From 610fb34635d150bf49c6f4c80f382d145550095f Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Fri, 6 Dec 2024 12:33:51 -0500 Subject: [PATCH 4/6] fix tests --- pallets/propagation/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/propagation/src/tests.rs b/pallets/propagation/src/tests.rs index 770bc6f24..081beed07 100644 --- a/pallets/propagation/src/tests.rs +++ b/pallets/propagation/src/tests.rs @@ -88,7 +88,7 @@ fn knows_how_to_mock_several_http_calls() { // doesn't trigger no reshare block Propagation::post_reshare(7).unwrap(); pallet_staking_extension::ReshareData::::put(ReshareInfo { - block_number: 8, + block_number: 6, new_signer: 1u64.encode(), }); // now triggers From bcbb39d8e2b435411bc53449093f8a258aca5150 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Fri, 6 Dec 2024 14:12:45 -0500 Subject: [PATCH 5/6] fix tests --- pallets/staking/src/tests.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/pallets/staking/src/tests.rs b/pallets/staking/src/tests.rs index 6a09eec75..f77a6b251 100644 --- a/pallets/staking/src/tests.rs +++ b/pallets/staking/src/tests.rs @@ -482,7 +482,7 @@ fn it_tests_new_session_handler() { assert_eq!( Staking::reshare_data().block_number, - 101, + 99, "Check reshare block start at 100 + 1" ); assert_eq!( @@ -496,17 +496,6 @@ fn it_tests_new_session_handler() { "parent key threhsold updated" ); - assert_eq!( - Staking::reshare_data().block_number, - 101, - "Check reshare block start at 100 + 1" - ); - assert_eq!( - Staking::reshare_data().new_signer, - 1u64.encode(), - "Check reshare next signer up is 1" - ); - assert_ok!(Staking::new_session_handler(&[6, 5, 3])); // takes 3 and leaves 5 and 6 since already in signer group assert_eq!(Staking::next_signers().unwrap().next_signers, vec![6, 3]); @@ -522,6 +511,7 @@ fn it_tests_new_session_handler_signer_size_changes() { new_test_ext().execute_with(|| { // Start with current validators as 5 and 6 based off the Mock `GenesisConfig`. Signers::::put(vec![5, 6]); + System::set_block_number(100); assert_ok!(Staking::new_session_handler(&[6, 5, 3, 4])); // Signer size increased is reflected as 5 is not removed from vec From 784375cf7e2db263e8371e9765519c38c4fe8802 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Mon, 9 Dec 2024 16:39:11 -0500 Subject: [PATCH 6/6] logging --- pallets/propagation/src/lib.rs | 1 + pallets/staking/src/lib.rs | 1 + runtime/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pallets/propagation/src/lib.rs b/pallets/propagation/src/lib.rs index 885ea5244..900b65a01 100644 --- a/pallets/propagation/src/lib.rs +++ b/pallets/propagation/src/lib.rs @@ -159,6 +159,7 @@ pub mod pallet { pub fn post_reshare(block_number: BlockNumberFor) -> Result<(), http::Error> { let reshare_data = pallet_staking_extension::Pallet::::reshare_data(); if reshare_data.block_number + sp_runtime::traits::One::one() != block_number { + log::warn!("reshare block numbers: {:?}, {:?}", reshare_data.block_number + sp_runtime::traits::One::one(), block_number); return Ok(()); } diff --git a/pallets/staking/src/lib.rs b/pallets/staking/src/lib.rs index 396a2d83c..046d56ed0 100644 --- a/pallets/staking/src/lib.rs +++ b/pallets/staking/src/lib.rs @@ -710,6 +710,7 @@ pub mod pallet { // Since not enough validators do not allow rotation // TODO: https://github.com/entropyxyz/entropy-core/issues/943 if validators.len() <= current_signers_length { + log::warn!("validtor length less than current signer"); return Ok(weight); } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index ab3318bdd..e9746c285 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -208,7 +208,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // We update this if the runtime behaviour has changed. When this happens we set the // `impl_version` to `0`. #[allow(clippy::zero_prefixed_literal)] - spec_version: 00_03_01, + spec_version: 00_03_02, // We only bump this if the runtime behaviour remains unchanged, but the implementations details // have changed.