Skip to content

Commit

Permalink
config polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Jun 7, 2023
1 parent a77e58e commit 418d45d
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ object VersionedLDBAVLStorage {
* Calculate tree digest, given root node label(hash) and root node height, by appending height to the hash
*/
def digest[D <: hash.Digest](rootNodeLabel: D, rootNodeHeight: Int): ADDigest = {
assert(rootNodeHeight >= 0 && rootNodeHeight <= 127)
assert(rootNodeHeight >= 0 && rootNodeHeight < 256)
// rootNodeHeight should never be more than 255, so the toByte conversion is safe (though it may cause an incorrect
// sign on the signed byte if rootHeight>127, but we handle that case correctly on decoding the byte back to int in the
// verifier, by adding 256 if it's negative).
Expand Down
2 changes: 1 addition & 1 deletion papers/utxo.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ tree is available in [the Scrypto framework](https://github.com/input-output-hk/

Time is broken into epochs, 1 epoch = 52,224 blocks (~72.5 days).
Snapshot is taken after last block of an epoch, namely, after processing a block with
height *h % 51200 == 52,224*.
height *h % 52224 == 52,223*.

Chunk format
------------
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ ergo {
# Minimal suffix size for PoPoW proof (may be pre-defined constant or settings parameter)
minimalSuffix = 10

# how many utxo set snapshots to store, 0 means that they are not stored at all
storingUtxoSnapshots = 0

# Is the node is doing mining
mining = false

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/mainnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ ergo {
#
# To validate all the scripts for all the blocks, set checkpoint = null.
checkpoint = {
height = 856800
blockId = "13335f1ec71a0b5511f30f03b283ca8c3549803c9b84a3a92106245b6f6282fb"
height = 1020454
blockId = "7829c6513c5b319b86e87253ed29d51fed61597c65e32f5197434461ccc4c905"
}

# List with hex-encoded identifiers of transactions banned from getting into memory pool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@ case class UtxoApiRoute(readersHolder: ActorRef, override val settings: RESTApiS
case _ => None
})
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ abstract class ErgoNodeViewHolder[State <: ErgoState[State]](settings: ErgoSetti
history().createPersistentProver(store, history(), height, blockId) match {
case Success(pp) =>
log.info(s"Restoring state from prover with digest ${pp.digest} reconstructed for height $height")
history().utxoSnapshotApplied(height)
history().onUtxoSnapshotApplied(height)
val newState = new UtxoState(pp, version = VersionTag @@@ blockId, store, settings)
updateNodeView(updatedState = Some(newState.asInstanceOf[State]))
case Failure(t) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ trait ToDownloadProcessor
val minHeight = Math.max(1, fb.header.height - 100)
continuation(minHeight, Map.empty, maxHeight = Int.MaxValue)
case None if (nodeSettings.utxoSettings.utxoBootstrap && !isUtxoSnapshotApplied) =>
// if bootstrapping with UTXO set snapshot is chosen, and no snapshot applied yet, ask peers for snapshots
if (utxoSetSnapshotDownloadPlan().isEmpty) {
Map(SnapshotsInfoTypeId.value -> Seq.empty)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import scorex.crypto.hash.Digest32
* @param createdTime - time when snapshot was created
* @param latestUpdateTime - latest time when anything was updated for the state of UTXO set snapshot
* @param snapshotHeight - height of a block UTXO set snapshot is corresponding to (UTXO set if after the block applied)
* @param utxoSetRootHash - root hash of AVL+ tree which is authenticating UTXO set snasphot
* @param utxoSetTreeHeight - tree height of AVL+ tree which is authenticating UTXO set snasphot
* @param expectedChunkIds - ids of UTXO set snasphot chunks to be downloaded
* @param utxoSetRootHash - root hash of AVL+ tree which is authenticating UTXO set snapshot
* @param utxoSetTreeHeight - tree height of AVL+ tree which is authenticating UTXO set snapshot
* @param expectedChunkIds - ids of UTXO set snapshot chunks to be downloaded
* @param downloadedChunkIds - shapshot chunks already downloaded, in form of boolean map over
* `expectedChunkIds` (true = downloaded)
* @param downloadingChunks - number of UTXO set shapshot chunks the node is currently downloading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ trait UtxoSetSnapshotProcessor extends MinimalFullBlockHeightFunctions with Scor
* Writes that UTXO set snapshot applied at height `height`. Starts full blocks applications since the next block
* after.
*/
def utxoSnapshotApplied(height: Height): Unit = {
def onUtxoSnapshotApplied(height: Height): Unit = {
val utxoPhaseTime = {
_cachedDownloadPlan.map(_.latestUpdateTime).getOrElse(0L) - _cachedDownloadPlan.map(_.createdTime).getOrElse(0L)
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/org/ergoplatform/settings/Constants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ object Constants {
* So for the Ergo mainnet the value should be divisible by 1024 (for testnet, 128, any number divisible by
* 1024 is divisible by 128 also.
*/
// todo: change before deployment to 52224
val MakeSnapshotEvery = 1024
val MakeSnapshotEvery = 52224

/**
* AVL+ tree node parameters. The tree is used to authenticate UTXO set.
Expand Down

0 comments on commit 418d45d

Please sign in to comment.