From 9fd8a65e9b8c535f09fdde6f3997cc94637bd292 Mon Sep 17 00:00:00 2001 From: caglarkaya Date: Wed, 16 Oct 2024 23:11:39 +0300 Subject: [PATCH] feat: add signature function to TxDeposit (#174) ## Motivation `optimism_deposit_tx_signature` function in `reth` should be moved to `op-alloy` as part of an [issue](https://github.com/paradigmxyz/reth/issues/11781). https://github.com/paradigmxyz/reth/issues/11781 ## Solution An associated function `signature` is added to the `TxDeposit` struct. ## PR Checklist - [ ] Added Tests - [ ] Added Documentation - [ ] Breaking changes --- .github/workflows/ci.yml | 2 +- crates/consensus/src/transaction/deposit.rs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1174edc8..8e7407e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -138,7 +138,7 @@ jobs: cache-on-failure: true - run: cargo +stable clippy --workspace --all-targets --all-features env: - RUSTFLAGS: -Dwarnings + RUSTFLAGS: -D warnings docs: runs-on: ubuntu-latest diff --git a/crates/consensus/src/transaction/deposit.rs b/crates/consensus/src/transaction/deposit.rs index fa3676b2..492dbeff 100644 --- a/crates/consensus/src/transaction/deposit.rs +++ b/crates/consensus/src/transaction/deposit.rs @@ -1,7 +1,7 @@ use super::OpTxType; use alloy_consensus::Transaction; use alloy_eips::eip2930::AccessList; -use alloy_primitives::{Address, Bytes, ChainId, TxKind, B256, U256}; +use alloy_primitives::{Address, Bytes, ChainId, Parity, Signature, TxKind, B256, U256}; use alloy_rlp::{ Buf, BufMut, Decodable, Encodable, Error as DecodeError, Header, EMPTY_STRING_CODE, }; @@ -152,6 +152,12 @@ impl TxDeposit { inner_payload_length } } + + /// Returns the signature for the optimism deposit transactions, which don't include a + /// signature. + pub fn signature() -> Signature { + Signature::new(U256::ZERO, U256::ZERO, Parity::Parity(false)) + } } impl Transaction for TxDeposit {