Skip to content

Commit

Permalink
Merge pull request #125 from excelsia/mainnetRelease
Browse files Browse the repository at this point in the history
Release 0.1.0
  • Loading branch information
sunnyking authored Sep 21, 2018
2 parents 4a7c7a7 + 63aa8ab commit 3c24f23
Show file tree
Hide file tree
Showing 14 changed files with 210 additions and 52 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enablePlugins(sbtdocker.DockerPlugin, JavaServerAppPackaging, JDebPackaging, Sys

name := "vee"
organization := "vee.tech"
version := "0.0.3"
version := "0.1.0"
scalaVersion in ThisBuild := "2.12.6"
crossPaths := false
publishArtifact in (Compile, packageDoc) := false
Expand Down Expand Up @@ -111,7 +111,7 @@ inConfig(Linux)(Seq(
))

network := Network(sys.props.get("network"))
normalizedName := network.value.name
normalizedName := "vee"

javaOptions in Universal ++= Seq(
// -J prefix is required by the bash script
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Vee node settings
vee {
# Node base directory
directory = ${user.home}"/vee"
directory = ${user.home}"/.vee"

# Application logging level. Could be TRACE | DEBUG | INFO | WARN | ERROR. Default value is INFO.
logging-level = INFO
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/wavesplatform/settings/Constants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ object Constants extends ScorexLogging {
val AgentName = s"VEE Core v${Version.VersionString}"

val UnitsInVee = 100000000L
val TotalVee = 10000000000L
val TotalVee = 10000000000L // unuse in mainnet
}
10 changes: 5 additions & 5 deletions src/main/scala/scorex/waves/http/DebugApiRoute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ case class DebugApiRoute(settings: RestAPISettings,
paramType = "path")
))
def blocks: Route = {
(path("blocks" / IntNumber) & get) { howMany =>
(path("blocks" / IntNumber) & get & withAuth) { howMany =>
complete(JsArray(history.lastBlocks(howMany).map { block =>
val bytes = block.bytes
Json.obj(bytes.length.toString -> Base58.encode(FastCryptographicHash(bytes)))
Expand All @@ -68,7 +68,7 @@ case class DebugApiRoute(settings: RestAPISettings,
@Path("/state")
@ApiOperation(value = "State", notes = "Get current state", httpMethod = "GET")
@ApiResponses(Array(new ApiResponse(code = 200, message = "Json state")))
def state: Route = (path("state") & get) {
def state: Route = (path("state") & get & withAuth) {
complete(stateReader.accountPortfolios
.map { case (k, v) =>
k.address -> v.balance
Expand Down Expand Up @@ -101,7 +101,7 @@ case class DebugApiRoute(settings: RestAPISettings,
))
@ApiResponses(Array(new ApiResponse(code = 200, message = "Json portfolio")))
def portfolios: Route = path("portfolios" / Segment) { (rawAddress) =>
(get & parameter('considerUnspent.as[Boolean])) { (considerUnspent) =>
(get & withAuth & parameter('considerUnspent.as[Boolean])) { (considerUnspent) =>
Address.fromString(rawAddress) match {
case Left(_) => complete(InvalidAddress)
case Right(address) =>
Expand All @@ -116,7 +116,7 @@ case class DebugApiRoute(settings: RestAPISettings,
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "height", value = "height", required = true, dataType = "integer", paramType = "path")
))
def stateVee: Route = (path("stateVee" / IntNumber) & get) { height =>
def stateVee: Route = (path("stateVee" / IntNumber) & get & withAuth) { height =>
val result = stateReader.accountPortfolios.keys
.map(acc => acc.stringRepr -> stateReader.balanceAtHeight(acc, height))
.filter(_._2 != 0)
Expand Down Expand Up @@ -169,7 +169,7 @@ case class DebugApiRoute(settings: RestAPISettings,
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json state")
))
def info: Route = (path("info") & get) {
def info: Route = (path("info") & get & withAuth) {
complete(Json.obj(
"stateHeight" -> stateReader.height,
"stateHash" -> stateReader.accountPortfoliosHash
Expand Down
38 changes: 29 additions & 9 deletions src/main/scala/vee/settings/BlockchainSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,36 @@ case class GenesisSettings(
averageBlockDelay: FiniteDuration)

object GenesisSettings {
val MAINNET = GenesisSettings(1460678400000L, 1465742577614L, Constants.UnitsInVee * Constants.TotalVee,
ByteStr.decodeBase58("FSH8eAAzZNqnG8xgTZtz5xuLqXySsXgAjmFEC25hXMbEufiGjqWPnGCZFt6gLiVLJny16ipxRNAkkzjjhqTjBE2").toOption,
val MAINNET = GenesisSettings(1537343925754686951L, 1537343925754686951L, 514285800000000000L,
ByteStr.decodeBase58("2XrcU7AoEbs1qACVgo6BADf3hbjPWtSaG2L36RVJAUmFvL96dWMrm6ohGb69uFi5CiCKNPaEBc9r6UYPbk5mTGwg").toOption,
List(
GenesisTransactionSettings("3PAWwWa6GbwcJaFzwqXQN5KQm7H96Y7SHTQ", Constants.UnitsInVee * Constants.TotalVee - 5 * Constants.UnitsInVee, 0),
GenesisTransactionSettings("3P8JdJGYc7vaLu4UXUZc1iRLdzrkGtdCyJM", Constants.UnitsInVee, 1),
GenesisTransactionSettings("3PAGPDPqnGkyhcihyjMHe9v36Y4hkAh9yDy", Constants.UnitsInVee, 2),
GenesisTransactionSettings("3P9o3ZYwtHkaU1KxsKkFjJqJKS3dLHLC9oF", Constants.UnitsInVee, 3),
GenesisTransactionSettings("3PJaDyprvekvPXPuAtxrapacuDJopgJRaU3", Constants.UnitsInVee, 4 ),
GenesisTransactionSettings("3PBWXDFUc86N2EQxKJmW8eFco65xTyMZx6J", Constants.UnitsInVee, 5)),
1529885280000000000L, 60.seconds)
GenesisTransactionSettings("ARMxPV8puShq49KzPoQb5XGttxghvLdMFg1",36000006000000000L,-1),
GenesisTransactionSettings("ARFHdvqddPNfMXNt9fgH7Lw1aGRgL29wTKY",15428574000000000L,-1),
GenesisTransactionSettings("ARQSe9A3DLryBqN4Y1NV1PhERnuWaDLheza",25097147000000000L,-1),
GenesisTransactionSettings("ARHY8cocXeGnH3q4bkLpU56sCg28fF5hSWV",36000006000000000L,-1),
GenesisTransactionSettings("ARCry9n7JvHF8rooXiEMhesAHP8zv3sBLDr",36000006000000000L,-1),
GenesisTransactionSettings("AR7M83ZypZc5WRzdZHjhULnQ7xzoMM8udJt",12342859200000000L,-1),
GenesisTransactionSettings("ARPdpZ9PT5kDbi2U6ZUgxoFwJzFchz7Fcsw",36000006000000000L,-1),
GenesisTransactionSettings("ARCK84TwkqzQEksj8pQTxbsCuRY9YGsAbSU",36000006000000000L,-1),
GenesisTransactionSettings("ARKbFz4N3f8Rgonf1Afd2aix2QtkCUjnWqW",39085720800000000L,-1),
GenesisTransactionSettings("ARRo5K1rfLk9wjXhUjAqxdZjK7LTjx7Y7ki",36000006000000000L,-1),
GenesisTransactionSettings("ARBLnj5P9XNspGRGj8UjS1Fny3pkvxJUqJV",36000006000000000L,-1),
GenesisTransactionSettings("AR5c7ibqGhkyjzYu143E171TiFdmPFHofKb",36000006000000000L,-1),
GenesisTransactionSettings("ARJukkvk47P9JKpdpjbvPQFr8Lv4D8Qsqnn",36000006000000000L,-1),
GenesisTransactionSettings("ARBD7fqPGPq5stYKyk3EbZe1w1FDYhh2KnZ",36000006000000000L,-1),
GenesisTransactionSettings("ARH6GEvr8FV12HN4rZ969K885sukp5qdNJY",36000006000000000L,-1),
GenesisTransactionSettings("AR2pa1RW5jvKV4b7PNnZG7Az6emz5WtiE4r",26331433000000000L,-1),
GenesisTransactionSettings("ARKMDAveps99s5k9ESiXjcXM9Ddp8p3GGAm",0,0),
GenesisTransactionSettings("ARKM1PkMevWdBjyEeMPAb7vrWWsJptDj891",0,4),
GenesisTransactionSettings("ARCmPJxYBkYAtxnu8qpoLA2iQbf7aJFRX2c",0,12),
GenesisTransactionSettings("ARNP2wJbehKh5Ck4Z2iR4pmnWiwgdsYh6Fw",0,16),
GenesisTransactionSettings("ARQiW9ckRc1GbbuEN3h4s18H8YH8mke15qB",0,24),
GenesisTransactionSettings("ARMfFAXxGZoFpQ7BwSKqjz9u2nxAtBRYXQ5",0,28),
GenesisTransactionSettings("ARM1o54Hdo3hHy83NE4BcmJHEdVUdeULZyZ",0,36),
GenesisTransactionSettings("ARDVLTDWf9Hwe3PBk16SNW7HCZXJPjJ43qE",0,40),
GenesisTransactionSettings("ARNNKhgFhW8ctmQYvckgf81PyHjsxDEzySd",0,48),
GenesisTransactionSettings("AR87ef8yc2Ldt1FGrJi85HW479TVeBCgS5V",0,52)),
1537343925000000000L, 60.seconds)

val TESTNET = GenesisSettings(1535356447650226656L, 1535356447650226656L, Constants.UnitsInVee * Constants.TotalVee,
ByteStr.decodeBase58("5n4ewwZh9F4MMpSvtdxLCu5MUKnhEyUth2w3zEfpuiX3vwS1STNCdi51fmowJuLT1CfFg1DuodSvxwBZDANvGNej").toOption,
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/vee/utils/JsonFileStorage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object JsonFileStorage {
private val aes = "AES"
private val algorithm = aes + "/ECB/PKCS5Padding"
private val hashing = "PBKDF2WithHmacSHA512"
private val hashingIterations = 999999
private val hashingIterations = 9999
private val keyLength = 256

import java.security.NoSuchAlgorithmException
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/vee/wallet/Wallet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object Wallet extends ScorexLogging {
}

private val chainName = if(AddressScheme.current.chainId == 'T') "testnet" else "mainnet"
private val agentString = s"VEE Wallet:1.0rc2/VEE Core:${Version.VersionString}/${chainName}"
private val agentString = s"VEE Wallet:1.0/VEE Core:${Version.VersionString}/${chainName}"

private case class WalletData(seed: String, accountSeeds: LinkedHashSet[ByteStr] = LinkedHashSet.empty, nonce: Long = 0, agent: String = agentString)

Expand Down
1 change: 0 additions & 1 deletion src/package/systemd.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Requires=${{start_facilities}}
Type=simple
EnvironmentFile=${{env_config}}
ExecStart=/usr/share/${{app_name}}/bin/${{exec}} \
-Dvee.directory=/var/lib/${{app_name}} \
-Dlogback.pattern="%%-5level %%logger{26} - %%msg%%n" \
-- /etc/${{app_name}}/vee.conf
Restart=always
Expand Down
1 change: 0 additions & 1 deletion src/package/upstart.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ chdir /usr/share/${{app_name}}

script
exec sudo -u ${{app_name}} bin/${{app_name}} \
-Dvee.directory=/var/lib/${{app_name}} \
-Dlogback.pattern='%date{yyyy-MM-dd HH:mm:ss} %-5level %logger{26} - %msg%n' \
-- /etc/${{app_name}}/vee.conf
end script
4 changes: 2 additions & 2 deletions src/test/scala/com/wavesplatform/http/DebugRouteSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DebugRouteSpec
val portfolioMap = portfolios.toMap
(state.accountPortfolios _).expects().returning(portfolioMap).once()

Get(routePath("/state")) ~> route ~> check {
Get(routePath("/state")) ~> api_key(apiKey) ~> route ~> check {
responseAs[JsObject] shouldEqual JsObject(portfolios.map {
case (account, p) => account.address -> JsNumber(p.balance)
})
Expand All @@ -52,7 +52,7 @@ class DebugRouteSpec
forAll(Gen.posNum[Int]) { height =>
(state.height _).expects().returning(height).once()
(state.accountPortfolios _).expects().returning(Map.empty).once()
Get(routePath("/info")) ~> route ~> check {
Get(routePath("/info")) ~> api_key(apiKey) ~> route ~> check {
responseAs[JsObject] should have(
"stateHeight" -> JsNumber(height),
"stateHash".ofType[JsNumber]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,36 @@ class BlockchainSettingsSpecification extends FlatSpec with Matchers {
settings.addressSchemeCharacter should be('M')
settings.functionalitySettings.numOfSlots should be (60)
settings.functionalitySettings.mintingSpeed should be (1)
settings.genesisSettings.blockTimestamp should be(1460678400000L)
settings.genesisSettings.timestamp should be(1465742577614L)
settings.genesisSettings.signature should be(ByteStr.decodeBase58("FSH8eAAzZNqnG8xgTZtz5xuLqXySsXgAjmFEC25hXMbEufiGjqWPnGCZFt6gLiVLJny16ipxRNAkkzjjhqTjBE2").toOption)
settings.genesisSettings.initialBalance should be(1000000000000000000L) //changed the total initialBalance in default setting
settings.genesisSettings.blockTimestamp should be(1537343925754686951L)
settings.genesisSettings.timestamp should be(1537343925754686951L)
settings.genesisSettings.signature should be(ByteStr.decodeBase58("2XrcU7AoEbs1qACVgo6BADf3hbjPWtSaG2L36RVJAUmFvL96dWMrm6ohGb69uFi5CiCKNPaEBc9r6UYPbk5mTGwg").toOption)
settings.genesisSettings.initialBalance should be(514285800000000000L) //changed the total initialBalance in default setting
settings.genesisSettings.transactions should be(Seq(
GenesisTransactionSettings("3PAWwWa6GbwcJaFzwqXQN5KQm7H96Y7SHTQ", 999999999500000000L, 0),
GenesisTransactionSettings("3P8JdJGYc7vaLu4UXUZc1iRLdzrkGtdCyJM", 100000000L, 1),
GenesisTransactionSettings("3PAGPDPqnGkyhcihyjMHe9v36Y4hkAh9yDy", 100000000L, 2),
GenesisTransactionSettings("3P9o3ZYwtHkaU1KxsKkFjJqJKS3dLHLC9oF", 100000000L, 3),
GenesisTransactionSettings("3PJaDyprvekvPXPuAtxrapacuDJopgJRaU3", 100000000L, 4),
GenesisTransactionSettings("3PBWXDFUc86N2EQxKJmW8eFco65xTyMZx6J", 100000000L,5)))
GenesisTransactionSettings("ARMxPV8puShq49KzPoQb5XGttxghvLdMFg1",36000006000000000L,-1),
GenesisTransactionSettings("ARFHdvqddPNfMXNt9fgH7Lw1aGRgL29wTKY",15428574000000000L,-1),
GenesisTransactionSettings("ARQSe9A3DLryBqN4Y1NV1PhERnuWaDLheza",25097147000000000L,-1),
GenesisTransactionSettings("ARHY8cocXeGnH3q4bkLpU56sCg28fF5hSWV",36000006000000000L,-1),
GenesisTransactionSettings("ARCry9n7JvHF8rooXiEMhesAHP8zv3sBLDr",36000006000000000L,-1),
GenesisTransactionSettings("AR7M83ZypZc5WRzdZHjhULnQ7xzoMM8udJt",12342859200000000L,-1),
GenesisTransactionSettings("ARPdpZ9PT5kDbi2U6ZUgxoFwJzFchz7Fcsw",36000006000000000L,-1),
GenesisTransactionSettings("ARCK84TwkqzQEksj8pQTxbsCuRY9YGsAbSU",36000006000000000L,-1),
GenesisTransactionSettings("ARKbFz4N3f8Rgonf1Afd2aix2QtkCUjnWqW",39085720800000000L,-1),
GenesisTransactionSettings("ARRo5K1rfLk9wjXhUjAqxdZjK7LTjx7Y7ki",36000006000000000L,-1),
GenesisTransactionSettings("ARBLnj5P9XNspGRGj8UjS1Fny3pkvxJUqJV",36000006000000000L,-1),
GenesisTransactionSettings("AR5c7ibqGhkyjzYu143E171TiFdmPFHofKb",36000006000000000L,-1),
GenesisTransactionSettings("ARJukkvk47P9JKpdpjbvPQFr8Lv4D8Qsqnn",36000006000000000L,-1),
GenesisTransactionSettings("ARBD7fqPGPq5stYKyk3EbZe1w1FDYhh2KnZ",36000006000000000L,-1),
GenesisTransactionSettings("ARH6GEvr8FV12HN4rZ969K885sukp5qdNJY",36000006000000000L,-1),
GenesisTransactionSettings("AR2pa1RW5jvKV4b7PNnZG7Az6emz5WtiE4r",26331433000000000L,-1),
GenesisTransactionSettings("ARKMDAveps99s5k9ESiXjcXM9Ddp8p3GGAm",0,0),
GenesisTransactionSettings("ARKM1PkMevWdBjyEeMPAb7vrWWsJptDj891",0,4),
GenesisTransactionSettings("ARCmPJxYBkYAtxnu8qpoLA2iQbf7aJFRX2c",0,12),
GenesisTransactionSettings("ARNP2wJbehKh5Ck4Z2iR4pmnWiwgdsYh6Fw",0,16),
GenesisTransactionSettings("ARQiW9ckRc1GbbuEN3h4s18H8YH8mke15qB",0,24),
GenesisTransactionSettings("ARMfFAXxGZoFpQ7BwSKqjz9u2nxAtBRYXQ5",0,28),
GenesisTransactionSettings("ARM1o54Hdo3hHy83NE4BcmJHEdVUdeULZyZ",0,36),
GenesisTransactionSettings("ARDVLTDWf9Hwe3PBk16SNW7HCZXJPjJ43qE",0,40),
GenesisTransactionSettings("ARNNKhgFhW8ctmQYvckgf81PyHjsxDEzySd",0,48),
GenesisTransactionSettings("AR87ef8yc2Ldt1FGrJi85HW479TVeBCgS5V",0,52)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class VeeSettingsSpecification extends FlatSpec with Matchers {
val config = ConfigFactory.load()
val settings = VeeSettings.fromConfig(config)

settings.directory should be(home + "/vee")
settings.directory should be(home + "/.vee")
settings.loggingLevel should be(LogLevel.INFO)
settings.networkSettings should not be null
settings.walletSettings should not be null
Expand Down
112 changes: 112 additions & 0 deletions src/test/scala/tools/MainnetGenesisBlockGenerator.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package tools

import vee.settings.{GenesisSettings, GenesisTransactionSettings}
import com.wavesplatform.state2.ByteStr
import scorex.account.{Address, AddressScheme, PrivateKeyAccount}
import scorex.block.Block
import vee.consensus.spos.SposConsensusBlockData
import scorex.transaction.{GenesisTransaction, Transaction}
import vee.transaction.{TransactionStatus, ProcessedTransaction}
import scorex.transaction.TransactionParser.SignatureLength
import com.wavesplatform.settings.Constants._

import scala.concurrent.duration._

object MainnetGenesisBlockGenerator extends App {

val genesisSigner = PrivateKeyAccount(Array.empty)
val reference = ByteStr(Array.fill(SignatureLength)(-1: Byte))
val balanceDistributions = Seq(360000060L * UnitsInVee,
154285740L * UnitsInVee,
250971470L * UnitsInVee,
360000060L * UnitsInVee,
360000060L * UnitsInVee,
123428592L * UnitsInVee,
360000060L * UnitsInVee,
360000060L * UnitsInVee,
390857208L * UnitsInVee,
360000060L * UnitsInVee,
360000060L * UnitsInVee,
360000060L * UnitsInVee,
360000060L * UnitsInVee,
360000060L * UnitsInVee,
360000060L * UnitsInVee,
263314330L * UnitsInVee,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
)

// add wallet address
val wallet_addresses = Array (
"ARMxPV8puShq49KzPoQb5XGttxghvLdMFg1",
"ARFHdvqddPNfMXNt9fgH7Lw1aGRgL29wTKY",
"ARQSe9A3DLryBqN4Y1NV1PhERnuWaDLheza",
"ARHY8cocXeGnH3q4bkLpU56sCg28fF5hSWV",
"ARCry9n7JvHF8rooXiEMhesAHP8zv3sBLDr",
"AR7M83ZypZc5WRzdZHjhULnQ7xzoMM8udJt",
"ARPdpZ9PT5kDbi2U6ZUgxoFwJzFchz7Fcsw",
"ARCK84TwkqzQEksj8pQTxbsCuRY9YGsAbSU",
"ARKbFz4N3f8Rgonf1Afd2aix2QtkCUjnWqW",
"ARRo5K1rfLk9wjXhUjAqxdZjK7LTjx7Y7ki",
"ARBLnj5P9XNspGRGj8UjS1Fny3pkvxJUqJV",
"AR5c7ibqGhkyjzYu143E171TiFdmPFHofKb",
"ARJukkvk47P9JKpdpjbvPQFr8Lv4D8Qsqnn",
"ARBD7fqPGPq5stYKyk3EbZe1w1FDYhh2KnZ",
"ARH6GEvr8FV12HN4rZ969K885sukp5qdNJY",
"AR2pa1RW5jvKV4b7PNnZG7Az6emz5WtiE4r", // with non-zero balance
"ARKMDAveps99s5k9ESiXjcXM9Ddp8p3GGAm",
"ARKM1PkMevWdBjyEeMPAb7vrWWsJptDj891",
"ARCmPJxYBkYAtxnu8qpoLA2iQbf7aJFRX2c",
"ARNP2wJbehKh5Ck4Z2iR4pmnWiwgdsYh6Fw",
"ARQiW9ckRc1GbbuEN3h4s18H8YH8mke15qB",
"ARMfFAXxGZoFpQ7BwSKqjz9u2nxAtBRYXQ5",
"ARM1o54Hdo3hHy83NE4BcmJHEdVUdeULZyZ",
"ARDVLTDWf9Hwe3PBk16SNW7HCZXJPjJ43qE",
"ARNNKhgFhW8ctmQYvckgf81PyHjsxDEzySd",
"AR87ef8yc2Ldt1FGrJi85HW479TVeBCgS5V" //minters
)

val genesis_slots = Array (
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 4, 12, 16, 24, 28, 36, 40, 48, 52
)

def generate(networkByte: Char, averageBlockDelay: FiniteDuration) :(IndexedSeq[(Int, Address)], GenesisSettings) = {
scorex.account.AddressScheme.current = new AddressScheme {
override val chainId: Byte = networkByte.toByte
}

val timestamp = System.currentTimeMillis() * 1000000L + System.nanoTime() % 1000000L
val initialBalance = balanceDistributions.reduceLeft(_ + _)

val mt = timestamp/ 4L * 4L / 1000000000L * 1000000000L

val accounts = wallet_addresses.indices.map(n => n -> Address.fromString(wallet_addresses(n)).right.get)
val genesisTxs = accounts.map { case (n, address) => GenesisTransaction(address, balanceDistributions(n), genesis_slots(n), timestamp, ByteStr.empty) }

// set the genesisblock's minting Balance to 0
val genesisBlock = Block.buildAndSign(1, timestamp, reference, SposConsensusBlockData(mt, 0L),
genesisTxs.map{tx: Transaction => ProcessedTransaction(TransactionStatus.Success, tx.transactionFee, tx)}, genesisSigner)
val signature = genesisBlock.signerData.signature

(accounts, GenesisSettings(timestamp, timestamp, initialBalance, Some(signature),
genesisTxs.map(tx => GenesisTransactionSettings(tx.recipient.stringRepr, tx.amount, tx.slotId)), mt, averageBlockDelay))

}

def print(accs: Seq[(Int, Address)], settings: GenesisSettings): Unit = {
println(
s"""GenesisSettings:
| timestamp: ${settings.timestamp}
| blockTimestamp: ${settings.blockTimestamp}
| averageBlockDelay: ${settings.averageBlockDelay}
| initialBalance: ${settings.initialBalance}
| initialMintTime: ${settings.initialMintTime}
| signature: ${settings.signature}
| transactions: ${settings.transactions.mkString("\n ", "\n ", "")}
""".stripMargin)
}

val (a, s) = generate('M', 60.seconds)
print(a, s)

}
Loading

0 comments on commit 3c24f23

Please sign in to comment.