Skip to content

Commit

Permalink
Merge pull request #1837 from ergoplatform/v4.0.45
Browse files Browse the repository at this point in the history
Candidate for 4.0.45
  • Loading branch information
kushti authored Sep 19, 2022
2 parents c66cd12 + f1d5835 commit df89bf3
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 10 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.44`.
Available versions can be found on [Ergo Docker image page](https://hub.docker.com/r/ergoplatform/ergo/tags), for example, `v4.0.45`.

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.44"
version: "4.0.45"
title: Ergo Node API
description: API docs for Ergo Node. Models are shared between all Ergo products
contact:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ scorex {
nodeName = "ergo-node"

# Network protocol version to be sent in handshakes
appVersion = 4.0.44
appVersion = 4.0.45

# 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.44"
nodeName = "ergo-mainnet-4.0.45"
nodeName = ${?NODENAME}
knownPeers = [
"213.239.193.208:9030",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import scorex.core.network.DeliveryTracker
import scorex.core.network.peer.PenaltyType
import scorex.core.transaction.state.TransactionValidation.TooHighCostError
import ErgoNodeViewSynchronizer.{IncomingTxInfo, TransactionProcessingCacheRecord}
import scorex.core.app.Version

import scala.annotation.tailrec
import scala.collection.mutable
Expand Down Expand Up @@ -598,7 +599,7 @@ class ErgoNodeViewSynchronizer(networkControllerRef: ActorRef,
Constants.modifierSerializers.get(typeId) match {
case Some(serializer: ScorexSerializer[BlockSection]@unchecked) =>
// parse all modifiers and put them to modifiers cache
val parsed: Iterable[BlockSection] = parseModifiers(requestedModifiers, serializer, remote)
val parsed: Iterable[BlockSection] = parseModifiers(requestedModifiers, typeId, serializer, remote)

// `deliveryTracker.setReceived()` called inside `validateAndSetStatus` for every correct modifier
val valid = parsed.filter(validateAndSetStatus(hr, remote, _))
Expand Down Expand Up @@ -679,14 +680,17 @@ class ErgoNodeViewSynchronizer(networkControllerRef: ActorRef,
* @return collection of parsed modifiers
*/
def parseModifiers[M <: NodeViewModifier](modifiers: Map[ModifierId, Array[Byte]],
modifierTypeId: ModifierTypeId,
serializer: ScorexSerializer[M],
remote: ConnectedPeer): Iterable[M] = {
modifiers.flatMap { case (id, bytes) =>
serializer.parseBytesTry(bytes) match {
case Success(mod) if id == mod.id =>
Some(mod)
case _ =>
// Penalize peer and do nothing - it will be switched to correct state on CheckDelivery
// Penalize peer and do nothing
// Forget about block section, so it will be redownloaded if announced again only
deliveryTracker.setUnknown(id, modifierTypeId)
penalizeMisbehavingPeer(remote)
log.warn(s"Failed to parse modifier with declared id ${encoder.encodeId(id)} from ${remote.toString}")
None
Expand Down Expand Up @@ -771,8 +775,14 @@ class ErgoNodeViewSynchronizer(networkControllerRef: ActorRef,
Seq.empty
}
case _ =>
log.info(s"Processing ${invData.ids.length} non-tx invs (of type $modifierTypeId) from $peer")
invData.ids.filter(mid => deliveryTracker.status(mid, modifierTypeId, Seq(hr)) == ModifiersStatus.Unknown)
if (peer.peerInfo.map(_.peerSpec.protocolVersion).getOrElse(Version.initial) == Version.v4043 &&
modifierTypeId == Header.modifierTypeId) {
log.debug("Header ids from 4.0.43")
Seq.empty
} else {
log.info(s"Processing ${invData.ids.length} non-tx invs (of type $modifierTypeId) from $peer")
invData.ids.filter(mid => deliveryTracker.status(mid, modifierTypeId, Seq(hr)) == ModifiersStatus.Unknown)
}
}

if (newModifierIds.nonEmpty) {
Expand Down Expand Up @@ -802,8 +812,17 @@ class ErgoNodeViewSynchronizer(networkControllerRef: ActorRef,
mp.getAll(invData.ids).map { unconfirmedTx =>
unconfirmedTx.transaction.id -> unconfirmedTx.transactionBytes.getOrElse(unconfirmedTx.transaction.bytes)
}
case _: ModifierTypeId =>
invData.ids.flatMap(id => hr.modifierBytesById(id).map(bytes => (id, bytes)))
case expectedTypeId: ModifierTypeId =>
invData.ids.flatMap { id =>
hr.modifierTypeAndBytesById(id).flatMap { case (mTypeId, bytes) =>
if (mTypeId == expectedTypeId) {
Some(id -> bytes)
} else {
log.debug(s"Improper type for asked modifier id: $id")
None
}
}
}
}

log.debug(s"Requested ${invData.ids.length} modifiers ${idsToString(invData)}, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ trait ErgoHistoryReader
None
}

/**
* @param id - modifier id
* @return type and raw bytes of semantically valid ErgoPersistentModifier with the given id it is in history
*/
def modifierTypeAndBytesById(id: ModifierId): Option[(ModifierTypeId, Array[Byte])] =
if (isSemanticallyValid(id) != ModifierSemanticValidity.Invalid) {
historyStorage.modifierTypeAndBytesById(id)
} else {
None
}

/**
* @param id - modifier id
* @return semantically valid ErgoPersistentModifier with the given id it is in history
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import org.ergoplatform.modifiers.BlockSection
import org.ergoplatform.modifiers.history.HistoryModifierSerializer
import org.ergoplatform.modifiers.history.header.Header
import org.ergoplatform.settings.{Algos, CacheSettings, ErgoSettings}
import scorex.core.ModifierTypeId
import scorex.core.utils.ScorexEncoding
import scorex.db.{ByteArrayWrapper, LDBFactory, LDBKVStore}
import scorex.util.{ModifierId, ScorexLogging, idToBytes}
import supertagged.PostfixSugar

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

Expand Down Expand Up @@ -56,6 +58,10 @@ class HistoryStorage private(indexStore: LDBKVStore, objectsStore: LDBKVStore, c
objectsStore.get(idToBytes(id)).map(_.tail) // removing modifier type byte with .tail
}

def modifierTypeAndBytesById(id: ModifierId): Option[(ModifierTypeId, Array[Byte])] = {
objectsStore.get(idToBytes(id)).map(bs => (bs.head @@ ModifierTypeId, bs.tail)) // first byte is type id, tail is modifier bytes
}

def modifierById(id: ModifierId): Option[BlockSection] =
lookupModifier(id) orElse
objectsStore.get(idToBytes(id)).flatMap { bytes =>
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/scorex/core/app/Version.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ object Version {

val v4022: Version = Version(4, 0, 22)

val v4043: Version = Version(4, 0, 43)
}

object ApplicationVersionSerializer extends ScorexSerializer[Version] {
Expand Down

0 comments on commit df89bf3

Please sign in to comment.