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 105 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
105 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
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
LocallyGeneratedInputBlock / LocallyGeneratedOrderingBlock
  • Loading branch information
kushti committed Oct 16, 2024
commit ac824a46a532a85bb2676682de7522bbb6a5740e
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import org.ergoplatform.modifiers.BlockSection
/**
* Wrapper for locally generated block section
*/
case class LocallyGeneratedModifier(blockSection: BlockSection)
case class LocallyGeneratedBlockSection(blockSection: BlockSection)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.ergoplatform.nodeView

import org.ergoplatform.modifiers.ErgoFullBlock

case class LocallyGeneratedInputBlock(efb: ErgoFullBlock)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.ergoplatform.nodeView

import org.ergoplatform.modifiers.ErgoFullBlock

case class LocallyGeneratedOrderingBlock(efb: ErgoFullBlock)
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 @@ -12,7 +12,7 @@ import org.ergoplatform.nodeView.ErgoReadersHolder.GetDataFromHistory
import org.ergoplatform.nodeView.history.ErgoHistoryReader
import org.ergoplatform.settings.{Algos, ErgoSettings, RESTApiSettings}
import org.ergoplatform.http.api.ApiError.BadRequest
import org.ergoplatform.nodeView.LocallyGeneratedModifier
import org.ergoplatform.nodeView.LocallyGeneratedBlockSection
import scorex.core.api.http.ApiResponse
import scorex.crypto.authds.merkle.MerkleProof
import scorex.crypto.hash.Digest32
Expand Down Expand Up @@ -127,9 +127,9 @@ case class BlocksApiRoute(viewHolderRef: ActorRef, readersHolder: ActorRef, ergo
if (ergoSettings.chainSettings.powScheme.validate(block.header).isSuccess) {
log.info("Received a new valid block through the API: " + block)

viewHolderRef ! LocallyGeneratedModifier(block.header)
viewHolderRef ! LocallyGeneratedBlockSection(block.header)
block.blockSections.foreach {
viewHolderRef ! LocallyGeneratedModifier(_)
viewHolderRef ! LocallyGeneratedBlockSection(_)
}

ApiResponse.OK
Expand Down
19 changes: 8 additions & 11 deletions src/main/scala/org/ergoplatform/mining/CandidateGenerator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import org.ergoplatform.modifiers.mempool.{ErgoTransaction, UnconfirmedTransacti
import org.ergoplatform.network.ErgoNodeViewSynchronizerMessages._
import org.ergoplatform.nodeView.ErgoNodeViewHolder.ReceivableMessages.EliminateTransactions
import org.ergoplatform.nodeView.ErgoReadersHolder.{GetReaders, Readers}
import org.ergoplatform.nodeView.LocallyGeneratedModifier
import org.ergoplatform.nodeView.{LocallyGeneratedInputBlock, LocallyGeneratedOrderingBlock}
import org.ergoplatform.nodeView.history.ErgoHistoryUtils.Height
import org.ergoplatform.nodeView.history.{ErgoHistoryReader, ErgoHistoryUtils}
import org.ergoplatform.nodeView.mempool.ErgoMemPoolReader
import org.ergoplatform.nodeView.state.{ErgoState, ErgoStateContext, StateType, UtxoStateReader}
import org.ergoplatform.nodeView.state.{ErgoState, ErgoStateContext, UtxoStateReader}
import org.ergoplatform.settings.{ErgoSettings, ErgoValidationSettingsUpdate, Parameters}
import org.ergoplatform.sdk.wallet.Constants.MaxAssetsPerBox
import org.ergoplatform.subblocks.SubBlockInfo
Expand Down Expand Up @@ -57,24 +57,20 @@ class CandidateGenerator(
readersHolderRef ! GetReaders
}

/** Send solved block to local blockchain controller */
/** Send solved ordering block to processing */
private def sendOrderingToNodeView(newBlock: ErgoFullBlock): Unit = {
log.info(
s"New ordering block ${newBlock.id} w. nonce ${Longs.fromByteArray(newBlock.header.powSolution.n)}"
)
viewHolderRef ! LocallyGeneratedModifier(newBlock.header)
val sectionsToApply = if (ergoSettings.nodeSettings.stateType == StateType.Digest) {
newBlock.blockSections
} else {
newBlock.mandatoryBlockSections
}
sectionsToApply.foreach(viewHolderRef ! LocallyGeneratedModifier(_))
viewHolderRef ! LocallyGeneratedOrderingBlock(newBlock)
}

/** Send solved input block to processing */
private def sendInputToNodeView(newBlock: ErgoFullBlock): Unit = {
log.info(
s"New input block ${newBlock.id} w. nonce ${Longs.fromByteArray(newBlock.header.powSolution.n)}"
)
viewHolderRef ! LocallyGeneratedInputBlock(newBlock)
}

override def receive: Receive = {
Expand Down Expand Up @@ -211,7 +207,8 @@ class CandidateGenerator(
log.info("Input-block mined!")
val newBlock = completeInputBlock(state.cache.get.candidateBlock, solution)
val powValid = SubBlockAlgos.checkInputBlockPoW(newBlock.header)
// todo: check links? send to node view, update state
// todo: check links?
// todo: update candidate generator state
sendInputToNodeView(newBlock)
StatusReply.error(
new Exception(s"Input block found! PoW valid: $powValid")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,23 @@ abstract class ErgoNodeViewHolder[State <: ErgoState[State]](settings: ErgoSetti
}

protected def processLocallyGeneratedModifiers: Receive = {
case lm: LocallyGeneratedModifier =>
case lm: LocallyGeneratedBlockSection =>
log.info(s"Got locally generated modifier ${lm.blockSection.encodedId} of type ${lm.blockSection.modifierTypeId}")
pmodModify(lm.blockSection, local = true)
case LocallyGeneratedOrderingBlock(efb) =>
log.info(s"Got locally generated ordering block ${efb.id}")
pmodModify(efb.header, local = true)
val sectionsToApply = if (settings.nodeSettings.stateType == StateType.Digest) {
efb.blockSections
} else {
efb.mandatoryBlockSections
}
sectionsToApply.foreach { section =>
pmodModify(section, local = true)
}
case LocallyGeneratedInputBlock(efb) =>
log.info(s"Got locally generated input block ${efb.id}")
// todo: real processing
}

protected def getCurrentInfo: Receive = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.ergoplatform.utils.LoggingUtil
import org.ergoplatform.wallet.boxes.ErgoBoxSerializer
import scorex.db.{ByteArrayWrapper, LDBVersionedStore}
import org.ergoplatform.core._
import org.ergoplatform.nodeView.LocallyGeneratedModifier
import org.ergoplatform.nodeView.LocallyGeneratedBlockSection
import org.ergoplatform.utils.ScorexEncoding
import scorex.crypto.authds.ADDigest
import scorex.util.ScorexLogging
Expand Down Expand Up @@ -81,7 +81,7 @@ class DigestState protected(override val version: VersionTag,
Failure(new Exception(s"Modifier not validated: $a"))
}

override def applyModifier(mod: BlockSection, estimatedTip: Option[Height])(generate: LocallyGeneratedModifier => Unit): Try[DigestState] =
override def applyModifier(mod: BlockSection, estimatedTip: Option[Height])(generate: LocallyGeneratedBlockSection => Unit): Try[DigestState] =
(processFullBlock orElse processHeader orElse processOther) (mod)

@SuppressWarnings(Array("OptionGet"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.ergoplatform.wallet.interpreter.ErgoInterpreter
import org.ergoplatform.validation.ValidationResult.Valid
import org.ergoplatform.validation.{ModifierValidator, ValidationResult}
import org.ergoplatform.core.{VersionTag, idToVersion}
import org.ergoplatform.nodeView.LocallyGeneratedModifier
import org.ergoplatform.nodeView.LocallyGeneratedBlockSection
import scorex.crypto.authds.avltree.batch.{Insert, Lookup, Remove}
import scorex.crypto.authds.{ADDigest, ADValue}
import scorex.util.encode.Base16
Expand Down Expand Up @@ -53,7 +53,7 @@ trait ErgoState[IState <: ErgoState[IState]] extends ErgoStateReader {
* @param generate function that handles newly created modifier as a result of application the current one
* @return new State
*/
def applyModifier(mod: BlockSection, estimatedTip: Option[Height])(generate: LocallyGeneratedModifier => Unit): Try[IState]
def applyModifier(mod: BlockSection, estimatedTip: Option[Height])(generate: LocallyGeneratedBlockSection => Unit): Try[IState]

def rollbackTo(version: VersionTag): Try[IState]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.ergoplatform.settings.ValidationRules.{fbDigestIncorrect, fbOperation
import org.ergoplatform.settings.{Algos, ErgoSettings, Parameters}
import org.ergoplatform.utils.LoggingUtil
import org.ergoplatform.core._
import org.ergoplatform.nodeView.LocallyGeneratedModifier
import org.ergoplatform.nodeView.LocallyGeneratedBlockSection
import org.ergoplatform.validation.ModifierValidator
import scorex.crypto.authds.avltree.batch._
import scorex.crypto.authds.avltree.batch.serialization.{BatchAVLProverManifest, BatchAVLProverSubtree}
Expand Down Expand Up @@ -108,7 +108,7 @@ class UtxoState(override val persistentProver: PersistentBatchAVLProver[Digest32
}

private def applyFullBlock(fb: ErgoFullBlock, estimatedTip: Option[Height])
(generate: LocallyGeneratedModifier => Unit): Try[UtxoState] = {
(generate: LocallyGeneratedBlockSection => Unit): Try[UtxoState] = {
val keepVersions = ergoSettings.nodeSettings.keepVersions

// avoid storing versioned information in the database when block being processed is behind
Expand Down Expand Up @@ -192,7 +192,7 @@ class UtxoState(override val persistentProver: PersistentBatchAVLProver[Digest32
if (fb.adProofs.isEmpty) {
if (fb.height >= estimatedTip.getOrElse(Int.MaxValue) - ergoSettings.nodeSettings.adProofsSuffixLength) {
val adProofs = ADProofs(fb.header.id, proofBytes)
generate(LocallyGeneratedModifier(adProofs))
generate(LocallyGeneratedBlockSection(adProofs))
}
}

Expand All @@ -213,7 +213,7 @@ class UtxoState(override val persistentProver: PersistentBatchAVLProver[Digest32
}

override def applyModifier(mod: BlockSection, estimatedTip: Option[Height])
(generate: LocallyGeneratedModifier => Unit): Try[UtxoState] = mod match {
(generate: LocallyGeneratedBlockSection => Unit): Try[UtxoState] = mod match {
case fb: ErgoFullBlock => applyFullBlock(fb, estimatedTip)(generate)

case bs: BlockSection =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.ergoplatform.modifiers.BlockSection
import org.ergoplatform.nodeView.state.DigestState
import org.ergoplatform.settings.ErgoSettings
import org.ergoplatform.core.VersionTag
import org.ergoplatform.nodeView.LocallyGeneratedModifier
import org.ergoplatform.nodeView.LocallyGeneratedBlockSection

import scala.util.Try

Expand All @@ -15,7 +15,7 @@ class WrappedDigestState(val digestState: DigestState,
extends DigestState(digestState.version, digestState.rootDigest, digestState.store, settings) {

override def applyModifier(mod: BlockSection, estimatedTip: Option[Height])
(generate: LocallyGeneratedModifier => Unit): Try[WrappedDigestState] = {
(generate: LocallyGeneratedBlockSection => Unit): Try[WrappedDigestState] = {
wrapped(super.applyModifier(mod, estimatedTip)(_ => ()), wrappedUtxoState.applyModifier(mod, estimatedTip)(_ => ()))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.ergoplatform.settings.{ErgoSettings, Parameters}
import org.ergoplatform.settings.Algos.HF
import org.ergoplatform.wallet.boxes.ErgoBoxSerializer
import org.ergoplatform.core.{VersionTag, idToVersion}
import org.ergoplatform.nodeView.LocallyGeneratedModifier
import org.ergoplatform.nodeView.LocallyGeneratedBlockSection
import scorex.crypto.authds.avltree.batch._
import scorex.crypto.hash.Digest32
import scorex.db.{ByteArrayWrapper, LDBVersionedStore}
Expand All @@ -36,7 +36,7 @@ class WrappedUtxoState(prover: PersistentBatchAVLProver[Digest32, HF],
}

override def applyModifier(mod: BlockSection, estimatedTip: Option[Height] = None)
(generate: LocallyGeneratedModifier => Unit): Try[WrappedUtxoState] =
(generate: LocallyGeneratedBlockSection => Unit): Try[WrappedUtxoState] =
super.applyModifier(mod, estimatedTip)(generate) match {
case Success(us) =>
mod match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.ergoplatform.settings.{Algos, Constants, ErgoSettings}
import org.ergoplatform.utils.{ErgoCorePropertyTest, NodeViewTestConfig, NodeViewTestOps, TestCase}
import org.ergoplatform.nodeView.ErgoNodeViewHolder.ReceivableMessages._
import org.ergoplatform.network.ErgoNodeViewSynchronizerMessages._
import org.ergoplatform.nodeView.{ErgoNodeViewHolder, LocallyGeneratedModifier}
import org.ergoplatform.nodeView.{ErgoNodeViewHolder, LocallyGeneratedBlockSection}
import org.ergoplatform.nodeView.ErgoNodeViewHolder.ReceivableMessages.ChainProgress
import org.ergoplatform.nodeView.mempool.ErgoMemPoolUtils.ProcessingOutcome.Accepted
import org.ergoplatform.wallet.utils.FileUtils
Expand Down Expand Up @@ -66,7 +66,7 @@ class ErgoNodeViewHolderSpec extends ErgoCorePropertyTest with NodeViewTestOps w
subscribeEvents(classOf[SyntacticallySuccessfulModifier])

//sending header
nodeViewHolderRef ! LocallyGeneratedModifier(block.header)
nodeViewHolderRef ! LocallyGeneratedBlockSection(block.header)
expectMsgType[SyntacticallySuccessfulModifier]

getHistoryHeight shouldBe GenesisHeight
Expand Down Expand Up @@ -106,15 +106,15 @@ class ErgoNodeViewHolderSpec extends ErgoCorePropertyTest with NodeViewTestOps w
val genesis = validFullBlock(parentOpt = None, us, bh)

subscribeEvents(classOf[SyntacticallySuccessfulModifier])
nodeViewHolderRef ! LocallyGeneratedModifier(genesis.header)
nodeViewHolderRef ! LocallyGeneratedBlockSection(genesis.header)
expectMsgType[SyntacticallySuccessfulModifier]

if (verifyTransactions) {
nodeViewHolderRef ! LocallyGeneratedModifier(genesis.blockTransactions)
nodeViewHolderRef ! LocallyGeneratedBlockSection(genesis.blockTransactions)
expectMsgType[SyntacticallySuccessfulModifier]
nodeViewHolderRef ! LocallyGeneratedModifier(genesis.adProofs.value)
nodeViewHolderRef ! LocallyGeneratedBlockSection(genesis.adProofs.value)
expectMsgType[SyntacticallySuccessfulModifier]
nodeViewHolderRef ! LocallyGeneratedModifier(genesis.extension)
nodeViewHolderRef ! LocallyGeneratedBlockSection(genesis.extension)
expectMsgType[SyntacticallySuccessfulModifier]
getBestFullBlockOpt shouldBe Some(genesis)
}
Expand Down Expand Up @@ -256,9 +256,9 @@ class ErgoNodeViewHolderSpec extends ErgoCorePropertyTest with NodeViewTestOps w
val (us, bh) = createUtxoState(fixture.settings)
val genesis = validFullBlock(parentOpt = None, us, bh)

nodeViewHolderRef ! LocallyGeneratedModifier(genesis.header)
nodeViewHolderRef ! LocallyGeneratedModifier(genesis.blockTransactions)
nodeViewHolderRef ! LocallyGeneratedModifier(genesis.extension)
nodeViewHolderRef ! LocallyGeneratedBlockSection(genesis.header)
nodeViewHolderRef ! LocallyGeneratedBlockSection(genesis.blockTransactions)
nodeViewHolderRef ! LocallyGeneratedBlockSection(genesis.extension)

getBestFullBlockOpt shouldBe Some(genesis)
getModifierById(genesis.adProofs.value.id) shouldBe genesis.adProofs
Expand Down Expand Up @@ -306,7 +306,7 @@ class ErgoNodeViewHolderSpec extends ErgoCorePropertyTest with NodeViewTestOps w

subscribeEvents(classOf[RecoverableFailedModification])
subscribeEvents(classOf[SyntacticallySuccessfulModifier])
nodeViewHolderRef ! LocallyGeneratedModifier(chain2block1.header)
nodeViewHolderRef ! LocallyGeneratedBlockSection(chain2block1.header)
expectMsgType[SyntacticallySuccessfulModifier]

applyBlock(chain2block2, excludeExt = true) shouldBe 'success
Expand All @@ -330,7 +330,7 @@ class ErgoNodeViewHolderSpec extends ErgoCorePropertyTest with NodeViewTestOps w
subscribeEvents(classOf[SyntacticallyFailedModification])

//sending header
nodeViewHolderRef ! LocallyGeneratedModifier(block.header)
nodeViewHolderRef ! LocallyGeneratedBlockSection(block.header)
expectMsgType[SyntacticallySuccessfulModifier]
val currentHeight = getHistoryHeight
currentHeight shouldBe GenesisHeight
Expand All @@ -357,16 +357,16 @@ class ErgoNodeViewHolderSpec extends ErgoCorePropertyTest with NodeViewTestOps w
block.blockTransactions.copy(txs = wrongTxs)
}

nodeViewHolderRef ! LocallyGeneratedModifier(recoverableTxs)
nodeViewHolderRef ! LocallyGeneratedBlockSection(recoverableTxs)
expectMsgType[RecoverableFailedModification]

nodeViewHolderRef ! LocallyGeneratedModifier(invalidTxsWithWrongOutputs)
nodeViewHolderRef ! LocallyGeneratedBlockSection(invalidTxsWithWrongOutputs)
expectMsgType[SyntacticallyFailedModification]

nodeViewHolderRef ! LocallyGeneratedModifier(invalidTxsWithWrongInputs)
nodeViewHolderRef ! LocallyGeneratedBlockSection(invalidTxsWithWrongInputs)
expectMsgType[SyntacticallyFailedModification]

nodeViewHolderRef ! LocallyGeneratedModifier(block.blockTransactions)
nodeViewHolderRef ! LocallyGeneratedBlockSection(block.blockTransactions)
expectMsgType[SyntacticallySuccessfulModifier]
}

Expand All @@ -384,21 +384,21 @@ class ErgoNodeViewHolderSpec extends ErgoCorePropertyTest with NodeViewTestOps w
subscribeEvents(classOf[SyntacticallyFailedModification])

//sending header
nodeViewHolderRef ! LocallyGeneratedModifier(block.header)
nodeViewHolderRef ! LocallyGeneratedBlockSection(block.header)
expectMsgType[SyntacticallySuccessfulModifier]

val randomId = modifierIdGen.sample.value
val wrongProofsBytes = SerializedAdProof @@ block.adProofs.value.proofBytes.reverse
val wrongProofs1 = block.adProofs.map(_.copy(headerId = randomId))
val wrongProofs2 = block.adProofs.map(_.copy(proofBytes = wrongProofsBytes))

nodeViewHolderRef ! LocallyGeneratedModifier(wrongProofs1.value)
nodeViewHolderRef ! LocallyGeneratedBlockSection(wrongProofs1.value)
expectMsgType[RecoverableFailedModification]

nodeViewHolderRef ! LocallyGeneratedModifier(wrongProofs2.value)
nodeViewHolderRef ! LocallyGeneratedBlockSection(wrongProofs2.value)
expectMsgType[SyntacticallyFailedModification]

nodeViewHolderRef ! LocallyGeneratedModifier(block.adProofs.value)
nodeViewHolderRef ! LocallyGeneratedBlockSection(block.adProofs.value)
expectMsgType[SyntacticallySuccessfulModifier]
}

Expand All @@ -417,7 +417,7 @@ class ErgoNodeViewHolderSpec extends ErgoCorePropertyTest with NodeViewTestOps w
subscribeEvents(classOf[SyntacticallyFailedModification])

//sending header
nodeViewHolderRef ! LocallyGeneratedModifier(block.header)
nodeViewHolderRef ! LocallyGeneratedBlockSection(block.header)
expectMsgType[SyntacticallyFailedModification]
getBestHeaderOpt shouldBe None
getHistoryHeight shouldBe EmptyHistoryHeight
Expand All @@ -436,7 +436,7 @@ class ErgoNodeViewHolderSpec extends ErgoCorePropertyTest with NodeViewTestOps w
subscribeEvents(classOf[SyntacticallySuccessfulModifier])
subscribeEvents(classOf[SyntacticallyFailedModification])

nodeViewHolderRef ! LocallyGeneratedModifier(block.header)
nodeViewHolderRef ! LocallyGeneratedBlockSection(block.header)
expectMsgType[SyntacticallySuccessfulModifier]
getHistoryHeight shouldBe GenesisHeight
getHeightOf(block.header.id) shouldBe Some(GenesisHeight)
Expand Down Expand Up @@ -485,7 +485,7 @@ class ErgoNodeViewHolderSpec extends ErgoCorePropertyTest with NodeViewTestOps w
subscribeEvents(classOf[SyntacticallySuccessfulModifier])
subscribeEvents(classOf[SyntacticallyFailedModification])

nodeViewHolderRef ! LocallyGeneratedModifier(header)
nodeViewHolderRef ! LocallyGeneratedBlockSection(header)
expectMsgType[SyntacticallyFailedModification]
getHistoryHeight shouldBe EmptyHistoryHeight
getHeightOf(header.id) shouldBe None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.ergoplatform.nodeView.viewholder
import akka.actor.ActorRef
import org.ergoplatform.mining.DefaultFakePowScheme
import org.ergoplatform.modifiers.ErgoFullBlock
import org.ergoplatform.nodeView.LocallyGeneratedModifier
import org.ergoplatform.nodeView.LocallyGeneratedBlockSection
import org.ergoplatform.nodeView.state.wrapped.WrappedUtxoState
import org.ergoplatform.nodeView.state.{DigestState, StateType}
import org.ergoplatform.settings.{ErgoSettings, ErgoSettingsReader, VotingSettings}
Expand Down Expand Up @@ -59,7 +59,7 @@ class PrunedNodeViewHolderSpec extends ErgoCorePropertyTest with NodeViewTestOps

fullChain.takeRight(totalBlocks - toSkip).foreach { block =>
block.blockSections.foreach { section =>
nodeViewHolderRef ! LocallyGeneratedModifier(section)
nodeViewHolderRef ! LocallyGeneratedBlockSection(section)
Thread.sleep(50)
}
}
Expand Down
Loading
Loading