Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot fix for reshare issue #1201

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pallets/propagation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,12 @@ pub mod pallet {
/// Submits a request to do a key refresh on the signers parent key.
pub fn post_reshare(block_number: BlockNumberFor<T>) -> Result<(), http::Error> {
let reshare_data = pallet_staking_extension::Pallet::<T>::reshare_data();
if reshare_data.block_number != block_number {
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(());
}

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());
Expand Down
2 changes: 1 addition & 1 deletion pallets/propagation/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Test>::put(ReshareInfo {
block_number: 7,
block_number: 6,
new_signer: 1u64.encode(),
});
// now triggers
Expand Down
3 changes: 2 additions & 1 deletion pallets/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -746,7 +747,7 @@ pub mod pallet {
// trigger reshare at next block
let current_block_number = <frame_system::Pallet<T>>::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,
};

Expand Down
14 changes: 2 additions & 12 deletions pallets/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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]);
Expand All @@ -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::<Test>::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
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_03_02,

// We only bump this if the runtime behaviour remains unchanged, but the implementations details
// have changed.
Expand Down
Loading