Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/Nethermind/Nethermind.Core/Buffers/CappedArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ public readonly Span<T> AsSpan(int start, int length)
return AsSpan().ToArray();
}

public override string? ToString()
{
return typeof(T) == typeof(byte) ?
SpanExtensions.ToHexString(MemoryMarshal.AsBytes(AsSpan()), withZeroX: true) :
public override string? ToString() =>
typeof(T) == typeof(byte) ?
MemoryMarshal.AsBytes(AsSpan()).ToHexString(withZeroX: true) :
base.ToString();
}

public readonly ArraySegment<T> AsArraySegment()
{
Expand Down
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Logging.NLog/NLogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public NLogManager(string logFileName, string logDirectory = null, string logRul
// Required since 'NLog.config' could change during runtime, we need to re-apply the configuration
_logManagerOnConfigurationChanged = (sender, args) => Setup(logFileName, logDirectory, logRules);
LogManager.ConfigurationChanged += _logManagerOnConfigurationChanged;
Static.LogManager = this;
}

private static void Setup(string logFileName, string logDirectory = null, string logRules = null)
Expand Down
11 changes: 11 additions & 0 deletions src/Nethermind/Nethermind.Logging/StaticLoggerFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System;

namespace Nethermind.Logging;

public static class Static
{
public static ILogManager LogManager { get; set; } = LimboLogs.Instance;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Nethermind.Network.P2P.Subprotocols.Eth.V63.Messages
{
public class ReceiptsMessageSerializer : IZeroInnerMessageSerializer<ReceiptsMessage>
{
private static readonly RlpLimit RlpLimit = RlpLimit.For<ReceiptsMessage>(NethermindSyncLimits.MaxReceiptFetch, nameof(ReceiptsMessage.TxReceipts));
private static readonly RlpLimit RlpLimit = RlpLimit.For<ReceiptsMessage>(NethermindSyncLimits.MaxReceiptFetch * 4, nameof(ReceiptsMessage.TxReceipts));
Comment thread
LukaszRozmej marked this conversation as resolved.
private readonly ISpecProvider _specProvider;
private readonly IRlpStreamDecoder<TxReceipt> _decoder;
private readonly Func<RlpStream, TxReceipt[]> _decodeArrayFunc;
Expand Down
4 changes: 3 additions & 1 deletion src/Nethermind/Nethermind.Runner/NLog.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" throwExceptions="false">
autoReload="true"
throwExceptions="false"
flushAllBeforeShutdown="true">

<extensions>
<add assembly="NLog.Targets.Seq" />
Expand Down
11 changes: 9 additions & 2 deletions src/Nethermind/Nethermind.Serialization.Rlp/Rlp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Nethermind.Core.Crypto;
using Nethermind.Core.Extensions;
using Nethermind.Int256;
using Nethermind.Logging;

namespace Nethermind.Serialization.Rlp
{
Expand Down Expand Up @@ -1836,21 +1837,27 @@ public sealed class DecoderAttribute(string key = RlpDecoderKey.Default) : Attri
public string Key { get; } = key;
}

private static ILogger _logger = Static.LogManager.GetClassLogger<Rlp>();

[StackTraceHidden]
public static void GuardLimit(int count, int bytesLeft, RlpLimit? limit = null)
{
RlpLimit l = limit ?? RlpLimit.DefaultLimit;
if (count > bytesLeft || count > l.Limit)
{
ThrowCountOverLimit(count, bytesLeft, l);
}
}

[DoesNotReturn]
[StackTraceHidden]
private static void ThrowCountOverLimit(int count, int bytesLeft, RlpLimit limit)
{
throw new RlpLimitException(string.IsNullOrEmpty(limit.CollectionExpression)
string message = string.IsNullOrEmpty(limit.CollectionExpression)
? $"Collection count of {count} is over limit {limit.Limit} or {bytesLeft} bytes left"
: $"Collection count {limit.CollectionExpression} of {count} is over limit {limit.Limit} or {bytesLeft} bytes left");
: $"Collection count {limit.CollectionExpression} of {count} is over limit {limit.Limit} or {bytesLeft} bytes left";
if (_logger.IsDebug) _logger.Error($"DEBUG/ERROR: {message}; {new StackTrace()}");
Comment thread
flcl42 marked this conversation as resolved.
throw new RlpLimitException(message);
}
}

Expand Down