Skip to content
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

Shutter: refactor & increase disconnection log timeout #7722

Merged
merged 6 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions src/Nethermind/Nethermind.Shutter/Config/IShutterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public interface IShutterConfig : IConfig
DefaultValue = "true", HiddenFromDocs = true)]
bool Validator { get; set; }

[ConfigItem(Description = "How many milliseconds to wait for transactions before sending a disconnection warning.",
DefaultValue = "1200000", HiddenFromDocs = true)]
uint DisconnectionLogTimeout { get; set; }

public void Validate(out Multiaddress[] bootnodeP2PAddresses)
{
if (Validator && ValidatorInfoFile is null)
Expand Down Expand Up @@ -107,6 +111,11 @@ public void Validate(out Multiaddress[] bootnodeP2PAddresses)
throw new ArgumentException("Must set Shutter keyper set manager contract address to valid address.");
}

if (DisconnectionLogTimeout < 60000)
{
throw new ArgumentException("Must set Shutter disconnection log timeout to at least a minute.");
}

if (P2PAgentVersion is null)
{
throw new ArgumentNullException(nameof(P2PAgentVersion));
Expand Down
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Shutter/Config/ShutterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ public class ShutterConfig : IShutterConfig
public ulong InstanceID { get; set; } = 0;
public int EncryptedGasLimit { get; set; } = 10000000;
public ushort MaxKeyDelay { get; set; } = 1666;
public uint DisconnectionLogTimeout { get; set; } = 1200000;
}
}
7 changes: 4 additions & 3 deletions src/Nethermind/Nethermind.Shutter/ShutterP2P.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ShutterP2P : IShutterP2P
private readonly ILocalPeer _peer;
private readonly ServiceProvider _serviceProvider;
private CancellationTokenSource? _cts;
private static readonly TimeSpan DisconnectionLogTimeout = TimeSpan.FromMinutes(5);
private readonly TimeSpan DisconnectionLogTimeout;

public class ShutterP2PException(string message, Exception? innerException = null) : Exception(message, innerException);

Expand All @@ -42,12 +42,13 @@ public ShutterP2P(IShutterConfig shutterConfig, ILogManager logManager, IFileSys
{
_logger = logManager.GetClassLogger();
_cfg = shutterConfig;
DisconnectionLogTimeout = TimeSpan.FromMilliseconds(_cfg.DisconnectionLogTimeout);
Marchhill marked this conversation as resolved.
Show resolved Hide resolved
_serviceProvider = new ServiceCollection()
.AddLibp2p(builder => builder)
.AddSingleton(new IdentifyProtocolSettings
{
ProtocolVersion = shutterConfig.P2PProtocolVersion,
AgentVersion = shutterConfig.P2PAgentVersion
ProtocolVersion = _cfg.P2PProtocolVersion,
AgentVersion = _cfg.P2PAgentVersion
})
// pubsub settings
.AddSingleton(new Settings()
Expand Down