Skip to content

Commit f7df0da

Browse files
committed
Merge phase 4
2 parents 6e2a14e + 7de0602 commit f7df0da

File tree

186 files changed

+13084
-2521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+13084
-2521
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ The scala build tool [sbt](http://www.scala-sbt.org/) must be installed.
1414

1515
A recent [java sdk](http://www.oracle.com/technetwork/java/javase/downloads/index.html#close) must be installed.
1616

17-
### Milestone 3 - transaction execution
1817

19-
**This version of the code supports downloading the blockchain from remote peers and executing the transactions in the blocks. When all transactions up to and including the latest have been executed the client will continue to stay synchronized.**
18+
### Milestone 3 & 4 - JSON RPC and Miner Integration
19+
20+
**This version of the code supports almost all the functionality for a first release.**
21+
2022

2123
For the curious ...
2224

@@ -42,11 +44,13 @@ The client attempts to contact the remote peers configured in the configuration
4244
`fast-sync` download. The [configuration file](https://github.com/input-output-hk/etc-client/blob/master/src/main/resources/application.conf)
4345
settings can all be overriden in
4446

45-
`./config/application.conf`
47+
`./config/production.conf`
4648

47-
The client has not been run on Windows.
49+
The client has been run on Windows 8 and seems to work however it has not been extensively tested.
4850

49-
The next milestone involves integrating our client with Mist browser!
51+
52+
The next milestone is our early Beta release!!
53+
5054

5155

5256

build.sbt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ val commonSettings = Seq(
88

99
val dep = {
1010
val akkaVersion = "2.4.17"
11-
val akkaHttpVersion = "10.0.3"
11+
val akkaHttpVersion = "10.0.6"
1212
val circeVersion = "0.7.0"
1313

1414
Seq(
@@ -17,15 +17,18 @@ val dep = {
1717
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion,
1818
"com.typesafe.akka" %% "akka-testkit" % akkaVersion,
1919
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
20-
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
20+
"ch.megard" %% "akka-http-cors" % "0.2.1",
21+
"org.json4s" %% "json4s-native" % "3.5.1",
22+
"de.heikoseeberger" %% "akka-http-json4s" % "1.11.0",
2123
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % "it,test",
2224
"io.suzaku" %% "boopickle" % "1.2.6",
2325
"org.consensusresearch" %% "scrypto" % "1.2.0-RC3",
24-
"com.madgag.spongycastle" % "core" % "1.54.0.0",
26+
"com.madgag.spongycastle" % "core" % "1.56.0.0",
2527
"org.iq80.leveldb" % "leveldb" % "0.9",
2628
"org.scorexfoundation" %% "iodb" % "0.3.0",
2729
"ch.qos.logback" % "logback-classic" % "1.1.9",
2830
"org.scalatest" %% "scalatest" % "3.0.1" % "it,test",
31+
"org.scalamock" %% "scalamock-scalatest-support" % "3.5.0" % "test",
2932
"org.scalacheck" %% "scalacheck" % "1.13.4" % "it,test",
3033
"org.scalacheck" %% "scalacheck" % "1.13.4" % "it,test",
3134
"ch.qos.logback" % "logback-classic" % "1.1.9",
@@ -35,7 +38,8 @@ val dep = {
3538
"io.circe" %% "circe-generic" % circeVersion,
3639
"io.circe" %% "circe-parser" % circeVersion,
3740
"io.circe" %% "circe-generic-extras" % circeVersion,
38-
"com.miguno.akka" %% "akka-mock-scheduler" % "0.5.1" % "it,test"
41+
"com.miguno.akka" %% "akka-mock-scheduler" % "0.5.1" % "it,test",
42+
"commons-io" % "commons-io" % "2.5"
3943
)
4044
}
4145

@@ -58,6 +62,8 @@ scalacOptions := Seq(
5862
"-Xfatal-warnings"
5963
)
6064

65+
parallelExecution in Test := false
66+
6167
testOptions in Test += Tests.Argument("-oD")
6268

6369
(test in Evm) := (test in Evm).dependsOn(solidityCompile).value
@@ -67,5 +73,3 @@ testOptions in Test += Tests.Argument("-oD")
6773
scalastyleSources in Test ++= {(unmanagedSourceDirectories in Integration).value}
6874

6975
mainClass in Compile := Some("io.iohk.ethereum.App")
70-
71-
coverageExcludedPackages := "io.iohk.ethereum.vmrunner.*"

circle.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
dependencies:
22
pre:
33
- sudo add-apt-repository -y ppa:ethereum/ethereum; sudo apt-get update; sudo apt-get install -y solc
4+
5+
# We want override the dependency steps inferred by CircleCI, which happens to be `sbt test:compile`. This is redundant
6+
# because tests need to be recompiled anyway, with coverage. Note that an empty list doesn't work here.
7+
override:
8+
- echo "OK, let's go!"
9+
10+
test:
11+
override:
12+
- sbt scalastyle
13+
- sbt test:scalastyle
14+
- sbt coverage test
15+
- sbt coverage evm:test
16+
- sbt coverageOff it:test
17+
- sbt coverageReport coverageAggregate coveralls
18+
- sbt dist
19+
post:
20+
- mkdir -p $CIRCLE_ARTIFACTS/scala-2.12
21+
- mv target/scala-2.12/coverage-report $CIRCLE_ARTIFACTS/scala-2.12/coverage-report
22+
- mv target/scala-2.12/scoverage-report $CIRCLE_ARTIFACTS/scala-2.12/scoverage-report

src/evmTest/scala/io/iohk/ethereum/vm/PrecompiledContractsSpecEvm.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import akka.util.ByteString
44
import io.iohk.ethereum.crypto
55
import io.iohk.ethereum.crypto._
66
import io.iohk.ethereum.domain.SignedTransaction.{FirstByteOfAddress, LastByteOfAddress}
7+
import io.iohk.ethereum.nodebuilder.SecureRandomBuilder
78
import io.iohk.ethereum.vm.utils.EvmTestEnv
89
import org.scalatest.{FunSuite, Matchers}
910
import org.spongycastle.crypto.params.ECPublicKeyParameters
1011

11-
class PrecompiledContractsSpecEvm extends FunSuite with Matchers {
12+
class PrecompiledContractsSpecEvm extends FunSuite with Matchers with SecureRandomBuilder {
1213

1314
test("Precompiled Contracts") {
14-
val keyPair = generateKeyPair()
15+
val keyPair = generateKeyPair(secureRandom)
1516
val bytes: Array[Byte] = ByteString("aabbccdd").toArray[Byte]
1617
val signature = ECDSASignature.sign(bytes, keyPair)
1718
val pubKey = keyPair.getPublic.asInstanceOf[ECPublicKeyParameters].getQ.getEncoded(false)

src/it/scala/io/iohk/ethereum/rlp/RLPSpeedSuite.scala

Lines changed: 24 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ package io.iohk.ethereum.rlp
22

33
import akka.util.ByteString
44
import io.iohk.ethereum.ObjectGenerators
5-
import io.iohk.ethereum.domain.{Address, BlockHeader, SignedTransaction, Transaction}
6-
import io.iohk.ethereum.network.p2p.messages.CommonMessages.SignedTransactions
7-
import io.iohk.ethereum.network.p2p.messages.PV62.BlockHeaderImplicits._
8-
import io.iohk.ethereum.rlp
5+
import io.iohk.ethereum.domain.Block._
6+
import io.iohk.ethereum.domain._
7+
import io.iohk.ethereum.network.p2p.messages.CommonMessages.SignedTransactions._
8+
import io.iohk.ethereum.network.p2p.messages.PV62.BlockBody
99
import io.iohk.ethereum.utils.Logger
1010
import org.scalacheck.Gen
1111
import org.scalatest.FunSuite
1212
import org.scalatest.prop.{GeneratorDrivenPropertyChecks, PropertyChecks}
1313
import org.spongycastle.util.encoders.Hex
1414

1515
/**
16-
* Tests based on
17-
* - https://github.com/cryptape/ruby-rlp/blob/master/test/speed.rb
18-
* - https://github.com/ethereum/pyrlp/blob/develop/tests/speed.py
19-
*/
16+
* Tests based on
17+
* - https://github.com/cryptape/ruby-rlp/blob/master/test/speed.rb
18+
* - https://github.com/ethereum/pyrlp/blob/develop/tests/speed.py
19+
*/
2020
class RLPSpeedSuite extends FunSuite
2121
with PropertyChecks
2222
with GeneratorDrivenPropertyChecks
@@ -28,23 +28,23 @@ class RLPSpeedSuite extends FunSuite
2828
test("Main") {
2929
val startBlockSerialization: Long = System.currentTimeMillis
3030
val block = blockGen.sample.get
31-
val serializedBlock = doTestSerialize[TestBlock](block, rounds)(TestBlock.encDec)
31+
val serializedBlock = doTestSerialize[Block](block, (b: Block) => b.toBytes, rounds)
3232
val elapsedBlockSerialization = (System.currentTimeMillis() - startBlockSerialization) / 1000f
3333
log.info(s"Block serializations / sec: (${rounds.toFloat / elapsedBlockSerialization})")
3434

3535
val blockDeserializationStart: Long = System.currentTimeMillis
36-
val deserializedBlock: TestBlock = doTestDeserialize(serializedBlock, rounds)(TestBlock.encDec)
36+
val deserializedBlock: Block = doTestDeserialize(serializedBlock, (b: Array[Byte]) => b.toBlock, rounds)
3737
val elapsedBlockDeserialization = (System.currentTimeMillis() - blockDeserializationStart) / 1000f
3838
log.info(s"Block deserializations / sec: (${rounds.toFloat / elapsedBlockDeserialization})")
3939

4040
val serializationTxStart: Long = System.currentTimeMillis
4141
val tx = validTransaction
42-
val serializedTx = doTestSerialize(tx, rounds)(SignedTransactions.txRlpEncDec)
42+
val serializedTx = doTestSerialize(tx, (stx: SignedTransaction) => stx.toBytes, rounds)
4343
val elapsedTxSerialization = (System.currentTimeMillis() - serializationTxStart) / 1000f
4444
log.info(s"TX serializations / sec: (${rounds.toFloat / elapsedTxSerialization})")
4545

4646
val txDeserializationStart: Long = System.currentTimeMillis
47-
val deserializedTx: SignedTransaction = doTestDeserialize(serializedTx, rounds)(SignedTransactions.txRlpEncDec)
47+
val deserializedTx: SignedTransaction = doTestDeserialize(serializedTx, (b: Array[Byte]) => b.toSignedTransaction, rounds)
4848
val elapsedTxDeserialization = (System.currentTimeMillis() - txDeserializationStart) / 1000f
4949
log.info(s"TX deserializations / sec: (${rounds.toFloat / elapsedTxDeserialization})")
5050
}
@@ -60,14 +60,18 @@ class RLPSpeedSuite extends FunSuite
6060
log.info("Result decode()\t: " + (end1 - start1) + "ms")
6161
}
6262

63-
def doTestSerialize[T](toSerialize: T, rounds: Int)(implicit enc: RLPEncoder[T]): Array[Byte] = {
64-
(1 until rounds).foreach(_ => { encode[T](toSerialize) })
65-
encode[T](toSerialize)
63+
def doTestSerialize[T](toSerialize: T, encode: T => Array[Byte], rounds: Int): Array[Byte] = {
64+
(1 until rounds).foreach(_ => {
65+
encode(toSerialize)
66+
})
67+
encode(toSerialize)
6668
}
6769

68-
def doTestDeserialize[T](serialized: Array[Byte], rounds: Int)(implicit dec: RLPDecoder[T]): T = {
69-
(1 until rounds).foreach(_ => { decode[T](serialized) })
70-
decode[T](serialized)
70+
def doTestDeserialize[T](serialized: Array[Byte], decode: Array[Byte] => T, rounds: Int): T = {
71+
(1 until rounds).foreach(_ => {
72+
decode(serialized)
73+
})
74+
decode(serialized)
7175
}
7276

7377
val validTransaction = SignedTransaction(
@@ -84,34 +88,8 @@ class RLPSpeedSuite extends FunSuite
8488
chainId = 0x3d.toByte
8589
).get
8690

87-
lazy val blockGen: Gen[TestBlock] = for {
91+
lazy val blockGen: Gen[Block] = for {
8892
header <- blockHeaderGen
8993
uncles <- blockHeaderGen
90-
} yield TestBlock(header = header, transactions = List.fill(10)(validTransaction), uncles = Seq(uncles))
91-
}
92-
93-
// FIXME Replace with our entity once implemented in our codebase
94-
case class TestBlock(header: BlockHeader, transactions: Seq[SignedTransaction], uncles: Seq[BlockHeader])
95-
96-
object TestBlock {
97-
98-
implicit val encDec = new RLPEncoder[TestBlock] with RLPDecoder[TestBlock] {
99-
100-
override def encode(obj: TestBlock): RLPEncodeable = {
101-
val rplEncodeables: Seq[RLPEncodeable] =
102-
obj.transactions.map(SignedTransactions.txRlpEncDec.encode)
103-
RLPList(headerRlpEncDec.encode(obj.header),
104-
RLPList(rplEncodeables: _*),
105-
RLPList(obj.uncles.map(headerRlpEncDec.encode(_)): _*))
106-
}
107-
108-
override def decode(rlp: RLPEncodeable): TestBlock = rlp match {
109-
case RLPList(header, txs: RLPList, uncles: RLPList) =>
110-
TestBlock(headerRlpEncDec.decode(header),
111-
txs.items.map(SignedTransactions.txRlpEncDec.decode),
112-
uncles.items.map(headerRlpEncDec.decode))
113-
case _ => throw new RuntimeException("Invalid Block encodeable")
114-
}
115-
116-
}
94+
} yield Block(header = header, BlockBody(transactionList = List.fill(10)(validTransaction), uncleNodesList = Seq(uncles)))
11795
}

src/it/scala/io/iohk/ethereum/txExecTest/ContractTest.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.iohk.ethereum.txExecTest
22

3+
import io.iohk.ethereum.domain.Receipt
34
import io.iohk.ethereum.ledger.LedgerImpl
45
import io.iohk.ethereum.txExecTest.util.FixtureProvider
56
import io.iohk.ethereum.utils.{BlockchainConfig, Config}
@@ -12,7 +13,7 @@ import scala.language.postfixOps
1213
class ContractTest extends FlatSpec with Matchers {
1314
val blockchainConfig = BlockchainConfig(Config.config)
1415

15-
val noErrors: Right[Nothing, Unit] = Right(())
16+
val noErrors = a[Right[_, Seq[Receipt]]]
1617
val validators = new Validators {
1718
val blockValidator: BlockValidator = BlockValidator
1819
val blockHeaderValidator: BlockHeaderValidator = new BlockHeaderValidatorImpl(blockchainConfig)
@@ -21,7 +22,7 @@ class ContractTest extends FlatSpec with Matchers {
2122
}
2223

2324
"Ledger" should "transfer ether" in {
24-
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract/")
25+
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract")
2526

2627
val storage = FixtureProvider.prepareStorages(0, fixtures)
2728

@@ -30,7 +31,7 @@ class ContractTest extends FlatSpec with Matchers {
3031
}
3132

3233
it should "deploy contract" in {
33-
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract/")
34+
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract")
3435

3536
val storage = FixtureProvider.prepareStorages(1, fixtures)
3637

@@ -39,7 +40,7 @@ class ContractTest extends FlatSpec with Matchers {
3940
}
4041

4142
it should "execute contract call" in {
42-
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract/")
43+
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract")
4344

4445
val storage = FixtureProvider.prepareStorages(2, fixtures)
4546

@@ -48,7 +49,7 @@ class ContractTest extends FlatSpec with Matchers {
4849
}
4950

5051
it should "execute contract that pays 2 accounts" in {
51-
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract/")
52+
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract")
5253

5354
val storage = FixtureProvider.prepareStorages(2, fixtures)
5455

src/it/scala/io/iohk/ethereum/txExecTest/ForksTest.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package io.iohk.ethereum.txExecTest
22

33
import akka.util.ByteString
4+
import io.iohk.ethereum.domain.Receipt
45
import io.iohk.ethereum.ledger.LedgerImpl
56
import io.iohk.ethereum.txExecTest.util.FixtureProvider
6-
import io.iohk.ethereum.utils.BlockchainConfig
7+
import io.iohk.ethereum.utils.{BlockchainConfig, MonetaryPolicyConfig}
78
import io.iohk.ethereum.validators._
8-
import io.iohk.ethereum.vm.{VM, UInt256}
9+
import io.iohk.ethereum.vm.{UInt256, VM}
910
import org.scalatest.{FlatSpec, Matchers}
1011

1112
class ForksTest extends FlatSpec with Matchers {
@@ -17,7 +18,7 @@ class ForksTest extends FlatSpec with Matchers {
1718
override val eip160BlockNumber: BigInt = 7
1819

1920
override val chainId: Byte = 0x3d
20-
override val blockReward: UInt256 = UInt256(BigInt("4563918244F40000", 16))
21+
override val monetaryPolicyConfig: MonetaryPolicyConfig = MonetaryPolicyConfig(5000000, 0.2, 5000000000000000000L)
2122

2223
// unused
2324
override val customGenesisFileOpt: Option[String] = None
@@ -30,7 +31,7 @@ class ForksTest extends FlatSpec with Matchers {
3031

3132
val ledger = new LedgerImpl(VM, blockchainConfig)
3233

33-
val noErrors: Right[Nothing, Unit] = Right(())
34+
val noErrors = a[Right[_, Seq[Receipt]]]
3435

3536
val validators = new Validators {
3637
val blockValidator: BlockValidator = BlockValidator
@@ -40,7 +41,7 @@ class ForksTest extends FlatSpec with Matchers {
4041
}
4142

4243
"Ledger" should "execute blocks with respect to forks" in {
43-
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/forksTest/")
44+
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/forksTest")
4445

4546
val startBlock = 1
4647
val endBlock = 11

0 commit comments

Comments
 (0)