init.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. "YOLOv3": {
  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. YoloV3Block: big.NewInt(0),
  151. },
  152. // This specification is subject to change, but is for now identical to YOLOv3
  153. // for cross-client testing purposes
  154. "Berlin": {
  155. ChainID: big.NewInt(1),
  156. HomesteadBlock: big.NewInt(0),
  157. EIP150Block: big.NewInt(0),
  158. EIP155Block: big.NewInt(0),
  159. EIP158Block: big.NewInt(0),
  160. ByzantiumBlock: big.NewInt(0),
  161. ConstantinopleBlock: big.NewInt(0),
  162. PetersburgBlock: big.NewInt(0),
  163. IstanbulBlock: big.NewInt(0),
  164. BerlinBlock: big.NewInt(0),
  165. },
  166. }
  167. // Returns the set of defined fork names
  168. func AvailableForks() []string {
  169. var availableForks []string
  170. for k := range Forks {
  171. availableForks = append(availableForks, k)
  172. }
  173. sort.Strings(availableForks)
  174. return availableForks
  175. }
  176. // UnsupportedForkError is returned when a test requests a fork that isn't implemented.
  177. type UnsupportedForkError struct {
  178. Name string
  179. }
  180. func (e UnsupportedForkError) Error() string {
  181. return fmt.Sprintf("unsupported fork %q", e.Name)
  182. }