Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle optimism deposit transactions on SenderRecovery stage #7376

Merged
merged 5 commits into from
Mar 29, 2024

Conversation

joshieDo
Copy link
Collaborator

Deposit transactions do not have a signature, and we were trying to recover them during the stage.

@joshieDo joshieDo added C-bug An unexpected or incorrect behavior A-staged-sync Related to staged sync (pipelines and stages) A-op-reth Related to Optimism and op-reth labels Mar 28, 2024
@joshieDo joshieDo requested a review from emhane March 28, 2024 13:53
///
/// Returns `None` if the transaction's signature is invalid, see also
/// [Signature::recover_signer_unchecked].
pub fn recover_signer_unchecked_with_buffer(&self, rlp_buf: &mut Vec<u8>) -> Option<Address> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a mouthful, accepting suggestions

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense,

need to properly document the expections wrt buffer content, perhaps ideally only use the [len..] slice when hashing

///
/// Returns `None` if the transaction's signature is invalid, see also
/// [Signature::recover_signer_unchecked].
pub fn recover_signer_unchecked_with_buffer(&self, rlp_buf: &mut Vec<u8>) -> Option<Address> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this always clear the buffer before returning or clear at the beginning?

imo clear first would be safer

Comment on lines 872 to 873
///
/// Re-uses a given buffer to avoid numerous reallocations when recovering batches.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depending on where we clear the buffer, we need to document this

///
/// Returns `None` if the transaction's signature is invalid, see also
/// [Signature::recover_signer_unchecked].
pub fn recover_signer_unchecked_with_buffer(&self, rlp_buf: &mut Vec<u8>) -> Option<Address> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is basically, encode + recover unchecked?

so perhaps encode_recover_unchecked?

wdyt @Rjected

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that or encode_and_recover_unchecked seem fine

Copy link
Member

@emhane emhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-03-28 at 16 35 54

pulled this fix into #6151. defo works as metrics shows, sender recovery stage passed!

@joshieDo joshieDo requested a review from mattsse March 28, 2024 16:20
Comment on lines 878 to 887
pub fn encode_and_recover_unchecked(&self, buffer: &mut Vec<u8>) -> Option<Address> {
// 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)
}

buffer.clear();
self.transaction.encode_without_signature(buffer);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a footgun here because op deposit is never encoded.

I think for the sake of consistency we should just encode them as well, even if this means overhead for recovery.

@joshieDo joshieDo added this pull request to the merge queue Mar 29, 2024
Merged via the queue into main with commit 8b88306 Mar 29, 2024
27 checks passed
@joshieDo joshieDo deleted the joshie/fix-optimism-sender-recovery branch March 29, 2024 12:22
@emhane emhane restored the joshie/fix-optimism-sender-recovery branch March 30, 2024 15:02
@joshieDo joshieDo deleted the joshie/fix-optimism-sender-recovery branch July 4, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-op-reth Related to Optimism and op-reth A-staged-sync Related to staged sync (pipelines and stages) C-bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants