Skip to content

Commit

Permalink
Skip signature only for TxType.DepositTx (#6349)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikita Mescheryakov <[email protected]>
  • Loading branch information
LukaszRozmej and deffrian authored Dec 12, 2023
1 parent 7cc8358 commit 0a3a694
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/Nethermind/Nethermind.Serialization.Rlp/TxDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ static Span<byte> DecodeTxType(RlpStream rlpStream, int length, out TxType txTyp
transactionSequence = DecodeTxType(rlpStream, rlpStream.ReadPrefixAndContentLength().ContentLength, out txType);
}


return transactionSequence;


}

private static Hash256 CalculateHashForNetworkPayloadForm(TxType type, Span<byte> transactionSequence)
Expand Down Expand Up @@ -521,10 +518,7 @@ private static void DecodeSignature(
ulong v = rlpStream.DecodeULong();
ReadOnlySpan<byte> rBytes = rlpStream.DecodeByteArraySpan();
ReadOnlySpan<byte> sBytes = rlpStream.DecodeByteArraySpan();
if (!(v == 0 && rBytes.IsEmpty && sBytes.IsEmpty))
{
ApplySignature(transaction, v, rBytes, sBytes, rlpBehaviors);
}
ApplySignature(transaction, v, rBytes, sBytes, rlpBehaviors);
}

private static void DecodeSignature(
Expand All @@ -535,10 +529,7 @@ private static void DecodeSignature(
ulong v = decoderContext.DecodeULong();
ReadOnlySpan<byte> rBytes = decoderContext.DecodeByteArraySpan();
ReadOnlySpan<byte> sBytes = decoderContext.DecodeByteArraySpan();
if (!(v == 0 && rBytes.IsEmpty && sBytes.IsEmpty))
{
ApplySignature(transaction, v, rBytes, sBytes, rlpBehaviors);
}
ApplySignature(transaction, v, rBytes, sBytes, rlpBehaviors);
}

private static void ApplySignature(
Expand All @@ -548,6 +539,8 @@ private static void ApplySignature(
ReadOnlySpan<byte> sBytes,
RlpBehaviors rlpBehaviors)
{
if (transaction.Type == TxType.DepositTx && v == 0 && rBytes.IsEmpty && sBytes.IsEmpty) return;

bool allowUnsigned = (rlpBehaviors & RlpBehaviors.AllowUnsigned) == RlpBehaviors.AllowUnsigned;
bool isSignatureOk = true;
string signatureError = null;
Expand Down

0 comments on commit 0a3a694

Please sign in to comment.