Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input/Ordering Block Implementation #2055

Open
wants to merge 129 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
10362c9
WeakBlockAlgos
kushti Aug 22, 2023
76e2f60
Merge branch 'v5.0.15' of github.com:ergoplatform/ergo into weak-blocks
kushti Sep 12, 2023
c5d30d3
WeakBlockInfo, WeakBlockMessageSpec
kushti Sep 18, 2023
5c2eb29
impl steps
kushti Sep 28, 2023
d378942
Merge branch 'v5.0.16' of github.com:ergoplatform/ergo into weak-blocks
kushti Oct 25, 2023
8843114
initial weak blocks structures and algos
kushti Oct 30, 2023
5c4f9c2
compact block like messaging
kushti Oct 31, 2023
0dbfeb0
before structures
kushti Nov 1, 2023
1a68d0e
skeleton of processing algo
kushti Nov 4, 2023
1040926
weak blocks => sub blocks
kushti Nov 7, 2023
636f3d8
more weak=>sub renaming
kushti Nov 7, 2023
6293421
returning download plan
kushti Nov 7, 2023
23a5db0
better comments and todos, formatting
kushti Nov 9, 2023
2c5cf3c
motivation started in EIP, data structures refined
kushti Nov 10, 2023
4189783
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti Nov 28, 2023
4962218
pow, superblocks
kushti Dec 1, 2023
514e6fb
subblocks section finished
kushti Dec 2, 2023
564ad05
propagation text started, prevSubBlockId made optional (comp fails)
kushti Dec 6, 2023
346e1a7
commitment
kushti Dec 21, 2023
a068545
styling fixes
kushti Dec 28, 2023
c0709f2
key spaces for sub-blocks and sidechains
kushti Dec 29, 2023
85de7a4
eip update
kushti Jan 3, 2024
a248ccf
dag note, new subsections added
kushti Jan 4, 2024
0a9fd56
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti Feb 12, 2024
93bc6bc
merging w. master, accounting for optional prevSubBlockId
kushti Feb 12, 2024
02056c2
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti Jul 17, 2024
92baed0
input/ordering blocks intro
kushti Jul 19, 2024
54c9971
script execution ctx started
kushti Jul 20, 2024
73d76f2
extending subblocks info
kushti Jul 24, 2024
69adf58
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti Jul 30, 2024
bed12e6
SubsPerBlock* improved comments in SubBlockAlgos
kushti Jul 30, 2024
01da1a0
BlockKind, distnguishing fn
kushti Aug 3, 2024
e448fb8
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti Aug 5, 2024
3e9f4d1
blockKind()
kushti Aug 6, 2024
1a8aaeb
unused reportModifierIsInvalid removed
kushti Aug 7, 2024
184996e
ProgressInfo.empty, removing implicit ScorexEncoder
kushti Aug 7, 2024
8bc72cc
MessageSpecInitial / MessageSpecSubBlock
kushti Aug 12, 2024
4192c61
merkle proof added to SubBlockInfo, serializer updated, SubBlockMessa…
kushti Aug 14, 2024
a044955
batch merkle proof usage and serialization
kushti Aug 29, 2024
613fc58
Merge branch 'jni-dep' of github.com:ergoplatform/ergo into weak-blocks
kushti Aug 29, 2024
c382a38
processSubblock started
kushti Sep 3, 2024
15ca997
subblock height check
kushti Sep 3, 2024
222c850
SubBlockTransactionsRequestSpec, completing processSubblock stub
kushti Sep 4, 2024
e6ee392
SubBlockTransactionsSpec
kushti Sep 5, 2024
fb98a2e
subblocks p2p logic stub
kushti Sep 8, 2024
95fb95e
LocallyGeneratedSubBlock
kushti Sep 13, 2024
5f66580
subblock keys, CandidateGenerator simplification
kushti Sep 13, 2024
f118879
more simplification in CandidateGenerator
kushti Sep 13, 2024
e8bcdfa
bestSubblock() stub. createCandidate #1
kushti Sep 13, 2024
647b6db
initial version of best subblock selection
kushti Sep 18, 2024
e93d333
merging w. 5.0.23
kushti Sep 19, 2024
e0feb83
input/ordering block distintcion in mining logic #1, input block gene…
kushti Sep 19, 2024
9ebe5db
subblocks generation
kushti Oct 1, 2024
5e623b4
fixing delivery of sub-blocks to processing
kushti Oct 1, 2024
c9de516
input block pow validation
kushti Oct 10, 2024
b908142
completeOrderingBlock / completeInputBlock
kushti Oct 10, 2024
08c52d6
sendInputToNodeView stub (pre-refactoring)
kushti Oct 15, 2024
ac824a4
LocallyGeneratedInputBlock / LocallyGeneratedOrderingBlock
kushti Oct 16, 2024
4fc43c5
reworked LocallyGeneratedInputBlock signature
kushti Oct 18, 2024
ef02664
forum post
kushti Oct 30, 2024
4011aa5
removing subblock field from Candidate
kushti Oct 30, 2024
e9811ce
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti Dec 10, 2024
c81839d
papers/subblocks folder
kushti Dec 10, 2024
319f7a6
forming SubBlockInfo, SubBlockTransactionsData moved to completeInput…
kushti Dec 10, 2024
cac7cd1
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti Dec 23, 2024
caf9f3f
subblock -> inputblock
kushti Dec 23, 2024
87a91d5
input blocks data pruning
kushti Dec 24, 2024
8e9d526
forming prevInputBlockId
kushti Dec 24, 2024
139d770
improving linking logic and code
kushti Dec 24, 2024
afb4ef4
refs, motivation rework
kushti Dec 28, 2024
8ed3749
EIP rework #1
kushti Dec 30, 2024
70c57c2
Transactions Handling
kushti Jan 1, 2025
d16aa23
Transactions Handling
kushti Jan 3, 2025
8d8afa5
propagation wip1
kushti Jan 3, 2025
3752b30
incentivization section
kushti Jan 4, 2025
e15dcd0
EIP alpha version
kushti Jan 4, 2025
7aae74a
update notes
kushti Jan 6, 2025
5d059f7
transactions handling section updatte
kushti Jan 7, 2025
7dfd05e
transactions handling update
kushti Jan 8, 2025
c5814df
input-block related extension fields
kushti Jan 9, 2025
251d097
generateCandidate comments
kushti Jan 10, 2025
7fd69ec
createCandidate refatoring
kushti Jan 10, 2025
b77765c
new extension fields stub
kushti Jan 10, 2025
7dcec20
forming prev input block id
kushti Jan 13, 2025
e34a181
comments for extension fields
kushti Jan 13, 2025
5773c17
reordering code before reworking forming transactions
kushti Jan 14, 2025
41f2d59
initial input/ordering txs split
kushti Jan 14, 2025
2245808
comments fix
kushti Jan 16, 2025
a4d892a
bestBlocks
kushti Jan 16, 2025
4633a5e
parentInputBlockIdOpt fix
kushti Jan 16, 2025
cebf363
transactionsCache
kushti Jan 16, 2025
8a4b690
input block id, prev link fix, accumulating ordering block transactions
kushti Jan 17, 2025
f687ca4
using previous ordering block transactions in orderingBlocktransactio…
kushti Jan 20, 2025
d0f7ca6
fixing subblocksPerBlock in checkNonces
kushti Jan 20, 2025
3288e61
checkInputBlockPoW & checkOrderingBlockPoW in AutolykosPowScheme
kushti Jan 20, 2025
879b50b
passing link to previous input block, clearing miner cache on input b…
kushti Jan 21, 2025
b689299
filtering out non-input transactions
kushti Jan 22, 2025
c77d30b
filtering out already included before collectTxs, id arg fix in apply…
kushti Jan 23, 2025
cac0278
real Merkle tree digests
kushti Jan 23, 2025
bca36db
NewBestInputBlock signal, /info field
kushti Jan 24, 2025
4988a6e
getInputBlock
kushti Jan 24, 2025
1aaa562
improving comments
kushti Jan 25, 2025
377d6c9
inputBlockParents stub
kushti Jan 27, 2025
c01a3d1
getBestInputBlocksChain
kushti Jan 27, 2025
9521425
bestInputBlock / bestInputChain
kushti Jan 28, 2025
49acb70
input blocks application tests plan
kushti Feb 4, 2025
be23a52
input blocks dag processing wip1
kushti Feb 4, 2025
d91fef6
check for best header for first subblock
kushti Feb 4, 2025
c19cc2e
handling missing parent wip1
kushti Feb 6, 2025
fa22cb8
first test in InputBlockProcessorSpecification, some fixes in ib appl…
kushti Feb 7, 2025
8e52469
chain of two input blocks and out of order application tests
kushti Feb 7, 2025
aadcd2b
deliveryWaitlist / disconnectedWaitlist
kushti Feb 8, 2025
47d1ef9
moving best input block update to applyInputBlockTransactions
kushti Feb 10, 2025
517e8fa
applyInputBlockTransactions scaladoc and fixes
kushti Feb 12, 2025
f436de2
-Xasync to solve idea compilation issues, processBestInputBlockCandid…
kushti Feb 13, 2025
9e2a6dd
bestHeight, bestTips to find best input block chains tips efficiently
kushti Feb 13, 2025
e39618a
updateBestTipsAndHeight, check best tips and best tip height in tests
kushti Feb 14, 2025
34cad4c
check tip height in tests
kushti Feb 14, 2025
c78e2ac
isAncestor
kushti Feb 14, 2025
13663b8
isAncestor returns parent's child
kushti Feb 14, 2025
10e1258
scaladoc for structures
kushti Feb 24, 2025
47e4f4b
improved comments, applyInputBlock refactoring
kushti Feb 25, 2025
adc4ebc
refactoring and fixing updateBestTipsAndHeight
kushti Feb 26, 2025
0170c15
processBestInputBlockCandidate extraction
kushti Feb 26, 2025
6d9abf9
recursively updating best input blocks
kushti Feb 28, 2025
f4add6d
checking applyInputBlockTransactions output in tests
kushti Mar 5, 2025
fad3817
input block id fix
kushti Mar 6, 2025
a9c522f
out of order txs application and corresponding fix
kushti Mar 7, 2025
a4a9306
packages refactoring, out of order test fix
kushti Mar 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ProgressInfo.empty, removing implicit ScorexEncoder
  • Loading branch information
