Skip to content

Commit 8de80c2

Browse files
authored
Make sure compact receipt does not get registered as global receipt decoder. (#5586)
* Make sure compact receipt does not get registered as global receipt encoder * Fix whitespace
1 parent 5103c6a commit 8de80c2

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited
2+
// SPDX-License-Identifier: LGPL-3.0-only
3+
4+
using Nethermind.Serialization.Rlp;
5+
using NUnit.Framework;
6+
7+
namespace Nethermind.Core.Test.Encoding;
8+
9+
public class ReceiptMessageDecoderTests
10+
{
11+
[Test]
12+
public void TestGlobalReceiptEncoderMustBeReceiptMessageDecoder()
13+
{
14+
Rlp.Decoders[typeof(TxReceipt)].Equals(typeof(ReceiptMessageDecoder));
15+
Rlp.Decoders[typeof(LogEntry)].Equals(typeof(LogEntryDecoder));
16+
}
17+
}

src/Nethermind/Nethermind.Serialization.Rlp/CompactLogEntryDecoder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
namespace Nethermind.Serialization.Rlp
1313
{
14-
public class CompactLogEntryDecoder
14+
[Rlp.SkipGlobalRegistration]
15+
public class CompactLogEntryDecoder : IRlpDecoder<LogEntry>
1516
{
1617
public static CompactLogEntryDecoder Instance { get; } = new();
1718

src/Nethermind/Nethermind.Serialization.Rlp/CompactReceiptStorageDecoder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
namespace Nethermind.Serialization.Rlp
1414
{
15+
16+
[Rlp.SkipGlobalRegistration]
1517
public class CompactReceiptStorageDecoder : IRlpStreamDecoder<TxReceipt>, IRlpValueDecoder<TxReceipt>, IRlpObjectDecoder<TxReceipt>
1618
{
1719
public static readonly CompactReceiptStorageDecoder Instance = new();

src/Nethermind/Nethermind.Serialization.Rlp/ReceiptArrayStorageDecoder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Nethermind.Serialization.Rlp;
99

10+
[Rlp.SkipGlobalRegistration]
1011
public class ReceiptArrayStorageDecoder : IRlpStreamDecoder<TxReceipt[]>
1112
{
1213
public static readonly ReceiptArrayStorageDecoder Instance = new();

src/Nethermind/Nethermind.Serialization.Rlp/Rlp.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ public static void RegisterDecoders(Assembly assembly)
7979
continue;
8080
}
8181

82+
if (type.GetCustomAttribute(typeof(SkipGlobalRegistration)) is not null)
83+
{
84+
continue;
85+
}
86+
8287
Type[]? implementedInterfaces = type.GetInterfaces();
8388
foreach (Type? implementedInterface in implementedInterfaces)
8489
{
@@ -1445,5 +1450,8 @@ public static int LengthOf(BlockInfo item)
14451450
return rlpDecoder?.GetLength(item, RlpBehaviors.None) ?? throw new RlpException($"{nameof(Rlp)} does not support length of {nameof(BlockInfo)}");
14461451
}
14471452

1453+
public class SkipGlobalRegistration : Attribute
1454+
{
1455+
}
14481456
}
14491457
}

0 commit comments

Comments
 (0)