@@ -35,16 +35,16 @@ object TestService {
35
35
mixHash : ByteString
36
36
)
37
37
case class BlockchainParams (
38
- EIP150ForkBlock : BigInt ,
39
- EIP158ForkBlock : BigInt ,
38
+ EIP150ForkBlock : Option [ BigInt ] ,
39
+ EIP158ForkBlock : Option [ BigInt ] ,
40
40
accountStartNonce : BigInt ,
41
41
allowFutureBlocks : Boolean ,
42
42
blockReward : BigInt ,
43
- byzantiumForkBlock : BigInt ,
44
- homesteadForkBlock : BigInt ,
43
+ byzantiumForkBlock : Option [ BigInt ] ,
44
+ homesteadForkBlock : Option [ BigInt ] ,
45
45
maximumExtraDataSize : BigInt ,
46
- constantinopleForkBlock : BigInt ,
47
- istanbulForkBlock : BigInt
46
+ constantinopleForkBlock : Option [ BigInt ] ,
47
+ istanbulForkBlock : Option [ BigInt ]
48
48
)
49
49
50
50
case class ChainParams (
@@ -155,19 +155,44 @@ class TestService(
155
155
// load the new genesis
156
156
val genesisDataLoader = new GenesisDataLoader (blockchain, newBlockchainConfig)
157
157
genesisDataLoader.loadGenesisData(genesisData)
158
+
158
159
// save account codes to world state
159
160
storeGenesisAccountCodes(genesisData.alloc)
160
161
storeGenesisAccountStorageData(genesisData.alloc)
161
162
162
163
// update test ledger with new config
163
164
testLedgerWrapper.blockchainConfig = newBlockchainConfig
165
+ consensus.blockchainConfig = newBlockchainConfig
164
166
165
167
accountAddresses = genesisData.alloc.keys.toList
166
168
accountRangeOffset = 0
167
169
168
170
SetChainParamsResponse ().rightNow
169
171
}
170
172
173
+ private def buildNewConfig (blockchainParams : BlockchainParams ) = {
174
+ val byzantiumBlockNumber : BigInt = blockchainParams.byzantiumForkBlock.getOrElse(Int .MaxValue )
175
+ val istanbulForkBlockNumber : BigInt = blockchainParams.istanbulForkBlock.getOrElse(Int .MaxValue )
176
+
177
+ // For block number which are not specified by retesteth, we try to align the number to another fork
178
+ testLedgerWrapper.blockchainConfig.copy(
179
+ homesteadBlockNumber = blockchainParams.homesteadForkBlock.getOrElse(Int .MaxValue ),
180
+ eip150BlockNumber = blockchainParams.EIP150ForkBlock .getOrElse(Int .MaxValue ),
181
+ eip160BlockNumber = byzantiumBlockNumber,
182
+ eip161BlockNumber = byzantiumBlockNumber,
183
+ byzantiumBlockNumber = byzantiumBlockNumber,
184
+ constantinopleBlockNumber = blockchainParams.constantinopleForkBlock.getOrElse(Int .MaxValue ),
185
+ petersburgBlockNumber = istanbulForkBlockNumber,
186
+ aghartaBlockNumber = istanbulForkBlockNumber,
187
+ istanbulBlockNumber = istanbulForkBlockNumber,
188
+ atlantisBlockNumber = istanbulForkBlockNumber,
189
+ phoenixBlockNumber = istanbulForkBlockNumber,
190
+ accountStartNonce = UInt256 (blockchainParams.accountStartNonce),
191
+ networkId = 1 ,
192
+ bootstrapNodes = Set ()
193
+ )
194
+ }
195
+
171
196
private def storeGenesisAccountCodes (accounts : Map [String , GenesisAccount ]): Unit =
172
197
accounts
173
198
.collect { case (_, GenesisAccount (_, _, Some (code), _, _)) => code }
0 commit comments