Skip to content

Commit

Permalink
feat: add signature function to TxDeposit (#174)
Browse files Browse the repository at this point in the history
<!--
Thank you for your Pull Request. Please provide a description above and
review
the requirements below.

Bug fixes and new features should include tests.

Contributors guide:
https://github.com/alloy-rs/core/blob/main/CONTRIBUTING.md

The contributors guide includes instructions for running rustfmt and
building the
documentation.
-->

<!-- ** Please select "Allow edits from maintainers" in the PR Options
** -->

## Motivation
`optimism_deposit_tx_signature` function in `reth` should be moved to
`op-alloy` as part of an
[issue](paradigmxyz/reth#11781).

paradigmxyz/reth#11781

<!--
Explain the context and why you're making that change. What is the
problem
you're trying to solve? In some cases there is not a problem and this
can be
thought of as being the motivation for your change.
-->

## Solution
An associated function `signature` is added to the `TxDeposit` struct.

<!--
Summarize the solution and provide any necessary context needed to
understand
the code change.
-->

## PR Checklist

- [ ] Added Tests
- [ ] Added Documentation
- [ ] Breaking changes
  • Loading branch information
caglaryucekaya authored Oct 16, 2024
1 parent 20eb162 commit 9fd8a65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion crates/consensus/src/transaction/deposit.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9fd8a65

Please sign in to comment.