From bfc827b167c778835327ad6abfd19ff42f31f333 Mon Sep 17 00:00:00 2001 From: Artyom Sayadyan Date: Fri, 14 Oct 2022 09:29:34 +0300 Subject: [PATCH] NODE-2504 Check genesis generator average and min block time (#3761) --- .../scala/com/wavesplatform/GenesisBlockGenerator.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/node/src/main/scala/com/wavesplatform/GenesisBlockGenerator.scala b/node/src/main/scala/com/wavesplatform/GenesisBlockGenerator.scala index b3cce2edfe1..599247ee703 100644 --- a/node/src/main/scala/com/wavesplatform/GenesisBlockGenerator.scala +++ b/node/src/main/scala/com/wavesplatform/GenesisBlockGenerator.scala @@ -223,7 +223,12 @@ object GenesisBlockGenerator { def inverseCalculateDelay(balance: Long, hitRate: Double): Int = posCalculator match { case FairPoSCalculator(minBlockTime, _) => - val z = (1 - Math.exp((settings.averageBlockDelay.toMillis - minBlockTime) / 70000.0)) * balance + val averageBlockDelay = settings.averageBlockDelay.toMillis + require( + averageBlockDelay > minBlockTime, + s"average-block-delay: ${averageBlockDelay}ms should be > min-block-time: ${minBlockTime}ms" + ) + val z = (1 - Math.exp((averageBlockDelay - minBlockTime) / 70000.0)) * balance (5e17 * (Math.log(hitRate) / z)).toInt case NxtPoSCalculator => (FairPoSCalculator.MaxHit * hitRate / settings.averageBlockDelay.toSeconds / balance).toInt