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

fix: rm Signature optimism cfg #6858

Merged
merged 1 commit into from
Feb 28, 2024
Merged
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
2 changes: 1 addition & 1 deletion crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ impl<'a> arbitrary::Arbitrary<'a> for TransactionSigned {

#[cfg(feature = "optimism")]
let signature = if transaction.is_deposit() {
Signature { r: crate::U256::ZERO, s: crate::U256::ZERO, odd_y_parity: false }
Signature::optimism_deposit_tx_signature()
} else {
signature
};
Expand Down
25 changes: 0 additions & 25 deletions crates/primitives/src/transaction/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ impl Signature {
/// Output the `v` of the signature depends on chain_id
#[inline]
pub fn v(&self, chain_id: Option<u64>) -> u64 {
#[cfg(feature = "optimism")]
if self.r.is_zero() && self.s.is_zero() {
return 0
}

if let Some(chain_id) = chain_id {
// EIP-155: v = {0, 1} + CHAIN_ID * 2 + 35
self.odd_y_parity as u64 + chain_id * 2 + 35
Expand Down Expand Up @@ -206,16 +201,6 @@ mod tests {
assert_eq!(4, signature.payload_len_with_eip155_chain_id(Some(47)));
}

#[cfg(feature = "optimism")]
#[test]
fn test_zero_signature_payload_len_with_eip155_chain_id() {
let zero_signature = Signature { r: U256::ZERO, s: U256::ZERO, odd_y_parity: false };

assert_eq!(3, zero_signature.payload_len_with_eip155_chain_id(None));
assert_eq!(3, zero_signature.payload_len_with_eip155_chain_id(Some(1)));
assert_eq!(3, zero_signature.payload_len_with_eip155_chain_id(Some(47)));
}

#[test]
fn test_v() {
// Select 1 as an arbitrary nonzero value for R and S, as v() always returns 0 for (0, 0).
Expand All @@ -228,16 +213,6 @@ mod tests {
assert_eq!(38, signature.v(Some(1)));
}

#[cfg(feature = "optimism")]
#[test]
fn test_zero_signature_v() {
let signature = Signature { r: U256::ZERO, s: U256::ZERO, odd_y_parity: false };

assert_eq!(0, signature.v(None));
assert_eq!(0, signature.v(Some(1)));
assert_eq!(0, signature.v(Some(47)));
}

#[test]
fn test_encode_and_decode_with_eip155_chain_id() {
// Select 1 as an arbitrary nonzero value for R and S, as v() always returns 0 for (0, 0).
Expand Down
Loading