@@ -23,9 +23,14 @@ import scala.util.{Failure, Success, Try}
23
23
object ScenarioSetup {
24
24
val testContext = ExecutionContext .fromExecutor(Executors .newFixedThreadPool(4 ))
25
25
val specificConfig = ethash.EthashConfig (Config .config)
26
- val fullConfig = FullConsensusConfig (ConsensusConfig (Config .config)(null ), specificConfig)
27
-
28
- def loadEthashConsensus (vm : VMImpl , blockchain : BlockchainImpl , blockchainConfig : BlockchainConfig , validators : ValidatorsExecutor ): ethash.EthashConsensus = {
26
+ val fullConfig = FullConsensusConfig (ConsensusConfig (Config .config), specificConfig)
27
+
28
+ def loadEthashConsensus (
29
+ vm : VMImpl ,
30
+ blockchain : BlockchainImpl ,
31
+ blockchainConfig : BlockchainConfig ,
32
+ validators : ValidatorsExecutor
33
+ ): ethash.EthashConsensus = {
29
34
val consensus = EthashConsensus (vm, blockchain, blockchainConfig, fullConfig, validators)
30
35
consensus
31
36
}
@@ -34,7 +39,6 @@ object ScenarioSetup {
34
39
override val pruningMode : PruningMode = ArchivePruning
35
40
}
36
41
37
-
38
42
def getBlockchain : BlockchainImpl = {
39
43
val storagesInstance = new EphemDataSourceComponent with Pruning with Storages .DefaultStorages
40
44
BlockchainImpl (storagesInstance.storages)
@@ -61,21 +65,28 @@ abstract class ScenarioSetup(_vm: VMImpl, scenario: BlockchainScenario) {
61
65
val ledger =
62
66
new LedgerImpl (
63
67
blockchain,
64
- new BlockQueue (blockchain, 50 , 50 ), blockchainConfig, consensus, ScenarioSetup .testContext)
68
+ new BlockQueue (blockchain, 50 , 50 ),
69
+ blockchainConfig,
70
+ consensus,
71
+ ScenarioSetup .testContext
72
+ )
65
73
66
74
def loadGenesis (): Block = {
67
75
val genesisBlock = scenario.genesisRLP match {
68
76
case Some (rlp) =>
69
77
val block = rlp.toArray.toBlock
70
- assert(block.header == scenario.genesisBlockHeader.toBlockHeader,
71
- " decoded genesis block header did not match the expectation" )
78
+ assert(
79
+ block.header == scenario.genesisBlockHeader.toBlockHeader,
80
+ " decoded genesis block header did not match the expectation"
81
+ )
72
82
block
73
83
74
84
case None =>
75
85
Block (scenario.genesisBlockHeader.toBlockHeader, BlockBody (Nil , Nil ))
76
86
}
77
87
78
- blockchain.storeBlock(genesisBlock)
88
+ blockchain
89
+ .storeBlock(genesisBlock)
79
90
.and(blockchain.storeReceipts(genesisBlock.header.hash, Nil ))
80
91
.and(blockchain.storeTotalDifficulty(genesisBlock.header.hash, genesisBlock.header.difficulty))
81
92
.commit()
@@ -85,7 +96,8 @@ abstract class ScenarioSetup(_vm: VMImpl, scenario: BlockchainScenario) {
85
96
86
97
val initialWorld : InMemoryWorldStateProxy = InMemoryWorldStateProxy .persistState(getWorldState(scenario.pre))
87
98
88
- val finalWorld : Option [InMemoryWorldStateProxy ] = scenario.postState.map(postState => InMemoryWorldStateProxy .persistState(getWorldState(postState)))
99
+ val finalWorld : Option [InMemoryWorldStateProxy ] =
100
+ scenario.postState.map(postState => InMemoryWorldStateProxy .persistState(getWorldState(postState)))
89
101
90
102
def getBestBlock : Option [Block ] = {
91
103
val bestBlockNumber = blockchain.getBestBlockNumber()
@@ -123,23 +135,25 @@ abstract class ScenarioSetup(_vm: VMImpl, scenario: BlockchainScenario) {
123
135
case _ => (FrontierConfig , Validators .frontierValidators)
124
136
}
125
137
126
- private def withSkippedPoWValidationBlockchainConfig (network : String ): (BlockchainConfig , ValidatorsExecutor ) = network match {
127
- case " EIP150" => (Eip150Config , ValidatorsWithSkippedPoW .eip150Validators)
128
- case " Frontier" => (FrontierConfig , ValidatorsWithSkippedPoW .frontierValidators)
129
- case " Homestead" => (HomesteadConfig , ValidatorsWithSkippedPoW .homesteadValidators)
130
- case " FrontierToHomesteadAt5" => (FrontierToHomesteadAt5 , ValidatorsWithSkippedPoW .frontierToHomesteadValidators)
131
- case " HomesteadToEIP150At5" => (HomesteadToEIP150At5 , ValidatorsWithSkippedPoW .homesteadToEipValidators)
132
- case " EIP158" => (Eip158Config , ValidatorsWithSkippedPoW .eip158Validators)
133
- case " HomesteadToDaoAt5" => (HomesteadToDaoAt5 , ValidatorsWithSkippedPoW .homesteadToDaoValidators)
134
- case " Byzantium" => (ByzantiumConfig , ValidatorsWithSkippedPoW .byzantiumValidators)
135
- case " Constantinople" => (ConstantinopleConfig , ValidatorsWithSkippedPoW .constantinopleValidators)
136
- case " EIP158ToByzantiumAt5" => (Eip158ToByzantiumAt5Config , ValidatorsWithSkippedPoW .eip158ToByzantiumValidators)
137
- case " ByzantiumToConstantinopleFixAt5" => (ByzantiumToConstantinopleAt5 , ValidatorsWithSkippedPoW .byzantiumToConstantinopleAt5)
138
- case " ConstantinopleFix" => (ConstantinopleFixConfig , ValidatorsWithSkippedPoW .constantinopleFixValidators)
139
- case " Istanbul" => (IstanbulConfig , ValidatorsWithSkippedPoW .istanbulValidators)
140
- // Some default config, test will fail or be canceled
141
- case _ => (FrontierConfig , ValidatorsWithSkippedPoW .frontierValidators)
142
- }
138
+ private def withSkippedPoWValidationBlockchainConfig (network : String ): (BlockchainConfig , ValidatorsExecutor ) =
139
+ network match {
140
+ case " EIP150" => (Eip150Config , ValidatorsWithSkippedPoW .eip150Validators)
141
+ case " Frontier" => (FrontierConfig , ValidatorsWithSkippedPoW .frontierValidators)
142
+ case " Homestead" => (HomesteadConfig , ValidatorsWithSkippedPoW .homesteadValidators)
143
+ case " FrontierToHomesteadAt5" => (FrontierToHomesteadAt5 , ValidatorsWithSkippedPoW .frontierToHomesteadValidators)
144
+ case " HomesteadToEIP150At5" => (HomesteadToEIP150At5 , ValidatorsWithSkippedPoW .homesteadToEipValidators)
145
+ case " EIP158" => (Eip158Config , ValidatorsWithSkippedPoW .eip158Validators)
146
+ case " HomesteadToDaoAt5" => (HomesteadToDaoAt5 , ValidatorsWithSkippedPoW .homesteadToDaoValidators)
147
+ case " Byzantium" => (ByzantiumConfig , ValidatorsWithSkippedPoW .byzantiumValidators)
148
+ case " Constantinople" => (ConstantinopleConfig , ValidatorsWithSkippedPoW .constantinopleValidators)
149
+ case " EIP158ToByzantiumAt5" => (Eip158ToByzantiumAt5Config , ValidatorsWithSkippedPoW .eip158ToByzantiumValidators)
150
+ case " ByzantiumToConstantinopleFixAt5" =>
151
+ (ByzantiumToConstantinopleAt5 , ValidatorsWithSkippedPoW .byzantiumToConstantinopleAt5)
152
+ case " ConstantinopleFix" => (ConstantinopleFixConfig , ValidatorsWithSkippedPoW .constantinopleFixValidators)
153
+ case " Istanbul" => (IstanbulConfig , ValidatorsWithSkippedPoW .istanbulValidators)
154
+ // Some default config, test will fail or be canceled
155
+ case _ => (FrontierConfig , ValidatorsWithSkippedPoW .frontierValidators)
156
+ }
143
157
144
158
private def decode (s : String ): Array [Byte ] = {
145
159
val stripped = s.replaceFirst(" ^0x" , " " )
@@ -152,7 +166,7 @@ abstract class ScenarioSetup(_vm: VMImpl, scenario: BlockchainScenario) {
152
166
case Success (block) =>
153
167
Some (block)
154
168
155
- case Failure (ex) =>
169
+ case Failure (ex) =>
156
170
ex.printStackTrace()
157
171
None
158
172
}
0 commit comments