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

Network specific launch parameters #2191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
package org.ergoplatform.settings

/**
* Parameters corresponding to initial moment of time in the mainnet and the testnet
*/
object LaunchParameters extends Parameters(height = 0,
parametersTable = Parameters.DefaultParameters,
proposedUpdate = ErgoValidationSettingsUpdate.empty)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.ergoplatform.settings

import org.ergoplatform.modifiers.history.header.Header

/**
* Parameters corresponding to initial moment of time in the mainnet and the testnet
*/
object MainnetLaunchParameters extends Parameters(height = 0,
parametersTable = Parameters.DefaultParameters,
proposedUpdate = ErgoValidationSettingsUpdate.empty)


object DevnetLaunchParameters extends Parameters(height = 0,
parametersTable = Parameters.DefaultParameters.updated(Parameters.BlockVersion, Header.Interpreter50Version),
proposedUpdate = ErgoValidationSettingsUpdate.empty)
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,10 @@ class Parameters(val height: Height,
activatedUpdate = proposedUpdate
}

// Forced version update to version 2 at height provided in settings
if (height == votingSettings.version2ActivationHeight) {
// Forced update should happen, but some soft-fork update happened before.
// Node should fail at this point, as the situation is unclear
require(table(BlockVersion) == 1, "Protocol version is not 1 on the hard-fork")
table = table.updated(BlockVersion, table(BlockVersion) + 1)
// Forced version update to version 2 at height provided in settings.
// Needed as it was non-voted hard-fork in the mainnet.
if (height == votingSettings.version2ActivationHeight && table(BlockVersion) == 1) {
table = table.updated(BlockVersion, 2)
}
(table, activatedUpdate)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object ErgoCoreTestConstants extends ScorexLogging {
implicit val validationSettingsNoIl: ErgoValidationSettings = validationSettings
.updated(ErgoValidationSettingsUpdate(Seq(exIlUnableToValidate, exIlEncoding, exIlStructure, exEmpty), Seq()))

val parameters: Parameters = LaunchParameters
val parameters: Parameters = MainnetLaunchParameters
val nipopowAlgos = new NipopowAlgos(chainSettings)

val emission: EmissionRules = chainSettings.emissionRules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.ergoplatform.nodeView.ErgoReadersHolder.{GetReaders, Readers}
import org.ergoplatform.nodeView.history.ErgoHistory
import org.ergoplatform.nodeView.history.ErgoHistoryUtils._
import org.ergoplatform.nodeView.state.{ErgoStateReader, StateType}
import org.ergoplatform.settings.{Algos, ErgoSettings, LaunchParameters, Parameters}
import org.ergoplatform.settings.{Algos, ErgoSettings, Parameters}
import scorex.core.network.ConnectedPeer
import scorex.core.network.NetworkController.ReceivableMessages.{GetConnectedPeers, GetPeersStatus}
import org.ergoplatform.network.ErgoNodeViewSynchronizerMessages._
Expand Down Expand Up @@ -63,7 +63,7 @@ class ErgoStatsCollector(readersHolder: ActorRef,
launchTime = System.currentTimeMillis(),
lastIncomingMessageTime = System.currentTimeMillis(),
None,
LaunchParameters,
settings.launchParameters,
eip27Supported = true,
settings.scorexSettings.restApi.publicUrl,
settings.nodeSettings.extraIndex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.ergoplatform.nodeView.mempool.ErgoMemPoolUtils.ProcessingOutcome
import org.ergoplatform.nodeView.state._
import org.ergoplatform.nodeView.wallet.ErgoWallet
import org.ergoplatform.wallet.utils.FileUtils
import org.ergoplatform.settings.{Algos, Constants, ErgoSettings, LaunchParameters, NetworkType, ScorexSettings}
import org.ergoplatform.settings.{Algos, Constants, ErgoSettings, NetworkType, ScorexSettings}
import org.ergoplatform.core._
import org.ergoplatform.network.ErgoNodeViewSynchronizerMessages._
import org.ergoplatform.nodeView.ErgoNodeViewHolder.{BlockAppliedTransactions, CurrentView, DownloadRequest}
Expand Down Expand Up @@ -414,8 +414,7 @@ abstract class ErgoNodeViewHolder[State <: ErgoState[State]](settings: ErgoSetti

val history = ErgoHistory.readOrGenerate(settings)

val wallet = ErgoWallet.readOrGenerate(
history.getReader, settings, LaunchParameters)
val wallet = ErgoWallet.readOrGenerate(history.getReader, settings, settings.launchParameters)

val memPool = ErgoMemPool.empty(settings)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.ergoplatform.modifiers.mempool.ErgoTransaction
import org.ergoplatform.modifiers.state.StateChanges
import org.ergoplatform.nodeView.history.ErgoHistoryUtils._
import org.ergoplatform.settings.ValidationRules._
import org.ergoplatform.settings.{ChainSettings, Constants, ErgoSettings, LaunchParameters, NodeConfigurationSettings}
import org.ergoplatform.settings.{ChainSettings, Constants, ErgoSettings, NodeConfigurationSettings}
import org.ergoplatform.wallet.interpreter.ErgoInterpreter
import org.ergoplatform.validation.ValidationResult.Valid
import org.ergoplatform.validation.{ModifierValidator, ValidationResult}
Expand Down Expand Up @@ -272,7 +272,7 @@ object ErgoState extends ScorexLogging {
val boxes = genesisBoxes(settings.chainSettings)
val bh = BoxHolder(boxes)

UtxoState.fromBoxHolder(bh, boxes.headOption, stateDir, settings, LaunchParameters).ensuring(us => {
UtxoState.fromBoxHolder(bh, boxes.headOption, stateDir, settings, settings.launchParameters).ensuring(us => {
log.info(s"Genesis UTXO state generated with hex digest ${Base16.encode(us.rootDigest)}")
java.util.Arrays.equals(us.rootDigest, settings.chainSettings.genesisStateDigest) && us.version == genesisStateVersion
}) -> bh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.ergoplatform.nodeView.state
import org.ergoplatform.{ErgoBox, NodeViewComponent}
import org.ergoplatform.nodeView.history.ErgoHistoryUtils.Height
import org.ergoplatform.nodeView.history.ErgoHistoryReader
import org.ergoplatform.settings.{Algos, Constants, ErgoSettings, LaunchParameters, Parameters}
import org.ergoplatform.settings.{Algos, Constants, ErgoSettings, Parameters}
import org.ergoplatform.core.VersionTag
import scorex.crypto.authds.ADDigest
import scorex.crypto.hash.Digest32
Expand Down Expand Up @@ -69,7 +69,7 @@ object ErgoStateReader extends ScorexLogging {
.flatMap(b => ErgoStateContextSerializer(settings.chainSettings).parseBytesTry(b).toOption)
.getOrElse {
log.warn("Can't read blockchain parameters from database")
ErgoStateContext.empty(settings.chainSettings, LaunchParameters)
ErgoStateContext.empty(settings.chainSettings, settings.launchParameters)
}
}

Expand All @@ -94,7 +94,7 @@ object ErgoStateReader extends ScorexLogging {
if (lastHeaders.size != Constants.LastHeadersInContext) {
Failure(new Exception(s"Only ${lastHeaders.size} headers found in reconstructStateContextBeforeEpoch"))
} else {
val empty = ErgoStateContext.empty(settings.chainSettings, LaunchParameters)
val empty = ErgoStateContext.empty(settings.chainSettings, settings.launchParameters)
val esc = new ErgoStateContext( lastHeaders,
None,
empty.genesisStateDigest,
Expand Down
8 changes: 8 additions & 0 deletions src/main/scala/org/ergoplatform/settings/ErgoSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ case class ErgoSettings(directory: String,
.toOption
}

def launchParameters: Parameters = {
if (networkType == NetworkType.DevNet) {
DevnetLaunchParameters
} else {
MainnetLaunchParameters
}
}

}

object ErgoSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class ErgoNodeTransactionSpec extends ErgoCorePropertyTest {
property("monotonic creation height") {
def stateContext(height: Int, blockVersion: Byte): ErgoStateContext = {
val header = defaultHeaderGen.sample.get.copy(version = blockVersion, height = height)
val params = Parameters(LaunchParameters.height,
LaunchParameters.parametersTable.updated(Parameters.BlockVersion, blockVersion),
LaunchParameters.proposedUpdate)
val params = Parameters(MainnetLaunchParameters.height,
MainnetLaunchParameters.parametersTable.updated(Parameters.BlockVersion, blockVersion),
MainnetLaunchParameters.proposedUpdate)
new ErgoStateContext(Seq(header), None, genesisStateDigest, params, ErgoValidationSettings.initial,
VotingData.empty)(settings.chainSettings)
}
Expand Down Expand Up @@ -496,7 +496,7 @@ class ErgoNodeTransactionSpec extends ErgoCorePropertyTest {
property("Soft-forked execution of Ergoscript containing unknown methods") {

val activatedVersion = 3.toByte
val params = new Parameters(0, LaunchParameters.parametersTable.updated(123, activatedVersion + 1), ErgoValidationSettingsUpdate.empty)
val params = new Parameters(0, MainnetLaunchParameters.parametersTable.updated(123, activatedVersion + 1), ErgoValidationSettingsUpdate.empty)

// for next version, rule 1011 should be replaced , otherwise transaction validation will fail
// in this test, the rule is replaced with self, but for real activation this choice should be revised
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.ergoplatform.tools

import org.ergoplatform.settings.LaunchParameters.parametersTable
import org.ergoplatform.settings.MainnetLaunchParameters.parametersTable
import org.ergoplatform.settings.Parameters.{maxValues, minValues, parametersDescs, stepsTable}

object DefaultParametersPrinter extends App {
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/org/ergoplatform/tools/FeeSimulator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.ergoplatform.tools

import org.ergoplatform.modifiers.mempool.ErgoTransaction
import org.ergoplatform.settings.Constants._
import org.ergoplatform.settings.LaunchParameters._
import org.ergoplatform.settings.MainnetLaunchParameters._
import org.ergoplatform.{ErgoBoxCandidate, Input}
import scorex.crypto.authds.ADKey
import scorex.utils.Random
Expand Down
Loading