mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 00:58:11 -05:00
feat(op): import bodies (#7659)
Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
This commit is contained in:
@@ -956,8 +956,8 @@ impl TransactionSignedNoHash {
|
||||
// Optimism's Deposit transaction does not have a signature. Directly return the
|
||||
// `from` address.
|
||||
#[cfg(feature = "optimism")]
|
||||
if let Transaction::Deposit(TxDeposit { from, .. }) = self.transaction {
|
||||
return Some(from)
|
||||
if let Some(address) = get_deposit_or_null_address(&self.transaction, &self.signature) {
|
||||
return Some(address)
|
||||
}
|
||||
|
||||
let signature_hash = self.signature_hash();
|
||||
@@ -976,11 +976,9 @@ impl TransactionSignedNoHash {
|
||||
buffer.clear();
|
||||
self.transaction.encode_without_signature(buffer);
|
||||
|
||||
// Optimism's Deposit transaction does not have a signature. Directly return the
|
||||
// `from` address.
|
||||
#[cfg(feature = "optimism")]
|
||||
if let Transaction::Deposit(TxDeposit { from, .. }) = self.transaction {
|
||||
return Some(from)
|
||||
if let Some(address) = get_deposit_or_null_address(&self.transaction, &self.signature) {
|
||||
return Some(address)
|
||||
}
|
||||
|
||||
self.signature.recover_signer_unchecked(keccak256(buffer))
|
||||
@@ -1189,8 +1187,8 @@ impl TransactionSigned {
|
||||
// Optimism's Deposit transaction does not have a signature. Directly return the
|
||||
// `from` address.
|
||||
#[cfg(feature = "optimism")]
|
||||
if let Transaction::Deposit(TxDeposit { from, .. }) = self.transaction {
|
||||
return Some(from)
|
||||
if let Some(address) = get_deposit_or_null_address(&self.transaction, &self.signature) {
|
||||
return Some(address)
|
||||
}
|
||||
let signature_hash = self.signature_hash();
|
||||
self.signature.recover_signer(signature_hash)
|
||||
@@ -1205,8 +1203,8 @@ impl TransactionSigned {
|
||||
// Optimism's Deposit transaction does not have a signature. Directly return the
|
||||
// `from` address.
|
||||
#[cfg(feature = "optimism")]
|
||||
if let Transaction::Deposit(TxDeposit { from, .. }) = self.transaction {
|
||||
return Some(from)
|
||||
if let Some(address) = get_deposit_or_null_address(&self.transaction, &self.signature) {
|
||||
return Some(address)
|
||||
}
|
||||
let signature_hash = self.signature_hash();
|
||||
self.signature.recover_signer_unchecked(signature_hash)
|
||||
@@ -1781,6 +1779,26 @@ impl IntoRecoveredTransaction for TransactionSignedEcRecovered {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "optimism")]
|
||||
fn get_deposit_or_null_address(
|
||||
transaction: &Transaction,
|
||||
signature: &Signature,
|
||||
) -> Option<Address> {
|
||||
// Optimism's Deposit transaction does not have a signature. Directly return the
|
||||
// `from` address.
|
||||
if let Transaction::Deposit(TxDeposit { from, .. }) = transaction {
|
||||
return Some(*from)
|
||||
}
|
||||
// OP blocks below bedrock include transactions sent from the null address
|
||||
if std::env::var_os(OP_RETH_MAINNET_BELOW_BEDROCK).as_deref() == Some("true".as_ref()) &&
|
||||
*signature == Signature::optimism_deposit_tx_signature()
|
||||
{
|
||||
return Some(Address::default())
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
|
||||
@@ -85,6 +85,12 @@ impl Signature {
|
||||
// EIP-155: v = {0, 1} + CHAIN_ID * 2 + 35
|
||||
self.odd_y_parity as u64 + chain_id * 2 + 35
|
||||
} else {
|
||||
#[cfg(feature = "optimism")]
|
||||
if std::env::var_os(OP_RETH_MAINNET_BELOW_BEDROCK).as_deref() == Some("true".as_ref()) &&
|
||||
*self == Self::optimism_deposit_tx_signature()
|
||||
{
|
||||
return 0
|
||||
}
|
||||
self.odd_y_parity as u64 + 27
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user