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

Chain halts after runtime upgrade | Getting Ignoring empty epoch change. Error with block built on #5064

Closed
2 tasks done
ashi20192020 opened this issue Jul 18, 2024 · 0 comments
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.

Comments

@ashi20192020
Copy link

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

I have a solo chain using Babe consensus. In my new branch, I implemented OneSessionHandler in one of my pallets. I am using this to collect active validators.

It's working fine if I run chain with my new branch. But if I do runtime upgrade on main branch, I started getting below error when new session changes:

2024-07-18 15:46:12 Corrupted state at `[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 224, 205, 208, 98, 230, 234, 242, 66, 149, 173, 76, 207, 196, 29, 70, 9]: Error`    
2024-07-18 15:46:12 Ignoring empty epoch change.    
2024-07-18 15:46:12 🎁 Prepared block for proposing at 34 (0 ms) [hash: 0xfe09b1a95631607aebada259e1a6adde43c64f4162e7fc33ae7468f42582157b; parent_hash: 0x4194…62e8; extrinsics (1): [0x6084…214a]    
2024-07-18 15:46:12 🔖 Pre-sealed block for proposal at 34. Hash now 0x73c962d1c74905a331ec6f81ce6bad5abf20d3bffc428846c3b8a43698d2dfcb, previously 0xfe09b1a95631607aebada259e1a6adde43c64f4162e7fc33ae7468f42582157b.    
2024-07-18 15:46:12 Error with block built on 0x419470202271cf7ba8e482c437226dc3201627ac9a7890f420b25506103162e8: Import failed: Expected epoch change to happen at 0x73c962d1c74905a331ec6f81ce6bad5abf20d3bffc428846c3b8a43698d2dfcb, s286882962    
^

After above error, chain stops producing blocks.

Here is my OneSessionHandler implementation:

impl<T: Config> sp_application_crypto::BoundToRuntimeAppPublic for Pallet<T> {
		type Public = T::AuthorityId;
	}

	impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
		type Key = T::AuthorityId;

		fn on_genesis_session<'a, I: 'a>(validators: I)
		where
			I: Iterator<Item = (&'a T::AccountId, Self::Key)>,
		{
			let validators = validators
				.map(|(_, k)| T::AccountId::decode(&mut &k.into().encode()[..]).unwrap())
				.collect::<Vec<_>>();

			ValidatorSet::<T>::put(validators); 
		}

		fn on_new_session<'a, I: 'a>(_changed: bool, validators: I, _queued_authorities: I)
		where
			I: Iterator<Item = (&'a T::AccountId, Self::Key)>,
		{
			let validators = validators
				.map(|(_, k)| T::AccountId::decode(&mut &k.into().encode()[..]).unwrap())
				.collect::<Vec<_>>();
			ValidatorSet::<T>::put(validators);
		}

		fn on_disabled(_i: u32) {}
	}
}

I also added corresponding changes in runtime.

impl_opaque_keys! {
	pub struct SessionKeys {
		pub grandpa: Grandpa,
		pub babe: Babe,
		pub im_online: ImOnline,
		pub authority_discovery: AuthorityDiscovery,
		pub template_module: TemplateModule,
	}
}

I haven't made any change related to epoch. Also if I remove last key from above SessionKeys, then it works fine but it does not call on_new_session method of OneSessionHandler.

Can somebody please help to fix this?

Steps to reproduce

No response

@ashi20192020 ashi20192020 added I10-unconfirmed Issue might be valid, but it's not yet known. I2-bug The node fails to follow expected behavior. labels Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.
Projects
None yet
Development

No branches or pull requests

1 participant