init.go 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. package tests
  17. import (
  18. "fmt"
  19. "math/big"
  20. "sort"
  21. "github.com/ethereum/go-ethereum/params"
  22. )
  23. // Forks table defines supported forks and their chain config.
  24. var Forks = map[string]*params.ChainConfig{
  25. "Frontier": {
  26. ChainID: big.NewInt(1),
  27. },
  28. "Homestead": {
  29. ChainID: big.NewInt(1),
  30. HomesteadBlock: big.NewInt(0),
  31. },
  32. "EIP150": {
  33. ChainID: big.NewInt(1),
  34. HomesteadBlock: big.NewInt(0),
  35. EIP150Block: big.NewInt(0),
  36. },
  37. "EIP158": {
  38. ChainID: big.NewInt(1),
  39. HomesteadBlock: big.NewInt(0),
  40. EIP150Block: big.NewInt(0),
  41. EIP155Block: big.NewInt(0),
  42. EIP158Block: big.NewInt(0),
  43. },
  44. "Byzantium": {
  45. ChainID: big.NewInt(1),
  46. HomesteadBlock: big.NewInt(0),
  47. EIP150Block: big.NewInt(0),
  48. EIP155Block: big.NewInt(0),
  49. EIP158Block: big.NewInt(0),
  50. DAOForkBlock: big.NewInt(0),
  51. ByzantiumBlock: big.NewInt(0),
  52. },
  53. "Constantinople": {
  54. ChainID: big.NewInt(1),
  55. HomesteadBlock: big.NewInt(0),
  56. EIP150Block: big.NewInt(0),
  57. EIP155Block: big.NewInt(0),
  58. EIP158Block: big.NewInt(0),
  59. DAOForkBlock: big.NewInt(0),
  60. ByzantiumBlock: big.NewInt(0),
  61. ConstantinopleBlock: big.NewInt(0),
  62. PetersburgBlock: big.NewInt(10000000),
  63. },
  64. "ConstantinopleFix": {
  65. ChainID: big.NewInt(1),
  66. HomesteadBlock: big.NewInt(0),
  67. EIP150Block: big.NewInt(0),
  68. EIP155Block: big.NewInt(0),
  69. EIP158Block: big.NewInt(0),
  70. DAOForkBlock: big.NewInt(0),
  71. ByzantiumBlock: big.NewInt(0),
  72. ConstantinopleBlock: big.NewInt(0),
  73. PetersburgBlock: big.NewInt(0),
  74. },
  75. "Istanbul": {
  76. ChainID: big.NewInt(1),
  77. HomesteadBlock: big.NewInt(0),
  78. EIP150Block: big.NewInt(0),
  79. EIP155Block: big.NewInt(0),
  80. EIP158Block: big.NewInt(0),
  81. DAOForkBlock: big.NewInt(0),
  82. ByzantiumBlock: big.NewInt(0),
  83. ConstantinopleBlock: big.NewInt(0),
  84. PetersburgBlock: big.NewInt(0),
  85. IstanbulBlock: big.NewInt(0),
  86. },
  87. "FrontierToHomesteadAt5": {
  88. ChainID: big.NewInt(1),
  89. HomesteadBlock: big.NewInt(5),
  90. },
  91. "HomesteadToEIP150At5": {
  92. ChainID: big.NewInt(1),
  93. HomesteadBlock: big.NewInt(0),
  94. EIP150Block: big.NewInt(5),
  95. },
  96. "HomesteadToDaoAt5": {
  97. ChainID: big.NewInt(1),
  98. HomesteadBlock: big.NewInt(0),
  99. DAOForkBlock: big.NewInt(5),
  100. DAOForkSupport: true,
  101. },
  102. "EIP158ToByzantiumAt5": {
  103. ChainID: big.NewInt(1),
  104. HomesteadBlock: big.NewInt(0),
  105. EIP150Block: big.NewInt(0),
  106. EIP155Block: big.NewInt(0),
  107. EIP158Block: big.NewInt(0),
  108. ByzantiumBlock: big.NewInt(5),
  109. },
  110. "ByzantiumToConstantinopleAt5": {
  111. ChainID: big.NewInt(1),
  112. HomesteadBlock: big.NewInt(0),
  113. EIP150Block: big.NewInt(0),
  114. EIP155Block: big.NewInt(0),
  115. EIP158Block: big.NewInt(0),
  116. ByzantiumBlock: big.NewInt(0),
  117. ConstantinopleBlock: big.NewInt(5),
  118. },
  119. "ByzantiumToConstantinopleFixAt5": {
  120. ChainID: big.NewInt(1),
  121. HomesteadBlock: big.NewInt(0),
  122. EIP150Block: big.NewInt(0),
  123. EIP155Block: big.NewInt(0),
  124. EIP158Block: big.NewInt(0),
  125. ByzantiumBlock: big.NewInt(0),
  126. ConstantinopleBlock: big.NewInt(5),
  127. PetersburgBlock: big.NewInt(5),
  128. },
  129. "ConstantinopleFixToIstanbulAt5": {
  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(0),
  137. PetersburgBlock: big.NewInt(0),
  138. IstanbulBlock: big.NewInt(5),
  139. },
  140. "Berlin": {
  141. ChainID: big.NewInt(1),
  142. HomesteadBlock: big.NewInt(0),
  143. EIP150Block: big.NewInt(0),
  144. EIP155Block: big.NewInt(0),
  145. EIP158Block: big.NewInt(0),
  146. ByzantiumBlock: big.NewInt(0),
  147. ConstantinopleBlock: big.NewInt(0),
  148. PetersburgBlock: big.NewInt(0),
  149. IstanbulBlock: big.NewInt(0),
  150. MuirGlacierBlock: big.NewInt(0),
  151. BerlinBlock: big.NewInt(0),
  152. },
  153. "BerlinToLondonAt5": {
  154. ChainID: big.NewInt(1),
  155. HomesteadBlock: big.NewInt(0),
  156. EIP150Block: big.NewInt(0),
  157. EIP155Block: big.NewInt(0),
  158. EIP158Block: big.NewInt(0),
  159. ByzantiumBlock: big.NewInt(0),
  160. ConstantinopleBlock: big.NewInt(0),
  161. PetersburgBlock: big.NewInt(0),
  162. IstanbulBlock: big.NewInt(0),
  163. MuirGlacierBlock: big.NewInt(0),
  164. BerlinBlock: big.NewInt(0),
  165. LondonBlock: big.NewInt(5),
  166. },
  167. "London": {
  168. ChainID: big.NewInt(1),
  169. HomesteadBlock: big.NewInt(0),
  170. EIP150Block: big.NewInt(0),
  171. EIP155Block: big.NewInt(0),
  172. EIP158Block: big.NewInt(0),
  173. ByzantiumBlock: big.NewInt(0),
  174. ConstantinopleBlock: big.NewInt(0),
  175. PetersburgBlock: big.NewInt(0),
  176. IstanbulBlock: big.NewInt(0),
  177. MuirGlacierBlock: big.NewInt(0),
  178. BerlinBlock: big.NewInt(0),
  179. LondonBlock: big.NewInt(0),
  180. },
  181. "ArrowGlacier": {
  182. ChainID: big.NewInt(1),
  183. HomesteadBlock: big.NewInt(0),
  184. EIP150Block: big.NewInt(0),
  185. EIP155Block: big.NewInt(0),
  186. EIP158Block: big.NewInt(0),
  187. ByzantiumBlock: big.NewInt(0),
  188. ConstantinopleBlock: big.NewInt(0),
  189. PetersburgBlock: big.NewInt(0),
  190. IstanbulBlock: big.NewInt(0),
  191. MuirGlacierBlock: big.NewInt(0),
  192. BerlinBlock: big.NewInt(0),
  193. LondonBlock: big.NewInt(0),
  194. ArrowGlacierBlock: big.NewInt(0),
  195. },
  196. "GrayGlacier": {
  197. ChainID: big.NewInt(1),
  198. HomesteadBlock: big.NewInt(0),
  199. EIP150Block: big.NewInt(0),
  200. EIP155Block: big.NewInt(0),
  201. EIP158Block: big.NewInt(0),
  202. ByzantiumBlock: big.NewInt(0),
  203. ConstantinopleBlock: big.NewInt(0),
  204. PetersburgBlock: big.NewInt(0),
  205. IstanbulBlock: big.NewInt(0),
  206. MuirGlacierBlock: big.NewInt(0),
  207. BerlinBlock: big.NewInt(0),
  208. LondonBlock: big.NewInt(0),
  209. ArrowGlacierBlock: big.NewInt(0),
  210. GrayGlacierBlock: big.NewInt(0),
  211. },
  212. "Merged": {
  213. ChainID: big.NewInt(1),
  214. HomesteadBlock: big.NewInt(0),
  215. EIP150Block: big.NewInt(0),
  216. EIP155Block: big.NewInt(0),
  217. EIP158Block: big.NewInt(0),
  218. ByzantiumBlock: big.NewInt(0),
  219. ConstantinopleBlock: big.NewInt(0),
  220. PetersburgBlock: big.NewInt(0),
  221. IstanbulBlock: big.NewInt(0),
  222. MuirGlacierBlock: big.NewInt(0),
  223. BerlinBlock: big.NewInt(0),
  224. LondonBlock: big.NewInt(0),
  225. ArrowGlacierBlock: big.NewInt(0),
  226. MergeNetsplitBlock: big.NewInt(0),
  227. TerminalTotalDifficulty: big.NewInt(0),
  228. },
  229. }
  230. // Returns the set of defined fork names
  231. func AvailableForks() []string {
  232. var availableForks []string
  233. for k := range Forks {
  234. availableForks = append(availableForks, k)
  235. }
  236. sort.Strings(availableForks)
  237. return availableForks
  238. }
  239. // UnsupportedForkError is returned when a test requests a fork that isn't implemented.
  240. type UnsupportedForkError struct {
  241. Name string
  242. }
  243. func (e UnsupportedForkError) Error() string {
  244. return fmt.Sprintf("unsupported fork %q", e.Name)
  245. }