kushti committed Aug 7, 2024
commit 184996e84a4744414f69394bb895c07eeb672dc9
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ import scorex.util.ModifierId
case class ProgressInfo[PM <: BlockSection](branchPoint: Option[ModifierId],
toRemove: Seq[PM],
toApply: Seq[PM],
toDownload: Seq[(NetworkObjectTypeId.Value, ModifierId)])
(implicit encoder: ScorexEncoder) {
toDownload: Seq[(NetworkObjectTypeId.Value, ModifierId)]) {

if (toRemove.nonEmpty)
require(branchPoint.isDefined, s"Branch point should be defined for non-empty `toRemove`")

lazy val chainSwitchingNeeded: Boolean = toRemove.nonEmpty

override def toString: String = {
s"ProgressInfo(BranchPoint: ${branchPoint.map(encoder.encodeId)}, " +
s"ProgressInfo(BranchPoint: ${branchPoint.map(ScorexEncoder.encodeId)}, " +
s" to remove: ${toRemove.map(_.encodedId)}, to apply: ${toApply.map(_.encodedId)})"
}
}

object ProgressInfo {
val empty = ProgressInfo[BlockSection](None, Seq.empty, Seq.empty, Seq.empty)
}
8 changes: 4 additions & 4 deletions ergo-core/src/main/scala/org/ergoplatform/core/core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ package object core {

type VersionTag = VersionTag.Type

def idsToString(ids: Seq[(NetworkObjectTypeId.Value, util.ModifierId)])(implicit enc: ScorexEncoder): String = {
def idsToString(ids: Seq[(NetworkObjectTypeId.Value, util.ModifierId)]): String = {
List(ids.headOption, ids.lastOption)
.flatten
.map { case (typeId, id) => s"($typeId,${enc.encodeId(id)})" }
.map { case (typeId, id) => s"($typeId,${ScorexEncoder.encodeId(id)})" }
.mkString("[", "..", "]")
}

def idsToString(modifierType: NetworkObjectTypeId.Value, ids: Seq[util.ModifierId])(implicit encoder: ScorexEncoder): String = {
def idsToString(modifierType: NetworkObjectTypeId.Value, ids: Seq[util.ModifierId]): String = {
idsToString(ids.map(id => (modifierType, id)))
}

def idsToString(invData: InvData)(implicit encoder: ScorexEncoder): String = idsToString(invData.typeId, invData.ids)
def idsToString(invData: InvData): String = idsToString(invData.typeId, invData.ids)

def bytesToId: Array[Byte] => util.ModifierId = scorex.util.bytesToId

Expand Down
16 changes: 8 additions & 8 deletions ergo-core/src/main/scala/org/ergoplatform/settings/Algos.scala
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package org.ergoplatform.settings

import org.ergoplatform.utils
import org.ergoplatform.utils.ScorexEncoder
import scorex.crypto.authds.LeafData
import scorex.crypto.authds.merkle.MerkleTree
import scorex.crypto.hash.Digest32
import scorex.util._
import scorex.util.encode.BytesEncoder


object Algos extends ErgoAlgos with utils.ScorexEncoding {

// ErgoAlgos in sigmastate extends scorex.util.ScorexEncoding where encoder is BytesEncoder
// but here we use scorex.core.utils.ScorexEncoding where encoder is ScorexEncoder
// After ScorexEncoder is moved (there is even a todo for that) from scorex.core to scorex.util
// we can fix this ugliness.
override implicit val encoder: ScorexEncoder = utils.ScorexEncoder.default
override implicit val encoder: BytesEncoder = utils.ScorexEncoder

lazy val emptyMerkleTreeRoot: Digest32 = Algos.hash(LeafData @@ Array[Byte]())

@inline def encode(id: ModifierId): String = encoder.encode(id)
/**
* This method might be useful and reimplemented, if encoding of ModifierId and VersionTag
* is different form default bytes encoding, e.g. this method should be reimplemented together
* with encode() and decode methods
*/
@inline def encode(id: String): String = id

/**
* A method to build a Merkle tree over binary objects (leafs of the tree)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import scorex.util.encode.{Base16, BytesEncoder}

import scala.util.Try

class ScorexEncoder extends BytesEncoder {
object ScorexEncoder extends BytesEncoder {
@inline
override val Alphabet: String = Base16.Alphabet

Expand All @@ -16,14 +16,6 @@ class ScorexEncoder extends BytesEncoder {
@inline
override def decode(input: String): Try[Array[Byte]] = Base16.decode(input)

/**
* This method might be useful and reimplemented, if encoding of ModifierId and VersionTag
* is different form default bytes encoding, e.g. this method should be reimplemented together
* with encode() and decode methods
*/
@inline
def encode(input: String): String = input

/**
* This method might be useful and reimplemented, if encoding of ModifierId and VersionTag
* is different form default bytes encoding, e.g. this method should be reimplemented together
Expand All @@ -41,7 +33,3 @@ class ScorexEncoder extends BytesEncoder {
def encodeId(input: ModifierId): String = input

}

object ScorexEncoder {
val default: ScorexEncoder = new ScorexEncoder()
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.ergoplatform.utils

import scorex.util.encode.BytesEncoder

/**
* Trait with bytes to string encoder
* TODO extract to ScorexUtils project
*/
trait ScorexEncoding {
implicit val encoder: ScorexEncoder = ScorexEncoder.default
val encoder: BytesEncoder = ScorexEncoder
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import scala.util.{Failure, Success, Try}
*/
object ModifierValidator {

def apply(settings: ValidationSettings)(implicit e: ScorexEncoder): ValidationState[Unit] = {
ValidationState(ModifierValidator.success, settings)(e)
def apply(settings: ValidationSettings): ValidationState[Unit] = {
ValidationState(ModifierValidator.success, settings)
}

/** report recoverable modifier error that could be fixed by later retries */
Expand Down Expand Up @@ -65,7 +65,7 @@ object ModifierValidator {
}

/** This is the place where all the validation DSL lives */
case class ValidationState[T](result: ValidationResult[T], settings: ValidationSettings)(implicit e: ScorexEncoder) {
case class ValidationState[T](result: ValidationResult[T], settings: ValidationSettings) {

/** Create the next validation state as the result of given `operation` */
def pass[R](operation: => ValidationResult[R]): ValidationState[R] = {
Expand Down Expand Up @@ -115,6 +115,7 @@ case class ValidationState[T](result: ValidationResult[T], settings: ValidationS
/** Validate the `id`s are equal. The `error` callback will be provided with detail on argument values
*/
def validateEqualIds(id: Short, `given`: => ModifierId, expected: => ModifierId, modifierTypeId: NetworkObjectTypeId.Value): ValidationState[T] = {
val e = ScorexEncoder
pass {
if (!settings.isActive(id) || given == expected) result
else settings.getError(id, InvalidModifier(s"Given: ${e.encodeId(given)}, expected ${e.encodeId(expected)}", given, modifierTypeId))
Expand Down
11 changes: 4 additions & 7 deletions src/main/scala/org/ergoplatform/http/api/ErgoUtilsApiRoute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.ergoplatform.http.api.ApiError.BadRequest
import org.ergoplatform.settings.{ErgoSettings, RESTApiSettings}
import org.ergoplatform.{ErgoAddressEncoder, P2PKAddress}
import scorex.core.api.http.{ApiResponse, ApiRoute}
import org.ergoplatform.utils.ScorexEncoding
import org.ergoplatform.utils.ScorexEncoder
import scorex.crypto.hash.Blake2b256
import scorex.util.encode.Base16
import sigmastate.crypto.DLogProtocol.ProveDlog
Expand All @@ -18,10 +18,7 @@ import java.security.SecureRandom
import scala.util.Failure
import sigmastate.serialization.{ErgoTreeSerializer, GroupElementSerializer, SigmaSerializer}

class ErgoUtilsApiRoute(val ergoSettings: ErgoSettings)(
implicit val context: ActorRefFactory
) extends ApiRoute
with ScorexEncoding {
class ErgoUtilsApiRoute(val ergoSettings: ErgoSettings)(implicit val context: ActorRefFactory) extends ApiRoute {

private val SeedSize = 32
private val treeSerializer: ErgoTreeSerializer = new ErgoTreeSerializer
Expand All @@ -46,7 +43,7 @@ class ErgoUtilsApiRoute(val ergoSettings: ErgoSettings)(
private def seed(length: Int): String = {
val seed = new Array[Byte](length)
new SecureRandom().nextBytes(seed) //seed mutated here!
encoder.encode(seed)
ScorexEncoder.encode(seed)
}

def seedRoute: Route = (get & path("seed")) {
Expand All @@ -60,7 +57,7 @@ class ErgoUtilsApiRoute(val ergoSettings: ErgoSettings)(
def hashBlake2b: Route = {
(post & path("hash" / "blake2b") & entity(as[Json])) { json =>
json.as[String] match {
case Right(message) => ApiResponse(encoder.encode(Blake2b256(message)))
case Right(message) => ApiResponse(ScorexEncoder.encode(Blake2b256(message)))
case Left(ex) => ApiError(StatusCodes.BadRequest, ex.getMessage())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.ergoplatform.network.message.{InvSpec, MessageSpec, ModifiersSpec, Re
import scorex.core.network._
import scorex.core.network.{ConnectedPeer, ModifiersStatus, SendToPeer, SendToPeers}
import org.ergoplatform.network.message.{InvData, Message, ModifiersData}
import org.ergoplatform.utils.ScorexEncoding
import org.ergoplatform.utils.ScorexEncoder
import org.ergoplatform.validation.MalformedModifierError
import scorex.util.{ModifierId, ScorexLogging}
import scorex.core.network.DeliveryTracker
Expand Down Expand Up @@ -53,7 +53,7 @@ class ErgoNodeViewSynchronizer(networkControllerRef: ActorRef,
settings: ErgoSettings,
syncTracker: ErgoSyncTracker,
deliveryTracker: DeliveryTracker)(implicit ex: ExecutionContext)
extends Actor with Synchronizer with ScorexLogging with ScorexEncoding {
extends Actor with Synchronizer with ScorexLogging {

import org.ergoplatform.network.ErgoNodeViewSynchronizer._

Expand Down Expand Up @@ -777,7 +777,7 @@ class ErgoNodeViewSynchronizer(networkControllerRef: ActorRef,
case _ =>
// Penalize peer and do nothing - it will be switched to correct state on CheckDelivery
penalizeMisbehavingPeer(remote)
log.warn(s"Failed to parse transaction with declared id ${encoder.encodeId(id)} from ${remote.toString}")
log.warn(s"Failed to parse transaction with declared id ${ScorexEncoder.encodeId(id)} from ${remote.toString}")
}
}
}
Expand All @@ -801,7 +801,7 @@ class ErgoNodeViewSynchronizer(networkControllerRef: ActorRef,
// 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}")
log.warn(s"Failed to parse modifier with declared id ${ScorexEncoder.encodeId(id)} from ${remote.toString}")
None
}
}
Expand Down Expand Up @@ -1230,7 +1230,7 @@ class ErgoNodeViewSynchronizer(networkControllerRef: ActorRef,
} else {
// A block section is not delivered on time.
log.info(s"Peer ${peer.toString} has not delivered network object " +
s"$modifierTypeId : ${encoder.encodeId(modifierId)} on time")
s"$modifierTypeId : ${ScorexEncoder.encodeId(modifierId)} on time")

// Number of delivery checks for a block section, utxo set snapshot chunk or manifest
// increased or initialized, except the case where we can have issues with connectivity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import org.ergoplatform.network.ErgoNodeViewSynchronizerMessages._
import org.ergoplatform.nodeView.ErgoNodeViewHolder.{BlockAppliedTransactions, CurrentView, DownloadRequest}
import org.ergoplatform.nodeView.ErgoNodeViewHolder.ReceivableMessages._
import org.ergoplatform.modifiers.history.{ADProofs, HistoryModifierSerializer}
import org.ergoplatform.utils.ScorexEncoding
import org.ergoplatform.validation.RecoverableModifierError
import scorex.util.{ModifierId, ScorexLogging}
import spire.syntax.all.cfor
Expand All @@ -40,7 +39,7 @@ import scala.util.{Failure, Success, Try}
*
*/
abstract class ErgoNodeViewHolder[State <: ErgoState[State]](settings: ErgoSettings)
extends Actor with ScorexLogging with ScorexEncoding with FileUtils {
extends Actor with ScorexLogging with FileUtils {

private implicit lazy val actorSystem: ActorSystem = context.system

Expand Down Expand Up @@ -573,7 +572,7 @@ abstract class ErgoNodeViewHolder[State <: ErgoState[State]](settings: ErgoSetti
log.info("State and history are both empty on startup")
Success(stateIn)
case (stateId, Some(block), _) if stateId == block.id =>
log.info(s"State and history have the same version ${encoder.encode(stateId)}, no recovery needed.")
log.info(s"State and history have the same version ${Algos.encode(stateId)}, no recovery needed.")
Success(stateIn)
case (_, None, _) =>
log.info("State and history are inconsistent. History is empty on startup, rollback state to genesis.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ trait ErgoHistory
case (false, false) =>
// Modifiers from best header and best full chain are not involved, no rollback and links change required
historyStorage.insert(validityRow, BlockSection.emptyArray).map { _ =>
this -> ProgressInfo[BlockSection](None, Seq.empty, Seq.empty, Seq.empty)
this -> ProgressInfo.empty
}
case _ =>
// Modifiers from best header and best full chain are involved, links change required
Expand All @@ -146,7 +146,7 @@ trait ErgoHistory
newBestHeaderOpt.map(h => BestHeaderKey -> idToBytes(h.id)).toArray,
BlockSection.emptyArray
).map { _ =>
this -> ProgressInfo[BlockSection](None, Seq.empty, Seq.empty, Seq.empty)
this -> ProgressInfo.empty
}
} else {
val invalidatedChain: Seq[ErgoFullBlock] = bestFullBlockOpt.toSeq
Expand Down Expand Up @@ -182,7 +182,7 @@ trait ErgoHistory
//No headers become invalid. Just mark this modifier as invalid
log.warn(s"Modifier ${modifier.encodedId} of type ${modifier.modifierTypeId} is missing corresponding header")
historyStorage.insert(Array(validityKey(modifier.id) -> Array(0.toByte)), BlockSection.emptyArray).map { _ =>
this -> ProgressInfo[BlockSection](None, Seq.empty, Seq.empty, Seq.empty)
this -> ProgressInfo.empty
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import org.ergoplatform.nodeView.history.extra.ExtraIndex
import org.ergoplatform.nodeView.history.storage._
import org.ergoplatform.nodeView.history.storage.modifierprocessors.{BlockSectionProcessor, HeadersProcessor}
import org.ergoplatform.settings.{ErgoSettings, NipopowSettings}
import org.ergoplatform.utils.ScorexEncoding
import org.ergoplatform.validation.MalformedModifierError
import scorex.util.{ModifierId, ScorexLogging}

Expand All @@ -27,8 +26,7 @@ trait ErgoHistoryReader
with ContainsModifiers[BlockSection]
with HeadersProcessor
with BlockSectionProcessor
with ScorexLogging
with ScorexEncoding {
with ScorexLogging {

type ModifierIds = Seq[(NetworkObjectTypeId.Value, ModifierId)]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.ergoplatform.modifiers.history.HistoryModifierSerializer
import org.ergoplatform.modifiers.history.header.Header
import org.ergoplatform.nodeView.history.extra.{ExtraIndex, ExtraIndexSerializer, Segment}
import org.ergoplatform.settings.{Algos, CacheSettings, ErgoSettings}
import org.ergoplatform.utils.ScorexEncoding
import scorex.db.{ByteArrayWrapper, LDBFactory, LDBKVStore}
import scorex.util.{ModifierId, ScorexLogging, idToBytes}

Expand All @@ -28,8 +27,7 @@ import scala.jdk.CollectionConverters.asScalaIteratorConverter
*/
class HistoryStorage(indexStore: LDBKVStore, objectsStore: LDBKVStore, extraStore: LDBKVStore, config: CacheSettings)
extends ScorexLogging
with AutoCloseable
with ScorexEncoding {
with AutoCloseable {

private lazy val headersCache =
Caffeine.newBuilder()
Expand Down Expand Up @@ -84,7 +82,7 @@ class HistoryStorage(indexStore: LDBKVStore, objectsStore: LDBKVStore, extraStor
cacheModifier(pm)
Some(pm)
case Failure(_) =>
log.warn(s"Failed to parse modifier ${encoder.encode(id)} from db (bytes are: ${Algos.encode(bytes)})")
log.warn(s"Failed to parse modifier ${Algos.encode(id)} from db (bytes are: ${Algos.encode(bytes)})")
None
}
}
Expand All @@ -99,7 +97,7 @@ class HistoryStorage(indexStore: LDBKVStore, objectsStore: LDBKVStore, extraStor
}
Some(pm)
case Failure(_) =>
log.warn(s"Failed to parse index ${encoder.encode(id)} from db (bytes are: ${Algos.encode(bytes)})")
log.warn(s"Failed to parse index ${Algos.encode(id)} from db (bytes are: ${Algos.encode(bytes)})")
None
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package org.ergoplatform.nodeView.history.storage.modifierprocessors

import org.ergoplatform.consensus.ProgressInfo
import org.ergoplatform.modifiers.{BlockSection, NonHeaderBlockSection}
import org.ergoplatform.utils.ScorexEncoding

import scala.util.Try

/**
* Trait that declares interfaces for validation and processing of various
* block sections: BlockTransactions, ADProofs, etc.
*/
trait BlockSectionProcessor extends ScorexEncoding {
trait BlockSectionProcessor {

/**
* Whether state requires to download adProofs before full block application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import scala.util.{Failure, Success, Try}
trait EmptyBlockSectionProcessor extends BlockSectionProcessor {

override protected def process(m: NonHeaderBlockSection): Try[ProgressInfo[BlockSection]] =
Success(ProgressInfo[BlockSection](None, Seq.empty, Seq.empty, Seq.empty))
Success(ProgressInfo.empty)

override protected def validate(m: NonHeaderBlockSection): Try[Unit] =
Failure(new Error("Regime that does not support block sections processing"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ trait FullBlockProcessor extends HeadersProcessor {
//Orphaned block or full chain is not initialized yet
logStatus(Seq(), Seq(), params.fullBlock, None)
historyStorage.insert(Array.empty[(ByteArrayWrapper, Array[Byte])], Array(params.newModRow)).map { _ =>
ProgressInfo(None, Seq.empty, Seq.empty, Seq.empty)
ProgressInfo.empty
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ trait FullBlockSectionProcessor extends BlockSectionProcessor with FullBlockProc

private def justPutToHistory(m: NonHeaderBlockSection): Try[ProgressInfo[BlockSection]] = {
historyStorage.insert(Array.empty[(ByteArrayWrapper, Array[Byte])], Array[BlockSection](m)).map { _ =>
ProgressInfo(None, Seq.empty, Seq.empty, Seq.empty)
ProgressInfo.empty
}
}

Expand Down
Loading
Loading