Skip to content

Commit

Permalink
Merge pull request #1766 from ergoplatform/v4.0.35
Browse files Browse the repository at this point in the history
Candidate for 4.0.35
  • Loading branch information
kushti authored Jul 25, 2022
2 parents a4d1e62 + 31c5a6d commit 66ae8ad
Show file tree
Hide file tree
Showing 111 changed files with 802 additions and 735 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.34`.
Available versions can be found on [Ergo Docker image page](https://hub.docker.com/r/ergoplatform/ergo/tags), for example, `v4.0.35`.

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
4 changes: 1 addition & 3 deletions avldb/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ libraryDependencies ++= Seq(
)

testOptions in Test := Seq(Tests.Filter(t => !t.matches(".*Benchmark$")))
javaOptions in run += "-Xmx12G"

//scalacOptions ++= Seq("-Xdisable-assertions")
javaOptions in run += "-Xmx6G"

publishMavenStyle := true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.ergoplatform

import org.ergoplatform.Utils.BenchReport
import org.ergoplatform.modifiers.ErgoPersistentModifier
import org.ergoplatform.modifiers.BlockSection
import org.ergoplatform.modifiers.history.extension.Extension
import org.ergoplatform.modifiers.history.BlockTransactions
import org.ergoplatform.modifiers.history.header.Header
Expand All @@ -25,17 +25,17 @@ object ModifiersApplicationBench extends HistoryTestHelpers with NVBenchmark {
val extensions: Seq[Extension] = readExtensions

def bench(benchCase: String)
(applicator: (Seq[ErgoPersistentModifier], ErgoHistory) => Any,
mods: Seq[ErgoPersistentModifier]): (String, Long) = {
(applicator: (Seq[BlockSection], ErgoHistory) => Any,
mods: Seq[BlockSection]): (String, Long) = {
val preparedHistory = applyModifiers(headers.take(mods.size / 2), unlockedHistory())._1
val et = Utils.time(applicator(mods, preparedHistory)).toLong
assert(preparedHistory.fullBlockHeight == mods.size / 2)
s"Performance of `$benchCase`: $et ms" -> et
}

def applyModifiersWithCache(mods: Seq[ErgoPersistentModifier], his: ErgoHistory): (ErgoHistory, Int) = {
def applyModifiersWithCache(mods: Seq[BlockSection], his: ErgoHistory): (ErgoHistory, Int) = {
mods.foreach(m => cache.put(m.id, m))
@tailrec def applyLoop(applied: Seq[ErgoPersistentModifier]): Seq[ErgoPersistentModifier] = {
@tailrec def applyLoop(applied: Seq[BlockSection]): Seq[BlockSection] = {
cache.popCandidate(his) match {
case Some(mod) =>
his.append(mod).get
Expand All @@ -49,9 +49,9 @@ object ModifiersApplicationBench extends HistoryTestHelpers with NVBenchmark {
his -> appliedModsQty
}

def applyModifiers(mods: Seq[ErgoPersistentModifier], his: ErgoHistory): (ErgoHistory, Int) = {
@tailrec def applyLoop(rem: Seq[ErgoPersistentModifier],
applied: Seq[ErgoPersistentModifier]): Seq[ErgoPersistentModifier] = {
def applyModifiers(mods: Seq[BlockSection], his: ErgoHistory): (ErgoHistory, Int) = {
@tailrec def applyLoop(rem: Seq[BlockSection],
applied: Seq[BlockSection]): Seq[BlockSection] = {
rem match {
case m :: tail =>
his.applicableTry(m)
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/test/scala/org/ergoplatform/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.net.URL

import com.google.common.primitives.Ints
import javax.net.ssl.HttpsURLConnection
import org.ergoplatform.modifiers.ErgoPersistentModifier
import org.ergoplatform.modifiers.BlockSection
import org.ergoplatform.modifiers.history.HistoryModifierSerializer

object Utils {
Expand All @@ -31,7 +31,7 @@ object Utils {
def readBytes(length: Int)(implicit fis: InputStream): Option[Array[Byte]] =
Some(Stream.continually(fis.read().toByte).take(length).toArray)

def readModifier[M <: ErgoPersistentModifier](implicit fis: InputStream): Option[M] = {
def readModifier[M <: BlockSection](implicit fis: InputStream): Option[M] = {
for {
length <- readLength
bytes <- readBytes(length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.ergoplatform.bench

import akka.actor.{ActorRef, ActorSystem}
import org.ergoplatform.bench.misc.TempDir
import org.ergoplatform.modifiers.ErgoPersistentModifier
import org.ergoplatform.modifiers.BlockSection
import org.ergoplatform.nodeView.history.ErgoHistory
import org.ergoplatform.nodeView.history.storage.modifierprocessors.{FullBlockPruningProcessor, ToDownloadProcessor}
import org.ergoplatform.nodeView.state.{ErgoState, StateType}
Expand Down Expand Up @@ -71,7 +71,7 @@ object BenchRunner extends ScorexLogging with NVBenchmark {
()
}

private def runBench(benchRef: ActorRef, nodeRef: ActorRef, modifiers: Vector[ErgoPersistentModifier]): Unit = {
private def runBench(benchRef: ActorRef, nodeRef: ActorRef, modifiers: Vector[BlockSection]): Unit = {
benchRef ! BenchActor.Start
modifiers.foreach { m => nodeRef ! LocallyGeneratedModifier(m) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CrawlerRunner(args: Array[String]) extends Application {

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

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

val statsCollectorRef: ActorRef =
ErgoStatsCollectorRef(nodeViewHolderRef, networkControllerRef, syncTracker, ergoSettings, timeProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import java.io.{InputStream, OutputStream}

import com.google.common.primitives.Ints
import org.ergoplatform.Utils._
import org.ergoplatform.modifiers.ErgoPersistentModifier
import org.ergoplatform.modifiers.BlockSection
import org.ergoplatform.modifiers.history._
import org.ergoplatform.modifiers.history.header.{Header, HeaderSerializer}
import scorex.core.serialization.ScorexSerializer
import scorex.core.{ModifierTypeId, NodeViewModifier}

object ModifierWriter {

val modifierSerializers: Map[ModifierTypeId, ScorexSerializer[_ <: ErgoPersistentModifier]] =
val modifierSerializers: Map[ModifierTypeId, ScorexSerializer[_ <: BlockSection]] =
Map(Header.modifierTypeId -> HeaderSerializer,
BlockTransactions.modifierTypeId -> BlockTransactionsSerializer,
ADProofs.modifierTypeId -> ADProofsSerializer)
Expand All @@ -27,7 +27,7 @@ object ModifierWriter {
fos.flush()
}

def read(implicit fis: InputStream): Option[ErgoPersistentModifier] = for {
def read(implicit fis: InputStream): Option[BlockSection] = for {
typeId <- readModId
length <- readLength
bytes <- readBytes(length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.ergoplatform.nodeView
import org.ergoplatform.Utils
import org.ergoplatform.modifiers.history.extension.Extension
import org.ergoplatform.modifiers.history.header.Header
import org.ergoplatform.modifiers.{ErgoFullBlock, ErgoPersistentModifier}
import org.ergoplatform.modifiers.{ErgoFullBlock, BlockSection}
import org.ergoplatform.modifiers.history.BlockTransactions

trait NVBenchmark {
Expand All @@ -16,7 +16,7 @@ trait NVBenchmark {
def readBlocks: Seq[ErgoFullBlock] = readHeaders.zip(readPayloads).zip(readExtensions)
.map { case ((h, txs), ext) => ErgoFullBlock(h, txs, ext, None) }

def readModifiers[M <: ErgoPersistentModifier](path: String): Seq[M] = {
def readModifiers[M <: BlockSection](path: String): Seq[M] = {
val is = Utils.getUrlInputStream(path)
Stream
.continually {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.ergoplatform.nodeView.state

import org.ergoplatform.Utils
import org.ergoplatform.Utils.BenchReport
import org.ergoplatform.modifiers.ErgoPersistentModifier
import org.ergoplatform.modifiers.BlockSection
import org.ergoplatform.nodeView.NVBenchmark
import org.ergoplatform.settings.{Args, ErgoSettings}
import org.ergoplatform.utils.HistoryTestHelpers
Expand All @@ -21,7 +21,7 @@ object UtxoStateBenchmark extends HistoryTestHelpers with NVBenchmark {

val transactionsQty = blocks.flatMap(_.transactions).size

def bench(mods: Seq[ErgoPersistentModifier]): Long = {
def bench(mods: Seq[BlockSection]): Long = {
val state = ErgoState.generateGenesisUtxoState(createTempDir, StateConstants(realNetworkSetting))._1
Utils.time {
mods.foldLeft(state) { case (st, mod) =>
Expand Down
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ val opts = Seq(
"-XX:+UseStringDeduplication"
)

// -J prefix is required by the bash script
javaOptions in run ++= opts
scalacOptions --= Seq("-Ywarn-numeric-widen", "-Ywarn-value-discard", "-Ywarn-unused:params", "-Xcheckinit")

Expand Down
2 changes: 0 additions & 2 deletions src/it/resources/devnetTemplate.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ ergo {

scorex {
network {
maxPacketSize = 2048576
maxInvObjects = 400
bindAddress = "0.0.0.0:9001"
knownPeers = []
agentName = "ergo-integration-test"
Expand Down
10 changes: 9 additions & 1 deletion 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.34"
version: "4.0.35"
title: Ergo Node API
description: API docs for Ergo Node. Models are shared between all Ergo products
contact:
Expand Down Expand Up @@ -1981,6 +1981,14 @@ components:
type: object
description: current parameters
$ref: '#/components/schemas/Parameters'
eip27Supported:
type: boolean
example: true
description: Whether EIP-27 locked in
restApiUrl:
type: string
example: 'https://example.com'
description: Publicly accessible url of node which exposes restApi in firewall

Parameters:
type: object
Expand Down
21 changes: 8 additions & 13 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ scorex {

# request processing timeout
timeout = 5s

# node which exposes restApi in firewall should define publicly accessible URL of it
# publicUrl = "https://example.com:80"
}

# P2P Network settings
Expand All @@ -388,7 +391,7 @@ scorex {
nodeName = "ergo-node"

# Network protocol version to be sent in handshakes
appVersion = 4.0.34
appVersion = 4.0.35

# Network agent name. May contain information about client code
# stack, starting from core code-base up to the end graphical interface.
Expand Down Expand Up @@ -469,9 +472,10 @@ scorex {
# Network delivery timeout
deliveryTimeout = 10s

# Max number of delivery checks. Stop expecting modifier (and penalize peer) if it was not delivered after that
# number of delivery attempts
maxDeliveryChecks = 2
# Max number of delivery checks. Stop expecting modifier if it was not delivered after that
# number of delivery attempts. The node tries to ask different peers on different attempts, and
# not increasing the delivery counter if global loss of connectivity is possible
maxDeliveryChecks = 100

############
# Timeouts #
Expand Down Expand Up @@ -504,15 +508,6 @@ scorex {
# Size limits #
###############

# Maximum income package size
maxPacketSize = 2048576

# Maximum size of a handshaking message
maxHandshakeSize = 8096

# Accept maximum inv objects
maxInvObjects = 400

# Desired number of inv objects. Our requests will have this size.
desiredInvObjects = 400

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/mainnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ ergo {
# The node still applying transactions to UTXO set and so checks UTXO set digests for each block.
# Block at checkpoint height is to be checked against expected one.
checkpoint = {
height = 777670
blockId = "157ecf59b067fdc81921432d7b8c4cb30890f18056788fdc32e433756a9fbb78"
height = 798128
blockId = "e7f9066562fa123cff39d4f30f8e205591f55f6ae4ac802efa850fd54d5507f1"
}

# List with hex-encoded identifiers of transactions banned from getting into memory pool
Expand All @@ -65,7 +65,7 @@ scorex {
network {
magicBytes = [1, 0, 2, 4]
bindAddress = "0.0.0.0:9030"
nodeName = "ergo-mainnet-4.0.34"
nodeName = "ergo-mainnet-4.0.35"
nodeName = ${?NODENAME}
knownPeers = [
"213.239.193.208:9030",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/testnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ scorex {
network {
magicBytes = [2, 0, 0, 2]
bindAddress = "0.0.0.0:9020"
nodeName = "ergo-testnet-4.0.34"
nodeName = "ergo-testnet-4.0.35"
nodeName = ${?NODENAME}
knownPeers = [
"213.239.193.208:9020",
Expand Down
15 changes: 6 additions & 9 deletions src/main/scala/org/ergoplatform/ErgoApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.ergoplatform.http.api._
import org.ergoplatform.local._
import org.ergoplatform.mining.ErgoMiner
import org.ergoplatform.mining.ErgoMiner.StartMining
import org.ergoplatform.network.{ErgoNodeViewSynchronizer, ErgoSyncTracker, ModeFeature}
import org.ergoplatform.network.{ErgoNodeViewSynchronizer, ErgoSyncTracker, ModePeerFeature}
import org.ergoplatform.nodeView.history.ErgoSyncInfoMessageSpec
import org.ergoplatform.nodeView.{ErgoNodeViewRef, ErgoReadersHolderRef}
import org.slf4j.{Logger, LoggerFactory}
Expand Down Expand Up @@ -48,7 +48,7 @@ class ErgoApp(args: Args) extends ScorexLogging {
implicit private val actorSystem: ActorSystem = ActorSystem(scorexSettings.network.agentName)
implicit private val executionContext: ExecutionContext = actorSystem.dispatcher

private val features: Seq[PeerFeature] = Seq(ModeFeature(ergoSettings.nodeSettings))
private val features: Seq[PeerFeature] = Seq(ModePeerFeature(ergoSettings.nodeSettings))
private val featureSerializers: PeerFeature.Serializers = features.map(f => f.featureId -> f.serializer).toMap

private val timeProvider = new NetworkTimeProvider(scorexSettings.ntp)
Expand All @@ -64,15 +64,12 @@ class ErgoApp(args: Args) extends ScorexLogging {
}

private val basicSpecs = {
val invSpec = new InvSpec(scorexSettings.network.maxInvObjects)
val requestModifierSpec = new RequestModifierSpec(scorexSettings.network.maxInvObjects)
val modifiersSpec = new ModifiersSpec(scorexSettings.network.maxPacketSize)
Seq(
GetPeersSpec,
new PeersSpec(featureSerializers, scorexSettings.network.maxPeerSpecObjects),
invSpec,
requestModifierSpec,
modifiersSpec
InvSpec,
RequestModifierSpec,
ModifiersSpec
)
}

Expand Down Expand Up @@ -104,7 +101,7 @@ class ErgoApp(args: Args) extends ScorexLogging {
}


private val syncTracker = ErgoSyncTracker(actorSystem, scorexSettings.network, timeProvider)
private val syncTracker = ErgoSyncTracker(scorexSettings.network, timeProvider)
private val statsCollectorRef: ActorRef = ErgoStatsCollectorRef(readersHolderRef, networkControllerRef, syncTracker, ergoSettings, timeProvider)
private val deliveryTracker: DeliveryTracker = DeliveryTracker.empty(ergoSettings)

Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/org/ergoplatform/http/api/BlocksApiRoute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import io.circe.Json
import io.circe.syntax._
import org.ergoplatform.modifiers.history.header.Header
import org.ergoplatform.modifiers.history.BlockTransactions
import org.ergoplatform.modifiers.{BlockSection, ErgoFullBlock, ErgoPersistentModifier}
import org.ergoplatform.modifiers.{NonHeaderBlockSection, ErgoFullBlock, BlockSection}
import org.ergoplatform.nodeView.ErgoReadersHolder.GetDataFromHistory
import org.ergoplatform.nodeView.history.ErgoHistoryReader
import org.ergoplatform.settings.{Algos, ErgoSettings}
Expand Down Expand Up @@ -69,13 +69,13 @@ case class BlocksApiRoute(viewHolderRef: ActorRef, readersHolder: ActorRef, ergo
history.typedModifierById[Header](headerId).flatMap(history.getFullBlock)
}

private def getModifierById(modifierId: ModifierId): Future[Option[ErgoPersistentModifier]] =
private def getModifierById(modifierId: ModifierId): Future[Option[BlockSection]] =
getHistory.map(_.modifierById(modifierId))

private def getProofForTx(headerId: ModifierId, txId: ModifierId): Future[Option[MerkleProof[Digest32]]] =
getModifierById(headerId).flatMap {
case Some(header: Header) =>
val blockTxsId = BlockSection.computeId(
val blockTxsId = NonHeaderBlockSection.computeId(
BlockTransactions.modifierTypeId,
headerId,
header.transactionsRoot.asInstanceOf[Array[Byte]]
Expand Down
Loading

0 comments on commit 66ae8ad

Please sign in to comment.