github.com/palisadeinc/bor@v0.0.0-20230615125219-ab7196213d15/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 // Forks table defines supported forks and their chain config. 28 var Forks = map[string]*params.ChainConfig{ 29 "Frontier": { 30 ChainID: big.NewInt(1), 31 Bor: params.BorUnittestChainConfig.Bor, 32 }, 33 "Homestead": { 34 ChainID: big.NewInt(1), 35 HomesteadBlock: big.NewInt(0), 36 Bor: params.BorUnittestChainConfig.Bor, 37 }, 38 "EIP150": { 39 ChainID: big.NewInt(1), 40 HomesteadBlock: big.NewInt(0), 41 EIP150Block: big.NewInt(0), 42 Bor: params.BorUnittestChainConfig.Bor, 43 }, 44 "EIP158": { 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 Bor: params.BorUnittestChainConfig.Bor, 51 }, 52 "Byzantium": { 53 ChainID: big.NewInt(1), 54 HomesteadBlock: big.NewInt(0), 55 EIP150Block: big.NewInt(0), 56 EIP155Block: big.NewInt(0), 57 EIP158Block: big.NewInt(0), 58 DAOForkBlock: big.NewInt(0), 59 ByzantiumBlock: big.NewInt(0), 60 Bor: params.BorUnittestChainConfig.Bor, 61 }, 62 "Constantinople": { 63 ChainID: big.NewInt(1), 64 HomesteadBlock: big.NewInt(0), 65 EIP150Block: big.NewInt(0), 66 EIP155Block: big.NewInt(0), 67 EIP158Block: big.NewInt(0), 68 DAOForkBlock: big.NewInt(0), 69 ByzantiumBlock: big.NewInt(0), 70 ConstantinopleBlock: big.NewInt(0), 71 PetersburgBlock: big.NewInt(10000000), 72 Bor: params.BorUnittestChainConfig.Bor, 73 }, 74 "ConstantinopleFix": { 75 ChainID: big.NewInt(1), 76 HomesteadBlock: big.NewInt(0), 77 EIP150Block: big.NewInt(0), 78 EIP155Block: big.NewInt(0), 79 EIP158Block: big.NewInt(0), 80 DAOForkBlock: big.NewInt(0), 81 ByzantiumBlock: big.NewInt(0), 82 ConstantinopleBlock: big.NewInt(0), 83 PetersburgBlock: big.NewInt(0), 84 Bor: params.BorUnittestChainConfig.Bor, 85 }, 86 "Istanbul": { 87 ChainID: big.NewInt(1), 88 HomesteadBlock: big.NewInt(0), 89 EIP150Block: big.NewInt(0), 90 EIP155Block: big.NewInt(0), 91 EIP158Block: big.NewInt(0), 92 DAOForkBlock: big.NewInt(0), 93 ByzantiumBlock: big.NewInt(0), 94 ConstantinopleBlock: big.NewInt(0), 95 PetersburgBlock: big.NewInt(0), 96 IstanbulBlock: big.NewInt(0), 97 Bor: params.BorUnittestChainConfig.Bor, 98 }, 99 "FrontierToHomesteadAt5": { 100 ChainID: big.NewInt(1), 101 HomesteadBlock: big.NewInt(5), 102 Bor: params.BorUnittestChainConfig.Bor, 103 }, 104 "HomesteadToEIP150At5": { 105 ChainID: big.NewInt(1), 106 HomesteadBlock: big.NewInt(0), 107 EIP150Block: big.NewInt(5), 108 Bor: params.BorUnittestChainConfig.Bor, 109 }, 110 "HomesteadToDaoAt5": { 111 ChainID: big.NewInt(1), 112 HomesteadBlock: big.NewInt(0), 113 DAOForkBlock: big.NewInt(5), 114 DAOForkSupport: true, 115 Bor: params.BorUnittestChainConfig.Bor, 116 }, 117 "EIP158ToByzantiumAt5": { 118 ChainID: big.NewInt(1), 119 HomesteadBlock: big.NewInt(0), 120 EIP150Block: big.NewInt(0), 121 EIP155Block: big.NewInt(0), 122 EIP158Block: big.NewInt(0), 123 ByzantiumBlock: big.NewInt(5), 124 Bor: params.BorUnittestChainConfig.Bor, 125 }, 126 "ByzantiumToConstantinopleAt5": { 127 ChainID: big.NewInt(1), 128 HomesteadBlock: big.NewInt(0), 129 EIP150Block: big.NewInt(0), 130 EIP155Block: big.NewInt(0), 131 EIP158Block: big.NewInt(0), 132 ByzantiumBlock: big.NewInt(0), 133 ConstantinopleBlock: big.NewInt(5), 134 Bor: params.BorUnittestChainConfig.Bor, 135 }, 136 "ByzantiumToConstantinopleFixAt5": { 137 ChainID: big.NewInt(1), 138 HomesteadBlock: big.NewInt(0), 139 EIP150Block: big.NewInt(0), 140 EIP155Block: big.NewInt(0), 141 EIP158Block: big.NewInt(0), 142 ByzantiumBlock: big.NewInt(0), 143 ConstantinopleBlock: big.NewInt(5), 144 PetersburgBlock: big.NewInt(5), 145 Bor: params.BorUnittestChainConfig.Bor, 146 }, 147 "ConstantinopleFixToIstanbulAt5": { 148 ChainID: big.NewInt(1), 149 HomesteadBlock: big.NewInt(0), 150 EIP150Block: big.NewInt(0), 151 EIP155Block: big.NewInt(0), 152 EIP158Block: big.NewInt(0), 153 ByzantiumBlock: big.NewInt(0), 154 ConstantinopleBlock: big.NewInt(0), 155 PetersburgBlock: big.NewInt(0), 156 IstanbulBlock: big.NewInt(5), 157 Bor: params.BorUnittestChainConfig.Bor, 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 Bor: params.BorUnittestChainConfig.Bor, 172 }, 173 "BerlinToLondonAt5": { 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(5), 186 Bor: params.BorUnittestChainConfig.Bor, 187 }, 188 "London": { 189 ChainID: big.NewInt(1), 190 HomesteadBlock: big.NewInt(0), 191 EIP150Block: big.NewInt(0), 192 EIP155Block: big.NewInt(0), 193 EIP158Block: big.NewInt(0), 194 ByzantiumBlock: big.NewInt(0), 195 ConstantinopleBlock: big.NewInt(0), 196 PetersburgBlock: big.NewInt(0), 197 IstanbulBlock: big.NewInt(0), 198 MuirGlacierBlock: big.NewInt(0), 199 BerlinBlock: big.NewInt(0), 200 LondonBlock: big.NewInt(0), 201 Bor: params.BorUnittestChainConfig.Bor, 202 }, 203 "ArrowGlacier": { 204 ChainID: big.NewInt(1), 205 HomesteadBlock: big.NewInt(0), 206 EIP150Block: big.NewInt(0), 207 EIP155Block: big.NewInt(0), 208 EIP158Block: big.NewInt(0), 209 ByzantiumBlock: big.NewInt(0), 210 ConstantinopleBlock: big.NewInt(0), 211 PetersburgBlock: big.NewInt(0), 212 IstanbulBlock: big.NewInt(0), 213 MuirGlacierBlock: big.NewInt(0), 214 BerlinBlock: big.NewInt(0), 215 LondonBlock: big.NewInt(0), 216 ArrowGlacierBlock: big.NewInt(0), 217 Bor: params.BorUnittestChainConfig.Bor, 218 }, 219 } 220 221 // Returns the set of defined fork names 222 func AvailableForks() []string { 223 var availableForks []string 224 for k := range Forks { 225 availableForks = append(availableForks, k) 226 } 227 sort.Strings(availableForks) 228 return availableForks 229 } 230 231 // UnsupportedForkError is returned when a test requests a fork that isn't implemented. 232 type UnsupportedForkError struct { 233 Name string 234 } 235 236 func (e UnsupportedForkError) Error() string { 237 return fmt.Sprintf("unsupported fork %q", e.Name) 238 }