Skip to content

Commit

Permalink
Merge pull request #1761 from ergoplatform/v4.0.34
Browse files Browse the repository at this point in the history
Candidate for version 4.0.34
  • Loading branch information
kushti authored Jul 5, 2022
2 parents 8066c84 + 64b0940 commit a4d1e62
Show file tree
Hide file tree
Showing 59 changed files with 212 additions and 426 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.33`.
Available versions can be found on [Ergo Docker image page](https://hub.docker.com/r/ergoplatform/ergo/tags), for example, `v4.0.34`.

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
2 changes: 1 addition & 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.33"
version: "4.0.34"
title: Ergo Node API
description: API docs for Ergo Node. Models are shared between all Ergo products
contact:
Expand Down
5 changes: 1 addition & 4 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,6 @@ 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 @@ -391,7 +388,7 @@ scorex {
nodeName = "ergo-node"

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

# Network agent name. May contain information about client code
# stack, starting from core code-base up to the end graphical interface.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mainnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ scorex {
network {
magicBytes = [1, 0, 2, 4]
bindAddress = "0.0.0.0:9030"
nodeName = "ergo-mainnet-4.0.33"
nodeName = "ergo-mainnet-4.0.34"
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.33"
nodeName = "ergo-testnet-4.0.34"
nodeName = ${?NODENAME}
knownPeers = [
"213.239.193.208:9020",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class ErgoPeersApiRoute(peerManager: ActorRef,
lastMessage = con.lastMessage,
lastHandshake = peerInfo.lastHandshake,
name = peerInfo.peerSpec.nodeName,
connectionType = peerInfo.connectionType.map(_.toString),
restApiUrl = peerInfo.peerSpec.restApiUrl.map(_.toString)
connectionType = peerInfo.connectionType.map(_.toString)
)
}
}
Expand Down Expand Up @@ -117,17 +116,15 @@ object ErgoPeersApiRoute {
lastMessage: Long,
lastHandshake: Long,
name: String,
connectionType: Option[String],
restApiUrl: Option[String])
connectionType: Option[String])

object PeerInfoResponse {
def fromAddressAndInfo(address: InetSocketAddress, peerInfo: PeerInfo): PeerInfoResponse = PeerInfoResponse(
address.toString,
0,
peerInfo.lastHandshake,
peerInfo.peerSpec.nodeName,
peerInfo.connectionType.map(_.toString),
peerInfo.peerSpec.restApiUrl.map(_.toString)
peerInfo.connectionType.map(_.toString)
)

@SuppressWarnings(Array("org.wartremover.warts.PublicInference"))
Expand Down
17 changes: 6 additions & 11 deletions src/main/scala/org/ergoplatform/local/ErgoStatsCollector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import scorex.core.utils.TimeProvider.Time
import scorex.util.ScorexLogging
import scorex.core.network.peer.PeersStatus

import java.net.URL
import scala.concurrent.ExecutionContextExecutor
import scala.concurrent.duration._

Expand All @@ -39,9 +38,9 @@ class ErgoStatsCollector(readersHolder: ActorRef,
val ec: ExecutionContextExecutor = context.dispatcher

readersHolder ! GetReaders
context.system.eventStream.subscribe(self, classOf[ChangedHistory[_]])
context.system.eventStream.subscribe(self, classOf[ChangedHistory])
context.system.eventStream.subscribe(self, classOf[ChangedState])
context.system.eventStream.subscribe(self, classOf[ChangedMempool[_]])
context.system.eventStream.subscribe(self, classOf[ChangedMempool])
context.system.eventStream.subscribe(self, classOf[SemanticallySuccessfulModifier])
context.system.scheduler.scheduleAtFixedRate(10.seconds, 20.seconds, networkController, GetConnectedPeers)(ec, self)
context.system.scheduler.scheduleAtFixedRate(45.seconds, 30.seconds, networkController, GetPeersStatus)(ec, self)
Expand All @@ -68,8 +67,7 @@ class ErgoStatsCollector(readersHolder: ActorRef,
lastIncomingMessageTime = networkTime(),
None,
LaunchParameters,
eip27Supported = true,
settings.scorexSettings.restApi.publicUrl)
eip27Supported = true)

override def receive: Receive =
onConnectedPeers orElse
Expand Down Expand Up @@ -195,16 +193,13 @@ object ErgoStatsCollector {
lastIncomingMessageTime: Long,
genesisBlockIdOpt: Option[String],
parameters: Parameters,
eip27Supported: Boolean,
restApiUrl: Option[URL])
eip27Supported: Boolean)

object NodeInfo extends ApiCodecs {
implicit val paramsEncoder: Encoder[Parameters] = org.ergoplatform.settings.ParametersSerializer.jsonEncoder

implicit val jsonEncoder: Encoder[NodeInfo] = (ni: NodeInfo) => {
val optionalFields =
ni.restApiUrl.map(_.toString).map(restApiUrl => Map("restApiUrl" -> restApiUrl.asJson)).getOrElse(Map.empty)
(Map(
Map(
"name" -> ni.nodeName.asJson,
"appVersion" -> Version.VersionString.asJson,
"network" -> ni.network.asJson,
Expand All @@ -228,7 +223,7 @@ object ErgoStatsCollector {
"genesisBlockId" -> ni.genesisBlockIdOpt.asJson,
"parameters" -> ni.parameters.asJson,
"eip27Supported" -> ni.eip27Supported.asJson
) ++ optionalFields).asJson
).asJson
}
}

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

import akka.actor.SupervisorStrategy.{Restart, Stop}

import java.net.InetSocketAddress

import akka.actor.{Actor, ActorInitializationException, ActorKilledException, ActorRef, ActorRefFactory, DeathPactException, OneForOneStrategy, Props}
import org.ergoplatform.modifiers.history.ADProofs
import org.ergoplatform.modifiers.history.header.Header
Expand All @@ -17,28 +17,28 @@ import org.ergoplatform.nodeView.mempool.{ErgoMemPool, ErgoMemPoolReader}
import org.ergoplatform.settings.{Constants, ErgoSettings}
import org.ergoplatform.nodeView.ErgoNodeViewHolder.ReceivableMessages.{ChainIsHealthy, ChainIsStuck, GetNodeViewChanges, IsChainHealthy, ModifiersFromRemote, TransactionsFromRemote}
import org.ergoplatform.nodeView.ErgoNodeViewHolder._
import scorex.core.consensus.History.{Equal, Fork, Nonsense, Older, Unknown, Younger}
import scorex.core.consensus.{HistoryReader, SyncInfo}
import scorex.core.consensus.{Equal, Fork, Nonsense, Older, Unknown, Younger}
import scorex.core.network.ModifiersStatus.Requested
import scorex.core.{ModifierTypeId, NodeViewModifier, PersistentNodeViewModifier, idsToString}
import scorex.core.network.NetworkController.ReceivableMessages.{PenalizePeer, RegisterMessageSpecs}
import org.ergoplatform.network.ErgoNodeViewSynchronizer.ReceivableMessages._
import org.ergoplatform.nodeView.state.{ErgoStateReader, StateType}
import org.ergoplatform.nodeView.wallet.ErgoWalletReader
import scorex.core.network.message.{InvSpec, MessageSpec, ModifiersSpec, RequestModifierSpec}
import scorex.core.network._
import scorex.core.network.NetworkController.ReceivableMessages.SendToNetwork
import scorex.core.network.message.{InvData, Message, ModifiersData}
import scorex.core.network.{ConnectedPeer, ModifiersStatus, SendToPeer, SendToPeers}
import scorex.core.serialization.ScorexSerializer
import scorex.core.settings.NetworkSettings
import scorex.core.transaction.{MempoolReader, Transaction}
import scorex.core.transaction.Transaction
import scorex.core.utils.{NetworkTimeProvider, ScorexEncoding}
import scorex.core.validation.MalformedModifierError
import scorex.util.{ModifierId, ScorexLogging}
import scorex.core.network.DeliveryTracker
import scorex.core.network.peer.PenaltyType
import scorex.core.transaction.state.TransactionValidation.TooHighCostError
import scorex.core.transaction.wallet.VaultReader


import scala.annotation.tailrec
import scala.collection.mutable
Expand Down Expand Up @@ -114,8 +114,8 @@ class ErgoNodeViewSynchronizer(networkControllerRef: ActorRef,
context.system.eventStream.subscribe(self, classOf[DisconnectedPeer])

// subscribe for all the node view holder events involving modifiers and transactions
context.system.eventStream.subscribe(self, classOf[ChangedHistory[ErgoHistoryReader]])
context.system.eventStream.subscribe(self, classOf[ChangedMempool[ErgoMemPoolReader]])
context.system.eventStream.subscribe(self, classOf[ChangedHistory])
context.system.eventStream.subscribe(self, classOf[ChangedMempool])
context.system.eventStream.subscribe(self, classOf[ModificationOutcome])
context.system.eventStream.subscribe(self, classOf[DownloadRequest])
context.system.eventStream.subscribe(self, classOf[BlockAppliedTransactions])
Expand Down Expand Up @@ -975,11 +975,11 @@ object ErgoNodeViewSynchronizer {

trait NodeViewChange extends NodeViewHolderEvent

case class ChangedHistory[HR <: HistoryReader[_ <: PersistentNodeViewModifier, _ <: SyncInfo]](reader: HR) extends NodeViewChange
case class ChangedHistory(reader: ErgoHistoryReader) extends NodeViewChange

case class ChangedMempool[MR <: MempoolReader[_ <: Transaction]](mempool: MR) extends NodeViewChange
case class ChangedMempool(mempool: ErgoMemPoolReader) extends NodeViewChange

case class ChangedVault[VR <: VaultReader](reader: VR) extends NodeViewChange
case class ChangedVault(reader: ErgoWalletReader) extends NodeViewChange

case class ChangedState(reader: ErgoStateReader) extends NodeViewChange

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.ergoplatform.network
import io.circe.{Encoder, Json}
import org.ergoplatform.nodeView.history.ErgoHistory.Height
import scorex.core.app.Version
import scorex.core.consensus.History.HistoryComparisonResult
import scorex.core.consensus.HistoryComparisonResult
import scorex.core.network.ConnectedPeer
import scorex.core.utils.TimeProvider.Time

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.net.InetSocketAddress
import akka.actor.ActorSystem
import org.ergoplatform.nodeView.history.ErgoHistory
import org.ergoplatform.nodeView.history.ErgoHistory.Height
import scorex.core.consensus.History.{Fork, HistoryComparisonResult, Older, Unknown}
import scorex.core.consensus.{Fork, HistoryComparisonResult, Older, Unknown}
import org.ergoplatform.network.ErgoNodeViewSynchronizer.Events.{BetterNeighbourAppeared, NoBetterNeighbour}
import scorex.core.network.ConnectedPeer
import scorex.core.settings.NetworkSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import scorex.core.validation.MalformedModifierError
import scala.util.Failure

class ErgoModifiersCache(override val maxSize: Int)
extends DefaultModifiersCache[ErgoPersistentModifier, ErgoHistory](maxSize) {
extends DefaultModifiersCache(maxSize) {

override def findCandidateKey(history: ErgoHistory): Option[K] = {
def tryToApply(k: K, v: ErgoPersistentModifier): Boolean = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import scorex.core._
import org.ergoplatform.network.ErgoNodeViewSynchronizer.ReceivableMessages._
import org.ergoplatform.nodeView.ErgoNodeViewHolder.{BlockAppliedTransactions, CurrentView, DownloadRequest}
import org.ergoplatform.nodeView.ErgoNodeViewHolder.ReceivableMessages._
import scorex.core.consensus.History.ProgressInfo
import scorex.core.consensus.ProgressInfo
import scorex.core.settings.ScorexSettings
import scorex.core.utils.{NetworkTimeProvider, ScorexEncoding}
import scorex.core.validation.RecoverableModifierError
Expand Down
29 changes: 22 additions & 7 deletions src/main/scala/org/ergoplatform/nodeView/history/ErgoHistory.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@ import org.ergoplatform.nodeView.history.storage.modifierprocessors._
import org.ergoplatform.nodeView.history.storage.modifierprocessors.popow.{EmptyPoPoWProofsProcessor, FullPoPoWProofsProcessor}
import org.ergoplatform.settings._
import org.ergoplatform.utils.LoggingUtil
import scorex.core.consensus.History
import scorex.core.consensus.History.ProgressInfo
import scorex.core.consensus.ProgressInfo
import scorex.core.utils.NetworkTimeProvider
import scorex.core.validation.RecoverableModifierError
import scorex.util.{ModifierId, ScorexLogging, idToBytes}

import scala.util.{Failure, Success, Try}

/**
*
* History of a blockchain system is some blocktree in fact
* (like this: http://image.slidesharecdn.com/sfbitcoindev-chepurnoy-2015-150322043044-conversion-gate01/95/proofofstake-its-improvements-san-francisco-bitcoin-devs-hackathon-12-638.jpg),
* where longest chain is being considered as canonical one, containing right kind of history.
*
* In cryptocurrencies of today blocktree view is usually implicit, means code supports only linear history,
* but other options are possible.
*
* To say "longest chain" is the canonical one is simplification, usually some kind of "cumulative difficulty"
* function has been used instead.
*
* History implementation. It is processing persistent modifiers generated locally or coming from the network.
* Depending on chosen node settings, it will process modifiers in a different way, different processors define how to
* process different type of modifiers.
Expand All @@ -39,8 +49,7 @@ import scala.util.{Failure, Success, Try}
* 2. Be ignored by history (verifyTransactions == false)
*/
trait ErgoHistory
extends History[ErgoPersistentModifier, ErgoSyncInfo, ErgoHistory]
with ErgoHistoryReader {
extends ErgoHistoryReader {

override protected lazy val requireProofs: Boolean = nodeSettings.stateType.requireProofs

Expand All @@ -62,7 +71,7 @@ trait ErgoHistory
/**
* Append ErgoPersistentModifier to History if valid
*/
override def append(modifier: ErgoPersistentModifier): Try[(ErgoHistory, ProgressInfo[ErgoPersistentModifier])] = synchronized {
def append(modifier: ErgoPersistentModifier): Try[(ErgoHistory, ProgressInfo[ErgoPersistentModifier])] = synchronized {
log.debug(s"Trying to append modifier ${modifier.encodedId} of type ${modifier.modifierTypeId} to history")
applicableTry(modifier).flatMap { _ =>
modifier match {
Expand All @@ -87,7 +96,7 @@ trait ErgoHistory
/**
* Mark modifier as valid
*/
override def reportModifierIsValid(modifier: ErgoPersistentModifier): Try[ErgoHistory] = synchronized {
def reportModifierIsValid(modifier: ErgoPersistentModifier): Try[ErgoHistory] = synchronized {
log.debug(s"Modifier ${modifier.encodedId} of type ${modifier.modifierTypeId} is marked as valid ")
modifier match {
case fb: ErgoFullBlock =>
Expand Down Expand Up @@ -115,7 +124,7 @@ trait ErgoHistory
* @return ProgressInfo with next modifier to try to apply
*/
@SuppressWarnings(Array("OptionGet", "TraversableHead"))
override def reportModifierIsInvalid(modifier: ErgoPersistentModifier,
def reportModifierIsInvalid(modifier: ErgoPersistentModifier,
progressInfo: ProgressInfo[ErgoPersistentModifier]
): Try[(ErgoHistory, ProgressInfo[ErgoPersistentModifier])] = synchronized {
log.warn(s"Modifier ${modifier.encodedId} of type ${modifier.modifierTypeId} is marked as invalid")
Expand Down Expand Up @@ -219,6 +228,12 @@ trait ErgoHistory
}
}
}

/**
* @return read-only copy of this history
*/
def getReader: ErgoHistoryReader = this

}

object ErgoHistory extends ScorexLogging {
Expand Down
Loading

0 comments on commit a4d1e62

Please sign in to comment.