mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add pre bedrock recovery check (#7726)
This commit is contained in:
@ -979,6 +979,11 @@ impl TransactionSignedNoHash {
|
||||
///
|
||||
/// Returns `None` if the transaction's signature is invalid, see also
|
||||
/// [Signature::recover_signer_unchecked].
|
||||
///
|
||||
/// # Optimism
|
||||
///
|
||||
/// For optimism this will return [Address::ZERO] if the Signature is empty, this is because pre bedrock (on OP mainnet), relay messages to the L2 Cross Domain Messenger were sent as legacy transactions from the zero address with an empty signature, e.g.: <https://optimistic.etherscan.io/tx/0x1bb352ff9215efe5a4c102f45d730bae323c3288d2636672eb61543ddd47abad>
|
||||
/// This makes it possible to import pre bedrock transactions via the sender recovery stage.
|
||||
pub fn encode_and_recover_unchecked(&self, buffer: &mut Vec<u8>) -> Option<Address> {
|
||||
buffer.clear();
|
||||
self.transaction.encode_without_signature(buffer);
|
||||
@ -986,8 +991,17 @@ 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 Transaction::Deposit(TxDeposit { from, .. }) = self.transaction {
|
||||
return Some(from)
|
||||
}
|
||||
|
||||
// pre bedrock system transactions were sent from the zero address as legacy
|
||||
// transactions with an empty signature Note: this is very hacky and only
|
||||
// relevant for op-mainnet pre bedrock
|
||||
if self.is_legacy() && self.signature == Signature::optimism_deposit_tx_signature() {
|
||||
return Some(Address::ZERO)
|
||||
}
|
||||
}
|
||||
|
||||
self.signature.recover_signer_unchecked(keccak256(buffer))
|
||||
|
||||
Reference in New Issue
Block a user