github.com/ethereum/go-ethereum@v1.16.1/tests/init.go (about) 1 // Copyright 2015 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 package tests 18 19 import ( 20 "fmt" 21 "math/big" 22 "sort" 23 24 "github.com/ethereum/go-ethereum/params" 25 ) 26 27 func u64(val uint64) *uint64 { return &val } 28 29 // Forks table defines supported forks and their chain config. 30 var Forks = map[string]*params.ChainConfig{ 31 "Frontier": { 32 ChainID: big.NewInt(1), 33 }, 34 "Homestead": { 35 ChainID: big.NewInt(1), 36 HomesteadBlock: big.NewInt(0), 37 }, 38 "EIP150": { 39 ChainID: big.NewInt(1), 40 HomesteadBlock: big.NewInt(0), 41 EIP150Block: big.NewInt(0), 42 }, 43 "EIP158": { 44 ChainID: big.NewInt(1), 45 HomesteadBlock: big.NewInt(0), 46 EIP150Block: big.NewInt(0), 47 EIP155Block: big.NewInt(0), 48 EIP158Block: big.NewInt(0), 49 }, 50 "Byzantium": { 51 ChainID: big.NewInt(1), 52 HomesteadBlock: big.NewInt(0), 53 EIP150Block: big.NewInt(0), 54 EIP155Block: big.NewInt(0), 55 EIP158Block: big.NewInt(0), 56 DAOForkBlock: big.NewInt(0), 57 ByzantiumBlock: big.NewInt(0), 58 }, 59 "Constantinople": { 60 ChainID: big.NewInt(1), 61 HomesteadBlock: big.NewInt(0), 62 EIP150Block: big.NewInt(0), 63 EIP155Block: big.NewInt(0), 64 EIP158Block: big.NewInt(0), 65 DAOForkBlock: big.NewInt(0), 66 ByzantiumBlock: big.NewInt(0), 67 ConstantinopleBlock: big.NewInt(0), 68 PetersburgBlock: big.NewInt(10000000), 69 }, 70 "ConstantinopleFix": { 71 ChainID: big.NewInt(1), 72 HomesteadBlock: big.NewInt(0), 73 EIP150Block: big.NewInt(0), 74 EIP155Block: big.NewInt(0), 75 EIP158Block: big.NewInt(0), 76 DAOForkBlock: big.NewInt(0), 77 ByzantiumBlock: big.NewInt(0), 78 ConstantinopleBlock: big.NewInt(0), 79 PetersburgBlock: big.NewInt(0), 80 }, 81 "Istanbul": { 82 ChainID: big.NewInt(1), 83 HomesteadBlock: big.NewInt(0), 84 EIP150Block: big.NewInt(0), 85 EIP155Block: big.NewInt(0), 86 EIP158Block: big.NewInt(0), 87 DAOForkBlock: big.NewInt(0), 88 ByzantiumBlock: big.NewInt(0), 89 ConstantinopleBlock: big.NewInt(0), 90 PetersburgBlock: big.NewInt(0), 91 IstanbulBlock: big.NewInt(0), 92 }, 93 "MuirGlacier": { 94 ChainID: big.NewInt(1), 95 HomesteadBlock: big.NewInt(0), 96 EIP150Block: big.NewInt(0), 97 EIP155Block: big.NewInt(0), 98 EIP158Block: big.NewInt(0), 99 DAOForkBlock: big.NewInt(0), 100 ByzantiumBlock: big.NewInt(0), 101 ConstantinopleBlock: big.NewInt(0), 102 PetersburgBlock: big.NewInt(0), 103 IstanbulBlock: big.NewInt(0), 104 MuirGlacierBlock: big.NewInt(0), 105 }, 106 "FrontierToHomesteadAt5": { 107 ChainID: big.NewInt(1), 108 HomesteadBlock: big.NewInt(5), 109 }, 110 "HomesteadToEIP150At5": { 111 ChainID: big.NewInt(1), 112 HomesteadBlock: big.NewInt(0), 113 EIP150Block: big.NewInt(5), 114 }, 115 "HomesteadToDaoAt5": { 116 ChainID: big.NewInt(1), 117 HomesteadBlock: big.NewInt(0), 118 DAOForkBlock: big.NewInt(5), 119 DAOForkSupport: true, 120 }, 121 "EIP158ToByzantiumAt5": { 122 ChainID: big.NewInt(1), 123 HomesteadBlock: big.NewInt(0), 124 EIP150Block: big.NewInt(0), 125 EIP155Block: big.NewInt(0), 126 EIP158Block: big.NewInt(0), 127 ByzantiumBlock: big.NewInt(5), 128 }, 129 "ByzantiumToConstantinopleAt5": { 130 ChainID: big.NewInt(1), 131 HomesteadBlock: big.NewInt(0), 132 EIP150Block: big.NewInt(0), 133 EIP155Block: big.NewInt(0), 134 EIP158Block: big.NewInt(0), 135 ByzantiumBlock: big.NewInt(0), 136 ConstantinopleBlock: big.NewInt(5), 137 }, 138 "ByzantiumToConstantinopleFixAt5": { 139 ChainID: big.NewInt(1), 140 HomesteadBlock: big.NewInt(0), 141 EIP150Block: big.NewInt(0), 142 EIP155Block: big.NewInt(0), 143 EIP158Block: big.NewInt(0), 144 ByzantiumBlock: big.NewInt(0), 145 ConstantinopleBlock: big.NewInt(5), 146 PetersburgBlock: big.NewInt(5), 147 }, 148 "ConstantinopleFixToIstanbulAt5": { 149 ChainID: big.NewInt(1), 150 HomesteadBlock: big.NewInt(0), 151 EIP150Block: big.NewInt(0), 152 EIP155Block: big.NewInt(0), 153 EIP158Block: big.NewInt(0), 154 ByzantiumBlock: big.NewInt(0), 155 ConstantinopleBlock: big.NewInt(0), 156 PetersburgBlock: big.NewInt(0), 157 IstanbulBlock: big.NewInt(5), 158 }, 159 "Berlin": { 160 ChainID: big.NewInt(1), 161 HomesteadBlock: big.NewInt(0), 162 EIP150Block: big.NewInt(0), 163 EIP155Block: big.NewInt(0), 164 EIP158Block: big.NewInt(0), 165 ByzantiumBlock: big.NewInt(0), 166 ConstantinopleBlock: big.NewInt(0), 167 PetersburgBlock: big.NewInt(0), 168 IstanbulBlock: big.NewInt(0), 169 MuirGlacierBlock: big.NewInt(0), 170 BerlinBlock: big.NewInt(0), 171 }, 172 "BerlinToLondonAt5": { 173 ChainID: big.NewInt(1), 174 HomesteadBlock: big.NewInt(0), 175 EIP150Block: big.NewInt(0), 176 EIP155Block: big.NewInt(0), 177 EIP158Block: big.NewInt(0), 178 ByzantiumBlock: big.NewInt(0), 179 ConstantinopleBlock: big.NewInt(0), 180 PetersburgBlock: big.NewInt(0), 181 IstanbulBlock: big.NewInt(0), 182 MuirGlacierBlock: big.NewInt(0), 183 BerlinBlock: big.NewInt(0), 184 LondonBlock: big.NewInt(5), 185 }, 186 "London": { 187 ChainID: big.NewInt(1), 188 HomesteadBlock: big.NewInt(0), 189 EIP150Block: big.NewInt(0), 190 EIP155Block: big.NewInt(0), 191 EIP158Block: big.NewInt(0), 192 ByzantiumBlock: big.NewInt(0), 193 ConstantinopleBlock: big.NewInt(0), 194 PetersburgBlock: big.NewInt(0), 195 IstanbulBlock: big.NewInt(0), 196 MuirGlacierBlock: big.NewInt(0), 197 BerlinBlock: big.NewInt(0), 198 LondonBlock: big.NewInt(0), 199 }, 200 "ArrowGlacier": { 201 ChainID: big.NewInt(1), 202 HomesteadBlock: big.NewInt(0), 203 EIP150Block: big.NewInt(0), 204 EIP155Block: big.NewInt(0), 205 EIP158Block: big.NewInt(0), 206 ByzantiumBlock: big.NewInt(0), 207 ConstantinopleBlock: big.NewInt(0), 208 PetersburgBlock: big.NewInt(0), 209 IstanbulBlock: big.NewInt(0), 210 MuirGlacierBlock: big.NewInt(0), 211 BerlinBlock: big.NewInt(0), 212 LondonBlock: big.NewInt(0), 213 ArrowGlacierBlock: big.NewInt(0), 214 }, 215 "ArrowGlacierToParisAtDiffC0000": { 216 ChainID: big.NewInt(1), 217 HomesteadBlock: big.NewInt(0), 218 EIP150Block: big.NewInt(0), 219 EIP155Block: big.NewInt(0), 220 EIP158Block: big.NewInt(0), 221 ByzantiumBlock: big.NewInt(0), 222 ConstantinopleBlock: big.NewInt(0), 223 PetersburgBlock: big.NewInt(0), 224 IstanbulBlock: big.NewInt(0), 225 MuirGlacierBlock: big.NewInt(0), 226 BerlinBlock: big.NewInt(0), 227 LondonBlock: big.NewInt(0), 228 ArrowGlacierBlock: big.NewInt(0), 229 GrayGlacierBlock: big.NewInt(0), 230 MergeNetsplitBlock: big.NewInt(0), 231 TerminalTotalDifficulty: big.NewInt(0xC0000), 232 }, 233 "GrayGlacier": { 234 ChainID: big.NewInt(1), 235 HomesteadBlock: big.NewInt(0), 236 EIP150Block: big.NewInt(0), 237 EIP155Block: big.NewInt(0), 238 EIP158Block: big.NewInt(0), 239 ByzantiumBlock: big.NewInt(0), 240 ConstantinopleBlock: big.NewInt(0), 241 PetersburgBlock: big.NewInt(0), 242 IstanbulBlock: big.NewInt(0), 243 MuirGlacierBlock: big.NewInt(0), 244 BerlinBlock: big.NewInt(0), 245 LondonBlock: big.NewInt(0), 246 ArrowGlacierBlock: big.NewInt(0), 247 GrayGlacierBlock: big.NewInt(0), 248 }, 249 "Paris": { 250 ChainID: big.NewInt(1), 251 HomesteadBlock: big.NewInt(0), 252 EIP150Block: big.NewInt(0), 253 EIP155Block: big.NewInt(0), 254 EIP158Block: big.NewInt(0), 255 ByzantiumBlock: big.NewInt(0), 256 ConstantinopleBlock: big.NewInt(0), 257 PetersburgBlock: big.NewInt(0), 258 IstanbulBlock: big.NewInt(0), 259 MuirGlacierBlock: big.NewInt(0), 260 BerlinBlock: big.NewInt(0), 261 LondonBlock: big.NewInt(0), 262 ArrowGlacierBlock: big.NewInt(0), 263 MergeNetsplitBlock: big.NewInt(0), 264 TerminalTotalDifficulty: big.NewInt(0), 265 }, 266 "Merge": { 267 ChainID: big.NewInt(1), 268 HomesteadBlock: big.NewInt(0), 269 EIP150Block: big.NewInt(0), 270 EIP155Block: big.NewInt(0), 271 EIP158Block: big.NewInt(0), 272 ByzantiumBlock: big.NewInt(0), 273 ConstantinopleBlock: big.NewInt(0), 274 PetersburgBlock: big.NewInt(0), 275 IstanbulBlock: big.NewInt(0), 276 MuirGlacierBlock: big.NewInt(0), 277 BerlinBlock: big.NewInt(0), 278 LondonBlock: big.NewInt(0), 279 ArrowGlacierBlock: big.NewInt(0), 280 MergeNetsplitBlock: big.NewInt(0), 281 TerminalTotalDifficulty: big.NewInt(0), 282 }, 283 "Shanghai": { 284 ChainID: big.NewInt(1), 285 HomesteadBlock: big.NewInt(0), 286 EIP150Block: big.NewInt(0), 287 EIP155Block: big.NewInt(0), 288 EIP158Block: big.NewInt(0), 289 ByzantiumBlock: big.NewInt(0), 290 ConstantinopleBlock: big.NewInt(0), 291 PetersburgBlock: big.NewInt(0), 292 IstanbulBlock: big.NewInt(0), 293 MuirGlacierBlock: big.NewInt(0), 294 BerlinBlock: big.NewInt(0), 295 LondonBlock: big.NewInt(0), 296 ArrowGlacierBlock: big.NewInt(0), 297 MergeNetsplitBlock: big.NewInt(0), 298 TerminalTotalDifficulty: big.NewInt(0), 299 ShanghaiTime: u64(0), 300 }, 301 "ParisToShanghaiAtTime15k": { 302 ChainID: big.NewInt(1), 303 HomesteadBlock: big.NewInt(0), 304 EIP150Block: big.NewInt(0), 305 EIP155Block: big.NewInt(0), 306 EIP158Block: big.NewInt(0), 307 ByzantiumBlock: big.NewInt(0), 308 ConstantinopleBlock: big.NewInt(0), 309 PetersburgBlock: big.NewInt(0), 310 IstanbulBlock: big.NewInt(0), 311 MuirGlacierBlock: big.NewInt(0), 312 BerlinBlock: big.NewInt(0), 313 LondonBlock: big.NewInt(0), 314 ArrowGlacierBlock: big.NewInt(0), 315 MergeNetsplitBlock: big.NewInt(0), 316 TerminalTotalDifficulty: big.NewInt(0), 317 ShanghaiTime: u64(15_000), 318 }, 319 "Cancun": { 320 ChainID: big.NewInt(1), 321 HomesteadBlock: big.NewInt(0), 322 EIP150Block: big.NewInt(0), 323 EIP155Block: big.NewInt(0), 324 EIP158Block: big.NewInt(0), 325 ByzantiumBlock: big.NewInt(0), 326 ConstantinopleBlock: big.NewInt(0), 327 PetersburgBlock: big.NewInt(0), 328 IstanbulBlock: big.NewInt(0), 329 MuirGlacierBlock: big.NewInt(0), 330 BerlinBlock: big.NewInt(0), 331 LondonBlock: big.NewInt(0), 332 ArrowGlacierBlock: big.NewInt(0), 333 MergeNetsplitBlock: big.NewInt(0), 334 TerminalTotalDifficulty: big.NewInt(0), 335 ShanghaiTime: u64(0), 336 CancunTime: u64(0), 337 BlobScheduleConfig: ¶ms.BlobScheduleConfig{ 338 Cancun: params.DefaultCancunBlobConfig, 339 }, 340 }, 341 "ShanghaiToCancunAtTime15k": { 342 ChainID: big.NewInt(1), 343 HomesteadBlock: big.NewInt(0), 344 EIP150Block: big.NewInt(0), 345 EIP155Block: big.NewInt(0), 346 EIP158Block: big.NewInt(0), 347 ByzantiumBlock: big.NewInt(0), 348 ConstantinopleBlock: big.NewInt(0), 349 PetersburgBlock: big.NewInt(0), 350 IstanbulBlock: big.NewInt(0), 351 MuirGlacierBlock: big.NewInt(0), 352 BerlinBlock: big.NewInt(0), 353 LondonBlock: big.NewInt(0), 354 ArrowGlacierBlock: big.NewInt(0), 355 MergeNetsplitBlock: big.NewInt(0), 356 TerminalTotalDifficulty: big.NewInt(0), 357 ShanghaiTime: u64(0), 358 CancunTime: u64(15_000), 359 BlobScheduleConfig: ¶ms.BlobScheduleConfig{ 360 Cancun: params.DefaultCancunBlobConfig, 361 }, 362 }, 363 "Prague": { 364 ChainID: big.NewInt(1), 365 HomesteadBlock: big.NewInt(0), 366 EIP150Block: big.NewInt(0), 367 EIP155Block: big.NewInt(0), 368 EIP158Block: big.NewInt(0), 369 ByzantiumBlock: big.NewInt(0), 370 ConstantinopleBlock: big.NewInt(0), 371 PetersburgBlock: big.NewInt(0), 372 IstanbulBlock: big.NewInt(0), 373 MuirGlacierBlock: big.NewInt(0), 374 BerlinBlock: big.NewInt(0), 375 LondonBlock: big.NewInt(0), 376 ArrowGlacierBlock: big.NewInt(0), 377 MergeNetsplitBlock: big.NewInt(0), 378 TerminalTotalDifficulty: big.NewInt(0), 379 ShanghaiTime: u64(0), 380 CancunTime: u64(0), 381 PragueTime: u64(0), 382 DepositContractAddress: params.MainnetChainConfig.DepositContractAddress, 383 BlobScheduleConfig: ¶ms.BlobScheduleConfig{ 384 Cancun: params.DefaultCancunBlobConfig, 385 Prague: params.DefaultPragueBlobConfig, 386 }, 387 }, 388 "CancunToPragueAtTime15k": { 389 ChainID: big.NewInt(1), 390 HomesteadBlock: big.NewInt(0), 391 EIP150Block: big.NewInt(0), 392 EIP155Block: big.NewInt(0), 393 EIP158Block: big.NewInt(0), 394 ByzantiumBlock: big.NewInt(0), 395 ConstantinopleBlock: big.NewInt(0), 396 PetersburgBlock: big.NewInt(0), 397 IstanbulBlock: big.NewInt(0), 398 MuirGlacierBlock: big.NewInt(0), 399 BerlinBlock: big.NewInt(0), 400 LondonBlock: big.NewInt(0), 401 ArrowGlacierBlock: big.NewInt(0), 402 MergeNetsplitBlock: big.NewInt(0), 403 TerminalTotalDifficulty: big.NewInt(0), 404 ShanghaiTime: u64(0), 405 CancunTime: u64(0), 406 PragueTime: u64(15_000), 407 DepositContractAddress: params.MainnetChainConfig.DepositContractAddress, 408 BlobScheduleConfig: ¶ms.BlobScheduleConfig{ 409 Cancun: params.DefaultCancunBlobConfig, 410 Prague: params.DefaultPragueBlobConfig, 411 }, 412 }, 413 "Osaka": { 414 ChainID: big.NewInt(1), 415 HomesteadBlock: big.NewInt(0), 416 EIP150Block: big.NewInt(0), 417 EIP155Block: big.NewInt(0), 418 EIP158Block: big.NewInt(0), 419 ByzantiumBlock: big.NewInt(0), 420 ConstantinopleBlock: big.NewInt(0), 421 PetersburgBlock: big.NewInt(0), 422 IstanbulBlock: big.NewInt(0), 423 MuirGlacierBlock: big.NewInt(0), 424 BerlinBlock: big.NewInt(0), 425 LondonBlock: big.NewInt(0), 426 ArrowGlacierBlock: big.NewInt(0), 427 MergeNetsplitBlock: big.NewInt(0), 428 TerminalTotalDifficulty: big.NewInt(0), 429 ShanghaiTime: u64(0), 430 CancunTime: u64(0), 431 PragueTime: u64(0), 432 OsakaTime: u64(0), 433 DepositContractAddress: params.MainnetChainConfig.DepositContractAddress, 434 BlobScheduleConfig: ¶ms.BlobScheduleConfig{ 435 Cancun: params.DefaultCancunBlobConfig, 436 Prague: params.DefaultPragueBlobConfig, 437 Osaka: params.DefaultOsakaBlobConfig, 438 }, 439 }, 440 "PragueToOsakaAtTime15k": { 441 ChainID: big.NewInt(1), 442 HomesteadBlock: big.NewInt(0), 443 EIP150Block: big.NewInt(0), 444 EIP155Block: big.NewInt(0), 445 EIP158Block: big.NewInt(0), 446 ByzantiumBlock: big.NewInt(0), 447 ConstantinopleBlock: big.NewInt(0), 448 PetersburgBlock: big.NewInt(0), 449 IstanbulBlock: big.NewInt(0), 450 MuirGlacierBlock: big.NewInt(0), 451 BerlinBlock: big.NewInt(0), 452 LondonBlock: big.NewInt(0), 453 ArrowGlacierBlock: big.NewInt(0), 454 MergeNetsplitBlock: big.NewInt(0), 455 TerminalTotalDifficulty: big.NewInt(0), 456 ShanghaiTime: u64(0), 457 CancunTime: u64(0), 458 PragueTime: u64(0), 459 OsakaTime: u64(15_000), 460 DepositContractAddress: params.MainnetChainConfig.DepositContractAddress, 461 BlobScheduleConfig: ¶ms.BlobScheduleConfig{ 462 Cancun: params.DefaultCancunBlobConfig, 463 Prague: params.DefaultPragueBlobConfig, 464 Osaka: params.DefaultOsakaBlobConfig, 465 }, 466 }, 467 } 468 469 // AvailableForks returns the set of defined fork names 470 func AvailableForks() []string { 471 var availableForks []string 472 for k := range Forks { 473 availableForks = append(availableForks, k) 474 } 475 sort.Strings(availableForks) 476 return availableForks 477 } 478 479 // UnsupportedForkError is returned when a test requests a fork that isn't implemented. 480 type UnsupportedForkError struct { 481 Name string 482 } 483 484 func (e UnsupportedForkError) Error() string { 485 return fmt.Sprintf("unsupported fork %q", e.Name) 486 }