-
Notifications
You must be signed in to change notification settings - Fork 75
/
BlockGeneratorSpec.scala
526 lines (453 loc) · 22 KB
/
BlockGeneratorSpec.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
package io.iohk.ethereum.consensus
import java.time.Instant
import java.util.concurrent.Executors
import akka.util.ByteString
import io.iohk.ethereum.blockchain.data.GenesisDataLoader
import io.iohk.ethereum.blockchain.sync.EphemBlockchainTestSetup
import io.iohk.ethereum.consensus.blocks.{BlockTimestampProvider, PendingBlock}
import io.iohk.ethereum.consensus.ethash.validators.ValidatorsExecutor
import io.iohk.ethereum.consensus.validators._
import io.iohk.ethereum.crypto
import io.iohk.ethereum.crypto._
import io.iohk.ethereum.domain.SignedTransaction.FirstByteOfAddress
import io.iohk.ethereum.domain._
import io.iohk.ethereum.ledger.{BlockExecution, BlockPreparationError, BlockQueue, BlockValidation}
import io.iohk.ethereum.mpt.MerklePatriciaTrie.MPTException
import io.iohk.ethereum.utils._
import org.scalatest.{FlatSpec, Matchers}
import org.bouncycastle.crypto.AsymmetricCipherKeyPair
import org.bouncycastle.crypto.params.ECPublicKeyParameters
import org.bouncycastle.util.encoders.Hex
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, ExecutionContext}
class BlockGeneratorSpec extends FlatSpec with Matchers with ScalaCheckPropertyChecks with Logger {
implicit val testContext = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(4))
"BlockGenerator" should "generate correct block with empty transactions" in new TestSetup {
val result: Either[BlockPreparationError, PendingBlock] =
blockGenerator.generateBlock(bestBlock, Nil, Address(testAddress), blockGenerator.emptyX)
result shouldBe a[Right[_, Block]]
//mined with mantis + ethminer
val minedNonce = ByteString(Hex.decode("eb49a2da108d63de"))
val minedMixHash = ByteString(Hex.decode("a91c44e62d17005c4b22f6ed116f485ea30d8b63f2429745816093b304eb4f73"))
val miningTimestamp = 1508751768
val fullBlock: Either[BlockPreparationError, Block] = result.right
.map(pb =>
pb.block.copy(header =
pb.block.header.copy(nonce = minedNonce, mixHash = minedMixHash, unixTimestamp = miningTimestamp)
)
)
fullBlock.right.foreach(b =>
validators.blockHeaderValidator.validate(b.header, blockchain.getBlockHeaderByHash) shouldBe Right(
BlockHeaderValid
)
)
fullBlock.right.foreach(b => blockExecution.executeBlock(b) shouldBe a[Right[_, Seq[Receipt]]])
fullBlock.right.foreach(b => b.header.extraData shouldBe headerExtraData)
}
it should "generate correct block with transactions" in new TestSetup {
val result: Either[BlockPreparationError, PendingBlock] =
blockGenerator.generateBlock(bestBlock, Seq(signedTransaction.tx), Address(testAddress), blockGenerator.emptyX)
result shouldBe a[Right[_, Block]]
//mined with mantis + ethminer
val minedNonce = ByteString(Hex.decode("4139b957dae0488d"))
val minedMixHash = ByteString(Hex.decode("dc25764fb562d778e5d1320f4c3ba4b09021a2603a0816235e16071e11f342ea"))
val miningTimestamp = 1508752265
val fullBlock: Either[BlockPreparationError, Block] = result.right
.map(pb =>
pb.block.copy(header =
pb.block.header.copy(nonce = minedNonce, mixHash = minedMixHash, unixTimestamp = miningTimestamp)
)
)
fullBlock.right.foreach(b =>
validators.blockHeaderValidator.validate(b.header, blockchain.getBlockHeaderByHash) shouldBe Right(
BlockHeaderValid
)
)
fullBlock.right.foreach(b => blockExecution.executeBlock(b) shouldBe a[Right[_, Seq[Receipt]]])
fullBlock.right.foreach(b => b.header.extraData shouldBe headerExtraData)
}
it should "be possible to simulate transaction, on world returned with pending block " in new TestSetup {
val result: Either[BlockPreparationError, PendingBlock] =
blockGenerator.generateBlock(bestBlock, Seq(signedTransaction.tx), Address(testAddress), blockGenerator.emptyX)
result shouldBe a[Right[_, Block]]
//mined with mantis + ethminer
val minedNonce = ByteString(Hex.decode("4139b957dae0488d"))
val minedMixHash = ByteString(Hex.decode("dc25764fb562d778e5d1320f4c3ba4b09021a2603a0816235e16071e11f342ea"))
val miningTimestamp = 1508752265
val fullBlock: Either[BlockPreparationError, Block] = result.right
.map(pb =>
pb.block.copy(header =
pb.block.header.copy(nonce = minedNonce, mixHash = minedMixHash, unixTimestamp = miningTimestamp)
)
)
// Import Block, to create some existing state
val res = Await.result(ledger.importBlock(fullBlock.right.get), Duration.Inf)
// Create new pending block, with updated stateRootHash
val result1: Either[BlockPreparationError, PendingBlock] = blockGenerator.generateBlock(
blockchain.getBestBlock(),
Seq(signedTransaction.tx),
Address(testAddress),
blockGenerator.emptyX
)
result1 shouldBe a[Right[_, Block]]
val pendBlockAndState = blockGenerator.getPendingBlockAndState.get
// Try to simulate transaction, on world with updated stateRootHash, but not updated storages
assertThrows[MPTException] {
stxLedger.simulateTransaction(signedTransaction, pendBlockAndState.pendingBlock.block.header, None)
}
// Try to simulate transaction, on world with all changes stored in caches
val simulationResult = stxLedger.simulateTransaction(
signedTransaction,
pendBlockAndState.pendingBlock.block.header,
Some(pendBlockAndState.worldState)
)
// Check if transaction was valid
simulationResult.vmError shouldBe None
}
it should "filter out failing transactions" in new TestSetup {
val result: Either[BlockPreparationError, PendingBlock] =
blockGenerator.generateBlock(
bestBlock,
Seq(signedTransaction.tx, duplicatedSignedTransaction.tx),
Address(testAddress),
blockGenerator.emptyX
)
result shouldBe a[Right[_, Block]]
//mined with mantis + ethminer
val minedNonce = ByteString(Hex.decode("12cb47f9208d1e81"))
val minedMixHash = ByteString(Hex.decode("908471b57f2d3e70649f9ce0c9c318d61146d3ce19f70d2f94309f135b87b64a"))
val miningTimestamp = 1508752389
val fullBlock: Either[BlockPreparationError, Block] = result.right
.map(pb =>
pb.block.copy(header =
pb.block.header.copy(nonce = minedNonce, mixHash = minedMixHash, unixTimestamp = miningTimestamp)
)
)
fullBlock.right.foreach(b =>
validators.blockHeaderValidator.validate(b.header, blockchain.getBlockHeaderByHash) shouldBe Right(
BlockHeaderValid
)
)
fullBlock.right.foreach(b => blockExecution.executeBlock(b) shouldBe a[Right[_, Seq[Receipt]]])
fullBlock.right.foreach(b => b.body.transactionList shouldBe Seq(signedTransaction.tx))
fullBlock.right.foreach(b => b.header.extraData shouldBe headerExtraData)
}
it should "filter out transactions exceeding block gas limit and include correct transactions" in new TestSetup {
val txWitGasTooBigGasLimit = SignedTransaction
.sign(
transaction.copy(gasLimit = BigInt(2).pow(100000), nonce = signedTransaction.tx.tx.nonce + 1),
keyPair,
Some(0x3d.toByte)
)
.tx
val transactions = Seq(txWitGasTooBigGasLimit, signedTransaction.tx, duplicatedSignedTransaction.tx)
val result: Either[BlockPreparationError, PendingBlock] =
blockGenerator.generateBlock(bestBlock, transactions, Address(testAddress), blockGenerator.emptyX)
result shouldBe a[Right[_, Block]]
//mined with mantis + ethminer
val minedNonce = ByteString(Hex.decode("38026e10fb18b458"))
val minedMixHash = ByteString(Hex.decode("806f26f0efb12a0c0c16e587984227186c46f25fc4e76698a68996183edf2cf1"))
val miningTimestamp = 1508752492
val fullBlock: Either[BlockPreparationError, Block] = result.right
.map(pb =>
pb.block.copy(header =
pb.block.header.copy(nonce = minedNonce, mixHash = minedMixHash, unixTimestamp = miningTimestamp)
)
)
fullBlock.right.foreach(b =>
validators.blockHeaderValidator.validate(b.header, blockchain.getBlockHeaderByHash) shouldBe Right(
BlockHeaderValid
)
)
fullBlock.right.foreach(b => blockExecution.executeBlock(b) shouldBe a[Right[_, Seq[Receipt]]])
fullBlock.right.foreach(b => b.body.transactionList shouldBe Seq(signedTransaction.tx))
fullBlock.right.foreach(b => b.header.extraData shouldBe headerExtraData)
}
it should "generate block before eip155 and filter out chain specific tx" in new TestSetup {
override lazy val blockchainConfig = BlockchainConfig(
frontierBlockNumber = 0,
homesteadBlockNumber = 1150000,
difficultyBombPauseBlockNumber = 3000000,
difficultyBombContinueBlockNumber = 5000000,
difficultyBombRemovalBlockNumber = 5900000,
eip155BlockNumber = Long.MaxValue,
eip106BlockNumber = Long.MaxValue,
byzantiumBlockNumber = Long.MaxValue,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
chainId = 0x3d.toByte,
networkId = 1,
customGenesisFileOpt = Some("test-genesis.json"),
monetaryPolicyConfig =
MonetaryPolicyConfig(5000000, 0.2, 5000000000000000000L, 3000000000000000000L, 2000000000000000000L),
// unused
maxCodeSize = None,
eip160BlockNumber = Long.MaxValue,
eip150BlockNumber = Long.MaxValue,
eip161BlockNumber = Long.MaxValue,
accountStartNonce = UInt256.Zero,
daoForkConfig = None,
bootstrapNodes = Set(),
gasTieBreaker = false,
ethCompatibleStorage = true,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue
)
override lazy val blockExecution =
new BlockExecution(blockchain, blockchainConfig, consensus.blockPreparator, blockValidation)
val generalTx = SignedTransaction.sign(transaction, keyPair, None).tx
val specificTx =
SignedTransaction.sign(transaction.copy(nonce = transaction.nonce + 1), keyPair, Some(0x3d.toByte)).tx
val result: Either[BlockPreparationError, PendingBlock] =
blockGenerator.generateBlock(bestBlock, Seq(generalTx, specificTx), Address(testAddress), blockGenerator.emptyX)
result shouldBe a[Right[_, Block]]
//mined with mantis + ethminer
val minedNonce = ByteString(Hex.decode("48381cb0cd40936a"))
val minedMixHash = ByteString(Hex.decode("dacd96cf5dbc662fa113c73319fcdc7d6e7053571432345b936fd221c1e18d42"))
val miningTimestamp = 1499952002
val fullBlock: Either[BlockPreparationError, Block] = result.right
.map(pb =>
pb.block.copy(header =
pb.block.header.copy(nonce = minedNonce, mixHash = minedMixHash, unixTimestamp = miningTimestamp)
)
)
fullBlock.right.foreach(b =>
validators.blockHeaderValidator.validate(b.header, blockchain.getBlockHeaderByHash) shouldBe Right(
BlockHeaderValid
)
)
fullBlock.right.foreach(b => blockExecution.executeBlock(b) shouldBe a[Right[_, Seq[Receipt]]])
fullBlock.right.foreach(b => b.body.transactionList shouldBe Seq(generalTx))
fullBlock.right.foreach(b => b.header.extraData shouldBe headerExtraData)
}
it should "generate block after eip155 and allow both chain specific and general transactions" in new TestSetup {
val generalTx = SignedTransaction.sign(transaction.copy(nonce = transaction.nonce + 1), keyPair, None).tx
val result: Either[BlockPreparationError, PendingBlock] =
blockGenerator.generateBlock(
bestBlock,
Seq(generalTx, signedTransaction.tx),
Address(testAddress),
blockGenerator.emptyX
)
result shouldBe a[Right[_, Block]]
//mined with mantis + ethminer
val minedNonce = ByteString(Hex.decode("39bd50fcbde30b18"))
val minedMixHash = ByteString(Hex.decode("c77dae7cef6c685896ed6b8026466a2e6338b8bc5f182e2dd7a64cf7da9c7d1b"))
val miningTimestamp = 1499951223
val fullBlock: Either[BlockPreparationError, Block] = result.right
.map(pb =>
pb.block.copy(header =
pb.block.header.copy(nonce = minedNonce, mixHash = minedMixHash, unixTimestamp = miningTimestamp)
)
)
fullBlock.right.foreach(b =>
validators.blockHeaderValidator.validate(b.header, blockchain.getBlockHeaderByHash) shouldBe Right(
BlockHeaderValid
)
)
fullBlock.right.foreach(b => blockExecution.executeBlock(b) shouldBe a[Right[_, Seq[Receipt]]])
fullBlock.right.foreach(b => b.body.transactionList shouldBe Seq(signedTransaction.tx, generalTx))
fullBlock.right.foreach(b => b.header.extraData shouldBe headerExtraData)
}
it should "include consecutive transactions from single sender" in new TestSetup {
val nextTransaction =
SignedTransaction.sign(transaction.copy(nonce = signedTransaction.tx.tx.nonce + 1), keyPair, Some(0x3d.toByte)).tx
val result: Either[BlockPreparationError, PendingBlock] =
blockGenerator.generateBlock(
bestBlock,
Seq(nextTransaction, signedTransaction.tx),
Address(testAddress),
blockGenerator.emptyX
)
result shouldBe a[Right[_, Block]]
//mined with mantis + ethminer
val minedNonce = ByteString(Hex.decode("8f88ec20f1be482f"))
val minedMixHash = ByteString(Hex.decode("247a206abc088487edc1697fcaceb33ad87b55666e438129b7048bb08c8ed88f"))
val miningTimestamp = 1499721182
val fullBlock: Either[BlockPreparationError, Block] = result.right
.map(pb =>
pb.block.copy(header =
pb.block.header.copy(nonce = minedNonce, mixHash = minedMixHash, unixTimestamp = miningTimestamp)
)
)
fullBlock.right.foreach(b =>
validators.blockHeaderValidator.validate(b.header, blockchain.getBlockHeaderByHash) shouldBe Right(
BlockHeaderValid
)
)
fullBlock.right.foreach(b => blockExecution.executeBlock(b) shouldBe a[Right[_, Seq[Receipt]]])
fullBlock.right.foreach(b => b.body.transactionList shouldBe Seq(signedTransaction.tx, nextTransaction))
fullBlock.right.foreach(b => b.header.extraData shouldBe headerExtraData)
}
it should "filter out failing transaction from the middle of tx list" in new TestSetup {
val nextTransaction =
SignedTransaction.sign(transaction.copy(nonce = signedTransaction.tx.tx.nonce + 1), keyPair, Some(0x3d.toByte)).tx
val privateKeyWithNoEthere =
BigInt(1, Hex.decode("584a31be275195585603ddd05a53d16fae9deafba67213b6060cec9f16e44cae"))
val failingTransaction = Transaction(
nonce = 0,
gasPrice = 1,
gasLimit = txGasLimit,
receivingAddress = Address(testAddress),
value = txTransfer,
payload = ByteString.empty
)
val signedFailingTransaction =
SignedTransaction.sign(failingTransaction, keyPairFromPrvKey(privateKeyWithNoEthere), Some(0x3d.toByte)).tx
val result: Either[BlockPreparationError, PendingBlock] =
blockGenerator.generateBlock(
bestBlock,
Seq(nextTransaction, signedFailingTransaction, signedTransaction.tx),
Address(testAddress),
blockGenerator.emptyX
)
result shouldBe a[Right[_, Block]]
//mined with mantis + ethminer
val minedNonce = ByteString(Hex.decode("8f88ec20f1be482f"))
val minedMixHash = ByteString(Hex.decode("247a206abc088487edc1697fcaceb33ad87b55666e438129b7048bb08c8ed88f"))
val miningTimestamp = 1499721182
val fullBlock: Either[BlockPreparationError, Block] = result.right
.map(pb =>
pb.block.copy(header =
pb.block.header.copy(nonce = minedNonce, mixHash = minedMixHash, unixTimestamp = miningTimestamp)
)
)
fullBlock.right.foreach(b =>
validators.blockHeaderValidator.validate(b.header, blockchain.getBlockHeaderByHash) shouldBe Right(
BlockHeaderValid
)
)
fullBlock.right.foreach(b => blockExecution.executeBlock(b) shouldBe a[Right[_, Seq[Receipt]]])
fullBlock.right.foreach(b => b.body.transactionList shouldBe Seq(signedTransaction.tx, nextTransaction))
fullBlock.right.foreach(b => b.header.extraData shouldBe headerExtraData)
}
it should "include transaction with higher gas price if nonce is the same" in new TestSetup {
val txWitSameNonceButLowerGasPrice = SignedTransaction
.sign(transaction.copy(gasPrice = signedTransaction.tx.tx.gasPrice - 1), keyPair, Some(0x3d.toByte))
.tx
val result: Either[BlockPreparationError, PendingBlock] =
blockGenerator.generateBlock(
bestBlock,
Seq(txWitSameNonceButLowerGasPrice, signedTransaction.tx),
Address(testAddress),
blockGenerator.emptyX
)
result shouldBe a[Right[_, Block]]
//mined with mantis + ethminer
val minedNonce = ByteString(Hex.decode("14d7000ac544b38e"))
val minedMixHash = ByteString(Hex.decode("270f6b2618c5bef6a188397927129c803e5fd41c85492835486832f6825a8d78"))
val miningTimestamp = 1508752698
val fullBlock: Either[BlockPreparationError, Block] = result.right
.map(pb =>
pb.block.copy(header =
pb.block.header.copy(nonce = minedNonce, mixHash = minedMixHash, unixTimestamp = miningTimestamp)
)
)
fullBlock.right.foreach(b =>
validators.blockHeaderValidator.validate(b.header, blockchain.getBlockHeaderByHash) shouldBe Right(
BlockHeaderValid
)
)
fullBlock.right.foreach(b => blockExecution.executeBlock(b) shouldBe a[Right[_, Seq[Receipt]]])
fullBlock.right.foreach(b => b.body.transactionList shouldBe Seq(signedTransaction.tx))
fullBlock.right.foreach(b => b.header.extraData shouldBe headerExtraData)
}
it should "build blocks with the correct opt-out" in {
val table = Table[Boolean, Boolean, Option[Boolean]](("ecip1098Activated", "selectedOptOut", "expectedOptOut"),
// Already activated
(true, true, Some(true)),
(true, false, Some(false)),
// Not yet activated
(false, true, None),
(false, false, None)
)
forAll(table) { case (ecip1098Activated, selectedOptOut, expectedOptOut) =>
val testSetup = new TestSetup {
override lazy val blockchainConfig = baseBlockchainConfig.copy(ecip1098BlockNumber = 10000000)
override lazy val consensusConfig = buildConsensusConfig().copy(treasuryOptOut = selectedOptOut)
}
import testSetup._
val blockNumber = if (ecip1098Activated) blockchainConfig.ecip1098BlockNumber * 2 else blockchainConfig.ecip1098BlockNumber / 2
val parentBlock = bestBlock.copy(header = bestBlock.header.copy(number = blockNumber - 1))
val generatedBlock: Either[BlockPreparationError, PendingBlock] =
blockGenerator.generateBlock(parentBlock, Nil, Address(testAddress), blockGenerator.emptyX)
generatedBlock shouldBe a[Right[_, Block]]
generatedBlock.right.foreach(b => b.block.header.treasuryOptOut shouldBe expectedOptOut)
}
}
trait TestSetup extends EphemBlockchainTestSetup {
val testAddress = 42
val privateKey = BigInt(1, Hex.decode("f3202185c84325302d43887e90a2e23e7bc058d0450bb58ef2f7585765d7d48b"))
lazy val keyPair: AsymmetricCipherKeyPair = keyPairFromPrvKey(privateKey)
lazy val pubKey: Array[Byte] = keyPair.getPublic.asInstanceOf[ECPublicKeyParameters].getQ.getEncoded(false).tail
lazy val address = Address(crypto.kec256(pubKey).drop(FirstByteOfAddress))
val txGasLimit = 21000
val txTransfer = 9000
val transaction = Transaction(
nonce = 0,
gasPrice = 1,
gasLimit = txGasLimit,
receivingAddress = Address(testAddress),
value = txTransfer,
payload = ByteString.empty
)
lazy val signedTransaction = SignedTransaction.sign(transaction, keyPair, Some(0x3d.toByte))
lazy val duplicatedSignedTransaction =
SignedTransaction.sign(transaction.copy(gasLimit = 2), keyPair, Some(0x3d.toByte))
val baseBlockchainConfig = BlockchainConfig(
frontierBlockNumber = 0,
homesteadBlockNumber = 1150000,
difficultyBombPauseBlockNumber = 3000000,
difficultyBombContinueBlockNumber = 5000000,
difficultyBombRemovalBlockNumber = 5900000,
eip155BlockNumber = 0,
eip106BlockNumber = Long.MaxValue,
byzantiumBlockNumber = Long.MaxValue,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
chainId = 0x3d.toByte,
networkId = 1,
customGenesisFileOpt = Some("test-genesis.json"),
monetaryPolicyConfig =
MonetaryPolicyConfig(5000000, 0.2, 5000000000000000000L, 3000000000000000000L, 2000000000000000000L),
// unused
maxCodeSize = None,
eip160BlockNumber = Long.MaxValue,
eip150BlockNumber = Long.MaxValue,
eip161BlockNumber = Long.MaxValue,
accountStartNonce = UInt256.Zero,
daoForkConfig = None,
bootstrapNodes = Set(),
gasTieBreaker = false,
ethCompatibleStorage = true,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue
)
override lazy val blockchainConfig = baseBlockchainConfig
val genesisDataLoader = new GenesisDataLoader(blockchain, blockchainConfig)
genesisDataLoader.loadGenesisData()
val bestBlock = blockchain.getBestBlock()
lazy val blockTimestampProvider = new FakeBlockTimestampProvider
val blockCacheSize: Int = 30
val headerExtraData: ByteString = ByteString("mined with etc scala")
override lazy val validators: ValidatorsExecutor = ethashValidators
override lazy val consensusConfig =
buildConsensusConfig().copy(headerExtraData = headerExtraData, blockCacheSize = blockCacheSize)
lazy val blockGenerator = consensus.blockGenerator.withBlockTimestampProvider(blockTimestampProvider)
lazy val blockValidation = new BlockValidation(consensus, blockchain, BlockQueue(blockchain, syncConfig))
lazy val blockExecution =
new BlockExecution(blockchain, blockchainConfig, consensus.blockPreparator, blockValidation)
}
}
class FakeBlockTimestampProvider extends BlockTimestampProvider {
private var timestamp = Instant.now.getEpochSecond
def advance(seconds: Long): Unit = timestamp += seconds
override def getEpochSecond: Long = timestamp
}