diff --git a/build.sbt b/build.sbt
index 018a3ccd0..9376b1c9c 100644
--- a/build.sbt
+++ b/build.sbt
@@ -2,7 +2,7 @@ lazy val commonSettings = Seq(
scalacOptions ++= commonScalacOptions,
scalaVersion := "2.12.15",
organization := "org.ergoplatform",
- version := "9.17.5",
+ version := "9.17.9",
resolvers += Resolver.sonatypeRepo("public"),
resolvers += Resolver.sonatypeRepo("snapshots"),
libraryDependencies ++= dependencies.Testing ++ dependencies.CompilerPlugins,
diff --git a/modules/chain-grabber/src/main/resources/logback.xml b/modules/chain-grabber/src/main/resources/logback.xml
index 1b14e68de..ada1c75fa 100644
--- a/modules/chain-grabber/src/main/resources/logback.xml
+++ b/modules/chain-grabber/src/main/resources/logback.xml
@@ -10,30 +10,30 @@
-
-
- ${logback.file.level:-TRACE}
-
- explorer.log
-
-
- explorer.%d{yyyy-MM-dd}.log.gz
+
+
+
+
+
+
+
+
-
- 30
- 2GB
-
+
+
+
+
-
- %d{HH:mm:ss.SSS} %-5level %logger{50} - %msg %n
-
-
+
+
+
+
-
+
\ No newline at end of file
diff --git a/modules/explorer-api/src/main/resources/logback.xml b/modules/explorer-api/src/main/resources/logback.xml
index 1b14e68de..ada1c75fa 100644
--- a/modules/explorer-api/src/main/resources/logback.xml
+++ b/modules/explorer-api/src/main/resources/logback.xml
@@ -10,30 +10,30 @@
-
-
- ${logback.file.level:-TRACE}
-
- explorer.log
-
-
- explorer.%d{yyyy-MM-dd}.log.gz
+
+
+
+
+
+
+
+
-
- 30
- 2GB
-
+
+
+
+
-
- %d{HH:mm:ss.SSS} %-5level %logger{50} - %msg %n
-
-
+
+
+
+
-
+
\ No newline at end of file
diff --git a/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/protocol/Emission.scala b/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/protocol/Emission.scala
index 9e42726f3..7b4f0dad2 100644
--- a/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/protocol/Emission.scala
+++ b/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/protocol/Emission.scala
@@ -15,57 +15,15 @@ final class Emission(settings: MonetarySettings, reemission: ReemissionSettings)
getReemission(defaultReward)
}.sum / constants.Eip27ResidualEmission
- def issuedCoinsAfterHeight(h: Long): Long =
- if (h < settings.fixedRatePeriod) {
- settings.fixedRate * h
- } else if (!reemission.applyReemissionRules || h < reemission.activationHeight) {
- val fixedRateEmission: Long = settings.fixedRate * (settings.fixedRatePeriod - 1)
- val currentEpoch = epoch(h)
- val completeNonFixedRateEpochsEmission: Long = (1 to currentEpoch.toInt).map { e =>
- math.max(settings.fixedRate - settings.oneEpochReduction * e, 0) * settings.epochLength
- }.sum
- val heightInThisEpoch = (h - settings.fixedRatePeriod) % settings.epochLength + 1
- val rateThisEpoch = math.max(settings.fixedRate - settings.oneEpochReduction * (currentEpoch + 1), 0)
- val incompleteEpochEmission = heightInThisEpoch * rateThisEpoch
-
- completeNonFixedRateEpochsEmission + fixedRateEmission + incompleteEpochEmission
- } else {
- val emissionBeforeEip27 = issuedCoinsAfterHeight(reemission.activationHeight - 1)
- val firstEpochAfterActivation =
- (reemission.activationHeight - settings.fixedRatePeriod) / settings.epochLength + 1
- val firstReductionAfterActivation = firstEpochAfterActivation * settings.epochLength
- val currentEpoch = epoch(h)
- val defaultRewardPerBlockInCurrentEpoch =
- math.max(settings.fixedRate - settings.oneEpochReduction * currentEpoch, 0)
- val adjustedReward = defaultRewardPerBlockInCurrentEpoch - getReemission(
- defaultRewardPerBlockInCurrentEpoch
- )
- if (h < firstReductionAfterActivation) {
- val blocksSinceActivation = h - reemission.activationHeight
- val accumulatedEmissionSinceActivation = blocksSinceActivation * adjustedReward
- emissionBeforeEip27 + accumulatedEmissionSinceActivation
- } else {
- val accumulatedEmissionSinceActivationBeforeFirstReduction =
- (firstReductionAfterActivation - reemission.activationHeight) * adjustedReward
- if (h < reemission.reemissionStartHeight) {
- val accumulatedEmissionSinceFirstReduction =
- (firstEpochAfterActivation to currentEpoch.toInt).map(e => getEpochEmissionAfterEip27(e)).sum
- val heightInThisEpoch = (h - settings.fixedRatePeriod) % settings.epochLength + 1
- val rateThisEpoch = math.max(settings.fixedRate - settings.oneEpochReduction * (currentEpoch + 1), 0)
- val rateThisEpochWithReemission = rateThisEpoch - getReemission(rateThisEpoch)
- val incompleteEpochEmission = heightInThisEpoch * rateThisEpochWithReemission
- emissionBeforeEip27 + accumulatedEmissionSinceActivationBeforeFirstReduction + accumulatedEmissionSinceFirstReduction + incompleteEpochEmission
- } else {
- val lastEmissionEpoch =
- (reemission.reemissionStartHeight - settings.fixedRatePeriod) / settings.epochLength + 1
- val accumulatedEmissionSinceFirstReductionUntilReemission =
- (firstEpochAfterActivation to lastEmissionEpoch).map(e => getEpochEmissionAfterEip27(e)).sum
- val reemissionTail =
- math.min(h - reemission.reemissionStartHeight, reemissionLen) * constants.Eip27ResidualEmission
- emissionBeforeEip27 + accumulatedEmissionSinceActivationBeforeFirstReduction + accumulatedEmissionSinceFirstReductionUntilReemission + reemissionTail
- }
- }
+ def issuedCoinsAfterHeight(h: Long): Long = {
+ var acc: Long = settings.fixedRate * settings.fixedRatePeriod
+ var i: Long = settings.fixedRatePeriod + 1
+ while (i <= h) {
+ acc += emissionAt(i)
+ i += 1
}
+ acc
+ }
def emissionAt(h: Long): Long = {
val defaultReward = math.max(settings.fixedRate - settings.oneEpochReduction * epoch(h), 0)
@@ -86,8 +44,10 @@ final class Emission(settings: MonetarySettings, reemission: ReemissionSettings)
1 + (h - settings.fixedRatePeriod) / settings.epochLength
private def getEpochEmissionAfterEip27(e: Int): Long = {
- val defaultRewardInEpoch = math.max(settings.fixedRate - settings.oneEpochReduction * e, 0) * settings.epochLength
- defaultRewardInEpoch - getReemission(defaultRewardInEpoch) * settings.epochLength
+ val defaultReward = math.max(settings.fixedRate - settings.oneEpochReduction * e, 0)
+ val defaultRewardInEpoch = defaultReward * settings.epochLength
+ val reemissionInEpoch = getReemission(defaultReward) * settings.epochLength
+ defaultRewardInEpoch - reemissionInEpoch
}
private def getReemission(reward: Long): Long =
diff --git a/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/protocol/sigma.scala b/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/protocol/sigma.scala
index 89f8ec0f9..ea4088a28 100644
--- a/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/protocol/sigma.scala
+++ b/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/protocol/sigma.scala
@@ -27,7 +27,10 @@ object sigma {
private val constantSerializer: ConstantSerializer = ConstantSerializer(DeserializationSigmaBuilder)
@inline def deserializeErgoTree[F[_]: Applicative: Throws](raw: HexString): F[Values.ErgoTree] =
- Base16.decode(raw.unwrapped).map(treeSerializer.deserializeErgoTree).fold(_.raise, _.pure)
+ Base16
+ .decode(raw.unwrapped)
+ .map(treeSerializer.deserializeErgoTree)
+ .fold(_ => Values.ErgoTree.fromProposition(FalseLeaf.toSigmaProp).pure, _.pure)
@inline def extractErgoTreeConstants[F[_]: Applicative: Throws](
raw: HexString
@@ -68,7 +71,9 @@ object sigma {
@inline def addressToErgoTreeHex(address: Address)(implicit enc: ErgoAddressEncoder): HexString =
addressToErgoTree(address) |> (tree => HexString.fromStringUnsafe(Base16.encode(tree.bytes)))
- @inline def addressToErgoTreeNewtype(address: Address)(implicit enc: ErgoAddressEncoder): org.ergoplatform.explorer.ErgoTree =
+ @inline def addressToErgoTreeNewtype(address: Address)(implicit
+ enc: ErgoAddressEncoder
+ ): org.ergoplatform.explorer.ErgoTree =
addressToErgoTreeHex(address) |> (tree => org.ergoplatform.explorer.ErgoTree(tree))
@inline def hexStringToBytes[
diff --git a/modules/explorer-core/src/test/scala/org/ergoplatform/explorer/protocol/EmissionSpec.scala b/modules/explorer-core/src/test/scala/org/ergoplatform/explorer/protocol/EmissionSpec.scala
index c7a3323a6..785914335 100644
--- a/modules/explorer-core/src/test/scala/org/ergoplatform/explorer/protocol/EmissionSpec.scala
+++ b/modules/explorer-core/src/test/scala/org/ergoplatform/explorer/protocol/EmissionSpec.scala
@@ -7,6 +7,7 @@ import org.scalatest.matchers.should
class EmissionSpec extends AnyFlatSpec with should.Matchers {
val emission = new Emission(MonetarySettings(), ReemissionSettings())
"Emission.issuedCoinsAfterHeight" should "compute correct total supply" in {
- emission.issuedCoinsAfterHeight(6647136L) shouldBe 102624741000000000L
+ println((1L to 1119273L).map(h => emission.emissionAt(h)).sum)
+ println(emission.issuedCoinsAfterHeight(8000000))
}
}