Skip to content

Commit

Permalink
Merge pull request #1562 from ergoplatform/v4.0.21
Browse files Browse the repository at this point in the history
Candidate for 4.0.21
  • Loading branch information
kushti authored Jan 17, 2022
2 parents 43ec620 + 5388bf6 commit b925ac9
Show file tree
Hide file tree
Showing 74 changed files with 665 additions and 430 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ To run specific Ergo version `<VERSION>` as a service with custom config `/path/
-e MAX_HEAP=3G \
ergoplatform/ergo:<VERSION> --<networkId> -c /etc/myergo.conf

Available versions can be found on [Ergo Docker image page](https://hub.docker.com/r/ergoplatform/ergo/tags), for example, `v4.0.20.2`.
Available versions can be found on [Ergo Docker image page](https://hub.docker.com/r/ergoplatform/ergo/tags), for example, `v4.0.21`.

This will connect to the Ergo mainnet or testnet following your configuration passed in `myergo.conf` and network flag `--<networkId>`. Every default config value would be overwritten with corresponding value in `myergo.conf`. `MAX_HEAP` variable can be used to control how much memory can the node consume.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.ergoplatform.nodeView.history.ErgoHistory
import org.ergoplatform.nodeView.history.storage.modifierprocessors.{FullBlockPruningProcessor, ToDownloadProcessor}
import org.ergoplatform.nodeView.state.{ErgoState, StateType}
import org.ergoplatform.nodeView.{ErgoNodeViewRef, NVBenchmark}
import org.ergoplatform.settings.{Args, ErgoSettings}
import org.ergoplatform.settings.{Args, ErgoSettings, LaunchParameters}
import org.ergoplatform.nodeView.ErgoNodeViewHolder.CurrentView
import org.ergoplatform.nodeView.ErgoNodeViewHolder.ReceivableMessages.{GetDataFromCurrentView, LocallyGeneratedModifier}
import scorex.core.utils.{NetworkTimeProvider, NetworkTimeProviderSettings}
Expand Down Expand Up @@ -44,7 +44,7 @@ object BenchRunner extends ScorexLogging with NVBenchmark {
val ntpSettings = NetworkTimeProviderSettings("pool.ntp.org", 30 minutes, 30 seconds)
val timeProvider = new NetworkTimeProvider(ntpSettings)

val nodeViewHolderRef: ActorRef = ErgoNodeViewRef(ergoSettings, timeProvider)
val nodeViewHolderRef: ActorRef = ErgoNodeViewRef(ergoSettings, timeProvider, LaunchParameters)

/**
* It's a hack to set minimalFullBlockHeightVar to 0 and to avoid "Header Is Not Synced" error, cause
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.ergoplatform.bench

import java.io.File

import akka.actor.ActorRef
import org.ergoplatform.bench.misc.{CrawlerConfig, TempDir}
import org.ergoplatform.http.api.{BlocksApiRoute, ErgoUtilsApiRoute, InfoApiRoute, TransactionsApiRoute}
Expand All @@ -10,7 +11,7 @@ import org.ergoplatform.mining.emission.EmissionRules
import org.ergoplatform.network.{ErgoNodeViewSynchronizer, ErgoSyncTracker}
import org.ergoplatform.nodeView.history.ErgoSyncInfoMessageSpec
import org.ergoplatform.nodeView.{ErgoNodeViewRef, ErgoReadersHolderRef}
import org.ergoplatform.settings.{Args, ErgoSettings}
import org.ergoplatform.settings.{Args, ErgoSettings, LaunchParameters}
import scorex.core.api.http.ApiRoute
import scorex.core.app.Application
import scorex.core.network.PeerFeature
Expand Down Expand Up @@ -42,19 +43,20 @@ class CrawlerRunner(args: Array[String]) extends Application {
override implicit lazy val settings: ScorexSettings = ergoSettings.scorexSettings

override protected lazy val additionalMessageSpecs: Seq[MessageSpec[_]] = Seq(ErgoSyncInfoMessageSpec)
override val nodeViewHolderRef: ActorRef = ErgoNodeViewRef(ergoSettings, timeProvider)
override val nodeViewHolderRef: ActorRef = ErgoNodeViewRef(ergoSettings, timeProvider, LaunchParameters)

val readersHolderRef: ActorRef = ErgoReadersHolderRef(nodeViewHolderRef)

val minerRef: ActorRef = ErgoMiner(ergoSettings, nodeViewHolderRef, readersHolderRef, timeProvider)

val statsCollectorRef: ActorRef = ErgoStatsCollectorRef(nodeViewHolderRef, networkControllerRef, ergoSettings, timeProvider)
val statsCollectorRef: ActorRef =
ErgoStatsCollectorRef(nodeViewHolderRef, networkControllerRef, ergoSettings, timeProvider, LaunchParameters)

override val apiRoutes: Seq[ApiRoute] = Seq(
ErgoUtilsApiRoute(ergoSettings),
InfoApiRoute(statsCollectorRef, settings.restApi, timeProvider),
BlocksApiRoute(nodeViewHolderRef, readersHolderRef, ergoSettings),
TransactionsApiRoute(readersHolderRef, nodeViewHolderRef, settings.restApi))
TransactionsApiRoute(readersHolderRef, nodeViewHolderRef, ergoSettings))

override val swaggerConfig: String = Source.fromResource("api/openapi.yaml").getLines.mkString("\n")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ object TransactionExecutionBenchmark extends HistoryTestHelpers with NVBenchmark

val WarmupRuns = 3

def stateContextWithMaxCost(manualCost: Int): UpcomingStateContext = {
val table2: Map[Byte, Int] = Parameters.DefaultParameters + (MaxBlockCostIncrease -> manualCost)
val params2 = new Parameters(height = 0,
parametersTable = table2,
proposedUpdate = ErgoValidationSettingsUpdate.empty)
emptyStateContext.copy(currentParameters = params2)(settings)
}
override val parameters =
new Parameters(height = 0,
parametersTable = Parameters.DefaultParameters + (MaxBlockCostIncrease -> Int.MaxValue),
proposedUpdate = ErgoValidationSettingsUpdate.empty
)

def main(args: Array[String]): Unit = {

Expand All @@ -41,10 +39,9 @@ object TransactionExecutionBenchmark extends HistoryTestHelpers with NVBenchmark
}.result()

val boxes = bh.boxes
val stateContext = stateContextWithMaxCost(Int.MaxValue)
def bench: Long =
Utils.time {
assert(ErgoState.execTransactions(txs, stateContext)(id => Try(boxes(ByteArrayWrapper(id)))) == Valid(178665000))
assert(ErgoState.execTransactions(txs, emptyStateContext)(id => Try(boxes(ByteArrayWrapper(id)))) == Valid(178665000))
}.toLong

(0 to WarmupRuns).foreach(_ => bench)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object UtxoStateBenchmark extends HistoryTestHelpers with NVBenchmark {
val transactionsQty = blocks.flatMap(_.transactions).size

def bench(mods: Seq[ErgoPersistentModifier]): Long = {
val state = ErgoState.generateGenesisUtxoState(createTempDir, StateConstants(None, realNetworkSetting))._1
val state = ErgoState.generateGenesisUtxoState(createTempDir, StateConstants(None, realNetworkSetting), parameters)._1
Utils.time {
mods.foldLeft(state) { case (st, mod) =>
st.applyModifier(mod).get
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-async" % "0.9.7" % "test",
"com.storm-enroute" %% "scalameter" % "0.8.+" % "test",
"org.scalactic" %% "scalactic" % "3.0.3" % "test",
"org.scalatest" %% "scalatest" % "3.1.1" % "test,it",
"org.scalatest" %% "scalatest" % "3.2.10" % "test,it",
"org.scalacheck" %% "scalacheck" % "1.14.+" % "test",
"org.scalatestplus" %% "scalatestplus-scalacheck" % "3.1.0.0-RC2" % Test,

Expand Down
4 changes: 2 additions & 2 deletions src/it/scala/org/ergoplatform/it/WalletSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.ergoplatform.it.util.RichEither
import org.ergoplatform.modifiers.mempool.UnsignedErgoTransaction
import org.ergoplatform.nodeView.wallet.requests.{PaymentRequest, PaymentRequestEncoder, RequestsHolder, RequestsHolderEncoder}
import org.ergoplatform.nodeView.wallet.{AugWalletTransaction, ErgoWalletServiceImpl}
import org.ergoplatform.settings.{Args, ErgoSettings, LaunchParameters}
import org.ergoplatform.settings.{Args, ErgoSettings}
import org.ergoplatform.utils.{ErgoTestHelpers, WalletTestOps}
import org.ergoplatform.wallet.interface4j.SecretString
import org.ergoplatform.wallet.boxes.ErgoBoxSerializer
Expand Down Expand Up @@ -71,7 +71,7 @@ class WalletSpec extends AsyncWordSpec with IntegrationSuite with WalletTestOps
"it should generate unsigned transaction" in {
import sigmastate.eval._
val mnemonic = SecretString.create(walletAutoInitConfig.getString("ergo.wallet.testMnemonic"))
val prover = new ErgoWalletServiceImpl().buildProverFromMnemonic(mnemonic, None, LaunchParameters)
val prover = new ErgoWalletServiceImpl().buildProverFromMnemonic(mnemonic, None, parameters)
val pk = prover.hdPubKeys.head.key
val ergoTree = ErgoTree.fromProposition(TrueLeaf)
val transactionId = ModifierId @@ Base16.encode(Array.fill(32)(5: Byte))
Expand Down
19 changes: 9 additions & 10 deletions src/main/resources/api/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: "3.0.2"

info:
version: "4.0.20.2"
version: "4.0.21"
title: Ergo Node API
description: API docs for Ergo Node. Models are shared between all Ergo products
contact:
Expand Down Expand Up @@ -1343,10 +1343,8 @@ components:
minimum: 0
example: 667
difficulty:
type: integer
format: int32
minimum: 0
example: 62
type: string
example: '9575989248'
parentId:
$ref: '#/components/schemas/ModifierId'
votes:
Expand Down Expand Up @@ -1701,11 +1699,12 @@ components:
example: 327
difficulty:
type: integer
format: int32
minimum: 0
nullable: true
example: 667
description: Difficulty on current bestFullHeaderId. Can be 'null' if no full block is applied since node launch
description: >
Difficulty on current bestFullHeaderId. Can be 'null' if no full block is applied since node launch.
Difficulty is a BigInt integer.
currentTime:
type: integer
description: Current internal node time
Expand All @@ -1718,11 +1717,11 @@ components:
- $ref: '#/components/schemas/Timestamp'
headersScore:
type: integer
description: Can be 'null' if no headers is applied since node launch
description: Can be 'null' if no headers is applied since node launch. headersScore is a BigInt integer.
nullable: true
fullBlocksScore:
type: integer
description: Can be 'null' if no full block is applied since node launch
description: Can be 'null' if no full block is applied since node launch. fullBlocksScore is a BigInt integer.
nullable: true
genesisBlockId:
type: string
Expand Down Expand Up @@ -4081,7 +4080,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/SerializedAdProof:
$ref: '#/components/schemas/SerializedAdProof'
'400':
description: Prove error
content:
Expand Down
12 changes: 9 additions & 3 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ ergo {
# Is the node is doing mining
mining = false

# Node will only include transactions to own blocks with lower complexity
maxTransactionComplexity = 250000
# maximum cost of transaction for it to be propagated
maxTransactionCost = 1000000

# Use external miner, native miner is used if set to `false`
useExternalMiner = true
Expand All @@ -50,6 +50,9 @@ ergo {
# Number of state snapshot diffs to keep. Defines maximum rollback depth
keepVersions = 200

# Acceptable difference between NOW and timestamp of the latest chain update or best block. This helps to discover syncing issues.
acceptableChainUpdateDelay = 15m

# Maximum number of unconfirmed transactions node can accept
mempoolCapacity = 1000

Expand Down Expand Up @@ -288,6 +291,9 @@ akka {
server {
request-timeout = 1 minute
}
parsing {
max-uri-length = 8192
}
}
}

Expand Down Expand Up @@ -338,7 +344,7 @@ scorex {
nodeName = "ergo-node"

# Network protocol version to be sent in handshakes
appVersion = 4.0.20.2
appVersion = 4.0.21

# Network agent name. May contain information about client code
# stack, starting from core code-base up to the end graphical interface.
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
<level>${logback.file.level:-DEBUG}</level>
</filter>
<file>ergo.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>ergo.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
<fileNamePattern>ergo-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>

<!-- keep 30 days' worth of history capped at 1GB total size -->
<maxHistory>30</maxHistory>
<maxFileSize>500MB</maxFileSize>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>

<encoder>
<pattern>${default.pattern}</pattern>
</encoder>
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/mainnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ ergo {

# List with hex-encoded identifiers of transactions banned from getting into memory pool
blacklistedTransactions = []

# maximum cost of transaction for it to be propagated
maxTransactionCost = 5000000
}
}

scorex {
network {
magicBytes = [1, 0, 2, 4]
bindAddress = "0.0.0.0:9030"
nodeName = "ergo-mainnet-4.0.20.2"
nodeName = "ergo-mainnet-4.0.21"
nodeName = ${?NODENAME}
knownPeers = [
"213.239.193.208:9030",
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/testnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ ergo {
# than headerChainDiff blocks on average from future
# testnet value is 800 blocks ~= 1600 minutes (~1.1 days)
headerChainDiff = 800

# having more internal miner threads helps to reproduce real use cases, like 100 GPU miners
internalMinersCount = 1

# GPU miners are currently polling at 100ms interval
internalMinerPollingInterval = 200ms

# maximum cost of transaction for it to be propagated
maxTransactionCost = 800000
}

chain {
Expand Down Expand Up @@ -56,7 +61,7 @@ scorex {
network {
magicBytes = [2, 0, 0, 2]
bindAddress = "0.0.0.0:9020"
nodeName = "ergo-testnet-4.0.20.2"
nodeName = "ergo-testnet-4.0.21"
nodeName = ${?NODENAME}
knownPeers = [
"213.239.193.208:9020",
Expand Down
10 changes: 6 additions & 4 deletions src/main/scala/org/ergoplatform/ErgoApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.ergoplatform.mining.ErgoMiner.StartMining
import org.ergoplatform.network.{ErgoNodeViewSynchronizer, ErgoSyncTracker, ModeFeature}
import org.ergoplatform.nodeView.history.ErgoSyncInfoMessageSpec
import org.ergoplatform.nodeView.{ErgoNodeViewRef, ErgoReadersHolderRef}
import org.ergoplatform.settings.{Args, ErgoSettings, NetworkType}
import org.ergoplatform.settings.{Args, ErgoSettings, LaunchParameters, NetworkType}
import scorex.core.api.http._
import scorex.core.app.ScorexContext
import scorex.core.network.NetworkController.ReceivableMessages.ShutdownNetwork
Expand Down Expand Up @@ -86,7 +86,9 @@ class ErgoApp(args: Args) extends ScorexLogging {
private val networkControllerRef: ActorRef = NetworkControllerRef(
"networkController", scorexSettings.network, peerManagerRef, scorexContext)

private val nodeViewHolderRef: ActorRef = ErgoNodeViewRef(ergoSettings, timeProvider)
private val parameters = LaunchParameters

private val nodeViewHolderRef: ActorRef = ErgoNodeViewRef(ergoSettings, timeProvider, parameters)

private val readersHolderRef: ActorRef = ErgoReadersHolderRef(nodeViewHolderRef)

Expand All @@ -99,7 +101,7 @@ class ErgoApp(args: Args) extends ScorexLogging {
}

private val statsCollectorRef: ActorRef =
ErgoStatsCollectorRef(readersHolderRef, networkControllerRef, ergoSettings, timeProvider)
ErgoStatsCollectorRef(readersHolderRef, networkControllerRef, ergoSettings, timeProvider, parameters)

private val syncTracker = ErgoSyncTracker(actorSystem, scorexSettings.network, timeProvider)

Expand All @@ -123,7 +125,7 @@ class ErgoApp(args: Args) extends ScorexLogging {
InfoApiRoute(statsCollectorRef, scorexSettings.restApi, timeProvider),
BlocksApiRoute(nodeViewHolderRef, readersHolderRef, ergoSettings),
NipopowApiRoute(nodeViewHolderRef, readersHolderRef, ergoSettings),
TransactionsApiRoute(readersHolderRef, nodeViewHolderRef, scorexSettings.restApi),
TransactionsApiRoute(readersHolderRef, nodeViewHolderRef, ergoSettings),
WalletApiRoute(readersHolderRef, nodeViewHolderRef, ergoSettings),
UtxoApiRoute(readersHolderRef, scorexSettings.restApi),
ScriptApiRoute(readersHolderRef, ergoSettings),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ import org.ergoplatform.nodeView.mempool.ErgoMemPoolReader
import org.ergoplatform.nodeView.mempool.HistogramStats.getFeeHistogram
import org.ergoplatform.nodeView.state.{ErgoStateReader, UtxoStateReader}
import org.ergoplatform.nodeView.ErgoNodeViewHolder.ReceivableMessages.LocallyGeneratedTransaction
import org.ergoplatform.settings.ErgoSettings
import scorex.core.api.http.ApiError.BadRequest
import scorex.core.api.http.ApiResponse
import scorex.core.settings.RESTApiSettings

import scala.concurrent.Future

case class TransactionsApiRoute(readersHolder: ActorRef, nodeViewActorRef: ActorRef, settings: RESTApiSettings)
case class TransactionsApiRoute(readersHolder: ActorRef,
nodeViewActorRef: ActorRef,
ergoSettings: ErgoSettings)
(implicit val context: ActorRefFactory) extends ErgoBaseApiRoute with ApiCodecs {

override val settings: RESTApiSettings = ergoSettings.scorexSettings.restApi

val txPaging: Directive[(Int, Int)] = parameters("offset".as[Int] ? 0, "limit".as[Int] ? 50)

Expand Down Expand Up @@ -48,7 +52,8 @@ case class TransactionsApiRoute(readersHolder: ActorRef, nodeViewActorRef: Actor
getStateAndPool
.map {
case (utxo: UtxoStateReader, mp: ErgoMemPoolReader) =>
utxo.withMempool(mp).validate(tx)
val maxTxCost = ergoSettings.nodeSettings.maxTransactionCost
utxo.withMempool(mp).validateWithCost(tx, maxTxCost)
case _ =>
tx.statelessValidity()
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/org/ergoplatform/local/CleanupWorker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class CleanupWorker(nodeViewHolderRef: ActorRef,
}

val t0 = System.nanoTime()
val validationResult = state.validate(head)
val validationResult = state.validateWithCost(head, nodeSettings.maxTransactionCost)
val t1 = System.nanoTime()
val accumulatedTime = etAcc + (t1 - t0)

Expand Down
Loading

0 comments on commit b925ac9

Please sign in to comment.