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

feat(consensus): Protected Legacy Signature #1578

Merged
merged 2 commits into from
Oct 28, 2024

Conversation

refcell
Copy link
Contributor

@refcell refcell commented Oct 28, 2024

Description

Adds a method to the TxEnvelope type that returns if the associated signature is protected.

Comment on lines +193 to +207
/// Returns true if the signature of the transaction is protected.
#[inline]
pub const fn is_protected(&self) -> bool {
match self {
Self::Legacy(tx) => {
let v = tx.signature().v().to_u64();
if 64 - v.leading_zeros() <= 8 {
return v != 27 && v != 28 && v != 1 && v != 0;
}
// anything not 27 or 28 is considered protected
true
}
_ => true,
}
}
Copy link
Member

Choose a reason for hiding this comment

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

should this be false for non-legacy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the reference impl in optimism's op-node

@klkvr klkvr merged commit b227b17 into alloy-rs:main Oct 28, 2024
26 checks passed
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.

2 participants