Skip to content

Commit

Permalink
Merge branch 'master' into EvalOpts
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrmkd committed May 25, 2018
2 parents 39e9290 + e200499 commit 2b3e871
Show file tree
Hide file tree
Showing 115 changed files with 4,134 additions and 1,747 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ sudo: false
jdk:
- oraclejdk8
scala:
- 2.12.4
- 2.12.6
env:
global:
- secure: NYdeuFBQVVjN5gon2KQEDfNfyp9Bk6AZJ7V1tfLJW54y5Dd/4PHdWGWeOyhCMIqwX3UaUmWExY1KcKXpbDMLwTmahNLjiDc3e3rCqxghL5cDgqs6OHcwNGw+CwNiw3tufo5PZ9mhK/ZJh0qgOHWyETs/ifq4VyacvgYH9IZzK4YdKYdwf+T9c3Q7VO3KmzOXiHkvPvLfkc8I8cSZlT1kJFCGawRdE/0nygPd8HYfCxiEFuXOKpRz0hlm8njjZdlZpMcou8TLeH5fFSvHtELIHFvSTEj/QilSTmCXgFRVUd8sd53n3uTouwtVbdCHsXNm4Nphf0lUJnN7fTzbD2xpOZN9zS+SO/YTkIxZpSgQLwsJsWzIHI+6IOlcjeNwZHbYBfsAdv1c4GMkgFfxsWWtb4r7+ooXDTbyy1qeZgVU4caGBMwoNE+l0Y60JdGYT4hrTfJ5c+GpcPzIV3CYVOUkHmoCYXRCtxnfDFXCR0mDVfYAA14osLi3v+EKdTxHDfqP6fICIW9y7oZd//38iEQrDy+k9iCyNmvOsqvDxXZithmSP0WzeGCXQDI+s3FxB5ywt8yDvzFbF5JYY74o1tnNFG7TlSF5v8EHSHxzXBeBtnE9V1g2wxYnvW2HYk5kW6WZJgYE9LCc6ubpQ2W387PRfCJjoLNjHqNlNGkEYlkPuaw=
- secure: rvBDWIiECsp1rI5wUjtw0098Gb2qE4r1uj33w+OtEnszftoZ+XgvvyyyfeykkcAAWob56pOFLox6CO1t/t3YyIyi8sXCPrf1eLBaFt4p6K5czNkWyWY6rlgd/cEXrJeE63UZhx9trN+jiZVjZ7oPpVNSNVAqXhf7dCHWOsKKu7i2gclzGYG1JeBL4eES/WJNVlgcsOdXbWG/udz9A/3+26afgN8Y5N/UMc0PJEmWUKcX7xWfLIcg4UIIvyPp5P55CT698N1jz57GHESDyYrMxMpZOO+0Q26Rjm+7A0U2+mm9XFE7cXT1JNFrJbUs/mvOpjTe0pScT34hRpH1pJcU3vppG/ffJ3IXB9/L2UfWcSemx4pNpdHuvt8Q2otdIlHxZrZpvHAOi6m/HkNBQlNYdRu9hjMVEmJUxiPtLl7npeMfbranEZ+gUtZoFV64aNBV6SUAmsi2supmj9xKmt3R0XOoMCR5zRglm/2EQY2fGhhp+OPrIWgSbGSTXXcUc5hEVM7sdTHo3taIbZsWya6NfjVJ/cxpBjc9hGpuSITU+r0WfSgTLqvEI3cgXQki/ggqVnDM80ft32KIUKIUaoaZSI7r5REps4A1F7HAP9+6VEJRk1p70Ls2IonzDifLij2LQDds1q8LbA9qOQtdj9beAGPvgKPJnBbH4rjNG5k+Iyw=
script:
- sbt -S-Xfatal-warnings ";clean;coverage;generator/compile;langJS/fastOptJS;benchmark/test:compile;lang/test;test;coverageReport"
after_success:
- "[[ $TRAVIS_REPO_SLUG == \"wavesplatform/Scorex\" ]] && [[ $TRAVIS_BRANCH == \"master\" ]] && { sbt publish; };"
- bash <(curl -s https://codecov.io/bash)
# These directories are cached to S3 at the end of the build
cache:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ object StateSyntheticBenchmark {

val textScript = "sigVerify(tx.bodyBytes,tx.proof0,tx.senderPk)"
val untypedScript = Parser(textScript).get.value
val typedScript = CompilerV1(dummyTypeCheckerContext, untypedScript).explicitGet()
assert(untypedScript.size == 1)
val typedScript = CompilerV1(dummyTypeCheckerContext, untypedScript.head).explicitGet()

val setScriptBlock = nextBlock(
Seq(
Expand Down
6 changes: 4 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ val versionSource = Def.task {
// Please, update the fallback version every major and minor releases.
// This version is used then building from sources without Git repository
// In case of not updating the version nodes build from headless sources will fail to connect to newer versions
val FallbackVersion = (0, 11, 0)
val FallbackVersion = (0, 13, 0)

val versionFile = (sourceManaged in Compile).value / "com" / "wavesplatform" / "Version.scala"
val versionExtractor = """(\d+)\.(\d+)\.(\d+).*""".r
Expand Down Expand Up @@ -43,7 +43,7 @@ logBuffered := false

inThisBuild(
Seq(
scalaVersion := "2.12.4",
scalaVersion := "2.12.6",
organization := "com.wavesplatform",
crossPaths := false,
scalacOptions ++= Seq("-feature", "-deprecation", "-language:higherKinds", "-language:implicitConversions", "-Ywarn-unused:-implicits", "-Xlint")
Expand Down Expand Up @@ -180,6 +180,8 @@ lazy val lang =
.withoutSuffixFor(JVMPlatform)
.settings(
version := "0.0.1",
// the following line forces scala version across all dependencies
scalaModuleInfo ~= (_.map(_.withOverrideScalaVersion(true))),
test in assembly := {},
addCompilerPlugin(Dependencies.kindProjector),
libraryDependencies ++=
Expand Down
23 changes: 12 additions & 11 deletions it/src/main/scala/com/wavesplatform/it/BaseTargetChecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,44 @@ package com.wavesplatform.it
import java.time.Instant

import com.typesafe.config.ConfigFactory.{defaultApplication, defaultReference}
import com.wavesplatform.consensus.PoSSelector
import com.wavesplatform.db.openDB
import com.wavesplatform.history.StorageFactory
import com.wavesplatform.settings._
import com.wavesplatform.state.{ByteStr, EitherExt2}
import net.ceedubs.ficus.Ficus._
import scorex.account.PublicKeyAccount
import scorex.block.Block
import scorex.transaction.PoSCalc
import scorex.utils.NTP

object BaseTargetChecker {
def main(args: Array[String]): Unit = {
val startTs = System.currentTimeMillis()
val docker = Docker(getClass)
val docker = Docker(getClass)
val sharedConfig = docker.genesisOverride
.withFallback(docker.configTemplate)
.withFallback(defaultApplication())
.withFallback(defaultReference())
.resolve()
val settings = WavesSettings.fromConfig(sharedConfig)
val fs = settings.blockchainSettings.functionalitySettings
val genesisBlock = Block.genesis(settings.blockchainSettings.genesisSettings).explicitGet()
val db = openDB("/tmp/tmp-db", 1024)
val bu = StorageFactory(settings, db, NTP)
val pos = new PoSSelector(bu, settings.blockchainSettings)
bu.processBlock(genesisBlock)

println(s"Genesis TS = ${Instant.ofEpochMilli(genesisBlock.timestamp)}")

val m = NodeConfigs.Default.map(_.withFallback(sharedConfig)).collect {
case cfg if cfg.as[Boolean]("waves.miner.enable") =>
val publicKey = PublicKeyAccount(cfg.as[ByteStr]("public-key").arr)
val address = publicKey.toAddress
PoSCalc.nextBlockGenerationTime(1, bu, fs, genesisBlock, publicKey) match {
case Right((_, ts)) => f"$address: ${(ts - startTs) * 1e-3}%10.3f s"
case _ => s"$address: n/a"
}

val account = PublicKeyAccount(cfg.as[ByteStr]("public-key").arr)
val address = account.toAddress
val balance = bu.balance(address, None)
val consensus = genesisBlock.consensusData
val timeDelay = pos
.getValidBlockDelay(bu.height, account.publicKey, consensus.baseTarget, balance)
.explicitGet()

f"$address: ${timeDelay * 1e-3}%10.3f s"
}

docker.close()
Expand Down
4 changes: 3 additions & 1 deletion it/src/main/scala/com/wavesplatform/it/NodeConfigs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ object NodeConfigs {
private val NonConflictingNodes = Set(1, 4, 6, 7)

val Default: Seq[Config] = ConfigFactory.parseResources("nodes.conf").getConfigList("nodes").asScala
val NotMiner = Default.last
val Miners: Seq[Config] = Default.init
val NotMiner: Config = Default.last
def randomMiner: Config = Random.shuffle(Miners).head

def newBuilder: Builder = Builder(Default, Default.size, Seq.empty)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ object AsyncHttpApi extends Assertions {
100.millis
)

def waitForHeight(expectedHeight: Int): Future[Int] = waitFor[Int](s"height >= $expectedHeight")(_.height, h => h >= expectedHeight, 1.second)
def waitForHeight(expectedHeight: Int): Future[Int] = waitFor[Int](s"height >= $expectedHeight")(_.height, h => h >= expectedHeight, 5.seconds)

def transactionInfo(txId: String): Future[TransactionInfo] = get(s"/transactions/info/$txId").as[TransactionInfo]

Expand Down
7 changes: 6 additions & 1 deletion it/src/main/scala/com/wavesplatform/it/api/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ object CompiledScript {
implicit val compiledScriptFormat: Format[CompiledScript] = Json.format
}

case class FullAssetInfo(assetId: String, balance: Long, reissuable: Boolean, quantity: Long)
case class FullAssetInfo(assetId: String,
balance: Long,
reissuable: Boolean,
minSponsoredAssetFee: Option[Long],
sponsorBalance: Option[Long],
quantity: Long)
object FullAssetInfo {
implicit val fullAssetInfoFormat: Format[FullAssetInfo] = Json.format
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.wavesplatform.it.async

import com.typesafe.config.Config
import com.typesafe.config.{Config, ConfigFactory}
import com.wavesplatform.it.api.AsyncHttpApi._
import com.wavesplatform.it.transactions.NodesFromDocker
import com.wavesplatform.it.{NodeConfigs, TransferSending}
Expand All @@ -11,52 +11,13 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._

class BlockSizeConstraintsSuite extends FreeSpec with Matchers with TransferSending with NodesFromDocker {
import BlockSizeConstraintsSuite._

private val maxTxs = 5000 // More, than 1mb of block
private val txsInMicroBlock = 500

override protected val nodeConfigs: Seq[Config] = NodeConfigs.newBuilder
.overrideBase(
_.raw(
s"""akka.http.server {
| parsing.max-content-length = 3737439
| request-timeout = 60s
|}
|
|waves {
| network.enable-peers-exchange = no
|
| miner {
| quorum = 0
| minimal-block-generation-offset = 60000ms
| micro-block-interval = 3s
| max-transactions-in-key-block = 0
| max-transactions-in-micro-block = $txsInMicroBlock
| }
|
| blockchain.custom {
| functionality {
| feature-check-blocks-period = 1
| blocks-for-feature-activation = 1
|
| pre-activated-features {
| 2: 0
| 3: 2
| }
| }
|
| store-transactions-in-state = false
| }
|
| features.supported = [2, 3]
|}""".stripMargin
))
.withDefault(1)
.build()
override protected val nodeConfigs: Seq[Config] =
Seq(ConfigOverrides.withFallback(NodeConfigs.randomMiner))

private val nodeAddresses = nodeConfigs.map(_.getString("address")).toSet

private def miner = nodes.head
private val miner = nodes.head

s"Block is limited by size after activation" in result(
for {
Expand All @@ -77,3 +38,41 @@ class BlockSizeConstraintsSuite extends FreeSpec with Matchers with TransferSend
)

}

object BlockSizeConstraintsSuite {
private val maxTxs = 5000 // More, than 1mb of block
private val txsInMicroBlock = 500
private val ConfigOverrides = ConfigFactory.parseString(s"""akka.http.server {
| parsing.max-content-length = 3737439
| request-timeout = 60s
|}
|
|waves {
| network.enable-peers-exchange = no
|
| miner {
| quorum = 0
| minimal-block-generation-offset = 60000ms
| micro-block-interval = 3s
| max-transactions-in-key-block = 0
| max-transactions-in-micro-block = $txsInMicroBlock
| }
|
| blockchain.custom {
| functionality {
| feature-check-blocks-period = 1
| blocks-for-feature-activation = 1
|
| pre-activated-features {
| 2: 0
| 3: 2
| }
| }
|
| store-transactions-in-state = false
| }
|
| features.supported = [2, 3]
|}""".stripMargin)

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.wavesplatform.it.async

import com.typesafe.config.Config
import com.typesafe.config.{Config, ConfigFactory}
import com.wavesplatform.it.api.AsyncHttpApi._
import com.wavesplatform.it.transactions.NodesFromDocker
import com.wavesplatform.it.{NodeConfigs, TransferSending}
Expand All @@ -11,30 +11,10 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._

class MicroblocksGenerationSuite extends FreeSpec with Matchers with TransferSending with NodesFromDocker {
import MicroblocksGenerationSuite._

private val txsInMicroBlock = 200
private val maxTxs = 2000

override protected val nodeConfigs: Seq[Config] = NodeConfigs.newBuilder
.overrideBase(
_.raw(
s"""waves {
| network.enable-peers-exchange = no
|
| miner {
| quorum = 0
| minimal-block-generation-offset = 1m
| micro-block-interval = 3s
| max-transactions-in-key-block = 0
| max-transactions-in-micro-block = $txsInMicroBlock
| }
|
| blockchain.custom.functionality.pre-activated-features.2 = 0
| features.supported = [2]
|}""".stripMargin
))
.withDefault(1)
.build()
override protected val nodeConfigs: Seq[Config] =
Seq(ConfigOverrides.withFallback(NodeConfigs.randomMiner))

private val nodeAddresses = nodeConfigs.map(_.getString("address")).toSet

Expand All @@ -56,3 +36,20 @@ class MicroblocksGenerationSuite extends FreeSpec with Matchers with TransferSen
)

}

object MicroblocksGenerationSuite {
private val txsInMicroBlock = 200
private val maxTxs = 2000
private val ConfigOverrides = ConfigFactory.parseString(s"""waves {
| miner {
| quorum = 0
| minimal-block-generation-offset = 1m
| micro-block-interval = 3s
| max-transactions-in-key-block = 0
| max-transactions-in-micro-block = $txsInMicroBlock
| }
|
| blockchain.custom.functionality.pre-activated-features.2 = 0
| features.supported = [2]
|}""".stripMargin)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future.traverse
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
import scala.util.Random

class RollbackSpecSuite
extends FreeSpec
Expand All @@ -25,10 +24,7 @@ class RollbackSpecSuite
with WaitForHeight2
with NodesFromDocker {

override protected val nodeConfigs: Seq[Config] = Seq(
Random.shuffle(NodeConfigs.Default.init).head,
NodeConfigs.NotMiner
)
override protected val nodeConfigs: Seq[Config] = Seq(NodeConfigs.randomMiner, NodeConfigs.NotMiner)

private val nodeAddresses = nodeConfigs.map(_.getString("address")).toSet
private val transactionsCount = 190
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class SmartTransactionsConstraintsSuite extends FreeSpec with Matchers with Tran
private def toRequest(tx: SetScriptTransaction): SignedSetScriptRequest = SignedSetScriptRequest(
version = tx.version,
senderPublicKey = Base58.encode(tx.sender.publicKey),
script = tx.script.map(_.bytes().base58),
script = tx.script.map(_.bytes().base64),
fee = tx.fee,
timestamp = tx.timestamp,
proofs = tx.proofs.proofs.map(_.base58)(collection.breakOut)
Expand Down
Loading

0 comments on commit 2b3e871

Please sign in to comment.