-
Notifications
You must be signed in to change notification settings - Fork 775
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
Incorrect Block Author Reward During Era Transition in Polkadot and Other Chains #4923
Comments
I think it would be clearer if you can attach a code snippet for the PoS chain runtime & node service configuration. |
This is bizarre because you'd expect the chain tracks its own block author rewards on-chain. |
This issue applies to both the Polkadot and Kusama chains as well. I have already provided some blocks on Polkadot as references where the block authoring reward was either not awarded to the author or was given to a different validator than the one who authored the block. |
Yeah the problem here is that when a session enacts a new validator set and the call to determine the block author comes later, we will already fetch the validator from the new set. The solution is that we buffer the old set in the current block. |
To ensure I understand this correctly. When allocating block rewards, the author is fetched using the Curious, why isn’t the author account id in the digest in the first place? |
Because the account id is not known to the node side. The node side only knows the session key, which is different to the account. |
Ah, I see. It seems to me the buffer of the previous validator set is only useful for determining the author of the first block of each session, which is kinda trivial (but a bug is a bug). Do you it's worth the overhead of extra storage? @bkchr @burdges The best I could find about determining whether a block is the first in a session is to check if authorities change is signaled in the digest. But that's specific to consensus engines. Do you think it makes sense to add a generic interface for that, similar to |
It's not storage overhead that's problematic here. We already have two validator sets simultaniously because elections require doing so. Afaik approvals checks needs the old authorities sets anyways, likely a third validator sets, so maybe someone can tell you how to access it. |
impl<T: Config, Inner: FindAuthor<u32>> FindAuthor<T::ValidatorId>
for FindAccountFromAuthorIndex<T, Inner>
{
fn find_author<'a, I>(digests: I) -> Option<T::ValidatorId>
where
I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
{
let i = Inner::find_author(digests)?;
fn first_block_of_session(digests: I) -> bool {
// guess this wouldn't work? as a slot can be without a block
frame_system::Pallet::<T>::block_number() % SLOTS_PER_SESSION == 0
// or
// check if authorities change is signaled in digests
}
let validators = if first_block_of_session(digests) {
OldValidators::<T>::get()
} else {
Validators::<T>::get()
};
validators.get(i as usize).cloned()
}
} Thinking about something like this: |
You missunderstood my comment: We should store the different session keys for each validator together in one structure of course, otherwise wastes lookup space. An An Just use the Also, our storage lacks O(1) moves, and future storages would lack them too, so |
What you said makes sense. If the set is already stored somewhere, for sure we shouldn't duplicate it. I've tried searching for |
Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Description of bug
During era transitions in PoS-based chains utilizing the BABE protocol for block production, the authorship of blocks is sometimes incorrectly identified. This leads to the block author reward being misallocated. Specifically, the reward may be given to the wrong authority or not given at all for certain era-transitioning blocks.
As a result of this bug, many of the era transition blocks have either rewarded the incorrect authority or were not rewarded at all. The following list of blocks is non-exhaustive:
Steps to reproduce
The text was updated successfully, but these errors were encountered: