Skip to content

Commit

Permalink
add --consensus-propose-second-base cli parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiker committed May 7, 2024
1 parent 333d6a2 commit a2c3811
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions Libplanet.Headless/Hosting/LibplanetNodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ IActionEvaluator BuildActionEvaluator(IActionEvaluatorConfiguration actionEvalua
ConsensusPrivateKey = Properties.ConsensusPrivateKey,
ConsensusWorkers = 500,
TargetBlockInterval = TimeSpan.FromMilliseconds(Properties.ConsensusTargetBlockIntervalMilliseconds ?? 7000),
ContextTimeoutOptions = Properties.ContextTimeoutOption,
};
}

Expand Down
3 changes: 3 additions & 0 deletions Libplanet.Headless/Hosting/LibplanetNodeServiceProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Libplanet.Types.Blocks;
using Libplanet.Crypto;
using Libplanet.Net;
using Libplanet.Net.Consensus;

namespace Libplanet.Headless.Hosting
{
Expand Down Expand Up @@ -67,6 +68,8 @@ public class LibplanetNodeServiceProperties

public TimeSpan TipTimeout { get; set; } = TimeSpan.FromSeconds(60);

public ContextTimeoutOption ContextTimeoutOption { get; set; }

public int DemandBuffer { get; set; } = 1150;

public ImmutableList<BoundPeer> ConsensusSeeds { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions NineChronicles.Headless.Executable/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class Configuration
public string[]? ConsensusSeedStrings { get; set; }
public ushort? ConsensusPort { get; set; }
public double? ConsensusTargetBlockIntervalMilliseconds { get; set; }
public int? ConsensusProposeSecondBase { get; set; }

public int? MaxTransactionPerBlock { get; set; }

Expand Down Expand Up @@ -143,6 +144,7 @@ public void Overwrite(
string? consensusPrivateKeyString,
string[]? consensusSeedStrings,
double? consensusTargetBlockIntervalMilliseconds,
int? consensusProposeSecondBase,
int? maxTransactionPerBlock,
string? sentryDsn,
double? sentryTraceSampleRate,
Expand Down Expand Up @@ -195,6 +197,7 @@ public void Overwrite(
ConsensusSeedStrings = consensusSeedStrings ?? ConsensusSeedStrings;
ConsensusPrivateKeyString = consensusPrivateKeyString ?? ConsensusPrivateKeyString;
ConsensusTargetBlockIntervalMilliseconds = consensusTargetBlockIntervalMilliseconds ?? ConsensusTargetBlockIntervalMilliseconds;
ConsensusProposeSecondBase = consensusProposeSecondBase ?? ConsensusProposeSecondBase;
MaxTransactionPerBlock = maxTransactionPerBlock ?? MaxTransactionPerBlock;
SentryDsn = sentryDsn ?? SentryDsn;
SentryTraceSampleRate = sentryTraceSampleRate ?? SentryTraceSampleRate;
Expand Down
6 changes: 5 additions & 1 deletion NineChronicles.Headless.Executable/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ public async Task Run(
[Option("consensus-target-block-interval",
Description = "A target block interval used in consensus context. The unit is millisecond.")]
double? consensusTargetBlockIntervalMilliseconds = null,
[Option("consensus-propose-second-base",
Description = "A propose second base for consensus context timeout. The unit is second.")]
int? consensusProposeSecondBase = null,
[Option("maximum-transaction-per-block",
Description = "Maximum transactions allowed in a block. null by default.")]
int? maxTransactionPerBlock = null,
Expand Down Expand Up @@ -304,7 +307,7 @@ public async Task Run(
logActionRenders, confirmations,
txLifeTime, messageTimeout, tipTimeout, demandBuffer, skipPreload,
minimumBroadcastTarget, bucketSize, chainTipStaleBehaviorType, txQuotaPerSigner, maximumPollPeers,
consensusPort, consensusPrivateKeyString, consensusSeedStrings, consensusTargetBlockIntervalMilliseconds,
consensusPort, consensusPrivateKeyString, consensusSeedStrings, consensusTargetBlockIntervalMilliseconds, consensusProposeSecondBase,
maxTransactionPerBlock, sentryDsn, sentryTraceSampleRate, arenaParticipantsSyncInterval
);

Expand Down Expand Up @@ -406,6 +409,7 @@ public async Task Run(
consensusPrivateKeyString: headlessConfig.ConsensusPrivateKeyString,
consensusSeedStrings: headlessConfig.ConsensusSeedStrings,
consensusTargetBlockIntervalMilliseconds: headlessConfig.ConsensusTargetBlockIntervalMilliseconds,
consensusProposeSecondBase: headlessConfig.ConsensusProposeSecondBase,
maximumPollPeers: headlessConfig.MaximumPollPeers,
actionEvaluatorConfiguration: actionEvaluatorConfiguration
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Libplanet.Net;
using Libplanet.Headless.Hosting;
using Libplanet.Headless;
using Libplanet.Net.Consensus;
using Nekoyume;

namespace NineChronicles.Headless.Properties
Expand Down Expand Up @@ -93,6 +94,7 @@ public static LibplanetNodeServiceProperties
string? consensusPrivateKeyString = null,
string[]? consensusSeedStrings = null,
double? consensusTargetBlockIntervalMilliseconds = null,
int? consensusProposeSecondBase = null,
IActionEvaluatorConfiguration? actionEvaluatorConfiguration = null)
{
var swarmPrivateKey = string.IsNullOrEmpty(swarmPrivateKeyString)
Expand All @@ -109,6 +111,10 @@ public static LibplanetNodeServiceProperties
var peers = peerStrings.Select(PropertyParser.ParsePeer).ToImmutableArray();
var consensusSeeds = consensusSeedStrings?.Select(PropertyParser.ParsePeer).ToImmutableList();

var consensusContextTimeoutOption = consensusProposeSecondBase.HasValue
? new ContextTimeoutOption(consensusProposeSecondBase.Value)
: new ContextTimeoutOption();

return new LibplanetNodeServiceProperties
{
Host = swarmHost,
Expand Down Expand Up @@ -144,6 +150,7 @@ public static LibplanetNodeServiceProperties
ConsensusSeeds = consensusSeeds,
ConsensusPrivateKey = consensusPrivateKey,
ConsensusTargetBlockIntervalMilliseconds = consensusTargetBlockIntervalMilliseconds,
ContextTimeoutOption = consensusContextTimeoutOption,
ActionEvaluatorConfiguration = actionEvaluatorConfiguration ?? new DefaultActionEvaluatorConfiguration(),
};
}
Expand Down

0 comments on commit a2c3811

Please sign in to comment.