Skip to content

Conversation

@rajk93
Copy link
Contributor

@rajk93 rajk93 commented Nov 20, 2025

fixes #6229

Problem

Block author extraction fails on parachains and chains with multiple preRuntime digest logs (e.g., Kreivo, Asset Hub, and other CMLS based chains).

Solution

  • Iterate through all preRuntime digest logs.
  • Extract the author from the first recognized engine rather than taking only the first log.

@rajk93 rajk93 marked this pull request as ready for review November 20, 2025 09:02
Copy link
Member

@TarikGul TarikGul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@TarikGul
Copy link
Member

cc: @voliva

Comment on lines +23 to +25
if (accountId) {
return accountId;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be mistaken, but from a distance this fix seems a bit brittle. Are we certain that performing engine.extractAuthor on an entry that doesn't actually have an author will always return undefined? Aren't we chancing it a bit? Are we certain that the underlying encoded data can't yield a false-positive? What if one day the extractAuthor implementation changes?

Again, I'm not familiar with the implementation of extractAuthor. However, I think that it would be best to be more assertive and to first find out which one is the correct entry from where to extract the author, and only then get the author using the extractAuthor method.

It's just a thought. Please take it with a pinch of salt, because I really am not familiar with this logic in PJS. 🙂

Copy link
Contributor Author

@rajk93 rajk93 Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question! Your concern about relying on undefined returns is valid. However, the current approach is safe because extractAuthor() validates the engine identifier first, before interpreting any payload data:

public extractAuthor (bytes: Bytes, sessionValidators: AccountId[]): AccountId | undefined {
if (sessionValidators?.length) {
if (this.isAura) {
return getAuraAuthor(this.registry, bytes, sessionValidators);
} else if (this.isBabe) {
return getBabeAuthor(this.registry, bytes, sessionValidators);
}
}
// For pow & Nimbus, the bytes are the actual author
if (this.isPow || this.isNimbus) {
return getBytesAsAuthor(this.registry, bytes);
}
return undefined;
}

Example: When we call extractAuthor() on a CMLS preRuntime log:

  • Engine = 'CMLS' (4 bytes: 0x434d4c53)
  • Doesn't match 'aura', 'BABE', 'pow_' ...
  • Returns undefined without decoding the payload
  • Loop continues to the next preRuntime log

This means the engine ID acts as a gatekeeper -- random bytes in unrecognized engine payloads can't produce false positives because the engine string is checked before any data interpretation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong block author on Kreivo network

4 participants