-
Notifications
You must be signed in to change notification settings - Fork 451
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 op-mainnet snapshot #7881
Merged
Merged
Fix op-mainnet snapshot #7881
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ad54d84
No signature in legacy transactions
deffrian 2ebd925
set fallback to null
deffrian 0483d2f
Fix build
deffrian b0e5339
Fix tools
deffrian 0b8adf4
Cleanup
deffrian f9c088c
Fix suggestions
deffrian 63c6a16
Remove block header
deffrian b5656e6
Fix
deffrian 78349f5
Merge branch 'master' into fix/optimism-snapshot
deffrian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/Nethermind/Nethermind.Optimism/OptimismLegacyTxDecoder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Crypto; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.Serialization.Rlp; | ||
using Nethermind.Serialization.Rlp.TxDecoders; | ||
using Nethermind.TxPool; | ||
|
||
namespace Nethermind.Optimism; | ||
|
||
public class OptimismLegacyTxDecoder : LegacyTxDecoder<Transaction> | ||
{ | ||
protected override Signature? DecodeSignature(ulong v, ReadOnlySpan<byte> rBytes, ReadOnlySpan<byte> sBytes, Signature? fallbackSignature = null, | ||
RlpBehaviors rlpBehaviors = RlpBehaviors.None) | ||
{ | ||
if (v == 0 && rBytes.IsEmpty && sBytes.IsEmpty) | ||
{ | ||
return null; | ||
} | ||
return base.DecodeSignature(v, rBytes, sBytes, fallbackSignature, rlpBehaviors); | ||
} | ||
} | ||
|
||
public class OptimismLegacyTxValidator : ITxValidator | ||
{ | ||
public ValidationResult IsWellFormed(Transaction transaction, IReleaseSpec releaseSpec) | ||
{ | ||
// In op bedrock eip1559 activated with bedrock | ||
if (releaseSpec.IsEip1559Enabled) | ||
{ | ||
return transaction.Signature is null ? new ValidationResult("Empty signature") : ValidationResult.Success; | ||
} | ||
|
||
return ValidationResult.Success; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we were not performing any validations on Deposit transactions, but now we require that post-Bedrock transactions contain a non-null signature. Is this correct? If so, shouldn't we also validate the signature (using
SignatureTxValidator
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if signature is null here it means that while decoding signature in
DecodeSignature
we got insideif (v == 0 && rBytes.IsEmpty && sBytes.IsEmpty)
. Without this pr we would crash insideDecodeSignature
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, what I'm missing is why we don't validate the signature of a Legacy transaction post bedrock. More so, why are we not performing the standard Legacy validations:
nethermind/src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs
Lines 24 to 30 in d00410f
With these changes, Legacy transactions that are processed in Optimism are not validated at all, when previously they went through several checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that means I made a mistake. But why we don't check DepositTransaction?
api.RegisterTxType<OptimismTransactionForRpc>(new OptimismTxDecoder<Transaction>(), Always.Valid);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It dates back to the original Optimism plugin PR where the
OptimismTxValidator
performed no checks on Deposit transactionsnethermind/src/Nethermind/Nethermind.Optimism/OptimismTxValidator.cs
Lines 20 to 26 in 6edd397
We didn't change the logic in the Transaction refactoring, so the current validator for Deposit transactions always succeeds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in #7887.