-
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
Fix op-mainnet snapshot #7881
Conversation
@@ -20,7 +20,7 @@ | |||
|
|||
namespace Nethermind.Init.Steps | |||
{ | |||
[RunnerStepDependencies(typeof(InitTxTypesAndRlp), typeof(InitDatabase), typeof(MigrateConfigs), typeof(SetupKeyStore))] | |||
[RunnerStepDependencies(typeof(InitTxTypesAndRlp), typeof(InitDatabase), typeof(MigrateConfigs), typeof(SetupKeyStore), typeof(InitTxTypesAndRlp))] |
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.
InitTxTypesAndRlp is twice there
@@ -8,6 +8,6 @@ namespace Nethermind.TxPool | |||
{ | |||
public interface ITxValidator | |||
{ | |||
public ValidationResult IsWellFormed(Transaction transaction, IReleaseSpec releaseSpec); | |||
public ValidationResult IsWellFormed(Transaction transaction, Block? block, IReleaseSpec releaseSpec); |
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.
Maybe? Would reduce those unnecessary nulls
all over the place
public ValidationResult IsWellFormed(Transaction transaction, Block? block, IReleaseSpec releaseSpec); | |
public ValidationResult IsWellFormed(Transaction transaction, IReleaseSpec releaseSpec, Block? block = null); |
{ | ||
public ValidationResult IsWellFormed(Transaction transaction, IReleaseSpec releaseSpec, BlockHeader? header = null) | ||
{ | ||
if (header is null || specHelper.IsBedrock(header)) |
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.
Could IsBedrock be in IReleaseSpec
, then we don't have to pass header?
IReleaseSpec
was created to have all fork information.
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.
we can check if eip1559 is enabled. Not sure it's good idea. But as I know ReleaseSpec is not aware of optimism forks
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.
Would be good to make IReleaseSpec extendable by plugins then
// In op bedrock eip1559 activated with bedrock | ||
if (releaseSpec.IsEip1559Enabled) | ||
{ | ||
return transaction.Signature is null ? new ValidationResult("Empty signature") : ValidationResult.Success; |
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 inside if (v == 0 && rBytes.IsEmpty && sBytes.IsEmpty)
. Without this pr we would crash inside DecodeSignature
.
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:
RegisterValidator(TxType.Legacy, new CompositeTxValidator([ | |
IntrinsicGasTxValidator.Instance, | |
new LegacySignatureTxValidator(chainId), | |
ContractSizeTxValidator.Instance, | |
NonBlobFieldsTxValidator.Instance, | |
NonSetCodeFieldsTxValidator.Instance | |
])); |
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 transactions
nethermind/src/Nethermind/Nethermind.Optimism/OptimismTxValidator.cs
Lines 20 to 26 in 6edd397
public bool IsWellFormed(Transaction transaction, IReleaseSpec releaseSpec) => | |
IsWellFormed(transaction, releaseSpec, out _); | |
public bool IsWellFormed(Transaction transaction, IReleaseSpec releaseSpec, [NotNullWhen(false)] out string? error) | |
{ | |
error = null; | |
return transaction.Type == TxType.DepositTx || _txValidator.IsWellFormed(transaction, releaseSpec, out error); | |
} |
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.
Fixes Closes Resolves #
Pre-bedrock legacy transactions might not have signature
Changes
Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Documentation
Requires documentation update
Requires explanation in Release Notes