chore: add optimism_deposit_tx_signature function (#5457)

This commit is contained in:
Matthias Seitz
2023-11-17 11:22:07 +01:00
committed by GitHub
parent b4cbd0b04f
commit 7312ada852
2 changed files with 14 additions and 6 deletions

View File

@@ -1209,7 +1209,7 @@ impl TransactionSigned {
#[cfg(feature = "optimism")]
let signature = if tx_type == DEPOSIT_TX_TYPE_ID {
Signature::default()
Signature::optimism_deposit_tx_signature()
} else {
Signature::decode(data)?
};
@@ -1358,11 +1358,10 @@ impl proptest::arbitrary::Arbitrary for TransactionSigned {
}
#[cfg(feature = "optimism")]
let sig = if transaction.is_deposit() {
Signature { r: crate::U256::ZERO, s: crate::U256::ZERO, odd_y_parity: false }
} else {
sig
};
let sig = transaction
.is_deposit()
.then(Signature::optimism_deposit_tx_signature)
.unwrap_or(sig);
let mut tx =
TransactionSigned { hash: Default::default(), signature: sig, transaction };

View File

@@ -19,6 +19,15 @@ pub struct Signature {
pub odd_y_parity: bool,
}
impl Signature {
/// Returns the signature for the optimism deposit transactions, which don't include a
/// signature.
#[cfg(feature = "optimism")]
pub(crate) const fn optimism_deposit_tx_signature() -> Self {
Signature { r: U256::ZERO, s: U256::ZERO, odd_y_parity: false }
}
}
impl Compact for Signature {
fn to_compact<B>(self, buf: &mut B) -> usize
where