github.com/tacshi/go-ethereum@v0.0.0-20230616113857-84a434e20921/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/tacshi/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 "FrontierToHomesteadAt5": { 94 ChainID: big.NewInt(1), 95 HomesteadBlock: big.NewInt(5), 96 }, 97 "HomesteadToEIP150At5": { 98 ChainID: big.NewInt(1), 99 HomesteadBlock: big.NewInt(0), 100 EIP150Block: big.NewInt(5), 101 }, 102 "HomesteadToDaoAt5": { 103 ChainID: big.NewInt(1), 104 HomesteadBlock: big.NewInt(0), 105 DAOForkBlock: big.NewInt(5), 106 DAOForkSupport: true, 107 }, 108 "EIP158ToByzantiumAt5": { 109 ChainID: big.NewInt(1), 110 HomesteadBlock: big.NewInt(0), 111 EIP150Block: big.NewInt(0), 112 EIP155Block: big.NewInt(0), 113 EIP158Block: big.NewInt(0), 114 ByzantiumBlock: big.NewInt(5), 115 }, 116 "ByzantiumToConstantinopleAt5": { 117 ChainID: big.NewInt(1), 118 HomesteadBlock: big.NewInt(0), 119 EIP150Block: big.NewInt(0), 120 EIP155Block: big.NewInt(0), 121 EIP158Block: big.NewInt(0), 122 ByzantiumBlock: big.NewInt(0), 123 ConstantinopleBlock: big.NewInt(5), 124 }, 125 "ByzantiumToConstantinopleFixAt5": { 126 ChainID: big.NewInt(1), 127 HomesteadBlock: big.NewInt(0), 128 EIP150Block: big.NewInt(0), 129 EIP155Block: big.NewInt(0), 130 EIP158Block: big.NewInt(0), 131 ByzantiumBlock: big.NewInt(0), 132 ConstantinopleBlock: big.NewInt(5), 133 PetersburgBlock: big.NewInt(5), 134 }, 135 "ConstantinopleFixToIstanbulAt5": { 136 ChainID: big.NewInt(1), 137 HomesteadBlock: big.NewInt(0), 138 EIP150Block: big.NewInt(0), 139 EIP155Block: big.NewInt(0), 140 EIP158Block: big.NewInt(0), 141 ByzantiumBlock: big.NewInt(0), 142 ConstantinopleBlock: big.NewInt(0), 143 PetersburgBlock: big.NewInt(0), 144 IstanbulBlock: big.NewInt(5), 145 }, 146 "Berlin": { 147 ChainID: big.NewInt(1), 148 HomesteadBlock: big.NewInt(0), 149 EIP150Block: big.NewInt(0), 150 EIP155Block: big.NewInt(0), 151 EIP158Block: big.NewInt(0), 152 ByzantiumBlock: big.NewInt(0), 153 ConstantinopleBlock: big.NewInt(0), 154 PetersburgBlock: big.NewInt(0), 155 IstanbulBlock: big.NewInt(0), 156 MuirGlacierBlock: big.NewInt(0), 157 BerlinBlock: big.NewInt(0), 158 }, 159 "BerlinToLondonAt5": { 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 LondonBlock: big.NewInt(5), 172 }, 173 "London": { 174 ChainID: big.NewInt(1), 175 HomesteadBlock: big.NewInt(0), 176 EIP150Block: big.NewInt(0), 177 EIP155Block: big.NewInt(0), 178 EIP158Block: big.NewInt(0), 179 ByzantiumBlock: big.NewInt(0), 180 ConstantinopleBlock: big.NewInt(0), 181 PetersburgBlock: big.NewInt(0), 182 IstanbulBlock: big.NewInt(0), 183 MuirGlacierBlock: big.NewInt(0), 184 BerlinBlock: big.NewInt(0), 185 LondonBlock: big.NewInt(0), 186 }, 187 "ArrowGlacier": { 188 ChainID: big.NewInt(1), 189 HomesteadBlock: big.NewInt(0), 190 EIP150Block: big.NewInt(0), 191 EIP155Block: big.NewInt(0), 192 EIP158Block: big.NewInt(0), 193 ByzantiumBlock: big.NewInt(0), 194 ConstantinopleBlock: big.NewInt(0), 195 PetersburgBlock: big.NewInt(0), 196 IstanbulBlock: big.NewInt(0), 197 MuirGlacierBlock: big.NewInt(0), 198 BerlinBlock: big.NewInt(0), 199 LondonBlock: big.NewInt(0), 200 ArrowGlacierBlock: big.NewInt(0), 201 }, 202 "ArrowGlacierToMergeAtDiffC0000": { 203 ChainID: big.NewInt(1), 204 HomesteadBlock: big.NewInt(0), 205 EIP150Block: big.NewInt(0), 206 EIP155Block: big.NewInt(0), 207 EIP158Block: big.NewInt(0), 208 ByzantiumBlock: big.NewInt(0), 209 ConstantinopleBlock: big.NewInt(0), 210 PetersburgBlock: big.NewInt(0), 211 IstanbulBlock: big.NewInt(0), 212 MuirGlacierBlock: big.NewInt(0), 213 BerlinBlock: big.NewInt(0), 214 LondonBlock: big.NewInt(0), 215 ArrowGlacierBlock: big.NewInt(0), 216 GrayGlacierBlock: big.NewInt(0), 217 MergeNetsplitBlock: big.NewInt(0), 218 TerminalTotalDifficulty: big.NewInt(0xC0000), 219 }, 220 "GrayGlacier": { 221 ChainID: big.NewInt(1), 222 HomesteadBlock: big.NewInt(0), 223 EIP150Block: big.NewInt(0), 224 EIP155Block: big.NewInt(0), 225 EIP158Block: big.NewInt(0), 226 ByzantiumBlock: big.NewInt(0), 227 ConstantinopleBlock: big.NewInt(0), 228 PetersburgBlock: big.NewInt(0), 229 IstanbulBlock: big.NewInt(0), 230 MuirGlacierBlock: big.NewInt(0), 231 BerlinBlock: big.NewInt(0), 232 LondonBlock: big.NewInt(0), 233 ArrowGlacierBlock: big.NewInt(0), 234 GrayGlacierBlock: big.NewInt(0), 235 }, 236 "Merge": { 237 ChainID: big.NewInt(1), 238 HomesteadBlock: big.NewInt(0), 239 EIP150Block: big.NewInt(0), 240 EIP155Block: big.NewInt(0), 241 EIP158Block: big.NewInt(0), 242 ByzantiumBlock: big.NewInt(0), 243 ConstantinopleBlock: big.NewInt(0), 244 PetersburgBlock: big.NewInt(0), 245 IstanbulBlock: big.NewInt(0), 246 MuirGlacierBlock: big.NewInt(0), 247 BerlinBlock: big.NewInt(0), 248 LondonBlock: big.NewInt(0), 249 ArrowGlacierBlock: big.NewInt(0), 250 MergeNetsplitBlock: big.NewInt(0), 251 TerminalTotalDifficulty: big.NewInt(0), 252 }, 253 "Shanghai": { 254 ChainID: big.NewInt(1), 255 HomesteadBlock: big.NewInt(0), 256 EIP150Block: big.NewInt(0), 257 EIP155Block: big.NewInt(0), 258 EIP158Block: big.NewInt(0), 259 ByzantiumBlock: big.NewInt(0), 260 ConstantinopleBlock: big.NewInt(0), 261 PetersburgBlock: big.NewInt(0), 262 IstanbulBlock: big.NewInt(0), 263 MuirGlacierBlock: big.NewInt(0), 264 BerlinBlock: big.NewInt(0), 265 LondonBlock: big.NewInt(0), 266 ArrowGlacierBlock: big.NewInt(0), 267 MergeNetsplitBlock: big.NewInt(0), 268 TerminalTotalDifficulty: big.NewInt(0), 269 ShanghaiTime: u64(0), 270 }, 271 "MergeToShanghaiAtTime15k": { 272 ChainID: big.NewInt(1), 273 HomesteadBlock: big.NewInt(0), 274 EIP150Block: big.NewInt(0), 275 EIP155Block: big.NewInt(0), 276 EIP158Block: big.NewInt(0), 277 ByzantiumBlock: big.NewInt(0), 278 ConstantinopleBlock: big.NewInt(0), 279 PetersburgBlock: big.NewInt(0), 280 IstanbulBlock: big.NewInt(0), 281 MuirGlacierBlock: big.NewInt(0), 282 BerlinBlock: big.NewInt(0), 283 LondonBlock: big.NewInt(0), 284 ArrowGlacierBlock: big.NewInt(0), 285 MergeNetsplitBlock: big.NewInt(0), 286 TerminalTotalDifficulty: big.NewInt(0), 287 ShanghaiTime: u64(15_000), 288 }, 289 } 290 291 // AvailableForks returns the set of defined fork names 292 func AvailableForks() []string { 293 var availableForks []string 294 for k := range Forks { 295 availableForks = append(availableForks, k) 296 } 297 sort.Strings(availableForks) 298 return availableForks 299 } 300 301 // UnsupportedForkError is returned when a test requests a fork that isn't implemented. 302 type UnsupportedForkError struct { 303 Name string 304 } 305 306 func (e UnsupportedForkError) Error() string { 307 return fmt.Sprintf("unsupported fork %q", e.Name) 308 }