Skip to content

Commit

Permalink
fix: rm Signature optimism cfg (#6858)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Feb 28, 2024
1 parent 2aa5f5d commit ecfe4b6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
2 changes: 1 addition & 1 deletion crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,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

0 comments on commit ecfe4b6

Please sign in to comment.